math / data /lean /OAI /Algebra /Homology /LinearDual.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
11.7 kB
/-
Copyright 2026 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 Mathlib.Algebra.Homology.Homotopy
import Mathlib.Algebra.Homology.ShortComplex.ModuleCat
import OAI.LinearAlgebra.Foundations.QuotientBasic
import OAI.LinearAlgebra.Foundations.DualDefs
import Mathlib.LinearAlgebra.Dual.Lemmas
/-! # Linear Dual -/
namespace OAI.Algebra.Homology.LinearDual
noncomputable section
open _root_.CategoryTheory
open _root_.CategoryTheory.ShortComplex
open _root_.HomologicalComplex
/-!
# The linear dual of a complex of modules
Applying the dual degreewise turns a nonnegatively graded chain complex into a cochain complex,
whose degree-`n` short complex is the reversed dual of the original one. Duality is
contravariantly functorial for maps, isomorphisms, chain homotopies and chain-homotopy
equivalences, so all of these transport to the dual cochain complex. That much holds over a
commutative ring.
Over a field the homology of the reversed dual is canonically the dual of the homology, with no
finite-dimensionality hypothesis: this is `linearDualHomologyEquiv`. Over a ring the comparison
map `dualHomologyComparisonExplicit` still exists but need not be bijective. Each namespace below
is split into a `CommRing` section and a `Field` section accordingly.
-/
open Limits
universe u
namespace CategoryTheory.ShortComplex
section CommRing
variable {R : Type u} [CommRing R]
attribute [local implicit_reducible] ShortComplex.moduleCatMk ShortComplex.moduleCatLeftHomologyData
/-- Let `R` be a commutative ring and `S` a sequence `A β†’ B β†’ C` of `R`-modules with zero composite.
Its reversed dual is the sequence `Hom_R(C,R) β†’ Hom_R(B,R) β†’ Hom_R(A,R)`, whose maps precompose
with those of `S`. -/
abbrev linearDual (S : ShortComplex (ModuleCat.{u} R)) :
ShortComplex (ModuleCat.{u} R) :=
ShortComplex.moduleCatMk S.g.hom.dualMap S.f.hom.dualMap (by ext; simp)
/-- Let `R` be a commutative ring and `A β†’ B β†’ C` a sequence of modules with zero composite. A
functional on `B` vanishing on the image of `A` restricts to cycles and descends to `ker(B β†’
C)/im(A β†’ B)`. This is the resulting linear map from dual cycles to functionals on homology. -/
@[simps]
def dualCycleToHomologyFunctional (S : ShortComplex (ModuleCat.{u} R)) :
LinearMap.ker S.f.hom.dualMap β†’β‚—[R]
Module.Dual R S.moduleCatLeftHomologyData.H where
toFun Ο† := (LinearMap.range S.moduleCatToCycles).liftQ
(Ο†.1.comp (LinearMap.ker S.g.hom).subtype) (by
rintro _ ⟨x, rfl⟩
have := LinearMap.congr_fun (LinearMap.mem_ker.1 Ο†.2) x
simp only [LinearMap.dualMap_apply, LinearMap.zero_apply] at this
simpa [moduleCatToCycles, S.f.hom.codRestrict_apply S.g.hom.ker (h := moduleCat_zero_apply S)])
map_add' Ο† ψ := by
generalize_proofs
simp [LinearMap.add_comp, OAI.LinearAlgebra.Foundations.QuotientBasic.Submodule.liftQ_add S.moduleCatToCycles.range, *]
map_smul' a Ο† := by
generalize_proofs
simp [LinearMap.smul_comp, OAI.LinearAlgebra.Foundations.QuotientBasic.Submodule.liftQ_smul S.moduleCatToCycles.range, *]
lemma dualCycleToHomologyFunctional_vanishes_on_boundaries
(S : ShortComplex (ModuleCat.{u} R)) :
LinearMap.range ((linearDual S).moduleCatToCycles) ≀
LinearMap.ker (dualCycleToHomologyFunctional S) := by
rintro _ ⟨(ψ : Module.Dual R S.X₃), rfl⟩
simp [dualCycleToHomologyFunctional]
ext z
induction z using Submodule.Quotient.induction_on with
| H z => simp [moduleCatToCycles, S.g.hom.dualMap_apply]
/-- Let `R` be a commutative ring and `S = (A β†’ B β†’ C)` a sequence of modules with zero composite.
This linear map from the homology of the reversed dual to `Hom_R(H(S), R)` pairs the class of a
functional `Ο†` with the class of a cycle `z` by `Ο†(z)`, using quotient modules for both homology
groups. -/
def dualHomologyComparisonExplicit (S : ShortComplex (ModuleCat.{u} R)) :
(linearDual S).moduleCatLeftHomologyData.H β†’β‚—[R]
Module.Dual R S.moduleCatLeftHomologyData.H :=
(LinearMap.range (linearDual S).moduleCatToCycles).liftQ
(dualCycleToHomologyFunctional S)
(dualCycleToHomologyFunctional_vanishes_on_boundaries S)
@[simp]
lemma dualHomologyComparisonExplicit_mk_apply_mk
(S : ShortComplex (ModuleCat.{u} R))
(Ο† : LinearMap.ker S.f.hom.dualMap) (z : LinearMap.ker S.g.hom) :
(dualHomologyComparisonExplicit S) (Submodule.Quotient.mk Ο†)
(Submodule.Quotient.mk z) = Ο†.1 z.1 :=
rfl
end CommRing
variable {R : Type u} [Field R]
attribute [local implicit_reducible] ShortComplex.moduleCatMk ShortComplex.moduleCatLeftHomologyData
lemma dualHomologyComparisonExplicit_surjective
(S : ShortComplex (ModuleCat.{u} R)) :
Function.Surjective (dualHomologyComparisonExplicit S) := by
intro Ξ±
let Ο† : Module.Dual R S.Xβ‚‚ :=
Subspace.dualLift (LinearMap.ker S.g.hom) <| Ξ±.comp (LinearMap.range S.moduleCatToCycles).mkQ
have hΟ† : Ο† ∈ LinearMap.ker S.f.hom.dualMap := LinearMap.mem_ker.2 <| LinearMap.ext fun x ↦ by
simpa [Ο†, Subspace.dualLift_of_mem (LinearMap.mem_ker.2 <| S.moduleCat_zero_apply x)] using!
congr(Ξ± $((Submodule.Quotient.mk_eq_zero _).2 <| S.moduleCatToCycles.mem_range_self x))
refine ⟨Submodule.Quotient.mk βŸ¨Ο†, hΟ†βŸ©, ?_⟩
ext z
induction z using Submodule.Quotient.induction_on with
| _ z => simp +zetaDelta [Submodule.mkQ_apply _]
lemma dualHomologyComparisonExplicit_injective
(S : ShortComplex (ModuleCat.{u} R)) :
Function.Injective (dualHomologyComparisonExplicit S) := by
intro a b hab
induction a using Submodule.Quotient.induction_on with
| _ Ο† =>
induction b using Submodule.Quotient.induction_on with
| _ ψ =>
rw [Submodule.Quotient.eq]
have hzero : (dualCycleToHomologyFunctional S) (Ο† - ψ) = 0 :=
((dualCycleToHomologyFunctional S).map_sub Ο† ψ).trans (sub_eq_zero.2 hab)
have hv : (Ο† - ψ).1 ∈ (LinearMap.ker S.g.hom).dualAnnihilator := by
rw [Submodule.mem_dualAnnihilator]
intro z hz
exact LinearMap.congr_fun hzero (Submodule.Quotient.mk ⟨z, hz⟩)
rw [← LinearMap.range_dualMap_eq_dualAnnihilator_ker] at hv
obtain ⟨η, hη⟩ := hv
exact ⟨η, Subtype.ext hη⟩
/-- Let `R` be a field and `S = (A β†’ B β†’ C)` a sequence of vector spaces with zero composite.
Evaluation of a dual cocycle on a cycle gives this linear equivalence `H(S*) ≃ Hom_R(H(S), R)`,
where `S*` is the reversed dual sequence. It holds without a finite-dimensionality assumption. -/
def linearDualHomologyEquiv (S : ShortComplex (ModuleCat.{u} R)) :
(linearDual S).homology ≃ₗ[R] Module.Dual R S.homology :=
(linearDual S).moduleCatHomologyIso.toLinearEquiv.trans <|
(LinearEquiv.ofBijective (dualHomologyComparisonExplicit S)
⟨(dualHomologyComparisonExplicit_injective S),
(dualHomologyComparisonExplicit_surjective S)⟩).trans <|
S.moduleCatHomologyIso.toLinearEquiv.dualMap
end CategoryTheory.ShortComplex
namespace HomologicalComplex
section CommRing
variable {R : Type u} [CommRing R]
/-- Let `R` be a commutative ring and `K` a chain complex of `R`-modules in nonnegative degrees. Its
dual cochain complex has `Hom_R(K_n, R)` in degree `n`, with coboundary `Ο† ↦ Ο† ∘ βˆ‚`, where `βˆ‚:
K_{n+1} β†’ K_n` is the boundary of `K`. -/
@[implicit_reducible, simps -isSimp X d]
def linearDualCochainComplex (K : ChainComplex (ModuleCat.{u} R) β„•) :
CochainComplex (ModuleCat.{u} R) β„• where
X n := ModuleCat.of R (Module.Dual R (K.X n))
d i j := ModuleCat.ofHom (K.d j i).hom.dualMap
shape i j := by simp +contextual
d_comp_d' i j k h1 h2 := by
simp [← ModuleCat.ofHom_comp, LinearMap.dualMap_comp_dualMap, ← ModuleCat.hom_comp]
attribute [simp] HomologicalComplex.linearDualCochainComplex_X
@[simp]
lemma linearDualCochainComplex_d_succ (K : ChainComplex (ModuleCat.{u} R) β„•) (n : β„•) :
((linearDualCochainComplex K)).d n (n + 1) =
ModuleCat.ofHom (K.d (n + 1) n).hom.dualMap := rfl
attribute [local implicit_reducible] shortComplexFunctor' shortComplexFunctor
/-- Let `R` be a commutative ring and `K` a nonnegative chain complex of `R`-modules. For each `n`,
this identifies the three terms around degree `n` in the dual cochain complex with the reversed
linear duals of the three terms around `n` in `K`, including the adjacent differentials. -/
@[implicit_reducible]
def linearDualCochainComplexScIso (K : ChainComplex (ModuleCat.{u} R) β„•) (n : β„•) :
(linearDualCochainComplex K).sc n β‰… (CategoryTheory.ShortComplex.linearDual (K.sc n)) :=
have hprev : (ComplexShape.up β„•).prev n = (ComplexShape.down β„•).next n := by cases n <;> simp
have hnext : (ComplexShape.up β„•).next n = (ComplexShape.down β„•).prev n := by simp
(linearDualCochainComplex K).isoSc' (c := ComplexShape.up β„•) _ _ _ hprev hnext --β‰ͺ≫
variable {K L M : ChainComplex (ModuleCat.{u} R) β„•}
/-- Let `R` be a commutative ring and `f: K β†’ L` a map of nonnegative chain complexes of
`R`-modules. This map of dual cochain complexes `L* β†’ K*` sends a degree-`n` functional `Ο†` to
`Ο† ∘ f_n`. -/
@[implicit_reducible, simps f]
def linearDualMap (f : K ⟢ L) :
(linearDualCochainComplex L) ⟢ (linearDualCochainComplex K) where
f n := ModuleCat.ofHom (f.f n).hom.dualMap
comm' _ _ _ := by
rw [linearDualCochainComplex_d, linearDualCochainComplex_d, ← ModuleCat.ofHom_comp,
LinearMap.dualMap_comp_dualMap, ← ModuleCat.hom_comp, ← ModuleCat.ofHom_comp,
LinearMap.dualMap_comp_dualMap, ← ModuleCat.hom_comp, f.comm]
@[simp]
lemma linearDualMap_id (K : ChainComplex (ModuleCat.{u} R) β„•) :
linearDualMap (πŸ™ K) = πŸ™ (linearDualCochainComplex K) :=
rfl
@[simp]
lemma linearDualMap_comp (f : K ⟢ L) (g : L ⟢ M) :
linearDualMap (f ≫ g) = linearDualMap g ≫ linearDualMap f :=
rfl
/-- Let `R` be a commutative ring and `e: K β‰… L` an isomorphism of nonnegative chain complexes of
`R`-modules. Precomposition with `e` gives this isomorphism of dual cochain complexes `L* β‰… K*`,
with inverse given by precomposition with `e⁻¹`. -/
@[implicit_reducible]
def linearDualIso (e : K β‰… L) :
(linearDualCochainComplex L) β‰… (linearDualCochainComplex K) where
hom := linearDualMap e.hom
inv := linearDualMap e.inv
hom_inv_id := by rw [← linearDualMap_comp, e.inv_hom_id, linearDualMap_id]
inv_hom_id := by rw [← linearDualMap_comp, e.hom_inv_id, linearDualMap_id]
end CommRing
variable {R : Type u} [Field R]
/-- Let `R` be a field and `K` a nonnegative chain complex of `R`-vector spaces. Evaluation of
cocycles on cycles gives this linear equivalence `H^n(Hom_R(K,R)) ≃ Hom_R(H_n(K), R)`. It
requires no finite-dimensionality assumption. -/
def linearDualHomologyEquiv (K : ChainComplex (ModuleCat.{u} R) β„•) (n : β„•) :
(linearDualCochainComplex K).homology n ≃ₗ[R] Module.Dual R (K.homology n) :=
(ShortComplex.homologyMapIso (linearDualCochainComplexScIso K n)).toLinearEquiv.trans
(CategoryTheory.ShortComplex.linearDualHomologyEquiv (K.sc n))
end HomologicalComplex
end
end OAI.Algebra.Homology.LinearDual