在Isabelle/HOLCF中对列表进行部分排序

在Isabelle/HOLCF中对列表进行部分排序,isabelle,Isabelle,我想制作一个列表数据类型,作为HOLCF中Porder.thy中偏序集的一个实例。我的尝试如下: theory Scratch imports Porder Representable begin datatype 'a myList = Nil | Cons 'a "'a myList" instantiation myList :: (below) below begin definition below_list_def: "(x ⊑ y) = (case x o

我想制作一个列表数据类型,作为HOLCF中Porder.thy中偏序集的一个实例。我的尝试如下:

theory Scratch
imports Porder Representable
begin

datatype 'a myList = 
  Nil |
  Cons 'a "'a myList"

instantiation myList :: (below) below
begin
  definition below_list_def:
    "(x ⊑ y) = (case x of Nil ⇒ True | 
    Cons a xs ⇒ (case y of Nil ⇒ False |
    Cons b ys ⇒ a ⊑ b ∧ xs ⊑ ys))"
  instance ..
end

我意识到“definition”不支持我正在使用的递归定义,我应该使用“fun”或“fixrec”之类的东西。但是,我不知道在这种情况下如何使用这些命令。我在网上找到的每个生成po实例的示例都使用非递归数据类型。使递归数据类型成为Lower和po实例的最佳方法是什么?

在这个本地上下文中,您可以使用
fun
,只需给它一个正确的名称,即后缀为“\u”的函数名和实例化的类型名,在本例中是
Lower\u myList

然后,您的示例改写为:

instantiation myList :: (below) below
begin
  fun below_myList where
    "Nil ⊑ xs = True"
  | "Cons x xs ⊑ Nil = False"
  | "Cons x xs ⊑ Cons y ys = (x ⊑ y ∧ xs ⊑ ys)"
  instance ..
end

lemma "Nil ⊑ Nil"
  by simp