Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prove False from obviously contradictory assumptions

Tags:

proof

coq

Suppose I want to prove following Theorem:

Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False.

This one is trivial since m cannot be both successor and zero, as assumed. However I found it quite tricky to prove it, and I don't know how to make it without an auxiliary lemma:

Lemma succ_neq_zero_lemma : forall n : nat, O = S n -> False.
Proof.
  intros.
  inversion H.
Qed.

Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False.
Proof.
  intros.
  symmetry in H.
  apply (succ_neq_zero_lemma n).
  transitivity m.
  assumption.
  assumption.
Qed.

I am pretty sure there is a better way to prove this. What is the best way to do it?

like image 685
Michal Seweryn Avatar asked Mar 26 '15 18:03

Michal Seweryn


2 Answers

You just need to substitute for m in the first equation:

Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False.
Proof.
intros n m H1 H2; rewrite <- H2 in H1; inversion H1.
Qed.
like image 197
Arthur Azevedo De Amorim Avatar answered Nov 23 '22 07:11

Arthur Azevedo De Amorim


There's a very easy way to prove it:

Theorem succ_neq_zero : forall n m: nat, S n = m -> 0 = m -> False.
Proof.
  congruence.
Qed.

The congruence tactic is a decision procedure for ground equalities on uninterpreted symbols. It's complete for uninterpreted symbols and for constructors, so in cases like this one, it can prove that the equality 0 = m is impossible.

like image 41
Gilles 'SO- stop being evil' Avatar answered Nov 23 '22 07:11

Gilles 'SO- stop being evil'