6

My question is: why 'intuition' works in my example?

I'm trying to prove

Lemma eqb_false : forall n m : nat, eqb n m = false -> n <> m.

At the last step, I can see

n : nat
IHn : forall m : nat, (n =? m) = false -> n <> m
m : nat
IHm : (S n =? m) = false -> S n <> m
============================
 (n =? m) = false -> S n <> S m

Then 'intuition'/'firstorder'/'auto' all work on the current goal.

But why do they work? The Coq manual says they will some search work. Does it mean it can be rewritten with some other simple tactics?

Thank you!

EDIT: It can be seen that I applied induction on n and m in the proof above. According to @Vinz's answer, it has no necessity to conduct such an induction process. intros at the first step and intro at the goal of n <> m, it will generate a contradictory hypothesis to H.

1 Answer 1

8

Tactics like intuition, firstorder or auto try to solve your goal with some automatic reasoning, but you can always replace one of their proofs by one you crafted by hand.

In previous version of Coq, you could do info intuition to get the proof script, but I heard it doesn't work anymore. Maybe you could try it. You can always Show Proof after intuition to get the proof term, but it won't give you the tactics used.

In your particular case, the proof is quite easy by introducing the S n = S m from the end of your goal, using injection on it to get n = m in the context, and then derive a contradiction with (n =? m) = false.

EDIT for xywang: any statement of the shape A <> B is just syntactic sugar for A = B -> False. Therefore, the intros tactic can be applied to any goal P1 -> ... Pn -> A <> B, with n+1 (note the +1) names. For example consider:

=============================
 P -> Q -> A <> B

by applying the tactic intros p q eqAB., the goal becomes

p : P
q : Q
eqAB : A = B
=============================
False
4
  • Could you please elaborate on how to introduce "S n = S m" from the current goal? I know the reason to do that but not know which tactics could work...
    – xywang
    May 19, 2015 at 14:48
  • xywang, I edited my post with more information, do not hesitate to ask more, or to read an introduction to Coq, like the Software Foundation tutorial by Benjamin Pierce.
    – Vinz
    May 19, 2015 at 15:43
  • Please let me make the answer clearer : on deriving a contradiction with (n =? m) = false, I should re-intro (n = m) back as a hypothesis, then apply lemma beq_nat_false on (n =? m) = false and finally 'contradiction', right?
    – xywang
    May 19, 2015 at 16:33
  • I don't have a Coq client right now, but this seems right
    – Vinz
    May 20, 2015 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.