Isabelle 伊莎贝尔引理可以用来陈述关于定义的事实吗?

Isabelle 伊莎贝尔引理可以用来陈述关于定义的事实吗?,isabelle,isar,Isabelle,Isar,我有伊莎贝尔的定义: definition two_integer_max_case_def :: "nat ⇒ nat ⇒ nat" where "two_integer_max_case_def a b = (case a > b of True ⇒ a | False ⇒ b)" value "two_integer_max_case_def 3 4" lemma spec_1: assumes "a: n

我有伊莎贝尔的定义:

definition two_integer_max_case_def :: "nat ⇒ nat ⇒ nat" where
"two_integer_max_case_def a b = (case a > b of True ⇒ a | False ⇒ b)"
value "two_integer_max_case_def 3 4"
lemma spec_1:
  assumes "a: nat" "b: nat" "a > b"
  shows "two_integer_max_case_def a b = a"
有输出

consts
  two_integer_max_case_def :: "nat ⇒ nat ⇒ nat
我可以从这个定义中得到价值:

definition two_integer_max_case_def :: "nat ⇒ nat ⇒ nat" where
"two_integer_max_case_def a b = (case a > b of True ⇒ a | False ⇒ b)"
value "two_integer_max_case_def 3 4"
lemma spec_1:
  assumes "a: nat" "b: nat" "a > b"
  shows "two_integer_max_case_def a b = a"
输出:

"4"
  :: "nat"
因此,这是可识别的、正确的表达/术语。但我试图用这个定义来声明引理:

definition two_integer_max_case_def :: "nat ⇒ nat ⇒ nat" where
"two_integer_max_case_def a b = (case a > b of True ⇒ a | False ⇒ b)"
value "two_integer_max_case_def 3 4"
lemma spec_1:
  assumes "a: nat" "b: nat" "a > b"
  shows "two_integer_max_case_def a b = a"
不幸的是,这个引理不被接受,没有生成目标/子目标,而是给出了错误消息:

Type unification failed: Clash of types "_ ⇒ _" and "_ set"

Type error in application: incompatible operand type

Operator:  (∈) a :: ??'a set ⇒ bool
Operand:   nat :: int ⇒ nat
我的引理怎么了?我只是使用了错误的相等操作,可能有一些微妙之处——nat实例与nat集合混淆,或者这是一个更普遍的问题?也许我不允许为可能的间断定义声明定理/引理,我只能为函数声明时已经完成终止证明的函数声明引理


如果引理可以被定义为“我的引理”,那么它可以被接受并生成证明目标吗?

你提出的引理没有本质上的错误,这里唯一的问题是a和b的类型是如何声明的

表达式a:nat被解释为∈ 产生类型错误的nat。您看到的错误消息说∈ 运算符nat应为“a集合”类型,但为int=>nat

为了在引理中声明变量的类型,可以使用fixes关键字,如下所示

lemma spec_1:
  fixes a :: nat and b :: nat
  assumes "a > b"
  shows "two_integer_max_case_def a b = a"

你提出的引理没有本质上的错误,这里唯一的问题是a和b的类型是如何声明的

表达式a:nat被解释为∈ 产生类型错误的nat。您看到的错误消息说∈ 运算符nat应为“a集合”类型,但为int=>nat

为了在引理中声明变量的类型,可以使用fixes关键字,如下所示

lemma spec_1:
  fixes a :: nat and b :: nat
  assumes "a > b"
  shows "two_integer_max_case_def a b = a"