0

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.

user4035
  • 22,508
  • 11
  • 59
  • 94

1 Answers1

4

The m in IHn' is just a dummy variable. IHn' quantifies over all natural numbers: forall m : nat, [...]. In particular, m' is a nat, so the hypothesis applies with m replaced with m'.

The m in IHn' is not the same as the one in your context (and in particular not the same as m in Em : m = S m'). They just happen to have the same name.

SCappella
  • 9,534
  • 1
  • 26
  • 35