The monoidal category of labeled finite tuples #
[UPSTREAM] candidate for Mathlib/CategoryTheory/Monoidal/. A LabeledTuple α
is a finite tuple of αs: a length n and a labeling Fin n → α. Morphisms are
label-preserving position maps (f : Fin a.len → Fin b.len with
b.label ∘ f = a.label); this is a skeleton of Over α (finite α-labeled
sets) on Fin-objects.
Concatenation (Fin.append on labels, + on lengths) is the categorical
coproduct and empty the initial object, so the category is cocartesian:
its MonoidalCategory and SymmetricCategory are obtained for free from
monoidalOfHasFiniteCoproducts/symmetricOfHasFiniteCoproducts (unlike
AugmentedSimplexCategory, whose monotone maps make its ordinal sum not a
coproduct, forcing a bespoke monoidal structure). The tensor is concat up to
the chosen-coproduct isomorphism.
The concrete Fin-skeletal concat/Hom.concatMap defs (with their
Fin.appendMap action) are kept alongside: downstream clients that need the
literal Fin (a.len + b.len) carrier — e.g. autosegmental tiers with typed
links — consume those directly rather than the opaque coproduct tensor.
Main definitions #
LabeledTuple α— a length-indexed labeled tuple; the object.LabeledTuple.Hom a b— a label-preserving position map.LabeledTuple.concat— concatenation;LabeledTuple.emptythe unit.LabeledTuple.Hom.concatMap— the concatenation bifunctor on morphisms.MonoidalCategory/SymmetricCategory (LabeledTuple α)— the cocartesian structure:concatas⊗(up to coproduct iso),emptyas𝟙_.
A finite tuple of αs: a length and a labeling.
- len : ℕ
The length of the tuple.
- label : Fin self.len → α
The labeling of the positions.
Instances For
Tuples are comparable when labels are: compare lengths, then the labelings
(decidable as Fin len is a Fintype). Reduces under decide.
Equations
- One or more equations did not get rendered due to their size.
A label-preserving position map.
The underlying position map.
The map preserves labels.
Instances For
The identity morphism.
Equations
- LabeledTuple.Hom.id a = { toFun := id, label_comp := ⋯ }
Instances For
A Hom is a label-preserving position map; bundle it as FunLike so f i
applies it and the mathlib hom machinery (DFunLike.ext, …) is available.
Equations
- LabeledTuple.Hom.instFunLikeFinLen = { coe := LabeledTuple.Hom.toFun, coe_injective := ⋯ }
Equations
- One or more equations did not get rendered due to their size.
The index map of an eqToHom is the length-cast finCongr.
Concatenation #
Concatenation of labeled tuples: lengths add, labels Fin.append.
Instances For
The empty tuple — the monoidal unit.
Equations
- LabeledTuple.empty = { len := 0, label := Fin.elim0 }
Instances For
The labeled tuple of a list: its length, positionally labeled. The ergonomic
bridge for clients that build tiers from List literals.
Equations
- LabeledTuple.ofList l = { len := l.length, label := l.get }
Instances For
The underlying list of labels, in position order.
Instances For
Raw ℕ-indexed access, out-of-range to none: the positional view for
clients that index tiers by ℕ (subgraph embedding, surface bookkeeping).
Instances For
Raw access into a concatenation: left block through a, right through b.
The concatenation bifunctor on morphisms: Fin.appendMap of the position
maps. Label preservation is exactly Fin-append naturality.
Instances For
Monoid structure on objects #
Extensionality via a length equality and a cast-compatible labeling. The
auto-generated structure ext would demand an unusable HEq on label
(which depends on len), and the cast dependency here defeats the @[ext]
generator, so this is a plain extensionality lemma.
Objects form a Monoid under concatenation, with empty as unit.
Equations
- LabeledTuple.instMonoid = { mul := LabeledTuple.concat, mul_assoc := ⋯, one := LabeledTuple.empty, one_mul := ⋯, mul_one := ⋯, npow_zero := ⋯, npow_succ := ⋯ }
Cocartesian monoidal structure #
empty is the initial object and concat the categorical coproduct (with
coprojections Fin.castAdd/Fin.natAdd), so the category is cocartesian and its
MonoidalCategory/SymmetricCategory come for free.
The copairing of f : a ⟶ T and g : b ⟶ T, glued by Fin.append.
Equations
- LabeledTuple.coprodDesc f g = { toFun := Fin.append f.toFun g.toFun, label_comp := ⋯ }
Instances For
concat is the categorical coproduct, with inl/inr the coprojections.
Equations
- LabeledTuple.instMonoidalCategory = CategoryTheory.monoidalOfHasFiniteCoproducts (LabeledTuple α)
Equations
- LabeledTuple.instSymmetricCategory = CategoryTheory.symmetricOfHasFiniteCoproducts (LabeledTuple α)