Syntax 伊莎贝尔:我如何在mixfix符号中定位固定参数?
假设我对关系的自反和传递闭包有以下定义,其中关系由二元谓词表示:Syntax 伊莎贝尔:我如何在mixfix符号中定位固定参数?,syntax,isabelle,Syntax,Isabelle,假设我对关系的自反和传递闭包有以下定义,其中关系由二元谓词表示: inductive closure :: "(['a, 'a] ⇒ bool) ⇒ (['a, 'a] ⇒ bool)" for ℛ (infix "→" 50) where gen: "x → y ⟹ closure (→) x y" | refl: "closure (→) x x" | trans: "⟦closure (→) x y; closure (→) y z⟧ ⟹ clo
inductive
closure :: "(['a, 'a] ⇒ bool) ⇒ (['a, 'a] ⇒ bool)"
for ℛ (infix "→" 50)
where
gen:
"x → y ⟹ closure (→) x y" |
refl:
"closure (→) x x" |
trans:
"⟦closure (→) x y; closure (→) y z⟧ ⟹ closure (→) x z"
我想为closure
的应用程序提供更好的语法。假设我想写x*(→)* y
用于关闭(→) xy
。问题是此符号中的参数顺序与函数闭包的参数顺序不匹配
我认为使用\
可能会有所帮助。不幸的是,中的\
文档非常简洁,我无法真正理解它。我玩了一会儿\
,但没有找到任何可行的解决方案
让我困惑的是,\
显然被翻译成了⇘一些指数⇙代码>,从我收到的一些错误消息判断。我尝试使用⇘ℛ⇙
来标记基关系应该到达的位置,但这也不起作用。您可能需要使用语法和翻译,例如:
syntax "_closure" :: "['a, (['a, 'a] ⇒ bool), 'a] ⇒ (['a, 'a] ⇒ bool)" ("(_ *'(_')* _)")
translations "x *(ℛ)* y" ⇌ "CONST closure (ℛ) x y"
inductive closure :: "(['a, 'a] ⇒ bool) ⇒ (['a, 'a] ⇒ bool)"
and closure_syntax :: "['a, ['a, 'a] ⇒ bool, 'a] ⇒ bool" ("(_ ⇧*(_)⇧* _)" [999,0,999] 100)
for ℛ (infix "→" 50)
where
"x ⇧*(→)⇧* y ≡ closure (→) x y"
| gen: "x → y ⟹ x ⇧*(→)⇧* y"
| refl: "x ⇧*(→)⇧* x"
| trans: "⟦x ⇧*(→)⇧* y; y ⇧*(→)⇧* z⟧ ⟹ x ⇧*(→)⇧* z"
这些也记录在isar-ref.pdf
中,一些示例在源理论文件中浮动(超搜索应该会显示这些示例)。您可能需要使用语法和翻译,例如:
syntax "_closure" :: "['a, (['a, 'a] ⇒ bool), 'a] ⇒ (['a, 'a] ⇒ bool)" ("(_ *'(_')* _)")
translations "x *(ℛ)* y" ⇌ "CONST closure (ℛ) x y"
inductive closure :: "(['a, 'a] ⇒ bool) ⇒ (['a, 'a] ⇒ bool)"
and closure_syntax :: "['a, ['a, 'a] ⇒ bool, 'a] ⇒ bool" ("(_ ⇧*(_)⇧* _)" [999,0,999] 100)
for ℛ (infix "→" 50)
where
"x ⇧*(→)⇧* y ≡ closure (→) x y"
| gen: "x → y ⟹ x ⇧*(→)⇧* y"
| refl: "x ⇧*(→)⇧* x"
| trans: "⟦x ⇧*(→)⇧* y; y ⇧*(→)⇧* z⟧ ⟹ x ⇧*(→)⇧* z"
这些也记录在isar-ref.pdf中,源理论文件中有一些例子(超级搜索应该会打开这些例子)。要切换参数,缩写是最好的选择。(语法
/翻译
也可以,但缩写词应该是首选,因为它们适用于任何上下文(区域设置、类型类等)并经过类型检查。)幸运的是,inclusive
允许您同时声明缩写和归纳定义。缩写的方程式必须放在第一位。下面是您的示例的工作原理:
syntax "_closure" :: "['a, (['a, 'a] ⇒ bool), 'a] ⇒ (['a, 'a] ⇒ bool)" ("(_ *'(_')* _)")
translations "x *(ℛ)* y" ⇌ "CONST closure (ℛ) x y"
inductive closure :: "(['a, 'a] ⇒ bool) ⇒ (['a, 'a] ⇒ bool)"
and closure_syntax :: "['a, ['a, 'a] ⇒ bool, 'a] ⇒ bool" ("(_ ⇧*(_)⇧* _)" [999,0,999] 100)
for ℛ (infix "→" 50)
where
"x ⇧*(→)⇧* y ≡ closure (→) x y"
| gen: "x → y ⟹ x ⇧*(→)⇧* y"
| refl: "x ⇧*(→)⇧* x"
| trans: "⟦x ⇧*(→)⇧* y; y ⇧*(→)⇧* z⟧ ⟹ x ⇧*(→)⇧* z"
现在很少使用语法元素\
,因为区域设置可以实现类似的效果,并且通常更灵活。\
的要点是可以将参数声明为(结构)
然后,解析器在语法语法中看到\
时,会自动插入该参数。因此,它允许您省略重复结构
参数,但区域设置通常效果更好。要切换参数,缩写是最佳选择。(语法
/翻译
也可以,但缩写词应该是首选,因为它们适用于任何上下文(区域设置、类型类等)并经过类型检查。)幸运的是,inclusive
允许您同时声明缩写和归纳定义。缩写的方程式必须放在第一位。下面是您的示例的工作原理:
syntax "_closure" :: "['a, (['a, 'a] ⇒ bool), 'a] ⇒ (['a, 'a] ⇒ bool)" ("(_ *'(_')* _)")
translations "x *(ℛ)* y" ⇌ "CONST closure (ℛ) x y"
inductive closure :: "(['a, 'a] ⇒ bool) ⇒ (['a, 'a] ⇒ bool)"
and closure_syntax :: "['a, ['a, 'a] ⇒ bool, 'a] ⇒ bool" ("(_ ⇧*(_)⇧* _)" [999,0,999] 100)
for ℛ (infix "→" 50)
where
"x ⇧*(→)⇧* y ≡ closure (→) x y"
| gen: "x → y ⟹ x ⇧*(→)⇧* y"
| refl: "x ⇧*(→)⇧* x"
| trans: "⟦x ⇧*(→)⇧* y; y ⇧*(→)⇧* z⟧ ⟹ x ⇧*(→)⇧* z"
现在很少使用语法元素\
,因为区域设置可以实现类似的效果,并且通常更灵活。\
的要点是可以将参数声明为(结构)
然后,解析器在语法语法中看到\
的地方会自动插入该参数。因此,它允许您省略重复结构
参数,但区域设置通常工作得更好