coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Semantics of lazymatch in 8.5
- Date: Thu, 13 Oct 2016 04:04:58 +0000
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-it0-f41.google.com
- Ironport-phdr: 9a23:K78I7BemahsC+sA83fAbO9mrlGMj4u6mDksu8pMizoh2WeGdxc65ZB7h7PlgxGXEQZ/co6odzbGH6ea8AidfsN6oizMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JXtkbzpsMKCKyxzxxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cY6Lod8JtLVry/dKAlR5RZCi4nOiY7/p7Frx7GGCmG/XwaGkoMlQFTS1zH5Qr9WJjrtTDh58Jy3SCbOYv9SrViCmfq1LtiVBK90HRPDDU+6myC0sE=
Here is a description of lazymatch in Coq 8.4:
Recall that there are two phases of tactic evaluation: there is tactic _expression_ evaluation, and tactic running. During tactic running, sequencing, refine, rewrite, etc, are executed. During tactic _expression_ evaluation, the following constructs are evaluated, of found in the head position:
- tactic calls are resolved/followed
- [let ... in ...] binds the evaluation of it's argument to the name, and does substitution
- constr:(...) is evaluated and type checked
- lazymaytch ... with ... end is evaluated (with back tracking), and returns the first matching branch which successfully _expression_-evaluates
- match ... with ... end is evaluated (with backtracking) *and the branch is eagerly executed*. Note that in this picture, match is strange, because it forces the execution of a tactic to come early. If you've ever seen "immediate tactic-producing match statements are not allowed in lets", or similar, I'm guessing it's because this confusing behavior is a wart that the original devs implementing Ltac wanted to hide. So the only place you can notice it in 8.4 is if you stick match inside of lazymatch and play with failure levels.
In 8.5, you can do strange things like:
let dummy := match goal with _ => rewrite H end in
constr:(true)
and have constr-producing tactics with side effects. However, you can no longer do:
let tac := lazymatch b with
| true => tac1
| false => tac2
end in
tac long args.
This is because in 8.5, lazymatch also eagerly evaluates it's branches, without backtracking.
On 10/12/2016 05:03 PM, Clément Pit--Claudel wrote:
> Hi coq-club,
>
> The CHANGES file says:
>
> - Matching using "lazymatch" was fundamentally modified. It now behaves
> like "match" (immediate execution of the matching branch) but without
> the backtracking mechanism in case of failure.
>
> The description of the new behaviour sounds close to what my understanding of lazymatch was in 8.4 (as long as the result of the lazy match isn't bound to a variable). Beyond the 8.4 issue that caused lazymatch to backtrack when a branch contained a type error, what are examples of differences between the old and the new lazymatch?
>
> Thanks!
> Clément.
>
Unfortunately, I don't have an 8.4 around to test this on - but AFAIR
lazymatch prior to 8.5 didn't have the greedy evaluation of branches
behavior as does (and did) match. Hence, something like:
Goal True.
let x := lazymatch goal with _ => idtac "hello" end in
idtac "there".
in 8.4 would just print "there" and not "hello" "there".
-- Jonathan
- [Coq-Club] Semantics of lazymatch in 8.5, Clément Pit--Claudel, 10/12/2016
- Re: [Coq-Club] Semantics of lazymatch in 8.5, Jonathan Leivent, 10/12/2016
- Re: [Coq-Club] Semantics of lazymatch in 8.5, Jason Gross, 10/13/2016
- Re: [Coq-Club] Semantics of lazymatch in 8.5, Jonathan Leivent, 10/12/2016
Archive powered by MHonArc 2.6.18.