M-types #
M types are potentially infinite tree-like structures. They are defined as the greatest fixpoint of a polynomial functor.
CofixA F n is an n level approximation of an M-type
- continue {F : PFunctor.{uA, uB}} : CofixA F 0
- intro {F : PFunctor.{uA, uB}} {n : ℕ} (a : F.A) : (F.B a → CofixA F n) → CofixA F n.succ
Instances For
Equations
- PFunctor.Approx.instInhabitedCofixAOfA F = { default := PFunctor.Approx.CofixA.default F n }
The label of the root of the tree for a non-trivial approximation of the cofix of a pfunctor.
Equations
Instances For
for a non-trivial approximation, return all the subtrees of the root
Equations
Instances For
Relation between two approximations of the cofix of a pfunctor that state they both contain the same data until one of them is truncated
- continu {F : PFunctor.{uA, uB}} (x : CofixA F 0) (y : CofixA F 1) : Agree x y
- intro {F : PFunctor.{uA, uB}} {n : ℕ} {a : F.A} (x : F.B a → CofixA F n) (x' : F.B a → CofixA F (n + 1)) : (∀ (i : F.B a), Agree (x i) (x' i)) → Agree (CofixA.intro a x) (CofixA.intro a x')
Instances For
Given an infinite series of approximations approx,
AllAgree approx states that they are all consistent with each other.
Equations
- PFunctor.Approx.AllAgree x = ∀ (n : ℕ), PFunctor.Approx.Agree (x n) (x n.succ)
Instances For
Alias of PFunctor.Approx.agree_trivial.
sCorec f i n creates an approximation of height n
of the final coalgebra of f
Equations
- PFunctor.Approx.sCorec f x✝ 0 = PFunctor.Approx.CofixA.continue
- PFunctor.Approx.sCorec f x✝ n.succ = PFunctor.Approx.CofixA.intro (f x✝).fst fun (i : F.B (f x✝).fst) => PFunctor.Approx.sCorec f ((f x✝).snd i) n
Instances For
Path F provides indices to access internal nodes in Corec F
Equations
- PFunctor.Approx.Path F = List F.Idx
Instances For
Internal definition for M. It is needed to avoid name clashes
between M.mk and M.casesOn and the declarations generated for
the structure
- approx (n : ℕ) : Approx.CofixA F n
An
n-th level approximation, for each depthn - consistent : Approx.AllAgree self.approx
Each approximation agrees with the next
Instances For
For polynomial functor F, M F is its final coalgebra
Instances For
Equations
Corecursor for the M-type defined by F.
Equations
- PFunctor.M.corec f i = { approx := PFunctor.Approx.sCorec f i, consistent := ⋯ }
Instances For
given a tree generated by F, head gives us the first piece of data
it contains
Equations
- x.head = PFunctor.Approx.head' (x.approx 1)
Instances For
select a subtree using an i : F.Idx or return an arbitrary tree if
i designates no subtree of x
Equations
Instances For
generates the approximations needed for M.mk
Equations
- PFunctor.M.Approx.sMk x 0 = PFunctor.Approx.CofixA.continue
- PFunctor.M.Approx.sMk x n.succ = PFunctor.Approx.CofixA.intro x.fst fun (i : F.B x.fst) => (x.snd i).approx n
Instances For
constructor for M-types
Equations
- PFunctor.M.mk x = { approx := PFunctor.M.Approx.sMk x, consistent := ⋯ }
Instances For
Agree' n relates two trees of type M F that
are the same up to depth n
- trivial {F : PFunctor.{uA, uB}} (x y : F.M) : Agree' 0 x y
- step {F : PFunctor.{uA, uB}} {n : ℕ} {a : F.A} (x y : F.B a → F.M) {x' y' : F.M} : x' = M.mk ⟨a, x⟩ → y' = M.mk ⟨a, y⟩ → (∀ (i : F.B a), Agree' n (x i) (y i)) → Agree' n.succ x' y'
Instances For
destructor for M-types
Equations
- PFunctor.M.cases f x = ⋯.mpr (f x.dest)
Instances For
destructor for M-types
Equations
- x.casesOn f = PFunctor.M.cases f x
Instances For
follow a path through a value of M F and return the subtree
found at the end of the path if it is a valid path for that value and
return a default tree
Equations
Instances For
similar to isubtree but returns the data at the end of the path instead
of the whole subtree
Equations
- PFunctor.M.iselect ps x = (PFunctor.M.isubtree ps x).head
Instances For
corecursor for M F with swapped arguments
Equations
- PFunctor.M.corecOn x₀ f = PFunctor.M.corec f x₀
Instances For
corecursor where the state of the computation can be sent downstream in the form of a recursive call
Equations
- PFunctor.M.corec₁ F = PFunctor.M.corec (F α id)
Instances For
corecursor where it is possible to return a fully formed value at any point of the computation
Equations
- One or more equations did not get rendered due to their size.