伊莎贝尔类型错误

Isabelle Type Error

我是 Isabelle 的新手,正在为大学做练习。我需要证明 Isabelle 中的反向函数。

在 Haskell 中,函数如下所示:

rev [] = []
rev (x:xs) = rev xs ++ [x]

我现在尝试在 Isabelle 中定义这个函数 "rev"。类型列表和函数 "app" (append)

Isabelle 给我的错误是:

Type unification failed: Clash of types "_
          ⇒ _" and "_ Exercise5.list"

Type error in application: incompatible operand type

Operator:  app (rev xs) ::
  'a Exercise5.list ⇒ 'a Exercise5.list
Operand:   Exercise5.list.Cons ::
  ??'a ⇒ ??'a Exercise5.list ⇒ ??'a Exercise5.list

问题出在哪里?据我了解,伊莎贝尔告诉我 "Hey buddy app needs 2 arguments of type a' list but this is not the case here"

但是为什么呢? xs 显然是 a' list 类型,使用我的 Cons 运算符我确实使 x 也是一个列表?

感谢您的帮助!

想想括号应该放在 app rev xs Cons x Nil 的什么地方:目前你似乎在它的参数 Nil.

上应用了函数 x