Pith. sign in

IndisputableMonolith.Foundation.MathlibCohomologyBridge

IndisputableMonolith/Foundation/MathlibCohomologyBridge.lean · 361 lines · 26 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: ready · generated 2026-08-12 09:42:49.944274+00:00

   1import Mathlib.AlgebraicTopology.SingularHomology.Basic
   2import Mathlib.Algebra.Category.ModuleCat.Colimits
   3import Mathlib.Algebra.Homology.ShortComplex.ModuleCat
   4import Mathlib.Topology.Category.TopCat.Sphere
   5import IndisputableMonolith.Foundation.DimensionForcing
   6
   7/-!
   8# Mathlib Cohomology Bridge Contract
   9
  10Mathlib currently supplies the singular homology functor API, but the T8
  11replacement needs more: a Mathlib-backed computation of the reduced cohomology
  12of `S¹`, plus the Alexander-duality bridge from circle-complement homology to
  13that cohomology group.
  14
  15This module records the exact backend object needed to replace the current
  16concrete `S¹` cohomology encoding.  It deliberately does not fake that backend
  17by reusing `AlexanderDuality.CircleReducedCohomologyNontrivial`.
  18-/
  19
  20namespace IndisputableMonolith
  21namespace Foundation
  22namespace MathlibCohomologyBridge
  23
  24universe u v w
  25
  26open CategoryTheory
  27
  28/-- Import-checked fact: the pinned Mathlib exposes the singular homology
  29functor API.  This is not yet the S¹ computation or Alexander-duality theorem;
  30it is the real Mathlib surface those future computations must use. -/
  31def MathlibSingularHomologyAPIAvailable : Prop :=
  32  ∀ (C : Type u) [CategoryTheory.Category.{v, u} C]
  33    [CategoryTheory.Limits.HasCoproducts.{w, v, u} C]
  34    [CategoryTheory.Preadditive C]
  35    [CategoryTheory.CategoryWithHomology C]
  36    (n : ℕ),
  37      Nonempty
  38        { F : CategoryTheory.Functor C (CategoryTheory.Functor TopCat.{w} C) //
  39          F = AlgebraicTopology.singularHomologyFunctor C n }
  40
  41/-- The singular homology functor exists in the pinned Mathlib. -/
  42theorem mathlibSingularHomologyAPIAvailable :
  43    MathlibSingularHomologyAPIAvailable := by
  44  intro C _ _ _ _ n
  45  exact ⟨AlgebraicTopology.singularHomologyFunctor C n, rfl⟩
  46
  47/-- The concrete Mathlib object that must eventually be computed:
  48first singular homology of the topological circle with integer coefficients. -/
  49noncomputable abbrev circleH1Z : ModuleCat ℤ :=
  50  ((AlgebraicTopology.singularHomologyFunctor (ModuleCat ℤ) 1).obj
  51    (ModuleCat.of ℤ ℤ)).obj (TopCat.sphere 1)
  52
  53/-- The nonvanishing computation required from Mathlib before the current
  54concrete S¹ bridge can be replaced. -/
  55def circleH1ZNonzero : Prop :=
  56  ¬ CategoryTheory.Limits.IsZero circleH1Z
  57
  58/-- Strong final Mathlib closure certificate: compute the circle's first
  59singular homology as the integer module. -/
  60def circleH1ZIsoInt : Prop :=
  61  Nonempty (circleH1Z ≅ ModuleCat.of ℤ ℤ)
  62
  63/-- Final import interface for the missing pinned-Mathlib computation.  A future
  64upgrade should fill this from Mathlib's actual computation of `H_1(S¹; ℤ)`,
  65not from a project-local replacement. -/
  66structure CircleH1MathlibComputation : Prop where
  67  singular_homology_api_available : MathlibSingularHomologyAPIAvailable
  68  target_is_imported_circle_h1 :
  69    circleH1Z =
  70      ((AlgebraicTopology.singularHomologyFunctor (ModuleCat ℤ) 1).obj
  71        (ModuleCat.of ℤ ℤ)).obj (TopCat.sphere 1)
  72  h1_iso_int : circleH1ZIsoInt
  73
  74/-- A proof of the strong target `H_1(S¹; ℤ) ≅ ℤ` fills the final Mathlib
  75computation interface, since the singular homology API and target identity are
  76already import-checked in this module. -/
  77theorem circleH1MathlibComputation_of_iso_int
  78    (hiso : circleH1ZIsoInt) : CircleH1MathlibComputation where
  79  singular_homology_api_available := mathlibSingularHomologyAPIAvailable
  80  target_is_imported_circle_h1 := rfl
  81  h1_iso_int := hiso
  82
  83/-- The final Mathlib computation interface is equivalent to the strong target
  84`H_1(S¹; ℤ) ≅ ℤ`. -/
  85theorem circleH1MathlibComputation_iff_iso_int :
  86    Nonempty CircleH1MathlibComputation ↔ circleH1ZIsoInt := by
  87  constructor
  88  · rintro ⟨C⟩
  89    exact C.h1_iso_int
  90  · intro hiso
  91    exact ⟨circleH1MathlibComputation_of_iso_int hiso⟩
  92
  93/-- The integer module is not a zero object in `ModuleCat ℤ`. -/
  94theorem intModuleCat_not_isZero :
  95    ¬ CategoryTheory.Limits.IsZero (ModuleCat.of ℤ ℤ) := by
  96  intro hzero
  97  rcases hzero.unique_to (ModuleCat.of ℤ ℤ) with ⟨u⟩
  98  letI : Unique ((ModuleCat.of ℤ ℤ) ⟶ (ModuleCat.of ℤ ℤ)) := u
  99  have hhom :
 100      (𝟙 (ModuleCat.of ℤ ℤ)) =
 101        (0 : (ModuleCat.of ℤ ℤ) ⟶ (ModuleCat.of ℤ ℤ)) :=
 102    Subsingleton.elim _ _
 103  have hlin := congrArg ModuleCat.Hom.hom hhom
 104  have hval := congrArg (fun f : ℤ →ₗ[ℤ] ℤ => f 1) hlin
 105  norm_num at hval
 106
 107/-- Computing `H_1(S¹; ℤ)` as `ℤ` closes the required nonvanishing target. -/
 108theorem circleH1ZNonzero_of_iso_int
 109    (hiso : circleH1ZIsoInt) : circleH1ZNonzero := by
 110  intro hzero
 111  rcases hiso with ⟨e⟩
 112  have hz : CategoryTheory.Limits.IsZero (ModuleCat.of ℤ ℤ) :=
 113    CategoryTheory.Limits.IsZero.of_iso hzero e.symm
 114  exact intModuleCat_not_isZero hz
 115
 116/-- The final computation interface supplies the strong `H_1(S¹; ℤ) ≅ ℤ`
 117certificate. -/
 118theorem circleH1ZIsoInt_of_mathlib_computation
 119    (C : CircleH1MathlibComputation) : circleH1ZIsoInt :=
 120  C.h1_iso_int
 121
 122/-- The final computation interface closes the nonvanishing theorem. -/
 123theorem circleH1ZNonzero_of_mathlib_computation
 124    (C : CircleH1MathlibComputation) : circleH1ZNonzero :=
 125  circleH1ZNonzero_of_iso_int C.h1_iso_int
 126
 127/-- Checked certificate for the exact final circle-H1 import target.  This does
 128not prove the missing homology computation; it proves that every remaining
 129circle-H1 handoff is pinned to the imported Mathlib object and to the single
 130strong target `H_1(S¹; ℤ) ≅ ℤ`. -/
 131structure CircleH1TargetCertificate : Prop where
 132  singular_homology_api_available : MathlibSingularHomologyAPIAvailable
 133  target_is_imported_circle_h1 :
 134    circleH1Z =
 135      ((AlgebraicTopology.singularHomologyFunctor (ModuleCat ℤ) 1).obj
 136        (ModuleCat.of ℤ ℤ)).obj (TopCat.sphere 1)
 137  computation_iff_iso_int :
 138    Nonempty CircleH1MathlibComputation ↔ circleH1ZIsoInt
 139  iso_int_implies_nonzero :
 140    circleH1ZIsoInt → circleH1ZNonzero
 141  computation_implies_nonzero :
 142    ∀ _C : CircleH1MathlibComputation, circleH1ZNonzero
 143
 144/-- The final circle-H1 target certificate for the pinned Mathlib surface. -/
 145theorem circleH1TargetCertificate : CircleH1TargetCertificate where
 146  singular_homology_api_available := mathlibSingularHomologyAPIAvailable
 147  target_is_imported_circle_h1 := rfl
 148  computation_iff_iso_int := circleH1MathlibComputation_iff_iso_int
 149  iso_int_implies_nonzero := circleH1ZNonzero_of_iso_int
 150  computation_implies_nonzero := circleH1ZNonzero_of_mathlib_computation
 151
 152/-- The circle homology target is the actual imported Mathlib singular homology
 153object, not a project-local placeholder. -/
 154theorem circleH1Z_is_mathlib_singular_homology :
 155    circleH1Z =
 156      ((AlgebraicTopology.singularHomologyFunctor (ModuleCat ℤ) 1).obj
 157        (ModuleCat.of ℤ ℤ)).obj (TopCat.sphere 1) :=
 158  rfl
 159
 160/-- The backend required to replace the current concrete S¹ cohomology encoding.
 161
 162The key field is `linking_from_circle_h1`: a future backend must prove the
 163nonvanishing of the concrete Mathlib circle homology object and route linking
 164through that computation. -/
 165structure MathlibCircleLinkingBackend where
 166  supportsLinking : DimensionForcing.Dimension → Prop
 167  uses_singular_homology_api : MathlibSingularHomologyAPIAvailable
 168  circle_h1_nonzero : circleH1ZNonzero
 169  linking_from_circle_h1 :
 170    ∀ D : DimensionForcing.Dimension,
 171      supportsLinking D ↔ D = 3 ∧ circleH1ZNonzero
 172
 173/-- A Mathlib circle-linking backend still gives the same D=3 characterization,
 174but now that characterization must pass through the concrete `H_1(𝕊¹; ℤ)`
 175nonvanishing target. -/
 176theorem MathlibCircleLinkingBackend.circle_linking_iff
 177    (B : MathlibCircleLinkingBackend) (D : DimensionForcing.Dimension) :
 178    B.supportsLinking D ↔ D = 3 := by
 179  constructor
 180  · intro h
 181    exact ((B.linking_from_circle_h1 D).mp h).1
 182  · intro hD
 183    exact (B.linking_from_circle_h1 D).mpr ⟨hD, B.circle_h1_nonzero⟩
 184
 185/-- Any backend satisfying the Mathlib replacement contract agrees with the
 186current T8 linking surface. -/
 187theorem MathlibCircleLinkingBackend.agrees_with_current
 188    (B : MathlibCircleLinkingBackend) (D : DimensionForcing.Dimension) :
 189    B.supportsLinking D ↔ DimensionForcing.SupportsNontrivialLinking D := by
 190  constructor
 191  · intro h
 192    have hD : D = 3 := (B.circle_linking_iff D).mp h
 193    rw [hD]
 194    exact DimensionForcing.D3_has_linking
 195  · intro h
 196    exact (B.circle_linking_iff D).mpr (DimensionForcing.linking_requires_D3 D h)
 197
 198/-- Any Mathlib linking backend has the same D=3 forcing theorem. -/
 199theorem MathlibCircleLinkingBackend.forces_D3
 200    (B : MathlibCircleLinkingBackend) (D : DimensionForcing.Dimension) :
 201    B.supportsLinking D → D = 3 :=
 202  (B.circle_linking_iff D).mp
 203
 204/-- Any Mathlib linking backend supports D=3. -/
 205theorem MathlibCircleLinkingBackend.d3_supports_linking
 206    (B : MathlibCircleLinkingBackend) :
 207    B.supportsLinking 3 :=
 208  (B.circle_linking_iff 3).mpr rfl
 209
 210/-- A proof of the concrete Mathlib circle-H1 nonvanishing target is enough to
 211build the backend object required by the T8 replacement. -/
 212def mathlibCircleLinkingBackend_from_circleH1ZNonzero
 213    (hH1 : circleH1ZNonzero) : MathlibCircleLinkingBackend where
 214  supportsLinking := fun D => D = 3
 215  uses_singular_homology_api := mathlibSingularHomologyAPIAvailable
 216  circle_h1_nonzero := hH1
 217  linking_from_circle_h1 := by
 218    intro D
 219    constructor
 220    · intro hD
 221      exact ⟨hD, hH1⟩
 222    · intro h
 223      exact h.1
 224
 225/-- The remaining backend object is equivalent to the single concrete Mathlib
 226homology computation `circleH1ZNonzero`. -/
 227theorem mathlibCircleLinkingBackend_nonempty_iff_circleH1ZNonzero :
 228    Nonempty MathlibCircleLinkingBackend ↔ circleH1ZNonzero := by
 229  constructor
 230  · rintro ⟨B⟩
 231    exact B.circle_h1_nonzero
 232  · intro hH1
 233    exact ⟨mathlibCircleLinkingBackend_from_circleH1ZNonzero hH1⟩
 234
 235/-- The backend object projects to the concrete circle-H1 nonvanishing theorem. -/
 236theorem circleH1ZNonzero_of_mathlibCircleLinkingBackend
 237    (hB : Nonempty MathlibCircleLinkingBackend) : circleH1ZNonzero :=
 238  mathlibCircleLinkingBackend_nonempty_iff_circleH1ZNonzero.mp hB
 239
 240/-- The concrete circle-H1 nonvanishing theorem builds the backend object. -/
 241theorem mathlibCircleLinkingBackend_of_circleH1ZNonzero
 242    (hH1 : circleH1ZNonzero) : Nonempty MathlibCircleLinkingBackend :=
 243  mathlibCircleLinkingBackend_nonempty_iff_circleH1ZNonzero.mpr hH1
 244
 245/-- The strong `H_1(S¹; ℤ) ≅ ℤ` target builds the backend object. -/
 246theorem mathlibCircleLinkingBackend_of_circleH1ZIsoInt
 247    (hiso : circleH1ZIsoInt) : Nonempty MathlibCircleLinkingBackend :=
 248  mathlibCircleLinkingBackend_of_circleH1ZNonzero
 249    (circleH1ZNonzero_of_iso_int hiso)
 250
 251/-- The final Mathlib computation interface builds the backend object. -/
 252theorem mathlibCircleLinkingBackend_of_circleH1MathlibComputation
 253    (C : CircleH1MathlibComputation) : Nonempty MathlibCircleLinkingBackend :=
 254  mathlibCircleLinkingBackend_of_circleH1ZNonzero
 255    (circleH1ZNonzero_of_mathlib_computation C)
 256
 257/-- Contract certificate for the present state: the Mathlib singular homology
 258API is imported and checked, while the backend replacing the concrete S¹
 259encoding remains a named `Nonempty MathlibCircleLinkingBackend` target. -/
 260structure MathlibCohomologyBridgeContract : Prop where
 261  singular_homology_api_available : MathlibSingularHomologyAPIAvailable
 262  circle_h1_target_certificate : CircleH1TargetCertificate
 263  circle_h1_object_checked :
 264    circleH1Z =
 265      ((AlgebraicTopology.singularHomologyFunctor (ModuleCat ℤ) 1).obj
 266        (ModuleCat.of ℤ ℤ)).obj (TopCat.sphere 1)
 267  current_linking_characterization :
 268    ∀ D : DimensionForcing.Dimension,
 269      DimensionForcing.SupportsNontrivialLinking D ↔ D = 3
 270  backend_nonempty_implies_circle_h1_nonzero :
 271    Nonempty MathlibCircleLinkingBackend → circleH1ZNonzero
 272  backend_nonempty_iff_circle_h1_nonzero :
 273    Nonempty MathlibCircleLinkingBackend ↔ circleH1ZNonzero
 274  backend_of_circle_h1_nonzero :
 275    circleH1ZNonzero → Nonempty MathlibCircleLinkingBackend
 276
 277/-- Checked contract for the remaining Mathlib cohomology replacement. -/
 278theorem mathlibCohomologyBridgeContract :
 279    MathlibCohomologyBridgeContract where
 280  singular_homology_api_available := mathlibSingularHomologyAPIAvailable
 281  circle_h1_target_certificate := circleH1TargetCertificate
 282  circle_h1_object_checked := circleH1Z_is_mathlib_singular_homology
 283  current_linking_characterization := by
 284    intro D
 285    constructor
 286    · exact DimensionForcing.linking_requires_D3 D
 287    · intro hD
 288      rw [hD]
 289      exact DimensionForcing.D3_has_linking
 290  backend_nonempty_implies_circle_h1_nonzero := by
 291    rintro ⟨B⟩
 292    exact B.circle_h1_nonzero
 293  backend_nonempty_iff_circle_h1_nonzero :=
 294    mathlibCircleLinkingBackend_nonempty_iff_circleH1ZNonzero
 295  backend_of_circle_h1_nonzero :=
 296    mathlibCircleLinkingBackend_of_circleH1ZNonzero
 297
 298/-- Paper-facing handoff certificate for the exact external Mathlib target.
 299This packages the imported object, the strong `H_1(S¹; ℤ) ≅ ℤ` interface, the
 300weaker nonvanishing target, and the backend object used by T8. -/
 301structure MathlibBackendHandoffCertificate : Prop where
 302  bridge_contract : MathlibCohomologyBridgeContract
 303  target_certificate : CircleH1TargetCertificate
 304  target_is_imported_circle_h1 :
 305    circleH1Z =
 306      ((AlgebraicTopology.singularHomologyFunctor (ModuleCat ℤ) 1).obj
 307        (ModuleCat.of ℤ ℤ)).obj (TopCat.sphere 1)
 308  computation_iff_iso_int :
 309    Nonempty CircleH1MathlibComputation ↔ circleH1ZIsoInt
 310  iso_int_implies_nonzero :
 311    circleH1ZIsoInt → circleH1ZNonzero
 312  computation_implies_nonzero :
 313    CircleH1MathlibComputation → circleH1ZNonzero
 314  backend_iff_circle_h1_nonzero :
 315    Nonempty MathlibCircleLinkingBackend ↔ circleH1ZNonzero
 316  backend_from_circle_h1_nonzero :
 317    circleH1ZNonzero → Nonempty MathlibCircleLinkingBackend
 318  backend_from_iso_int :
 319    circleH1ZIsoInt → Nonempty MathlibCircleLinkingBackend
 320  backend_from_mathlib_computation :
 321    CircleH1MathlibComputation → Nonempty MathlibCircleLinkingBackend
 322  backend_agrees_with_current :
 323    ∀ (B : MathlibCircleLinkingBackend) (D : DimensionForcing.Dimension),
 324      B.supportsLinking D ↔ DimensionForcing.SupportsNontrivialLinking D
 325  backend_forces_D3 :
 326    ∀ (B : MathlibCircleLinkingBackend) (D : DimensionForcing.Dimension),
 327      B.supportsLinking D → D = 3
 328  backend_supports_D3 :
 329    ∀ B : MathlibCircleLinkingBackend, B.supportsLinking 3
 330
 331/-- Checked handoff certificate for the exact external Mathlib target. -/
 332theorem mathlibBackendHandoffCertificate :
 333    MathlibBackendHandoffCertificate where
 334  bridge_contract := mathlibCohomologyBridgeContract
 335  target_certificate := circleH1TargetCertificate
 336  target_is_imported_circle_h1 := circleH1Z_is_mathlib_singular_homology
 337  computation_iff_iso_int := circleH1MathlibComputation_iff_iso_int
 338  iso_int_implies_nonzero := circleH1ZNonzero_of_iso_int
 339  computation_implies_nonzero := circleH1ZNonzero_of_mathlib_computation
 340  backend_iff_circle_h1_nonzero :=
 341    mathlibCircleLinkingBackend_nonempty_iff_circleH1ZNonzero
 342  backend_from_circle_h1_nonzero :=
 343    mathlibCircleLinkingBackend_of_circleH1ZNonzero
 344  backend_from_iso_int := by
 345    exact mathlibCircleLinkingBackend_of_circleH1ZIsoInt
 346  backend_from_mathlib_computation := by
 347    exact mathlibCircleLinkingBackend_of_circleH1MathlibComputation
 348  backend_agrees_with_current := by
 349    intro B D
 350    exact B.agrees_with_current D
 351  backend_forces_D3 := by
 352    intro B D
 353    exact B.forces_D3 D
 354  backend_supports_D3 := by
 355    intro B
 356    exact B.d3_supports_linking
 357
 358end MathlibCohomologyBridge
 359end Foundation
 360end IndisputableMonolith
 361

source mirrored from github.com/jonwashburn/shape-of-logic