Theorem add_0_r : forall n:nat, n + 0 = n.
Proof.
intros n. induction n as [| n' IHn'].
- (* n = 0 *) reflexivity.
- (* n = S n' *) simpl. rewrite -> IHn'. reflexivity. Qed.
Theorem plus_n_Sm : forall n m : nat,
S (n + m) = n + (S m).
Proof.
intros n m. induction m as [| m' IHn']. rewrite -> add_0_r. rewrite <- sum.
The last tactic rewirte <- sum
does not work. This is the goal:
n: ℕ
-------------
S(n) = n + 1
I don't know how to rewrite n+1
as S(n)
. I think that n+1
is just a notation for S(n)
, right?
If you look at the definition of
+
as follows, you can see that it is defined by induction on its first argument:As a result
1 + n
is indeed convertible toS n
(you can see that usingEval cbn in 1 + ?[n].
) but notn + 1
(if youunfold Nat.add.
you will obtain a pattern match stuck on the variablen
).For your proof, that specific definition of
+
means that you might reconsider your approach and try to do your proof by induction onn
rather thanm
(paying attention to have the right induction hypothesis).