The W construction as a multivariate polynomial functor. #
W types are well-founded tree-like structures. They are defined as the least fixpoint of a polynomial functor.
Main definitions #
W_mk
- constructor- `W_dest - destructor
W_rec
- recursor: basis for defining functions by structural recursion onP.W α
W_rec_eq
- defining equation forW_rec
W_ind
- induction principle forP.W α
Implementation notes #
Three views of M-types:
wp
: polynomial functorW
: data type inductively defined by a triple: shape of the root, data in the root and children of the rootW
: least fixed point of a polynomial functor
Specifically, we define the polynomial functor wp
as:
- A := a tree-like structure without information in the nodes
- B := given the tree-like structure
t
,B t
is a valid path (specified inductively byW_path
) from the root oft
to any given node.
As a result wp α
is made of a dataless tree and a function from
its valid paths to values of α
Reference #
- Jeremy Avigad, Mario M. Carneiro and Simon Hudon. Data Types as Quotients of Polynomial Functors
A path from the root of a tree to one of its node
- root {n : ℕ} {P : MvPFunctor.{u} (n + 1)} (a : P.A) (f : P.last.B a → P.last.W) (i : Fin2 n) (c : P.drop.B a i) : P.WPath (WType.mk a f) i
- child {n : ℕ} {P : MvPFunctor.{u} (n + 1)} (a : P.A) (f : P.last.B a → P.last.W) (i : Fin2 n) (j : P.last.B a) (c : P.WPath (f j) i) : P.WPath (WType.mk a f) i
Instances For
Equations
- MvPFunctor.WPath.inhabited P (WType.mk a f) = { default := MvPFunctor.WPath.root a f i default }
Specialized destructor on WPath
Equations
- P.wPathCasesOn g' g i (MvPFunctor.WPath.root a f i c) = g' i c
- P.wPathCasesOn g' g i (MvPFunctor.WPath.child a f i j c) = g j i c
Instances For
Specialized destructor on WPath
Equations
- P.wPathDestLeft h i c = h i (MvPFunctor.WPath.root a f i c)
Instances For
Specialized destructor on WPath
Equations
- P.wPathDestRight h j i c = h i (MvPFunctor.WPath.child a f i j c)
Instances For
Polynomial functor for the W-type of P
. A
is a data-less well-founded
tree whereas, for a given a : A
, B a
is a valid path in tree a
so
that Wp.obj α
is made of a tree and a function from its valid paths to
the values it contains
Equations
- P.wp = { A := P.last.W, B := P.WPath }
Instances For
First, describe operations on W
as a polynomial functor.
Constructor for wp
Instances For
Equations
Instances For
Now think of W as defined inductively by the data ⟨a, f', f⟩ where
a : P.A
is the shape of the top nodef' : P.drop.B a ⟹ α
is the contents of the top nodef : P.last.B a → P.last.W
are the subtrees
Constructor for W
Equations
Instances For
Recursor for W
Equations
- One or more equations did not get rendered due to their size.
Instances For
Defining equation for the recursor of W
Induction principle for W
W-types are functorial
Equations
- P.wMap g x = MvFunctor.map g x
Instances For
Constructor of a value of P.obj (α ::: β)
from components.
Useful to avoid complicated type annotation
Equations
- P.objAppend1 a f' f = ⟨a, TypeVec.splitFun f' f⟩
Instances For
Yet another view of the W type: as a fixed point for a multivariate polynomial functor.
These are needed to use the W-construction to construct a fixed point of a qpf, since
the qpf axioms are expressed in terms of map
on P
.
Constructor for the W-type of P
Equations
- P.wMk' ⟨a, f⟩ = P.wMk a (TypeVec.dropFun f) (TypeVec.lastFun f)
Instances For
Destructor for the W-type of P
Equations
- P.wDest' = P.wRec fun (a : P.A) (f' : (P.drop.B a).Arrow α) (f : P.last.B a → P.W α) (x : P.last.B a → ↑P (α ::: P.W α)) => ⟨a, TypeVec.splitFun f' f⟩