Vector : t A n = t A (n+0)?
Question
I want trivial lemma below.
Require Import Coq.Vectors.Vector.A: Type
n: natt A n = t A (n + 0)A: Type
n: natt A n = t A (n + 0)A: Typet A 0 = t A (0 + 0)A: Type
n: nat
IHn: t A n = t A (n + 0)t A (S n) = t A (S n + 0)Abort.A: Type
n: nat
IHn: t A n = t A (n + 0)t A (S n) = t A (S n + 0)
How do I simplify (n+0) to n?
Answer
When you want to prove an equality between complex structures it can often be useful to use the f_equal tactic which will ask to prove that the subterms are equal. For instance here it turns t A n = t A (n+0) into n = n + 0. Once you have this, you can use the very useful lia tactic to deal with equalities on natural numbers.
Require Import Coq.Vectors.Vector. From Coq Require Import Lia.A: Type
n: natt A n = t A (n + 0)A: Type
n: natt A n = t A (n + 0)lia. Qed.A: Type
n: natn = n + 0
(Notice that you have to require the Lia module to use lia.)
In some cases you will not be proving an equality directly so it might be useful to replace n+0 with n:
A: Type
n: natt A n = t A (n + 0)(* f_equal. lia. *)A: Type
n: natt A n = t A (n + 0)reflexivity. Qed.A: Type
n: natt A n = t A n