Isabelle 尝试计算“互质”时出错`
我想使用Isabelle的Isabelle 尝试计算“互质”时出错`,isabelle,Isabelle,我想使用Isabelle的GCD中定义的互质函数,并对其进行一些处理。 为什么值“互质Suc(Suc 0)Suc(Suc(Suc(Suc 0))”返回错误 Type unification failed: No type arity fun :: gcd Type error in application: incompatible operand type Operator: coprime :: ??'a ⇒ ??'a ⇒ bool Operand: Suc :: nat ⇒ na
GCD
中定义的互质
函数,并对其进行一些处理。
为什么值“互质Suc(Suc 0)Suc(Suc(Suc(Suc 0))”
返回错误
Type unification failed: No type arity fun :: gcd
Type error in application: incompatible operand type
Operator: coprime :: ??'a ⇒ ??'a ⇒ bool
Operand: Suc :: nat ⇒ nat
Coercion Inference:
Local coercion insertion on the operand failed:
No type arity fun :: gcd
Now trying to infer coercions globally.
Coercion inference failed:
weak unification of subtype constraints fails
Clash of types "_ ⇒ _" and "nat"
而不是false
(这也是值“互质0 0”
的情况)
最小MWE w.r.t回答:
(*<*) theory T
imports
Main
"~~/src/HOL/Number_Theory/Number_Theory"
begin (*>*)
value "coprime 2 (4 :: nat))"
(*<*) end (*>*)
(**)
值“互质2(4::nat))”
(**)
这里有很多问题
值“互质(Suc(Suc 0))(Suc(Suc(Suc(Suc 0)))”
。函数应用程序绑定最强并向左关联,因此您编写的内容将被解释为应用于Suc
、suc0
和其他一些参数的copinite
,这是一个类型错误coprime 0 0
在我的伊莎贝尔版本中运行良好;它输出有点混乱的“equal_class.equal(gcd 0 0)1”:“bool”
。这是因为该术语中没有任何东西表明0
是一个自然数,多态常数的计算往往是有问题的。甚至像2这样的东西≠ 4
通常不会计算为True
,因为这取决于2
和4
的类型。如果您编写互质0(0::nat)
,一切都会按预期工作此外,编写
value”互质2(4::nat)
比使用后继符号更方便。这里有许多问题
value“互质(Suc(Suc 0))(Suc(Suc(Suc(Suc(Suc 0)))”
。函数应用程序绑定最强并与左侧关联,因此您编写的内容将被解释为应用于Suc
、Suc 0
和其他一些参数的copprime
,这是一个类型错误互质0 0
在我的伊莎贝尔版本中效果很好;它输出了有点混乱的“equal_class.equal(gcd 0)1”:“bool”“
。这是因为该术语中没有任何东西表明0
是一个自然数,多态常数的计算往往是有问题的。甚至像2这样的东西≠ 4
通常不会计算为True
,因为这取决于2
和4
的类型。如果您编写互质0(0::nat)
,一切都会按预期工作此外,编写
value“copinite2(4::nat)
比使用后继符号更方便。一如既往,非常感谢您的回复。如果没有您的快速回复,我不知道该怎么办。尽管value“copinite2(4::nat)”
并没有为我编译,正如它所说的内部语法错误⌂ 无法分析术语
。我在回答中添加了一个最小(非)工作示例作为编辑。您的MWE中似乎有一个未闭合的括号-可能就是这个问题?value“coprime 2(4::nat)“
应该绝对有效。另一方面,IIM指出的额外括号会导致确切的错误。一如既往,非常感谢您的回复。如果没有你的快速反应,我不知道该怎么办。虽然值“copinite2(4::nat)”
并没有为我编译,正如它所说的内部语法错误⌂ 无法分析术语
。我在回答中添加了一个最小的(非)工作示例作为编辑。您的MWE中似乎有一个未闭合的括号-这可能就是问题所在?值“coprime 2(4::nat)”
应该绝对有效。另一方面,IIM指出的额外括号会导致这个确切的错误。