-1

I have the following goals:

  f : bool -> bool
  b : bool
  H1 : f true = true
  H2 : f true = false
  H3 : f false = false
  ============================
   false = true

Now using H1 and H2, I want to prove the goal using contradiction. I know about inversion tactic, but I don't think I can apply it here. Any idea on how to proceed from here ?

This is the fully reproducible code where you can get the above goals:

Theorem bool_fn_applied_thrice :
  forall (f : bool -> bool) (b : bool),
  f (f (f b)) = f b.
Proof.
  intros f b.
  destruct (f b) eqn:H1.
  - destruct (f true) eqn:H2.
    + rewrite -> H2.
      reflexivity.
    + destruct (f false) eqn:H3.
      * reflexivity.
      * destruct b in H1.
        {

        }

Also would be interested to know if there is an simpler way of solving the above theorem than the above approach (Just the hints. One another way of approaching is using destruct on b initially which actually proves the theorem after 5 usage of destructs).

Sibi
  • 47,472
  • 16
  • 95
  • 163
  • 1
    This is [related](http://stackoverflow.com/questions/1674018/proving-f-f-bool-bool)(see the answers). – Anton Trunov Apr 01 '17 at 05:44
  • Thanks to @Ptival for noticing this is an exercise from SF. OP: it's kind of dishonest to post a question about such an exercise without linking to the source. We're having lots of these questions which ask about SF without telling it these days! – Zimm i48 Apr 02 '17 at 10:34
  • @Zimmi48 I don't see what's the problem here. I'm reading that book and solving the problems whenever I get spare time apart from my day job. Why do you think it's *dishonest* to post the question without linking to the source ? – Sibi Apr 02 '17 at 11:54
  • The word is a bit too strong but why didn't you put a link in the first place? Not referencing the source might be considered unfair to the authors / copyright infringement, and there is a risk of some answer containing a complete solution while the authors ask that people refrain from putting solutions on the Internet. For instance, if there wasn't already an answer I might have done just that (not being aware of the source). This problem has occurred before. – Zimm i48 Apr 02 '17 at 12:22
  • @Zimmi48 > The word is a bit too strong but why didn't you put a link in the first place? - Because I didn't think (and still think) it is necessary. > ot referencing the source might be considered unfair to the authors / copyright infringement, - I'm not sure how it is unfair or does copyright infringement. I describe in the question what problem I have and what I have attempted and ask if there is a better solution. In fact, the linked question by Anton also doesn't have any link to SF. – Sibi Apr 02 '17 at 12:39
  • 1
    > while the authors ask that people refrain to put solutions on the Internet. - I agree with this. But I don't know what's the best way to ask question then. Infact, Pitval's answer was enough to find me a solution. Also right now, there are already many solutions for SF book in the web. So, if someone is really looking for an answer, then he is gonna get it. – Sibi Apr 02 '17 at 12:39

1 Answers1

2

There are many ways to proceed, and since this is an exercise from Software Foundations that might be used as homework, I will not give a full answer.

Indeed H1 and H2 contradict each other.

The way I expect you know about at this point is using rewrite. For instance, rewrite H1 in H2. will replace f true with true in H2, yielding H2 : true = false. You can then do either inversion H2 or discriminate.

I'm not sure there's a best way of going about the proof, there are essentially 8 cases to consider and only little room for shortcutting those.

Ptival
  • 9,167
  • 36
  • 53
  • 2
    I would favor `discriminate` over `inversion` for several reasons: `discriminate` makes it clear that the result is obtained by contradiction and it is a simpler tactic (the generated proof term is much simpler). – Zimm i48 Apr 02 '17 at 10:36
  • Of course, there is also a solution with just one `rewrite` in the goal and one `assumption` but it does not look like a proof by contradiction. – Zimm i48 Apr 02 '17 at 10:38