我想在coq中制定一个Ltac策略,它可以接受1个或3个参数。我在LibTactics模块中读过关于ltac_No_arg的文章,但如果我理解正确的话,我将不得不用以下命令调用我的策略:
Coq < mytactic arg_1 ltac_no_arg ltac_no_arg.这不是很方便。
有没有办法得到这样的结果?:
Coq < mytactic arg_1.
Coq < mytactic arg_1 arg_2 arg_3.发布于 2017-06-30 16:50:21
我们可以使用Tactic Notation机制来尝试解决您的问题,因为它可以处理可变参数。
为了演示的目的,让我们重用ltac_No_arg并定义一个虚拟策略mytactic
Inductive ltac_No_arg : Set :=
| ltac_no_arg : ltac_No_arg.
Ltac mytactic x y z :=
match type of y with
| ltac_No_arg => idtac "x =" x (* a bunch of cases omitted *)
| _ => idtac "x =" x "; y =" y "; z =" z
end.现在让我们定义前面提到的策略符号:
Tactic Notation "mytactic_notation" constr(x) :=
mytactic x ltac_no_arg ltac_no_arg.
Tactic Notation "mytactic_notation" constr(x) constr(y) constr(z) :=
mytactic x y z.测试:
Goal True.
mytactic_notation 1.
mytactic_notation 1 2 3.
Abort.https://stackoverflow.com/questions/44840624
复制相似问题