Isabelle:如何在 mixfix 表示法中定位固定参数?

Isabelle: How can I position fixed arguments in mixfix notation?

假设我有以下关系的自反和传递闭包的定义,其中关系由二元谓词表示:

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 的应用程序提供更好的语法。假设我希望能够为 closure (→) x y 编写 x *(→)* y。问题在于此表示法中的参数顺序与函数 closure.

的参数顺序不匹配

我想也许使用 \<index> 会有所帮助。不幸的是,Isabelle/Isar Reference Manual\<index> 的文档非常简洁,我无法真正理解它。我玩了一下 \<index> 但没有找到任何可行的解决方案。

令我困惑的是,从我收到的一些错误消息来看,显然 \<index> 被翻译成了 ⇘some_index⇙。我试着用⇘ℛ⇙来标记基关系应该去的位置,但这也没有用。

您可能想要使用 syntaxtranslations,例如:

syntax "_closure" :: "['a, (['a, 'a] ⇒ bool), 'a] ⇒ (['a, 'a] ⇒ bool)" ("(_ *'(_')* _)")
translations "x *(ℛ)* y" ⇌ "CONST closure (ℛ) x y"

这些也记录在 isar-ref.pdf 中,源理论文件中有一些例子(超级搜索应该会找到这些)。

要转换参数,缩写是最好的选择。 (syntax/translations 也可以,但应该首选缩写,因为它们可以在任何上下文(语言环境、类型 类、...)中使用并且经过类型检查。)幸运的是, inductive 允许您同时声明缩写和归纳定义。缩写的方程式必须放在第一位。以下是您的示例的工作原理:

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"

句法元素 \<index> 如今很少使用,因为语言环境可以达到类似的效果并且通常更灵活。 \<index> 的要点是您可以将参数声明为 (structure) 然后它将自动插入解析器在语法语法中看到 \<index> 的任何地方。因此它允许您省略重复 structure 参数,但语言环境通常效果更好。