Equality on inductive types
Question
How do I prove the following trivial lemma:
Require Import Vector.forall (A : Type) (x : t A 0), x = nil AAbort.forall (A : Type) (x : t A 0), x = nil A
FAQ recommends decide equality and discriminate tactics but I could not find a way to apply either of them. For the reference, here is inductive definition:
Answer
What you want to do is to invert on x. Unfortunately, it turns out that general inversion of dependently typed hypotheses is undecidable, see Adam Chlipala's CPDT. You can pattern match on the structure manually though, e.g. with:
forall (A : Type) (x : t A 0), x = nil Aforall (A : Type) (x : t A 0), x = nil AA: Type
x: t A 0x = nil AA: Type
x: t A 0nil A = nil AA: Type
x: Vector.t A 0
a: A
n: nat
t: Vector.t A nIDPropreflexivity.A: Type
x: t A 0nil A = nil Aexact @id. Qed.A: Type
x: Vector.t A 0
a: A
n: nat
t: Vector.t A nIDProp
In many cases you can also use the tactic dep_destruct provided by CPDT. In that case your proof simply becomes:
Require Import CpdtTactics.
Lemma t0_nil : forall A (x : t A 0), x = nil A.
intros. dep_destruct x. reflexivity.
Qed.
A: An elegant solution by Pierre Boutillier, taken from this Coq-club post:
Definition t0_nil A (x : t A 0) : x = nil A := match x with nil _ => eq_refl end.