I have just run into the issue of the Coq induction
discarding information about constructed terms while reading a proof from here.
The authors used something like:
remember (WHILE b DO c END) as cw eqn:Heqcw.
to rewrite a hypothesis H
before the actual induction induction H
. I really don't like the idea of having to introduce a trivial equality as it looks like black magic.
Some search here in SO shows that actually the remember
trick is necessary. One answer here, however, points out that the new dependent induction
can be used to avoid the remember
trick. This is nice, but the dependent induction
itself now seems a bit magical.
I have a hard time trying to understand how dependent induction
works. The documentation gives an example where dependent induction
is required:
Lemma le_minus : forall n:nat, n < 1 -> n = 0.
I can verify how induction
fails and dependent induction
works in this case. But I can't use the remember
trick to replicate the dependent induction
result.
What I tried so far to mimic the remember
trick is:
Require Import Coq.Program.Equality.
Lemma le_minus : forall n:nat, n < 1 -> n = 0.
intros n H. (* dependent induction H works*)
remember (n < 1) as H0. induction H.
But this doesn't work. Anyone can explain how dependent induction
works here in terms of the remember
-ing?