coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: scott constable <sdconsta AT syr.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Question about tacargs
- Date: Mon, 4 Apr 2016 09:29:35 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=sdconsta AT syr.edu; spf=None smtp.mailfrom=sdconsta AT syr.edu; spf=None smtp.helo=postmaster AT smtp1.syr.edu
- Ironport-phdr: 9a23:8vztoxdE3pyaDKKg9JslHi9qlGMj4u6mDksu8pMizoh2WeGdxc65YR7h7PlgxGXEQZ/co6odzbGG4+a7Bideut6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDivcaMKFsTzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IAu3GePEzSqUdBzA7OUg04tfqvF/NV1ih/HwZB34dlQZUSwPC6grmV531v2OureZ23y+BIcTeVqEuHzmu8vE4G1fTlC4bOmthoynsgctqgfcDrQ==
Jonathan,
Thanks for the quick response. I have two follow-up questions:
- Based on your description, it seems as though arguments to Ltac sometimes are call-by-value (i.e. the first exactor') and at other times are call-by-name (i.e. the second exactor'). Is this statement correct?
- If the answer to (1) was "Yes," then is there a general rule to determine whether an argument will be evaluated by call-by-value or call-by-name?
Thanks again,
~Scott
On Sun, Apr 3, 2016 at 5:29 PM, Jonathan Leivent <jonikelee AT gmail.com> wrote:
On 04/03/2016 05:17 PM, scott constable wrote:
In the following, why does attempt1 succeed, whereas attempt2 fails? I followed
through with the Ltac debugger, and found that extractor' is never executed
after intros, but I cannot come up with an explanation as to why.
Try rewriting exactor' as:
Ltac exactor' := idtac;
match goal with
| [ H : ?P |- ?P ] => exact H
| _ => idtac
end.
What's happening with the original exactor' is that because it's body a raw match tactical, it can be evaluated in the arg position of my_solve prior to calling my_solve - and it evaluates to the tactic idtac there (because the intros haven't happened yet). In exactor, the try tactical prevents this early evaluation. In the above rewrite of exactor', the sequence tactical ";" prevents the early evaluation.
-- Jonathan
Ltac my_solve m :=
intros; m.
Ltac exactor := try
match goal with
| [ H : ?P |- ?P ] => exact H
end.
Ltac exactor' :=
match goal with
| [ H : ?P |- ?P ] => exact H
| _ => idtac
end.
Theorem attempt1 : forall (A : Type) (x y : A),
x = y -> x = y.
Proof. my_solve exactor. Qed.
Theorem attempt2 : forall (A : Type) (x y : A),
x = y -> x = y.
Proof. my_solve exactor'. Qed.
Thanks in advance,
~Scott Constable
- [Coq-Club] Question about tacargs, scott constable, 04/03/2016
- Re: [Coq-Club] Question about tacargs, Jonathan Leivent, 04/03/2016
- Re: [Coq-Club] Question about tacargs, scott constable, 04/04/2016
- Re: [Coq-Club] Question about tacargs, Jonathan Leivent, 04/04/2016
- Re: [Coq-Club] Question about tacargs, scott constable, 04/04/2016
- Re: [Coq-Club] Question about tacargs, Jonathan Leivent, 04/03/2016
Archive powered by MHonArc 2.6.18.