The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.QPF.Multivariate.Constructions.Fix

35 declarations. Mathlib docs · Source

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 - constructor
  • Fix.dest - destructor
  • Fix.rec - recursor: basis for defining functions by structural recursion on Fix F α
  • Fix.drec - dependent recursor: generalization of Fix.rec where the result type of the function is allowed to depend on the Fix F α value
  • Fix.rec_eq - defining equation for recursor
  • Fix.ind - induction principle for Fix 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.

References

  • Jeremy Avigad, Mario M. Carneiro and Simon Hudon. [Data Types as Quotients of Polynomial Functors][avigad-carneiro-hudon2019]

ctor MvQPF.WEquiv.below.ind E0 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n}
  {motive : (a a_1 : (MvQPF.P F).W α) → MvQPF.WEquiv a a_1 → Prop} (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 α)
  (a_1 : ∀ (x : (MvQPF.P F).last.B a), MvQPF.WEquiv (f₀ x) (f₁ x)),
  (∀ (x : (MvQPF.P F).last.B a), MvQPF.WEquiv.below ⋯) →
    (∀ (x : (MvQPF.P F).last.B a), motive (f₀ x) (f₁ x) ⋯) → MvQPF.WEquiv.below ⋯

ctor MvQPF.WEquiv.below.trans E0 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n}
  {motive : (a a_1 : (MvQPF.P F).W α) → MvQPF.WEquiv a a_1 → Prop} (u v w : (MvQPF.P F).W α) (a : MvQPF.WEquiv u v)
  (a_1 : MvQPF.WEquiv v w),
  MvQPF.WEquiv.below a → motive u v a → MvQPF.WEquiv.below a_1 → motive v w a_1 → MvQPF.WEquiv.below ⋯

ctor MvQPF.WEquiv.below.abs E0 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n}
  {motive : (a a_1 : (MvQPF.P F).W α) → MvQPF.WEquiv a a_1 → Prop} (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 α)
  (a : MvQPF.abs ⟨a₀, (MvQPF.P F).appendContents f'₀ f₀⟩ = MvQPF.abs ⟨a₁, (MvQPF.P F).appendContents f'₁ f₁⟩),
  MvQPF.WEquiv.below ⋯

def MvQPF.recF E1 #

{n : ℕ} →
  {F : TypeVec.{u} (n + 1) → Type u} →
    [q : MvQPF F] → {α : TypeVec.{u} n} → {β : Type u} → (F (α ::: β) → β) → (MvQPF.P F).W α → β

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

theorem MvQPF.recF_eq E0 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} {β : Type u} (g : F (α ::: β) → β)
  (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.recF g ((MvQPF.P F).wMk a f' f) = g (MvQPF.abs ⟨a, TypeVec.splitFun f' (MvQPF.recF g ∘ f)⟩)

theorem MvQPF.recF_eq' E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} {β : Type u} (g : F (α ::: β) → β)
  (x : (MvQPF.P F).W α),
  MvQPF.recF g x = g (MvQPF.abs (MvFunctor.map (TypeVec.id ::: MvQPF.recF g) ((MvQPF.P F).wDest' x)))

inductive MvQPF.WEquiv E1 #

{n : ℕ} →
  {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → {α : TypeVec.{u} n} → (MvQPF.P F).W α → (MvQPF.P F).W α → Prop

Equivalence relation on W-types that represent the same Fix F value

ctor MvQPF.WEquiv.ind E0 #

∀ {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₁)

ctor MvQPF.WEquiv.abs E0 #

∀ {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₁)

ctor MvQPF.WEquiv.trans E0 #

∀ {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

theorem MvQPF.recF_eq_of_wEquiv E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] (α : TypeVec.{u} n) {β : Type u} (u : F (α ::: β) → β)
  (x y : (MvQPF.P F).W α), MvQPF.WEquiv x y → MvQPF.recF u x = MvQPF.recF u y

theorem MvQPF.wEquiv.abs' E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (x y : (MvQPF.P F).W α),
  MvQPF.abs ((MvQPF.P F).wDest' x) = MvQPF.abs ((MvQPF.P F).wDest' y) → MvQPF.WEquiv x y

theorem MvQPF.wEquiv.refl E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (x : (MvQPF.P F).W α), MvQPF.WEquiv x x

theorem MvQPF.wEquiv.symm E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (x y : (MvQPF.P F).W α),
  MvQPF.WEquiv x y → MvQPF.WEquiv y x

def MvQPF.wrepr E1 #

{n : ℕ} → {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → {α : TypeVec.{u} n} → (MvQPF.P F).W α → (MvQPF.P F).W α

maps every element of the W type to a canonical representative

theorem MvQPF.wrepr_wMk E1 #

∀ {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 α),
  MvQPF.wrepr ((MvQPF.P F).wMk a f' f) =
    (MvQPF.P F).wMk'
      (MvQPF.repr (MvQPF.abs (MvFunctor.map (TypeVec.id ::: MvQPF.wrepr) ⟨a, (MvQPF.P F).appendContents f' f⟩)))

theorem MvQPF.wrepr_equiv E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (x : (MvQPF.P F).W α),
  MvQPF.WEquiv (MvQPF.wrepr x) x

theorem MvQPF.wEquiv_map E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α β : TypeVec.{u} n} (g : α.Arrow β)
  (x y : (MvQPF.P F).W α), MvQPF.WEquiv x y → MvQPF.WEquiv (MvFunctor.map g x) (MvFunctor.map g y)

def MvQPF.wSetoid E1 #

{n : ℕ} → {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → (α : TypeVec.{u} n) → Setoid ((MvQPF.P F).W α)

Define the fixed point as the quotient of trees under the equivalence relation.

def MvQPF.Fix E1 #

{n : ℕ} → (F : TypeVec.{u_1} (n + 1) → Type u_1) → [q : MvQPF F] → TypeVec.{u_1} n → Type u_1

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)

def MvQPF.Fix.map E1 #

{n : ℕ} →
  {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → {α β : TypeVec.{u} n} → α.Arrow β → MvQPF.Fix F α → MvQPF.Fix F β

Fix F is a functor

instance MvQPF.Fix.mvfunctor E0 #

{n : ℕ} → {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → MvFunctor (MvQPF.Fix F)

def MvQPF.Fix.rec E3 #

{n : ℕ} →
  {F : TypeVec.{u} (n + 1) → Type u} →
    [q : MvQPF F] → {α : TypeVec.{u} n} → {β : Type u} → (F (α ::: β) → β) → MvQPF.Fix F α → β

Recursor for Fix F

def MvQPF.fixToW E1 #

{n : ℕ} → {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → {α : TypeVec.{u} n} → MvQPF.Fix F α → (MvQPF.P F).W α

Access W-type underlying Fix F

def MvQPF.Fix.mk E3 #

{n : ℕ} →
  {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → {α : TypeVec.{u} n} → F (α ::: MvQPF.Fix F α) → MvQPF.Fix F α

Constructor for Fix F

def MvQPF.Fix.dest E3 #

{n : ℕ} →
  {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → {α : TypeVec.{u} n} → MvQPF.Fix F α → F (α ::: MvQPF.Fix F α)

Destructor for Fix F

theorem MvQPF.Fix.rec_eq E3 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} {β : Type u} (g : F (α ::: β) → β)
  (x : F (α ::: MvQPF.Fix F α)), MvQPF.Fix.rec g (MvQPF.Fix.mk x) = g (MvFunctor.map (TypeVec.id ::: MvQPF.Fix.rec g) x)

theorem MvQPF.Fix.ind_aux E0 #

∀ {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 α),
  MvQPF.Fix.mk (MvQPF.abs ⟨a, (MvQPF.P F).appendContents f' fun x ↦ ⟦f x⟧⟩) = ⟦(MvQPF.P F).wMk a f' f⟧

theorem MvQPF.Fix.ind_rec E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} {β : Type u} (g₁ g₂ : MvQPF.Fix F α → β),
  (∀ (x : F (α ::: MvQPF.Fix F α)),
      MvFunctor.map (TypeVec.id ::: g₁) x = MvFunctor.map (TypeVec.id ::: g₂) x →
        g₁ (MvQPF.Fix.mk x) = g₂ (MvQPF.Fix.mk x)) →
    ∀ (x : MvQPF.Fix F α), g₁ x = g₂ x

theorem MvQPF.Fix.rec_unique E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} {β : Type u} (g : F (α ::: β) → β)
  (h : MvQPF.Fix F α → β),
  (∀ (x : F (α ::: MvQPF.Fix F α)), h (MvQPF.Fix.mk x) = g (MvFunctor.map (TypeVec.id ::: h) x)) → MvQPF.Fix.rec g = h

theorem MvQPF.Fix.mk_dest E1 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (x : MvQPF.Fix F α),
  MvQPF.Fix.mk x.dest = x

theorem MvQPF.Fix.dest_mk E0 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (x : F (α ::: MvQPF.Fix F α)),
  (MvQPF.Fix.mk x).dest = x

theorem MvQPF.Fix.ind E3 #

∀ {n : ℕ} {F : TypeVec.{u} (n + 1) → Type u} [q : MvQPF F] {α : TypeVec.{u} n} (p : MvQPF.Fix F α → Prop),
  (∀ (x : F (α ::: MvQPF.Fix F α)), MvFunctor.LiftP (α.PredLast p) x → p (MvQPF.Fix.mk x)) → ∀ (x : MvQPF.Fix F α), p x

instance MvQPF.mvqpfFix E0 #

{n : ℕ} → {F : TypeVec.{u} (n + 1) → Type u} → [q : MvQPF F] → MvQPF (MvQPF.Fix F)

def MvQPF.Fix.drec E3 #

{n : ℕ} →
  {F : TypeVec.{u} (n + 1) → Type u} →
    [q : MvQPF F] →
      {α : TypeVec.{u} n} →
        {β : MvQPF.Fix F α → Type u} →
          ((x : F (α ::: Sigma β)) → β (MvQPF.Fix.mk (MvFunctor.map (TypeVec.id ::: Sigma.fst) x))) →
            (x : MvQPF.Fix F α) → β x

Dependent recursor for fix F