证明 isabelle/hol 中的解释时的多态 "fix" 语句

Polymorphic "fix" statements when proving interpretations in isabelle/hol

我正在努力证明关于多变量的一些基本事实 多项式,因此需要一个多阶类型。为了模拟这个,我 使用了一些未指定类型的变量名的部分函数 到自然数:

type_synonym 'v multi_degree = "'v ⇒ nat"

还有一些涉及有限支持的内容,但没有 这个问题真的很重要。然后我定义添加 以明显的逐点方式进行多度:

definition zero_degree :: "'v multi_degree" where "zero_degree = (λ v. 0)"

definition md_plus :: "'v multi_degree ⇒ 'v multi_degree ⇒ 'v multi_degree" (infix "⊕" 70) where
  "(d1 ⊕ d2) = (λ v. d1 v + d2 v)"

lemma assoc_md_plus [simp]: "d1 ⊕ (d2 ⊕ d3) = (d1 ⊕ d2) ⊕ d3"
  by (rule; simp add: md_plus_def)

lemma ident_zero_degree [simp]: "d ⊕ zero_degree = d" and "zero_degree ⊕ d = d"
  by (auto simp add: md_plus_def zero_degree_def)

lemma sym_md_plus: "d ⊕ d' = d' ⊕ d"
  by (rule; simp add: md_plus_def)

现在我想说多度相加的结构是 一个可交换的幺半群。显而易见的事情是像 这个:

interpretation md: comm_monoid "op ⊕" "zero_degree"
proof

到目前为止一切顺利:输出是

goal (3 subgoals):
 1. ⋀a b c. (a ⊕ b) ⊕ c = a ⊕ (b ⊕ c)
 2. ⋀a b. a ⊕ b = b ⊕ a
 3. ⋀a. a ⊕ zero_degree = a

我绝对可以证明!但是,如果我现在写

interpretation md: comm_monoid "op ⊕" "zero_degree"
proof
  fix a
  show "a ⊕ zero_degree = a" by simp

然后我收到警告

Introduced fixed type variable(s): 'c in "a__"

有没有办法避免警告?现在,我作弊并证明了 用

解释
interpretation md: comm_monoid "op ⊕" "zero_degree"
  by (unfold_locales; simp?; rule sym_md_plus)

哪个有效,但未来的读者并不十分清楚...

就写fix a :: "'a multi_degree"。如果没有其他约束,Isabelle 将选择 'a 作为类型变量。但是,我认为明确绑定类型变量是一种很好的风格,例如

interpretation md: comm_monoid "op ⊕" "zero_degree :: 'a multi_degree"
proof
  fix a :: "'a multi_degree"

再说一句:您可能要考虑使用 typedefmulti_degree 引入一个新类型,然后使用 lifting/transfer 定义您想要在其上定义的所有函数。 (见相应手册)

这样做的好处是您可以实例化正确的类型 类(如 comm_monoid_add),而不必一直进行区域设置假设。此外,您可以编写 +0 而不是 zero_degree