软件基础'| - '符号阴影Ltac匹配符号

时间:2015-04-17 02:00:07

标签: coq

Software Foundations在其几个符号中使用|-。例如,在Stlc中:

Reserved Notation "Gamma '|-' t '\in' T" (at level 40).

这会干扰Ltac匹配构造。例如,这个:

Ltac test :=
  match goal with
    H: _ |- _  => idtac
  end.

在Stlc之外正常工作,但是一旦定义了这种表示法,它就失败了:

Toplevel input, characters 43-44:
Syntax error: "\in" expected after [constr:operconstr level 200] (in [constr:operconstr]).

除了更改Gamma '|-' t '\in' T表示法之外,还有什么可以做的吗?

1 个答案:

答案 0 :(得分:2)

据我所知,这里没有任何可以做到真正修复问题的事情。 Coq的可扩展解析器非常脆弱,这样的冲突可能导致某些事情变得无法解析。

解决方法是在模块中声明符号:

(* Foo.v *)
Module MyNotation.

Reserved Notation "Gamma '|-' t '\in' T" (at level 40).

(* Include actual notation definition somewhere here *)

End MyNotation.

要使用表示法,只需导入模块:

(* Bar.v *)
Require Import Foo.

Import MyNotation.

Definition asdf := 4.

然后,您可以在其他地方使用FooBar,而不会出现与ltac代码冲突的符号:

(* Baz.v *)
Require Import Foo.
Require Import Bar.

Ltac test :=
  match goal with
  | H : _ |- _ => idtac
  end.
相关问题