Search code examples
coqcoq-tactic

How to prove by contradicting the goal?


Require Import Arith.

Goal forall a b c: nat, nat_eq a b -> nat_eq b c -> nat_eq a c.
Proof.
  intros a b c H0 H1.
1 subgoal
a, b, c : nat
H0 : eq_nat a b
H1 : eq_nat b c
______________________________________(1/1)
eq_nat a c

This is just an example I made up and my question is, if I want to prove it by contradicting the goal, saying assume that (~ eq_nat a c) is true, then prove by finding contradiction in the context, how should I achieve that? Not able to find a way to do that, any hint about what tactic I should use?


Solution

  • This would require double negation elimination (not not goal -> goal) to work. If you have that as an axiom (say Axiom dne: forall P: Prop, ~~P -> P), then the tactic apply dne can be used.

    To be precise,

    Require Import Arith.
    
    Axiom dne: forall P: Prop, ~~P -> P.
    
    Goal forall a b c: nat, nat_eq a b -> nat_eq b c -> nat_eq a c.
    Proof.
      intros a b c H0 H1.
      apply dne; intro H2.
      (* now the context is
         1 subgoal
         a, b, c : nat
         H0 : eq_nat a b
         H1 : eq_nat b c
         H2 : ~ eq_nat a c
         ______________________________________(1/1)
         False
      *)
    Abort.