Multivariate quotients of polynomial functors. #
Basic definition of multivariate QPF. QPFs form a compositional framework for defining inductive and coinductive types, their quotients and nesting.
The idea is based on building ever larger functors. For instance, we can define a list using a shape functor:
inductive ListShape (a b : Type)
| nil : ListShape
| cons : a -> b -> ListShape
This shape can itself be decomposed as a sum of product which are themselves QPFs. It follows that the shape is a QPF and we can take its fixed point and create the list itself:
def List (a : Type) := fix ListShape a -- not the actual notation
We can continue and define the quotient on permutation of lists and create the multiset type:
def Multiset (a : Type) := QPF.quot List.perm List a -- not the actual notion
And Multiset
is also a QPF. We can then create a novel data type (for Lean):
inductive Tree (a : Type)
| node : a -> Multiset Tree -> Tree
An unordered tree. This is currently not supported by Lean because it nests an inductive type inside of a quotient. We can go further and define unordered, possibly infinite trees:
coinductive Tree' (a : Type)
| node : a -> Multiset Tree' -> Tree'
by using the cofix
construct. Those options can all be mixed and
matched because they preserve the properties of QPF. The latter example,
Tree'
, combines fixed point, co-fixed point and quotients.
Related modules #
- constructions
- Fix
- Cofix
- Quot
- Comp
- Sigma / Pi
- Prj
- Const
each proves that some operations on functors preserves the QPF structure
Reference #
Jeremy Avigad, Mario M. Carneiro and Simon Hudon, Data Types as Quotients of Polynomial Functors
Multivariate quotients of polynomial functors.
- map : {α β : TypeVec.{u} n} → α.Arrow β → F α → F β
- P : MvPFunctor.{u} n
- abs : {α : TypeVec.{u} n} → ↑(MvQPF.P F) α → F α
- repr : {α : TypeVec.{u} n} → F α → ↑(MvQPF.P F) α
- abs_repr : ∀ {α : TypeVec.{u} n} (x : F α), MvQPF.abs (MvQPF.repr x) = x
- abs_map : ∀ {α β : TypeVec.{u} n} (f : α.Arrow β) (p : ↑(MvQPF.P F) α), MvQPF.abs (MvFunctor.map f p) = MvFunctor.map f (MvQPF.abs p)
Instances
Show that every MvQPF is a lawful MvFunctor. #
Equations
- ⋯ = ⋯
A qpf is said to be uniform if every polynomial functor representing a single value all have the same range.
Equations
- One or more equations did not get rendered due to their size.
Instances For
does abs
preserve liftp
?
Equations
- MvQPF.LiftPPreservation = ∀ ⦃α : TypeVec.{?u.6} n⦄ (p : ⦃i : Fin2 n⦄ → α i → Prop) (x : ↑(MvQPF.P F) α), MvFunctor.LiftP p (MvQPF.abs x) ↔ MvFunctor.LiftP p x
Instances For
does abs
preserve supp
?
Equations
- MvQPF.SuppPreservation = ∀ ⦃α : TypeVec.{?u.25} n⦄ (x : ↑(MvQPF.P F) α), MvFunctor.supp (MvQPF.abs x) = MvFunctor.supp x
Instances For
Any type function F
that is (extensionally) equivalent to a QPF, is itself a QPF,
assuming that the functorial map of F
behaves similar to MvFunctor.ofEquiv eqv
Equations
- One or more equations did not get rendered due to their size.
Instances For
Every polynomial functor is a (trivial) QPF
Equations
- P.instMvQPFObj = MvQPF.mk P (fun {α : TypeVec.{?u.17} n} => id) (fun {α : TypeVec.{?u.17} n} => id) ⋯ ⋯