如何在类型上定义线性排序?

时间:2017-03-22 09:38:31

标签: isabelle

我试图定义a conjunction function for 4-valued logic (false, true, null, and error)。在我的情况下,连词与线性顺序min上的false < error < null < true函数等效。

datatype bool4 = JF | JT | BN | BE

instantiation bool4 :: linear_order
begin

fun leq_bool4 :: "bool4 ⇒ bool4 ⇒ bool" where
  "leq_bool4 JF b = True"
| "leq_bool4 BE b = (b = BE ∨ b = BN ∨ b = JT)"
| "leq_bool4 BN b = (b = BN ∨ b = JT)"
| "leq_bool4 JT b = (b = JT)"

instance proof
  fix x y z :: bool4
  show "x ⊑ x"
    by (induct x) simp_all
  show "x ⊑ y ⟹ y ⊑ z ⟹ x ⊑ z"
    by (induct x; induct y) simp_all
  show "x ⊑ y ⟹ y ⊑ x ⟹ x = y"
    by (induct x; induct y) simp_all
  show "x ⊑ y ∨ y ⊑ x"
    by (induct x; induct y) simp_all
qed

end

definition and4 :: "bool4 ⇒ bool4 ⇒ bool4" where
  "and4 a b ≡ minimum a b"

我想在Isabelle HOL中必须有一种更简单的方法来定义线性顺序。你能建议简化理论吗?

1 个答案:

答案 0 :(得分:2)

您可以使用"Datatype_Order_Generator" AFP entry

然后就像导入"$AFP/Datatype_Order_Generator/Order_Generator"并声明derive linorder "bool4"一样简单。请注意,在定义数据类型时,必须按照所需的顺序声明构造函数。

有关如何在本地下载和使用AFP的详细信息,请访问here