Inverting a clearly false hypothesis does not prove a lie

I am trying to prove a trivial lemma, which is a recreation of a situation in which I found myself in another place.

Lemma Sn_neq_n: forall n, S n <> n.

The proof seems as simple as it gets:

Proof. unfold not. intros.

Now my goal state shows:

n : nat
H : S n = n
===================
 False

Well, obviously, that S ncannot be combined with n, so I would just have to invert this hypothesis:

inversion H.

But instead of solving the goal, my state now shows:

n : nat
H : S n = n
H0 : S n = n
===================
 False    

AND? I am now in an endless cycle. I can inversion H0, and I just get H1, etc.

I was able to prove the lemma by induction:

unfold not. intros. induction n.
Case "n = 0". inversion H.
Case "n > 0". inversion H. apply IHn. apply H1.

But this is a little stupid, because, apparently, the unification algorithm, which allows the use of reflexive equality in the first place, should not be combined S nwith n.

What's going on here?

+4
1

, inversion , , .

(co), , Coq, , , , , (, Coq ). , 1 <> 0 Coq , :

Definition one_neq_zero (p : 1 = 0) : False :=
  match p in _ = n return match n with
                          | 0 => False
                          | _ => True
                          end
  with
  | eq_refl => I (* "I" is the only constructor of the True proposition *)
  end.

return match . :

  • p, .
  • , .
  • , 0. n, , 0. - , Coq.
  • "" Coq: , False , (.. n = 0), , - .
  • match, - , return, , in.
  • , eq_refl. , n = 1. 1 n , True, - True, .
  • , p 0, Coq , False, .

, 0 , Coq , , . S n = n: n , .

n = S n , Coq . , , . , in _ = m return match m with 0 => True | _ => False end, eq_refl - match n with 0 => True | _ => False end, .

, , Coq "", , , , , . , , S n <> n, , , , . , , n = m - , - , n m . , nat , S n = n , , n.

+4

Source: https://habr.com/ru/post/1570213/


All Articles