1

Getting started with Coq and "Software Foundation" problems, I run into the following example:

Theorem plus_O_n : forall n : nat, 0 + n = n.
Proof.
  intros n. simpl. reflexivity.  Qed.

Which is proved just fine. When however, I try the right-hand side equation;

Theorem plus_n_O : forall n, n = n + 0.
Proof.
  intros n. simpl. (* Doesn't do anything! *)

And this in fact, is one of the excercises in the book, why does simpl not work in that case. I was trying to be smart, so I reversed the equation using symmetry.

Theorem plus_n_O : forall n, n = n + 0.
Proof.
  intros n. simpl. symmetry. simpl. (* Doesn't do anything still!!! *)

But still no bueno. It's especially weird because symmetry works as expected and brings my goal to the same form as plus_O_n.

Anton Trunov
  • 15,074
  • 2
  • 23
  • 43
rausted
  • 951
  • 5
  • 21
  • 2
    Look closer, `symmetry` won't get you the same goal than before. Then look at how `plus` is defined, then you will see that indeed your goal cannot be simplified, you need to perform additional steps. – ejgallego Oct 29 '17 at 01:44
  • Could it be that the commutative property is not defined yet for my addition? Looks like `0+n` is treated different that `n+0` – rausted Oct 29 '17 at 01:51
  • 2
    Indeed `0+n` is treated different than `n+0`. "+" is a function, you can see its "rules" issuing `Print plus`. Then, you should find your answer in SF. – ejgallego Oct 29 '17 at 02:10
  • you'd better walk it through from the beginning of of nat's definition. it helps you understand algebra is nothing but logical consequences of a bunch of rules. to finish your proof, you need to use a specific proof technique. – Jason Hu Oct 29 '17 at 02:19
  • Try to do the job of the evaluator and compute `plus 0 n` manually, then do `plus n 0`. What's the difference? – Anton Trunov Oct 29 '17 at 09:17

0 Answers0