Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Ltac extend

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Ltac extend


Chronological Thread 
  • From: Jonathan Leivent <jonikelee AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Ltac extend
  • Date: Thu, 22 Sep 2016 10:07:31 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qk0-f170.google.com
  • Ironport-phdr: 9a23:vgROoRHsQVjc0rOYAp4glZ1GYnF86YWxBRYc798ds5kLTJ76oMiwAkXT6L1XgUPTWs2DsrQf2rCQ6/yrBjRIoc7Y9itdINoUD15NoP5VtjJjKfbNMVf8Iv/uYn5yN+V5f3ghwUuGN1NIEt31fVzYry76xzcTHhLiKVg9fbytScaBx/iwguu14tjYZxhCrDu7e7J7ahus/ivLscxDo4xkI7oxwx2BhnZJZelQ2Ss8J1WVnhXx4sq91JFm+iVU/fkm8pgTAu3BY60kQOkAX3wdOGcv6ZizuA==



On 09/22/2016 04:27 AM, Robbert Krebbers wrote:
On 09/22/2016 10:15 AM, Frédéric Besson wrote:
Otherwise:

Class is_var_bool {T} (x : T) := decide_is_var : bool.
Hint Extern 0 (is_var_bool ?x) => first [ is_var x; exact true | exact false ] : typeclass_instances.
Ltac is_var_bool x := constr:(_ : is_var_bool x).
This is what I would call Ltac kung-fu.
A dark art which I sincerely admire but do not intend to practice.
Jason's trick can be simplified as follows:

Ltac is_var_bool x :=
constr:(ltac:(first [is_var x; exact true|exact false])).

I sometimes use this constr:(ltac:t) trick to define tactics that return a term while being implemented using possibly side-effecting tactics.

IMHO my solution isn't very pretty either...

Yet another solution is:

Ltac is_var_bool x :=
match goal with
| _ => let dummy := match goal with _ => is_var x end in true
| _ => false
end.

This is a throwback to the pre-tactic-in-term days of 8.4+.

IMHO none of these are pretty. But, one can mask them with a Tactic Notation. One additional behavioral feature of this ugly match form is that - if one instead uses multimatch for the outer match, the form have multiple backtracked successes, unlike the constr:(ltac:(...)) form.

-- Jonathan




Archive powered by MHonArc 2.6.18.

Top of Page