Documentation

ToMathlib.PFunctor.Chart.Basic

Charts between polynomial functors #

A Chart P Q is a pair (toFunA, toFunB) where

While lenses make Poly into a 2-category whose categorical product is * (positions ×, directions Σ), charts make Poly into a different category that is isomorphic to the arrow category Set^→ (squares B → A → B' → A'). A consequence is that the chart category has a different monoidal structure from the lens category.

Comparison with Lens #

LensChart
Coproduct++ (same)
Product* (positions ×, directions ⊕) (positions ×, directions ×)
Terminal1 (positions = 1, no directions)X = y (positions = 1, dir = 1)
CompositioncompMap is naturalcompMap is not natural
SigmasigmaExists, sigmaMapsigmaExists, sigmaMap
PipiForall, piMaponly piMap

The operations missing from charts (compMap, piForall, projections from *, sigmaForall) all require contravariance and so are intrinsically lens-side. What charts do have, they have cleanly: + is the coproduct with inl/inr/sumPair, and is the categorical product with fst/snd/tensorPair.

Layout #

This file mirrors ToMathlib/PFunctor/Lens/Basic.lean for ease of cross-reference. Each section header that overlaps with Lens is named identically; the chart-specific sections (Tensor for the categorical product, Prod for the polynomial product) are documented inline.

Downstream consumers #

Interface.Hom, Interface.Hom.mapPacket, and the boundary-side composition operators are intentionally thin wrappers around this file. New downstream operators on packet/index transport (e.g. parallel composition, sum routing) should be defined as wrappers, not re-implemented.

theorem PFunctor.Chart.ext {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} (c₁ c₂ : P.Chart Q) (h₁ : ∀ (a : P.A), c₁.toFunA a = c₂.toFunA a) (h₂ : ∀ (a : P.A), c₁.toFunB a = Eq.rec (motive := fun (x : Q.A) (h : c₂.toFunA a = x) => P.B aQ.B x) (c₂.toFunB a) ) :
c₁ = c₂

Identity and composition #

The identity chart

Instances For

    Composition of charts

    Instances For

      Infix notation for chart composition c' ∘c c

      Instances For

        Equivalences #

        structure PFunctor.Chart.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, using charts. This corresponds to an isomorphism in the category PFunctor with Chart morphisms.

        Instances For
          theorem PFunctor.Chart.Equiv.ext {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} {x y : P ≃c Q} (toChart : x.toChart = y.toChart) (invChart : x.invChart = y.invChart) :
          x = y

          Infix notation for chart equivalence P ≃c Q

          Instances For

            Initial and terminal #

            The (unique) initial chart from the zero functor to any functor P.

            Instances For

              The (unique) terminal chart from any functor P to X = y.

              X is the terminal object of the chart category — a single position with a single direction — corresponding to the identity arrow 1 → 1 in Set^→. This differs from the lens-side terminal 1 (positions 1, no directions).

              Instances For

                Alias of PFunctor.Chart.initial.


                The (unique) initial chart from the zero functor to any functor P.

                Instances For

                  Alias of PFunctor.Chart.terminal.


                  The (unique) terminal chart from any functor P to X = y.

                  X is the terminal object of the chart category — a single position with a single direction — corresponding to the identity arrow 1 → 1 in Set^→. This differs from the lens-side terminal 1 (positions 1, no directions).

                  Instances For

                    Coproduct (+) #

                    + is the coproduct in the chart category (as it is in the lens category). The two inclusions inl/inr plus the copairing sumPair realise the universal property of +. The parallel-sum sumMap is then a derived construction.

                    Left injection chart inl : P → P + Q.

                    Instances For

                      Right injection chart inr : Q → P + Q.

                      Instances For

                        Copairing of charts [c₁, c₂]c : P + Q → R.

                        Instances For

                          Parallel application of charts for coproduct c₁ ⊎c c₂ : P + Q → R + W.

                          Instances For

                            Tensor () — the chart category's binary product #

                            is the categorical binary product in the chart category, with projections fst/snd and pairing tensorPair. (For lenses, the categorical product is *, not .)

                            Projection chart fst : P ⊗ Q → P.

                            Instances For

                              Projection chart snd : P ⊗ Q → Q.

                              Instances For

                                Pairing of charts ⟨c₁, c₂⟩c : P → Q ⊗ R.

                                Instances For

                                  Parallel application of charts for tensor c₁ ⊗c c₂ : P ⊗ Q → R ⊗ W.

                                  Instances For

                                    Polynomial product (*) — not the chart categorical product #

                                    The polynomial product * is not the categorical product in the chart category: there is no natural chart P * Q → P because the source has direction type P.B a₁ ⊕ Q.B a₂ and we cannot project a Q.B a₂ to a P.B a₁. We provide only the parallel-map operation.

                                    For categorical projections / pairing, use instead.

                                    Parallel application of charts for polynomial product c₁ ×c c₂ : P * Q → R * W.

                                    Instances For

                                      Indexed colimits and limits #

                                      The chart category has Sigma-eliminations (sigmaExists/sigmaMap) but only the parametric Pi-map (piMap); piForall is intrinsically a lens-side construction because it requires "choosing an index" in the chart direction, which has no canonical choice in Set^→.

                                      def PFunctor.Chart.sigmaExists {I : Type v} {F : IPFunctor.{uA₁, uB₁}} {R : PFunctor.{uA₂, uB₂}} (c : (i : I) → (F i).Chart R) :
                                      (sigma F).Chart R

                                      Dependent copairing of charts over sigma: (Σ i, F i) → R.

                                      Instances For
                                        def PFunctor.Chart.sigmaMap {I : Type v} {F : IPFunctor.{uA₁, uB₁}} {G : IPFunctor.{uA₂, uB₂}} (c : (i : I) → (F i).Chart (G i)) :
                                        (sigma F).Chart (sigma G)

                                        Pointwise mapping of charts over sigma.

                                        Instances For
                                          def PFunctor.Chart.piMap {I : Type v} {F : IPFunctor.{uA₁, uB₁}} {G : IPFunctor.{uA₂, uB₂}} (c : (i : I) → (F i).Chart (G i)) :
                                          (pi F).Chart (pi G)

                                          Pointwise mapping of charts over pi.

                                          Instances For

                                            Action on indices #

                                            A chart φ : P → Q acts on Idx P = Σ a : P.A, P.B a by sending ⟨a, b⟩ ↦ ⟨φ.toFunA a, φ.toFunB a b⟩. This is the underlying function on positions; Trace.mapChart (in ToMathlib.PFunctor.Trace) uses it to push event traces along charts.

                                            Push an Idx P along a chart P → Q to an Idx Q.

                                            Instances For

                                              Special charts #

                                              def PFunctor.Chart.enclose (P : PFunctor.{uA, uB}) :
                                              Type (max uA uA₁ uB uB₁)

                                              The type of charts from a polynomial functor P to X.

                                              A chart P → X is equivalent to a function (a : P.A) → P.B a → PUnit, i.e. a boundary valuation that picks out a single direction at every position. Analogous to Lens.enclose.

                                              Instances For

                                                Notations for binary operations #

                                                Parallel application of charts for coproduct c₁ ⊎c c₂ : P + Q → R + W.

                                                Instances For

                                                  Parallel application of charts for tensor c₁ ⊗c c₂ : P ⊗ Q → R ⊗ W.

                                                  Instances For

                                                    Parallel application of charts for polynomial product c₁ ×c c₂ : P * Q → R * W.

                                                    Instances For

                                                      Coproduct coherence #

                                                      theorem PFunctor.Chart.sumMap_comp_sumMap {P : PFunctor.{uA₁, uB}} {Q : PFunctor.{uA₂, uB}} {R : PFunctor.{uA₃, uB₃}} {W : PFunctor.{uA₄, uB₃}} {S : PFunctor.{uA₅, uB₅}} {T : PFunctor.{uA₆, uB₅}} (c₁ : P.Chart R) (c₂ : Q.Chart W) (c₁' : R.Chart S) (c₂' : W.Chart T) :
                                                      c₁' ⊎c c₂' ∘c (c₁ ⊎c c₂) = c₁' ∘c c₁ ⊎c (c₂' ∘c c₂)

                                                      Commutativity of coproduct

                                                      Instances For

                                                        Associativity of coproduct

                                                        Instances For

                                                          Coproduct with 0 is identity (right)

                                                          Instances For

                                                            Coproduct with 0 is identity (left)

                                                            Instances For

                                                              Coproduct preserves equivalences: P ≃c P' → Q ≃c Q' → P + Q ≃c P' + Q'.

                                                              Instances For

                                                                Tensor coherence #

                                                                theorem PFunctor.Chart.tensorMap_comp {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} {R : PFunctor.{uA₃, uB₃}} {W : PFunctor.{uA₄, uB₄}} {P' : PFunctor.{uA₅, uB₅}} {Q' : PFunctor.{uA₆, uB₆}} (c₁ : P.Chart P') (c₂ : Q.Chart Q') (c₁' : P'.Chart R) (c₂' : Q'.Chart W) :
                                                                c₁' ∘c c₁ ⊗c (c₂' ∘c c₂) = c₁' ⊗c c₂' ∘c (c₁ ⊗c c₂)
                                                                theorem PFunctor.Chart.tensorMap_comp_tensorMap {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} {R : PFunctor.{uA₃, uB₃}} {W : PFunctor.{uA₄, uB₄}} {P' : PFunctor.{uA₅, uB₅}} {Q' : PFunctor.{uA₆, uB₆}} (c₁ : P.Chart R) (c₂ : Q.Chart W) (c₁' : R.Chart P') (c₂' : W.Chart Q') :
                                                                c₁' ⊗c c₂' ∘c (c₁ ⊗c c₂) = c₁' ∘c c₁ ⊗c (c₂' ∘c c₂)

                                                                Commutativity of tensor product

                                                                Instances For

                                                                  Associativity of tensor product

                                                                  Instances For

                                                                    Tensor product with X is identity (right)

                                                                    Instances For

                                                                      Tensor product with X is identity (left)

                                                                      Instances For

                                                                        Tensor product with 0 is zero (left)

                                                                        Instances For

                                                                          Tensor product with 0 is zero (right)

                                                                          Instances For

                                                                            Tensor product preserves equivalences: P ≃c P' → Q ≃c Q' → P ⊗ Q ≃c P' ⊗ Q'.

                                                                            Instances For

                                                                              Left distributivity of tensor product over coproduct.

                                                                              P ⊗ (Q + R) ≃c (P ⊗ Q) + (P ⊗ R).

                                                                              Instances For

                                                                                Right distributivity of tensor product over coproduct.

                                                                                (Q + R) ⊗ P ≃c (Q ⊗ P) + (R ⊗ P).

                                                                                Instances For

                                                                                  Polynomial-product coherence #

                                                                                  Even though * is not the categorical product in the chart category, it is still a functor and admits coherent equivalences (commutativity, associativity, units, zeros, congruence, distributivity over +). These mirror the PFunctor.Equiv.prod* lemmas.

                                                                                  theorem PFunctor.Chart.prodMap_comp_prodMap {P : PFunctor.{uA₁, uB₁}} {Q : PFunctor.{uA₂, uB₂}} {R : PFunctor.{uA₃, uB₃}} {W : PFunctor.{uA₄, uB₄}} {S : PFunctor.{uA₅, uB₅}} {T : PFunctor.{uA₆, uB₆}} (c₁ : P.Chart R) (c₂ : Q.Chart W) (c₁' : R.Chart S) (c₂' : W.Chart T) :
                                                                                  c₁' ×c c₂' ∘c (c₁ ×c c₂) = c₁' ∘c c₁ ×c (c₂' ∘c c₂)

                                                                                  Polynomial-product preserves equivalences: P ≃c P' → Q ≃c Q' → P * Q ≃c P' * Q'.

                                                                                  Instances For

                                                                                    Commutativity of the polynomial product.

                                                                                    Instances For

                                                                                      Associativity of the polynomial product.

                                                                                      Instances For

                                                                                        Polynomial-product with 0 is 0 (right).

                                                                                        Instances For

                                                                                          Polynomial-product with 0 is 0 (left).

                                                                                          Instances For

                                                                                            Left distributivity of polynomial product over coproduct.

                                                                                            P * (Q + R) ≃c (P * Q) + (P * R).

                                                                                            Instances For

                                                                                              Right distributivity of polynomial product over coproduct.

                                                                                              (Q + R) * P ≃c (Q * P) + (R * P).

                                                                                              Instances For

                                                                                                ULift #

                                                                                                ULift equivalence for charts.

                                                                                                Instances For

                                                                                                  Convert an equivalence between two polynomial functors P and Q to a chart.

                                                                                                  Instances For

                                                                                                    Bridge PFunctor.EquivChart.Equiv #

                                                                                                    Every polynomial-functor equivalence yields a chart equivalence: the forward chart uses e.equivA / e.equivB, and the inverse chart uses their symmetric counterparts. The proofs of left_inv / right_inv need the cast machinery from forward_equivB_roundtrip / reverse_equivB_roundtrip because e.symm.equivA (e.equivA a) and a are only propositionally equal.

                                                                                                    This is the chart analogue of Equiv.toLensEquiv and is the standard way to derive sigma / distributivity equivalences from their PFunctor.Equiv counterparts.

                                                                                                    Convert an equivalence between two polynomial functors to a chart equivalence.

                                                                                                    Chart-side analogue of Equiv.toLensEquiv. Together with Chart.Equiv.refl, symm, and trans, this establishes a faithful functor PFunctor.EquivChart.Equiv.

                                                                                                    Instances For

                                                                                                      Sigma equivalences #

                                                                                                      These are derived from PFunctor.Equiv.toChartEquiv applied to the corresponding PFunctor.Equiv constructions. They mirror the PFunctor.Lens.Equiv.sigma* family.

                                                                                                      Sigma of an empty family is the zero functor.

                                                                                                      Instances For

                                                                                                        Sigma of a PUnit-indexed family is equivalent to the functor itself (up to ulift).

                                                                                                        Instances For

                                                                                                          Sigma of a unique-indexed family is equivalent to the default fiber (up to ulift).

                                                                                                          Instances For

                                                                                                            Left distributivity of polynomial product over sigma.

                                                                                                            Instances For

                                                                                                              Right distributivity of polynomial product over sigma.

                                                                                                              Instances For

                                                                                                                Left distributivity of tensor product over sigma.

                                                                                                                Instances For

                                                                                                                  Right distributivity of tensor product over sigma.

                                                                                                                  Instances For

                                                                                                                    Pi equivalences #

                                                                                                                    piMap lives in the operations section, but unlike lenses, charts admit no piForall (Pi-elimination requires direction-contravariance). What we get cleanly here is piUnit and piZero.

                                                                                                                    Pi over a PUnit-indexed family is equivalent to the functor itself.

                                                                                                                    Instances For
                                                                                                                      def PFunctor.Chart.Equiv.piZero {I : Type v} [Inhabited I] {F : IPFunctor.{uA, uB}} (F_zero : ∀ (i : I), F i = 0) :
                                                                                                                      pi F ≃c 0

                                                                                                                      Pi of a family of zero functors over an inhabited type is the zero functor.

                                                                                                                      Instances For