The universal property of final coalgebras can be formalized as
unique-ana : β (f : A β B Γ A) (g : A β Stream B) β
unfold β g β‘ mapβ g β f β g β‘ ana f
where
unfold : Stream B β B Γ Stream B -- Final coalgebra
ana : (A β B Γ A) β A β Stream B -- Anamorphism of a coalgebra
mapβ : (A β S) β B Γ A β B Γ S -- The functor (B Γ_)
Assuming functional extensionality (which you have in ExtMLTT), unique-ana
is indeed equivalent to the bisimulation principle, aka. stream extensionality:
stream-ext : s β t β s β‘ t
where
_β_ : {A : Set} β Stream A β Stream A β Typeβ -- Bisimilarity
s β t = Ξ£[ R β (Stream _ β Stream _ β Type) ]
R s t Γ (β {u v} β R u v β (u .hd β‘ v .hd) Γ R (u .tl) (v .tl)))
The trick is to view a stream s : Stream A
as a coalgebra index s : β β A Γ β
, which given an index i
returns the i
-th element of s
and the incremented index i+1
. Define drop i s
as the stream after dropping the first i
elements of s
. The universal property unique-ana
tells you that drop i s = ana (index s) i
. Then s β t β s β‘ t
can be proved as follows:
s
β‘ drop 0 s -- by definition
β‘ ana (index s) 0 -- by unique-ana
β‘ ana (index t) 0 -- by fun-ext and s β t
β‘ drop 0 t -- by unique-ana
β‘ t -- by definition
Note that the bisimulation principle is a coinduction principle for the identity type on streams: in your formulation, the premises above the bar is a coalgebra (an object R
and a morphism R ~> F R
for a certain endofunctor F
) and the conclusion is the anamorphism R ~> _β‘_
.
postulate
for that." (This was Agda.) $\endgroup$