在Idris中,使用lambda下的重写

时间:2017-05-09 20:21:10

标签: idris

根据https://homes.cs.washington.edu/~jrw12/InductionExercises.html我要证明sumsum_cont是等价的。我到了:

sum : List Nat -> Nat
sum [] = 0
sum (x :: xs) = x + sum xs

sum_cont' : {a : Type} -> List Nat -> (Nat -> a) -> a
sum_cont' [] k = k 0
sum_cont' (x :: xs) k = sum_cont' xs (\ans => k (x + ans))

sum_cont : List Nat -> Nat
sum_cont l = sum_cont' l (\x => x)

sum_cont_correct' : (xs : List Nat) -> (x : Nat) -> sum_cont' xs (\ans => plus x ans) = plus x (sum xs)
sum_cont_correct' [] acc = Refl
sum_cont_correct' (x :: xs) acc =
    rewrite plusAssociative acc x (sum xs) in
    ?todo

todo的类型为:

sum_cont' xs (\ans => plus acc (plus x ans)) = plus (plus acc x) (sum xs)

我想应用重写plusAssociative acc x ans,但ans不在顶部范围内。如何将lambda下的重写应用于我无法绑定的变量?

问题How do I prove a "seemingly obvious" fact when relevant types are abstracted by a lambda in Idris?似乎回答了一些类似的观点,但最终建议使用cong,这在这里是不合适的,因为在我应用内部重写之后,我无法使外部部分相似。< / p>

0 个答案:

没有答案