§ Simulating Inductives Via Coinductives (And Vice Versa)

§ Simulating List from Stream

type Church = (a -> a) -> (a -> a)

zero :: Church
zero f = id

succ :: Church -> Church
succ n f = (n f) . f
type Tuple a b where
  fst :: a
  snd :: b

-- Final encoding of option.
type Option a = {b : Type} -> Tuple b (a -> b) -> b

none :: Option a
none tup = tup.fst

some :: a -> Option a
none a tup = tup.snd a
-- List, final encoding.
type List a = (b : Type) -> (hnil : b) -> (hcons : b -> a -> b)
coinductive OnlyNone (s : Stream (Option a)) : Prop where
  hdNone :: (hd s) = none
  tailNone :: OnlyNone (tail s)
type EventuallyNone (s : Stream (Option a)) : Prop := 
  ∃ (n : Church), OnlyNone ((n Stream.tail) s)