Isabelle 正确性错误。。。不相上下

Isabelle 正确性错误。。。不相上下,isabelle,Isabelle,下面是一个从语言foo到bar的简单翻译: type_synonym vname = "string" type_synonym 'a env = "vname ⇒ 'a option" datatype foo_exp = FooBConst bool datatype foo_type = FooBType | FooIType | FooSType datatype bar_exp = BarBConst bool datatype bar_type = BarBType | BarI

下面是一个从语言
foo
bar
的简单翻译:

type_synonym vname = "string"
type_synonym 'a env = "vname ⇒ 'a option"

datatype foo_exp = FooBConst bool
datatype foo_type = FooBType | FooIType | FooSType

datatype bar_exp = BarBConst bool
datatype bar_type = BarBType | BarIType

fun foo_to_bar_type :: "foo_type ⇒ bar_type option" where
  "foo_to_bar_type FooBType = Some BarBType" |
  "foo_to_bar_type FooIType = Some BarIType" |
  "foo_to_bar_type _ = None"

inductive foo_to_bar :: "foo_type env ⇒ foo_exp ⇒ bar_type env ⇒ bar_exp ⇒ bool" where
"Γ⇩B = map_comp foo_to_bar_type Γ⇩F ⟹
 foo_to_bar Γ⇩F (FooBConst c) Γ⇩B (BarBConst c)"

code_pred [show_modes] foo_to_bar .

values "{t. foo_to_bar Map.empty (FooBConst True) Map.empty t}"
最后一行导致以下错误:

Wellsortedness error
(in code equation foo_to_bar_i_i_i_o ?x ?xa ?xb ≡
                  Predicate.bind (Predicate.single (?x, ?xa, ?xb))
                   (λ(Γ⇩F_, aa, Γ⇩B_).
                       case aa of
                       FooBConst c_ ⇒
                         Predicate.bind (eq_i_i Γ⇩B_ (foo_to_bar_type ∘⇩m Γ⇩F_))
                          (λ(). Predicate.single (BarBConst c_))),
with dependency "Pure.dummy_pattern" -> "foo_to_bar_i_i_i_o"):
Type char list ⇒ bar_type option not of sort equal
No type arity list :: enum
你能告诉我怎么修吗


而且
foo\u to\u bar
具有模式
i=>i=>o=>boolpos
。我应该如何执行
来生成第三个和第四个参数?

一般来说,我建议不要使用
归纳
来定义可以轻松表示为函数的东西。虽然谓词编译器附带了很多细节来解释归纳定义的计算意义,但由于它太复杂,可能会出现很多问题。在您的情况下,问题在于线路

Γ⇩B = map_comp foo_to_bar_type Γ⇩F
您正在尝试比较两个函数。谓词编译器不知道它可以被看作是一个“定义等式”。从某种意义上说,您要求谓词编译器解决一个不可能的问题

如果将
foo_to_bar
定义为一个函数(或简单定义),您的生活会轻松得多。它将与代码生成器一起开箱即用