Charts between polynomial functors #
A Chart P Q is a pair (toFunA, toFunB) where
toFunA : P.A → Q.Ais a forward map on positions, andtoFunB : ∀ a, P.B a → Q.B (toFunA a)is a forward map on directions.
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 #
| Lens | Chart | |
|---|---|---|
| Coproduct | + | + (same) |
| Product | * (positions ×, directions ⊕) | ⊗ (positions ×, directions ×) |
| Terminal | 1 (positions = 1, no directions) | X = y (positions = 1, dir = 1) |
| Composition | compMap is natural | compMap is not natural |
| Sigma | sigmaExists, sigmaMap | sigmaExists, sigmaMap |
| Pi | piForall, piMap | only 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.
Identity and composition #
Composition of charts
Instances For
Infix notation for chart composition c' ∘c c
Instances For
Equivalences #
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
Infix notation for chart equivalence P ≃c Q
Instances For
Instances For
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^→.
Dependent copairing of charts over sigma: (Σ i, F i) → R.
Instances For
Pointwise mapping of charts over sigma.
Instances For
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 #
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 #
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 #
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.
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.Equiv → Chart.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.Equiv → Chart.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
Pi of a family of zero functors over an inhabited type is the zero functor.