gpt4 book ai didi

类型中的 Idris Nat 文字

转载 作者:行者123 更新时间:2023-12-04 06:18:03 35 4
gpt4 key购买 nike

我想让 idris 证明 testMult : mult 3 3 = 9有人居住。

不幸的是,这是键入为

mult (fromInteger 3) (fromInteger 3) = fromInteger 9 : Type

我可以像这样解决它:
n3 : Nat; n3 = 3
n9 : Nat; n9 = 9
testMult : mult n3 n3 = n9
testMult = Refl

有没有办法做一些类似于 mult (3 : Nat) (3 : Nat) = (9 : Nat) 的事情?

最佳答案

您可以使用功能the : (a : Type) -> a -> a当类型推断失败时指定类型。

testMult : the Nat (3 * 3) = the Nat 9
testMult = Refl

请注意,您需要拥有 the在等式的两边,因为 Idris 具有异构等式,即 (=) : {a : Type} -> {b : Type} -> a -> b -> Type .

或者,你可以写
testMult : the Nat 3 * the Nat 3 = the Nat 9
testMult = Refl

如果你喜欢这种风格。

关于类型中的 Idris Nat 文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17851008/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com