0

I am working on a tactic that would create two new hypothesis

x0 : D
x0_Linked : P x0

from an hypothesis of that form

H : forall x : D, P x

Here is my Ltac code :

Ltac mytactic h t x :=
    match type of h with
    | (forall (_: ?X1), _) =>  evar (x : X1) ; pose ( t := h x )
    | _ => idtac "Erreur: Aucun pour tout decomposable dans l'hypothese."
    end
.

were h is the hypothesis to decompose, x the name of the new variable and t the name of the new hypothesis. The tactic works as intended but at the end of the proof I get this :

testproof< exact H0. 
All the remaining goals are on the shelf.

1 subgoal

subgoal 1 is:
 D

The evar tactic seem to have created a new type named D instead of using the existing one. Note that if I use

Coq< Variable x0 : D.

in coqtop instead it works perfectly.

L. Soret
  • 169
  • 10
  • What happens if your hypothesis is of the form `forall x : Empty_set, P x`? – Anton Trunov Jul 03 '17 at 10:44
  • I am working on standard first-order logic so the interpretation domain should be non-empty. – L. Soret Jul 04 '17 at 07:04
  • 1
    Elimination on `forall` does not work this way. You can build a term of type `D` and then apply `H` to it, because `H` is a function taking an element `x` of the domain and producing a proof of `P x`. In other words: you can't ask a function to produce its input argument. `Variable x0 : D.` works because you postulate that `x0` exists. HTH. – Anton Trunov Jul 04 '17 at 07:12
  • I see. Maybe using `Variable x0 : D.` followed by a tactic `mytactic h t x` same as in my initial question but without the evar and `x` referring to `x0` would work if I could automatize it. Can I do such a thing ? Not with Ltac from what I know. – L. Soret Jul 04 '17 at 07:34
  • Not sure if I understand what you mean. There are a couple of tactics that might help: `pose proof` and `specialize`. E.g. `pose proof (H x0).` adds a new hypothesis which is a proof of `P x0`, and `specialize (H x0)` changes `H : forall x, P x` into `H : P x0`. – Anton Trunov Jul 04 '17 at 07:49
  • I want that a user would not have to enter `Variable x0 : D.` in order to finish proofs were such declarations are needed like for exemple in section 1.4.3 ( page 23 ) of [this Coq tutorial](https://coq.inria.fr/distrib/current/files/Tutorial.pdf). So I want to know if there is a way of combining the two lines `Variable x0 : D.` and `mytactic h t x0.` ( `x0` is a `constr` here ) into one line of code `declarationAndTac h t x0` ( `x0` is a `ident` here ). – L. Soret Jul 04 '17 at 08:22
  • 1
    You can't postulate new variables inside proofs (if you try you'll see something like `Variable d' is not visible from current goals`). Recall that after you close your current section you get: `weird : forall (D : Type) (P : D -> Prop), D -> (forall x : D, P x) -> exists x : D, P x`, so with `Variable` you are essentially just writing you parameters in a different way. You can also be a bit more explicit with `Lemma weird (D : Type) (P : D -> Prop) : inhabited D -> (forall x : D, P x) -> exists x, P x.` – Anton Trunov Jul 04 '17 at 08:48
  • Yes I just experienced `Variable d' is not visible from current goals` 5 minutes ago. I guess I will have to create the x0 variable before the proof and narrow down `mytactic` to a simple `pose ( t := h x0 )`. Thanks for the enlightenment. – L. Soret Jul 04 '17 at 09:01

0 Answers0