我注意到符号可以区别对待。例如,<
只是常规定义的表示法,而unfold "<"
的确如下例所示:
Theorem a : 4 < 5.
Proof.
unfold "<".
但是,<=
是与le
类型相关联的表示法,由于某种原因unfold "<="
不起作用,如下例所示:
Theorem a : 4 <= 5
Proof.
unfold "<=".
以Unable to interpret "<=" as a reference
失败。
我可以使用一些ltac命令将4 <= 5
转换为le 4 5
吗?
答案 0 :(得分:1)
This happens because <
is interpreted as lt
which is a definition (here):
Definition lt (n m:nat) := S n <= m.
You can achieve the same effect with unfold lt
.
In the same manner <=
means le
, but you cannot unfold le
, because it is a type constructor. The manual says that you can unfold only a defined transparent constant or local definition.
The upshot here is that you don't unfold notations, you unfold the definitions those notations refer to.
答案 1 :(得分:1)
添加到Anton的答案:如果您已经知道如何定义符号并且只想让它在目标中可见,您可以执行类似
的操作Definition make_visible {X} (f : X) := f.
Notation "` f" := (make_visible f) (at level 5, format "` f").
Tactic Notation "unfold" "notation" constr(f) :=
change f with (`f).
Tactic Notation "fold" "notation" constr(f) :=
unfold make_visible.
Theorem a : 4 <= 5.
Proof.
unfold notation le.
fold notation le.
(编辑:我的第一个解决方案是Definition make_visible {X} (f : X) := (fun _ => f) tt.
,但正如安东指出的那样,这更容易。)