0

I have a hypothesis that is clearly wrong and I would like to use that to prove False. In this case I have Hx: 0 * 0 = 2 and I have False in my goal. How would I start to do it?

Image from CoqIDE: enter image description here

Ali Esmailpor
  • 1,209
  • 3
  • 11
  • 22
LeBaguette
  • 11
  • 1

5 Answers5

0

You can use the easy tactic:

Goal 0 * 0 = 2 -> False. Proof. easy. Qed.
Arthur Azevedo De Amorim
  • 23,012
  • 3
  • 33
  • 39
0

A manual approach, for completeness:

Goal 0 * 0 = 2 -> False.
Proof.
  intro H.
  inversion H.
Qed.

(Disclaimer: I'm a relative beginner at Coq myself, so apologies if I get any details incorrect—please let me know so I can improve the answer!)

This works because 0 * 0 = 2 evaluates to 0 = 2, and inverting that hypothesis breaks it down into its different possible constructors (like a smarter version of destruct). The only possible constructor for eq is eq_refl : forall a, a = a. So, Coq realizes that eq_refl is the only possible constructor that could have been used to make a hypothesis of the form 0 = 2. As such, Coq will try to find the value of a, as part of the inversion process. But, applying this to 0 = 2, it gets x = 0 and x = 2! Because 0 = O and 2 = S (S O) are made up of entirely different constructors, Coq recognizes this as a contradiction and considers your proof complete.

0

Yet another solution for completeness: cbn ; congruence. Indeed 0 * 0 reduces to 0 (i.e. O), which is different from 2 (S (S O)) by disjointness of the constructors of the type nat. The first tactic reduces (simplifies) the goal, the second one exploits disjointness to deduce the contradiction.

Goal 0 * 0 = 2 -> False.
  cbn. congruence.
Qed.
Maëlan
  • 3,586
  • 1
  • 15
  • 35
0

Yet another solution, which applies in this specific example: lia. lia stands for Linear Integer Arithmetic. This powerful tactic considers all hypotheses consisting of, well, linear integer arithmetic (be it equations or inequalities) and uses them to solve an arithmetic goal, or any goal if the arithmetic hypotheses are contradictory.

You have to load a library.

Require Import Coq.micromega.Lia.

Goal 0 * 0 = 2 -> False.
  lia.
Qed.

With Coq there are always a bunch of alternatives.

Maëlan
  • 3,586
  • 1
  • 15
  • 35
0

If you want to understand how it works "behind the scenes", this answer may be useful.

larsr
  • 5,447
  • 19
  • 38