The initial algebra of a multivariate qpf is again a qpf. #
For an (n+1)
-ary QPF F (α₀,..,αₙ)
, we take the least fixed point of F
with
regards to its last argument αₙ
. The result is an n
-ary functor: Fix F (α₀,..,αₙ₋₁)
.
Making Fix F
into a functor allows us to take the fixed point, compose with other functors
and take a fixed point again.
Main definitions #
Fix.mk
- constructorFix.dest
- destructorFix.rec
- recursor: basis for defining functions by structural recursion onFix F α
Fix.drec
- dependent recursor: generalization ofFix.rec
where the result type of the function is allowed to depend on theFix F α
valueFix.rec_eq
- defining equation forrecursor
Fix.ind
- induction principle forFix F α
Implementation notes #
For F
a QPF
, we define Fix F α
in terms of the W-type of the polynomial functor P
of F
.
We define the relation WEquiv
and take its quotient as the definition of Fix F α
.
See [avigad-carneiro-hudon2019] for more details.
Reference #
- Jeremy Avigad, Mario M. Carneiro and Simon Hudon. [Data Types as Quotients of Polynomial Functors][avigad-carneiro-hudon2019]
recF
is used as a basis for defining the recursor on Fix F α
. recF
traverses recursively the W-type generated by q.P
using a function on F
as a recursive step
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equivalence relation on W-types that represent the same Fix F
value
- ind: ∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (a : (MvQPF.P F).A) (f' : ((MvQPF.P F).drop.B a).Arrow α) (f₀ f₁ : (MvQPF.P F).last.B a → (MvQPF.P F).W α), (∀ (x : (MvQPF.P F).last.B a), MvQPF.WEquiv (f₀ x) (f₁ x)) → MvQPF.WEquiv ((MvQPF.P F).wMk a f' f₀) ((MvQPF.P F).wMk a f' f₁)
- abs: ∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (a₀ : (MvQPF.P F).A) (f'₀ : ((MvQPF.P F).drop.B a₀).Arrow α) (f₀ : (MvQPF.P F).last.B a₀ → (MvQPF.P F).W α) (a₁ : (MvQPF.P F).A) (f'₁ : ((MvQPF.P F).drop.B a₁).Arrow α) (f₁ : (MvQPF.P F).last.B a₁ → (MvQPF.P F).W α), MvQPF.abs ⟨a₀, (MvQPF.P F).appendContents f'₀ f₀⟩ = MvQPF.abs ⟨a₁, (MvQPF.P F).appendContents f'₁ f₁⟩ → MvQPF.WEquiv ((MvQPF.P F).wMk a₀ f'₀ f₀) ((MvQPF.P F).wMk a₁ f'₁ f₁)
- trans: ∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (u v w : (MvQPF.P F).W α), MvQPF.WEquiv u v → MvQPF.WEquiv v w → MvQPF.WEquiv u w
Instances For
maps every element of the W type to a canonical representative
Equations
- MvQPF.wrepr = MvQPF.recF ((MvQPF.P F).wMk' ∘ MvQPF.repr)
Instances For
Define the fixed point as the quotient of trees under the equivalence relation.
Equations
- MvQPF.wSetoid α = { r := MvQPF.WEquiv, iseqv := ⋯ }
Instances For
Least fixed point of functor F. The result is a functor with one fewer parameters
than the input. For F a b c
a ternary functor, Fix F
is a binary functor such that
Fix F a b = F a b (Fix F a b)
Equations
- MvQPF.Fix F α = Quotient (MvQPF.wSetoid α)
Instances For
Fix F
is a functor
Equations
- MvQPF.Fix.map g = Quotient.lift (fun (x : (MvQPF.P F).W α) => ⟦(MvQPF.P F).wMap g x⟧) ⋯
Instances For
Equations
- MvQPF.Fix.mvfunctor = { map := fun {α β : TypeVec.{?u.39} n} => MvQPF.Fix.map }
Recursor for Fix F
Equations
- MvQPF.Fix.rec g = Quot.lift (MvQPF.recF g) ⋯
Instances For
Access W-type underlying Fix F
Equations
- MvQPF.fixToW = Quotient.lift MvQPF.wrepr ⋯
Instances For
Constructor for Fix F
Equations
- MvQPF.Fix.mk x = Quot.mk (⇑(MvQPF.wSetoid α)) ((MvQPF.P F).wMk' (MvFunctor.map (TypeVec.id ::: MvQPF.fixToW) (MvQPF.repr x)))
Instances For
Destructor for Fix F
Equations
- MvQPF.Fix.dest = MvQPF.Fix.rec (MvFunctor.map (TypeVec.id ::: MvQPF.Fix.mk))
Instances For
Equations
- One or more equations did not get rendered due to their size.
Dependent recursor for fix F
Equations
- MvQPF.Fix.drec g x = cast ⋯ (MvQPF.Fix.rec (fun (i : F (α ::: Sigma β)) => ⟨MvQPF.Fix.mk (MvFunctor.map (TypeVec.id ::: Sigma.fst) i), g i⟩) x).snd