Documentation

PolyFun.PFunctor.Basic

Polynomial Functors, Lens, and Charts #

This file defines polynomial functors, lenses, and charts. The goal is to provide basic definitions, with their properties and categories defined in later files.

dt: this file is getting long and should maybe be split up more.

@[implicit_reducible]

The zero polynomial functor, defined as A = PEmpty and B _ = PEmpty, is the identity with respect to sum (up to equivalence)

@[implicit_reducible]

The unit polynomial functor, defined as A = PUnit and B _ = PEmpty, is the identity with respect to product (up to equivalence)

The variable y polynomial functor. This is the unit for composition.

Instances For
    @[implicit_reducible]
    @[implicit_reducible]

    The monomial functor, also written P(X) = A X^ B, has A as its head type and the constant family B_a = B as the child type for each each shape a : A .

    Instances For

      The monomial functor, also written P(X) = A X^ B, has A as its head type and the constant family B_a = B as the child type for each each shape a : A .

      Instances For

        The constant polynomial functor P(X) = A X^ PEmpty

        Instances For

          The variable (or indeterminate) polynomial functor X, defined as P(X) = PUnit X^ PUnit.

          This is the identity with respect to tensor product and composition (up to equivalence).

          Instances For

            The linear polynomial functor P(X) = A X

            Instances For

              The self monomial polynomial functor P(X) = S X^ S

              Instances For

                The pure power polynomial functor P(X) = X^ B

                Instances For

                  A polynomial functor is representable if it is equivalent to X^A for some type A.

                  Instances For
                    def PFunctor.ofFn {A : Type uA₁} (B : AType uB) :

                    Construct a polynomial functor from just a function B, with A derived implicitly.

                    Instances For
                      @[simp]
                      theorem PFunctor.ofFn_A {A : Type uA₁} (B : AType uB) :
                      (ofFn B).A = A
                      @[simp]
                      theorem PFunctor.ofFn_B {A : Type uA₁} (B : AType uB) (a : A) :
                      (ofFn B).B a = B a
                      instance PFunctor.instIsEmptyBC {α : Type u_1} (a : α) :
                      IsEmpty ((C α).B a)
                      @[implicit_reducible]
                      @[implicit_reducible]
                      instance PFunctor.instUniqueBX {a : X.A} :
                      Unique (X.B a)
                      @[implicit_reducible]
                      instance PFunctor.instUniqueBLinear {α : Type u_1} (a : α) :
                      Unique ((linear α).B a)
                      @[implicit_reducible]
                      @[simp]
                      theorem PFunctor.C_A (A : Type u) :
                      (C A).A = A
                      @[simp]
                      theorem PFunctor.C_B (A : Type u) (a : (C A).A) :
                      @[simp]
                      theorem PFunctor.X_B (a : X.A) :
                      @[simp]
                      theorem PFunctor.linear_A (A : Type u) :
                      (linear A).A = A
                      @[simp]
                      theorem PFunctor.linear_B (A : Type u) (a : (linear A).A) :
                      @[simp]
                      @[simp]
                      theorem PFunctor.selfMonomial_B (S : Type u) (a : (selfMonomial S).A) :
                      (selfMonomial S).B a = S
                      @[simp]
                      theorem PFunctor.purePower_B (B : Type u) (a : (purePower B).A) :
                      (purePower B).B a = B

                      The sum (coproduct) of two polynomial functors P and Q, written as P + Q.

                      Defined as the sum of the head types and the sum case analysis for the child types.

                      Note: requires the B universe levels to be the same.

                      Instances For
                        @[implicit_reducible]

                        Addition of polynomial functors, defined as the sum construction.

                        @[implicit_reducible]
                        theorem PFunctor.add_def (P : PFunctor.{uA₁, uB}) (Q : PFunctor.{uA₂, uB}) :
                        P + Q = { A := P.A Q.A, B := Sum.elim P.B Q.B }

                        Alias of PFunctor.sum.


                        The sum (coproduct) of two polynomial functors P and Q, written as P + Q.

                        Defined as the sum of the head types and the sum case analysis for the child types.

                        Note: requires the B universe levels to be the same.

                        Instances For

                          The generalized sum (sigma type) of an indexed family of polynomial functors.

                          Instances For

                            The product of two polynomial functors P and Q, written as P * Q.

                            Defined as the product of the head types and the sum of the child types.

                            Instances For
                              @[implicit_reducible]

                              Multiplication of polynomial functors, defined as the product construction.

                              @[implicit_reducible]

                              The generalized product (pi type) of an indexed family of polynomial functors.

                              Instances For

                                The tensor (also called parallel or Dirichlet) product of two polynomial functors P and Q.

                                Defined as the product of the head types and the product of the child types.

                                Instances For

                                  Infix notation for tensor product P ⊗ Q

                                  Instances For

                                    The unit for the tensor product Y

                                    Instances For

                                      The unit for composition Y

                                      Instances For

                                        Repeated composition P ◃ P ◃ ... ◃ P (n times).

                                        Instances For

                                          Lift a polynomial functor P to a pair of larger universes.

                                          Instances For

                                            Exponential of polynomial functors P ^ Q

                                            Instances For
                                              class PFunctor.Fintype (P : PFunctor.{uA, uB}) :
                                              Type (max uA uB)

                                              A polynomial functor is finitely branching if each of its branches is a finite type.

                                              Instances
                                                @[implicit_reducible]
                                                @[implicit_reducible]
                                                instance PFunctor.instFintypeBOfFintype {P : PFunctor.{uA, uB}} [inst : P.Fintype] (a : P.A) :
                                                Fintype (P.B a)
                                                @[implicit_reducible]
                                                @[implicit_reducible]
                                                class PFunctor.Inhabited (P : PFunctor.{uA, uB}) :
                                                Type (max uA uB)
                                                Instances
                                                  @[implicit_reducible]
                                                  @[implicit_reducible]
                                                  Instances
                                                    @[implicit_reducible]
                                                    @[implicit_reducible]

                                                    PFunctor where the output type is constant over an arbitrary input type.

                                                    Instances For
                                                      @[implicit_reducible]
                                                      instance PFunctor.instFintypeOfConstOfFintype (A : Type uA) (B : Type uB) [hB : Fintype B] :
                                                      @[implicit_reducible]
                                                      @[implicit_reducible]
                                                      structure PFunctor.Equiv (P : PFunctor.{uA₁, uB₁}) (Q : PFunctor.{uA₂, uB₂}) :
                                                      Type (max (max (max uA₁ uA₂) uB₁) uB₂)

                                                      An equivalence between two polynomial functors P and Q, written P ≃ₚ Q, is given by an equivalence of the A types and an equivalence between the B types for each a : A.

                                                      • equivA : P.A Q.A

                                                        An equivalence between the A types

                                                      • equivB (a : P.A) : P.B a Q.B (self.equivA a)

                                                        An equivalence between the B types for each a : A

                                                      Instances For
                                                        theorem PFunctor.Equiv.ext {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} {x y : P.Equiv Q} (equivA : x.equivA = y.equivA) (equivB : x.equivB y.equivB) :
                                                        x = y

                                                        An equivalence between two polynomial functors P and Q, written P ≃ₚ Q, is given by an equivalence of the A types and an equivalence between the B types for each a : A.

                                                        Instances For

                                                          The identity equivalence between a polynomial functor P and itself.

                                                          Instances For

                                                            The inverse of an equivalence between polynomial functors.

                                                            Instances For

                                                              The composition of two equivalences between polynomial functors.

                                                              Instances For
                                                                def PFunctor.Equiv.cast {P Q : PFunctor.{uA, uB}} (hA : P.A = Q.A) (hB : ∀ (a : P.A), P.B a = Q.B (_root_.cast hA a)) :
                                                                P.Equiv Q

                                                                Equivalence between two polynomial functors P and Q that are equal.

                                                                Instances For
                                                                  theorem PFunctor.Equiv.eqRec_id_apply {α : Sort u} {β : αSort v} {a1 a0 : α} (h : a1 = a0) (x : β a0) :
                                                                  Eq.rec (motive := fun (y : α) (x : a1 = y) => β yβ a1) id h x = _root_.cast x

                                                                  Rewrite a dependent Eq.rec with identity to a cast on the argument.

                                                                  theorem PFunctor.Equiv.equivB_symm_apply_of_eq {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} (e : P.Equiv Q) {a a' : P.A} (ha : e.equivA a = e.equivA a') (b : P.B a') :
                                                                  (e.equivB a).symm ((_root_.Equiv.cast ).symm ((e.equivB a') b)) = _root_.cast b

                                                                  Cast-normalization helper for equivB under equal equivA images.

                                                                  theorem PFunctor.Equiv.symm_equivB_symm_apply_of_eq {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} (e : P.Equiv Q) {a a' : Q.A} (ha : e.symm.equivA a = e.symm.equivA a') (b : Q.B a') :
                                                                  (e.symm.equivB a).symm ((_root_.Equiv.cast ).symm ((e.symm.equivB a') b)) = _root_.cast b

                                                                  Cast-normalization helper for symm.equivB under equal symm.equivA images.

                                                                  theorem PFunctor.Equiv.equivB_symm_apply {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} (e : P.Equiv Q) (a : P.A) (b : P.B (e.equivA.symm (e.equivA a))) :
                                                                  (e.equivB a).symm ((e.symm.equivB (e.equivA a)).symm b) = _root_.cast b

                                                                  Specialized cast-normalization for e followed by e.symm.

                                                                  Specialized cast-normalization for e.symm followed by e.

                                                                  theorem PFunctor.Equiv.forward_equivB_roundtrip {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} (e : P.Equiv Q) (a : P.A) (b : P.B a) :
                                                                  (e.symm.equivB (e.equivA a)) ((e.equivB a) b) = _root_.cast b

                                                                  Forward roundtrip: applying equivB then symm.equivB gives a cast.

                                                                  theorem PFunctor.Equiv.reverse_equivB_roundtrip {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} (e : P.Equiv Q) (a : Q.A) (b : Q.B a) :
                                                                  (e.equivB (e.equivA.symm a)) ((e.symm.equivB a) b) = _root_.cast b

                                                                  Reverse roundtrip: applying symm.equivB then equivB gives a cast.

                                                                  structure PFunctor.Lens (P : PFunctor.{uA₁, uB₁}) (Q : PFunctor.{uA₂, uB₂}) :
                                                                  Type (max (max (max uA₁ uA₂) uB₁) uB₂)

                                                                  A lens between two polynomial functors P and Q is a pair of a function:

                                                                  • toFunA : P.A → Q.A
                                                                  • toFunB : ∀ a, Q.B (toFunA a) → P.B a
                                                                  • toFunA : P.AQ.A
                                                                  • toFunB (a : P.A) : Q.B (self.toFunA a)P.B a
                                                                  Instances For

                                                                    Infix notation for constructing a lens toFunAtoFunB

                                                                    Instances For
                                                                      structure PFunctor.Chart (P : PFunctor.{uA₁, uB₁}) (Q : PFunctor.{uA₂, uB₂}) :
                                                                      Type (max (max (max uA₁ uA₂) uB₁) uB₂)

                                                                      A chart between two polynomial functors P and Q is a pair of a function:

                                                                      • toFunA : P.A → Q.A
                                                                      • toFunB : ∀ a, P.B a → Q.B (toFunA a)
                                                                      • toFunA : P.AQ.A
                                                                      • toFunB (a : P.A) : P.B aQ.B (self.toFunA a)
                                                                      Instances For

                                                                        Infix notation for constructing a chart toFunAtoFunB

                                                                        Instances For
                                                                          theorem PFunctor.ext {P Q : PFunctor.{uA, uB}} (h : P.A = Q.A) (h' : ∀ (a : P.A), P.B a = Q.B (h a)) :
                                                                          P = Q
                                                                          @[simp]
                                                                          theorem PFunctor.ulift_B {P : PFunctor.{uA, uB}} {a : P.A} :
                                                                          P.ulift.B { down := a } = ULift.{u_1, uB} (P.B a)