【发布时间】:2023-08-27 22:16:02
【问题描述】:
我正在阅读 Jeremy Gibbons 在 origami programming 上的文章,但在练习 3.7 中遇到了困难,该练习要求读者证明列表展开的融合定律:
unfoldL p f g . h = unfoldL p' f' g'如果
p . h = p' f . h = f' g . h = h . g'
函数unfoldL,用于列表展开,定义如下:
unfoldL :: (b -> Bool) -> (b -> a) -> (b -> b) -> b -> List a
unfoldL p f g b = if p b then Nil else Cons (f b) (unfoldL p f g (g b))
这是我目前的证明尝试:
(unfoldL p f g . h) b
= { composition }
unfoldL p f g (h b)
= { unfoldL }
if p (h b) then Nil else Cons (f (h b)) (unfoldL p f g (g (h b)))
= { composition }
if (p . h) b then Nil else Cons ((f . h) b) (unfoldL p f g ((g . h) b))
= { assumptions }
if p' b then Nil else Cons (f' b) (unfoldL p f g ((h . g') b))
= { composition }
if p' b then Nil else Cons (f' b) ((unfoldL p f g . h) (g' b))
= { ??? }
if p' b then Nil else Cons (f' b) (unfoldL p' f' g' (g' b))
= { unFoldL }
unFoldL p' f' g'
我不确定如何证明标有??? 的步骤。我可能应该对b 上的功能应用程序进行某种归纳?相关问题:有哪些很好的资源可以解释和激发各种归纳技术,例如结构归纳?
【问题讨论】:
标签: haskell recursion proof induction recursion-schemes