5

我希望伊德里斯证明那里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)

4

1 回答 1

6

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

如果你喜欢那种风格。

于 2013-10-12T11:46:22.700 回答