Playing with leb_complete theorem from IndProp I found the following weirdness:
Theorem leb_complete : forall n m,
n <=? m = true -> n <= m.
Proof.
induction n as [|n'].
- intros. apply O_le_n.
- induction m as [| m'] eqn:Em.
+ intros H. discriminate H.
+ intros H. apply n_le_m__Sn_le_Sm.
It produces the following:
1 subgoal (ID 155)
n' : nat
IHn' : forall m : nat, (n' <=? m) = true -> n' <= m
m, m' : nat
Em : m = S m'
IHm' : m = m' -> (S n' <=? m') = true -> S n' <= m'
H : (S n' <=? S m') = true
============================
n' <= m'
Everything is fine. Now when I run apply IHn'.
it works and produces the following:
(n' <=? m') = true
Why does it work? In IHn' we have
n' <= m - in IHn'
n' <= m' - in the goal
Variable m and m'
are different, but it still works. When I tried
`rewrite -> Em in IHn'.
it gave an error:
Found no subterm matching "m" in IHn'.
But there is variable "m" in IHn'! I am confused, please, explain what's going on here.