语言环境忽略操作符号

Locale ignores operation notation

以下工作正常:

class test1 = semilattice_sup +
  fixes x :: "'a"
  assumes "x < y"

但是当我将 class 替换为 locale 时:

locale test2 = semilattice_sup +
  fixes x :: "'a"
  assumes "x < y"

我收到错误:

Type unification failed: Variable 'a::type not of sort ord

错误可以按如下方式修复:

locale test2 = semilattice_sup +
  fixes x :: "'a"
  assumes "less x y"

但是可以使用<表示法吗?


更新

这里有一个类似的问题:

datatype 'a ty = A | B

instantiation ty :: (order) order
begin
definition "x < y ≡ x = A ∧ y = B"
definition "x ≤ y ≡ (x :: 'a ty) = y ∨ x < y"
instance
  apply intro_classes
  using less_eq_ty_def less_ty_def by auto
end

locale loc = semilattice_sup +
  fixes f :: "'a ⇒ 't :: order"
begin
definition "g ≡ inv f"
end

class cls = semilattice_sup +
  fixes f :: "'a ⇒ 'a ty"
begin
interpretation base: loc .
abbreviation "g ≡ base.g"
end

解释失败,出现以下错误:

Type unification failed: Variable 'a::type not of sort semilattice_sup

locale test2 =
  fixes x :: "'a :: semilattice_sup"
  assumes "x < y"

适合您吗?在这种情况下,您不再将语言环境基于另一个语言环境,而是要求 x 的类型是 class semilattice_sup 的实例,这允许您使用漂亮的中缀语法less.