3

If I have a hypothesis in my proof context that looks like H: True -> P and I want to convert it to H: P, what's the easiest way to do this? I tried simpl in H but it does nothing, and the only way I've found is the extremely unsatisfactory pose proof (H Coq.Init.Logic.I) as H. Isn't there a simpler way?

psquid
  • 747
  • 1
  • 5
  • 17

1 Answers1

4

There are two ways to work with this, besides using pose proof.

Using specialize.

This tactics allows you to provide arguments to you hypotheses. In you case you could do

specialize (H I).

or even

specialize H with (1 := I).

and you can use as if you want to create a copy rather than instantiate H directly.

Using forward.

I think this is what you want here. forward H. will ask you to prove the first hypothesis of H. So you will do something like this:

forward H.
- auto.
- (* Then resume with H : P *)

but you can also provide it with a (goal-closing) tactic:

forward H by auto.
(* Now you have one goal, and H has type P *)

forward is—as of yet—not part of the standard library. It can however be defined pretty easily (here is the definition from the MetaCoq library).

Ltac forward_gen H tac :=
  match type of H with
  | ?X -> _ => let H' := fresh in assert (H':X) ; [tac|specialize (H H'); clear H']
  end.

Tactic Notation "forward" constr(H) := forward_gen H ltac:(idtac).
Tactic Notation "forward" constr(H) "by" tactic(tac) := forward_gen H tac.

Note that simpl here doesn't work because it's not really a tactic to simplify hypotheses in the usual sense, it's really just a tactic to apply some computation rules, it basically evaluates the goal or the hypothesis you apply it on. True -> P does not reduce to P because it would then take one fewer argument.

psquid
  • 747
  • 1
  • 5
  • 17
Théo Winterhalter
  • 4,908
  • 2
  • 18
  • 34
  • Do I need to import something to use the `forward` tactic? I'm getting `Error: The reference forward was not found in the current environment.` – psquid Mar 24 '20 at 09:33
  • 1
    I was using it without knowing it was part of the stdlib! I will edit my answer to provide its definition, sorry! – Théo Winterhalter Mar 24 '20 at 13:34
  • Why not add a section with asset? `assert (H := H I).` And perhaps explain why `simpl` is not an option in this setting? – Tiago Cogumbreiro Mar 24 '20 at 18:34
  • I do explain why `simpl` is not an option, or do you think it needs more details? I wasn't aware or `assert (H := H I)`. – Théo Winterhalter Mar 24 '20 at 19:53
  • According to the definition, it behaves as `specialize` in that case so I don't really see the point, it's just a confusing way of writing it. https://coq.inria.fr/refman/proof-engine/tactics.html#coq:tacn.assert – Théo Winterhalter Mar 24 '20 at 19:55
  • What is the difference here between `specialize` and `pose`? – gust Dec 21 '20 at 14:42
  • `specialize (h x)` will replace hypothesis `h` with its application to `x`. `pose (h x)` will create a *new* hypothesis. – Théo Winterhalter Dec 21 '20 at 20:19