Documentation

Mathlib.Data.PFunctor.Univariate.Basic

Polynomial functors #

This file defines polynomial functors and the W-type construction as a polynomial functor. (For the M-type construction, see pfunctor/M.lean.)

structure PFunctor :
Type (u + 1)

A polynomial functor P is given by a type A and a family B of types over A. P maps any type α to a new type P α, which is defined as the sigma type Σ x, P.B x → α.

An element of P α is a pair ⟨a, f⟩, where a is an element of a type A and f : B a → α. Think of a as the shape of the object and f as an index to the relevant elements of α.

  • A : Type u

    The head type

  • B : self.AType u

    The child family of types

Instances For
    Equations
    def PFunctor.Obj (P : PFunctor.{u}) (α : Type v) :
    Type (max u u v)

    Applying P to an object of Type

    Equations
    • P α = ((x : P.A) × (P.B xα))
    Instances For
      def PFunctor.map (P : PFunctor.{u}) {α : Type v₁} {β : Type v₂} (f : αβ) :
      P αP β

      Applying P to a morphism of Type

      Equations
      • PFunctor.map P f x = match x with | { fst := a, snd := g } => { fst := a, snd := f g }
      Instances For
        instance PFunctor.Obj.inhabited (P : PFunctor.{u}) {α : Type v₁} [Inhabited P.A] [Inhabited α] :
        Inhabited (P α)
        Equations
        Equations
        @[simp]
        theorem PFunctor.map_eq_map (P : PFunctor.{u}) {α : Type v} {β : Type v} (f : αβ) (x : P α) :
        f <$> x = PFunctor.map P f x

        We prefer PFunctor.map to Functor.map because it is universe-polymorphic.

        @[simp]
        theorem PFunctor.map_eq (P : PFunctor.{u}) {α : Type v₁} {β : Type v₂} (f : αβ) (a : P.A) (g : P.B aα) :
        PFunctor.map P f { fst := a, snd := g } = { fst := a, snd := f g }
        @[simp]
        theorem PFunctor.id_map (P : PFunctor.{u}) {α : Type v₁} (x : P α) :
        PFunctor.map P id x = x
        @[simp]
        theorem PFunctor.map_map (P : PFunctor.{u}) {α : Type v₁} {β : Type v₂} {γ : Type v₃} (f : αβ) (g : βγ) (x : P α) :

        re-export existing definition of W-types and adapt it to a packaged definition of polynomial functor

        Equations
        Instances For

          root element of a W tree

          Equations
          Instances For

            children of the root of a W tree

            Equations
            Instances For

              destructor for W-types

              Equations
              Instances For

                constructor for W-types

                Equations
                Instances For

                  Idx identifies a location inside the application of a pfunctor. For F : PFunctor, x : F α and i : F.Idx, i can designate one part of x or is invalid, if i.1 ≠ x.1

                  Equations
                  Instances For
                    Equations
                    def PFunctor.Obj.iget {P : PFunctor.{u}} [DecidableEq P.A] {α : Type u_1} [Inhabited α] (x : P α) (i : PFunctor.Idx P) :
                    α

                    x.iget i takes the component of x designated by i if any is or returns a default value

                    Equations
                    Instances For
                      @[simp]
                      theorem PFunctor.fst_map {P : PFunctor.{u}} {α : Type v₁} {β : Type v₂} (x : P α) (f : αβ) :
                      (PFunctor.map P f x).fst = x.fst
                      @[simp]
                      theorem PFunctor.iget_map {P : PFunctor.{u}} {α : Type v₁} {β : Type v₂} [DecidableEq P.A] [Inhabited α] [Inhabited β] (x : P α) (f : αβ) (i : PFunctor.Idx P) (h : i.fst = x.fst) :

                      functor composition for polynomial functors

                      Equations
                      • PFunctor.comp P₂ P₁ = { A := (a₂ : P₂.A) × (P₂.B a₂P₁.A), B := fun (a₂a₁ : (a₂ : P₂.A) × (P₂.B a₂P₁.A)) => (u : P₂.B a₂a₁.fst) × P₁.B (a₂a₁.snd u) }
                      Instances For
                        def PFunctor.comp.mk (P₂ : PFunctor.{u}) (P₁ : PFunctor.{u}) {α : Type} (x : P₂ (P₁ α)) :
                        (PFunctor.comp P₂ P₁) α

                        constructor for composition

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def PFunctor.comp.get (P₂ : PFunctor.{u}) (P₁ : PFunctor.{u}) {α : Type} (x : (PFunctor.comp P₂ P₁) α) :
                          P₂ (P₁ α)

                          destructor for composition

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem PFunctor.liftp_iff {P : PFunctor.{u}} {α : Type u} (p : αProp) (x : P α) :
                            Functor.Liftp p x ∃ (a : P.A) (f : P.B aα), x = { fst := a, snd := f } ∀ (i : P.B a), p (f i)
                            theorem PFunctor.liftp_iff' {P : PFunctor.{u}} {α : Type u} (p : αProp) (a : P.A) (f : P.B aα) :
                            Functor.Liftp p { fst := a, snd := f } ∀ (i : P.B a), p (f i)
                            theorem PFunctor.liftr_iff {P : PFunctor.{u}} {α : Type u} (r : ααProp) (x : P α) (y : P α) :
                            Functor.Liftr r x y ∃ (a : P.A) (f₀ : P.B aα) (f₁ : P.B aα), x = { fst := a, snd := f₀ } y = { fst := a, snd := f₁ } ∀ (i : P.B a), r (f₀ i) (f₁ i)
                            theorem PFunctor.supp_eq {P : PFunctor.{u}} {α : Type u} (a : P.A) (f : P.B aα) :
                            Functor.supp { fst := a, snd := f } = f '' Set.univ