2
元素
Require Import Streams.
CoFixpoint map {X Y : Type} (f : X -> Y) (s : Stream X) : Stream Y :=
Cons (f (hd s)) (map f (tl s)).
CoFixpoint interleave {X : Type} (s : Stream X * Stream X) : Stream X := Cons (hd (fst s)) (Cons (hd (snd s)) (interleave (tl (fst s), tl (snd s)))).
Lemma map_interleave : forall {X Y : Type} (f : X -> Y) (s1 s2 : Stream X), map f (interleave (s1, s2)) = interleave (map f s1, map f s2).
Proof.
Fail cofix. (* error *)
Abort.
輸出:Ltac呼叫「cofix」失敗。錯誤:所有方法都必須構建coinductive類型
Ltac call to "cofix" failed.
Error: All methods must construct elements in coinductive types.
我不知道這意味着什麼 - 無論map
和interleave
是直接corecursive功能coinductive類型的建築價值。有什麼問題?
這是[相關問題](https://stackoverflow.com/q/39882575/2747511)。 –