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} [inst : MvFunctor F] [q : MvQPF F] {α : TypeVec.{u} n} (a : (MvQPF.P F).A) (f' : TypeVec.Arrow ((MvPFunctor.drop (MvQPF.P F)).B a) α) (f₀ f₁ : (MvPFunctor.last (MvQPF.P F)).B a → MvPFunctor.W (MvQPF.P F) α), (∀ (x : (MvPFunctor.last (MvQPF.P F)).B a), MvQPF.WEquiv (f₀ x) (f₁ x)) → MvQPF.WEquiv (MvPFunctor.wMk (MvQPF.P F) a f' f₀) (MvPFunctor.wMk (MvQPF.P F) a f' f₁)
- abs: ∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [inst : MvFunctor F] [q : MvQPF F] {α : TypeVec.{u} n} (a₀ : (MvQPF.P F).A) (f'₀ : TypeVec.Arrow ((MvPFunctor.drop (MvQPF.P F)).B a₀) α) (f₀ : (MvPFunctor.last (MvQPF.P F)).B a₀ → MvPFunctor.W (MvQPF.P F) α) (a₁ : (MvQPF.P F).A) (f'₁ : TypeVec.Arrow ((MvPFunctor.drop (MvQPF.P F)).B a₁) α) (f₁ : (MvPFunctor.last (MvQPF.P F)).B a₁ → MvPFunctor.W (MvQPF.P F) α), MvQPF.abs { fst := a₀, snd := MvPFunctor.appendContents (MvQPF.P F) f'₀ f₀ } = MvQPF.abs { fst := a₁, snd := MvPFunctor.appendContents (MvQPF.P F) f'₁ f₁ } → MvQPF.WEquiv (MvPFunctor.wMk (MvQPF.P F) a₀ f'₀ f₀) (MvPFunctor.wMk (MvQPF.P F) a₁ f'₁ f₁)
- trans: ∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [inst : MvFunctor F] [q : MvQPF F] {α : TypeVec.{u} n} (u v w : MvPFunctor.W (MvQPF.P F) α), 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 (MvPFunctor.wMk' (MvQPF.P F) ∘ MvQPF.repr)
Instances For
Define the fixed point as the quotient of trees under the equivalence relation.
Equations
- MvQPF.wSetoid α = { r := MvQPF.WEquiv, iseqv := (_ : Equivalence MvQPF.WEquiv) }
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
- One or more equations did not get rendered due to their size.
Instances For
Equations
- MvQPF.Fix.mvfunctor = { map := @MvQPF.Fix.map n F inst q }
Recursor for Fix F
Equations
- MvQPF.Fix.rec g = Quot.lift (MvQPF.recF g) (_ : ∀ (x y : MvPFunctor.W (MvQPF.P F) α), MvQPF.WEquiv x y → MvQPF.recF g x = MvQPF.recF g y)
Instances For
Access W-type underlying Fix F
Equations
- One or more equations did not get rendered due to their size.
Instances For
Constructor for Fix F
Equations
- MvQPF.Fix.mk x = Quot.mk Setoid.r (MvPFunctor.wMk' (MvQPF.P F) (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
- One or more equations did not get rendered due to their size.