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 call to "cofix" failed.
Error: All methods must construct elements in coinductive types.
Je ne sais pas ce que cela signifie - à la fois map
et interleave
sont des valeurs de construction simples fonctions corecursive de types CoInductive. Quel est le problème?
Ceci est une [question connexe] (https://stackoverflow.com/q/39882575/2747511). –