1

I believe the title is pretty self explanatory : https://en.wikipedia.org/wiki/Conditional_proof

I would like to have a tactic where I assume a proposition and proceed to find another one, if succeeded, then I have found that the first proposition implies the second one and this is put as an hypothesis in the context.

So for example Ltac cp P Q creates a subgoal Qand puts Pin the context. If I can indeed reach the subgoal Q, then the subgoal is discharged and P->Q is added to the context. How can I achieve this ?

Edit: It is clear that while proving assert (P->Q). intro. does the job, but I cannot combine them into a Ltac tactic, it gives an error of No focused proof (No proof-editing in progress).

mlg556
  • 419
  • 3
  • 13

2 Answers2

2

To define new tactics, you need to compose them with ;.

Ltac cp P Q := assert (P -> Q); [ intro | ].
  (* Use intro in the first subgoal of assert *) 
Li-yao Xia
  • 31,896
  • 2
  • 33
  • 56
2

There is already such a tactic, it's called enough, as "it is enough to show that P". It assumes P and you now get to finish your proof using P. When you're done, you have to prove P.

If it is easy to finish, you can use by (in the same as for assert). I often do enough (bla bla) by (subst; auto). or something similar, which leaves me with the goal bla bla.

You may also find this tactic useful, i.e. if you don't want to type the entire complicated antecedent into the enough statement:

Ltac postpone_antecedent H :=
  match type of H with  ?A -> _ =>
    let Q := fresh in enough A as Q ; [specialize (H Q) | ]
  end.
larsr
  • 5,447
  • 19
  • 38