【发布时间】:2019-10-01 22:15:42
【问题描述】:
我试图通过尝试证明计算三角数的计算方法与它们的封闭形式的等价性来了解一些简单的证明。到目前为止,我已经设法实现的是:
total
tn_eval : (n : Nat) -> Nat
tn_eval Z = Z
tn_eval (S k) = (S k) + tn_eval k
total
tn_closed : (n: Nat) -> Nat
tn_closed Z = Z
tn_closed (S k) = div ((S k) * ((S k) - 1)) 2
total
tn_closed_proof : (n : Nat) -> (tn_closed n) = (tn_eval n)
tn_closed_proof Z = ?strange_hole
tn_closed_proof (S k) = ?more_difficult_hole
但是,我对?strange_hole 的可能定义感到困惑。检查类型给出:
Idris: Type of strange_hole
--------------------------------------
strange_hole : tn_closed 0 = 0
这(据我所知)实际上是tn_closed Z 的定义,因此,这应该可以简单地使用Refl 来证明,因为tn_closed 0 在定义上等同于0。
但是,这是不对的,当我尝试这个时,我得到一个类型错误:
When checking right hand side of tn_closed_proof with expected type
tn_closed 0 = tn_eval 0
Type mismatch between
0 = 0 (Type of Refl)
and
tn_closed 0 = 0 (Expected type)
Specifically:
Type mismatch between
0
and
tn_closed 0
连同整体警告:
Arith.tn_closed is possibly not total due to: Prelude.Nat.Nat implementation of Prelude.Interfaces.Integral
我觉得后者可能是前者的原因,但除此之外我完全被卡住了!据我了解,tn_closed 0 和 0根据定义是等效的,所以任何需要 tn_closed 0 = 0 的证明都应该是微不足道的,或者可以用 Refl 证明,但看起来我是错了……
【问题讨论】: