I have a data type
data N a = N a [N a]
of rose trees and Applicative instance
instance Applicative N where
pure a = N a (repeat (pure a))
(N f xs) <*> (N a ys) = N (f a) (zipWith (<*>) xs ys)
and need to prove the Applicative laws for it. However, pure creates infinitely deep, infinitely branching trees. So, for instance, in proving the homomorphism law
pure f <*> pure a = pure (f a)
I thought that proving the equality
zipWith (<*>) (repeat (pure f)) (repeat (pure a)) = repeat (pure (f a))
by the approximation (or take) lemma would work. However, my attempts lead to "vicious circles" in the inductive step. In particular, reducing
approx (n + 1) (zipWith (<*>) (repeat (pure f)) (repeat (pure a))
gives
(pure f <*> pure a) : approx n (repeat (pure (f a)))
where approx is the approximation function. How can I prove the equality without an explicit coinductive proof?