Quotients of Polynomial Functors #
We assume the following:
P
: a polynomial functorW
: its W-typeM
: its M-typeF
: a functor
We define:
The main goal is to construct:
Fix
: the initial algebra with structure mapF Fix → Fix
.Cofix
: the final coalgebra with structure mapCofix → F Cofix
We also show that the composition of qpfs is a qpf, and that the quotient of a qpf is a qpf.
The present theory focuses on the univariate case for qpfs
References #
- [Jeremy Avigad, Mario M. Carneiro and Simon Hudon, Data Types as Quotients of Polynomial Functors][avigad-carneiro-hudon2019]
Quotients of polynomial functors.
Roughly speaking, saying that F
is a quotient of a polynomial functor means that for each α
,
elements of F α
are represented by pairs ⟨a, f⟩
, where a
is the shape of the object and
f
indexes the relevant elements of α
, in a suitably natural manner.
- P : PFunctor.{u}
Instances
two trees are equivalent if their F-abstractions are
- ind: ∀ {F : Type u → Type u} [inst : Functor F] [q : QPF F] (a : (QPF.P F).A) (f f' : (QPF.P F).B a → PFunctor.W (QPF.P F)), (∀ (x : (QPF.P F).B a), QPF.Wequiv (f x) (f' x)) → QPF.Wequiv (WType.mk a f) (WType.mk a f')
- abs: ∀ {F : Type u → Type u} [inst : Functor F] [q : QPF F] (a : (QPF.P F).A) (f : (QPF.P F).B a → PFunctor.W (QPF.P F)) (a' : (QPF.P F).A) (f' : (QPF.P F).B a' → PFunctor.W (QPF.P F)), QPF.abs { fst := a, snd := f } = QPF.abs { fst := a', snd := f' } → QPF.Wequiv (WType.mk a f) (WType.mk a' f')
- trans: ∀ {F : Type u → Type u} [inst : Functor F] [q : QPF F] (u v w : PFunctor.W (QPF.P F)), QPF.Wequiv u v → QPF.Wequiv v w → QPF.Wequiv u w
Instances For
recF
is insensitive to the representation
Define the fixed point as the quotient of trees under the equivalence relation Wequiv
.
Equations
- QPF.Wsetoid = { r := QPF.Wequiv, iseqv := (_ : Equivalence QPF.Wequiv) }
Instances For
recursor of a type defined by a qpf
Equations
- QPF.Fix.rec g = Quot.lift (QPF.recF g) (_ : ∀ (x y : PFunctor.W (QPF.P F)), QPF.Wequiv x y → QPF.recF g x = QPF.recF g y)
Instances For
access the underlying W-type of a fixpoint data type
Equations
- One or more equations did not get rendered due to their size.
Instances For
constructor of a type defined by a qpf
Equations
- QPF.Fix.mk x = Quot.mk Setoid.r (PFunctor.W.mk (PFunctor.map (QPF.P F) QPF.fixToW (QPF.repr x)))
Instances For
destructor of a type defined by a qpf
Equations
- QPF.Fix.dest = QPF.Fix.rec (Functor.map QPF.Fix.mk)
Instances For
does recursion on q.P.M
using g : α → F α
rather than g : α → P α
Equations
- QPF.corecF g = PFunctor.M.corec fun (x : α) => QPF.repr (g x)
Instances For
A pre-congruence on q.P.M
viewed as an F-coalgebra. Not necessarily symmetric.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The maximal congruence on q.P.M
.
Equations
- QPF.Mcongr x y = ∃ (r : PFunctor.M (QPF.P F) → PFunctor.M (QPF.P F) → Prop), QPF.IsPrecongr r ∧ r x y
Instances For
corecursor for type defined by Cofix
Equations
- QPF.Cofix.corec g x = Quot.mk QPF.Mcongr (QPF.corecF g x)
Instances For
Given a qpf F
and a well-behaved surjection FG_abs
from F α
to
functor G α
, G
is a qpf. We can consider G
a quotient on F
where
elements x y : F α
are in the same equivalence class if
FG_abs x = FG_abs y
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
does abs
preserve supp
?
Equations
- QPF.SuppPreservation = ∀ ⦃α : Type u⦄ (x : ↑(QPF.P F) α), Functor.supp (QPF.abs x) = Functor.supp x