ltac

Ltac: repeating a tactic n times with backtracking

六眼飞鱼酱① 提交于 2020-01-25 00:37:46
问题 Suppose I have a tactic like this (taken from HaysTac), that searches for an argument to specialize a particular hypothesis with: Ltac find_specialize_in H := multimatch goal with | [ v : _ |- _ ] => specialize (H v) end. However, I'd like to write a tactic that searches for n arguments to specialize a tactic with. The key is that it needs to backtrack. For example, if I have the following hypotheses: y : T H : forall (x : T), x = y -> P x x1 : T x2 : T Heq : x1 = y If I write do 2 (find

Ltac : optional arguments tactic

感情迁移 提交于 2019-12-10 10:06:58
问题 I want to make a Ltac tactic in coq which would take either 1 or 3 arguments. I have read about ltac_No_arg in the LibTactics module but if I understood it correctly I would have to invoke my tactic with : Coq < mytactic arg_1 ltac_no_arg ltac_no_arg. which is not very convenient. Is there any way to get a result like this ? : Coq < mytactic arg_1. Coq < mytactic arg_1 arg_2 arg_3. 回答1: We can use the Tactic Notation mechanism to try to solve your issue because it can handle variadic

Can I define a tactic under “coqtop - nois”?

南笙酒味 提交于 2019-12-10 10:02:17
问题 $ coqtop -nois Welcome to Coq 8.7.0 (October 2017) Coq < Ltac i := idtac. Toplevel input, characters 0-4: > Ltac i := idtac. > ^^^^ Error: Syntax error: illegal begin of vernac. I am redeveloping "Coq.Init.Prelude" and "HoTT.Basics.Overture" under "coqtop -nois" for pratice. I find it hard to write expressions directly. That's why I want to use tactics. I wonder why I can not use "Ltac". 回答1: Ltac is now provided as a plugin, which you’ll need to load to use: Declare ML Module "ltac_plugin".

Modus Ponens and Modus Tollens in Coq

情到浓时终转凉″ 提交于 2019-12-07 14:53:00
问题 I would like to have Ltac tactics for these simple inference rules. In Modus Ponens, if I have H:P->Q and H1:P , Ltac mp H H1 will add Q to the context as H2 : Q . In Modus Tollens, if I have H:P->Q and H1:~Q , then Ltac mt H H1 will add H2:~P to the context. I have written one for the modus ponens, but it does not work in the complicated cases where the precedent is also an implication. Ltac mp H0 H1 := let H := fresh "H" in apply H0 in H1 as H. Edit : I have found the answer to Modus Ponens

Modus Ponens and Modus Tollens in Coq

柔情痞子 提交于 2019-12-05 22:06:55
I would like to have Ltac tactics for these simple inference rules. In Modus Ponens, if I have H:P->Q and H1:P , Ltac mp H H1 will add Q to the context as H2 : Q . In Modus Tollens, if I have H:P->Q and H1:~Q , then Ltac mt H H1 will add H2:~P to the context. I have written one for the modus ponens, but it does not work in the complicated cases where the precedent is also an implication. Ltac mp H0 H1 := let H := fresh "H" in apply H0 in H1 as H. Edit : I have found the answer to Modus Ponens in another seemingly unrelated question ( Rewrite hypothesis in Coq, keeping implication ), where a

Ltac : optional arguments tactic

早过忘川 提交于 2019-12-05 21:47:07
I want to make a Ltac tactic in coq which would take either 1 or 3 arguments. I have read about ltac_No_arg in the LibTactics module but if I understood it correctly I would have to invoke my tactic with : Coq < mytactic arg_1 ltac_no_arg ltac_no_arg. which is not very convenient. Is there any way to get a result like this ? : Coq < mytactic arg_1. Coq < mytactic arg_1 arg_2 arg_3. We can use the Tactic Notation mechanism to try to solve your issue because it can handle variadic arguments. Let's reuse ltac_No_arg and define a dummy tactic mytactic for the purposes of demonstration Inductive

Can I define a tactic under “coqtop - nois”?

醉酒当歌 提交于 2019-12-05 21:38:17
$ coqtop -nois Welcome to Coq 8.7.0 (October 2017) Coq < Ltac i := idtac. Toplevel input, characters 0-4: > Ltac i := idtac. > ^^^^ Error: Syntax error: illegal begin of vernac. I am redeveloping "Coq.Init.Prelude" and "HoTT.Basics.Overture" under "coqtop -nois" for pratice. I find it hard to write expressions directly. That's why I want to use tactics. I wonder why I can not use "Ltac". Ltac is now provided as a plugin, which you’ll need to load to use: Declare ML Module "ltac_plugin". 来源: https://stackoverflow.com/questions/48837345/can-i-define-a-tactic-under-coqtop-nois

Coq: Ltac definitions over variable argument lists?

。_饼干妹妹 提交于 2019-12-01 17:57:41
问题 While trying to create an Ltac definition that loops over a variable-length argument list, I encountered the following unexpected behavior on Coq 8.4pl2. Can anyone explain it to me? Ltac ltac_loop X := match X with | 0 => idtac "done" | _ => (fun Y => idtac "hello"; ltac_loop Y) end. Goal True. ltac_loop 0. (* prints "done" as expected *) ltac_loop 1 0. (* prints "hello" then "done" as expected *) ltac_loop 1 1 0. (* unexpectedly yields "Error: Illegal tactic application." *) 回答1: Let's

Coq: Ltac definitions over variable argument lists?

二次信任 提交于 2019-12-01 17:48:44
While trying to create an Ltac definition that loops over a variable-length argument list, I encountered the following unexpected behavior on Coq 8.4pl2. Can anyone explain it to me? Ltac ltac_loop X := match X with | 0 => idtac "done" | _ => (fun Y => idtac "hello"; ltac_loop Y) end. Goal True. ltac_loop 0. (* prints "done" as expected *) ltac_loop 1 0. (* prints "hello" then "done" as expected *) ltac_loop 1 1 0. (* unexpectedly yields "Error: Illegal tactic application." *) Let's expand the last invocation of ltac_loop to see what's happening: ltac_loop 1 1 0 -> (fun Y => idtac "hello";