-- Conaturals, split out of Codata/stream.nova: the Ξ½-scheme at its
-- simplest sum polynomial (NovaFoundation.txt, "Coinductive
-- types"). conat = Ξ½ (K π β π): zero observes as injβ, a successor
-- as injβ of its predecessor; β is its own predecessor. Ξ²-shaped
-- lemmas close by computation; infSucc is the classic coinductive
-- theorem, by el-nu-coind.
-- Conaturals: Ξ½ (K π β π) β zero observes as injβ, a successor as
-- injβ of its predecessor; β is its own predecessor
conat : π
conat = Ξ½ (K π β π)
czero : conat using (Codata.conat.unfold)
czero = corec (s : π. injβ s) ()
cinf : conat using (Codata.conat.unfold)
cinf = corec (s : π. injβ s) ()
-- observation shapes, by computation (el-nu-beta + el-sum-beta)
outZero : out czero β‘ injβ () β π β conat
using (Codata.conat.eq, czero.eq, hyp.rw, Codata.conat.unfold)
outZero = β
outInf : out cinf β‘ injβ cinf β π β conat
using (cinf.eq, Codata.conat.eq, hyp.rw, Codata.conat.unfold)
outInf = β
-- csucc: emit injβ of the stored conat, continuing by observation
csucc : conat β conat using (Codata.conat.unfold)
csucc = Ξ»n. corec (p : π β conat. injβ (β-elim (u. injβ u) (m. out m) p)) (out n)
-- a successor always observes as injβ β one Ξ² step, the payload
-- irrelevant to the shape (β-elim at an equality motive would refute
-- injβ; here the equation is between the injections themselves)
outSuccInf : out (csucc cinf) β‘ injβ (csucc cinf) β π β conat
using (cinf.eq, Codata.conat.eq, csucc.eq, hyp.rw, Codata.conat.unfold)
outSuccInf = β
-- conat's classic coinductive theorem: β is its own successor. The
-- closure exercises the relator's SUM clause: the β-elim at motive Ξ©
-- is stuck at the generic observations, un-stuck by the invariant's
-- variable-definition equations, and collapses definitionally on the
-- injβ/injβ diagonal.
infSucc : cinf β‘ csucc cinf using (cinf.eq, csucc.eq, hyp.rw, Codata.conat.unfold)
infSucc =
coind
x y. β₯(x β‘ cinf β conat) Γ (y β‘ csucc cinf β conat)β₯
β (β, β)
x y h. squash-elim h (w. β (β, β))