/- Copyright 2026 Paul Lezeau and The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This file has been modified. -/ import OAI.AlgebraicTopology.Singular.ExcisionCoverSmall import Mathlib.AlgebraicTopology.SimplicialSet.Subdivision /-! # Subdivision Basic -/ namespace OAI.AlgebraicTopology.Singular.SubdivisionBasic noncomputable section /-! # The last-vertex map for simplicial subdivision Mathlib defines barycentric subdivision as a left Kan extension, but currently does not include the classical last-vertex natural transformation. This file begins that construction at its finite-poset source: a nonempty finite chain is sent to its greatest vertex. The maximum map is monotone and natural in monotone maps between finite linear orders, so taking nerves gives the last-vertex map on the subdivided standard simplices. -/ open _root_.CategoryTheory PartialOrder universe u /-- A nonempty finite chain in a linear order is sent monotonically to its greatest element. -/ noncomputable def nonemptyFiniteChainMaximum (X : Type*) [LinearOrder X] : NonemptyFiniteChains X →o X where toFun A := A.finset.max' A.nonempty monotone' A _ h := Finset.max'_subset A.nonempty h @[simp] theorem nonemptyFiniteChainMaximum_apply {X : Type*} [LinearOrder X] (A : NonemptyFiniteChains X) : nonemptyFiniteChainMaximum X A = A.finset.max' A.nonempty := rfl /-- Taking the maximum commutes with a monotone map between finite linear orders. -/ theorem nonemptyFiniteChainMaximum_map {X Y : Type*} [LinearOrder X] [LinearOrder Y] (f : X →o Y) (A : NonemptyFiniteChains X) : nonemptyFiniteChainMaximum Y (A.map f) = f (nonemptyFiniteChainMaximum X A) := by rw [nonemptyFiniteChainMaximum_apply, nonemptyFiniteChainMaximum_apply] apply le_antisymm · apply Finset.max'_le intro y hy obtain ⟨x, hx, rfl⟩ := (NonemptyFiniteChains.mem_map_iff A f y).1 hy exact f.monotone (Finset.le_max' A.finset x hx) · apply Finset.le_max' exact (NonemptyFiniteChains.mem_map_iff A f _).2 ⟨A.finset.max' A.nonempty, A.finset.max'_mem A.nonempty, rfl⟩ /-- The maximum-vertex morphism from chains in the vertex poset of a standard simplex. -/ noncomputable def simplexSubdivisionMaximum (n : SimplexCategory) : (SimplexCategory.toPartOrd.{u} ⋙ PartOrd.nonemptyFiniteChainsFunctor).obj n ⟶ SimplexCategory.toPartOrd.{u}.obj n := PartOrd.ofHom (nonemptyFiniteChainMaximum (ULift.{u} (Fin (n.len + 1)))) /-- Maximum vertex is natural in morphisms of the simplex category. -/ noncomputable def simplexSubdivisionMaximumNatTrans : SimplexCategory.toPartOrd.{u} ⋙ PartOrd.nonemptyFiniteChainsFunctor ⟶ SimplexCategory.toPartOrd.{u} where app := simplexSubdivisionMaximum naturality := by intro n m f apply PartOrd.ext intro A rw [PartOrd.comp_apply, PartOrd.comp_apply] change NonemptyFiniteChains (ULift.{u} (Fin (n.len + 1))) at A change nonemptyFiniteChainMaximum (ULift.{u} (Fin (m.len + 1))) (A.map (SimplexCategory.toPartOrd.{u}.map f).hom) = (SimplexCategory.toPartOrd.{u}.map f).hom (nonemptyFiniteChainMaximum (ULift.{u} (Fin (n.len + 1))) A) exact nonemptyFiniteChainMaximum_map _ A /-- The objectwise identification of the standard simplex with the nerve of its vertex order is natural in the simplex category. -/ noncomputable def standardSimplexNerveIso : SSet.stdSimplex.{u} ≅ SimplexCategory.toPartOrd.{u} ⋙ PartOrd.nerveFunctor := NatIso.ofComponents (fun n ↦ SSet.stdSimplex.isoNerve n.len) fun _ ↦ rfl /-- The last-vertex map from the subdivision model of standard simplices to standard simplices. -/ noncomputable def simplexSubdivisionLastVertex : SimplexCategory.sd.{u} ⟶ SSet.stdSimplex.{u} := Functor.whiskerRight simplexSubdivisionMaximumNatTrans PartOrd.nerveFunctor ≫ standardSimplexNerveIso.inv /-- The last-vertex map, viewed with the codomain required by the left Kan extension universal property. -/ noncomputable def simplexSubdivisionLastVertexExtension : SimplexCategory.sd.{u} ⟶ SSet.stdSimplex.{u} ⋙ Functor.id SSet.{u} := simplexSubdivisionLastVertex ≫ (Functor.rightUnitor SSet.stdSimplex.{u}).inv /-- The global last-vertex natural transformation `sd X ⟶ X`, obtained from the defining left Kan extension universal property of simplicial subdivision. -/ noncomputable def subdivisionLastVertex : SSet.sd.{u} ⟶ Functor.id SSet.{u} := SSet.sd.descOfIsLeftKanExtension SSet.stdSimplex.sdIso.inv (Functor.id SSet.{u}) simplexSubdivisionLastVertexExtension /-- On subdivided standard simplices, the global last-vertex map restricts to the maximum-vertex construction above. -/ theorem subdivisionLastVertex_standardSimplex (n : SimplexCategory) : SSet.stdSimplex.sdIso.inv.app n ≫ (subdivisionLastVertex.{u}.app (SSet.stdSimplex.obj n)) = simplexSubdivisionLastVertex.{u}.app n := SSet.sd.descOfIsLeftKanExtension_fac_app SSet.stdSimplex.sdIso.inv (Functor.id SSet.{u}) simplexSubdivisionLastVertexExtension n /-- The chain map induced by the last-vertex map of a simplicial set. -/ noncomputable def subdivisionLastVertexChainMap (X : SSet.{0}) : (SSet.sd.obj X).chainComplex (AddCommGrpCat.of ℤ) ⟶ X.chainComplex (AddCommGrpCat.of ℤ) := SSet.chainComplexMap (subdivisionLastVertex.app X) (AddCommGrpCat.of ℤ) /-- The last-vertex chain maps are natural in the simplicial set. -/ @[reassoc] theorem subdivisionLastVertexChainMap_naturality {X Y : SSet.{0}} (f : X ⟶ Y) : SSet.chainComplexMap (SSet.sd.map f) (AddCommGrpCat.of ℤ) ≫ subdivisionLastVertexChainMap Y = subdivisionLastVertexChainMap X ≫ SSet.chainComplexMap f (AddCommGrpCat.of ℤ) := by change ((SSet.chainComplexFunctor AddCommGrpCat).obj (AddCommGrpCat.of ℤ)).map (SSet.sd.map f) ≫ ((SSet.chainComplexFunctor AddCommGrpCat).obj (AddCommGrpCat.of ℤ)).map (subdivisionLastVertex.app Y) = ((SSet.chainComplexFunctor AddCommGrpCat).obj (AddCommGrpCat.of ℤ)).map (subdivisionLastVertex.app X) ≫ ((SSet.chainComplexFunctor AddCommGrpCat).obj (AddCommGrpCat.of ℤ)).map f rw [← Functor.map_comp, ← Functor.map_comp, subdivisionLastVertex.naturality] rfl end end OAI.AlgebraicTopology.Singular.SubdivisionBasic