我希望在2017年的Isabelle中引入新的语法(在一个足够复杂的情况下,我必须使用parse_translations
)。
问题在于,如果我这样做,那么#34;正常"方式(例如,在Groups_Big.thy
中,也参见下面示例中的double1
情况),结果条款没有超链接。
也就是说,如果我在某些术语中按顺序单击Isabelle / jEdit语法,则光标不会跳转到定义。
我有两个有效的解决方案(double2
和double4
),但由于各种原因它们并不完全令人满意,请参阅下面理论中的评论。
以下是我实现转换为double x
的语法x+x
的示例文件。 (我知道这可以使用abbreviations
完成,但我想要一个适用于更复杂案例的解决方案。)
除了解决方案或建议之外,我还想了解为什么正常方法不会导致超链接语法。
以下是失败和工作方法的示例:
theory Test
imports Main
begin
ML {* fun double ctx [e] = @{const plus(dummy)} $ e $ e *}
syntax "_double1" :: "'a ⇒ 'a" ("double1 _" [81] 80)
parse_translation {* [("_double1", double)] *}
(* Ctrl-click on double1 DOES NOT jump to definition *)
term "double1 2"
consts "double2_donotuse" :: "'a ⇒ 'a" ("double2 _" [81] 80)
parse_translation {* [(@{const_syntax double2_donotuse}, double)] *}
(* Ctrl-click on double1 DOES jump to definition
but we define an extra constant that clutters the name space
and is forbidden (meaningless) *)
term "double2 2"
(* Example: leads to valid looking pretty printing but is nonsense *)
term "double2_donotuse 2"
abbreviation (input) double3 ("double3 _" [81] 80) where
"double3 x == x+x"
(* Ctrl-click on double1 DOES jump to definition,
but abbreviation mechanism too limited for more complex cases *)
term "double3 2"
syntax "_double4" :: "'a ⇒ 'a" ("TEMPORARY")
parse_translation {* [("_double4", double)] *}
abbreviation (input) double4_donotuse ("double4 _" [81] 80) where
"double4_donotuse x == TEMPORARY x"
no_syntax "_double4" :: "'a ⇒ 'a" ("TEMPORARY")
(* Ctrl-click on double1 DOES jump to definition,
no "forbidden" constant defined,
but it's complicated and feels like a hack. *)
term "double4 2"