path
stringlengths
11
71
content
stringlengths
75
124k
Algebra\Homology\ShortComplex\FunctorEquivalence.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.Basic /-! # Short complexes in functor categories In this file, it is shown that if `J` and `C` are two categories (such that `C` has zero morphisms), then there is an equivalence of categories `ShortComplex.functorEquivalence J C : ShortComplex (J ⥤ C) ≌ J ⥤ ShortComplex C`. -/ namespace CategoryTheory open Limits variable (J C : Type*) [Category J] [Category C] [HasZeroMorphisms C] namespace ShortComplex namespace FunctorEquivalence attribute [local simp] ShortComplex.Hom.comm₁₂ ShortComplex.Hom.comm₂₃ /-- The obvious functor `ShortComplex (J ⥤ C) ⥤ J ⥤ ShortComplex C`. -/ @[simps] def functor : ShortComplex (J ⥤ C) ⥤ J ⥤ ShortComplex C where obj S := { obj := fun j => S.map ((evaluation J C).obj j) map := fun f => S.mapNatTrans ((evaluation J C).map f) } map φ := { app := fun j => ((evaluation J C).obj j).mapShortComplex.map φ } /-- The obvious functor `(J ⥤ ShortComplex C) ⥤ ShortComplex (J ⥤ C)`. -/ @[simps] def inverse : (J ⥤ ShortComplex C) ⥤ ShortComplex (J ⥤ C) where obj F := { f := whiskerLeft F π₁Toπ₂ g := whiskerLeft F π₂Toπ₃ zero := by aesop_cat } map φ := Hom.mk (whiskerRight φ π₁) (whiskerRight φ π₂) (whiskerRight φ π₃) (by aesop_cat) (by aesop_cat) /-- The unit isomorphism of the equivalence `ShortComplex.functorEquivalence : ShortComplex (J ⥤ C) ≌ J ⥤ ShortComplex C`. -/ @[simps!] def unitIso : 𝟭 _ ≅ functor J C ⋙ inverse J C := NatIso.ofComponents (fun _ => isoMk (NatIso.ofComponents (fun _ => Iso.refl _) (by aesop_cat)) (NatIso.ofComponents (fun _ => Iso.refl _) (by aesop_cat)) (NatIso.ofComponents (fun _ => Iso.refl _) (by aesop_cat)) (by aesop_cat) (by aesop_cat)) (by aesop_cat) /-- The counit isomorphism of the equivalence `ShortComplex.functorEquivalence : ShortComplex (J ⥤ C) ≌ J ⥤ ShortComplex C`. -/ @[simps!] def counitIso : inverse J C ⋙ functor J C ≅ 𝟭 _ := NatIso.ofComponents (fun _ => NatIso.ofComponents (fun _ => isoMk (Iso.refl _) (Iso.refl _) (Iso.refl _) (by aesop_cat) (by aesop_cat)) (by aesop_cat)) (by aesop_cat) end FunctorEquivalence /-- The obvious equivalence `ShortComplex (J ⥤ C) ≌ J ⥤ ShortComplex C`. -/ @[simps] def functorEquivalence : ShortComplex (J ⥤ C) ≌ J ⥤ ShortComplex C where functor := FunctorEquivalence.functor J C inverse := FunctorEquivalence.inverse J C unitIso := FunctorEquivalence.unitIso J C counitIso := FunctorEquivalence.counitIso J C end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\HomologicalComplex.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.Additive import Mathlib.Algebra.Homology.ShortComplex.Exact import Mathlib.Algebra.Homology.ShortComplex.Preadditive import Mathlib.Tactic.Linarith /-! # The short complexes attached to homological complexes In this file, we define a functor `shortComplexFunctor C c i : HomologicalComplex C c ⥤ ShortComplex C`. By definition, the image of a homological complex `K` by this functor is the short complex `K.X (c.prev i) ⟶ K.X i ⟶ K.X (c.next i)`. The homology `K.homology i` of a homological complex `K` in degree `i` is defined as the homology of the short complex `(shortComplexFunctor C c i).obj K`, which can be abbreviated as `K.sc i`. -/ open CategoryTheory Category Limits namespace HomologicalComplex variable (C : Type*) [Category C] [HasZeroMorphisms C] {ι : Type*} (c : ComplexShape ι) /-- The functor `HomologicalComplex C c ⥤ ShortComplex C` which sends a homological complex `K` to the short complex `K.X i ⟶ K.X j ⟶ K.X k` for arbitrary indices `i`, `j` and `k`. -/ @[simps] def shortComplexFunctor' (i j k : ι) : HomologicalComplex C c ⥤ ShortComplex C where obj K := ShortComplex.mk (K.d i j) (K.d j k) (K.d_comp_d i j k) map f := { τ₁ := f.f i τ₂ := f.f j τ₃ := f.f k } /-- The functor `HomologicalComplex C c ⥤ ShortComplex C` which sends a homological complex `K` to the short complex `K.X (c.prev i) ⟶ K.X i ⟶ K.X (c.next i)`. -/ @[simps!] noncomputable def shortComplexFunctor (i : ι) := shortComplexFunctor' C c (c.prev i) i (c.next i) /-- The natural isomorphism `shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k` when `c.prev j = i` and `c.next j = k`. -/ @[simps!] noncomputable def natIsoSc' (i j k : ι) (hi : c.prev j = i) (hk : c.next j = k) : shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k := NatIso.ofComponents (fun K => ShortComplex.isoMk (K.XIsoOfEq hi) (Iso.refl _) (K.XIsoOfEq hk) (by aesop_cat) (by aesop_cat)) (by aesop_cat) variable {C c} section variable (K L M : HomologicalComplex C c) (φ : K ⟶ L) (ψ : L ⟶ M) (i j k : ι) /-- The short complex `K.X i ⟶ K.X j ⟶ K.X k` for arbitrary indices `i`, `j` and `k`. -/ abbrev sc' := (shortComplexFunctor' C c i j k).obj K /-- The short complex `K.X (c.prev i) ⟶ K.X i ⟶ K.X (c.next i)`. -/ noncomputable abbrev sc := (shortComplexFunctor C c i).obj K /-- The canonical isomorphism `K.sc j ≅ K.sc' i j k` when `c.prev j = i` and `c.next j = k`. -/ noncomputable abbrev isoSc' (hi : c.prev j = i) (hk : c.next j = k) : K.sc j ≅ K.sc' i j k := (natIsoSc' C c i j k hi hk).app K /-- A homological complex `K` has homology in degree `i` if the associated short complex `K.sc i` has. -/ abbrev HasHomology := (K.sc i).HasHomology variable [K.HasHomology i] /-- The homology in degree `i` of a homological complex. -/ noncomputable def homology := (K.sc i).homology /-- The cycles in degree `i` of a homological complex. -/ noncomputable def cycles := (K.sc i).cycles /-- The inclusion of the cycles of a homological complex. -/ noncomputable def iCycles : K.cycles i ⟶ K.X i := (K.sc i).iCycles /-- The homology class map from cycles to the homology of a homological complex. -/ noncomputable def homologyπ : K.cycles i ⟶ K.homology i := (K.sc i).homologyπ variable {i} /-- The morphism to `K.cycles i` that is induced by a "cycle", i.e. a morphism to `K.X i` whose postcomposition with the differential is zero. -/ noncomputable def liftCycles {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j) (hk : k ≫ K.d i j = 0) : A ⟶ K.cycles i := (K.sc i).liftCycles k (by subst hj; exact hk) /-- The morphism to `K.cycles i` that is induced by a "cycle", i.e. a morphism to `K.X i` whose postcomposition with the differential is zero. -/ noncomputable abbrev liftCycles' {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.Rel i j) (hk : k ≫ K.d i j = 0) : A ⟶ K.cycles i := K.liftCycles k j (c.next_eq' hj) hk @[reassoc (attr := simp)] lemma liftCycles_i {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j) (hk : k ≫ K.d i j = 0) : K.liftCycles k j hj hk ≫ K.iCycles i = k := by dsimp [liftCycles, iCycles] simp variable (i) /-- The map `K.X i ⟶ K.cycles j` induced by the differential `K.d i j`. -/ noncomputable def toCycles [K.HasHomology j] : K.X i ⟶ K.cycles j := K.liftCycles (K.d i j) (c.next j) rfl (K.d_comp_d _ _ _) @[reassoc (attr := simp)] lemma iCycles_d : K.iCycles i ≫ K.d i j = 0 := by by_cases hij : c.Rel i j · obtain rfl := c.next_eq' hij exact (K.sc i).iCycles_g · rw [K.shape _ _ hij, comp_zero] /-- `K.cycles i` is the kernel of `K.d i j` when `c.next i = j`. -/ noncomputable def cyclesIsKernel (hj : c.next i = j) : IsLimit (KernelFork.ofι (K.iCycles i) (K.iCycles_d i j)) := by obtain rfl := hj exact (K.sc i).cyclesIsKernel @[reassoc (attr := simp)] lemma toCycles_i [K.HasHomology j] : K.toCycles i j ≫ K.iCycles j = K.d i j := liftCycles_i _ _ _ _ _ instance : Mono (K.iCycles i) := by dsimp only [iCycles] infer_instance instance : Epi (K.homologyπ i) := by dsimp only [homologyπ] infer_instance @[reassoc (attr := simp)] lemma d_toCycles [K.HasHomology k] : K.d i j ≫ K.toCycles j k = 0 := by simp only [← cancel_mono (K.iCycles k), assoc, toCycles_i, d_comp_d, zero_comp] variable {i} @[reassoc] lemma comp_liftCycles {A' A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j) (hk : k ≫ K.d i j = 0) (α : A' ⟶ A) : α ≫ K.liftCycles k j hj hk = K.liftCycles (α ≫ k) j hj (by rw [assoc, hk, comp_zero]) := by simp only [← cancel_mono (K.iCycles i), assoc, liftCycles_i] @[reassoc] lemma liftCycles_homologyπ_eq_zero_of_boundary {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j) {i' : ι} (x : A ⟶ K.X i') (hx : k = x ≫ K.d i' i) : K.liftCycles k j hj (by rw [hx, assoc, K.d_comp_d, comp_zero]) ≫ K.homologyπ i = 0 := by by_cases h : c.Rel i' i · obtain rfl := c.prev_eq' h exact (K.sc i).liftCycles_homologyπ_eq_zero_of_boundary _ x hx · have : liftCycles K k j hj (by rw [hx, assoc, K.d_comp_d, comp_zero]) = 0 := by rw [K.shape _ _ h, comp_zero] at hx rw [← cancel_mono (K.iCycles i), zero_comp, liftCycles_i, hx] rw [this, zero_comp] variable (i) @[reassoc (attr := simp)] lemma toCycles_comp_homologyπ [K.HasHomology j] : K.toCycles i j ≫ K.homologyπ j = 0 := K.liftCycles_homologyπ_eq_zero_of_boundary (K.d i j) (c.next j) rfl (𝟙 _) (by simp) /-- `K.homology j` is the cokernel of `K.toCycles i j : K.X i ⟶ K.cycles j` when `c.prev j = i`. -/ noncomputable def homologyIsCokernel (hi : c.prev j = i) [K.HasHomology j] : IsColimit (CokernelCofork.ofπ (K.homologyπ j) (K.toCycles_comp_homologyπ i j)) := by subst hi exact (K.sc j).homologyIsCokernel /-- The opcycles in degree `i` of a homological complex. -/ noncomputable def opcycles := (K.sc i).opcycles /-- The projection to the opcycles of a homological complex. -/ noncomputable def pOpcycles : K.X i ⟶ K.opcycles i := (K.sc i).pOpcycles /-- The inclusion map of the homology of a homological complex into its opcycles. -/ noncomputable def homologyι : K.homology i ⟶ K.opcycles i := (K.sc i).homologyι variable {i} /-- The morphism from `K.opcycles i` that is induced by an "opcycle", i.e. a morphism from `K.X i` whose precomposition with the differential is zero. -/ noncomputable def descOpcycles {A : C} (k : K.X i ⟶ A) (j : ι) (hj : c.prev i = j) (hk : K.d j i ≫ k = 0) : K.opcycles i ⟶ A := (K.sc i).descOpcycles k (by subst hj; exact hk) /-- The morphism from `K.opcycles i` that is induced by an "opcycle", i.e. a morphism from `K.X i` whose precomposition with the differential is zero. -/ noncomputable abbrev descOpcycles' {A : C} (k : K.X i ⟶ A) (j : ι) (hj : c.Rel j i) (hk : K.d j i ≫ k = 0) : K.opcycles i ⟶ A := K.descOpcycles k j (c.prev_eq' hj) hk @[reassoc (attr := simp)] lemma p_descOpcycles {A : C} (k : K.X i ⟶ A) (j : ι) (hj : c.prev i = j) (hk : K.d j i ≫ k = 0) : K.pOpcycles i ≫ K.descOpcycles k j hj hk = k := by dsimp [descOpcycles, pOpcycles] simp variable (i) /-- The map `K.opcycles i ⟶ K.X j` induced by the differential `K.d i j`. -/ noncomputable def fromOpcycles : K.opcycles i ⟶ K.X j := K.descOpcycles (K.d i j) (c.prev i) rfl (K.d_comp_d _ _ _) @[reassoc (attr := simp)] lemma d_pOpcycles [K.HasHomology j] : K.d i j ≫ K.pOpcycles j = 0 := by by_cases hij : c.Rel i j · obtain rfl := c.prev_eq' hij exact (K.sc j).f_pOpcycles · rw [K.shape _ _ hij, zero_comp] /-- `K.opcycles j` is the cokernel of `K.d i j` when `c.prev j = i`. -/ noncomputable def opcyclesIsCokernel (hi : c.prev j = i) [K.HasHomology j] : IsColimit (CokernelCofork.ofπ (K.pOpcycles j) (K.d_pOpcycles i j)) := by obtain rfl := hi exact (K.sc j).opcyclesIsCokernel @[reassoc (attr := simp)] lemma p_fromOpcycles : K.pOpcycles i ≫ K.fromOpcycles i j = K.d i j := p_descOpcycles _ _ _ _ _ instance : Epi (K.pOpcycles i) := by dsimp only [pOpcycles] infer_instance instance : Mono (K.homologyι i) := by dsimp only [homologyι] infer_instance @[reassoc (attr := simp)] lemma fromOpcycles_d : K.fromOpcycles i j ≫ K.d j k = 0 := by simp only [← cancel_epi (K.pOpcycles i), p_fromOpcycles_assoc, d_comp_d, comp_zero] variable {i} @[reassoc] lemma descOpcycles_comp {A A' : C} (k : K.X i ⟶ A) (j : ι) (hj : c.prev i = j) (hk : K.d j i ≫ k = 0) (α : A ⟶ A') : K.descOpcycles k j hj hk ≫ α = K.descOpcycles (k ≫ α) j hj (by rw [reassoc_of% hk, zero_comp]) := by simp only [← cancel_epi (K.pOpcycles i), p_descOpcycles_assoc, p_descOpcycles] @[reassoc] lemma homologyι_descOpcycles_eq_zero_of_boundary {A : C} (k : K.X i ⟶ A) (j : ι) (hj : c.prev i = j) {i' : ι} (x : K.X i' ⟶ A) (hx : k = K.d i i' ≫ x) : K.homologyι i ≫ K.descOpcycles k j hj (by rw [hx, K.d_comp_d_assoc, zero_comp]) = 0 := by by_cases h : c.Rel i i' · obtain rfl := c.next_eq' h exact (K.sc i).homologyι_descOpcycles_eq_zero_of_boundary _ x hx · have : K.descOpcycles k j hj (by rw [hx, K.d_comp_d_assoc, zero_comp]) = 0 := by rw [K.shape _ _ h, zero_comp] at hx rw [← cancel_epi (K.pOpcycles i), comp_zero, p_descOpcycles, hx] rw [this, comp_zero] variable (i) @[reassoc (attr := simp)] lemma homologyι_comp_fromOpcycles : K.homologyι i ≫ K.fromOpcycles i j = 0 := K.homologyι_descOpcycles_eq_zero_of_boundary (K.d i j) _ rfl (𝟙 _) (by simp) /-- `K.homology i` is the kernel of `K.fromOpcycles i j : K.opcycles i ⟶ K.X j` when `c.next i = j`. -/ noncomputable def homologyIsKernel (hi : c.next i = j) : IsLimit (KernelFork.ofι (K.homologyι i) (K.homologyι_comp_fromOpcycles i j)) := by subst hi exact (K.sc i).homologyIsKernel variable {K L M} variable [L.HasHomology i] [M.HasHomology i] /-- The map `K.homology i ⟶ L.homology i` induced by a morphism in `HomologicalComplex`. -/ noncomputable def homologyMap : K.homology i ⟶ L.homology i := ShortComplex.homologyMap ((shortComplexFunctor C c i).map φ) /-- The map `K.cycles i ⟶ L.cycles i` induced by a morphism in `HomologicalComplex`. -/ noncomputable def cyclesMap : K.cycles i ⟶ L.cycles i := ShortComplex.cyclesMap ((shortComplexFunctor C c i).map φ) /-- The map `K.opcycles i ⟶ L.opcycles i` induced by a morphism in `HomologicalComplex`. -/ noncomputable def opcyclesMap : K.opcycles i ⟶ L.opcycles i := ShortComplex.opcyclesMap ((shortComplexFunctor C c i).map φ) @[reassoc (attr := simp)] lemma cyclesMap_i : cyclesMap φ i ≫ L.iCycles i = K.iCycles i ≫ φ.f i := ShortComplex.cyclesMap_i _ @[reassoc (attr := simp)] lemma p_opcyclesMap : K.pOpcycles i ≫ opcyclesMap φ i = φ.f i ≫ L.pOpcycles i := ShortComplex.p_opcyclesMap _ instance [Mono (φ.f i)] : Mono (cyclesMap φ i) := mono_of_mono_fac (cyclesMap_i φ i) attribute [local instance] epi_comp instance [Epi (φ.f i)] : Epi (opcyclesMap φ i) := epi_of_epi_fac (p_opcyclesMap φ i) variable (K) @[simp] lemma homologyMap_id : homologyMap (𝟙 K) i = 𝟙 _ := ShortComplex.homologyMap_id _ @[simp] lemma cyclesMap_id : cyclesMap (𝟙 K) i = 𝟙 _ := ShortComplex.cyclesMap_id _ @[simp] lemma opcyclesMap_id : opcyclesMap (𝟙 K) i = 𝟙 _ := ShortComplex.opcyclesMap_id _ variable {K} @[reassoc] lemma homologyMap_comp : homologyMap (φ ≫ ψ) i = homologyMap φ i ≫ homologyMap ψ i := by dsimp [homologyMap] rw [Functor.map_comp, ShortComplex.homologyMap_comp] @[reassoc] lemma cyclesMap_comp : cyclesMap (φ ≫ ψ) i = cyclesMap φ i ≫ cyclesMap ψ i := by dsimp [cyclesMap] rw [Functor.map_comp, ShortComplex.cyclesMap_comp] @[reassoc] lemma opcyclesMap_comp : opcyclesMap (φ ≫ ψ) i = opcyclesMap φ i ≫ opcyclesMap ψ i := by dsimp [opcyclesMap] rw [Functor.map_comp, ShortComplex.opcyclesMap_comp] variable (K L) @[simp] lemma homologyMap_zero : homologyMap (0 : K ⟶ L) i = 0 := ShortComplex.homologyMap_zero _ _ @[simp] lemma cyclesMap_zero : cyclesMap (0 : K ⟶ L) i = 0 := ShortComplex.cyclesMap_zero _ _ @[simp] lemma opcyclesMap_zero : opcyclesMap (0 : K ⟶ L) i = 0 := ShortComplex.opcyclesMap_zero _ _ variable {K L} @[reassoc (attr := simp)] lemma homologyπ_naturality : K.homologyπ i ≫ homologyMap φ i = cyclesMap φ i ≫ L.homologyπ i := ShortComplex.homologyπ_naturality _ @[reassoc (attr := simp)] lemma homologyι_naturality : homologyMap φ i ≫ L.homologyι i = K.homologyι i ≫ opcyclesMap φ i := ShortComplex.homologyι_naturality _ @[reassoc (attr := simp)] lemma homology_π_ι : K.homologyπ i ≫ K.homologyι i = K.iCycles i ≫ K.pOpcycles i := (K.sc i).homology_π_ι variable {i} @[reassoc (attr := simp)] lemma opcyclesMap_comp_descOpcycles {A : C} (k : L.X i ⟶ A) (j : ι) (hj : c.prev i = j) (hk : L.d j i ≫ k = 0) (φ : K ⟶ L) : opcyclesMap φ i ≫ L.descOpcycles k j hj hk = K.descOpcycles (φ.f i ≫ k) j hj (by rw [← φ.comm_assoc, hk, comp_zero]) := by simp only [← cancel_epi (K.pOpcycles i), p_opcyclesMap_assoc, p_descOpcycles] @[reassoc (attr := simp)] lemma liftCycles_comp_cyclesMap {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j) (hk : k ≫ K.d i j = 0) (φ : K ⟶ L) : K.liftCycles k j hj hk ≫ cyclesMap φ i = L.liftCycles (k ≫ φ.f i) j hj (by rw [assoc, φ.comm, reassoc_of% hk, zero_comp]) := by simp only [← cancel_mono (L.iCycles i), assoc, cyclesMap_i, liftCycles_i_assoc, liftCycles_i] section variable (C c i) attribute [local simp] homologyMap_comp cyclesMap_comp opcyclesMap_comp /-- The `i`th homology functor `HomologicalComplex C c ⥤ C`. -/ @[simps] noncomputable def homologyFunctor [CategoryWithHomology C] : HomologicalComplex C c ⥤ C where obj K := K.homology i map f := homologyMap f i /-- The homology functor to graded objects. -/ @[simps] noncomputable def gradedHomologyFunctor [CategoryWithHomology C] : HomologicalComplex C c ⥤ GradedObject ι C where obj K i := K.homology i map f i := homologyMap f i /-- The `i`th cycles functor `HomologicalComplex C c ⥤ C`. -/ @[simps] noncomputable def cyclesFunctor [CategoryWithHomology C] : HomologicalComplex C c ⥤ C where obj K := K.cycles i map f := cyclesMap f i /-- The `i`th opcycles functor `HomologicalComplex C c ⥤ C`. -/ @[simps] noncomputable def opcyclesFunctor [CategoryWithHomology C] : HomologicalComplex C c ⥤ C where obj K := K.opcycles i map f := opcyclesMap f i /-- The natural transformation `K.homologyπ i : K.cycles i ⟶ K.homology i` for all `K : HomologicalComplex C c`. -/ @[simps] noncomputable def natTransHomologyπ [CategoryWithHomology C] : cyclesFunctor C c i ⟶ homologyFunctor C c i where app K := K.homologyπ i /-- The natural transformation `K.homologyι i : K.homology i ⟶ K.opcycles i` for all `K : HomologicalComplex C c`. -/ @[simps] noncomputable def natTransHomologyι [CategoryWithHomology C] : homologyFunctor C c i ⟶ opcyclesFunctor C c i where app K := K.homologyι i /-- The natural isomorphism `K.homology i ≅ (K.sc i).homology` for all homological complexes `K`. -/ @[simps!] noncomputable def homologyFunctorIso [CategoryWithHomology C] : homologyFunctor C c i ≅ shortComplexFunctor C c i ⋙ ShortComplex.homologyFunctor C := Iso.refl _ /-- The natural isomorphism `K.homology j ≅ (K.sc' i j k).homology` for all homological complexes `K` when `c.prev j = i` and `c.next j = k`. -/ noncomputable def homologyFunctorIso' [CategoryWithHomology C] (hi : c.prev j = i) (hk : c.next j = k) : homologyFunctor C c j ≅ shortComplexFunctor' C c i j k ⋙ ShortComplex.homologyFunctor C := homologyFunctorIso C c j ≪≫ isoWhiskerRight (natIsoSc' C c i j k hi hk) _ instance [CategoryWithHomology C] : (homologyFunctor C c i).PreservesZeroMorphisms where instance [CategoryWithHomology C] : (opcyclesFunctor C c i).PreservesZeroMorphisms where instance [CategoryWithHomology C] : (cyclesFunctor C c i).PreservesZeroMorphisms where end end variable (K L : HomologicalComplex C c) (i j k : ι) section variable (hj : c.next i = j) (h : K.d i j = 0) [K.HasHomology i] lemma isIso_iCycles : IsIso (K.iCycles i) := by subst hj exact ShortComplex.isIso_iCycles _ h /-- The canonical isomorphism `K.cycles i ≅ K.X i` when the differential from `i` is zero. -/ @[simps! hom] noncomputable def iCyclesIso : K.cycles i ≅ K.X i := have := K.isIso_iCycles i j hj h asIso (K.iCycles i) @[reassoc (attr := simp)] lemma iCyclesIso_hom_inv_id : K.iCycles i ≫ (K.iCyclesIso i j hj h).inv = 𝟙 _ := (K.iCyclesIso i j hj h).hom_inv_id @[reassoc (attr := simp)] lemma iCyclesIso_inv_hom_id : (K.iCyclesIso i j hj h).inv ≫ K.iCycles i = 𝟙 _ := (K.iCyclesIso i j hj h).inv_hom_id lemma isIso_homologyι : IsIso (K.homologyι i) := ShortComplex.isIso_homologyι _ (by aesop_cat) /-- The canonical isomorphism `K.homology i ≅ K.opcycles i` when the differential from `i` is zero. -/ @[simps! hom] noncomputable def isoHomologyι : K.homology i ≅ K.opcycles i := have := K.isIso_homologyι i j hj h asIso (K.homologyι i) @[reassoc (attr := simp)] lemma isoHomologyι_hom_inv_id : K.homologyι i ≫ (K.isoHomologyι i j hj h).inv = 𝟙 _ := (K.isoHomologyι i j hj h).hom_inv_id @[reassoc (attr := simp)] lemma isoHomologyι_inv_hom_id : (K.isoHomologyι i j hj h).inv ≫ K.homologyι i = 𝟙 _ := (K.isoHomologyι i j hj h).inv_hom_id end section variable (hi : c.prev j = i) (h : K.d i j = 0) [K.HasHomology j] lemma isIso_pOpcycles : IsIso (K.pOpcycles j) := by obtain rfl := hi exact ShortComplex.isIso_pOpcycles _ h /-- The canonical isomorphism `K.X j ≅ K.opCycles j` when the differential to `j` is zero. -/ @[simps! hom] noncomputable def pOpcyclesIso : K.X j ≅ K.opcycles j := have := K.isIso_pOpcycles i j hi h asIso (K.pOpcycles j) @[reassoc (attr := simp)] lemma pOpcyclesIso_hom_inv_id : K.pOpcycles j ≫ (K.pOpcyclesIso i j hi h).inv = 𝟙 _ := (K.pOpcyclesIso i j hi h).hom_inv_id @[reassoc (attr := simp)] lemma pOpcyclesIso_inv_hom_id : (K.pOpcyclesIso i j hi h).inv ≫ K.pOpcycles j = 𝟙 _ := (K.pOpcyclesIso i j hi h).inv_hom_id lemma isIso_homologyπ : IsIso (K.homologyπ j) := ShortComplex.isIso_homologyπ _ (by aesop_cat) /-- The canonical isomorphism `K.cycles j ≅ K.homology j` when the differential to `j` is zero. -/ @[simps! hom] noncomputable def isoHomologyπ : K.cycles j ≅ K.homology j := have := K.isIso_homologyπ i j hi h asIso (K.homologyπ j) @[reassoc (attr := simp)] lemma isoHomologyπ_hom_inv_id : K.homologyπ j ≫ (K.isoHomologyπ i j hi h).inv = 𝟙 _ := (K.isoHomologyπ i j hi h).hom_inv_id @[reassoc (attr := simp)] lemma isoHomologyπ_inv_hom_id : (K.isoHomologyπ i j hi h).inv ≫ K.homologyπ j = 𝟙 _ := (K.isoHomologyπ i j hi h).inv_hom_id end section variable {K L} lemma epi_homologyMap_of_epi_of_not_rel (φ : K ⟶ L) (i : ι) [K.HasHomology i] [L.HasHomology i] [Epi (φ.f i)] (hi : ∀ j, ¬ c.Rel i j) : Epi (homologyMap φ i) := ((MorphismProperty.epimorphisms C).arrow_mk_iso_iff (Arrow.isoMk (K.isoHomologyι i _ rfl (shape _ _ _ (by tauto))) (L.isoHomologyι i _ rfl (shape _ _ _ (by tauto))))).2 (MorphismProperty.epimorphisms.infer_property (opcyclesMap φ i)) lemma mono_homologyMap_of_mono_of_not_rel (φ : K ⟶ L) (j : ι) [K.HasHomology j] [L.HasHomology j] [Mono (φ.f j)] (hj : ∀ i, ¬ c.Rel i j) : Mono (homologyMap φ j) := ((MorphismProperty.monomorphisms C).arrow_mk_iso_iff (Arrow.isoMk (K.isoHomologyπ _ j rfl (shape _ _ _ (by tauto))) (L.isoHomologyπ _ j rfl (shape _ _ _ (by tauto))))).1 (MorphismProperty.monomorphisms.infer_property (cyclesMap φ j)) end /-- A homological complex `K` is exact at `i` if the short complex `K.sc i` is exact. -/ def ExactAt := (K.sc i).Exact lemma exactAt_iff : K.ExactAt i ↔ (K.sc i).Exact := by rfl variable {K i} in lemma ExactAt.of_iso (hK : K.ExactAt i) {L : HomologicalComplex C c} (e : K ≅ L) : L.ExactAt i := by rw [exactAt_iff] at hK ⊢ exact ShortComplex.exact_of_iso ((shortComplexFunctor C c i).mapIso e) hK lemma exactAt_iff' (hi : c.prev j = i) (hk : c.next j = k) : K.ExactAt j ↔ (K.sc' i j k).Exact := ShortComplex.exact_iff_of_iso (K.isoSc' i j k hi hk) lemma exactAt_iff_isZero_homology [K.HasHomology i] : K.ExactAt i ↔ IsZero (K.homology i) := by dsimp [homology] rw [exactAt_iff, ShortComplex.exact_iff_isZero_homology] end HomologicalComplex namespace ChainComplex variable {C : Type*} [Category C] [HasZeroMorphisms C] (K L : ChainComplex C ℕ) (φ : K ⟶ L) [K.HasHomology 0] instance isIso_homologyι₀ : IsIso (K.homologyι 0) := K.isIso_homologyι 0 _ rfl (by simp) /-- The canonical isomorphism `K.homology 0 ≅ K.opcycles 0` for a chain complex `K` indexed by `ℕ`. -/ noncomputable abbrev isoHomologyι₀ : K.homology 0 ≅ K.opcycles 0 := K.isoHomologyι 0 _ rfl (by simp) variable {K L} @[reassoc (attr := simp)] lemma isoHomologyι₀_inv_naturality [L.HasHomology 0] : K.isoHomologyι₀.inv ≫ HomologicalComplex.homologyMap φ 0 = HomologicalComplex.opcyclesMap φ 0 ≫ L.isoHomologyι₀.inv := by simp only [assoc, ← cancel_mono (L.homologyι 0), HomologicalComplex.homologyι_naturality, HomologicalComplex.isoHomologyι_inv_hom_id_assoc, HomologicalComplex.isoHomologyι_inv_hom_id, comp_id] end ChainComplex namespace CochainComplex variable {C : Type*} [Category C] [HasZeroMorphisms C] (K L : CochainComplex C ℕ) (φ : K ⟶ L) [K.HasHomology 0] instance isIso_homologyπ₀ : IsIso (K.homologyπ 0) := K.isIso_homologyπ _ 0 rfl (by simp) /-- The canonical isomorphism `K.cycles 0 ≅ K.homology 0` for a cochain complex `K` indexed by `ℕ`. -/ noncomputable abbrev isoHomologyπ₀ : K.cycles 0 ≅ K.homology 0 := K.isoHomologyπ _ 0 rfl (by simp) variable {K L} @[reassoc (attr := simp)] lemma isoHomologyπ₀_inv_naturality [L.HasHomology 0] : HomologicalComplex.homologyMap φ 0 ≫ L.isoHomologyπ₀.inv = K.isoHomologyπ₀.inv ≫ HomologicalComplex.cyclesMap φ 0 := by simp only [← cancel_epi (K.homologyπ 0), HomologicalComplex.homologyπ_naturality_assoc, HomologicalComplex.isoHomologyπ_hom_inv_id, comp_id, HomologicalComplex.isoHomologyπ_hom_inv_id_assoc] end CochainComplex namespace HomologicalComplex variable {C ι : Type*} [Category C] [Preadditive C] {c : ComplexShape ι} {K L : HomologicalComplex C c} {f g : K ⟶ L} variable (φ ψ : K ⟶ L) (i : ι) [K.HasHomology i] [L.HasHomology i] @[simp] lemma homologyMap_neg : homologyMap (-φ) i = -homologyMap φ i := by dsimp [homologyMap] rw [← ShortComplex.homologyMap_neg] rfl @[simp] lemma homologyMap_add : homologyMap (φ + ψ) i = homologyMap φ i + homologyMap ψ i := by dsimp [homologyMap] rw [← ShortComplex.homologyMap_add] rfl @[simp] lemma homologyMap_sub : homologyMap (φ - ψ) i = homologyMap φ i - homologyMap ψ i := by dsimp [homologyMap] rw [← ShortComplex.homologyMap_sub] rfl instance [CategoryWithHomology C] : (homologyFunctor C c i).Additive where end HomologicalComplex namespace CochainComplex variable {C : Type*} [Category C] [Abelian C] lemma isIso_liftCycles_iff (K : CochainComplex C ℕ) {X : C} (φ : X ⟶ K.X 0) [K.HasHomology 0] (hφ : φ ≫ K.d 0 1 = 0) : IsIso (K.liftCycles φ 1 (by simp) hφ) ↔ (ShortComplex.mk _ _ hφ).Exact ∧ Mono φ := by suffices ∀ (i : ℕ) (hx : (ComplexShape.up ℕ).next 0 = i) (hφ : φ ≫ K.d 0 i = 0), IsIso (K.liftCycles φ i hx hφ) ↔ (ShortComplex.mk _ _ hφ).Exact ∧ Mono φ from this 1 (by simp) hφ rintro _ rfl hφ let α : ShortComplex.mk (0 : X ⟶ X) (0 : X ⟶ X) (by simp) ⟶ K.sc 0 := { τ₁ := 0 τ₂ := φ τ₃ := 0 } exact (ShortComplex.quasiIso_iff_isIso_liftCycles α rfl rfl (by simp)).symm.trans (ShortComplex.quasiIso_iff_of_zeros α rfl rfl (by simp)) end CochainComplex namespace ChainComplex variable {C : Type*} [Category C] [Abelian C] lemma isIso_descOpcycles_iff (K : ChainComplex C ℕ) {X : C} (φ : K.X 0 ⟶ X) [K.HasHomology 0] (hφ : K.d 1 0 ≫ φ = 0) : IsIso (K.descOpcycles φ 1 (by simp) hφ) ↔ (ShortComplex.mk _ _ hφ).Exact ∧ Epi φ := by suffices ∀ (i : ℕ) (hx : (ComplexShape.down ℕ).prev 0 = i) (hφ : K.d i 0 ≫ φ = 0), IsIso (K.descOpcycles φ i hx hφ) ↔ (ShortComplex.mk _ _ hφ).Exact ∧ Epi φ from this 1 (by simp) hφ rintro _ rfl hφ let α : K.sc 0 ⟶ ShortComplex.mk (0 : X ⟶ X) (0 : X ⟶ X) (by simp) := { τ₁ := 0 τ₂ := φ τ₃ := 0 } exact (ShortComplex.quasiIso_iff_isIso_descOpcycles α (by simp) rfl rfl).symm.trans (ShortComplex.quasiIso_iff_of_zeros' α (by simp) rfl rfl) end ChainComplex namespace HomologicalComplex variable {C : Type*} [Category C] [HasZeroMorphisms C] {ι : Type*} {c : ComplexShape ι} (K : HomologicalComplex C c) (i j k : ι) (hi : c.prev j = i) (hk : c.next j = k) [K.HasHomology j] [(K.sc' i j k).HasHomology] /-- The cycles of a homological complex in degree `j` can be computed by specifying a choice of `c.prev j` and `c.next j`. -/ noncomputable def cyclesIsoSc' : K.cycles j ≅ (K.sc' i j k).cycles := ShortComplex.cyclesMapIso (K.isoSc' i j k hi hk) @[reassoc (attr := simp)] lemma cyclesIsoSc'_hom_iCycles : (K.cyclesIsoSc' i j k hi hk).hom ≫ (K.sc' i j k).iCycles = K.iCycles j := by dsimp [cyclesIsoSc'] simp only [ShortComplex.cyclesMap_i, shortComplexFunctor_obj_X₂, shortComplexFunctor'_obj_X₂, natIsoSc'_hom_app_τ₂, comp_id] rfl @[reassoc (attr := simp)] lemma cyclesIsoSc'_inv_iCycles : (K.cyclesIsoSc' i j k hi hk).inv ≫ K.iCycles j = (K.sc' i j k).iCycles := by dsimp [cyclesIsoSc'] erw [ShortComplex.cyclesMap_i] apply comp_id @[reassoc (attr := simp)] lemma toCycles_cyclesIsoSc'_hom : K.toCycles i j ≫ (K.cyclesIsoSc' i j k hi hk).hom = (K.sc' i j k).toCycles := by simp only [← cancel_mono (K.sc' i j k).iCycles, assoc, cyclesIsoSc'_hom_iCycles, toCycles_i, ShortComplex.toCycles_i, shortComplexFunctor'_obj_f] /-- The homology of a homological complex in degree `j` can be computed by specifying a choice of `c.prev j` and `c.next j`. -/ noncomputable def opcyclesIsoSc' : K.opcycles j ≅ (K.sc' i j k).opcycles := ShortComplex.opcyclesMapIso (K.isoSc' i j k hi hk) @[reassoc (attr := simp)] lemma pOpcycles_opcyclesIsoSc'_inv : (K.sc' i j k).pOpcycles ≫ (K.opcyclesIsoSc' i j k hi hk).inv = K.pOpcycles j := by dsimp [opcyclesIsoSc'] simp only [ShortComplex.p_opcyclesMap, shortComplexFunctor'_obj_X₂, shortComplexFunctor_obj_X₂, natIsoSc'_inv_app_τ₂, id_comp] rfl @[reassoc (attr := simp)] lemma pOpcycles_opcyclesIsoSc'_hom : K.pOpcycles j ≫ (K.opcyclesIsoSc' i j k hi hk).hom = (K.sc' i j k).pOpcycles := by dsimp [opcyclesIsoSc'] erw [ShortComplex.p_opcyclesMap] apply id_comp @[reassoc (attr := simp)] lemma opcyclesIsoSc'_inv_fromOpcycles : (K.opcyclesIsoSc' i j k hi hk).inv ≫ K.fromOpcycles j k = (K.sc' i j k).fromOpcycles := by simp only [← cancel_epi (K.sc' i j k).pOpcycles, pOpcycles_opcyclesIsoSc'_inv_assoc, p_fromOpcycles, ShortComplex.p_fromOpcycles, shortComplexFunctor'_obj_g] /-- The opcycles of a homological complex in degree `j` can be computed by specifying a choice of `c.prev j` and `c.next j`. -/ noncomputable def homologyIsoSc' : K.homology j ≅ (K.sc' i j k).homology := ShortComplex.homologyMapIso (K.isoSc' i j k hi hk) @[reassoc (attr := simp)] lemma π_homologyIsoSc'_hom : K.homologyπ j ≫ (K.homologyIsoSc' i j k hi hk).hom = (K.cyclesIsoSc' i j k hi hk).hom ≫ (K.sc' i j k).homologyπ := by apply ShortComplex.homologyπ_naturality @[reassoc (attr := simp)] lemma π_homologyIsoSc'_inv : (K.sc' i j k).homologyπ ≫ (K.homologyIsoSc' i j k hi hk).inv = (K.cyclesIsoSc' i j k hi hk).inv ≫ K.homologyπ j := by apply ShortComplex.homologyπ_naturality @[reassoc (attr := simp)] lemma homologyIsoSc'_hom_ι : (K.homologyIsoSc' i j k hi hk).hom ≫ (K.sc' i j k).homologyι = K.homologyι j ≫ (K.opcyclesIsoSc' i j k hi hk).hom := by apply ShortComplex.homologyι_naturality @[reassoc (attr := simp)] lemma homologyIsoSc'_inv_ι : (K.homologyIsoSc' i j k hi hk).inv ≫ K.homologyι j = (K.sc' i j k).homologyι ≫ (K.opcyclesIsoSc' i j k hi hk).inv := by apply ShortComplex.homologyι_naturality end HomologicalComplex
Algebra\Homology\ShortComplex\Homology.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.RightHomology /-! # Homology of short complexes In this file, we shall define the homology of short complexes `S`, i.e. diagrams `f : X₁ ⟶ X₂` and `g : X₂ ⟶ X₃` such that `f ≫ g = 0`. We shall say that `[S.HasHomology]` when there exists `h : S.HomologyData`. A homology data for `S` consists of compatible left/right homology data `left` and `right`. The left homology data `left` involves an object `left.H` that is a cokernel of the canonical map `S.X₁ ⟶ K` where `K` is a kernel of `g`. On the other hand, the dual notion `right.H` is a kernel of the canonical morphism `Q ⟶ S.X₃` when `Q` is a cokernel of `f`. The compatibility that is required involves an isomorphism `left.H ≅ right.H` which makes a certain pentagon commute. When such a homology data exists, `S.homology` shall be defined as `h.left.H` for a chosen `h : S.HomologyData`. This definition requires very little assumption on the category (only the existence of zero morphisms). We shall prove that in abelian categories, all short complexes have homology data. Note: This definition arose by the end of the Liquid Tensor Experiment which contained a structure `has_homology` which is quite similar to `S.HomologyData`. After the category `ShortComplex C` was introduced by J. Riou, A. Topaz suggested such a structure could be used as a basis for the *definition* of homology. -/ universe v u namespace CategoryTheory open Category Limits variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C] (S : ShortComplex C) {S₁ S₂ S₃ S₄ : ShortComplex C} namespace ShortComplex /-- A homology data for a short complex consists of two compatible left and right homology data -/ structure HomologyData where /-- a left homology data -/ left : S.LeftHomologyData /-- a right homology data -/ right : S.RightHomologyData /-- the compatibility isomorphism relating the two dual notions of `LeftHomologyData` and `RightHomologyData` -/ iso : left.H ≅ right.H /-- the pentagon relation expressing the compatibility of the left and right homology data -/ comm : left.π ≫ iso.hom ≫ right.ι = left.i ≫ right.p := by aesop_cat attribute [reassoc (attr := simp)] HomologyData.comm variable (φ : S₁ ⟶ S₂) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) /-- A homology map data for a morphism `φ : S₁ ⟶ S₂` where both `S₁` and `S₂` are equipped with homology data consists of left and right homology map data. -/ structure HomologyMapData where /-- a left homology map data -/ left : LeftHomologyMapData φ h₁.left h₂.left /-- a right homology map data -/ right : RightHomologyMapData φ h₁.right h₂.right namespace HomologyMapData attribute [nolint simpNF] mk.injEq variable {φ h₁ h₂} @[reassoc] lemma comm (h : HomologyMapData φ h₁ h₂) : h.left.φH ≫ h₂.iso.hom = h₁.iso.hom ≫ h.right.φH := by simp only [← cancel_epi h₁.left.π, ← cancel_mono h₂.right.ι, assoc, LeftHomologyMapData.commπ_assoc, HomologyData.comm, LeftHomologyMapData.commi_assoc, RightHomologyMapData.commι, HomologyData.comm_assoc, RightHomologyMapData.commp] instance : Subsingleton (HomologyMapData φ h₁ h₂) := ⟨by rintro ⟨left₁, right₁⟩ ⟨left₂, right₂⟩ simp only [mk.injEq, eq_iff_true_of_subsingleton, and_self]⟩ instance : Inhabited (HomologyMapData φ h₁ h₂) := ⟨⟨default, default⟩⟩ instance : Unique (HomologyMapData φ h₁ h₂) := Unique.mk' _ variable (φ h₁ h₂) /-- A choice of the (unique) homology map data associated with a morphism `φ : S₁ ⟶ S₂` where both short complexes `S₁` and `S₂` are equipped with homology data. -/ def homologyMapData : HomologyMapData φ h₁ h₂ := default variable {φ h₁ h₂} lemma congr_left_φH {γ₁ γ₂ : HomologyMapData φ h₁ h₂} (eq : γ₁ = γ₂) : γ₁.left.φH = γ₂.left.φH := by rw [eq] end HomologyMapData namespace HomologyData /-- When the first map `S.f` is zero, this is the homology data on `S` given by any limit kernel fork of `S.g` -/ @[simps] def ofIsLimitKernelFork (hf : S.f = 0) (c : KernelFork S.g) (hc : IsLimit c) : S.HomologyData where left := LeftHomologyData.ofIsLimitKernelFork S hf c hc right := RightHomologyData.ofIsLimitKernelFork S hf c hc iso := Iso.refl _ /-- When the first map `S.f` is zero, this is the homology data on `S` given by the chosen `kernel S.g` -/ @[simps] noncomputable def ofHasKernel (hf : S.f = 0) [HasKernel S.g] : S.HomologyData where left := LeftHomologyData.ofHasKernel S hf right := RightHomologyData.ofHasKernel S hf iso := Iso.refl _ /-- When the second map `S.g` is zero, this is the homology data on `S` given by any colimit cokernel cofork of `S.f` -/ @[simps] def ofIsColimitCokernelCofork (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : S.HomologyData where left := LeftHomologyData.ofIsColimitCokernelCofork S hg c hc right := RightHomologyData.ofIsColimitCokernelCofork S hg c hc iso := Iso.refl _ /-- When the second map `S.g` is zero, this is the homology data on `S` given by the chosen `cokernel S.f` -/ @[simps] noncomputable def ofHasCokernel (hg : S.g = 0) [HasCokernel S.f] : S.HomologyData where left := LeftHomologyData.ofHasCokernel S hg right := RightHomologyData.ofHasCokernel S hg iso := Iso.refl _ /-- When both `S.f` and `S.g` are zero, the middle object `S.X₂` gives a homology data on S -/ @[simps] noncomputable def ofZeros (hf : S.f = 0) (hg : S.g = 0) : S.HomologyData where left := LeftHomologyData.ofZeros S hf hg right := RightHomologyData.ofZeros S hf hg iso := Iso.refl _ /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a homology data for `S₁` induces a homology data for `S₂`. The inverse construction is `ofEpiOfIsIsoOfMono'`. -/ @[simps] noncomputable def ofEpiOfIsIsoOfMono (φ : S₁ ⟶ S₂) (h : HomologyData S₁) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HomologyData S₂ where left := LeftHomologyData.ofEpiOfIsIsoOfMono φ h.left right := RightHomologyData.ofEpiOfIsIsoOfMono φ h.right iso := h.iso /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a homology data for `S₂` induces a homology data for `S₁`. The inverse construction is `ofEpiOfIsIsoOfMono`. -/ @[simps] noncomputable def ofEpiOfIsIsoOfMono' (φ : S₁ ⟶ S₂) (h : HomologyData S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HomologyData S₁ where left := LeftHomologyData.ofEpiOfIsIsoOfMono' φ h.left right := RightHomologyData.ofEpiOfIsIsoOfMono' φ h.right iso := h.iso /-- If `e : S₁ ≅ S₂` is an isomorphism of short complexes and `h₁ : HomologyData S₁`, this is the homology data for `S₂` deduced from the isomorphism. -/ @[simps!] noncomputable def ofIso (e : S₁ ≅ S₂) (h : HomologyData S₁) := h.ofEpiOfIsIsoOfMono e.hom variable {S} /-- A homology data for a short complex `S` induces a homology data for `S.op`. -/ @[simps] def op (h : S.HomologyData) : S.op.HomologyData where left := h.right.op right := h.left.op iso := h.iso.op comm := Quiver.Hom.unop_inj (by simp) /-- A homology data for a short complex `S` in the opposite category induces a homology data for `S.unop`. -/ @[simps] def unop {S : ShortComplex Cᵒᵖ} (h : S.HomologyData) : S.unop.HomologyData where left := h.right.unop right := h.left.unop iso := h.iso.unop comm := Quiver.Hom.op_inj (by simp) end HomologyData /-- A short complex `S` has homology when there exists a `S.HomologyData` -/ class HasHomology : Prop where /-- the condition that there exists a homology data -/ condition : Nonempty S.HomologyData /-- A chosen `S.HomologyData` for a short complex `S` that has homology -/ noncomputable def homologyData [HasHomology S] : S.HomologyData := HasHomology.condition.some variable {S} lemma HasHomology.mk' (h : S.HomologyData) : HasHomology S := ⟨Nonempty.intro h⟩ instance [HasHomology S] : HasHomology S.op := HasHomology.mk' S.homologyData.op instance (S : ShortComplex Cᵒᵖ) [HasHomology S] : HasHomology S.unop := HasHomology.mk' S.homologyData.unop instance hasLeftHomology_of_hasHomology [S.HasHomology] : S.HasLeftHomology := HasLeftHomology.mk' S.homologyData.left instance hasRightHomology_of_hasHomology [S.HasHomology] : S.HasRightHomology := HasRightHomology.mk' S.homologyData.right instance hasHomology_of_hasCokernel {X Y : C} (f : X ⟶ Y) (Z : C) [HasCokernel f] : (ShortComplex.mk f (0 : Y ⟶ Z) comp_zero).HasHomology := HasHomology.mk' (HomologyData.ofHasCokernel _ rfl) instance hasHomology_of_hasKernel {Y Z : C} (g : Y ⟶ Z) (X : C) [HasKernel g] : (ShortComplex.mk (0 : X ⟶ Y) g zero_comp).HasHomology := HasHomology.mk' (HomologyData.ofHasKernel _ rfl) instance hasHomology_of_zeros (X Y Z : C) : (ShortComplex.mk (0 : X ⟶ Y) (0 : Y ⟶ Z) zero_comp).HasHomology := HasHomology.mk' (HomologyData.ofZeros _ rfl rfl) lemma hasHomology_of_epi_of_isIso_of_mono (φ : S₁ ⟶ S₂) [HasHomology S₁] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HasHomology S₂ := HasHomology.mk' (HomologyData.ofEpiOfIsIsoOfMono φ S₁.homologyData) lemma hasHomology_of_epi_of_isIso_of_mono' (φ : S₁ ⟶ S₂) [HasHomology S₂] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HasHomology S₁ := HasHomology.mk' (HomologyData.ofEpiOfIsIsoOfMono' φ S₂.homologyData) lemma hasHomology_of_iso (e : S₁ ≅ S₂) [HasHomology S₁] : HasHomology S₂ := HasHomology.mk' (HomologyData.ofIso e S₁.homologyData) namespace HomologyMapData /-- The homology map data associated to the identity morphism of a short complex. -/ @[simps] def id (h : S.HomologyData) : HomologyMapData (𝟙 S) h h where left := LeftHomologyMapData.id h.left right := RightHomologyMapData.id h.right /-- The homology map data associated to the zero morphism between two short complexes. -/ @[simps] def zero (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) : HomologyMapData 0 h₁ h₂ where left := LeftHomologyMapData.zero h₁.left h₂.left right := RightHomologyMapData.zero h₁.right h₂.right /-- The composition of homology map data. -/ @[simps] def comp {φ : S₁ ⟶ S₂} {φ' : S₂ ⟶ S₃} {h₁ : S₁.HomologyData} {h₂ : S₂.HomologyData} {h₃ : S₃.HomologyData} (ψ : HomologyMapData φ h₁ h₂) (ψ' : HomologyMapData φ' h₂ h₃) : HomologyMapData (φ ≫ φ') h₁ h₃ where left := ψ.left.comp ψ'.left right := ψ.right.comp ψ'.right /-- A homology map data for a morphism of short complexes induces a homology map data in the opposite category. -/ @[simps] def op {φ : S₁ ⟶ S₂} {h₁ : S₁.HomologyData} {h₂ : S₂.HomologyData} (ψ : HomologyMapData φ h₁ h₂) : HomologyMapData (opMap φ) h₂.op h₁.op where left := ψ.right.op right := ψ.left.op /-- A homology map data for a morphism of short complexes in the opposite category induces a homology map data in the original category. -/ @[simps] def unop {S₁ S₂ : ShortComplex Cᵒᵖ} {φ : S₁ ⟶ S₂} {h₁ : S₁.HomologyData} {h₂ : S₂.HomologyData} (ψ : HomologyMapData φ h₁ h₂) : HomologyMapData (unopMap φ) h₂.unop h₁.unop where left := ψ.right.unop right := ψ.left.unop /-- When `S₁.f`, `S₁.g`, `S₂.f` and `S₂.g` are all zero, the action on homology of a morphism `φ : S₁ ⟶ S₂` is given by the action `φ.τ₂` on the middle objects. -/ @[simps] def ofZeros (φ : S₁ ⟶ S₂) (hf₁ : S₁.f = 0) (hg₁ : S₁.g = 0) (hf₂ : S₂.f = 0) (hg₂ : S₂.g = 0) : HomologyMapData φ (HomologyData.ofZeros S₁ hf₁ hg₁) (HomologyData.ofZeros S₂ hf₂ hg₂) where left := LeftHomologyMapData.ofZeros φ hf₁ hg₁ hf₂ hg₂ right := RightHomologyMapData.ofZeros φ hf₁ hg₁ hf₂ hg₂ /-- When `S₁.g` and `S₂.g` are zero and we have chosen colimit cokernel coforks `c₁` and `c₂` for `S₁.f` and `S₂.f` respectively, the action on homology of a morphism `φ : S₁ ⟶ S₂` of short complexes is given by the unique morphism `f : c₁.pt ⟶ c₂.pt` such that `φ.τ₂ ≫ c₂.π = c₁.π ≫ f`. -/ @[simps] def ofIsColimitCokernelCofork (φ : S₁ ⟶ S₂) (hg₁ : S₁.g = 0) (c₁ : CokernelCofork S₁.f) (hc₁ : IsColimit c₁) (hg₂ : S₂.g = 0) (c₂ : CokernelCofork S₂.f) (hc₂ : IsColimit c₂) (f : c₁.pt ⟶ c₂.pt) (comm : φ.τ₂ ≫ c₂.π = c₁.π ≫ f) : HomologyMapData φ (HomologyData.ofIsColimitCokernelCofork S₁ hg₁ c₁ hc₁) (HomologyData.ofIsColimitCokernelCofork S₂ hg₂ c₂ hc₂) where left := LeftHomologyMapData.ofIsColimitCokernelCofork φ hg₁ c₁ hc₁ hg₂ c₂ hc₂ f comm right := RightHomologyMapData.ofIsColimitCokernelCofork φ hg₁ c₁ hc₁ hg₂ c₂ hc₂ f comm /-- When `S₁.f` and `S₂.f` are zero and we have chosen limit kernel forks `c₁` and `c₂` for `S₁.g` and `S₂.g` respectively, the action on homology of a morphism `φ : S₁ ⟶ S₂` of short complexes is given by the unique morphism `f : c₁.pt ⟶ c₂.pt` such that `c₁.ι ≫ φ.τ₂ = f ≫ c₂.ι`. -/ @[simps] def ofIsLimitKernelFork (φ : S₁ ⟶ S₂) (hf₁ : S₁.f = 0) (c₁ : KernelFork S₁.g) (hc₁ : IsLimit c₁) (hf₂ : S₂.f = 0) (c₂ : KernelFork S₂.g) (hc₂ : IsLimit c₂) (f : c₁.pt ⟶ c₂.pt) (comm : c₁.ι ≫ φ.τ₂ = f ≫ c₂.ι) : HomologyMapData φ (HomologyData.ofIsLimitKernelFork S₁ hf₁ c₁ hc₁) (HomologyData.ofIsLimitKernelFork S₂ hf₂ c₂ hc₂) where left := LeftHomologyMapData.ofIsLimitKernelFork φ hf₁ c₁ hc₁ hf₂ c₂ hc₂ f comm right := RightHomologyMapData.ofIsLimitKernelFork φ hf₁ c₁ hc₁ hf₂ c₂ hc₂ f comm /-- When both maps `S.f` and `S.g` of a short complex `S` are zero, this is the homology map data (for the identity of `S`) which relates the homology data `ofZeros` and `ofIsColimitCokernelCofork`. -/ def compatibilityOfZerosOfIsColimitCokernelCofork (hf : S.f = 0) (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : HomologyMapData (𝟙 S) (HomologyData.ofZeros S hf hg) (HomologyData.ofIsColimitCokernelCofork S hg c hc) where left := LeftHomologyMapData.compatibilityOfZerosOfIsColimitCokernelCofork S hf hg c hc right := RightHomologyMapData.compatibilityOfZerosOfIsColimitCokernelCofork S hf hg c hc /-- When both maps `S.f` and `S.g` of a short complex `S` are zero, this is the homology map data (for the identity of `S`) which relates the homology data `HomologyData.ofIsLimitKernelFork` and `ofZeros` . -/ @[simps] def compatibilityOfZerosOfIsLimitKernelFork (hf : S.f = 0) (hg : S.g = 0) (c : KernelFork S.g) (hc : IsLimit c) : HomologyMapData (𝟙 S) (HomologyData.ofIsLimitKernelFork S hf c hc) (HomologyData.ofZeros S hf hg) where left := LeftHomologyMapData.compatibilityOfZerosOfIsLimitKernelFork S hf hg c hc right := RightHomologyMapData.compatibilityOfZerosOfIsLimitKernelFork S hf hg c hc /-- This homology map data expresses compatibilities of the homology data constructed by `HomologyData.ofEpiOfIsIsoOfMono` -/ noncomputable def ofEpiOfIsIsoOfMono (φ : S₁ ⟶ S₂) (h : HomologyData S₁) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HomologyMapData φ h (HomologyData.ofEpiOfIsIsoOfMono φ h) where left := LeftHomologyMapData.ofEpiOfIsIsoOfMono φ h.left right := RightHomologyMapData.ofEpiOfIsIsoOfMono φ h.right /-- This homology map data expresses compatibilities of the homology data constructed by `HomologyData.ofEpiOfIsIsoOfMono'` -/ noncomputable def ofEpiOfIsIsoOfMono' (φ : S₁ ⟶ S₂) (h : HomologyData S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HomologyMapData φ (HomologyData.ofEpiOfIsIsoOfMono' φ h) h where left := LeftHomologyMapData.ofEpiOfIsIsoOfMono' φ h.left right := RightHomologyMapData.ofEpiOfIsIsoOfMono' φ h.right end HomologyMapData variable (S) /-- The homology of a short complex is the `left.H` field of a chosen homology data. -/ noncomputable def homology [HasHomology S] : C := S.homologyData.left.H /-- When a short complex has homology, this is the canonical isomorphism `S.leftHomology ≅ S.homology`. -/ noncomputable def leftHomologyIso [S.HasHomology] : S.leftHomology ≅ S.homology := leftHomologyMapIso' (Iso.refl _) _ _ /-- When a short complex has homology, this is the canonical isomorphism `S.rightHomology ≅ S.homology`. -/ noncomputable def rightHomologyIso [S.HasHomology] : S.rightHomology ≅ S.homology := rightHomologyMapIso' (Iso.refl _) _ _ ≪≫ S.homologyData.iso.symm variable {S} /-- When a short complex has homology, its homology can be computed using any left homology data. -/ noncomputable def LeftHomologyData.homologyIso (h : S.LeftHomologyData) [S.HasHomology] : S.homology ≅ h.H := S.leftHomologyIso.symm ≪≫ h.leftHomologyIso /-- When a short complex has homology, its homology can be computed using any right homology data. -/ noncomputable def RightHomologyData.homologyIso (h : S.RightHomologyData) [S.HasHomology] : S.homology ≅ h.H := S.rightHomologyIso.symm ≪≫ h.rightHomologyIso variable (S) @[simp] lemma LeftHomologyData.homologyIso_leftHomologyData [S.HasHomology] : S.leftHomologyData.homologyIso = S.leftHomologyIso.symm := by ext dsimp [homologyIso, leftHomologyIso, ShortComplex.leftHomologyIso] rw [← leftHomologyMap'_comp, comp_id] @[simp] lemma RightHomologyData.homologyIso_rightHomologyData [S.HasHomology] : S.rightHomologyData.homologyIso = S.rightHomologyIso.symm := by ext dsimp [homologyIso, rightHomologyIso] erw [rightHomologyMap'_id, comp_id] variable {S} /-- Given a morphism `φ : S₁ ⟶ S₂` of short complexes and homology data `h₁` and `h₂` for `S₁` and `S₂` respectively, this is the induced homology map `h₁.left.H ⟶ h₁.left.H`. -/ def homologyMap' (φ : S₁ ⟶ S₂) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) : h₁.left.H ⟶ h₂.left.H := leftHomologyMap' φ _ _ /-- The homology map `S₁.homology ⟶ S₂.homology` induced by a morphism `S₁ ⟶ S₂` of short complexes. -/ noncomputable def homologyMap (φ : S₁ ⟶ S₂) [HasHomology S₁] [HasHomology S₂] : S₁.homology ⟶ S₂.homology := homologyMap' φ _ _ namespace HomologyMapData variable {φ : S₁ ⟶ S₂} {h₁ : S₁.HomologyData} {h₂ : S₂.HomologyData} (γ : HomologyMapData φ h₁ h₂) lemma homologyMap'_eq : homologyMap' φ h₁ h₂ = γ.left.φH := LeftHomologyMapData.congr_φH (Subsingleton.elim _ _) lemma cyclesMap'_eq : cyclesMap' φ h₁.left h₂.left = γ.left.φK := LeftHomologyMapData.congr_φK (Subsingleton.elim _ _) lemma opcyclesMap'_eq : opcyclesMap' φ h₁.right h₂.right = γ.right.φQ := RightHomologyMapData.congr_φQ (Subsingleton.elim _ _) end HomologyMapData namespace LeftHomologyMapData variable {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} (γ : LeftHomologyMapData φ h₁ h₂) [S₁.HasHomology] [S₂.HasHomology] lemma homologyMap_eq : homologyMap φ = h₁.homologyIso.hom ≫ γ.φH ≫ h₂.homologyIso.inv := by dsimp [homologyMap, LeftHomologyData.homologyIso, leftHomologyIso, LeftHomologyData.leftHomologyIso, homologyMap'] simp only [← γ.leftHomologyMap'_eq, ← leftHomologyMap'_comp, id_comp, comp_id] lemma homologyMap_comm : homologyMap φ ≫ h₂.homologyIso.hom = h₁.homologyIso.hom ≫ γ.φH := by simp only [γ.homologyMap_eq, assoc, Iso.inv_hom_id, comp_id] end LeftHomologyMapData namespace RightHomologyMapData variable {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} (γ : RightHomologyMapData φ h₁ h₂) [S₁.HasHomology] [S₂.HasHomology] lemma homologyMap_eq : homologyMap φ = h₁.homologyIso.hom ≫ γ.φH ≫ h₂.homologyIso.inv := by dsimp [homologyMap, homologyMap', RightHomologyData.homologyIso, rightHomologyIso, RightHomologyData.rightHomologyIso] have γ' : HomologyMapData φ S₁.homologyData S₂.homologyData := default simp only [← γ.rightHomologyMap'_eq, assoc, ← rightHomologyMap'_comp_assoc, id_comp, comp_id, γ'.left.leftHomologyMap'_eq, γ'.right.rightHomologyMap'_eq, ← γ'.comm_assoc, Iso.hom_inv_id] lemma homologyMap_comm : homologyMap φ ≫ h₂.homologyIso.hom = h₁.homologyIso.hom ≫ γ.φH := by simp only [γ.homologyMap_eq, assoc, Iso.inv_hom_id, comp_id] end RightHomologyMapData @[simp] lemma homologyMap'_id (h : S.HomologyData) : homologyMap' (𝟙 S) h h = 𝟙 _ := (HomologyMapData.id h).homologyMap'_eq variable (S) @[simp] lemma homologyMap_id [HasHomology S] : homologyMap (𝟙 S) = 𝟙 _ := homologyMap'_id _ @[simp] lemma homologyMap'_zero (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) : homologyMap' 0 h₁ h₂ = 0 := (HomologyMapData.zero h₁ h₂).homologyMap'_eq variable (S₁ S₂) @[simp] lemma homologyMap_zero [S₁.HasHomology] [S₂.HasHomology] : homologyMap (0 : S₁ ⟶ S₂) = 0 := homologyMap'_zero _ _ variable {S₁ S₂} lemma homologyMap'_comp (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) (h₃ : S₃.HomologyData) : homologyMap' (φ₁ ≫ φ₂) h₁ h₃ = homologyMap' φ₁ h₁ h₂ ≫ homologyMap' φ₂ h₂ h₃ := leftHomologyMap'_comp _ _ _ _ _ @[simp] lemma homologyMap_comp [HasHomology S₁] [HasHomology S₂] [HasHomology S₃] (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) : homologyMap (φ₁ ≫ φ₂) = homologyMap φ₁ ≫ homologyMap φ₂ := homologyMap'_comp _ _ _ _ _ /-- Given an isomorphism `S₁ ≅ S₂` of short complexes and homology data `h₁` and `h₂` for `S₁` and `S₂` respectively, this is the induced homology isomorphism `h₁.left.H ≅ h₁.left.H`. -/ @[simps] def homologyMapIso' (e : S₁ ≅ S₂) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) : h₁.left.H ≅ h₂.left.H where hom := homologyMap' e.hom h₁ h₂ inv := homologyMap' e.inv h₂ h₁ hom_inv_id := by rw [← homologyMap'_comp, e.hom_inv_id, homologyMap'_id] inv_hom_id := by rw [← homologyMap'_comp, e.inv_hom_id, homologyMap'_id] instance isIso_homologyMap'_of_isIso (φ : S₁ ⟶ S₂) [IsIso φ] (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) : IsIso (homologyMap' φ h₁ h₂) := (inferInstance : IsIso (homologyMapIso' (asIso φ) h₁ h₂).hom) /-- The homology isomorphism `S₁.homology ⟶ S₂.homology` induced by an isomorphism `S₁ ≅ S₂` of short complexes. -/ @[simps] noncomputable def homologyMapIso (e : S₁ ≅ S₂) [S₁.HasHomology] [S₂.HasHomology] : S₁.homology ≅ S₂.homology where hom := homologyMap e.hom inv := homologyMap e.inv hom_inv_id := by rw [← homologyMap_comp, e.hom_inv_id, homologyMap_id] inv_hom_id := by rw [← homologyMap_comp, e.inv_hom_id, homologyMap_id] instance isIso_homologyMap_of_iso (φ : S₁ ⟶ S₂) [IsIso φ] [S₁.HasHomology] [S₂.HasHomology] : IsIso (homologyMap φ) := (inferInstance : IsIso (homologyMapIso (asIso φ)).hom) variable {S} section variable (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) /-- If a short complex `S` has both a left homology data `h₁` and a right homology data `h₂`, this is the canonical morphism `h₁.H ⟶ h₂.H`. -/ def leftRightHomologyComparison' : h₁.H ⟶ h₂.H := h₂.liftH (h₁.descH (h₁.i ≫ h₂.p) (by simp)) (by rw [← cancel_epi h₁.π, LeftHomologyData.π_descH_assoc, assoc, RightHomologyData.p_g', LeftHomologyData.wi, comp_zero]) lemma leftRightHomologyComparison'_eq_liftH : leftRightHomologyComparison' h₁ h₂ = h₂.liftH (h₁.descH (h₁.i ≫ h₂.p) (by simp)) (by rw [← cancel_epi h₁.π, LeftHomologyData.π_descH_assoc, assoc, RightHomologyData.p_g', LeftHomologyData.wi, comp_zero]) := rfl @[reassoc (attr := simp)] lemma π_leftRightHomologyComparison'_ι : h₁.π ≫ leftRightHomologyComparison' h₁ h₂ ≫ h₂.ι = h₁.i ≫ h₂.p := by simp only [leftRightHomologyComparison'_eq_liftH, RightHomologyData.liftH_ι, LeftHomologyData.π_descH] lemma leftRightHomologyComparison'_eq_descH : leftRightHomologyComparison' h₁ h₂ = h₁.descH (h₂.liftH (h₁.i ≫ h₂.p) (by simp)) (by rw [← cancel_mono h₂.ι, assoc, RightHomologyData.liftH_ι, LeftHomologyData.f'_i_assoc, RightHomologyData.wp, zero_comp]) := by simp only [← cancel_mono h₂.ι, ← cancel_epi h₁.π, π_leftRightHomologyComparison'_ι, LeftHomologyData.π_descH_assoc, RightHomologyData.liftH_ι] end variable (S) /-- If a short complex `S` has both a left and right homology, this is the canonical morphism `S.leftHomology ⟶ S.rightHomology`. -/ noncomputable def leftRightHomologyComparison [S.HasLeftHomology] [S.HasRightHomology] : S.leftHomology ⟶ S.rightHomology := leftRightHomologyComparison' _ _ @[reassoc (attr := simp)] lemma π_leftRightHomologyComparison_ι [S.HasLeftHomology] [S.HasRightHomology] : S.leftHomologyπ ≫ S.leftRightHomologyComparison ≫ S.rightHomologyι = S.iCycles ≫ S.pOpcycles := π_leftRightHomologyComparison'_ι _ _ @[reassoc] lemma leftRightHomologyComparison'_naturality (φ : S₁ ⟶ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₁.RightHomologyData) (h₁' : S₂.LeftHomologyData) (h₂' : S₂.RightHomologyData) : leftHomologyMap' φ h₁ h₁' ≫ leftRightHomologyComparison' h₁' h₂' = leftRightHomologyComparison' h₁ h₂ ≫ rightHomologyMap' φ h₂ h₂' := by simp only [← cancel_epi h₁.π, ← cancel_mono h₂'.ι, assoc, leftHomologyπ_naturality'_assoc, rightHomologyι_naturality', π_leftRightHomologyComparison'_ι, π_leftRightHomologyComparison'_ι_assoc, cyclesMap'_i_assoc, p_opcyclesMap'] variable {S} lemma leftRightHomologyComparison'_compatibility (h₁ h₁' : S.LeftHomologyData) (h₂ h₂' : S.RightHomologyData) : leftRightHomologyComparison' h₁ h₂ = leftHomologyMap' (𝟙 S) h₁ h₁' ≫ leftRightHomologyComparison' h₁' h₂' ≫ rightHomologyMap' (𝟙 S) _ _ := by rw [leftRightHomologyComparison'_naturality_assoc (𝟙 S) h₁ h₂ h₁' h₂', ← rightHomologyMap'_comp, comp_id, rightHomologyMap'_id, comp_id] lemma leftRightHomologyComparison_eq [S.HasLeftHomology] [S.HasRightHomology] (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) : S.leftRightHomologyComparison = h₁.leftHomologyIso.hom ≫ leftRightHomologyComparison' h₁ h₂ ≫ h₂.rightHomologyIso.inv := leftRightHomologyComparison'_compatibility _ _ _ _ @[simp] lemma HomologyData.leftRightHomologyComparison'_eq (h : S.HomologyData) : leftRightHomologyComparison' h.left h.right = h.iso.hom := by simp only [← cancel_epi h.left.π, ← cancel_mono h.right.ι, assoc, π_leftRightHomologyComparison'_ι, comm] instance isIso_leftRightHomologyComparison'_of_homologyData (h : S.HomologyData) : IsIso (leftRightHomologyComparison' h.left h.right) := by rw [h.leftRightHomologyComparison'_eq] infer_instance instance isIso_leftRightHomologyComparison' [S.HasHomology] (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) : IsIso (leftRightHomologyComparison' h₁ h₂) := by rw [leftRightHomologyComparison'_compatibility h₁ S.homologyData.left h₂ S.homologyData.right] infer_instance instance isIso_leftRightHomologyComparison [S.HasHomology] : IsIso S.leftRightHomologyComparison := by dsimp only [leftRightHomologyComparison] infer_instance namespace HomologyData /-- This is the homology data for a short complex `S` that is obtained from a left homology data `h₁` and a right homology data `h₂` when the comparison morphism `leftRightHomologyComparison' h₁ h₂ : h₁.H ⟶ h₂.H` is an isomorphism. -/ @[simps] noncomputable def ofIsIsoLeftRightHomologyComparison' (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) [IsIso (leftRightHomologyComparison' h₁ h₂)] : S.HomologyData where left := h₁ right := h₂ iso := asIso (leftRightHomologyComparison' h₁ h₂) end HomologyData lemma leftRightHomologyComparison'_eq_leftHomologpMap'_comp_iso_hom_comp_rightHomologyMap' (h : S.HomologyData) (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) : leftRightHomologyComparison' h₁ h₂ = leftHomologyMap' (𝟙 S) h₁ h.left ≫ h.iso.hom ≫ rightHomologyMap' (𝟙 S) h.right h₂ := by simpa only [h.leftRightHomologyComparison'_eq] using leftRightHomologyComparison'_compatibility h₁ h.left h₂ h.right @[reassoc] lemma leftRightHomologyComparison'_fac (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) [S.HasHomology] : leftRightHomologyComparison' h₁ h₂ = h₁.homologyIso.inv ≫ h₂.homologyIso.hom := by rw [leftRightHomologyComparison'_eq_leftHomologpMap'_comp_iso_hom_comp_rightHomologyMap' S.homologyData h₁ h₂] dsimp only [LeftHomologyData.homologyIso, LeftHomologyData.leftHomologyIso, Iso.symm, Iso.trans, Iso.refl, leftHomologyMapIso', leftHomologyIso, RightHomologyData.homologyIso, RightHomologyData.rightHomologyIso, rightHomologyMapIso', rightHomologyIso] simp only [assoc, ← leftHomologyMap'_comp_assoc, id_comp, ← rightHomologyMap'_comp] variable (S) @[reassoc] lemma leftRightHomologyComparison_fac [S.HasHomology] : S.leftRightHomologyComparison = S.leftHomologyIso.hom ≫ S.rightHomologyIso.inv := by simpa only [LeftHomologyData.homologyIso_leftHomologyData, Iso.symm_inv, RightHomologyData.homologyIso_rightHomologyData, Iso.symm_hom] using leftRightHomologyComparison'_fac S.leftHomologyData S.rightHomologyData variable {S} lemma HomologyData.right_homologyIso_eq_left_homologyIso_trans_iso (h : S.HomologyData) [S.HasHomology] : h.right.homologyIso = h.left.homologyIso ≪≫ h.iso := by suffices h.iso = h.left.homologyIso.symm ≪≫ h.right.homologyIso by rw [this, Iso.self_symm_id_assoc] ext dsimp rw [← leftRightHomologyComparison'_fac, leftRightHomologyComparison'_eq] lemma hasHomology_of_isIso_leftRightHomologyComparison' (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) [IsIso (leftRightHomologyComparison' h₁ h₂)] : S.HasHomology := HasHomology.mk' (HomologyData.ofIsIsoLeftRightHomologyComparison' h₁ h₂) lemma hasHomology_of_isIsoLeftRightHomologyComparison [S.HasLeftHomology] [S.HasRightHomology] [h : IsIso S.leftRightHomologyComparison] : S.HasHomology := by haveI : IsIso (leftRightHomologyComparison' S.leftHomologyData S.rightHomologyData) := h exact hasHomology_of_isIso_leftRightHomologyComparison' S.leftHomologyData S.rightHomologyData section variable [S₁.HasHomology] [S₂.HasHomology] (φ : S₁ ⟶ S₂) @[reassoc] lemma LeftHomologyData.leftHomologyIso_hom_naturality (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : h₁.homologyIso.hom ≫ leftHomologyMap' φ h₁ h₂ = homologyMap φ ≫ h₂.homologyIso.hom := by dsimp [homologyIso, ShortComplex.leftHomologyIso, homologyMap, homologyMap', leftHomologyIso] simp only [← leftHomologyMap'_comp, id_comp, comp_id] @[reassoc] lemma LeftHomologyData.leftHomologyIso_inv_naturality (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : h₁.homologyIso.inv ≫ homologyMap φ = leftHomologyMap' φ h₁ h₂ ≫ h₂.homologyIso.inv := by dsimp [homologyIso, ShortComplex.leftHomologyIso, homologyMap, homologyMap', leftHomologyIso] simp only [← leftHomologyMap'_comp, id_comp, comp_id] @[reassoc] lemma leftHomologyIso_hom_naturality : S₁.leftHomologyIso.hom ≫ homologyMap φ = leftHomologyMap φ ≫ S₂.leftHomologyIso.hom := by simpa only [LeftHomologyData.homologyIso_leftHomologyData, Iso.symm_inv] using LeftHomologyData.leftHomologyIso_inv_naturality φ S₁.leftHomologyData S₂.leftHomologyData @[reassoc] lemma leftHomologyIso_inv_naturality : S₁.leftHomologyIso.inv ≫ leftHomologyMap φ = homologyMap φ ≫ S₂.leftHomologyIso.inv := by simpa only [LeftHomologyData.homologyIso_leftHomologyData, Iso.symm_inv] using LeftHomologyData.leftHomologyIso_hom_naturality φ S₁.leftHomologyData S₂.leftHomologyData @[reassoc] lemma RightHomologyData.rightHomologyIso_hom_naturality (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : h₁.homologyIso.hom ≫ rightHomologyMap' φ h₁ h₂ = homologyMap φ ≫ h₂.homologyIso.hom := by rw [← cancel_epi h₁.homologyIso.inv, Iso.inv_hom_id_assoc, ← cancel_epi (leftRightHomologyComparison' S₁.leftHomologyData h₁), ← leftRightHomologyComparison'_naturality φ S₁.leftHomologyData h₁ S₂.leftHomologyData h₂, ← cancel_epi (S₁.leftHomologyData.homologyIso.hom), LeftHomologyData.leftHomologyIso_hom_naturality_assoc, leftRightHomologyComparison'_fac, leftRightHomologyComparison'_fac, assoc, Iso.hom_inv_id_assoc, Iso.hom_inv_id_assoc, Iso.hom_inv_id_assoc] @[reassoc] lemma RightHomologyData.rightHomologyIso_inv_naturality (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : h₁.homologyIso.inv ≫ homologyMap φ = rightHomologyMap' φ h₁ h₂ ≫ h₂.homologyIso.inv := by simp only [← cancel_mono h₂.homologyIso.hom, assoc, Iso.inv_hom_id_assoc, comp_id, ← RightHomologyData.rightHomologyIso_hom_naturality φ h₁ h₂, Iso.inv_hom_id] @[reassoc] lemma rightHomologyIso_hom_naturality : S₁.rightHomologyIso.hom ≫ homologyMap φ = rightHomologyMap φ ≫ S₂.rightHomologyIso.hom := by simpa only [RightHomologyData.homologyIso_rightHomologyData, Iso.symm_inv] using RightHomologyData.rightHomologyIso_inv_naturality φ S₁.rightHomologyData S₂.rightHomologyData @[reassoc] lemma rightHomologyIso_inv_naturality : S₁.rightHomologyIso.inv ≫ rightHomologyMap φ = homologyMap φ ≫ S₂.rightHomologyIso.inv := by simpa only [RightHomologyData.homologyIso_rightHomologyData, Iso.symm_inv] using RightHomologyData.rightHomologyIso_hom_naturality φ S₁.rightHomologyData S₂.rightHomologyData end variable (C) /-- We shall say that a category `C` is a category with homology when all short complexes have homology. -/ class _root_.CategoryTheory.CategoryWithHomology : Prop where hasHomology : ∀ (S : ShortComplex C), S.HasHomology attribute [instance] CategoryWithHomology.hasHomology instance [CategoryWithHomology C] : CategoryWithHomology Cᵒᵖ := ⟨fun S => HasHomology.mk' S.unop.homologyData.op⟩ /-- The homology functor `ShortComplex C ⥤ C` for a category `C` with homology. -/ @[simps] noncomputable def homologyFunctor [CategoryWithHomology C] : ShortComplex C ⥤ C where obj S := S.homology map f := homologyMap f variable {C} instance isIso_homologyMap'_of_epi_of_isIso_of_mono (φ : S₁ ⟶ S₂) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : IsIso (homologyMap' φ h₁ h₂) := by dsimp only [homologyMap'] infer_instance lemma isIso_homologyMap_of_epi_of_isIso_of_mono' (φ : S₁ ⟶ S₂) [S₁.HasHomology] [S₂.HasHomology] (h₁ : Epi φ.τ₁) (h₂ : IsIso φ.τ₂) (h₃ : Mono φ.τ₃) : IsIso (homologyMap φ) := by dsimp only [homologyMap] infer_instance instance isIso_homologyMap_of_epi_of_isIso_of_mono (φ : S₁ ⟶ S₂) [S₁.HasHomology] [S₂.HasHomology] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : IsIso (homologyMap φ) := isIso_homologyMap_of_epi_of_isIso_of_mono' φ inferInstance inferInstance inferInstance instance isIso_homologyFunctor_map_of_epi_of_isIso_of_mono (φ : S₁ ⟶ S₂) [CategoryWithHomology C] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : IsIso ((homologyFunctor C).map φ) := (inferInstance : IsIso (homologyMap φ)) instance isIso_homologyMap_of_isIso (φ : S₁ ⟶ S₂) [S₁.HasHomology] [S₂.HasHomology] [IsIso φ] : IsIso (homologyMap φ) := by dsimp only [homologyMap, homologyMap'] infer_instance section variable (S) {A : C} variable [HasHomology S] /-- The canonical morphism `S.cycles ⟶ S.homology` for a short complex `S` that has homology. -/ noncomputable def homologyπ : S.cycles ⟶ S.homology := S.leftHomologyπ ≫ S.leftHomologyIso.hom /-- The canonical morphism `S.homology ⟶ S.opcycles` for a short complex `S` that has homology. -/ noncomputable def homologyι : S.homology ⟶ S.opcycles := S.rightHomologyIso.inv ≫ S.rightHomologyι @[reassoc (attr := simp)] lemma homologyπ_comp_leftHomologyIso_inv : S.homologyπ ≫ S.leftHomologyIso.inv = S.leftHomologyπ := by dsimp only [homologyπ] simp only [assoc, Iso.hom_inv_id, comp_id] @[reassoc (attr := simp)] lemma rightHomologyIso_hom_comp_homologyι : S.rightHomologyIso.hom ≫ S.homologyι = S.rightHomologyι := by dsimp only [homologyι] simp only [Iso.hom_inv_id_assoc] @[reassoc (attr := simp)] lemma toCycles_comp_homologyπ : S.toCycles ≫ S.homologyπ = 0 := by dsimp only [homologyπ] simp only [toCycles_comp_leftHomologyπ_assoc, zero_comp] @[reassoc (attr := simp)] lemma homologyι_comp_fromOpcycles : S.homologyι ≫ S.fromOpcycles = 0 := by dsimp only [homologyι] simp only [assoc, rightHomologyι_comp_fromOpcycles, comp_zero] /-- The homology `S.homology` of a short complex is the cokernel of the morphism `S.toCycles : S.X₁ ⟶ S.cycles`. -/ noncomputable def homologyIsCokernel : IsColimit (CokernelCofork.ofπ S.homologyπ S.toCycles_comp_homologyπ) := IsColimit.ofIsoColimit S.leftHomologyIsCokernel (Cofork.ext S.leftHomologyIso rfl) /-- The homology `S.homology` of a short complex is the kernel of the morphism `S.fromOpcycles : S.opcycles ⟶ S.X₃`. -/ noncomputable def homologyIsKernel : IsLimit (KernelFork.ofι S.homologyι S.homologyι_comp_fromOpcycles) := IsLimit.ofIsoLimit S.rightHomologyIsKernel (Fork.ext S.rightHomologyIso (by simp)) instance : Epi S.homologyπ := Limits.epi_of_isColimit_cofork (S.homologyIsCokernel) instance : Mono S.homologyι := Limits.mono_of_isLimit_fork (S.homologyIsKernel) /-- Given a morphism `k : S.cycles ⟶ A` such that `S.toCycles ≫ k = 0`, this is the induced morphism `S.homology ⟶ A`. -/ noncomputable def descHomology (k : S.cycles ⟶ A) (hk : S.toCycles ≫ k = 0) : S.homology ⟶ A := S.homologyIsCokernel.desc (CokernelCofork.ofπ k hk) /-- Given a morphism `k : A ⟶ S.opcycles` such that `k ≫ S.fromOpcycles = 0`, this is the induced morphism `A ⟶ S.homology`. -/ noncomputable def liftHomology (k : A ⟶ S.opcycles) (hk : k ≫ S.fromOpcycles = 0) : A ⟶ S.homology := S.homologyIsKernel.lift (KernelFork.ofι k hk) @[reassoc (attr := simp)] lemma π_descHomology (k : S.cycles ⟶ A) (hk : S.toCycles ≫ k = 0) : S.homologyπ ≫ S.descHomology k hk = k := Cofork.IsColimit.π_desc S.homologyIsCokernel @[reassoc (attr := simp)] lemma liftHomology_ι (k : A ⟶ S.opcycles) (hk : k ≫ S.fromOpcycles = 0) : S.liftHomology k hk ≫ S.homologyι = k := Fork.IsLimit.lift_ι S.homologyIsKernel @[reassoc (attr := simp)] lemma homologyπ_naturality (φ : S₁ ⟶ S₂) [S₁.HasHomology] [S₂.HasHomology] : S₁.homologyπ ≫ homologyMap φ = cyclesMap φ ≫ S₂.homologyπ := by simp only [← cancel_mono S₂.leftHomologyIso.inv, assoc, ← leftHomologyIso_inv_naturality φ, homologyπ_comp_leftHomologyIso_inv] simp only [homologyπ, assoc, Iso.hom_inv_id_assoc, leftHomologyπ_naturality] @[reassoc (attr := simp)] lemma homologyι_naturality (φ : S₁ ⟶ S₂) [S₁.HasHomology] [S₂.HasHomology] : homologyMap φ ≫ S₂.homologyι = S₁.homologyι ≫ S₁.opcyclesMap φ := by simp only [← cancel_epi S₁.rightHomologyIso.hom, rightHomologyIso_hom_naturality_assoc φ, rightHomologyIso_hom_comp_homologyι, rightHomologyι_naturality] simp only [homologyι, assoc, Iso.hom_inv_id_assoc] @[reassoc (attr := simp)] lemma homology_π_ι : S.homologyπ ≫ S.homologyι = S.iCycles ≫ S.pOpcycles := by dsimp only [homologyπ, homologyι] simpa only [assoc, S.leftRightHomologyComparison_fac] using S.π_leftRightHomologyComparison_ι /-- The homology of a short complex `S` identifies to the kernel of the induced morphism `cokernel S.f ⟶ S.X₃`. -/ noncomputable def homologyIsoKernelDesc [HasCokernel S.f] [HasKernel (cokernel.desc S.f S.g S.zero)] : S.homology ≅ kernel (cokernel.desc S.f S.g S.zero) := S.rightHomologyIso.symm ≪≫ S.rightHomologyIsoKernelDesc /-- The homology of a short complex `S` identifies to the cokernel of the induced morphism `S.X₁ ⟶ kernel S.g`. -/ noncomputable def homologyIsoCokernelLift [HasKernel S.g] [HasCokernel (kernel.lift S.g S.f S.zero)] : S.homology ≅ cokernel (kernel.lift S.g S.f S.zero) := S.leftHomologyIso.symm ≪≫ S.leftHomologyIsoCokernelLift @[reassoc (attr := simp)] lemma LeftHomologyData.homologyπ_comp_homologyIso_hom (h : S.LeftHomologyData) : S.homologyπ ≫ h.homologyIso.hom = h.cyclesIso.hom ≫ h.π := by dsimp only [homologyπ, homologyIso] simp only [Iso.trans_hom, Iso.symm_hom, assoc, Iso.hom_inv_id_assoc, leftHomologyπ_comp_leftHomologyIso_hom] @[reassoc (attr := simp)] lemma LeftHomologyData.π_comp_homologyIso_inv (h : S.LeftHomologyData) : h.π ≫ h.homologyIso.inv = h.cyclesIso.inv ≫ S.homologyπ := by dsimp only [homologyπ, homologyIso] simp only [Iso.trans_inv, Iso.symm_inv, π_comp_leftHomologyIso_inv_assoc] @[reassoc (attr := simp)] lemma RightHomologyData.homologyIso_inv_comp_homologyι (h : S.RightHomologyData) : h.homologyIso.inv ≫ S.homologyι = h.ι ≫ h.opcyclesIso.inv := by dsimp only [homologyι, homologyIso] simp only [Iso.trans_inv, Iso.symm_inv, assoc, Iso.hom_inv_id_assoc, rightHomologyIso_inv_comp_rightHomologyι] @[reassoc (attr := simp)] lemma RightHomologyData.homologyIso_hom_comp_ι (h : S.RightHomologyData) : h.homologyIso.hom ≫ h.ι = S.homologyι ≫ h.opcyclesIso.hom := by dsimp only [homologyι, homologyIso] simp only [Iso.trans_hom, Iso.symm_hom, assoc, rightHomologyIso_hom_comp_ι] @[reassoc (attr := simp)] lemma LeftHomologyData.homologyIso_hom_comp_leftHomologyIso_inv (h : S.LeftHomologyData) : h.homologyIso.hom ≫ h.leftHomologyIso.inv = S.leftHomologyIso.inv := by dsimp only [homologyIso] simp only [Iso.trans_hom, Iso.symm_hom, assoc, Iso.hom_inv_id, comp_id] @[reassoc (attr := simp)] lemma LeftHomologyData.leftHomologyIso_hom_comp_homologyIso_inv (h : S.LeftHomologyData) : h.leftHomologyIso.hom ≫ h.homologyIso.inv = S.leftHomologyIso.hom := by dsimp only [homologyIso] simp only [Iso.trans_inv, Iso.symm_inv, Iso.hom_inv_id_assoc] @[reassoc (attr := simp)] lemma RightHomologyData.homologyIso_hom_comp_rightHomologyIso_inv (h : S.RightHomologyData) : h.homologyIso.hom ≫ h.rightHomologyIso.inv = S.rightHomologyIso.inv := by dsimp only [homologyIso] simp only [Iso.trans_hom, Iso.symm_hom, assoc, Iso.hom_inv_id, comp_id] @[reassoc (attr := simp)] lemma RightHomologyData.rightHomologyIso_hom_comp_homologyIso_inv (h : S.RightHomologyData) : h.rightHomologyIso.hom ≫ h.homologyIso.inv = S.rightHomologyIso.hom := by dsimp only [homologyIso] simp only [Iso.trans_inv, Iso.symm_inv, Iso.hom_inv_id_assoc] @[reassoc] lemma comp_homologyMap_comp [S₁.HasHomology] [S₂.HasHomology] (φ : S₁ ⟶ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.RightHomologyData) : h₁.π ≫ h₁.homologyIso.inv ≫ homologyMap φ ≫ h₂.homologyIso.hom ≫ h₂.ι = h₁.i ≫ φ.τ₂ ≫ h₂.p := by dsimp only [LeftHomologyData.homologyIso, RightHomologyData.homologyIso, Iso.symm, Iso.trans, Iso.refl, leftHomologyIso, rightHomologyIso, leftHomologyMapIso', rightHomologyMapIso', LeftHomologyData.cyclesIso, RightHomologyData.opcyclesIso, LeftHomologyData.leftHomologyIso, RightHomologyData.rightHomologyIso, homologyMap, homologyMap'] simp only [assoc, rightHomologyι_naturality', rightHomologyι_naturality'_assoc, leftHomologyπ_naturality'_assoc, HomologyData.comm_assoc, p_opcyclesMap'_assoc, id_τ₂, p_opcyclesMap', id_comp, cyclesMap'_i_assoc] @[reassoc] lemma π_homologyMap_ι [S₁.HasHomology] [S₂.HasHomology] (φ : S₁ ⟶ S₂) : S₁.homologyπ ≫ homologyMap φ ≫ S₂.homologyι = S₁.iCycles ≫ φ.τ₂ ≫ S₂.pOpcycles := by simp only [homologyι_naturality, homology_π_ι_assoc, p_opcyclesMap] end variable (S) /-- The canonical isomorphism `S.op.homology ≅ Opposite.op S.homology` when a short complex `S` has homology. -/ noncomputable def homologyOpIso [S.HasHomology] : S.op.homology ≅ Opposite.op S.homology := S.op.leftHomologyIso.symm ≪≫ S.leftHomologyOpIso ≪≫ S.rightHomologyIso.symm.op lemma homologyMap'_op : (homologyMap' φ h₁ h₂).op = h₂.iso.inv.op ≫ homologyMap' (opMap φ) h₂.op h₁.op ≫ h₁.iso.hom.op := Quiver.Hom.unop_inj (by dsimp have γ : HomologyMapData φ h₁ h₂ := default simp only [γ.homologyMap'_eq, γ.op.homologyMap'_eq, HomologyData.op_left, HomologyMapData.op_left, RightHomologyMapData.op_φH, Quiver.Hom.unop_op, assoc, ← γ.comm_assoc, Iso.hom_inv_id, comp_id]) lemma homologyMap_op [HasHomology S₁] [HasHomology S₂] : (homologyMap φ).op = (S₂.homologyOpIso).inv ≫ homologyMap (opMap φ) ≫ (S₁.homologyOpIso).hom := by dsimp only [homologyMap, homologyOpIso] rw [homologyMap'_op] dsimp only [Iso.symm, Iso.trans, Iso.op, Iso.refl, rightHomologyIso, leftHomologyIso, leftHomologyOpIso, leftHomologyMapIso', rightHomologyMapIso', LeftHomologyData.leftHomologyIso, homologyMap'] simp only [assoc, rightHomologyMap'_op, op_comp, ← leftHomologyMap'_comp_assoc, id_comp, opMap_id, comp_id, HomologyData.op_left] variable (C) /-- The natural isomorphism `(homologyFunctor C).op ≅ opFunctor C ⋙ homologyFunctor Cᵒᵖ` which relates the homology in `C` and in `Cᵒᵖ`. -/ noncomputable def homologyFunctorOpNatIso [CategoryWithHomology C] : (homologyFunctor C).op ≅ opFunctor C ⋙ homologyFunctor Cᵒᵖ := NatIso.ofComponents (fun S => S.unop.homologyOpIso.symm) (by simp [homologyMap_op]) variable {C} {A : C} lemma liftCycles_homologyπ_eq_zero_of_boundary [S.HasHomology] (k : A ⟶ S.X₂) (x : A ⟶ S.X₁) (hx : k = x ≫ S.f) : S.liftCycles k (by rw [hx, assoc, S.zero, comp_zero]) ≫ S.homologyπ = 0 := by dsimp only [homologyπ] rw [S.liftCycles_leftHomologyπ_eq_zero_of_boundary_assoc k x hx, zero_comp] @[reassoc] lemma homologyι_descOpcycles_eq_zero_of_boundary [S.HasHomology] (k : S.X₂ ⟶ A) (x : S.X₃ ⟶ A) (hx : k = S.g ≫ x) : S.homologyι ≫ S.descOpcycles k (by rw [hx, S.zero_assoc, zero_comp]) = 0 := by dsimp only [homologyι] rw [assoc, S.rightHomologyι_descOpcycles_π_eq_zero_of_boundary k x hx, comp_zero] lemma isIso_homologyMap_of_isIso_cyclesMap_of_epi {φ : S₁ ⟶ S₂} [S₁.HasHomology] [S₂.HasHomology] (h₁ : IsIso (cyclesMap φ)) (h₂ : Epi φ.τ₁) : IsIso (homologyMap φ) := by have h : S₂.toCycles ≫ inv (cyclesMap φ) ≫ S₁.homologyπ = 0 := by simp only [← cancel_epi φ.τ₁, ← toCycles_naturality_assoc, IsIso.hom_inv_id_assoc, toCycles_comp_homologyπ, comp_zero] have ⟨z, hz⟩ := CokernelCofork.IsColimit.desc' S₂.homologyIsCokernel _ h dsimp at hz refine ⟨⟨z, ?_, ?_⟩⟩ · rw [← cancel_epi S₁.homologyπ, homologyπ_naturality_assoc, hz, IsIso.hom_inv_id_assoc, comp_id] · rw [← cancel_epi S₂.homologyπ, reassoc_of% hz, homologyπ_naturality, IsIso.inv_hom_id_assoc, comp_id] lemma isIso_homologyMap_of_isIso_opcyclesMap_of_mono {φ : S₁ ⟶ S₂} [S₁.HasHomology] [S₂.HasHomology] (h₁ : IsIso (opcyclesMap φ)) (h₂ : Mono φ.τ₃) : IsIso (homologyMap φ) := by have h : (S₂.homologyι ≫ inv (opcyclesMap φ)) ≫ S₁.fromOpcycles = 0 := by simp only [← cancel_mono φ.τ₃, zero_comp, assoc, ← fromOpcycles_naturality, IsIso.inv_hom_id_assoc, homologyι_comp_fromOpcycles] have ⟨z, hz⟩ := KernelFork.IsLimit.lift' S₁.homologyIsKernel _ h dsimp at hz refine ⟨⟨z, ?_, ?_⟩⟩ · rw [← cancel_mono S₁.homologyι, id_comp, assoc, hz, homologyι_naturality_assoc, IsIso.hom_inv_id, comp_id] · rw [← cancel_mono S₂.homologyι, assoc, homologyι_naturality, reassoc_of% hz, IsIso.inv_hom_id, comp_id, id_comp] lemma isZero_homology_of_isZero_X₂ (hS : IsZero S.X₂) [S.HasHomology] : IsZero S.homology := IsZero.of_iso hS (HomologyData.ofZeros S (hS.eq_of_tgt _ _) (hS.eq_of_src _ _)).left.homologyIso lemma isIso_homologyπ (hf : S.f = 0) [S.HasHomology] : IsIso S.homologyπ := by have := S.isIso_leftHomologyπ hf dsimp only [homologyπ] infer_instance lemma isIso_homologyι (hg : S.g = 0) [S.HasHomology] : IsIso S.homologyι := by have := S.isIso_rightHomologyι hg dsimp only [homologyι] infer_instance /-- The canonical isomorphism `S.cycles ≅ S.homology` when `S.f = 0`. -/ @[simps! hom] noncomputable def asIsoHomologyπ (hf : S.f = 0) [S.HasHomology] : S.cycles ≅ S.homology := by have := S.isIso_homologyπ hf exact asIso S.homologyπ @[reassoc (attr := simp)] lemma asIsoHomologyπ_inv_comp_homologyπ (hf : S.f = 0) [S.HasHomology] : (S.asIsoHomologyπ hf).inv ≫ S.homologyπ = 𝟙 _ := Iso.inv_hom_id _ @[reassoc (attr := simp)] lemma homologyπ_comp_asIsoHomologyπ_inv (hf : S.f = 0) [S.HasHomology] : S.homologyπ ≫ (S.asIsoHomologyπ hf).inv = 𝟙 _ := (S.asIsoHomologyπ hf).hom_inv_id /-- The canonical isomorphism `S.homology ≅ S.opcycles` when `S.g = 0`. -/ @[simps! hom] noncomputable def asIsoHomologyι (hg : S.g = 0) [S.HasHomology] : S.homology ≅ S.opcycles := by have := S.isIso_homologyι hg exact asIso S.homologyι @[reassoc (attr := simp)] lemma asIsoHomologyι_inv_comp_homologyι (hg : S.g = 0) [S.HasHomology] : (S.asIsoHomologyι hg).inv ≫ S.homologyι = 𝟙 _ := Iso.inv_hom_id _ @[reassoc (attr := simp)] lemma homologyι_comp_asIsoHomologyι_inv (hg : S.g = 0) [S.HasHomology] : S.homologyι ≫ (S.asIsoHomologyι hg).inv = 𝟙 _ := (S.asIsoHomologyι hg).hom_inv_id lemma mono_homologyMap_of_mono_opcyclesMap' [S₁.HasHomology] [S₂.HasHomology] (h : Mono (opcyclesMap φ)) : Mono (homologyMap φ) := by have : Mono (homologyMap φ ≫ S₂.homologyι) := by rw [homologyι_naturality φ] apply mono_comp exact mono_of_mono (homologyMap φ) S₂.homologyι instance mono_homologyMap_of_mono_opcyclesMap [S₁.HasHomology] [S₂.HasHomology] [Mono (opcyclesMap φ)] : Mono (homologyMap φ) := mono_homologyMap_of_mono_opcyclesMap' φ inferInstance lemma epi_homologyMap_of_epi_cyclesMap' [S₁.HasHomology] [S₂.HasHomology] (h : Epi (cyclesMap φ)) : Epi (homologyMap φ) := by have : Epi (S₁.homologyπ ≫ homologyMap φ) := by rw [homologyπ_naturality φ] apply epi_comp exact epi_of_epi S₁.homologyπ (homologyMap φ) instance epi_homologyMap_of_epi_cyclesMap [S₁.HasHomology] [S₂.HasHomology] [Epi (cyclesMap φ)] : Epi (homologyMap φ) := epi_homologyMap_of_epi_cyclesMap' φ inferInstance end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\LeftHomology.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.Basic import Mathlib.CategoryTheory.Limits.Shapes.Kernels /-! # Left Homology of short complexes Given a short complex `S : ShortComplex C`, which consists of two composable maps `f : X₁ ⟶ X₂` and `g : X₂ ⟶ X₃` such that `f ≫ g = 0`, we shall define here the "left homology" `S.leftHomology` of `S`. For this, we introduce the notion of "left homology data". Such an `h : S.LeftHomologyData` consists of the data of morphisms `i : K ⟶ X₂` and `π : K ⟶ H` such that `i` identifies `K` with the kernel of `g : X₂ ⟶ X₃`, and that `π` identifies `H` with the cokernel of the induced map `f' : X₁ ⟶ K`. When such a `S.LeftHomologyData` exists, we shall say that `[S.HasLeftHomology]` and we define `S.leftHomology` to be the `H` field of a chosen left homology data. Similarly, we define `S.cycles` to be the `K` field. The dual notion is defined in `RightHomologyData.lean`. In `Homology.lean`, when `S` has two compatible left and right homology data (i.e. they give the same `H` up to a canonical isomorphism), we shall define `[S.HasHomology]` and `S.homology`. -/ namespace CategoryTheory open Category Limits namespace ShortComplex variable {C : Type*} [Category C] [HasZeroMorphisms C] (S : ShortComplex C) {S₁ S₂ S₃ : ShortComplex C} /-- A left homology data for a short complex `S` consists of morphisms `i : K ⟶ S.X₂` and `π : K ⟶ H` such that `i` identifies `K` to the kernel of `g : S.X₂ ⟶ S.X₃`, and that `π` identifies `H` to the cokernel of the induced map `f' : S.X₁ ⟶ K` -/ structure LeftHomologyData where /-- a choice of kernel of `S.g : S.X₂ ⟶ S.X₃`-/ K : C /-- a choice of cokernel of the induced morphism `S.f' : S.X₁ ⟶ K`-/ H : C /-- the inclusion of cycles in `S.X₂` -/ i : K ⟶ S.X₂ /-- the projection from cycles to the (left) homology -/ π : K ⟶ H /-- the kernel condition for `i` -/ wi : i ≫ S.g = 0 /-- `i : K ⟶ S.X₂` is a kernel of `g : S.X₂ ⟶ S.X₃` -/ hi : IsLimit (KernelFork.ofι i wi) /-- the cokernel condition for `π` -/ wπ : hi.lift (KernelFork.ofι _ S.zero) ≫ π = 0 /-- `π : K ⟶ H` is a cokernel of the induced morphism `S.f' : S.X₁ ⟶ K` -/ hπ : IsColimit (CokernelCofork.ofπ π wπ) initialize_simps_projections LeftHomologyData (-hi, -hπ) namespace LeftHomologyData /-- The chosen kernels and cokernels of the limits API give a `LeftHomologyData` -/ @[simps] noncomputable def ofHasKernelOfHasCokernel [HasKernel S.g] [HasCokernel (kernel.lift S.g S.f S.zero)] : S.LeftHomologyData where K := kernel S.g H := cokernel (kernel.lift S.g S.f S.zero) i := kernel.ι _ π := cokernel.π _ wi := kernel.condition _ hi := kernelIsKernel _ wπ := cokernel.condition _ hπ := cokernelIsCokernel _ attribute [reassoc (attr := simp)] wi wπ variable {S} variable (h : S.LeftHomologyData) {A : C} instance : Mono h.i := ⟨fun _ _ => Fork.IsLimit.hom_ext h.hi⟩ instance : Epi h.π := ⟨fun _ _ => Cofork.IsColimit.hom_ext h.hπ⟩ /-- Any morphism `k : A ⟶ S.X₂` that is a cycle (i.e. `k ≫ S.g = 0`) lifts to a morphism `A ⟶ K` -/ def liftK (k : A ⟶ S.X₂) (hk : k ≫ S.g = 0) : A ⟶ h.K := h.hi.lift (KernelFork.ofι k hk) @[reassoc (attr := simp)] lemma liftK_i (k : A ⟶ S.X₂) (hk : k ≫ S.g = 0) : h.liftK k hk ≫ h.i = k := h.hi.fac _ WalkingParallelPair.zero /-- The (left) homology class `A ⟶ H` attached to a cycle `k : A ⟶ S.X₂` -/ @[simp] def liftH (k : A ⟶ S.X₂) (hk : k ≫ S.g = 0) : A ⟶ h.H := h.liftK k hk ≫ h.π /-- Given `h : LeftHomologyData S`, this is morphism `S.X₁ ⟶ h.K` induced by `S.f : S.X₁ ⟶ S.X₂` and the fact that `h.K` is a kernel of `S.g : S.X₂ ⟶ S.X₃`. -/ def f' : S.X₁ ⟶ h.K := h.liftK S.f S.zero @[reassoc (attr := simp)] lemma f'_i : h.f' ≫ h.i = S.f := liftK_i _ _ _ @[reassoc (attr := simp)] lemma f'_π : h.f' ≫ h.π = 0 := h.wπ @[reassoc] lemma liftK_π_eq_zero_of_boundary (k : A ⟶ S.X₂) (x : A ⟶ S.X₁) (hx : k = x ≫ S.f) : h.liftK k (by rw [hx, assoc, S.zero, comp_zero]) ≫ h.π = 0 := by rw [show 0 = (x ≫ h.f') ≫ h.π by simp] congr 1 simp only [← cancel_mono h.i, hx, liftK_i, assoc, f'_i] /-- For `h : S.LeftHomologyData`, this is a restatement of `h.hπ`, saying that `π : h.K ⟶ h.H` is a cokernel of `h.f' : S.X₁ ⟶ h.K`. -/ def hπ' : IsColimit (CokernelCofork.ofπ h.π h.f'_π) := h.hπ /-- The morphism `H ⟶ A` induced by a morphism `k : K ⟶ A` such that `f' ≫ k = 0` -/ def descH (k : h.K ⟶ A) (hk : h.f' ≫ k = 0) : h.H ⟶ A := h.hπ.desc (CokernelCofork.ofπ k hk) @[reassoc (attr := simp)] lemma π_descH (k : h.K ⟶ A) (hk : h.f' ≫ k = 0) : h.π ≫ h.descH k hk = k := h.hπ.fac (CokernelCofork.ofπ k hk) WalkingParallelPair.one lemma isIso_i (hg : S.g = 0) : IsIso h.i := ⟨h.liftK (𝟙 S.X₂) (by rw [hg, id_comp]), by simp only [← cancel_mono h.i, id_comp, assoc, liftK_i, comp_id], liftK_i _ _ _⟩ lemma isIso_π (hf : S.f = 0) : IsIso h.π := by have ⟨φ, hφ⟩ := CokernelCofork.IsColimit.desc' h.hπ' (𝟙 _) (by rw [← cancel_mono h.i, comp_id, f'_i, zero_comp, hf]) dsimp at hφ exact ⟨φ, hφ, by rw [← cancel_epi h.π, reassoc_of% hφ, comp_id]⟩ variable (S) /-- When the second map `S.g` is zero, this is the left homology data on `S` given by any colimit cokernel cofork of `S.f` -/ @[simps] def ofIsColimitCokernelCofork (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : S.LeftHomologyData where K := S.X₂ H := c.pt i := 𝟙 _ π := c.π wi := by rw [id_comp, hg] hi := KernelFork.IsLimit.ofId _ hg wπ := CokernelCofork.condition _ hπ := IsColimit.ofIsoColimit hc (Cofork.ext (Iso.refl _)) @[simp] lemma ofIsColimitCokernelCofork_f' (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : (ofIsColimitCokernelCofork S hg c hc).f' = S.f := by rw [← cancel_mono (ofIsColimitCokernelCofork S hg c hc).i, f'_i, ofIsColimitCokernelCofork_i] dsimp rw [comp_id] /-- When the second map `S.g` is zero, this is the left homology data on `S` given by the chosen `cokernel S.f` -/ @[simps!] noncomputable def ofHasCokernel [HasCokernel S.f] (hg : S.g = 0) : S.LeftHomologyData := ofIsColimitCokernelCofork S hg _ (cokernelIsCokernel _) /-- When the first map `S.f` is zero, this is the left homology data on `S` given by any limit kernel fork of `S.g` -/ @[simps] def ofIsLimitKernelFork (hf : S.f = 0) (c : KernelFork S.g) (hc : IsLimit c) : S.LeftHomologyData where K := c.pt H := c.pt i := c.ι π := 𝟙 _ wi := KernelFork.condition _ hi := IsLimit.ofIsoLimit hc (Fork.ext (Iso.refl _)) wπ := Fork.IsLimit.hom_ext hc (by dsimp simp only [comp_id, zero_comp, Fork.IsLimit.lift_ι, Fork.ι_ofι, hf]) hπ := CokernelCofork.IsColimit.ofId _ (Fork.IsLimit.hom_ext hc (by dsimp simp only [comp_id, zero_comp, Fork.IsLimit.lift_ι, Fork.ι_ofι, hf])) @[simp] lemma ofIsLimitKernelFork_f' (hf : S.f = 0) (c : KernelFork S.g) (hc : IsLimit c) : (ofIsLimitKernelFork S hf c hc).f' = 0 := by rw [← cancel_mono (ofIsLimitKernelFork S hf c hc).i, f'_i, hf, zero_comp] /-- When the first map `S.f` is zero, this is the left homology data on `S` given by the chosen `kernel S.g` -/ @[simp] noncomputable def ofHasKernel [HasKernel S.g] (hf : S.f = 0) : S.LeftHomologyData := ofIsLimitKernelFork S hf _ (kernelIsKernel _) /-- When both `S.f` and `S.g` are zero, the middle object `S.X₂` gives a left homology data on S -/ @[simps] def ofZeros (hf : S.f = 0) (hg : S.g = 0) : S.LeftHomologyData where K := S.X₂ H := S.X₂ i := 𝟙 _ π := 𝟙 _ wi := by rw [id_comp, hg] hi := KernelFork.IsLimit.ofId _ hg wπ := by change S.f ≫ 𝟙 _ = 0 simp only [hf, zero_comp] hπ := CokernelCofork.IsColimit.ofId _ hf @[simp] lemma ofZeros_f' (hf : S.f = 0) (hg : S.g = 0) : (ofZeros S hf hg).f' = 0 := by rw [← cancel_mono ((ofZeros S hf hg).i), zero_comp, f'_i, hf] end LeftHomologyData /-- A short complex `S` has left homology when there exists a `S.LeftHomologyData` -/ class HasLeftHomology : Prop where condition : Nonempty S.LeftHomologyData /-- A chosen `S.LeftHomologyData` for a short complex `S` that has left homology -/ noncomputable def leftHomologyData [S.HasLeftHomology] : S.LeftHomologyData := HasLeftHomology.condition.some variable {S} namespace HasLeftHomology lemma mk' (h : S.LeftHomologyData) : HasLeftHomology S := ⟨Nonempty.intro h⟩ instance of_hasKernel_of_hasCokernel [HasKernel S.g] [HasCokernel (kernel.lift S.g S.f S.zero)] : S.HasLeftHomology := HasLeftHomology.mk' (LeftHomologyData.ofHasKernelOfHasCokernel S) instance of_hasCokernel {X Y : C} (f : X ⟶ Y) (Z : C) [HasCokernel f] : (ShortComplex.mk f (0 : Y ⟶ Z) comp_zero).HasLeftHomology := HasLeftHomology.mk' (LeftHomologyData.ofHasCokernel _ rfl) instance of_hasKernel {Y Z : C} (g : Y ⟶ Z) (X : C) [HasKernel g] : (ShortComplex.mk (0 : X ⟶ Y) g zero_comp).HasLeftHomology := HasLeftHomology.mk' (LeftHomologyData.ofHasKernel _ rfl) instance of_zeros (X Y Z : C) : (ShortComplex.mk (0 : X ⟶ Y) (0 : Y ⟶ Z) zero_comp).HasLeftHomology := HasLeftHomology.mk' (LeftHomologyData.ofZeros _ rfl rfl) end HasLeftHomology section variable (φ : S₁ ⟶ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) /-- Given left homology data `h₁` and `h₂` for two short complexes `S₁` and `S₂`, a `LeftHomologyMapData` for a morphism `φ : S₁ ⟶ S₂` consists of a description of the induced morphisms on the `K` (cycles) and `H` (left homology) fields of `h₁` and `h₂`. -/ structure LeftHomologyMapData where /-- the induced map on cycles -/ φK : h₁.K ⟶ h₂.K /-- the induced map on left homology -/ φH : h₁.H ⟶ h₂.H /-- commutation with `i` -/ commi : φK ≫ h₂.i = h₁.i ≫ φ.τ₂ := by aesop_cat /-- commutation with `f'` -/ commf' : h₁.f' ≫ φK = φ.τ₁ ≫ h₂.f' := by aesop_cat /-- commutation with `π` -/ commπ : h₁.π ≫ φH = φK ≫ h₂.π := by aesop_cat namespace LeftHomologyMapData attribute [reassoc (attr := simp)] commi commf' commπ attribute [nolint simpNF] mk.injEq /-- The left homology map data associated to the zero morphism between two short complexes. -/ @[simps] def zero (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : LeftHomologyMapData 0 h₁ h₂ where φK := 0 φH := 0 /-- The left homology map data associated to the identity morphism of a short complex. -/ @[simps] def id (h : S.LeftHomologyData) : LeftHomologyMapData (𝟙 S) h h where φK := 𝟙 _ φH := 𝟙 _ /-- The composition of left homology map data. -/ @[simps] def comp {φ : S₁ ⟶ S₂} {φ' : S₂ ⟶ S₃} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} {h₃ : S₃.LeftHomologyData} (ψ : LeftHomologyMapData φ h₁ h₂) (ψ' : LeftHomologyMapData φ' h₂ h₃) : LeftHomologyMapData (φ ≫ φ') h₁ h₃ where φK := ψ.φK ≫ ψ'.φK φH := ψ.φH ≫ ψ'.φH instance : Subsingleton (LeftHomologyMapData φ h₁ h₂) := ⟨fun ψ₁ ψ₂ => by have hK : ψ₁.φK = ψ₂.φK := by rw [← cancel_mono h₂.i, commi, commi] have hH : ψ₁.φH = ψ₂.φH := by rw [← cancel_epi h₁.π, commπ, commπ, hK] cases ψ₁ cases ψ₂ congr⟩ instance : Inhabited (LeftHomologyMapData φ h₁ h₂) := ⟨by let φK : h₁.K ⟶ h₂.K := h₂.liftK (h₁.i ≫ φ.τ₂) (by rw [assoc, φ.comm₂₃, h₁.wi_assoc, zero_comp]) have commf' : h₁.f' ≫ φK = φ.τ₁ ≫ h₂.f' := by rw [← cancel_mono h₂.i, assoc, assoc, LeftHomologyData.liftK_i, LeftHomologyData.f'_i_assoc, LeftHomologyData.f'_i, φ.comm₁₂] let φH : h₁.H ⟶ h₂.H := h₁.descH (φK ≫ h₂.π) (by rw [reassoc_of% commf', h₂.f'_π, comp_zero]) exact ⟨φK, φH, by simp [φK], commf', by simp [φH]⟩⟩ instance : Unique (LeftHomologyMapData φ h₁ h₂) := Unique.mk' _ variable {φ h₁ h₂} lemma congr_φH {γ₁ γ₂ : LeftHomologyMapData φ h₁ h₂} (eq : γ₁ = γ₂) : γ₁.φH = γ₂.φH := by rw [eq] lemma congr_φK {γ₁ γ₂ : LeftHomologyMapData φ h₁ h₂} (eq : γ₁ = γ₂) : γ₁.φK = γ₂.φK := by rw [eq] /-- When `S₁.f`, `S₁.g`, `S₂.f` and `S₂.g` are all zero, the action on left homology of a morphism `φ : S₁ ⟶ S₂` is given by the action `φ.τ₂` on the middle objects. -/ @[simps] def ofZeros (φ : S₁ ⟶ S₂) (hf₁ : S₁.f = 0) (hg₁ : S₁.g = 0) (hf₂ : S₂.f = 0) (hg₂ : S₂.g = 0) : LeftHomologyMapData φ (LeftHomologyData.ofZeros S₁ hf₁ hg₁) (LeftHomologyData.ofZeros S₂ hf₂ hg₂) where φK := φ.τ₂ φH := φ.τ₂ /-- When `S₁.g` and `S₂.g` are zero and we have chosen colimit cokernel coforks `c₁` and `c₂` for `S₁.f` and `S₂.f` respectively, the action on left homology of a morphism `φ : S₁ ⟶ S₂` of short complexes is given by the unique morphism `f : c₁.pt ⟶ c₂.pt` such that `φ.τ₂ ≫ c₂.π = c₁.π ≫ f`. -/ @[simps] def ofIsColimitCokernelCofork (φ : S₁ ⟶ S₂) (hg₁ : S₁.g = 0) (c₁ : CokernelCofork S₁.f) (hc₁ : IsColimit c₁) (hg₂ : S₂.g = 0) (c₂ : CokernelCofork S₂.f) (hc₂ : IsColimit c₂) (f : c₁.pt ⟶ c₂.pt) (comm : φ.τ₂ ≫ c₂.π = c₁.π ≫ f) : LeftHomologyMapData φ (LeftHomologyData.ofIsColimitCokernelCofork S₁ hg₁ c₁ hc₁) (LeftHomologyData.ofIsColimitCokernelCofork S₂ hg₂ c₂ hc₂) where φK := φ.τ₂ φH := f commπ := comm.symm commf' := by simp only [LeftHomologyData.ofIsColimitCokernelCofork_f', φ.comm₁₂] /-- When `S₁.f` and `S₂.f` are zero and we have chosen limit kernel forks `c₁` and `c₂` for `S₁.g` and `S₂.g` respectively, the action on left homology of a morphism `φ : S₁ ⟶ S₂` of short complexes is given by the unique morphism `f : c₁.pt ⟶ c₂.pt` such that `c₁.ι ≫ φ.τ₂ = f ≫ c₂.ι`. -/ @[simps] def ofIsLimitKernelFork (φ : S₁ ⟶ S₂) (hf₁ : S₁.f = 0) (c₁ : KernelFork S₁.g) (hc₁ : IsLimit c₁) (hf₂ : S₂.f = 0) (c₂ : KernelFork S₂.g) (hc₂ : IsLimit c₂) (f : c₁.pt ⟶ c₂.pt) (comm : c₁.ι ≫ φ.τ₂ = f ≫ c₂.ι) : LeftHomologyMapData φ (LeftHomologyData.ofIsLimitKernelFork S₁ hf₁ c₁ hc₁) (LeftHomologyData.ofIsLimitKernelFork S₂ hf₂ c₂ hc₂) where φK := f φH := f commi := comm.symm variable (S) /-- When both maps `S.f` and `S.g` of a short complex `S` are zero, this is the left homology map data (for the identity of `S`) which relates the left homology data `ofZeros` and `ofIsColimitCokernelCofork`. -/ @[simps] def compatibilityOfZerosOfIsColimitCokernelCofork (hf : S.f = 0) (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : LeftHomologyMapData (𝟙 S) (LeftHomologyData.ofZeros S hf hg) (LeftHomologyData.ofIsColimitCokernelCofork S hg c hc) where φK := 𝟙 _ φH := c.π /-- When both maps `S.f` and `S.g` of a short complex `S` are zero, this is the left homology map data (for the identity of `S`) which relates the left homology data `LeftHomologyData.ofIsLimitKernelFork` and `ofZeros` . -/ @[simps] def compatibilityOfZerosOfIsLimitKernelFork (hf : S.f = 0) (hg : S.g = 0) (c : KernelFork S.g) (hc : IsLimit c) : LeftHomologyMapData (𝟙 S) (LeftHomologyData.ofIsLimitKernelFork S hf c hc) (LeftHomologyData.ofZeros S hf hg) where φK := c.ι φH := c.ι end LeftHomologyMapData end section variable (S) variable [S.HasLeftHomology] /-- The left homology of a short complex, given by the `H` field of a chosen left homology data. -/ noncomputable def leftHomology : C := S.leftHomologyData.H /-- The cycles of a short complex, given by the `K` field of a chosen left homology data. -/ noncomputable def cycles : C := S.leftHomologyData.K /-- The "homology class" map `S.cycles ⟶ S.leftHomology`. -/ noncomputable def leftHomologyπ : S.cycles ⟶ S.leftHomology := S.leftHomologyData.π /-- The inclusion `S.cycles ⟶ S.X₂`. -/ noncomputable def iCycles : S.cycles ⟶ S.X₂ := S.leftHomologyData.i /-- The "boundaries" map `S.X₁ ⟶ S.cycles`. (Note that in this homology API, we make no use of the "image" of this morphism, which under some categorical assumptions would be a subobject of `S.X₂` contained in `S.cycles`.) -/ noncomputable def toCycles : S.X₁ ⟶ S.cycles := S.leftHomologyData.f' @[reassoc (attr := simp)] lemma iCycles_g : S.iCycles ≫ S.g = 0 := S.leftHomologyData.wi @[reassoc (attr := simp)] lemma toCycles_i : S.toCycles ≫ S.iCycles = S.f := S.leftHomologyData.f'_i instance : Mono S.iCycles := by dsimp only [iCycles] infer_instance instance : Epi S.leftHomologyπ := by dsimp only [leftHomologyπ] infer_instance lemma leftHomology_ext_iff {A : C} (f₁ f₂ : S.leftHomology ⟶ A) : f₁ = f₂ ↔ S.leftHomologyπ ≫ f₁ = S.leftHomologyπ ≫ f₂ := by rw [cancel_epi] @[ext] lemma leftHomology_ext {A : C} (f₁ f₂ : S.leftHomology ⟶ A) (h : S.leftHomologyπ ≫ f₁ = S.leftHomologyπ ≫ f₂) : f₁ = f₂ := by simpa only [leftHomology_ext_iff] using h lemma cycles_ext_iff {A : C} (f₁ f₂ : A ⟶ S.cycles) : f₁ = f₂ ↔ f₁ ≫ S.iCycles = f₂ ≫ S.iCycles := by rw [cancel_mono] @[ext] lemma cycles_ext {A : C} (f₁ f₂ : A ⟶ S.cycles) (h : f₁ ≫ S.iCycles = f₂ ≫ S.iCycles) : f₁ = f₂ := by simpa only [cycles_ext_iff] using h lemma isIso_iCycles (hg : S.g = 0) : IsIso S.iCycles := LeftHomologyData.isIso_i _ hg /-- When `S.g = 0`, this is the canonical isomorphism `S.cycles ≅ S.X₂` induced by `S.iCycles`. -/ @[simps! hom] noncomputable def cyclesIsoX₂ (hg : S.g = 0) : S.cycles ≅ S.X₂ := by have := S.isIso_iCycles hg exact asIso S.iCycles @[reassoc (attr := simp)] lemma cyclesIsoX₂_hom_inv_id (hg : S.g = 0) : S.iCycles ≫ (S.cyclesIsoX₂ hg).inv = 𝟙 _ := (S.cyclesIsoX₂ hg).hom_inv_id @[reassoc (attr := simp)] lemma cyclesIsoX₂_inv_hom_id (hg : S.g = 0) : (S.cyclesIsoX₂ hg).inv ≫ S.iCycles = 𝟙 _ := (S.cyclesIsoX₂ hg).inv_hom_id lemma isIso_leftHomologyπ (hf : S.f = 0) : IsIso S.leftHomologyπ := LeftHomologyData.isIso_π _ hf /-- When `S.f = 0`, this is the canonical isomorphism `S.cycles ≅ S.leftHomology` induced by `S.leftHomologyπ`. -/ @[simps! hom] noncomputable def cyclesIsoLeftHomology (hf : S.f = 0) : S.cycles ≅ S.leftHomology := by have := S.isIso_leftHomologyπ hf exact asIso S.leftHomologyπ @[reassoc (attr := simp)] lemma cyclesIsoLeftHomology_hom_inv_id (hf : S.f = 0) : S.leftHomologyπ ≫ (S.cyclesIsoLeftHomology hf).inv = 𝟙 _ := (S.cyclesIsoLeftHomology hf).hom_inv_id @[reassoc (attr := simp)] lemma cyclesIsoLeftHomology_inv_hom_id (hf : S.f = 0) : (S.cyclesIsoLeftHomology hf).inv ≫ S.leftHomologyπ = 𝟙 _ := (S.cyclesIsoLeftHomology hf).inv_hom_id end section variable (φ : S₁ ⟶ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) /-- The (unique) left homology map data associated to a morphism of short complexes that are both equipped with left homology data. -/ def leftHomologyMapData : LeftHomologyMapData φ h₁ h₂ := default /-- Given a morphism `φ : S₁ ⟶ S₂` of short complexes and left homology data `h₁` and `h₂` for `S₁` and `S₂` respectively, this is the induced left homology map `h₁.H ⟶ h₁.H`. -/ def leftHomologyMap' : h₁.H ⟶ h₂.H := (leftHomologyMapData φ _ _).φH /-- Given a morphism `φ : S₁ ⟶ S₂` of short complexes and left homology data `h₁` and `h₂` for `S₁` and `S₂` respectively, this is the induced morphism `h₁.K ⟶ h₁.K` on cycles. -/ def cyclesMap' : h₁.K ⟶ h₂.K := (leftHomologyMapData φ _ _).φK @[reassoc (attr := simp)] lemma cyclesMap'_i : cyclesMap' φ h₁ h₂ ≫ h₂.i = h₁.i ≫ φ.τ₂ := LeftHomologyMapData.commi _ @[reassoc (attr := simp)] lemma f'_cyclesMap' : h₁.f' ≫ cyclesMap' φ h₁ h₂ = φ.τ₁ ≫ h₂.f' := by simp only [← cancel_mono h₂.i, assoc, φ.comm₁₂, cyclesMap'_i, LeftHomologyData.f'_i_assoc, LeftHomologyData.f'_i] @[reassoc (attr := simp)] lemma leftHomologyπ_naturality' : h₁.π ≫ leftHomologyMap' φ h₁ h₂ = cyclesMap' φ h₁ h₂ ≫ h₂.π := LeftHomologyMapData.commπ _ end section variable [HasLeftHomology S₁] [HasLeftHomology S₂] (φ : S₁ ⟶ S₂) /-- The (left) homology map `S₁.leftHomology ⟶ S₂.leftHomology` induced by a morphism `S₁ ⟶ S₂` of short complexes. -/ noncomputable def leftHomologyMap : S₁.leftHomology ⟶ S₂.leftHomology := leftHomologyMap' φ _ _ /-- The morphism `S₁.cycles ⟶ S₂.cycles` induced by a morphism `S₁ ⟶ S₂` of short complexes. -/ noncomputable def cyclesMap : S₁.cycles ⟶ S₂.cycles := cyclesMap' φ _ _ @[reassoc (attr := simp)] lemma cyclesMap_i : cyclesMap φ ≫ S₂.iCycles = S₁.iCycles ≫ φ.τ₂ := cyclesMap'_i _ _ _ @[reassoc (attr := simp)] lemma toCycles_naturality : S₁.toCycles ≫ cyclesMap φ = φ.τ₁ ≫ S₂.toCycles := f'_cyclesMap' _ _ _ @[reassoc (attr := simp)] lemma leftHomologyπ_naturality : S₁.leftHomologyπ ≫ leftHomologyMap φ = cyclesMap φ ≫ S₂.leftHomologyπ := leftHomologyπ_naturality' _ _ _ end namespace LeftHomologyMapData variable {φ : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} (γ : LeftHomologyMapData φ h₁ h₂) lemma leftHomologyMap'_eq : leftHomologyMap' φ h₁ h₂ = γ.φH := LeftHomologyMapData.congr_φH (Subsingleton.elim _ _) lemma cyclesMap'_eq : cyclesMap' φ h₁ h₂ = γ.φK := LeftHomologyMapData.congr_φK (Subsingleton.elim _ _) end LeftHomologyMapData @[simp] lemma leftHomologyMap'_id (h : S.LeftHomologyData) : leftHomologyMap' (𝟙 S) h h = 𝟙 _ := (LeftHomologyMapData.id h).leftHomologyMap'_eq @[simp] lemma cyclesMap'_id (h : S.LeftHomologyData) : cyclesMap' (𝟙 S) h h = 𝟙 _ := (LeftHomologyMapData.id h).cyclesMap'_eq variable (S) @[simp] lemma leftHomologyMap_id [HasLeftHomology S] : leftHomologyMap (𝟙 S) = 𝟙 _ := leftHomologyMap'_id _ @[simp] lemma cyclesMap_id [HasLeftHomology S] : cyclesMap (𝟙 S) = 𝟙 _ := cyclesMap'_id _ @[simp] lemma leftHomologyMap'_zero (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : leftHomologyMap' 0 h₁ h₂ = 0 := (LeftHomologyMapData.zero h₁ h₂).leftHomologyMap'_eq @[simp] lemma cyclesMap'_zero (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : cyclesMap' 0 h₁ h₂ = 0 := (LeftHomologyMapData.zero h₁ h₂).cyclesMap'_eq variable (S₁ S₂) @[simp] lemma leftHomologyMap_zero [HasLeftHomology S₁] [HasLeftHomology S₂] : leftHomologyMap (0 : S₁ ⟶ S₂) = 0 := leftHomologyMap'_zero _ _ @[simp] lemma cyclesMap_zero [HasLeftHomology S₁] [HasLeftHomology S₂] : cyclesMap (0 : S₁ ⟶ S₂) = 0 := cyclesMap'_zero _ _ variable {S₁ S₂} @[reassoc] lemma leftHomologyMap'_comp (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) (h₃ : S₃.LeftHomologyData) : leftHomologyMap' (φ₁ ≫ φ₂) h₁ h₃ = leftHomologyMap' φ₁ h₁ h₂ ≫ leftHomologyMap' φ₂ h₂ h₃ := by let γ₁ := leftHomologyMapData φ₁ h₁ h₂ let γ₂ := leftHomologyMapData φ₂ h₂ h₃ rw [γ₁.leftHomologyMap'_eq, γ₂.leftHomologyMap'_eq, (γ₁.comp γ₂).leftHomologyMap'_eq, LeftHomologyMapData.comp_φH] @[reassoc] lemma cyclesMap'_comp (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) (h₃ : S₃.LeftHomologyData) : cyclesMap' (φ₁ ≫ φ₂) h₁ h₃ = cyclesMap' φ₁ h₁ h₂ ≫ cyclesMap' φ₂ h₂ h₃ := by let γ₁ := leftHomologyMapData φ₁ h₁ h₂ let γ₂ := leftHomologyMapData φ₂ h₂ h₃ rw [γ₁.cyclesMap'_eq, γ₂.cyclesMap'_eq, (γ₁.comp γ₂).cyclesMap'_eq, LeftHomologyMapData.comp_φK] @[reassoc] lemma leftHomologyMap_comp [HasLeftHomology S₁] [HasLeftHomology S₂] [HasLeftHomology S₃] (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) : leftHomologyMap (φ₁ ≫ φ₂) = leftHomologyMap φ₁ ≫ leftHomologyMap φ₂ := leftHomologyMap'_comp _ _ _ _ _ @[reassoc] lemma cyclesMap_comp [HasLeftHomology S₁] [HasLeftHomology S₂] [HasLeftHomology S₃] (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) : cyclesMap (φ₁ ≫ φ₂) = cyclesMap φ₁ ≫ cyclesMap φ₂ := cyclesMap'_comp _ _ _ _ _ attribute [simp] leftHomologyMap_comp cyclesMap_comp /-- An isomorphism of short complexes `S₁ ≅ S₂` induces an isomorphism on the `H` fields of left homology data of `S₁` and `S₂`. -/ @[simps] def leftHomologyMapIso' (e : S₁ ≅ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : h₁.H ≅ h₂.H where hom := leftHomologyMap' e.hom h₁ h₂ inv := leftHomologyMap' e.inv h₂ h₁ hom_inv_id := by rw [← leftHomologyMap'_comp, e.hom_inv_id, leftHomologyMap'_id] inv_hom_id := by rw [← leftHomologyMap'_comp, e.inv_hom_id, leftHomologyMap'_id] instance isIso_leftHomologyMap'_of_isIso (φ : S₁ ⟶ S₂) [IsIso φ] (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : IsIso (leftHomologyMap' φ h₁ h₂) := (inferInstance : IsIso (leftHomologyMapIso' (asIso φ) h₁ h₂).hom) /-- An isomorphism of short complexes `S₁ ≅ S₂` induces an isomorphism on the `K` fields of left homology data of `S₁` and `S₂`. -/ @[simps] def cyclesMapIso' (e : S₁ ≅ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : h₁.K ≅ h₂.K where hom := cyclesMap' e.hom h₁ h₂ inv := cyclesMap' e.inv h₂ h₁ hom_inv_id := by rw [← cyclesMap'_comp, e.hom_inv_id, cyclesMap'_id] inv_hom_id := by rw [← cyclesMap'_comp, e.inv_hom_id, cyclesMap'_id] instance isIso_cyclesMap'_of_isIso (φ : S₁ ⟶ S₂) [IsIso φ] (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : IsIso (cyclesMap' φ h₁ h₂) := (inferInstance : IsIso (cyclesMapIso' (asIso φ) h₁ h₂).hom) /-- The isomorphism `S₁.leftHomology ≅ S₂.leftHomology` induced by an isomorphism of short complexes `S₁ ≅ S₂`. -/ @[simps] noncomputable def leftHomologyMapIso (e : S₁ ≅ S₂) [S₁.HasLeftHomology] [S₂.HasLeftHomology] : S₁.leftHomology ≅ S₂.leftHomology where hom := leftHomologyMap e.hom inv := leftHomologyMap e.inv hom_inv_id := by rw [← leftHomologyMap_comp, e.hom_inv_id, leftHomologyMap_id] inv_hom_id := by rw [← leftHomologyMap_comp, e.inv_hom_id, leftHomologyMap_id] instance isIso_leftHomologyMap_of_iso (φ : S₁ ⟶ S₂) [IsIso φ] [S₁.HasLeftHomology] [S₂.HasLeftHomology] : IsIso (leftHomologyMap φ) := (inferInstance : IsIso (leftHomologyMapIso (asIso φ)).hom) /-- The isomorphism `S₁.cycles ≅ S₂.cycles` induced by an isomorphism of short complexes `S₁ ≅ S₂`. -/ @[simps] noncomputable def cyclesMapIso (e : S₁ ≅ S₂) [S₁.HasLeftHomology] [S₂.HasLeftHomology] : S₁.cycles ≅ S₂.cycles where hom := cyclesMap e.hom inv := cyclesMap e.inv hom_inv_id := by rw [← cyclesMap_comp, e.hom_inv_id, cyclesMap_id] inv_hom_id := by rw [← cyclesMap_comp, e.inv_hom_id, cyclesMap_id] instance isIso_cyclesMap_of_iso (φ : S₁ ⟶ S₂) [IsIso φ] [S₁.HasLeftHomology] [S₂.HasLeftHomology] : IsIso (cyclesMap φ) := (inferInstance : IsIso (cyclesMapIso (asIso φ)).hom) variable {S} namespace LeftHomologyData variable (h : S.LeftHomologyData) [S.HasLeftHomology] /-- The isomorphism `S.leftHomology ≅ h.H` induced by a left homology data `h` for a short complex `S`. -/ noncomputable def leftHomologyIso : S.leftHomology ≅ h.H := leftHomologyMapIso' (Iso.refl _) _ _ /-- The isomorphism `S.cycles ≅ h.K` induced by a left homology data `h` for a short complex `S`. -/ noncomputable def cyclesIso : S.cycles ≅ h.K := cyclesMapIso' (Iso.refl _) _ _ @[reassoc (attr := simp)] lemma cyclesIso_hom_comp_i : h.cyclesIso.hom ≫ h.i = S.iCycles := by dsimp [iCycles, LeftHomologyData.cyclesIso] simp only [cyclesMap'_i, id_τ₂, comp_id] @[reassoc (attr := simp)] lemma cyclesIso_inv_comp_iCycles : h.cyclesIso.inv ≫ S.iCycles = h.i := by simp only [← h.cyclesIso_hom_comp_i, Iso.inv_hom_id_assoc] @[reassoc (attr := simp)] lemma leftHomologyπ_comp_leftHomologyIso_hom : S.leftHomologyπ ≫ h.leftHomologyIso.hom = h.cyclesIso.hom ≫ h.π := by dsimp only [leftHomologyπ, leftHomologyIso, cyclesIso, leftHomologyMapIso', cyclesMapIso', Iso.refl] rw [← leftHomologyπ_naturality'] @[reassoc (attr := simp)] lemma π_comp_leftHomologyIso_inv : h.π ≫ h.leftHomologyIso.inv = h.cyclesIso.inv ≫ S.leftHomologyπ := by simp only [← cancel_epi h.cyclesIso.hom, ← cancel_mono h.leftHomologyIso.hom, assoc, Iso.inv_hom_id, comp_id, Iso.hom_inv_id_assoc, LeftHomologyData.leftHomologyπ_comp_leftHomologyIso_hom] end LeftHomologyData namespace LeftHomologyMapData variable {φ : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} (γ : LeftHomologyMapData φ h₁ h₂) lemma leftHomologyMap_eq [S₁.HasLeftHomology] [S₂.HasLeftHomology] : leftHomologyMap φ = h₁.leftHomologyIso.hom ≫ γ.φH ≫ h₂.leftHomologyIso.inv := by dsimp [LeftHomologyData.leftHomologyIso, leftHomologyMapIso'] rw [← γ.leftHomologyMap'_eq, ← leftHomologyMap'_comp, ← leftHomologyMap'_comp, id_comp, comp_id] rfl lemma cyclesMap_eq [S₁.HasLeftHomology] [S₂.HasLeftHomology] : cyclesMap φ = h₁.cyclesIso.hom ≫ γ.φK ≫ h₂.cyclesIso.inv := by dsimp [LeftHomologyData.cyclesIso, cyclesMapIso'] rw [← γ.cyclesMap'_eq, ← cyclesMap'_comp, ← cyclesMap'_comp, id_comp, comp_id] rfl lemma leftHomologyMap_comm [S₁.HasLeftHomology] [S₂.HasLeftHomology] : leftHomologyMap φ ≫ h₂.leftHomologyIso.hom = h₁.leftHomologyIso.hom ≫ γ.φH := by simp only [γ.leftHomologyMap_eq, assoc, Iso.inv_hom_id, comp_id] lemma cyclesMap_comm [S₁.HasLeftHomology] [S₂.HasLeftHomology] : cyclesMap φ ≫ h₂.cyclesIso.hom = h₁.cyclesIso.hom ≫ γ.φK := by simp only [γ.cyclesMap_eq, assoc, Iso.inv_hom_id, comp_id] end LeftHomologyMapData section variable (C) variable [HasKernels C] [HasCokernels C] /-- The left homology functor `ShortComplex C ⥤ C`, where the left homology of a short complex `S` is understood as a cokernel of the obvious map `S.toCycles : S.X₁ ⟶ S.cycles` where `S.cycles` is a kernel of `S.g : S.X₂ ⟶ S.X₃`. -/ @[simps] noncomputable def leftHomologyFunctor : ShortComplex C ⥤ C where obj S := S.leftHomology map := leftHomologyMap /-- The cycles functor `ShortComplex C ⥤ C` which sends a short complex `S` to `S.cycles` which is a kernel of `S.g : S.X₂ ⟶ S.X₃`. -/ @[simps] noncomputable def cyclesFunctor : ShortComplex C ⥤ C where obj S := S.cycles map := cyclesMap /-- The natural transformation `S.cycles ⟶ S.leftHomology` for all short complexes `S`. -/ @[simps] noncomputable def leftHomologyπNatTrans : cyclesFunctor C ⟶ leftHomologyFunctor C where app S := leftHomologyπ S naturality := fun _ _ φ => (leftHomologyπ_naturality φ).symm /-- The natural transformation `S.cycles ⟶ S.X₂` for all short complexes `S`. -/ @[simps] noncomputable def iCyclesNatTrans : cyclesFunctor C ⟶ ShortComplex.π₂ where app S := S.iCycles /-- The natural transformation `S.X₁ ⟶ S.cycles` for all short complexes `S`. -/ @[simps] noncomputable def toCyclesNatTrans : π₁ ⟶ cyclesFunctor C where app S := S.toCycles naturality := fun _ _ φ => (toCycles_naturality φ).symm end namespace LeftHomologyData /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a left homology data for `S₁` induces a left homology data for `S₂` with the same `K` and `H` fields. The inverse construction is `ofEpiOfIsIsoOfMono'`. -/ @[simps] noncomputable def ofEpiOfIsIsoOfMono (φ : S₁ ⟶ S₂) (h : LeftHomologyData S₁) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : LeftHomologyData S₂ := by let i : h.K ⟶ S₂.X₂ := h.i ≫ φ.τ₂ have wi : i ≫ S₂.g = 0 := by simp only [i, assoc, φ.comm₂₃, h.wi_assoc, zero_comp] have hi : IsLimit (KernelFork.ofι i wi) := KernelFork.IsLimit.ofι _ _ (fun x hx => h.liftK (x ≫ inv φ.τ₂) (by rw [assoc, ← cancel_mono φ.τ₃, assoc, assoc, ← φ.comm₂₃, IsIso.inv_hom_id_assoc, hx, zero_comp])) (fun x hx => by simp [i]) (fun x hx b hb => by dsimp rw [← cancel_mono h.i, ← cancel_mono φ.τ₂, assoc, assoc, liftK_i_assoc, assoc, IsIso.inv_hom_id, comp_id, hb]) let f' := hi.lift (KernelFork.ofι S₂.f S₂.zero) have hf' : φ.τ₁ ≫ f' = h.f' := by have eq := @Fork.IsLimit.lift_ι _ _ _ _ _ _ _ ((KernelFork.ofι S₂.f S₂.zero)) hi simp only [Fork.ι_ofι] at eq rw [← cancel_mono h.i, ← cancel_mono φ.τ₂, assoc, assoc, eq, f'_i, φ.comm₁₂] have wπ : f' ≫ h.π = 0 := by rw [← cancel_epi φ.τ₁, comp_zero, reassoc_of% hf', h.f'_π] have hπ : IsColimit (CokernelCofork.ofπ h.π wπ) := CokernelCofork.IsColimit.ofπ _ _ (fun x hx => h.descH x (by rw [← hf', assoc, hx, comp_zero])) (fun x hx => by simp) (fun x hx b hb => by rw [← cancel_epi h.π, π_descH, hb]) exact ⟨h.K, h.H, i, h.π, wi, hi, wπ, hπ⟩ @[simp] lemma τ₁_ofEpiOfIsIsoOfMono_f' (φ : S₁ ⟶ S₂) (h : LeftHomologyData S₁) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : φ.τ₁ ≫ (ofEpiOfIsIsoOfMono φ h).f' = h.f' := by rw [← cancel_mono (ofEpiOfIsIsoOfMono φ h).i, assoc, f'_i, ofEpiOfIsIsoOfMono_i, f'_i_assoc, φ.comm₁₂] /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a left homology data for `S₂` induces a left homology data for `S₁` with the same `K` and `H` fields. The inverse construction is `ofEpiOfIsIsoOfMono`. -/ @[simps] noncomputable def ofEpiOfIsIsoOfMono' (φ : S₁ ⟶ S₂) (h : LeftHomologyData S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : LeftHomologyData S₁ := by let i : h.K ⟶ S₁.X₂ := h.i ≫ inv φ.τ₂ have wi : i ≫ S₁.g = 0 := by rw [assoc, ← cancel_mono φ.τ₃, zero_comp, assoc, assoc, ← φ.comm₂₃, IsIso.inv_hom_id_assoc, h.wi] have hi : IsLimit (KernelFork.ofι i wi) := KernelFork.IsLimit.ofι _ _ (fun x hx => h.liftK (x ≫ φ.τ₂) (by rw [assoc, φ.comm₂₃, reassoc_of% hx, zero_comp])) (fun x hx => by simp [i]) (fun x hx b hb => by rw [← cancel_mono h.i, ← cancel_mono (inv φ.τ₂), assoc, assoc, hb, liftK_i_assoc, assoc, IsIso.hom_inv_id, comp_id]) let f' := hi.lift (KernelFork.ofι S₁.f S₁.zero) have hf' : f' ≫ i = S₁.f := Fork.IsLimit.lift_ι _ have hf'' : f' = φ.τ₁ ≫ h.f' := by rw [← cancel_mono h.i, ← cancel_mono (inv φ.τ₂), assoc, assoc, assoc, hf', f'_i_assoc, φ.comm₁₂_assoc, IsIso.hom_inv_id, comp_id] have wπ : f' ≫ h.π = 0 := by simp only [hf'', assoc, f'_π, comp_zero] have hπ : IsColimit (CokernelCofork.ofπ h.π wπ) := CokernelCofork.IsColimit.ofπ _ _ (fun x hx => h.descH x (by rw [← cancel_epi φ.τ₁, ← reassoc_of% hf'', hx, comp_zero])) (fun x hx => π_descH _ _ _) (fun x hx b hx => by rw [← cancel_epi h.π, π_descH, hx]) exact ⟨h.K, h.H, i, h.π, wi, hi, wπ, hπ⟩ @[simp] lemma ofEpiOfIsIsoOfMono'_f' (φ : S₁ ⟶ S₂) (h : LeftHomologyData S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : (ofEpiOfIsIsoOfMono' φ h).f' = φ.τ₁ ≫ h.f' := by rw [← cancel_mono (ofEpiOfIsIsoOfMono' φ h).i, f'_i, ofEpiOfIsIsoOfMono'_i, assoc, f'_i_assoc, φ.comm₁₂_assoc, IsIso.hom_inv_id, comp_id] /-- If `e : S₁ ≅ S₂` is an isomorphism of short complexes and `h₁ : LeftHomologyData S₁`, this is the left homology data for `S₂` deduced from the isomorphism. -/ noncomputable def ofIso (e : S₁ ≅ S₂) (h₁ : LeftHomologyData S₁) : LeftHomologyData S₂ := h₁.ofEpiOfIsIsoOfMono e.hom end LeftHomologyData lemma hasLeftHomology_of_epi_of_isIso_of_mono (φ : S₁ ⟶ S₂) [HasLeftHomology S₁] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HasLeftHomology S₂ := HasLeftHomology.mk' (LeftHomologyData.ofEpiOfIsIsoOfMono φ S₁.leftHomologyData) lemma hasLeftHomology_of_epi_of_isIso_of_mono' (φ : S₁ ⟶ S₂) [HasLeftHomology S₂] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HasLeftHomology S₁ := HasLeftHomology.mk' (LeftHomologyData.ofEpiOfIsIsoOfMono' φ S₂.leftHomologyData) lemma hasLeftHomology_of_iso {S₁ S₂ : ShortComplex C} (e : S₁ ≅ S₂) [HasLeftHomology S₁] : HasLeftHomology S₂ := hasLeftHomology_of_epi_of_isIso_of_mono e.hom namespace LeftHomologyMapData /-- This left homology map data expresses compatibilities of the left homology data constructed by `LeftHomologyData.ofEpiOfIsIsoOfMono` -/ @[simps] def ofEpiOfIsIsoOfMono (φ : S₁ ⟶ S₂) (h : LeftHomologyData S₁) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : LeftHomologyMapData φ h (LeftHomologyData.ofEpiOfIsIsoOfMono φ h) where φK := 𝟙 _ φH := 𝟙 _ /-- This left homology map data expresses compatibilities of the left homology data constructed by `LeftHomologyData.ofEpiOfIsIsoOfMono'` -/ @[simps] noncomputable def ofEpiOfIsIsoOfMono' (φ : S₁ ⟶ S₂) (h : LeftHomologyData S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : LeftHomologyMapData φ (LeftHomologyData.ofEpiOfIsIsoOfMono' φ h) h where φK := 𝟙 _ φH := 𝟙 _ end LeftHomologyMapData instance (φ : S₁ ⟶ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : IsIso (leftHomologyMap' φ h₁ h₂) := by let h₂' := LeftHomologyData.ofEpiOfIsIsoOfMono φ h₁ have : IsIso (leftHomologyMap' φ h₁ h₂') := by rw [(LeftHomologyMapData.ofEpiOfIsIsoOfMono φ h₁).leftHomologyMap'_eq] dsimp infer_instance have eq := leftHomologyMap'_comp φ (𝟙 S₂) h₁ h₂' h₂ rw [comp_id] at eq rw [eq] infer_instance /-- If a morphism of short complexes `φ : S₁ ⟶ S₂` is such that `φ.τ₁` is epi, `φ.τ₂` is an iso, and `φ.τ₃` is mono, then the induced morphism on left homology is an isomorphism. -/ instance (φ : S₁ ⟶ S₂) [S₁.HasLeftHomology] [S₂.HasLeftHomology] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : IsIso (leftHomologyMap φ) := by dsimp only [leftHomologyMap] infer_instance section variable (S) (h : LeftHomologyData S) {A : C} (k : A ⟶ S.X₂) (hk : k ≫ S.g = 0) [HasLeftHomology S] /-- A morphism `k : A ⟶ S.X₂` such that `k ≫ S.g = 0` lifts to a morphism `A ⟶ S.cycles`. -/ noncomputable def liftCycles : A ⟶ S.cycles := S.leftHomologyData.liftK k hk @[reassoc (attr := simp)] lemma liftCycles_i : S.liftCycles k hk ≫ S.iCycles = k := LeftHomologyData.liftK_i _ k hk @[reassoc] lemma comp_liftCycles {A' : C} (α : A' ⟶ A) : α ≫ S.liftCycles k hk = S.liftCycles (α ≫ k) (by rw [assoc, hk, comp_zero]) := by aesop_cat /-- Via `S.iCycles : S.cycles ⟶ S.X₂`, the object `S.cycles` identifies to the kernel of `S.g : S.X₂ ⟶ S.X₃`. -/ noncomputable def cyclesIsKernel : IsLimit (KernelFork.ofι S.iCycles S.iCycles_g) := S.leftHomologyData.hi /-- The canonical isomorphism `S.cycles ≅ kernel S.g`. -/ @[simps] noncomputable def cyclesIsoKernel [HasKernel S.g] : S.cycles ≅ kernel S.g where hom := kernel.lift S.g S.iCycles (by simp) inv := S.liftCycles (kernel.ι S.g) (by simp) /-- The morphism `A ⟶ S.leftHomology` obtained from a morphism `k : A ⟶ S.X₂` such that `k ≫ S.g = 0.` -/ @[simp] noncomputable def liftLeftHomology : A ⟶ S.leftHomology := S.liftCycles k hk ≫ S.leftHomologyπ @[reassoc] lemma liftCycles_leftHomologyπ_eq_zero_of_boundary (x : A ⟶ S.X₁) (hx : k = x ≫ S.f) : S.liftCycles k (by rw [hx, assoc, S.zero, comp_zero]) ≫ S.leftHomologyπ = 0 := LeftHomologyData.liftK_π_eq_zero_of_boundary _ k x hx @[reassoc (attr := simp)] lemma toCycles_comp_leftHomologyπ : S.toCycles ≫ S.leftHomologyπ = 0 := S.liftCycles_leftHomologyπ_eq_zero_of_boundary S.f (𝟙 _) (by rw [id_comp]) /-- Via `S.leftHomologyπ : S.cycles ⟶ S.leftHomology`, the object `S.leftHomology` identifies to the cokernel of `S.toCycles : S.X₁ ⟶ S.cycles`. -/ noncomputable def leftHomologyIsCokernel : IsColimit (CokernelCofork.ofπ S.leftHomologyπ S.toCycles_comp_leftHomologyπ) := S.leftHomologyData.hπ @[reassoc (attr := simp)] lemma liftCycles_comp_cyclesMap (φ : S ⟶ S₁) [S₁.HasLeftHomology] : S.liftCycles k hk ≫ cyclesMap φ = S₁.liftCycles (k ≫ φ.τ₂) (by rw [assoc, φ.comm₂₃, reassoc_of% hk, zero_comp]) := by aesop_cat variable {S} @[reassoc (attr := simp)] lemma LeftHomologyData.liftCycles_comp_cyclesIso_hom : S.liftCycles k hk ≫ h.cyclesIso.hom = h.liftK k hk := by simp only [← cancel_mono h.i, assoc, LeftHomologyData.cyclesIso_hom_comp_i, liftCycles_i, LeftHomologyData.liftK_i] @[reassoc (attr := simp)] lemma LeftHomologyData.lift_K_comp_cyclesIso_inv : h.liftK k hk ≫ h.cyclesIso.inv = S.liftCycles k hk := by rw [← h.liftCycles_comp_cyclesIso_hom, assoc, Iso.hom_inv_id, comp_id] end namespace HasLeftHomology variable (S) lemma hasKernel [S.HasLeftHomology] : HasKernel S.g := ⟨⟨⟨_, S.leftHomologyData.hi⟩⟩⟩ lemma hasCokernel [S.HasLeftHomology] [HasKernel S.g] : HasCokernel (kernel.lift S.g S.f S.zero) := by let h := S.leftHomologyData haveI : HasColimit (parallelPair h.f' 0) := ⟨⟨⟨_, h.hπ'⟩⟩⟩ let e : parallelPair (kernel.lift S.g S.f S.zero) 0 ≅ parallelPair h.f' 0 := parallelPair.ext (Iso.refl _) (IsLimit.conePointUniqueUpToIso (kernelIsKernel S.g) h.hi) (by aesop_cat) (by aesop_cat) exact hasColimitOfIso e end HasLeftHomology /-- The left homology of a short complex `S` identifies to the cokernel of the canonical morphism `S.X₁ ⟶ kernel S.g`. -/ noncomputable def leftHomologyIsoCokernelLift [S.HasLeftHomology] [HasKernel S.g] [HasCokernel (kernel.lift S.g S.f S.zero)] : S.leftHomology ≅ cokernel (kernel.lift S.g S.f S.zero) := (LeftHomologyData.ofHasKernelOfHasCokernel S).leftHomologyIso /-! The following lemmas and instance gives a sufficient condition for a morphism of short complexes to induce an isomorphism on cycles. -/ lemma isIso_cyclesMap'_of_isIso_of_mono (φ : S₁ ⟶ S₂) (h₂ : IsIso φ.τ₂) (h₃ : Mono φ.τ₃) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : IsIso (cyclesMap' φ h₁ h₂) := by refine ⟨h₁.liftK (h₂.i ≫ inv φ.τ₂) ?_, ?_, ?_⟩ · simp only [assoc, ← cancel_mono φ.τ₃, zero_comp, ← φ.comm₂₃, IsIso.inv_hom_id_assoc, h₂.wi] · simp only [← cancel_mono h₁.i, assoc, h₁.liftK_i, cyclesMap'_i_assoc, IsIso.hom_inv_id, comp_id, id_comp] · simp only [← cancel_mono h₂.i, assoc, cyclesMap'_i, h₁.liftK_i_assoc, IsIso.inv_hom_id, comp_id, id_comp] lemma isIso_cyclesMap_of_isIso_of_mono' (φ : S₁ ⟶ S₂) (h₂ : IsIso φ.τ₂) (h₃ : Mono φ.τ₃) [S₁.HasLeftHomology] [S₂.HasLeftHomology] : IsIso (cyclesMap φ) := isIso_cyclesMap'_of_isIso_of_mono φ h₂ h₃ _ _ instance isIso_cyclesMap_of_isIso_of_mono (φ : S₁ ⟶ S₂) [IsIso φ.τ₂] [Mono φ.τ₃] [S₁.HasLeftHomology] [S₂.HasLeftHomology] : IsIso (cyclesMap φ) := isIso_cyclesMap_of_isIso_of_mono' φ inferInstance inferInstance end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\Limits.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.Basic import Mathlib.CategoryTheory.Limits.Constructions.EpiMono import Mathlib.CategoryTheory.Limits.Shapes.FiniteLimits import Mathlib.CategoryTheory.Limits.Preserves.Finite /-! # Limits and colimits in the category of short complexes In this file, it is shown if a category `C` with zero morphisms has limits of a certain shape `J`, then it is also the case of the category `ShortComplex C`. TODO (@rioujoel): Do the same for colimits. -/ namespace CategoryTheory open Category Limits variable {J C : Type*} [Category J] [Category C] [HasZeroMorphisms C] {F : J ⥤ ShortComplex C} namespace ShortComplex /-- If a cone with values in `ShortComplex C` is such that it becomes limit when we apply the three projections `ShortComplex C ⥤ C`, then it is limit. -/ def isLimitOfIsLimitπ (c : Cone F) (h₁ : IsLimit (π₁.mapCone c)) (h₂ : IsLimit (π₂.mapCone c)) (h₃ : IsLimit (π₃.mapCone c)) : IsLimit c where lift s := { τ₁ := h₁.lift (π₁.mapCone s) τ₂ := h₂.lift (π₂.mapCone s) τ₃ := h₃.lift (π₃.mapCone s) comm₁₂ := h₂.hom_ext (fun j => by have eq₁ := h₁.fac (π₁.mapCone s) have eq₂ := h₂.fac (π₂.mapCone s) have eq₁₂ := fun j => (c.π.app j).comm₁₂ have eq₁₂' := fun j => (s.π.app j).comm₁₂ dsimp at eq₁ eq₂ eq₁₂ eq₁₂' ⊢ rw [assoc, assoc, ← eq₁₂, reassoc_of% eq₁, eq₂, eq₁₂']) comm₂₃ := h₃.hom_ext (fun j => by have eq₂ := h₂.fac (π₂.mapCone s) have eq₃ := h₃.fac (π₃.mapCone s) have eq₂₃ := fun j => (c.π.app j).comm₂₃ have eq₂₃' := fun j => (s.π.app j).comm₂₃ dsimp at eq₂ eq₃ eq₂₃ eq₂₃' ⊢ rw [assoc, assoc, ← eq₂₃, reassoc_of% eq₂, eq₃, eq₂₃']) } fac s j := by ext <;> apply IsLimit.fac uniq s m hm := by ext · exact h₁.uniq (π₁.mapCone s) _ (fun j => π₁.congr_map (hm j)) · exact h₂.uniq (π₂.mapCone s) _ (fun j => π₂.congr_map (hm j)) · exact h₃.uniq (π₃.mapCone s) _ (fun j => π₃.congr_map (hm j)) section variable (F) variable [HasLimit (F ⋙ π₁)] [HasLimit (F ⋙ π₂)] [HasLimit (F ⋙ π₃)] /-- Construction of a limit cone for a functor `J ⥤ ShortComplex C` using the limits of the three components `J ⥤ C`. -/ noncomputable def limitCone : Cone F := Cone.mk (ShortComplex.mk (limMap (whiskerLeft F π₁Toπ₂)) (limMap (whiskerLeft F π₂Toπ₃)) (by aesop_cat)) { app := fun j => Hom.mk (limit.π _ _) (limit.π _ _) (limit.π _ _) (by aesop_cat) (by aesop_cat) naturality := fun _ _ f => by ext all_goals dsimp erw [id_comp, limit.w] } /-- `limitCone F` becomes limit after the application of `π₁ : ShortComplex C ⥤ C`. -/ noncomputable def isLimitπ₁MapConeLimitCone : IsLimit (π₁.mapCone (limitCone F)) := (IsLimit.ofIsoLimit (limit.isLimit _) (Cones.ext (Iso.refl _) (by aesop_cat))) /-- `limitCone F` becomes limit after the application of `π₂ : ShortComplex C ⥤ C`. -/ noncomputable def isLimitπ₂MapConeLimitCone : IsLimit (π₂.mapCone (limitCone F)) := (IsLimit.ofIsoLimit (limit.isLimit _) (Cones.ext (Iso.refl _) (by aesop_cat))) /-- `limitCone F` becomes limit after the application of `π₃ : ShortComplex C ⥤ C`. -/ noncomputable def isLimitπ₃MapConeLimitCone : IsLimit (π₃.mapCone (limitCone F)) := (IsLimit.ofIsoLimit (limit.isLimit _) (Cones.ext (Iso.refl _) (by aesop_cat))) /-- `limitCone F` is limit. -/ noncomputable def isLimitLimitCone : IsLimit (limitCone F) := isLimitOfIsLimitπ _ (isLimitπ₁MapConeLimitCone F) (isLimitπ₂MapConeLimitCone F) (isLimitπ₃MapConeLimitCone F) instance hasLimit_of_hasLimitπ : HasLimit F := ⟨⟨⟨_, isLimitLimitCone _⟩⟩⟩ noncomputable instance : PreservesLimit F π₁ := preservesLimitOfPreservesLimitCone (isLimitLimitCone F) (isLimitπ₁MapConeLimitCone F) noncomputable instance : PreservesLimit F π₂ := preservesLimitOfPreservesLimitCone (isLimitLimitCone F) (isLimitπ₂MapConeLimitCone F) noncomputable instance : PreservesLimit F π₃ := preservesLimitOfPreservesLimitCone (isLimitLimitCone F) (isLimitπ₃MapConeLimitCone F) end section variable [HasLimitsOfShape J C] instance hasLimitsOfShape : HasLimitsOfShape J (ShortComplex C) where noncomputable instance : PreservesLimitsOfShape J (π₁ : _ ⥤ C) where noncomputable instance : PreservesLimitsOfShape J (π₂ : _ ⥤ C) where noncomputable instance : PreservesLimitsOfShape J (π₃ : _ ⥤ C) where end section variable [HasFiniteLimits C] instance hasFiniteLimits : HasFiniteLimits (ShortComplex C) := ⟨fun _ _ _ => inferInstance⟩ noncomputable instance : PreservesFiniteLimits (π₁ : _ ⥤ C) := ⟨fun _ _ _ => inferInstance⟩ noncomputable instance : PreservesFiniteLimits (π₂ : _ ⥤ C) := ⟨fun _ _ _ => inferInstance⟩ noncomputable instance : PreservesFiniteLimits (π₃ : _ ⥤ C) := ⟨fun _ _ _ => inferInstance⟩ end section variable [HasLimitsOfShape WalkingCospan C] instance preservesMonomorphisms_π₁ : Functor.PreservesMonomorphisms (π₁ : _ ⥤ C) := CategoryTheory.preservesMonomorphisms_of_preservesLimitsOfShape _ instance preservesMonomorphisms_π₂ : Functor.PreservesMonomorphisms (π₂ : _ ⥤ C) := CategoryTheory.preservesMonomorphisms_of_preservesLimitsOfShape _ instance preservesMonomorphisms_π₃ : Functor.PreservesMonomorphisms (π₃ : _ ⥤ C) := CategoryTheory.preservesMonomorphisms_of_preservesLimitsOfShape _ end /-- If a cocone with values in `ShortComplex C` is such that it becomes colimit when we apply the three projections `ShortComplex C ⥤ C`, then it is colimit. -/ def isColimitOfIsColimitπ (c : Cocone F) (h₁ : IsColimit (π₁.mapCocone c)) (h₂ : IsColimit (π₂.mapCocone c)) (h₃ : IsColimit (π₃.mapCocone c)) : IsColimit c where desc s := { τ₁ := h₁.desc (π₁.mapCocone s) τ₂ := h₂.desc (π₂.mapCocone s) τ₃ := h₃.desc (π₃.mapCocone s) comm₁₂ := h₁.hom_ext (fun j => by have eq₁ := h₁.fac (π₁.mapCocone s) have eq₂ := h₂.fac (π₂.mapCocone s) have eq₁₂ := fun j => (c.ι.app j).comm₁₂ have eq₁₂' := fun j => (s.ι.app j).comm₁₂ dsimp at eq₁ eq₂ eq₁₂ eq₁₂' ⊢ rw [reassoc_of% (eq₁ j), eq₁₂', reassoc_of% eq₁₂, eq₂]) comm₂₃ := h₂.hom_ext (fun j => by have eq₂ := h₂.fac (π₂.mapCocone s) have eq₃ := h₃.fac (π₃.mapCocone s) have eq₂₃ := fun j => (c.ι.app j).comm₂₃ have eq₂₃' := fun j => (s.ι.app j).comm₂₃ dsimp at eq₂ eq₃ eq₂₃ eq₂₃' ⊢ rw [reassoc_of% (eq₂ j), eq₂₃', reassoc_of% eq₂₃, eq₃]) } fac s j := by ext · apply IsColimit.fac h₁ · apply IsColimit.fac h₂ · apply IsColimit.fac h₃ uniq s m hm := by ext · exact h₁.uniq (π₁.mapCocone s) _ (fun j => π₁.congr_map (hm j)) · exact h₂.uniq (π₂.mapCocone s) _ (fun j => π₂.congr_map (hm j)) · exact h₃.uniq (π₃.mapCocone s) _ (fun j => π₃.congr_map (hm j)) section variable (F) variable [HasColimit (F ⋙ π₁)] [HasColimit (F ⋙ π₂)] [HasColimit (F ⋙ π₃)] /-- Construction of a colimit cocone for a functor `J ⥤ ShortComplex C` using the colimits of the three components `J ⥤ C`. -/ noncomputable def colimitCocone : Cocone F := Cocone.mk (ShortComplex.mk (colimMap (whiskerLeft F π₁Toπ₂)) (colimMap (whiskerLeft F π₂Toπ₃)) (by aesop_cat)) { app := fun j => Hom.mk (colimit.ι (F ⋙ π₁) _) (colimit.ι (F ⋙ π₂) _) (colimit.ι (F ⋙ π₃) _) (by aesop_cat) (by aesop_cat) naturality := fun _ _ f => by ext · dsimp; erw [comp_id, colimit.w (F ⋙ π₁)] · dsimp; erw [comp_id, colimit.w (F ⋙ π₂)] · dsimp; erw [comp_id, colimit.w (F ⋙ π₃)] } /-- `colimitCocone F` becomes colimit after the application of `π₁ : ShortComplex C ⥤ C`. -/ noncomputable def isColimitπ₁MapCoconeColimitCocone : IsColimit (π₁.mapCocone (colimitCocone F)) := (IsColimit.ofIsoColimit (colimit.isColimit _) (Cocones.ext (Iso.refl _) (by aesop_cat))) /-- `colimitCocone F` becomes colimit after the application of `π₂ : ShortComplex C ⥤ C`. -/ noncomputable def isColimitπ₂MapCoconeColimitCocone : IsColimit (π₂.mapCocone (colimitCocone F)) := (IsColimit.ofIsoColimit (colimit.isColimit _) (Cocones.ext (Iso.refl _) (by aesop_cat))) /-- `colimitCocone F` becomes colimit after the application of `π₃ : ShortComplex C ⥤ C`. -/ noncomputable def isColimitπ₃MapCoconeColimitCocone : IsColimit (π₃.mapCocone (colimitCocone F)) := (IsColimit.ofIsoColimit (colimit.isColimit _) (Cocones.ext (Iso.refl _) (by aesop_cat))) /-- `colimitCocone F` is colimit. -/ noncomputable def isColimitColimitCocone : IsColimit (colimitCocone F) := isColimitOfIsColimitπ _ (isColimitπ₁MapCoconeColimitCocone F) (isColimitπ₂MapCoconeColimitCocone F) (isColimitπ₃MapCoconeColimitCocone F) instance hasColimit_of_hasColimitπ : HasColimit F := ⟨⟨⟨_, isColimitColimitCocone _⟩⟩⟩ noncomputable instance : PreservesColimit F π₁ := preservesColimitOfPreservesColimitCocone (isColimitColimitCocone F) (isColimitπ₁MapCoconeColimitCocone F) noncomputable instance : PreservesColimit F π₂ := preservesColimitOfPreservesColimitCocone (isColimitColimitCocone F) (isColimitπ₂MapCoconeColimitCocone F) noncomputable instance : PreservesColimit F π₃ := preservesColimitOfPreservesColimitCocone (isColimitColimitCocone F) (isColimitπ₃MapCoconeColimitCocone F) end section variable [HasColimitsOfShape J C] instance hasColimitsOfShape : HasColimitsOfShape J (ShortComplex C) where noncomputable instance : PreservesColimitsOfShape J (π₁ : _ ⥤ C) where noncomputable instance : PreservesColimitsOfShape J (π₂ : _ ⥤ C) where noncomputable instance : PreservesColimitsOfShape J (π₃ : _ ⥤ C) where end section variable [HasFiniteColimits C] instance hasFiniteColimits : HasFiniteColimits (ShortComplex C) := ⟨fun _ _ _ => inferInstance⟩ noncomputable instance : PreservesFiniteColimits (π₁ : _ ⥤ C) := ⟨fun _ _ _ => inferInstance⟩ noncomputable instance : PreservesFiniteColimits (π₂ : _ ⥤ C) := ⟨fun _ _ _ => inferInstance⟩ noncomputable instance : PreservesFiniteColimits (π₃ : _ ⥤ C) := ⟨fun _ _ _ => inferInstance⟩ end section variable [HasColimitsOfShape WalkingSpan C] instance preservesEpimorphisms_π₁ : Functor.PreservesEpimorphisms (π₁ : _ ⥤ C) := CategoryTheory.preservesEpimorphisms_of_preservesColimitsOfShape _ instance preservesEpimorphisms_π₂ : Functor.PreservesEpimorphisms (π₂ : _ ⥤ C) := CategoryTheory.preservesEpimorphisms_of_preservesColimitsOfShape _ instance preservesEpimorphisms_π₃ : Functor.PreservesEpimorphisms (π₃ : _ ⥤ C) := CategoryTheory.preservesEpimorphisms_of_preservesColimitsOfShape _ end end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\Linear.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.Preadditive import Mathlib.CategoryTheory.Linear.LinearFunctor /-! # Homology of linear categories In this file, it is shown that if `C` is a `R`-linear category, then `ShortComplex C` is a `R`-linear category. Various homological notions are also shown to be linear. -/ namespace CategoryTheory open Category Limits variable {R C : Type*} [Semiring R] [Category C] [Preadditive C] [Linear R C] namespace ShortComplex variable {S₁ S₂ : ShortComplex C} attribute [local simp] Hom.comm₁₂ Hom.comm₂₃ mul_smul add_smul instance : SMul R (S₁ ⟶ S₂) where smul a φ := { τ₁ := a • φ.τ₁ τ₂ := a • φ.τ₂ τ₃ := a • φ.τ₃ } @[simp] lemma smul_τ₁ (a : R) (φ : S₁ ⟶ S₂) : (a • φ).τ₁ = a • φ.τ₁ := rfl @[simp] lemma smul_τ₂ (a : R) (φ : S₁ ⟶ S₂) : (a • φ).τ₂ = a • φ.τ₂ := rfl @[simp] lemma smul_τ₃ (a : R) (φ : S₁ ⟶ S₂) : (a • φ).τ₃ = a • φ.τ₃ := rfl instance : Module R (S₁ ⟶ S₂) where zero_smul := by aesop_cat one_smul := by aesop_cat smul_zero := by aesop_cat smul_add := by aesop_cat add_smul := by aesop_cat mul_smul := by aesop_cat instance : Linear R (ShortComplex C) where section LeftHomology variable {φ φ' : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} namespace LeftHomologyMapData variable (γ : LeftHomologyMapData φ h₁ h₂) /-- Given a left homology map data for morphism `φ`, this is the induced left homology map data for `a • φ`. -/ @[simps] def smul (a : R) : LeftHomologyMapData (a • φ) h₁ h₂ where φK := a • γ.φK φH := a • γ.φH end LeftHomologyMapData variable (h₁ h₂ φ) variable (a : R) @[simp] lemma leftHomologyMap'_smul : leftHomologyMap' (a • φ) h₁ h₂ = a • leftHomologyMap' φ h₁ h₂ := by have γ : LeftHomologyMapData φ h₁ h₂ := default simp only [(γ.smul a).leftHomologyMap'_eq, LeftHomologyMapData.smul_φH, γ.leftHomologyMap'_eq] @[simp] lemma cyclesMap'_smul : cyclesMap' (a • φ) h₁ h₂ = a • cyclesMap' φ h₁ h₂ := by have γ : LeftHomologyMapData φ h₁ h₂ := default simp only [(γ.smul a).cyclesMap'_eq, LeftHomologyMapData.smul_φK, γ.cyclesMap'_eq] section variable [S₁.HasLeftHomology] [S₂.HasLeftHomology] @[simp] lemma leftHomologyMap_smul : leftHomologyMap (a • φ) = a • leftHomologyMap φ := leftHomologyMap'_smul _ _ _ _ @[simp] lemma cyclesMap_smul : cyclesMap (a • φ) = a • cyclesMap φ := cyclesMap'_smul _ _ _ _ end instance leftHomologyFunctor_linear [HasKernels C] [HasCokernels C] : Functor.Linear R (leftHomologyFunctor C) where instance cyclesFunctor_linear [HasKernels C] [HasCokernels C] : Functor.Linear R (cyclesFunctor C) where end LeftHomology section RightHomology variable {φ φ' : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} namespace RightHomologyMapData variable (γ : RightHomologyMapData φ h₁ h₂) /-- Given a right homology map data for morphism `φ`, this is the induced right homology map data for `a • φ`. -/ @[simps] def smul (a : R) : RightHomologyMapData (a • φ) h₁ h₂ where φQ := a • γ.φQ φH := a • γ.φH end RightHomologyMapData variable (h₁ h₂ φ) variable (a : R) @[simp] lemma rightHomologyMap'_smul : rightHomologyMap' (a • φ) h₁ h₂ = a • rightHomologyMap' φ h₁ h₂ := by have γ : RightHomologyMapData φ h₁ h₂ := default simp only [(γ.smul a).rightHomologyMap'_eq, RightHomologyMapData.smul_φH, γ.rightHomologyMap'_eq] @[simp] lemma opcyclesMap'_smul : opcyclesMap' (a • φ) h₁ h₂ = a • opcyclesMap' φ h₁ h₂ := by have γ : RightHomologyMapData φ h₁ h₂ := default simp only [(γ.smul a).opcyclesMap'_eq, RightHomologyMapData.smul_φQ, γ.opcyclesMap'_eq] section variable [S₁.HasRightHomology] [S₂.HasRightHomology] @[simp] lemma rightHomologyMap_smul : rightHomologyMap (a • φ) = a • rightHomologyMap φ := rightHomologyMap'_smul _ _ _ _ @[simp] lemma opcyclesMap_smul : opcyclesMap (a • φ) = a • opcyclesMap φ := opcyclesMap'_smul _ _ _ _ end instance rightHomologyFunctor_linear [HasKernels C] [HasCokernels C] : Functor.Linear R (rightHomologyFunctor C) where instance opcyclesFunctor_linear [HasKernels C] [HasCokernels C] : Functor.Linear R (opcyclesFunctor C) where end RightHomology section Homology variable {φ φ' : S₁ ⟶ S₂} {h₁ : S₁.HomologyData} {h₂ : S₂.HomologyData} namespace HomologyMapData variable (γ : HomologyMapData φ h₁ h₂) (γ' : HomologyMapData φ' h₁ h₂) /-- Given a homology map data for a morphism `φ`, this is the induced homology map data for `a • φ`. -/ @[simps] def smul (a : R) : HomologyMapData (a • φ) h₁ h₂ where left := γ.left.smul a right := γ.right.smul a end HomologyMapData variable (h₁ h₂) variable (a : R) @[simp] lemma homologyMap'_smul : homologyMap' (a • φ) h₁ h₂ = a • homologyMap' φ h₁ h₂ := leftHomologyMap'_smul _ _ _ _ variable (φ φ') @[simp] lemma homologyMap_smul [S₁.HasHomology] [S₂.HasHomology] : homologyMap (a • φ) = a • homologyMap φ := homologyMap'_smul _ _ _ instance homologyFunctor_linear [CategoryWithHomology C] : Functor.Linear R (homologyFunctor C) where end Homology /-- Homotopy between morphisms of short complexes is compatible with the scalar multiplication. -/ @[simps] def Homotopy.smul {φ₁ φ₂ : S₁ ⟶ S₂} (h : Homotopy φ₁ φ₂) (a : R) : Homotopy (a • φ₁) (a • φ₂) where h₀ := a • h.h₀ h₁ := a • h.h₁ h₂ := a • h.h₂ h₃ := a • h.h₃ comm₁ := by dsimp rw [h.comm₁] simp only [smul_add, Linear.comp_smul] comm₂ := by dsimp rw [h.comm₂] simp only [smul_add, Linear.comp_smul, Linear.smul_comp] comm₃ := by dsimp rw [h.comm₃] simp only [smul_add, Linear.smul_comp] end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\ModuleCat.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.ConcreteCategory import Mathlib.Algebra.Category.ModuleCat.Colimits /-! # Homology and exactness of short complexes of modules In this file, the homology of a short complex `S` of abelian groups is identified with the quotient of `LinearMap.ker S.g` by the image of the morphism `S.moduleCatToCycles : S.X₁ →ₗ[R] LinearMap.ker S.g` induced by `S.f`. -/ universe v u variable {R : Type u} [Ring R] namespace CategoryTheory open Limits namespace ShortComplex noncomputable instance : (forget₂ (ModuleCat.{v} R) Ab).PreservesHomology where /-- Constructor for short complexes in `ModuleCat.{v} R` taking as inputs linear maps `f` and `g` and the vanishing of their composition. -/ @[simps] def moduleCatMk {X₁ X₂ X₃ : Type v} [AddCommGroup X₁] [AddCommGroup X₂] [AddCommGroup X₃] [Module R X₁] [Module R X₂] [Module R X₃] (f : X₁ →ₗ[R] X₂) (g : X₂ →ₗ[R] X₃) (hfg : g.comp f = 0) : ShortComplex (ModuleCat.{v} R) := ShortComplex.mk (ModuleCat.ofHom f) (ModuleCat.ofHom g) hfg variable (S : ShortComplex (ModuleCat.{v} R)) @[simp] lemma moduleCat_zero_apply (x : S.X₁) : S.g (S.f x) = 0 := S.zero_apply x lemma moduleCat_exact_iff : S.Exact ↔ ∀ (x₂ : S.X₂) (_ : S.g x₂ = 0), ∃ (x₁ : S.X₁), S.f x₁ = x₂ := S.exact_iff_of_concreteCategory lemma moduleCat_exact_iff_ker_sub_range : S.Exact ↔ LinearMap.ker S.g ≤ LinearMap.range S.f := by rw [moduleCat_exact_iff] constructor · intro h x₂ hx₂ exact h x₂ hx₂ · intro h x₂ hx₂ exact h hx₂ lemma moduleCat_exact_iff_range_eq_ker : S.Exact ↔ LinearMap.range S.f = LinearMap.ker S.g := by rw [moduleCat_exact_iff_ker_sub_range] constructor · intro h ext x constructor · rintro ⟨y, hy⟩ rw [← hy] simp only [LinearMap.mem_ker, moduleCat_zero_apply] · intro hx exact h hx · intro h rw [h] variable {S} lemma Exact.moduleCat_range_eq_ker (hS : S.Exact) : LinearMap.range S.f = LinearMap.ker S.g := by simpa only [moduleCat_exact_iff_range_eq_ker] using hS lemma ShortExact.moduleCat_injective_f (hS : S.ShortExact) : Function.Injective S.f := hS.injective_f lemma ShortExact.moduleCat_surjective_g (hS : S.ShortExact) : Function.Surjective S.g := hS.surjective_g variable (S) lemma ShortExact.moduleCat_exact_iff_function_exact : S.Exact ↔ Function.Exact S.f S.g := by rw [moduleCat_exact_iff_range_eq_ker, LinearMap.exact_iff] tauto /-- Constructor for short complexes in `ModuleCat.{v} R` taking as inputs morphisms `f` and `g` and the assumption `LinearMap.range f ≤ LinearMap.ker g`. -/ @[simps] def moduleCatMkOfKerLERange {X₁ X₂ X₃ : ModuleCat.{v} R} (f : X₁ ⟶ X₂) (g : X₂ ⟶ X₃) (hfg : LinearMap.range f ≤ LinearMap.ker g) : ShortComplex (ModuleCat.{v} R) := ShortComplex.mk f g (by ext exact hfg ⟨_, rfl⟩) lemma Exact.moduleCat_of_range_eq_ker {X₁ X₂ X₃ : ModuleCat.{v} R} (f : X₁ ⟶ X₂) (g : X₂ ⟶ X₃) (hfg : LinearMap.range f = LinearMap.ker g) : (moduleCatMkOfKerLERange f g (by rw [hfg])).Exact := by simpa only [moduleCat_exact_iff_range_eq_ker] using hfg /-- The canonical linear map `S.X₁ →ₗ[R] LinearMap.ker S.g` induced by `S.f`. -/ @[simps] def moduleCatToCycles : S.X₁ →ₗ[R] LinearMap.ker S.g where toFun x := ⟨S.f x, S.moduleCat_zero_apply x⟩ map_add' x y := by aesop map_smul' a x := by aesop /-- The homology of `S`, defined as the quotient of the kernel of `S.g` by the image of `S.moduleCatToCycles` -/ abbrev moduleCatHomology := ModuleCat.of R (LinearMap.ker S.g ⧸ LinearMap.range S.moduleCatToCycles) /-- The canonical map `ModuleCat.of R (LinearMap.ker S.g) ⟶ S.moduleCatHomology`. -/ abbrev moduleCatHomologyπ : ModuleCat.of R (LinearMap.ker S.g) ⟶ S.moduleCatHomology := (LinearMap.range S.moduleCatToCycles).mkQ /-- The explicit left homology data of a short complex of modules that is given by a kernel and a quotient given by the `LinearMap` API. -/ @[simps] def moduleCatLeftHomologyData : S.LeftHomologyData where K := ModuleCat.of R (LinearMap.ker S.g) H := S.moduleCatHomology i := (LinearMap.ker S.g).subtype π := S.moduleCatHomologyπ wi := by ext ⟨_, hx⟩ exact hx hi := ModuleCat.kernelIsLimit _ wπ := by ext (x : S.X₁) dsimp erw [Submodule.Quotient.mk_eq_zero] rw [LinearMap.mem_range] apply exists_apply_eq_apply hπ := ModuleCat.cokernelIsColimit (ModuleCat.ofHom S.moduleCatToCycles) @[simp] lemma moduleCatLeftHomologyData_f' : S.moduleCatLeftHomologyData.f' = S.moduleCatToCycles := rfl instance : Epi S.moduleCatHomologyπ := (inferInstance : Epi S.moduleCatLeftHomologyData.π) /-- Given a short complex `S` of modules, this is the isomorphism between the abstract `S.cycles` of the homology API and the more concrete description as `LinearMap.ker S.g`. -/ noncomputable def moduleCatCyclesIso : S.cycles ≅ ModuleCat.of R (LinearMap.ker S.g) := S.moduleCatLeftHomologyData.cyclesIso @[reassoc (attr := simp, elementwise)] lemma moduleCatCyclesIso_hom_subtype : S.moduleCatCyclesIso.hom ≫ (LinearMap.ker S.g).subtype = S.iCycles := S.moduleCatLeftHomologyData.cyclesIso_hom_comp_i @[reassoc (attr := simp, elementwise)] lemma moduleCatCyclesIso_inv_iCycles : S.moduleCatCyclesIso.inv ≫ S.iCycles = (LinearMap.ker S.g).subtype := S.moduleCatLeftHomologyData.cyclesIso_inv_comp_iCycles @[reassoc (attr := simp, elementwise)] lemma toCycles_moduleCatCyclesIso_hom : S.toCycles ≫ S.moduleCatCyclesIso.hom = S.moduleCatToCycles := by rw [← cancel_mono S.moduleCatLeftHomologyData.i, moduleCatLeftHomologyData_i, Category.assoc, S.moduleCatCyclesIso_hom_subtype, toCycles_i] rfl /-- Given a short complex `S` of modules, this is the isomorphism between the abstract `S.homology` of the homology API and the more explicit quotient of `LinearMap.ker S.g` by the image of `S.moduleCatToCycles : S.X₁ →ₗ[R] LinearMap.ker S.g`. -/ noncomputable def moduleCatHomologyIso : S.homology ≅ S.moduleCatHomology := S.moduleCatLeftHomologyData.homologyIso @[reassoc (attr := simp, elementwise)] lemma π_moduleCatCyclesIso_hom : S.homologyπ ≫ S.moduleCatHomologyIso.hom = S.moduleCatCyclesIso.hom ≫ S.moduleCatHomologyπ := S.moduleCatLeftHomologyData.homologyπ_comp_homologyIso_hom @[reassoc (attr := simp, elementwise)] lemma moduleCatCyclesIso_inv_π : S.moduleCatCyclesIso.inv ≫ S.homologyπ = S.moduleCatHomologyπ ≫ S.moduleCatHomologyIso.inv := S.moduleCatLeftHomologyData.π_comp_homologyIso_inv lemma exact_iff_surjective_moduleCatToCycles : S.Exact ↔ Function.Surjective S.moduleCatToCycles := by rw [S.moduleCatLeftHomologyData.exact_iff_epi_f', moduleCatLeftHomologyData_f', ModuleCat.epi_iff_surjective] rfl end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\Preadditive.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.Homology import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.CategoryTheory.Preadditive.Opposite /-! # Homology of preadditive categories In this file, it is shown that if `C` is a preadditive category, then `ShortComplex C` is a preadditive category. -/ namespace CategoryTheory open Category Limits Preadditive variable {C : Type*} [Category C] [Preadditive C] namespace ShortComplex variable {S₁ S₂ S₃ : ShortComplex C} attribute [local simp] Hom.comm₁₂ Hom.comm₂₃ instance : Add (S₁ ⟶ S₂) where add φ φ' := { τ₁ := φ.τ₁ + φ'.τ₁ τ₂ := φ.τ₂ + φ'.τ₂ τ₃ := φ.τ₃ + φ'.τ₃ } instance : Sub (S₁ ⟶ S₂) where sub φ φ' := { τ₁ := φ.τ₁ - φ'.τ₁ τ₂ := φ.τ₂ - φ'.τ₂ τ₃ := φ.τ₃ - φ'.τ₃ } instance : Neg (S₁ ⟶ S₂) where neg φ := { τ₁ := -φ.τ₁ τ₂ := -φ.τ₂ τ₃ := -φ.τ₃ } instance : AddCommGroup (S₁ ⟶ S₂) where add_assoc := fun a b c => by ext <;> apply add_assoc add_zero := fun a => by ext <;> apply add_zero zero_add := fun a => by ext <;> apply zero_add add_left_neg := fun a => by ext <;> apply add_left_neg add_comm := fun a b => by ext <;> apply add_comm sub_eq_add_neg := fun a b => by ext <;> apply sub_eq_add_neg nsmul := nsmulRec zsmul := zsmulRec @[simp] lemma add_τ₁ (φ φ' : S₁ ⟶ S₂) : (φ + φ').τ₁ = φ.τ₁ + φ'.τ₁ := rfl @[simp] lemma add_τ₂ (φ φ' : S₁ ⟶ S₂) : (φ + φ').τ₂ = φ.τ₂ + φ'.τ₂ := rfl @[simp] lemma add_τ₃ (φ φ' : S₁ ⟶ S₂) : (φ + φ').τ₃ = φ.τ₃ + φ'.τ₃ := rfl @[simp] lemma sub_τ₁ (φ φ' : S₁ ⟶ S₂) : (φ - φ').τ₁ = φ.τ₁ - φ'.τ₁ := rfl @[simp] lemma sub_τ₂ (φ φ' : S₁ ⟶ S₂) : (φ - φ').τ₂ = φ.τ₂ - φ'.τ₂ := rfl @[simp] lemma sub_τ₃ (φ φ' : S₁ ⟶ S₂) : (φ - φ').τ₃ = φ.τ₃ - φ'.τ₃ := rfl @[simp] lemma neg_τ₁ (φ : S₁ ⟶ S₂) : (-φ).τ₁ = -φ.τ₁ := rfl @[simp] lemma neg_τ₂ (φ : S₁ ⟶ S₂) : (-φ).τ₂ = -φ.τ₂ := rfl @[simp] lemma neg_τ₃ (φ : S₁ ⟶ S₂) : (-φ).τ₃ = -φ.τ₃ := rfl instance : Preadditive (ShortComplex C) where section LeftHomology variable {φ φ' : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} namespace LeftHomologyMapData variable (γ : LeftHomologyMapData φ h₁ h₂) (γ' : LeftHomologyMapData φ' h₁ h₂) /-- Given a left homology map data for morphism `φ`, this is the induced left homology map data for `-φ`. -/ @[simps] def neg : LeftHomologyMapData (-φ) h₁ h₂ where φK := -γ.φK φH := -γ.φH /-- Given left homology map data for morphisms `φ` and `φ'`, this is the induced left homology map data for `φ + φ'`. -/ @[simps] def add : LeftHomologyMapData (φ + φ') h₁ h₂ where φK := γ.φK + γ'.φK φH := γ.φH + γ'.φH end LeftHomologyMapData variable (h₁ h₂) @[simp] lemma leftHomologyMap'_neg : leftHomologyMap' (-φ) h₁ h₂ = -leftHomologyMap' φ h₁ h₂ := by have γ : LeftHomologyMapData φ h₁ h₂ := default simp only [γ.leftHomologyMap'_eq, γ.neg.leftHomologyMap'_eq, LeftHomologyMapData.neg_φH] @[simp] lemma cyclesMap'_neg : cyclesMap' (-φ) h₁ h₂ = -cyclesMap' φ h₁ h₂ := by have γ : LeftHomologyMapData φ h₁ h₂ := default simp only [γ.cyclesMap'_eq, γ.neg.cyclesMap'_eq, LeftHomologyMapData.neg_φK] @[simp] lemma leftHomologyMap'_add : leftHomologyMap' (φ + φ') h₁ h₂ = leftHomologyMap' φ h₁ h₂ + leftHomologyMap' φ' h₁ h₂ := by have γ : LeftHomologyMapData φ h₁ h₂ := default have γ' : LeftHomologyMapData φ' h₁ h₂ := default simp only [γ.leftHomologyMap'_eq, γ'.leftHomologyMap'_eq, (γ.add γ').leftHomologyMap'_eq, LeftHomologyMapData.add_φH] @[simp] lemma cyclesMap'_add : cyclesMap' (φ + φ') h₁ h₂ = cyclesMap' φ h₁ h₂ + cyclesMap' φ' h₁ h₂ := by have γ : LeftHomologyMapData φ h₁ h₂ := default have γ' : LeftHomologyMapData φ' h₁ h₂ := default simp only [γ.cyclesMap'_eq, γ'.cyclesMap'_eq, (γ.add γ').cyclesMap'_eq, LeftHomologyMapData.add_φK] @[simp] lemma leftHomologyMap'_sub : leftHomologyMap' (φ - φ') h₁ h₂ = leftHomologyMap' φ h₁ h₂ - leftHomologyMap' φ' h₁ h₂ := by simp only [sub_eq_add_neg, leftHomologyMap'_add, leftHomologyMap'_neg] @[simp] lemma cyclesMap'_sub : cyclesMap' (φ - φ') h₁ h₂ = cyclesMap' φ h₁ h₂ - cyclesMap' φ' h₁ h₂ := by simp only [sub_eq_add_neg, cyclesMap'_add, cyclesMap'_neg] variable (φ φ') section variable [S₁.HasLeftHomology] [S₂.HasLeftHomology] @[simp] lemma leftHomologyMap_neg : leftHomologyMap (-φ) = -leftHomologyMap φ := leftHomologyMap'_neg _ _ @[simp] lemma cyclesMap_neg : cyclesMap (-φ) = -cyclesMap φ := cyclesMap'_neg _ _ @[simp] lemma leftHomologyMap_add : leftHomologyMap (φ + φ') = leftHomologyMap φ + leftHomologyMap φ' := leftHomologyMap'_add _ _ @[simp] lemma cyclesMap_add : cyclesMap (φ + φ') = cyclesMap φ + cyclesMap φ' := cyclesMap'_add _ _ @[simp] lemma leftHomologyMap_sub : leftHomologyMap (φ - φ') = leftHomologyMap φ - leftHomologyMap φ' := leftHomologyMap'_sub _ _ @[simp] lemma cyclesMap_sub : cyclesMap (φ - φ') = cyclesMap φ - cyclesMap φ' := cyclesMap'_sub _ _ end instance leftHomologyFunctor_additive [HasKernels C] [HasCokernels C] : (leftHomologyFunctor C).Additive where instance cyclesFunctor_additive [HasKernels C] [HasCokernels C] : (cyclesFunctor C).Additive where end LeftHomology section RightHomology variable {φ φ' : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} namespace RightHomologyMapData variable (γ : RightHomologyMapData φ h₁ h₂) (γ' : RightHomologyMapData φ' h₁ h₂) /-- Given a right homology map data for morphism `φ`, this is the induced right homology map data for `-φ`. -/ @[simps] def neg : RightHomologyMapData (-φ) h₁ h₂ where φQ := -γ.φQ φH := -γ.φH /-- Given right homology map data for morphisms `φ` and `φ'`, this is the induced right homology map data for `φ + φ'`. -/ @[simps] def add : RightHomologyMapData (φ + φ') h₁ h₂ where φQ := γ.φQ + γ'.φQ φH := γ.φH + γ'.φH end RightHomologyMapData variable (h₁ h₂) @[simp] lemma rightHomologyMap'_neg : rightHomologyMap' (-φ) h₁ h₂ = -rightHomologyMap' φ h₁ h₂ := by have γ : RightHomologyMapData φ h₁ h₂ := default simp only [γ.rightHomologyMap'_eq, γ.neg.rightHomologyMap'_eq, RightHomologyMapData.neg_φH] @[simp] lemma opcyclesMap'_neg : opcyclesMap' (-φ) h₁ h₂ = -opcyclesMap' φ h₁ h₂ := by have γ : RightHomologyMapData φ h₁ h₂ := default simp only [γ.opcyclesMap'_eq, γ.neg.opcyclesMap'_eq, RightHomologyMapData.neg_φQ] @[simp] lemma rightHomologyMap'_add : rightHomologyMap' (φ + φ') h₁ h₂ = rightHomologyMap' φ h₁ h₂ + rightHomologyMap' φ' h₁ h₂ := by have γ : RightHomologyMapData φ h₁ h₂ := default have γ' : RightHomologyMapData φ' h₁ h₂ := default simp only [γ.rightHomologyMap'_eq, γ'.rightHomologyMap'_eq, (γ.add γ').rightHomologyMap'_eq, RightHomologyMapData.add_φH] @[simp] lemma opcyclesMap'_add : opcyclesMap' (φ + φ') h₁ h₂ = opcyclesMap' φ h₁ h₂ + opcyclesMap' φ' h₁ h₂ := by have γ : RightHomologyMapData φ h₁ h₂ := default have γ' : RightHomologyMapData φ' h₁ h₂ := default simp only [γ.opcyclesMap'_eq, γ'.opcyclesMap'_eq, (γ.add γ').opcyclesMap'_eq, RightHomologyMapData.add_φQ] @[simp] lemma rightHomologyMap'_sub : rightHomologyMap' (φ - φ') h₁ h₂ = rightHomologyMap' φ h₁ h₂ - rightHomologyMap' φ' h₁ h₂ := by simp only [sub_eq_add_neg, rightHomologyMap'_add, rightHomologyMap'_neg] @[simp] lemma opcyclesMap'_sub : opcyclesMap' (φ - φ') h₁ h₂ = opcyclesMap' φ h₁ h₂ - opcyclesMap' φ' h₁ h₂ := by simp only [sub_eq_add_neg, opcyclesMap'_add, opcyclesMap'_neg] variable (φ φ') section variable [S₁.HasRightHomology] [S₂.HasRightHomology] @[simp] lemma rightHomologyMap_neg : rightHomologyMap (-φ) = -rightHomologyMap φ := rightHomologyMap'_neg _ _ @[simp] lemma opcyclesMap_neg : opcyclesMap (-φ) = -opcyclesMap φ := opcyclesMap'_neg _ _ @[simp] lemma rightHomologyMap_add : rightHomologyMap (φ + φ') = rightHomologyMap φ + rightHomologyMap φ' := rightHomologyMap'_add _ _ @[simp] lemma opcyclesMap_add : opcyclesMap (φ + φ') = opcyclesMap φ + opcyclesMap φ' := opcyclesMap'_add _ _ @[simp] lemma rightHomologyMap_sub : rightHomologyMap (φ - φ') = rightHomologyMap φ - rightHomologyMap φ' := rightHomologyMap'_sub _ _ @[simp] lemma opcyclesMap_sub : opcyclesMap (φ - φ') = opcyclesMap φ - opcyclesMap φ' := opcyclesMap'_sub _ _ end instance rightHomologyFunctor_additive [HasKernels C] [HasCokernels C] : (rightHomologyFunctor C).Additive where instance opcyclesFunctor_additive [HasKernels C] [HasCokernels C] : (opcyclesFunctor C).Additive where end RightHomology section Homology variable {φ φ' : S₁ ⟶ S₂} {h₁ : S₁.HomologyData} {h₂ : S₂.HomologyData} namespace HomologyMapData variable (γ : HomologyMapData φ h₁ h₂) (γ' : HomologyMapData φ' h₁ h₂) /-- Given a homology map data for a morphism `φ`, this is the induced homology map data for `-φ`. -/ @[simps] def neg : HomologyMapData (-φ) h₁ h₂ where left := γ.left.neg right := γ.right.neg /-- Given homology map data for morphisms `φ` and `φ'`, this is the induced homology map data for `φ + φ'`. -/ @[simps] def add : HomologyMapData (φ + φ') h₁ h₂ where left := γ.left.add γ'.left right := γ.right.add γ'.right end HomologyMapData variable (h₁ h₂) @[simp] lemma homologyMap'_neg : homologyMap' (-φ) h₁ h₂ = -homologyMap' φ h₁ h₂ := leftHomologyMap'_neg _ _ @[simp] lemma homologyMap'_add : homologyMap' (φ + φ') h₁ h₂ = homologyMap' φ h₁ h₂ + homologyMap' φ' h₁ h₂ := leftHomologyMap'_add _ _ @[simp] lemma homologyMap'_sub : homologyMap' (φ - φ') h₁ h₂ = homologyMap' φ h₁ h₂ - homologyMap' φ' h₁ h₂ := leftHomologyMap'_sub _ _ variable (φ φ') section variable [S₁.HasHomology] [S₂.HasHomology] @[simp] lemma homologyMap_neg : homologyMap (-φ) = -homologyMap φ := homologyMap'_neg _ _ @[simp] lemma homologyMap_add : homologyMap (φ + φ') = homologyMap φ + homologyMap φ' := homologyMap'_add _ _ @[simp] lemma homologyMap_sub : homologyMap (φ - φ') = homologyMap φ - homologyMap φ' := homologyMap'_sub _ _ end instance homologyFunctor_additive [CategoryWithHomology C] : (homologyFunctor C).Additive where end Homology section Homotopy variable (φ₁ φ₂ φ₃ φ₄ : S₁ ⟶ S₂) /-- A homotopy between two morphisms of short complexes `S₁ ⟶ S₂` consists of various maps and conditions which will be sufficient to show that they induce the same morphism in homology. -/ @[ext] structure Homotopy where /-- a morphism `S₁.X₁ ⟶ S₂.X₁` -/ h₀ : S₁.X₁ ⟶ S₂.X₁ h₀_f : h₀ ≫ S₂.f = 0 := by aesop_cat /-- a morphism `S₁.X₂ ⟶ S₂.X₁` -/ h₁ : S₁.X₂ ⟶ S₂.X₁ /-- a morphism `S₁.X₃ ⟶ S₂.X₂` -/ h₂ : S₁.X₃ ⟶ S₂.X₂ /-- a morphism `S₁.X₃ ⟶ S₂.X₃` -/ h₃ : S₁.X₃ ⟶ S₂.X₃ g_h₃ : S₁.g ≫ h₃ = 0 := by aesop_cat comm₁ : φ₁.τ₁ = S₁.f ≫ h₁ + h₀ + φ₂.τ₁ := by aesop_cat comm₂ : φ₁.τ₂ = S₁.g ≫ h₂ + h₁ ≫ S₂.f + φ₂.τ₂ := by aesop_cat comm₃ : φ₁.τ₃ = h₃ + h₂ ≫ S₂.g + φ₂.τ₃ := by aesop_cat attribute [reassoc (attr := simp)] Homotopy.h₀_f Homotopy.g_h₃ variable (S₁ S₂) /-- Constructor for null homotopic morphisms, see also `Homotopy.ofNullHomotopic` and `Homotopy.eq_add_nullHomotopic`. -/ @[simps] def nullHomotopic (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : S₁ ⟶ S₂ where τ₁ := h₀ + S₁.f ≫ h₁ τ₂ := h₁ ≫ S₂.f + S₁.g ≫ h₂ τ₃ := h₂ ≫ S₂.g + h₃ namespace Homotopy attribute [local simp] neg_comp variable {S₁ S₂ φ₁ φ₂ φ₃ φ₄} /-- The obvious homotopy between two equal morphisms of short complexes. -/ @[simps] def ofEq (h : φ₁ = φ₂) : Homotopy φ₁ φ₂ where h₀ := 0 h₁ := 0 h₂ := 0 h₃ := 0 /-- The obvious homotopy between a morphism of short complexes and itself. -/ @[simps!] def refl (φ : S₁ ⟶ S₂) : Homotopy φ φ := ofEq rfl /-- The symmetry of homotopy between morphisms of short complexes. -/ @[simps] def symm (h : Homotopy φ₁ φ₂) : Homotopy φ₂ φ₁ where h₀ := -h.h₀ h₁ := -h.h₁ h₂ := -h.h₂ h₃ := -h.h₃ comm₁ := by rw [h.comm₁, comp_neg]; abel comm₂ := by rw [h.comm₂, comp_neg, neg_comp]; abel comm₃ := by rw [h.comm₃, neg_comp]; abel /-- If two maps of short complexes are homotopic, their opposites also are. -/ @[simps] def neg (h : Homotopy φ₁ φ₂) : Homotopy (-φ₁) (-φ₂) where h₀ := -h.h₀ h₁ := -h.h₁ h₂ := -h.h₂ h₃ := -h.h₃ comm₁ := by rw [neg_τ₁, neg_τ₁, h.comm₁, neg_add_rev, comp_neg]; abel comm₂ := by rw [neg_τ₂, neg_τ₂, h.comm₂, neg_add_rev, comp_neg, neg_comp]; abel comm₃ := by rw [neg_τ₃, neg_τ₃, h.comm₃, neg_comp]; abel /-- The transitivity of homotopy between morphisms of short complexes. -/ @[simps] def trans (h₁₂ : Homotopy φ₁ φ₂) (h₂₃ : Homotopy φ₂ φ₃) : Homotopy φ₁ φ₃ where h₀ := h₁₂.h₀ + h₂₃.h₀ h₁ := h₁₂.h₁ + h₂₃.h₁ h₂ := h₁₂.h₂ + h₂₃.h₂ h₃ := h₁₂.h₃ + h₂₃.h₃ comm₁ := by rw [h₁₂.comm₁, h₂₃.comm₁, comp_add]; abel comm₂ := by rw [h₁₂.comm₂, h₂₃.comm₂, comp_add, add_comp]; abel comm₃ := by rw [h₁₂.comm₃, h₂₃.comm₃, add_comp]; abel /-- Homotopy between morphisms of short complexes is compatible with addition. -/ @[simps] def add (h : Homotopy φ₁ φ₂) (h' : Homotopy φ₃ φ₄) : Homotopy (φ₁ + φ₃) (φ₂ + φ₄) where h₀ := h.h₀ + h'.h₀ h₁ := h.h₁ + h'.h₁ h₂ := h.h₂ + h'.h₂ h₃ := h.h₃ + h'.h₃ comm₁ := by rw [add_τ₁, add_τ₁, h.comm₁, h'.comm₁, comp_add]; abel comm₂ := by rw [add_τ₂, add_τ₂, h.comm₂, h'.comm₂, comp_add, add_comp]; abel comm₃ := by rw [add_τ₃, add_τ₃, h.comm₃, h'.comm₃, add_comp]; abel /-- Homotopy between morphisms of short complexes is compatible with substraction. -/ @[simps] def sub (h : Homotopy φ₁ φ₂) (h' : Homotopy φ₃ φ₄) : Homotopy (φ₁ - φ₃) (φ₂ - φ₄) where h₀ := h.h₀ - h'.h₀ h₁ := h.h₁ - h'.h₁ h₂ := h.h₂ - h'.h₂ h₃ := h.h₃ - h'.h₃ comm₁ := by rw [sub_τ₁, sub_τ₁, h.comm₁, h'.comm₁, comp_sub]; abel comm₂ := by rw [sub_τ₂, sub_τ₂, h.comm₂, h'.comm₂, comp_sub, sub_comp]; abel comm₃ := by rw [sub_τ₃, sub_τ₃, h.comm₃, h'.comm₃, sub_comp]; abel /-- Homotopy between morphisms of short complexes is compatible with precomposition. -/ @[simps] def compLeft (h : Homotopy φ₁ φ₂) (ψ : S₃ ⟶ S₁) : Homotopy (ψ ≫ φ₁) (ψ ≫ φ₂) where h₀ := ψ.τ₁ ≫ h.h₀ h₁ := ψ.τ₂ ≫ h.h₁ h₂ := ψ.τ₃ ≫ h.h₂ h₃ := ψ.τ₃ ≫ h.h₃ g_h₃ := by rw [← ψ.comm₂₃_assoc, h.g_h₃, comp_zero] comm₁ := by rw [comp_τ₁, comp_τ₁, h.comm₁, comp_add, comp_add, add_left_inj, ψ.comm₁₂_assoc] comm₂ := by rw [comp_τ₂, comp_τ₂, h.comm₂, comp_add, comp_add, assoc, ψ.comm₂₃_assoc] comm₃ := by rw [comp_τ₃, comp_τ₃, h.comm₃, comp_add, comp_add, assoc] /-- Homotopy between morphisms of short complexes is compatible with postcomposition. -/ @[simps] def compRight (h : Homotopy φ₁ φ₂) (ψ : S₂ ⟶ S₃) : Homotopy (φ₁ ≫ ψ) (φ₂ ≫ ψ) where h₀ := h.h₀ ≫ ψ.τ₁ h₁ := h.h₁ ≫ ψ.τ₁ h₂ := h.h₂ ≫ ψ.τ₂ h₃ := h.h₃ ≫ ψ.τ₃ comm₁ := by rw [comp_τ₁, comp_τ₁, h.comm₁, add_comp, add_comp, assoc] comm₂ := by rw [comp_τ₂, comp_τ₂, h.comm₂, add_comp, add_comp, assoc, assoc, assoc, ψ.comm₁₂] comm₃ := by rw [comp_τ₃, comp_τ₃, h.comm₃, add_comp, add_comp, assoc, assoc, ψ.comm₂₃] /-- Homotopy between morphisms of short complexes is compatible with composition. -/ @[simps!] def comp (h : Homotopy φ₁ φ₂) {ψ₁ ψ₂ : S₂ ⟶ S₃} (h' : Homotopy ψ₁ ψ₂) : Homotopy (φ₁ ≫ ψ₁) (φ₂ ≫ ψ₂) := (h.compRight ψ₁).trans (h'.compLeft φ₂) /-- The homotopy between morphisms in `ShortComplex Cᵒᵖ` that is induced by a homotopy between morphisms in `ShortComplex C`. -/ @[simps] def op (h : Homotopy φ₁ φ₂) : Homotopy (opMap φ₁) (opMap φ₂) where h₀ := h.h₃.op h₁ := h.h₂.op h₂ := h.h₁.op h₃ := h.h₀.op h₀_f := Quiver.Hom.unop_inj h.g_h₃ g_h₃ := Quiver.Hom.unop_inj h.h₀_f comm₁ := Quiver.Hom.unop_inj (by dsimp; rw [h.comm₃]; abel) comm₂ := Quiver.Hom.unop_inj (by dsimp; rw [h.comm₂]; abel) comm₃ := Quiver.Hom.unop_inj (by dsimp; rw [h.comm₁]; abel) /-- The homotopy between morphisms in `ShortComplex C` that is induced by a homotopy between morphisms in `ShortComplex Cᵒᵖ`. -/ @[simps] def unop {S₁ S₂ : ShortComplex Cᵒᵖ} {φ₁ φ₂ : S₁ ⟶ S₂} (h : Homotopy φ₁ φ₂) : Homotopy (unopMap φ₁) (unopMap φ₂) where h₀ := h.h₃.unop h₁ := h.h₂.unop h₂ := h.h₁.unop h₃ := h.h₀.unop h₀_f := Quiver.Hom.op_inj h.g_h₃ g_h₃ := Quiver.Hom.op_inj h.h₀_f comm₁ := Quiver.Hom.op_inj (by dsimp; rw [h.comm₃]; abel) comm₂ := Quiver.Hom.op_inj (by dsimp; rw [h.comm₂]; abel) comm₃ := Quiver.Hom.op_inj (by dsimp; rw [h.comm₁]; abel) variable (φ₁ φ₂) /-- Equivalence expressing that two morphisms are homotopic iff their difference is homotopic to zero. -/ @[simps] def equivSubZero : Homotopy φ₁ φ₂ ≃ Homotopy (φ₁ - φ₂) 0 where toFun h := (h.sub (refl φ₂)).trans (ofEq (sub_self φ₂)) invFun h := ((ofEq (sub_add_cancel φ₁ φ₂).symm).trans (h.add (refl φ₂))).trans (ofEq (zero_add φ₂)) left_inv := by aesop_cat right_inv := by aesop_cat variable {φ₁ φ₂} lemma eq_add_nullHomotopic (h : Homotopy φ₁ φ₂) : φ₁ = φ₂ + nullHomotopic _ _ h.h₀ h.h₀_f h.h₁ h.h₂ h.h₃ h.g_h₃ := by ext · dsimp; rw [h.comm₁]; abel · dsimp; rw [h.comm₂]; abel · dsimp; rw [h.comm₃]; abel variable (S₁ S₂) /-- A morphism constructed with `nullHomotopic` is homotopic to zero. -/ @[simps] def ofNullHomotopic (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : Homotopy (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) 0 where h₀ := h₀ h₁ := h₁ h₂ := h₂ h₃ := h₃ h₀_f := h₀_f g_h₃ := g_h₃ comm₁ := by rw [nullHomotopic_τ₁, zero_τ₁, add_zero]; abel comm₂ := by rw [nullHomotopic_τ₂, zero_τ₂, add_zero]; abel comm₃ := by rw [nullHomotopic_τ₃, zero_τ₃, add_zero]; abel end Homotopy variable {S₁ S₂} /-- The left homology map data expressing that null homotopic maps induce the zero morphism in left homology. -/ def LeftHomologyMapData.ofNullHomotopic (H₁ : S₁.LeftHomologyData) (H₂ : S₂.LeftHomologyData) (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : LeftHomologyMapData (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) H₁ H₂ where φK := H₂.liftK (H₁.i ≫ h₁ ≫ S₂.f) (by simp) φH := 0 commf' := by rw [← cancel_mono H₂.i, assoc, LeftHomologyData.liftK_i, LeftHomologyData.f'_i_assoc, nullHomotopic_τ₁, add_comp, add_comp, assoc, assoc, assoc, LeftHomologyData.f'_i, self_eq_add_left, h₀_f] commπ := by rw [H₂.liftK_π_eq_zero_of_boundary (H₁.i ≫ h₁ ≫ S₂.f) (H₁.i ≫ h₁) (by rw [assoc]), comp_zero] /-- The right homology map data expressing that null homotopic maps induce the zero morphism in right homology. -/ def RightHomologyMapData.ofNullHomotopic (H₁ : S₁.RightHomologyData) (H₂ : S₂.RightHomologyData) (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : RightHomologyMapData (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) H₁ H₂ where φQ := H₁.descQ (S₁.g ≫ h₂ ≫ H₂.p) (by simp) φH := 0 commg' := by rw [← cancel_epi H₁.p, RightHomologyData.p_descQ_assoc, RightHomologyData.p_g'_assoc, nullHomotopic_τ₃, comp_add, assoc, assoc, RightHomologyData.p_g', g_h₃, add_zero] commι := by rw [H₁.ι_descQ_eq_zero_of_boundary (S₁.g ≫ h₂ ≫ H₂.p) (h₂ ≫ H₂.p) rfl, zero_comp] @[simp] lemma leftHomologyMap'_nullHomotopic (H₁ : S₁.LeftHomologyData) (H₂ : S₂.LeftHomologyData) (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : leftHomologyMap' (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) H₁ H₂ = 0 := (LeftHomologyMapData.ofNullHomotopic H₁ H₂ h₀ h₀_f h₁ h₂ h₃ g_h₃).leftHomologyMap'_eq @[simp] lemma rightHomologyMap'_nullHomotopic (H₁ : S₁.RightHomologyData) (H₂ : S₂.RightHomologyData) (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : rightHomologyMap' (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) H₁ H₂ = 0 := (RightHomologyMapData.ofNullHomotopic H₁ H₂ h₀ h₀_f h₁ h₂ h₃ g_h₃).rightHomologyMap'_eq @[simp] lemma homologyMap'_nullHomotopic (H₁ : S₁.HomologyData) (H₂ : S₂.HomologyData) (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : homologyMap' (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) H₁ H₂ = 0 := by apply leftHomologyMap'_nullHomotopic variable (S₁ S₂) @[simp] lemma leftHomologyMap_nullHomotopic [S₁.HasLeftHomology] [S₂.HasLeftHomology] (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : leftHomologyMap (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) = 0 := by apply leftHomologyMap'_nullHomotopic @[simp] lemma rightHomologyMap_nullHomotopic [S₁.HasRightHomology] [S₂.HasRightHomology] (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : rightHomologyMap (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) = 0 := by apply rightHomologyMap'_nullHomotopic @[simp] lemma homologyMap_nullHomotopic [S₁.HasHomology] [S₂.HasHomology] (h₀ : S₁.X₁ ⟶ S₂.X₁) (h₀_f : h₀ ≫ S₂.f = 0) (h₁ : S₁.X₂ ⟶ S₂.X₁) (h₂ : S₁.X₃ ⟶ S₂.X₂) (h₃ : S₁.X₃ ⟶ S₂.X₃) (g_h₃ : S₁.g ≫ h₃ = 0) : homologyMap (nullHomotopic _ _ h₀ h₀_f h₁ h₂ h₃ g_h₃) = 0 := by apply homologyMap'_nullHomotopic namespace Homotopy variable {φ₁ φ₂ S₁ S₂} lemma leftHomologyMap'_congr (h : Homotopy φ₁ φ₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : leftHomologyMap' φ₁ h₁ h₂ = leftHomologyMap' φ₂ h₁ h₂ := by rw [h.eq_add_nullHomotopic, leftHomologyMap'_add, leftHomologyMap'_nullHomotopic, add_zero] lemma rightHomologyMap'_congr (h : Homotopy φ₁ φ₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : rightHomologyMap' φ₁ h₁ h₂ = rightHomologyMap' φ₂ h₁ h₂ := by rw [h.eq_add_nullHomotopic, rightHomologyMap'_add, rightHomologyMap'_nullHomotopic, add_zero] lemma homologyMap'_congr (h : Homotopy φ₁ φ₂) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) : homologyMap' φ₁ h₁ h₂ = homologyMap' φ₂ h₁ h₂ := by rw [h.eq_add_nullHomotopic, homologyMap'_add, homologyMap'_nullHomotopic, add_zero] lemma leftHomologyMap_congr (h : Homotopy φ₁ φ₂) [S₁.HasLeftHomology] [S₂.HasLeftHomology] : leftHomologyMap φ₁ = leftHomologyMap φ₂ := h.leftHomologyMap'_congr _ _ lemma rightHomologyMap_congr (h : Homotopy φ₁ φ₂) [S₁.HasRightHomology] [S₂.HasRightHomology] : rightHomologyMap φ₁ = rightHomologyMap φ₂ := h.rightHomologyMap'_congr _ _ lemma homologyMap_congr (h : Homotopy φ₁ φ₂) [S₁.HasHomology] [S₂.HasHomology] : homologyMap φ₁ = homologyMap φ₂ := h.homologyMap'_congr _ _ end Homotopy /-- An homotopy equivalence between two short complexes `S₁` and `S₂` consists of morphisms `hom : S₁ ⟶ S₂` and `inv : S₂ ⟶ S₁` such that both compositions `hom ≫ inv` and `inv ≫ hom` are homotopic to the identity. -/ @[ext] structure HomotopyEquiv where /-- the forward direction of a homotopy equivalence. -/ hom : S₁ ⟶ S₂ /-- the backwards direction of a homotopy equivalence. -/ inv : S₂ ⟶ S₁ /-- the composition of the two directions of a homotopy equivalence is homotopic to the identity of the source -/ homotopyHomInvId : Homotopy (hom ≫ inv) (𝟙 S₁) /-- the composition of the two directions of a homotopy equivalence is homotopic to the identity of the target -/ homotopyInvHomId : Homotopy (inv ≫ hom) (𝟙 S₂) namespace HomotopyEquiv variable {S₁ S₂} /-- The homotopy equivalence from a short complex to itself that is induced by the identity. -/ @[simps] def refl (S : ShortComplex C) : HomotopyEquiv S S where hom := 𝟙 S inv := 𝟙 S homotopyHomInvId := Homotopy.ofEq (by simp) homotopyInvHomId := Homotopy.ofEq (by simp) /-- The inverse of a homotopy equivalence. -/ @[simps] def symm (e : HomotopyEquiv S₁ S₂) : HomotopyEquiv S₂ S₁ where hom := e.inv inv := e.hom homotopyHomInvId := e.homotopyInvHomId homotopyInvHomId := e.homotopyHomInvId /-- The composition of homotopy equivalences. -/ @[simps] def trans (e : HomotopyEquiv S₁ S₂) (e' : HomotopyEquiv S₂ S₃) : HomotopyEquiv S₁ S₃ where hom := e.hom ≫ e'.hom inv := e'.inv ≫ e.inv homotopyHomInvId := (Homotopy.ofEq (by simp)).trans (((e'.homotopyHomInvId.compRight e.inv).compLeft e.hom).trans ((Homotopy.ofEq (by simp)).trans e.homotopyHomInvId)) homotopyInvHomId := (Homotopy.ofEq (by simp)).trans (((e.homotopyInvHomId.compRight e'.hom).compLeft e'.inv).trans ((Homotopy.ofEq (by simp)).trans e'.homotopyInvHomId)) end HomotopyEquiv end Homotopy end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\PreservesHomology.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.QuasiIso import Mathlib.CategoryTheory.Limits.Preserves.Finite import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Kernels /-! # Functors which preserves homology If `F : C ⥤ D` is a functor between categories with zero morphisms, we shall say that `F` preserves homology when `F` preserves both kernels and cokernels. This typeclass is named `[F.PreservesHomology]`, and is automatically satisfied when `F` preserves both finite limits and finite colimits. If `S : ShortComplex C` and `[F.PreservesHomology]`, then there is an isomorphism `S.mapHomologyIso F : (S.map F).homology ≅ F.obj S.homology`, which is part of the natural isomorphism `homologyFunctorIso F` between the functors `F.mapShortComplex ⋙ homologyFunctor D` and `homologyFunctor C ⋙ F`. -/ namespace CategoryTheory open Category Limits variable {C D : Type*} [Category C] [Category D] [HasZeroMorphisms C] [HasZeroMorphisms D] namespace Functor variable (F : C ⥤ D) /-- A functor preserves homology when it preserves both kernels and cokernels. -/ class PreservesHomology (F : C ⥤ D) [PreservesZeroMorphisms F] where /-- the functor preserves kernels -/ preservesKernels ⦃X Y : C⦄ (f : X ⟶ Y) : PreservesLimit (parallelPair f 0) F := by infer_instance /-- the functor preserves cokernels -/ preservesCokernels ⦃X Y : C⦄ (f : X ⟶ Y) : PreservesColimit (parallelPair f 0) F := by infer_instance variable [PreservesZeroMorphisms F] /-- A functor which preserves homology preserves kernels. -/ def PreservesHomology.preservesKernel [F.PreservesHomology] {X Y : C} (f : X ⟶ Y) : PreservesLimit (parallelPair f 0) F := PreservesHomology.preservesKernels _ /-- A functor which preserves homology preserves cokernels. -/ def PreservesHomology.preservesCokernel [F.PreservesHomology] {X Y : C} (f : X ⟶ Y) : PreservesColimit (parallelPair f 0) F := PreservesHomology.preservesCokernels _ noncomputable instance preservesHomologyOfExact [PreservesFiniteLimits F] [PreservesFiniteColimits F] : F.PreservesHomology where end Functor namespace ShortComplex variable {S S₁ S₂ : ShortComplex C} namespace LeftHomologyData variable (h : S.LeftHomologyData) (F : C ⥤ D) /-- A left homology data `h` of a short complex `S` is preserved by a functor `F` is `F` preserves the kernel of `S.g : S.X₂ ⟶ S.X₃` and the cokernel of `h.f' : S.X₁ ⟶ h.K`. -/ class IsPreservedBy [F.PreservesZeroMorphisms] where /-- the functor preserves the kernel of `S.g : S.X₂ ⟶ S.X₃`. -/ g : PreservesLimit (parallelPair S.g 0) F /-- the functor preserves the cokernel of `h.f' : S.X₁ ⟶ h.K`. -/ f' : PreservesColimit (parallelPair h.f' 0) F variable [F.PreservesZeroMorphisms] noncomputable instance isPreservedByOfPreservesHomology [F.PreservesHomology] : h.IsPreservedBy F where g := Functor.PreservesHomology.preservesKernel _ _ f' := Functor.PreservesHomology.preservesCokernel _ _ variable [h.IsPreservedBy F] /-- When a left homology data is preserved by a functor `F`, this functor preserves the kernel of `S.g : S.X₂ ⟶ S.X₃`. -/ def IsPreservedBy.hg : PreservesLimit (parallelPair S.g 0) F := @IsPreservedBy.g _ _ _ _ _ _ _ h F _ _ /-- When a left homology data `h` is preserved by a functor `F`, this functor preserves the cokernel of `h.f' : S.X₁ ⟶ h.K`. -/ def IsPreservedBy.hf' : PreservesColimit (parallelPair h.f' 0) F := IsPreservedBy.f' /-- When a left homology data `h` of a short complex `S` is preserved by a functor `F`, this is the induced left homology data `h.map F` for the short complex `S.map F`. -/ @[simps] noncomputable def map : (S.map F).LeftHomologyData := by have := IsPreservedBy.hg h F have := IsPreservedBy.hf' h F have wi : F.map h.i ≫ F.map S.g = 0 := by rw [← F.map_comp, h.wi, F.map_zero] have hi := KernelFork.mapIsLimit _ h.hi F let f' : F.obj S.X₁ ⟶ F.obj h.K := hi.lift (KernelFork.ofι (S.map F).f (S.map F).zero) have hf' : f' = F.map h.f' := Fork.IsLimit.hom_ext hi (by rw [Fork.IsLimit.lift_ι hi] simp only [KernelFork.map_ι, Fork.ι_ofι, map_f, ← F.map_comp, f'_i]) have wπ : f' ≫ F.map h.π = 0 := by rw [hf', ← F.map_comp, f'_π, F.map_zero] have hπ : IsColimit (CokernelCofork.ofπ (F.map h.π) wπ) := by let e : parallelPair f' 0 ≅ parallelPair (F.map h.f') 0 := parallelPair.ext (Iso.refl _) (Iso.refl _) (by simpa using hf') (by simp) refine IsColimit.precomposeInvEquiv e _ (IsColimit.ofIsoColimit (CokernelCofork.mapIsColimit _ h.hπ' F) ?_) exact Cofork.ext (Iso.refl _) (by simp [e]) exact { K := F.obj h.K H := F.obj h.H i := F.map h.i π := F.map h.π wi := wi hi := hi wπ := wπ hπ := hπ } @[simp] lemma map_f' : (h.map F).f' = F.map h.f' := by rw [← cancel_mono (h.map F).i, f'_i, map_f, map_i, ← F.map_comp, f'_i] end LeftHomologyData /-- Given a left homology map data `ψ : LeftHomologyMapData φ h₁ h₂` such that both left homology data `h₁` and `h₂` are preserved by a functor `F`, this is the induced left homology map data for the morphism `F.mapShortComplex.map φ`. -/ @[simps] def LeftHomologyMapData.map {φ : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} (ψ : LeftHomologyMapData φ h₁ h₂) (F : C ⥤ D) [F.PreservesZeroMorphisms] [h₁.IsPreservedBy F] [h₂.IsPreservedBy F] : LeftHomologyMapData (F.mapShortComplex.map φ) (h₁.map F) (h₂.map F) where φK := F.map ψ.φK φH := F.map ψ.φH commi := by simpa only [F.map_comp] using F.congr_map ψ.commi commf' := by simpa only [LeftHomologyData.map_f', F.map_comp] using F.congr_map ψ.commf' commπ := by simpa only [F.map_comp] using F.congr_map ψ.commπ namespace RightHomologyData variable (h : S.RightHomologyData) (F : C ⥤ D) /-- A right homology data `h` of a short complex `S` is preserved by a functor `F` is `F` preserves the cokernel of `S.f : S.X₁ ⟶ S.X₂` and the kernel of `h.g' : h.Q ⟶ S.X₃`. -/ class IsPreservedBy [F.PreservesZeroMorphisms] where /-- the functor preserves the cokernel of `S.f : S.X₁ ⟶ S.X₂`. -/ f : PreservesColimit (parallelPair S.f 0) F /-- the functor preserves the kernel of `h.g' : h.Q ⟶ S.X₃`. -/ g' : PreservesLimit (parallelPair h.g' 0) F variable [F.PreservesZeroMorphisms] noncomputable instance isPreservedByOfPreservesHomology [F.PreservesHomology] : h.IsPreservedBy F where f := Functor.PreservesHomology.preservesCokernel F _ g' := Functor.PreservesHomology.preservesKernel F _ variable [h.IsPreservedBy F] /-- When a right homology data is preserved by a functor `F`, this functor preserves the cokernel of `S.f : S.X₁ ⟶ S.X₂`. -/ def IsPreservedBy.hf : PreservesColimit (parallelPair S.f 0) F := @IsPreservedBy.f _ _ _ _ _ _ _ h F _ _ /-- When a right homology data `h` is preserved by a functor `F`, this functor preserves the kernel of `h.g' : h.Q ⟶ S.X₃`. -/ def IsPreservedBy.hg' : PreservesLimit (parallelPair h.g' 0) F := @IsPreservedBy.g' _ _ _ _ _ _ _ h F _ _ /-- When a right homology data `h` of a short complex `S` is preserved by a functor `F`, this is the induced right homology data `h.map F` for the short complex `S.map F`. -/ @[simps] noncomputable def map : (S.map F).RightHomologyData := by have := IsPreservedBy.hf h F have := IsPreservedBy.hg' h F have wp : F.map S.f ≫ F.map h.p = 0 := by rw [← F.map_comp, h.wp, F.map_zero] have hp := CokernelCofork.mapIsColimit _ h.hp F let g' : F.obj h.Q ⟶ F.obj S.X₃ := hp.desc (CokernelCofork.ofπ (S.map F).g (S.map F).zero) have hg' : g' = F.map h.g' := by apply Cofork.IsColimit.hom_ext hp rw [Cofork.IsColimit.π_desc hp] simp only [Cofork.π_ofπ, CokernelCofork.map_π, map_g, ← F.map_comp, p_g'] have wι : F.map h.ι ≫ g' = 0 := by rw [hg', ← F.map_comp, ι_g', F.map_zero] have hι : IsLimit (KernelFork.ofι (F.map h.ι) wι) := by let e : parallelPair g' 0 ≅ parallelPair (F.map h.g') 0 := parallelPair.ext (Iso.refl _) (Iso.refl _) (by simpa using hg') (by simp) refine IsLimit.postcomposeHomEquiv e _ (IsLimit.ofIsoLimit (KernelFork.mapIsLimit _ h.hι' F) ?_) exact Fork.ext (Iso.refl _) (by simp [e]) exact { Q := F.obj h.Q H := F.obj h.H p := F.map h.p ι := F.map h.ι wp := wp hp := hp wι := wι hι := hι } @[simp] lemma map_g' : (h.map F).g' = F.map h.g' := by rw [← cancel_epi (h.map F).p, p_g', map_g, map_p, ← F.map_comp, p_g'] end RightHomologyData /-- Given a right homology map data `ψ : RightHomologyMapData φ h₁ h₂` such that both right homology data `h₁` and `h₂` are preserved by a functor `F`, this is the induced right homology map data for the morphism `F.mapShortComplex.map φ`. -/ @[simps] def RightHomologyMapData.map {φ : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} (ψ : RightHomologyMapData φ h₁ h₂) (F : C ⥤ D) [F.PreservesZeroMorphisms] [h₁.IsPreservedBy F] [h₂.IsPreservedBy F] : RightHomologyMapData (F.mapShortComplex.map φ) (h₁.map F) (h₂.map F) where φQ := F.map ψ.φQ φH := F.map ψ.φH commp := by simpa only [F.map_comp] using F.congr_map ψ.commp commg' := by simpa only [RightHomologyData.map_g', F.map_comp] using F.congr_map ψ.commg' commι := by simpa only [F.map_comp] using F.congr_map ψ.commι /-- When a homology data `h` of a short complex `S` is such that both `h.left` and `h.right` are preserved by a functor `F`, this is the induced homology data `h.map F` for the short complex `S.map F`. -/ @[simps] noncomputable def HomologyData.map (h : S.HomologyData) (F : C ⥤ D) [F.PreservesZeroMorphisms] [h.left.IsPreservedBy F] [h.right.IsPreservedBy F] : (S.map F).HomologyData where left := h.left.map F right := h.right.map F iso := F.mapIso h.iso comm := by simpa only [F.map_comp] using F.congr_map h.comm /-- Given a homology map data `ψ : HomologyMapData φ h₁ h₂` such that `h₁.left`, `h₁.right`, `h₂.left` and `h₂.right` are all preserved by a functor `F`, this is the induced homology map data for the morphism `F.mapShortComplex.map φ`. -/ @[simps] def HomologyMapData.map {φ : S₁ ⟶ S₂} {h₁ : S₁.HomologyData} {h₂ : S₂.HomologyData} (ψ : HomologyMapData φ h₁ h₂) (F : C ⥤ D) [F.PreservesZeroMorphisms] [h₁.left.IsPreservedBy F] [h₁.right.IsPreservedBy F] [h₂.left.IsPreservedBy F] [h₂.right.IsPreservedBy F] : HomologyMapData (F.mapShortComplex.map φ) (h₁.map F) (h₂.map F) where left := ψ.left.map F right := ψ.right.map F end ShortComplex namespace Functor variable (F : C ⥤ D) [PreservesZeroMorphisms F] (S : ShortComplex C) {S₁ S₂ : ShortComplex C} /-- A functor preserves the left homology of a short complex `S` if it preserves all the left homology data of `S`. -/ class PreservesLeftHomologyOf where /-- the functor preserves all the left homology data of the short complex -/ isPreservedBy : ∀ (h : S.LeftHomologyData), h.IsPreservedBy F /-- A functor preserves the right homology of a short complex `S` if it preserves all the right homology data of `S`. -/ class PreservesRightHomologyOf where /-- the functor preserves all the right homology data of the short complex -/ isPreservedBy : ∀ (h : S.RightHomologyData), h.IsPreservedBy F noncomputable instance PreservesHomology.preservesLeftHomologyOf [F.PreservesHomology] : F.PreservesLeftHomologyOf S := ⟨inferInstance⟩ noncomputable instance PreservesHomology.preservesRightHomologyOf [F.PreservesHomology] : F.PreservesRightHomologyOf S := ⟨inferInstance⟩ variable {S} /-- If a functor preserves a certain left homology data of a short complex `S`, then it preserves the left homology of `S`. -/ def PreservesLeftHomologyOf.mk' (h : S.LeftHomologyData) [h.IsPreservedBy F] : F.PreservesLeftHomologyOf S where isPreservedBy h' := { g := ShortComplex.LeftHomologyData.IsPreservedBy.hg h F f' := by have := ShortComplex.LeftHomologyData.IsPreservedBy.hf' h F let e : parallelPair h.f' 0 ≅ parallelPair h'.f' 0 := parallelPair.ext (Iso.refl _) (ShortComplex.cyclesMapIso' (Iso.refl S) h h') (by simp) (by simp) exact preservesColimitOfIsoDiagram F e } /-- If a functor preserves a certain right homology data of a short complex `S`, then it preserves the right homology of `S`. -/ def PreservesRightHomologyOf.mk' (h : S.RightHomologyData) [h.IsPreservedBy F] : F.PreservesRightHomologyOf S where isPreservedBy h' := { f := ShortComplex.RightHomologyData.IsPreservedBy.hf h F g' := by have := ShortComplex.RightHomologyData.IsPreservedBy.hg' h F let e : parallelPair h.g' 0 ≅ parallelPair h'.g' 0 := parallelPair.ext (ShortComplex.opcyclesMapIso' (Iso.refl S) h h') (Iso.refl _) (by simp) (by simp) exact preservesLimitOfIsoDiagram F e } end Functor namespace ShortComplex variable {S : ShortComplex C} (h₁ : S.LeftHomologyData) (h₂ : S.RightHomologyData) (F : C ⥤ D) [F.PreservesZeroMorphisms] instance LeftHomologyData.isPreservedByOfPreserves [F.PreservesLeftHomologyOf S] : h₁.IsPreservedBy F := Functor.PreservesLeftHomologyOf.isPreservedBy _ instance RightHomologyData.isPreservedByOfPreserves [F.PreservesRightHomologyOf S] : h₂.IsPreservedBy F := Functor.PreservesRightHomologyOf.isPreservedBy _ variable (S) instance hasLeftHomology_of_preserves [S.HasLeftHomology] [F.PreservesLeftHomologyOf S] : (S.map F).HasLeftHomology := HasLeftHomology.mk' (S.leftHomologyData.map F) instance hasLeftHomology_of_preserves' [S.HasLeftHomology] [F.PreservesLeftHomologyOf S] : (F.mapShortComplex.obj S).HasLeftHomology := by dsimp; infer_instance instance hasRightHomology_of_preserves [S.HasRightHomology] [F.PreservesRightHomologyOf S] : (S.map F).HasRightHomology := HasRightHomology.mk' (S.rightHomologyData.map F) instance hasRightHomology_of_preserves' [S.HasRightHomology] [F.PreservesRightHomologyOf S] : (F.mapShortComplex.obj S).HasRightHomology := by dsimp; infer_instance instance hasHomology_of_preserves [S.HasHomology] [F.PreservesLeftHomologyOf S] [F.PreservesRightHomologyOf S] : (S.map F).HasHomology := HasHomology.mk' (S.homologyData.map F) instance hasHomology_of_preserves' [S.HasHomology] [F.PreservesLeftHomologyOf S] [F.PreservesRightHomologyOf S] : (F.mapShortComplex.obj S).HasHomology := by dsimp; infer_instance section variable (hl : S.LeftHomologyData) (hr : S.RightHomologyData) {S₁ S₂ : ShortComplex C} (φ : S₁ ⟶ S₂) (hl₁ : S₁.LeftHomologyData) (hr₁ : S₁.RightHomologyData) (hl₂ : S₂.LeftHomologyData) (hr₂ : S₂.RightHomologyData) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) (F : C ⥤ D) [F.PreservesZeroMorphisms] namespace LeftHomologyData variable [hl₁.IsPreservedBy F] [hl₂.IsPreservedBy F] lemma map_cyclesMap' : F.map (ShortComplex.cyclesMap' φ hl₁ hl₂) = ShortComplex.cyclesMap' (F.mapShortComplex.map φ) (hl₁.map F) (hl₂.map F) := by have γ : ShortComplex.LeftHomologyMapData φ hl₁ hl₂ := default rw [γ.cyclesMap'_eq, (γ.map F).cyclesMap'_eq, ShortComplex.LeftHomologyMapData.map_φK] lemma map_leftHomologyMap' : F.map (ShortComplex.leftHomologyMap' φ hl₁ hl₂) = ShortComplex.leftHomologyMap' (F.mapShortComplex.map φ) (hl₁.map F) (hl₂.map F) := by have γ : ShortComplex.LeftHomologyMapData φ hl₁ hl₂ := default rw [γ.leftHomologyMap'_eq, (γ.map F).leftHomologyMap'_eq, ShortComplex.LeftHomologyMapData.map_φH] end LeftHomologyData namespace RightHomologyData variable [hr₁.IsPreservedBy F] [hr₂.IsPreservedBy F] lemma map_opcyclesMap' : F.map (ShortComplex.opcyclesMap' φ hr₁ hr₂) = ShortComplex.opcyclesMap' (F.mapShortComplex.map φ) (hr₁.map F) (hr₂.map F) := by have γ : ShortComplex.RightHomologyMapData φ hr₁ hr₂ := default rw [γ.opcyclesMap'_eq, (γ.map F).opcyclesMap'_eq, ShortComplex.RightHomologyMapData.map_φQ] lemma map_rightHomologyMap' : F.map (ShortComplex.rightHomologyMap' φ hr₁ hr₂) = ShortComplex.rightHomologyMap' (F.mapShortComplex.map φ) (hr₁.map F) (hr₂.map F) := by have γ : ShortComplex.RightHomologyMapData φ hr₁ hr₂ := default rw [γ.rightHomologyMap'_eq, (γ.map F).rightHomologyMap'_eq, ShortComplex.RightHomologyMapData.map_φH] end RightHomologyData lemma HomologyData.map_homologyMap' [h₁.left.IsPreservedBy F] [h₁.right.IsPreservedBy F] [h₂.left.IsPreservedBy F] [h₂.right.IsPreservedBy F] : F.map (ShortComplex.homologyMap' φ h₁ h₂) = ShortComplex.homologyMap' (F.mapShortComplex.map φ) (h₁.map F) (h₂.map F) := LeftHomologyData.map_leftHomologyMap' _ _ _ _ /-- When a functor `F` preserves the left homology of a short complex `S`, this is the canonical isomorphism `(S.map F).cycles ≅ F.obj S.cycles`. -/ noncomputable def mapCyclesIso [S.HasLeftHomology] [F.PreservesLeftHomologyOf S] : (S.map F).cycles ≅ F.obj S.cycles := (S.leftHomologyData.map F).cyclesIso @[reassoc (attr := simp)] lemma mapCyclesIso_hom_iCycles [S.HasLeftHomology] [F.PreservesLeftHomologyOf S] : (S.mapCyclesIso F).hom ≫ F.map S.iCycles = (S.map F).iCycles := by apply LeftHomologyData.cyclesIso_hom_comp_i /-- When a functor `F` preserves the left homology of a short complex `S`, this is the canonical isomorphism `(S.map F).leftHomology ≅ F.obj S.leftHomology`. -/ noncomputable def mapLeftHomologyIso [S.HasLeftHomology] [F.PreservesLeftHomologyOf S] : (S.map F).leftHomology ≅ F.obj S.leftHomology := (S.leftHomologyData.map F).leftHomologyIso /-- When a functor `F` preserves the right homology of a short complex `S`, this is the canonical isomorphism `(S.map F).opcycles ≅ F.obj S.opcycles`. -/ noncomputable def mapOpcyclesIso [S.HasRightHomology] [F.PreservesRightHomologyOf S] : (S.map F).opcycles ≅ F.obj S.opcycles := (S.rightHomologyData.map F).opcyclesIso /-- When a functor `F` preserves the right homology of a short complex `S`, this is the canonical isomorphism `(S.map F).rightHomology ≅ F.obj S.rightHomology`. -/ noncomputable def mapRightHomologyIso [S.HasRightHomology] [F.PreservesRightHomologyOf S] : (S.map F).rightHomology ≅ F.obj S.rightHomology := (S.rightHomologyData.map F).rightHomologyIso /-- When a functor `F` preserves the left homology of a short complex `S`, this is the canonical isomorphism `(S.map F).homology ≅ F.obj S.homology`. -/ noncomputable def mapHomologyIso [S.HasHomology] [(S.map F).HasHomology] [F.PreservesLeftHomologyOf S] : (S.map F).homology ≅ F.obj S.homology := (S.homologyData.left.map F).homologyIso /-- When a functor `F` preserves the right homology of a short complex `S`, this is the canonical isomorphism `(S.map F).homology ≅ F.obj S.homology`. -/ noncomputable def mapHomologyIso' [S.HasHomology] [(S.map F).HasHomology] [F.PreservesRightHomologyOf S] : (S.map F).homology ≅ F.obj S.homology := (S.homologyData.right.map F).homologyIso ≪≫ F.mapIso S.homologyData.right.homologyIso.symm variable {S} lemma LeftHomologyData.mapCyclesIso_eq [S.HasLeftHomology] [F.PreservesLeftHomologyOf S] : S.mapCyclesIso F = (hl.map F).cyclesIso ≪≫ F.mapIso hl.cyclesIso.symm := by ext dsimp [mapCyclesIso, cyclesIso] simp only [map_cyclesMap', ← cyclesMap'_comp, Functor.map_id, comp_id, Functor.mapShortComplex_obj] lemma LeftHomologyData.mapLeftHomologyIso_eq [S.HasLeftHomology] [F.PreservesLeftHomologyOf S] : S.mapLeftHomologyIso F = (hl.map F).leftHomologyIso ≪≫ F.mapIso hl.leftHomologyIso.symm := by ext dsimp [mapLeftHomologyIso, leftHomologyIso] simp only [map_leftHomologyMap', ← leftHomologyMap'_comp, Functor.map_id, comp_id, Functor.mapShortComplex_obj] lemma RightHomologyData.mapOpcyclesIso_eq [S.HasRightHomology] [F.PreservesRightHomologyOf S] : S.mapOpcyclesIso F = (hr.map F).opcyclesIso ≪≫ F.mapIso hr.opcyclesIso.symm := by ext dsimp [mapOpcyclesIso, opcyclesIso] simp only [map_opcyclesMap', ← opcyclesMap'_comp, Functor.map_id, comp_id, Functor.mapShortComplex_obj] lemma RightHomologyData.mapRightHomologyIso_eq [S.HasRightHomology] [F.PreservesRightHomologyOf S] : S.mapRightHomologyIso F = (hr.map F).rightHomologyIso ≪≫ F.mapIso hr.rightHomologyIso.symm := by ext dsimp [mapRightHomologyIso, rightHomologyIso] simp only [map_rightHomologyMap', ← rightHomologyMap'_comp, Functor.map_id, comp_id, Functor.mapShortComplex_obj] lemma LeftHomologyData.mapHomologyIso_eq [S.HasHomology] [(S.map F).HasHomology] [F.PreservesLeftHomologyOf S] : S.mapHomologyIso F = (hl.map F).homologyIso ≪≫ F.mapIso hl.homologyIso.symm := by ext dsimp only [mapHomologyIso, homologyIso, ShortComplex.leftHomologyIso, leftHomologyMapIso', leftHomologyIso, Functor.mapIso, Iso.symm, Iso.trans, Iso.refl] simp only [F.map_comp, map_leftHomologyMap', ← leftHomologyMap'_comp, comp_id, Functor.map_id, Functor.mapShortComplex_obj] lemma RightHomologyData.mapHomologyIso'_eq [S.HasHomology] [(S.map F).HasHomology] [F.PreservesRightHomologyOf S] : S.mapHomologyIso' F = (hr.map F).homologyIso ≪≫ F.mapIso hr.homologyIso.symm := by ext dsimp only [Iso.trans, Iso.symm, Iso.refl, Functor.mapIso, mapHomologyIso', homologyIso, rightHomologyIso, rightHomologyMapIso', ShortComplex.rightHomologyIso] simp only [assoc, F.map_comp, map_rightHomologyMap', ← rightHomologyMap'_comp_assoc] @[reassoc] lemma mapCyclesIso_hom_naturality [S₁.HasLeftHomology] [S₂.HasLeftHomology] [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] : cyclesMap (F.mapShortComplex.map φ) ≫ (S₂.mapCyclesIso F).hom = (S₁.mapCyclesIso F).hom ≫ F.map (cyclesMap φ) := by dsimp only [cyclesMap, mapCyclesIso, LeftHomologyData.cyclesIso, cyclesMapIso', Iso.refl] simp only [LeftHomologyData.map_cyclesMap', Functor.mapShortComplex_obj, ← cyclesMap'_comp, comp_id, id_comp] @[reassoc] lemma mapCyclesIso_inv_naturality [S₁.HasLeftHomology] [S₂.HasLeftHomology] [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] : F.map (cyclesMap φ) ≫ (S₂.mapCyclesIso F).inv = (S₁.mapCyclesIso F).inv ≫ cyclesMap (F.mapShortComplex.map φ) := by rw [← cancel_epi (S₁.mapCyclesIso F).hom, ← mapCyclesIso_hom_naturality_assoc, Iso.hom_inv_id, comp_id, Iso.hom_inv_id_assoc] @[reassoc] lemma mapLeftHomologyIso_hom_naturality [S₁.HasLeftHomology] [S₂.HasLeftHomology] [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] : leftHomologyMap (F.mapShortComplex.map φ) ≫ (S₂.mapLeftHomologyIso F).hom = (S₁.mapLeftHomologyIso F).hom ≫ F.map (leftHomologyMap φ) := by dsimp only [leftHomologyMap, mapLeftHomologyIso, LeftHomologyData.leftHomologyIso, leftHomologyMapIso', Iso.refl] simp only [LeftHomologyData.map_leftHomologyMap', Functor.mapShortComplex_obj, ← leftHomologyMap'_comp, comp_id, id_comp] @[reassoc] lemma mapLeftHomologyIso_inv_naturality [S₁.HasLeftHomology] [S₂.HasLeftHomology] [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] : F.map (leftHomologyMap φ) ≫ (S₂.mapLeftHomologyIso F).inv = (S₁.mapLeftHomologyIso F).inv ≫ leftHomologyMap (F.mapShortComplex.map φ) := by rw [← cancel_epi (S₁.mapLeftHomologyIso F).hom, ← mapLeftHomologyIso_hom_naturality_assoc, Iso.hom_inv_id, comp_id, Iso.hom_inv_id_assoc] @[reassoc] lemma mapOpcyclesIso_hom_naturality [S₁.HasRightHomology] [S₂.HasRightHomology] [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] : opcyclesMap (F.mapShortComplex.map φ) ≫ (S₂.mapOpcyclesIso F).hom = (S₁.mapOpcyclesIso F).hom ≫ F.map (opcyclesMap φ) := by dsimp only [opcyclesMap, mapOpcyclesIso, RightHomologyData.opcyclesIso, opcyclesMapIso', Iso.refl] simp only [RightHomologyData.map_opcyclesMap', Functor.mapShortComplex_obj, ← opcyclesMap'_comp, comp_id, id_comp] @[reassoc] lemma mapOpcyclesIso_inv_naturality [S₁.HasRightHomology] [S₂.HasRightHomology] [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] : F.map (opcyclesMap φ) ≫ (S₂.mapOpcyclesIso F).inv = (S₁.mapOpcyclesIso F).inv ≫ opcyclesMap (F.mapShortComplex.map φ) := by rw [← cancel_epi (S₁.mapOpcyclesIso F).hom, ← mapOpcyclesIso_hom_naturality_assoc, Iso.hom_inv_id, comp_id, Iso.hom_inv_id_assoc] @[reassoc] lemma mapRightHomologyIso_hom_naturality [S₁.HasRightHomology] [S₂.HasRightHomology] [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] : rightHomologyMap (F.mapShortComplex.map φ) ≫ (S₂.mapRightHomologyIso F).hom = (S₁.mapRightHomologyIso F).hom ≫ F.map (rightHomologyMap φ) := by dsimp only [rightHomologyMap, mapRightHomologyIso, RightHomologyData.rightHomologyIso, rightHomologyMapIso', Iso.refl] simp only [RightHomologyData.map_rightHomologyMap', Functor.mapShortComplex_obj, ← rightHomologyMap'_comp, comp_id, id_comp] @[reassoc] lemma mapRightHomologyIso_inv_naturality [S₁.HasRightHomology] [S₂.HasRightHomology] [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] : F.map (rightHomologyMap φ) ≫ (S₂.mapRightHomologyIso F).inv = (S₁.mapRightHomologyIso F).inv ≫ rightHomologyMap (F.mapShortComplex.map φ) := by rw [← cancel_epi (S₁.mapRightHomologyIso F).hom, ← mapRightHomologyIso_hom_naturality_assoc, Iso.hom_inv_id, comp_id, Iso.hom_inv_id_assoc] @[reassoc] lemma mapHomologyIso_hom_naturality [S₁.HasHomology] [S₂.HasHomology] [(S₁.map F).HasHomology] [(S₂.map F).HasHomology] [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] : @homologyMap _ _ _ (S₁.map F) (S₂.map F) (F.mapShortComplex.map φ) _ _ ≫ (S₂.mapHomologyIso F).hom = (S₁.mapHomologyIso F).hom ≫ F.map (homologyMap φ) := by dsimp only [homologyMap, homologyMap', mapHomologyIso, LeftHomologyData.homologyIso, LeftHomologyData.leftHomologyIso, leftHomologyMapIso', leftHomologyIso, Iso.symm, Iso.trans, Iso.refl] simp only [LeftHomologyData.map_leftHomologyMap', ← leftHomologyMap'_comp, comp_id, id_comp] @[reassoc] lemma mapHomologyIso_inv_naturality [S₁.HasHomology] [S₂.HasHomology] [(S₁.map F).HasHomology] [(S₂.map F).HasHomology] [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] : F.map (homologyMap φ) ≫ (S₂.mapHomologyIso F).inv = (S₁.mapHomologyIso F).inv ≫ @homologyMap _ _ _ (S₁.map F) (S₂.map F) (F.mapShortComplex.map φ) _ _ := by rw [← cancel_epi (S₁.mapHomologyIso F).hom, ← mapHomologyIso_hom_naturality_assoc, Iso.hom_inv_id, comp_id, Iso.hom_inv_id_assoc] @[reassoc] lemma mapHomologyIso'_hom_naturality [S₁.HasHomology] [S₂.HasHomology] [(S₁.map F).HasHomology] [(S₂.map F).HasHomology] [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] : @homologyMap _ _ _ (S₁.map F) (S₂.map F) (F.mapShortComplex.map φ) _ _ ≫ (S₂.mapHomologyIso' F).hom = (S₁.mapHomologyIso' F).hom ≫ F.map (homologyMap φ) := by dsimp only [Iso.trans, Iso.symm, Functor.mapIso, mapHomologyIso'] simp only [← RightHomologyData.rightHomologyIso_hom_naturality_assoc _ ((homologyData S₁).right.map F) ((homologyData S₂).right.map F), assoc, ← RightHomologyData.map_rightHomologyMap', ← F.map_comp, RightHomologyData.rightHomologyIso_inv_naturality _ (homologyData S₁).right (homologyData S₂).right] @[reassoc] lemma mapHomologyIso'_inv_naturality [S₁.HasHomology] [S₂.HasHomology] [(S₁.map F).HasHomology] [(S₂.map F).HasHomology] [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] : F.map (homologyMap φ) ≫ (S₂.mapHomologyIso' F).inv = (S₁.mapHomologyIso' F).inv ≫ @homologyMap _ _ _ (S₁.map F) (S₂.map F) (F.mapShortComplex.map φ) _ _ := by rw [← cancel_epi (S₁.mapHomologyIso' F).hom, ← mapHomologyIso'_hom_naturality_assoc, Iso.hom_inv_id, comp_id, Iso.hom_inv_id_assoc] variable (S) lemma mapHomologyIso'_eq_mapHomologyIso [S.HasHomology] [F.PreservesLeftHomologyOf S] [F.PreservesRightHomologyOf S] : S.mapHomologyIso' F = S.mapHomologyIso F := by ext rw [S.homologyData.left.mapHomologyIso_eq F, S.homologyData.right.mapHomologyIso'_eq F] dsimp only [Iso.trans, Iso.symm, Iso.refl, Functor.mapIso, RightHomologyData.homologyIso, rightHomologyIso, RightHomologyData.rightHomologyIso, LeftHomologyData.homologyIso, leftHomologyIso, LeftHomologyData.leftHomologyIso] simp only [RightHomologyData.map_H, rightHomologyMapIso'_inv, rightHomologyMapIso'_hom, assoc, Functor.map_comp, RightHomologyData.map_rightHomologyMap', Functor.mapShortComplex_obj, Functor.map_id, LeftHomologyData.map_H, leftHomologyMapIso'_inv, leftHomologyMapIso'_hom, LeftHomologyData.map_leftHomologyMap', ← rightHomologyMap'_comp_assoc, ← leftHomologyMap'_comp, ← leftHomologyMap'_comp_assoc, id_comp] have γ : HomologyMapData (𝟙 (S.map F)) (map S F).homologyData (S.homologyData.map F) := default have eq := γ.comm rw [← γ.left.leftHomologyMap'_eq, ← γ.right.rightHomologyMap'_eq] at eq dsimp at eq simp only [← reassoc_of% eq, ← F.map_comp, Iso.hom_inv_id, F.map_id, comp_id] end section variable {S} {F G : C ⥤ D} [F.PreservesZeroMorphisms] [G.PreservesZeroMorphisms] [F.PreservesLeftHomologyOf S] [G.PreservesLeftHomologyOf S] [F.PreservesRightHomologyOf S] [G.PreservesRightHomologyOf S] /-- Given a natural transformation `τ : F ⟶ G` between functors `C ⥤ D` which preserve the left homology of a short complex `S`, and a left homology data for `S`, this is the left homology map data for the morphism `S.mapNatTrans τ` obtained by evaluating `τ`. -/ @[simps] def LeftHomologyMapData.natTransApp (h : LeftHomologyData S) (τ : F ⟶ G) : LeftHomologyMapData (S.mapNatTrans τ) (h.map F) (h.map G) where φK := τ.app h.K φH := τ.app h.H /-- Given a natural transformation `τ : F ⟶ G` between functors `C ⥤ D` which preserve the right homology of a short complex `S`, and a right homology data for `S`, this is the right homology map data for the morphism `S.mapNatTrans τ` obtained by evaluating `τ`. -/ @[simps] def RightHomologyMapData.natTransApp (h : RightHomologyData S) (τ : F ⟶ G) : RightHomologyMapData (S.mapNatTrans τ) (h.map F) (h.map G) where φQ := τ.app h.Q φH := τ.app h.H /-- Given a natural transformation `τ : F ⟶ G` between functors `C ⥤ D` which preserve the homology of a short complex `S`, and a homology data for `S`, this is the homology map data for the morphism `S.mapNatTrans τ` obtained by evaluating `τ`. -/ @[simps] def HomologyMapData.natTransApp (h : HomologyData S) (τ : F ⟶ G) : HomologyMapData (S.mapNatTrans τ) (h.map F) (h.map G) where left := LeftHomologyMapData.natTransApp h.left τ right := RightHomologyMapData.natTransApp h.right τ variable (S) lemma homologyMap_mapNatTrans [S.HasHomology] (τ : F ⟶ G) : homologyMap (S.mapNatTrans τ) = (S.mapHomologyIso F).hom ≫ τ.app S.homology ≫ (S.mapHomologyIso G).inv := (LeftHomologyMapData.natTransApp S.homologyData.left τ).homologyMap_eq end section variable [HasKernels C] [HasCokernels C] [HasKernels D] [HasCokernels D] /-- The natural isomorphism `F.mapShortComplex ⋙ cyclesFunctor D ≅ cyclesFunctor C ⋙ F` for a functor `F : C ⥤ D` which preserves homology. --/ noncomputable def cyclesFunctorIso [F.PreservesHomology] : F.mapShortComplex ⋙ ShortComplex.cyclesFunctor D ≅ ShortComplex.cyclesFunctor C ⋙ F := NatIso.ofComponents (fun S => S.mapCyclesIso F) (fun f => ShortComplex.mapCyclesIso_hom_naturality f F) /-- The natural isomorphism `F.mapShortComplex ⋙ leftHomologyFunctor D ≅ leftHomologyFunctor C ⋙ F` for a functor `F : C ⥤ D` which preserves homology. --/ noncomputable def leftHomologyFunctorIso [F.PreservesHomology] : F.mapShortComplex ⋙ ShortComplex.leftHomologyFunctor D ≅ ShortComplex.leftHomologyFunctor C ⋙ F := NatIso.ofComponents (fun S => S.mapLeftHomologyIso F) (fun f => ShortComplex.mapLeftHomologyIso_hom_naturality f F) /-- The natural isomorphism `F.mapShortComplex ⋙ opcyclesFunctor D ≅ opcyclesFunctor C ⋙ F` for a functor `F : C ⥤ D` which preserves homology. --/ noncomputable def opcyclesFunctorIso [F.PreservesHomology] : F.mapShortComplex ⋙ ShortComplex.opcyclesFunctor D ≅ ShortComplex.opcyclesFunctor C ⋙ F := NatIso.ofComponents (fun S => S.mapOpcyclesIso F) (fun f => ShortComplex.mapOpcyclesIso_hom_naturality f F) /-- The natural isomorphism `F.mapShortComplex ⋙ rightHomologyFunctor D ≅ rightHomologyFunctor C ⋙ F` for a functor `F : C ⥤ D` which preserves homology. --/ noncomputable def rightHomologyFunctorIso [F.PreservesHomology] : F.mapShortComplex ⋙ ShortComplex.rightHomologyFunctor D ≅ ShortComplex.rightHomologyFunctor C ⋙ F := NatIso.ofComponents (fun S => S.mapRightHomologyIso F) (fun f => ShortComplex.mapRightHomologyIso_hom_naturality f F) end /-- The natural isomorphism `F.mapShortComplex ⋙ homologyFunctor D ≅ homologyFunctor C ⋙ F` for a functor `F : C ⥤ D` which preserves homology. --/ noncomputable def homologyFunctorIso [CategoryWithHomology C] [CategoryWithHomology D] [F.PreservesHomology] : F.mapShortComplex ⋙ ShortComplex.homologyFunctor D ≅ ShortComplex.homologyFunctor C ⋙ F := NatIso.ofComponents (fun S => S.mapHomologyIso F) (fun f => ShortComplex.mapHomologyIso_hom_naturality f F) section variable {S₁ S₂ : ShortComplex C} {φ : S₁ ⟶ S₂} {hl₁ : S₁.LeftHomologyData} {hr₁ : S₁.RightHomologyData} {hl₂ : S₂.LeftHomologyData} {hr₂ : S₂.RightHomologyData} (ψl : LeftHomologyMapData φ hl₁ hl₂) (ψr : RightHomologyMapData φ hr₁ hr₂) lemma LeftHomologyMapData.quasiIso_map_iff [(F.mapShortComplex.obj S₁).HasHomology] [(F.mapShortComplex.obj S₂).HasHomology] [hl₁.IsPreservedBy F] [hl₂.IsPreservedBy F] : QuasiIso (F.mapShortComplex.map φ) ↔ IsIso (F.map ψl.φH) := (ψl.map F).quasiIso_iff lemma RightHomologyMapData.quasiIso_map_iff [(F.mapShortComplex.obj S₁).HasHomology] [(F.mapShortComplex.obj S₂).HasHomology] [hr₁.IsPreservedBy F] [hr₂.IsPreservedBy F] : QuasiIso (F.mapShortComplex.map φ) ↔ IsIso (F.map ψr.φH) := (ψr.map F).quasiIso_iff variable (φ) [S₁.HasHomology] [S₂.HasHomology] [(F.mapShortComplex.obj S₁).HasHomology] [(F.mapShortComplex.obj S₂).HasHomology] instance quasiIso_map_of_preservesLeftHomology [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] [QuasiIso φ] : QuasiIso (F.mapShortComplex.map φ) := by have γ : LeftHomologyMapData φ S₁.leftHomologyData S₂.leftHomologyData := default have : IsIso γ.φH := by rw [← γ.quasiIso_iff] infer_instance rw [(γ.map F).quasiIso_iff, LeftHomologyMapData.map_φH] infer_instance lemma quasiIso_map_iff_of_preservesLeftHomology [F.PreservesLeftHomologyOf S₁] [F.PreservesLeftHomologyOf S₂] [F.ReflectsIsomorphisms] : QuasiIso (F.mapShortComplex.map φ) ↔ QuasiIso φ := by have γ : LeftHomologyMapData φ S₁.leftHomologyData S₂.leftHomologyData := default rw [γ.quasiIso_iff, (γ.map F).quasiIso_iff, LeftHomologyMapData.map_φH] constructor · intro exact isIso_of_reflects_iso _ F · intro infer_instance instance quasiIso_map_of_preservesRightHomology [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] [QuasiIso φ] : QuasiIso (F.mapShortComplex.map φ) := by have γ : RightHomologyMapData φ S₁.rightHomologyData S₂.rightHomologyData := default have : IsIso γ.φH := by rw [← γ.quasiIso_iff] infer_instance rw [(γ.map F).quasiIso_iff, RightHomologyMapData.map_φH] infer_instance lemma quasiIso_map_iff_of_preservesRightHomology [F.PreservesRightHomologyOf S₁] [F.PreservesRightHomologyOf S₂] [F.ReflectsIsomorphisms] : QuasiIso (F.mapShortComplex.map φ) ↔ QuasiIso φ := by have γ : RightHomologyMapData φ S₁.rightHomologyData S₂.rightHomologyData := default rw [γ.quasiIso_iff, (γ.map F).quasiIso_iff, RightHomologyMapData.map_φH] constructor · intro exact isIso_of_reflects_iso _ F · intro infer_instance end end ShortComplex namespace Functor variable (F : C ⥤ D) [F.PreservesZeroMorphisms] (S : ShortComplex C) /-- If a short complex `S` is such that `S.f = 0` and that the kernel of `S.g` is preserved by a functor `F`, then `F` preserves the left homology of `S`. -/ noncomputable def preservesLeftHomologyOfZerof (hf : S.f = 0) [PreservesLimit (parallelPair S.g 0) F] : F.PreservesLeftHomologyOf S := ⟨fun h => { g := by infer_instance f' := Limits.preservesCokernelZero' _ _ (by rw [← cancel_mono h.i, h.f'_i, zero_comp, hf]) }⟩ /-- If a short complex `S` is such that `S.g = 0` and that the cokernel of `S.f` is preserved by a functor `F`, then `F` preserves the right homology of `S`. -/ noncomputable def preservesRightHomologyOfZerog (hg : S.g = 0) [PreservesColimit (parallelPair S.f 0) F] : F.PreservesRightHomologyOf S := ⟨fun h => { f := by infer_instance g' := Limits.preservesKernelZero' _ _ (by rw [← cancel_epi h.p, h.p_g', comp_zero, hg]) }⟩ /-- If a short complex `S` is such that `S.g = 0` and that the cokernel of `S.f` is preserved by a functor `F`, then `F` preserves the left homology of `S`. -/ noncomputable def preservesLeftHomologyOfZerog (hg : S.g = 0) [PreservesColimit (parallelPair S.f 0) F] : F.PreservesLeftHomologyOf S := ⟨fun h => { g := by rw [hg] infer_instance f' := by have := h.isIso_i hg let e : parallelPair h.f' 0 ≅ parallelPair S.f 0 := parallelPair.ext (Iso.refl _) (asIso h.i) (by aesop_cat) (by aesop_cat) exact Limits.preservesColimitOfIsoDiagram F e.symm}⟩ /-- If a short complex `S` is such that `S.f = 0` and that the kernel of `S.g` is preserved by a functor `F`, then `F` preserves the right homology of `S`. -/ noncomputable def preservesRightHomologyOfZerof (hf : S.f = 0) [PreservesLimit (parallelPair S.g 0) F] : F.PreservesRightHomologyOf S := ⟨fun h => { f := by rw [hf] infer_instance g' := by have := h.isIso_p hf let e : parallelPair S.g 0 ≅ parallelPair h.g' 0 := parallelPair.ext (asIso h.p) (Iso.refl _) (by aesop_cat) (by aesop_cat) exact Limits.preservesLimitOfIsoDiagram F e }⟩ end Functor lemma NatTrans.app_homology {F G : C ⥤ D} (τ : F ⟶ G) (S : ShortComplex C) [S.HasHomology] [F.PreservesZeroMorphisms] [G.PreservesZeroMorphisms] [F.PreservesLeftHomologyOf S] [G.PreservesLeftHomologyOf S] [F.PreservesRightHomologyOf S] [G.PreservesRightHomologyOf S] : τ.app S.homology = (S.mapHomologyIso F).inv ≫ ShortComplex.homologyMap (S.mapNatTrans τ) ≫ (S.mapHomologyIso G).hom := by rw [ShortComplex.homologyMap_mapNatTrans, assoc, assoc, Iso.inv_hom_id, comp_id, Iso.inv_hom_id_assoc] end CategoryTheory
Algebra\Homology\ShortComplex\QuasiIso.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.Homology /-! # Quasi-isomorphisms of short complexes This file introduces the typeclass `QuasiIso φ` for a morphism `φ : S₁ ⟶ S₂` of short complexes (which have homology): the condition is that the induced morphism `homologyMap φ` in homology is an isomorphism. -/ namespace CategoryTheory open Category Limits namespace ShortComplex variable {C : Type _} [Category C] [HasZeroMorphisms C] {S₁ S₂ S₃ S₄ : ShortComplex C} [S₁.HasHomology] [S₂.HasHomology] [S₃.HasHomology] [S₄.HasHomology] /-- A morphism `φ : S₁ ⟶ S₂` of short complexes that have homology is a quasi-isomorphism if the induced map `homologyMap φ : S₁.homology ⟶ S₂.homology` is an isomorphism. -/ class QuasiIso (φ : S₁ ⟶ S₂) : Prop where /-- the homology map is an isomorphism -/ isIso' : IsIso (homologyMap φ) instance QuasiIso.isIso (φ : S₁ ⟶ S₂) [QuasiIso φ] : IsIso (homologyMap φ) := QuasiIso.isIso' lemma quasiIso_iff (φ : S₁ ⟶ S₂) : QuasiIso φ ↔ IsIso (homologyMap φ) := by constructor · intro h infer_instance · intro h exact ⟨h⟩ instance quasiIso_of_isIso (φ : S₁ ⟶ S₂) [IsIso φ] : QuasiIso φ := ⟨(homologyMapIso (asIso φ)).isIso_hom⟩ instance quasiIso_comp (φ : S₁ ⟶ S₂) (φ' : S₂ ⟶ S₃) [hφ : QuasiIso φ] [hφ' : QuasiIso φ'] : QuasiIso (φ ≫ φ') := by rw [quasiIso_iff] at hφ hφ' ⊢ rw [homologyMap_comp] infer_instance lemma quasiIso_of_comp_left (φ : S₁ ⟶ S₂) (φ' : S₂ ⟶ S₃) [hφ : QuasiIso φ] [hφφ' : QuasiIso (φ ≫ φ')] : QuasiIso φ' := by rw [quasiIso_iff] at hφ hφφ' ⊢ rw [homologyMap_comp] at hφφ' exact IsIso.of_isIso_comp_left (homologyMap φ) (homologyMap φ') lemma quasiIso_iff_comp_left (φ : S₁ ⟶ S₂) (φ' : S₂ ⟶ S₃) [hφ : QuasiIso φ] : QuasiIso (φ ≫ φ') ↔ QuasiIso φ' := by constructor · intro exact quasiIso_of_comp_left φ φ' · intro exact quasiIso_comp φ φ' lemma quasiIso_of_comp_right (φ : S₁ ⟶ S₂) (φ' : S₂ ⟶ S₃) [hφ' : QuasiIso φ'] [hφφ' : QuasiIso (φ ≫ φ')] : QuasiIso φ := by rw [quasiIso_iff] at hφ' hφφ' ⊢ rw [homologyMap_comp] at hφφ' exact IsIso.of_isIso_comp_right (homologyMap φ) (homologyMap φ') lemma quasiIso_iff_comp_right (φ : S₁ ⟶ S₂) (φ' : S₂ ⟶ S₃) [hφ' : QuasiIso φ'] : QuasiIso (φ ≫ φ') ↔ QuasiIso φ := by constructor · intro exact quasiIso_of_comp_right φ φ' · intro exact quasiIso_comp φ φ' lemma quasiIso_of_arrow_mk_iso (φ : S₁ ⟶ S₂) (φ' : S₃ ⟶ S₄) (e : Arrow.mk φ ≅ Arrow.mk φ') [hφ : QuasiIso φ] : QuasiIso φ' := by let α : S₃ ⟶ S₁ := e.inv.left let β : S₂ ⟶ S₄ := e.hom.right suffices φ' = α ≫ φ ≫ β by rw [this] infer_instance simp only [α, β, Arrow.w_mk_right_assoc, Arrow.mk_left, Arrow.mk_right, Arrow.mk_hom, ← Arrow.comp_right, e.inv_hom_id, Arrow.id_right, comp_id] lemma quasiIso_iff_of_arrow_mk_iso (φ : S₁ ⟶ S₂) (φ' : S₃ ⟶ S₄) (e : Arrow.mk φ ≅ Arrow.mk φ') : QuasiIso φ ↔ QuasiIso φ' := ⟨fun _ => quasiIso_of_arrow_mk_iso φ φ' e, fun _ => quasiIso_of_arrow_mk_iso φ' φ e.symm⟩ lemma LeftHomologyMapData.quasiIso_iff {φ : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} (γ : LeftHomologyMapData φ h₁ h₂) : QuasiIso φ ↔ IsIso γ.φH := by rw [ShortComplex.quasiIso_iff, γ.homologyMap_eq] constructor · intro h haveI : IsIso (γ.φH ≫ (LeftHomologyData.homologyIso h₂).inv) := IsIso.of_isIso_comp_left (LeftHomologyData.homologyIso h₁).hom _ exact IsIso.of_isIso_comp_right _ (LeftHomologyData.homologyIso h₂).inv · intro h infer_instance lemma RightHomologyMapData.quasiIso_iff {φ : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} (γ : RightHomologyMapData φ h₁ h₂) : QuasiIso φ ↔ IsIso γ.φH := by rw [ShortComplex.quasiIso_iff, γ.homologyMap_eq] constructor · intro h haveI : IsIso (γ.φH ≫ (RightHomologyData.homologyIso h₂).inv) := IsIso.of_isIso_comp_left (RightHomologyData.homologyIso h₁).hom _ exact IsIso.of_isIso_comp_right _ (RightHomologyData.homologyIso h₂).inv · intro h infer_instance lemma quasiIso_iff_isIso_leftHomologyMap' (φ : S₁ ⟶ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : QuasiIso φ ↔ IsIso (leftHomologyMap' φ h₁ h₂) := by have γ : LeftHomologyMapData φ h₁ h₂ := default rw [γ.quasiIso_iff, γ.leftHomologyMap'_eq] lemma quasiIso_iff_isIso_rightHomologyMap' (φ : S₁ ⟶ S₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : QuasiIso φ ↔ IsIso (rightHomologyMap' φ h₁ h₂) := by have γ : RightHomologyMapData φ h₁ h₂ := default rw [γ.quasiIso_iff, γ.rightHomologyMap'_eq] lemma quasiIso_iff_isIso_homologyMap' (φ : S₁ ⟶ S₂) (h₁ : S₁.HomologyData) (h₂ : S₂.HomologyData) : QuasiIso φ ↔ IsIso (homologyMap' φ h₁ h₂) := quasiIso_iff_isIso_leftHomologyMap' _ _ _ lemma quasiIso_of_epi_of_isIso_of_mono (φ : S₁ ⟶ S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : QuasiIso φ := by rw [((LeftHomologyMapData.ofEpiOfIsIsoOfMono φ) S₁.leftHomologyData).quasiIso_iff] dsimp infer_instance lemma quasiIso_opMap_iff (φ : S₁ ⟶ S₂) : QuasiIso (opMap φ) ↔ QuasiIso φ := by have γ : HomologyMapData φ S₁.homologyData S₂.homologyData := default rw [γ.left.quasiIso_iff, γ.op.right.quasiIso_iff] dsimp constructor · intro h apply isIso_of_op · intro h infer_instance lemma quasiIso_opMap (φ : S₁ ⟶ S₂) [QuasiIso φ] : QuasiIso (opMap φ) := by rw [quasiIso_opMap_iff] infer_instance lemma quasiIso_unopMap {S₁ S₂ : ShortComplex Cᵒᵖ} [S₁.HasHomology] [S₂.HasHomology] [S₁.unop.HasHomology] [S₂.unop.HasHomology] (φ : S₁ ⟶ S₂) [QuasiIso φ] : QuasiIso (unopMap φ) := by rw [← quasiIso_opMap_iff] change QuasiIso φ infer_instance lemma quasiIso_iff_isIso_liftCycles (φ : S₁ ⟶ S₂) (hf₁ : S₁.f = 0) (hg₁ : S₁.g = 0) (hf₂ : S₂.f = 0) : QuasiIso φ ↔ IsIso (S₂.liftCycles φ.τ₂ (by rw [φ.comm₂₃, hg₁, zero_comp])) := by let H : LeftHomologyMapData φ (LeftHomologyData.ofZeros S₁ hf₁ hg₁) (LeftHomologyData.ofIsLimitKernelFork S₂ hf₂ _ S₂.cyclesIsKernel) := { φK := S₂.liftCycles φ.τ₂ (by rw [φ.comm₂₃, hg₁, zero_comp]) φH := S₂.liftCycles φ.τ₂ (by rw [φ.comm₂₃, hg₁, zero_comp]) } exact H.quasiIso_iff lemma quasiIso_iff_isIso_descOpcycles (φ : S₁ ⟶ S₂) (hg₁ : S₁.g = 0) (hf₂ : S₂.f = 0) (hg₂ : S₂.g = 0) : QuasiIso φ ↔ IsIso (S₁.descOpcycles φ.τ₂ (by rw [← φ.comm₁₂, hf₂, comp_zero])) := by let H : RightHomologyMapData φ (RightHomologyData.ofIsColimitCokernelCofork S₁ hg₁ _ S₁.opcyclesIsCokernel) (RightHomologyData.ofZeros S₂ hf₂ hg₂) := { φQ := S₁.descOpcycles φ.τ₂ (by rw [← φ.comm₁₂, hf₂, comp_zero]) φH := S₁.descOpcycles φ.τ₂ (by rw [← φ.comm₁₂, hf₂, comp_zero]) } exact H.quasiIso_iff end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\RightHomology.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.LeftHomology import Mathlib.CategoryTheory.Limits.Opposites /-! # Right Homology of short complexes In this file, we define the dual notions to those defined in `Algebra.Homology.ShortComplex.LeftHomology`. In particular, if `S : ShortComplex C` is a short complex consisting of two composable maps `f : X₁ ⟶ X₂` and `g : X₂ ⟶ X₃` such that `f ≫ g = 0`, we define `h : S.RightHomologyData` to be the datum of morphisms `p : X₂ ⟶ Q` and `ι : H ⟶ Q` such that `Q` identifies to the cokernel of `f` and `H` to the kernel of the induced map `g' : Q ⟶ X₃`. When such a `S.RightHomologyData` exists, we shall say that `[S.HasRightHomology]` and we define `S.rightHomology` to be the `H` field of a chosen right homology data. Similarly, we define `S.opcycles` to be the `Q` field. In `Homology.lean`, when `S` has two compatible left and right homology data (i.e. they give the same `H` up to a canonical isomorphism), we shall define `[S.HasHomology]` and `S.homology`. -/ namespace CategoryTheory open Category Limits namespace ShortComplex variable {C : Type*} [Category C] [HasZeroMorphisms C] (S : ShortComplex C) {S₁ S₂ S₃ : ShortComplex C} /-- A right homology data for a short complex `S` consists of morphisms `p : S.X₂ ⟶ Q` and `ι : H ⟶ Q` such that `p` identifies `Q` to the kernel of `f : S.X₁ ⟶ S.X₂`, and that `ι` identifies `H` to the kernel of the induced map `g' : Q ⟶ S.X₃` -/ structure RightHomologyData where /-- a choice of cokernel of `S.f : S.X₁ ⟶ S.X₂`-/ Q : C /-- a choice of kernel of the induced morphism `S.g' : S.Q ⟶ X₃`-/ H : C /-- the projection from `S.X₂` -/ p : S.X₂ ⟶ Q /-- the inclusion of the (right) homology in the chosen cokernel of `S.f` -/ ι : H ⟶ Q /-- the cokernel condition for `p` -/ wp : S.f ≫ p = 0 /-- `p : S.X₂ ⟶ Q` is a cokernel of `S.f : S.X₁ ⟶ S.X₂` -/ hp : IsColimit (CokernelCofork.ofπ p wp) /-- the kernel condition for `ι` -/ wι : ι ≫ hp.desc (CokernelCofork.ofπ _ S.zero) = 0 /-- `ι : H ⟶ Q` is a kernel of `S.g' : Q ⟶ S.X₃` -/ hι : IsLimit (KernelFork.ofι ι wι) initialize_simps_projections RightHomologyData (-hp, -hι) namespace RightHomologyData /-- The chosen cokernels and kernels of the limits API give a `RightHomologyData` -/ @[simps] noncomputable def ofHasCokernelOfHasKernel [HasCokernel S.f] [HasKernel (cokernel.desc S.f S.g S.zero)] : S.RightHomologyData := { Q := cokernel S.f, H := kernel (cokernel.desc S.f S.g S.zero), p := cokernel.π _, ι := kernel.ι _, wp := cokernel.condition _, hp := cokernelIsCokernel _, wι := kernel.condition _, hι := kernelIsKernel _, } attribute [reassoc (attr := simp)] wp wι variable {S} variable (h : S.RightHomologyData) {A : C} instance : Epi h.p := ⟨fun _ _ => Cofork.IsColimit.hom_ext h.hp⟩ instance : Mono h.ι := ⟨fun _ _ => Fork.IsLimit.hom_ext h.hι⟩ /-- Any morphism `k : S.X₂ ⟶ A` such that `S.f ≫ k = 0` descends to a morphism `Q ⟶ A` -/ def descQ (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.Q ⟶ A := h.hp.desc (CokernelCofork.ofπ k hk) @[reassoc (attr := simp)] lemma p_descQ (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.p ≫ h.descQ k hk = k := h.hp.fac _ WalkingParallelPair.one /-- The morphism from the (right) homology attached to a morphism `k : S.X₂ ⟶ A` such that `S.f ≫ k = 0`. -/ @[simp] def descH (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.H ⟶ A := h.ι ≫ h.descQ k hk /-- The morphism `h.Q ⟶ S.X₃` induced by `S.g : S.X₂ ⟶ S.X₃` and the fact that `h.Q` is a cokernel of `S.f : S.X₁ ⟶ S.X₂`. -/ def g' : h.Q ⟶ S.X₃ := h.descQ S.g S.zero @[reassoc (attr := simp)] lemma p_g' : h.p ≫ h.g' = S.g := p_descQ _ _ _ @[reassoc (attr := simp)] lemma ι_g' : h.ι ≫ h.g' = 0 := h.wι @[reassoc] lemma ι_descQ_eq_zero_of_boundary (k : S.X₂ ⟶ A) (x : S.X₃ ⟶ A) (hx : k = S.g ≫ x) : h.ι ≫ h.descQ k (by rw [hx, S.zero_assoc, zero_comp]) = 0 := by rw [show 0 = h.ι ≫ h.g' ≫ x by simp] congr 1 simp only [← cancel_epi h.p, hx, p_descQ, p_g'_assoc] /-- For `h : S.RightHomologyData`, this is a restatement of `h.hι`, saying that `ι : h.H ⟶ h.Q` is a kernel of `h.g' : h.Q ⟶ S.X₃`. -/ def hι' : IsLimit (KernelFork.ofι h.ι h.ι_g') := h.hι /-- The morphism `A ⟶ H` induced by a morphism `k : A ⟶ Q` such that `k ≫ g' = 0` -/ def liftH (k : A ⟶ h.Q) (hk : k ≫ h.g' = 0) : A ⟶ h.H := h.hι.lift (KernelFork.ofι k hk) @[reassoc (attr := simp)] lemma liftH_ι (k : A ⟶ h.Q) (hk : k ≫ h.g' = 0) : h.liftH k hk ≫ h.ι = k := h.hι.fac (KernelFork.ofι k hk) WalkingParallelPair.zero lemma isIso_p (hf : S.f = 0) : IsIso h.p := ⟨h.descQ (𝟙 S.X₂) (by rw [hf, comp_id]), p_descQ _ _ _, by simp only [← cancel_epi h.p, p_descQ_assoc, id_comp, comp_id]⟩ lemma isIso_ι (hg : S.g = 0) : IsIso h.ι := by have ⟨φ, hφ⟩ := KernelFork.IsLimit.lift' h.hι' (𝟙 _) (by rw [← cancel_epi h.p, id_comp, p_g', comp_zero, hg]) dsimp at hφ exact ⟨φ, by rw [← cancel_mono h.ι, assoc, hφ, comp_id, id_comp], hφ⟩ variable (S) /-- When the first map `S.f` is zero, this is the right homology data on `S` given by any limit kernel fork of `S.g` -/ @[simps] def ofIsLimitKernelFork (hf : S.f = 0) (c : KernelFork S.g) (hc : IsLimit c) : S.RightHomologyData where Q := S.X₂ H := c.pt p := 𝟙 _ ι := c.ι wp := by rw [comp_id, hf] hp := CokernelCofork.IsColimit.ofId _ hf wι := KernelFork.condition _ hι := IsLimit.ofIsoLimit hc (Fork.ext (Iso.refl _) (by aesop_cat)) @[simp] lemma ofIsLimitKernelFork_g' (hf : S.f = 0) (c : KernelFork S.g) (hc : IsLimit c) : (ofIsLimitKernelFork S hf c hc).g' = S.g := by rw [← cancel_epi (ofIsLimitKernelFork S hf c hc).p, p_g', ofIsLimitKernelFork_p, id_comp] /-- When the first map `S.f` is zero, this is the right homology data on `S` given by the chosen `kernel S.g` -/ @[simps!] noncomputable def ofHasKernel [HasKernel S.g] (hf : S.f = 0) : S.RightHomologyData := ofIsLimitKernelFork S hf _ (kernelIsKernel _) /-- When the second map `S.g` is zero, this is the right homology data on `S` given by any colimit cokernel cofork of `S.g` -/ @[simps] def ofIsColimitCokernelCofork (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : S.RightHomologyData where Q := c.pt H := c.pt p := c.π ι := 𝟙 _ wp := CokernelCofork.condition _ hp := IsColimit.ofIsoColimit hc (Cofork.ext (Iso.refl _) (by aesop_cat)) wι := Cofork.IsColimit.hom_ext hc (by simp [hg]) hι := KernelFork.IsLimit.ofId _ (Cofork.IsColimit.hom_ext hc (by simp [hg])) @[simp] lemma ofIsColimitCokernelCofork_g' (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : (ofIsColimitCokernelCofork S hg c hc).g' = 0 := by rw [← cancel_epi (ofIsColimitCokernelCofork S hg c hc).p, p_g', hg, comp_zero] /-- When the second map `S.g` is zero, this is the right homology data on `S` given by the chosen `cokernel S.f` -/ @[simp] noncomputable def ofHasCokernel [HasCokernel S.f] (hg : S.g = 0) : S.RightHomologyData := ofIsColimitCokernelCofork S hg _ (cokernelIsCokernel _) /-- When both `S.f` and `S.g` are zero, the middle object `S.X₂` gives a right homology data on S -/ @[simps] def ofZeros (hf : S.f = 0) (hg : S.g = 0) : S.RightHomologyData where Q := S.X₂ H := S.X₂ p := 𝟙 _ ι := 𝟙 _ wp := by rw [comp_id, hf] hp := CokernelCofork.IsColimit.ofId _ hf wι := by change 𝟙 _ ≫ S.g = 0 simp only [hg, comp_zero] hι := KernelFork.IsLimit.ofId _ hg @[simp] lemma ofZeros_g' (hf : S.f = 0) (hg : S.g = 0) : (ofZeros S hf hg).g' = 0 := by rw [← cancel_epi ((ofZeros S hf hg).p), comp_zero, p_g', hg] end RightHomologyData /-- A short complex `S` has right homology when there exists a `S.RightHomologyData` -/ class HasRightHomology : Prop where condition : Nonempty S.RightHomologyData /-- A chosen `S.RightHomologyData` for a short complex `S` that has right homology -/ noncomputable def rightHomologyData [HasRightHomology S] : S.RightHomologyData := HasRightHomology.condition.some variable {S} namespace HasRightHomology lemma mk' (h : S.RightHomologyData) : HasRightHomology S := ⟨Nonempty.intro h⟩ instance of_hasCokernel_of_hasKernel [HasCokernel S.f] [HasKernel (cokernel.desc S.f S.g S.zero)] : S.HasRightHomology := HasRightHomology.mk' (RightHomologyData.ofHasCokernelOfHasKernel S) instance of_hasKernel {Y Z : C} (g : Y ⟶ Z) (X : C) [HasKernel g] : (ShortComplex.mk (0 : X ⟶ Y) g zero_comp).HasRightHomology := HasRightHomology.mk' (RightHomologyData.ofHasKernel _ rfl) instance of_hasCokernel {X Y : C} (f : X ⟶ Y) (Z : C) [HasCokernel f] : (ShortComplex.mk f (0 : Y ⟶ Z) comp_zero).HasRightHomology := HasRightHomology.mk' (RightHomologyData.ofHasCokernel _ rfl) instance of_zeros (X Y Z : C) : (ShortComplex.mk (0 : X ⟶ Y) (0 : Y ⟶ Z) zero_comp).HasRightHomology := HasRightHomology.mk' (RightHomologyData.ofZeros _ rfl rfl) end HasRightHomology namespace RightHomologyData /-- A right homology data for a short complex `S` induces a left homology data for `S.op`. -/ @[simps] def op (h : S.RightHomologyData) : S.op.LeftHomologyData where K := Opposite.op h.Q H := Opposite.op h.H i := h.p.op π := h.ι.op wi := Quiver.Hom.unop_inj h.wp hi := CokernelCofork.IsColimit.ofπOp _ _ h.hp wπ := Quiver.Hom.unop_inj h.wι hπ := KernelFork.IsLimit.ofιOp _ _ h.hι @[simp] lemma op_f' (h : S.RightHomologyData) : h.op.f' = h.g'.op := rfl /-- A right homology data for a short complex `S` in the opposite category induces a left homology data for `S.unop`. -/ @[simps] def unop {S : ShortComplex Cᵒᵖ} (h : S.RightHomologyData) : S.unop.LeftHomologyData where K := Opposite.unop h.Q H := Opposite.unop h.H i := h.p.unop π := h.ι.unop wi := Quiver.Hom.op_inj h.wp hi := CokernelCofork.IsColimit.ofπUnop _ _ h.hp wπ := Quiver.Hom.op_inj h.wι hπ := KernelFork.IsLimit.ofιUnop _ _ h.hι @[simp] lemma unop_f' {S : ShortComplex Cᵒᵖ} (h : S.RightHomologyData) : h.unop.f' = h.g'.unop := rfl end RightHomologyData namespace LeftHomologyData /-- A left homology data for a short complex `S` induces a right homology data for `S.op`. -/ @[simps] def op (h : S.LeftHomologyData) : S.op.RightHomologyData where Q := Opposite.op h.K H := Opposite.op h.H p := h.i.op ι := h.π.op wp := Quiver.Hom.unop_inj h.wi hp := KernelFork.IsLimit.ofιOp _ _ h.hi wι := Quiver.Hom.unop_inj h.wπ hι := CokernelCofork.IsColimit.ofπOp _ _ h.hπ @[simp] lemma op_g' (h : S.LeftHomologyData) : h.op.g' = h.f'.op := rfl /-- A left homology data for a short complex `S` in the opposite category induces a right homology data for `S.unop`. -/ @[simps] def unop {S : ShortComplex Cᵒᵖ} (h : S.LeftHomologyData) : S.unop.RightHomologyData where Q := Opposite.unop h.K H := Opposite.unop h.H p := h.i.unop ι := h.π.unop wp := Quiver.Hom.op_inj h.wi hp := KernelFork.IsLimit.ofιUnop _ _ h.hi wι := Quiver.Hom.op_inj h.wπ hι := CokernelCofork.IsColimit.ofπUnop _ _ h.hπ @[simp] lemma unop_g' {S : ShortComplex Cᵒᵖ} (h : S.LeftHomologyData) : h.unop.g' = h.f'.unop := rfl end LeftHomologyData instance [S.HasLeftHomology] : HasRightHomology S.op := HasRightHomology.mk' S.leftHomologyData.op instance [S.HasRightHomology] : HasLeftHomology S.op := HasLeftHomology.mk' S.rightHomologyData.op lemma hasLeftHomology_iff_op (S : ShortComplex C) : S.HasLeftHomology ↔ S.op.HasRightHomology := ⟨fun _ => inferInstance, fun _ => HasLeftHomology.mk' S.op.rightHomologyData.unop⟩ lemma hasRightHomology_iff_op (S : ShortComplex C) : S.HasRightHomology ↔ S.op.HasLeftHomology := ⟨fun _ => inferInstance, fun _ => HasRightHomology.mk' S.op.leftHomologyData.unop⟩ lemma hasLeftHomology_iff_unop (S : ShortComplex Cᵒᵖ) : S.HasLeftHomology ↔ S.unop.HasRightHomology := S.unop.hasRightHomology_iff_op.symm lemma hasRightHomology_iff_unop (S : ShortComplex Cᵒᵖ) : S.HasRightHomology ↔ S.unop.HasLeftHomology := S.unop.hasLeftHomology_iff_op.symm section variable (φ : S₁ ⟶ S₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) /-- Given right homology data `h₁` and `h₂` for two short complexes `S₁` and `S₂`, a `RightHomologyMapData` for a morphism `φ : S₁ ⟶ S₂` consists of a description of the induced morphisms on the `Q` (opcycles) and `H` (right homology) fields of `h₁` and `h₂`. -/ structure RightHomologyMapData where /-- the induced map on opcycles -/ φQ : h₁.Q ⟶ h₂.Q /-- the induced map on right homology -/ φH : h₁.H ⟶ h₂.H /-- commutation with `p` -/ commp : h₁.p ≫ φQ = φ.τ₂ ≫ h₂.p := by aesop_cat /-- commutation with `g'` -/ commg' : φQ ≫ h₂.g' = h₁.g' ≫ φ.τ₃ := by aesop_cat /-- commutation with `ι` -/ commι : φH ≫ h₂.ι = h₁.ι ≫ φQ := by aesop_cat namespace RightHomologyMapData attribute [reassoc (attr := simp)] commp commg' commι attribute [nolint simpNF] mk.injEq /-- The right homology map data associated to the zero morphism between two short complexes. -/ @[simps] def zero (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : RightHomologyMapData 0 h₁ h₂ where φQ := 0 φH := 0 /-- The right homology map data associated to the identity morphism of a short complex. -/ @[simps] def id (h : S.RightHomologyData) : RightHomologyMapData (𝟙 S) h h where φQ := 𝟙 _ φH := 𝟙 _ /-- The composition of right homology map data. -/ @[simps] def comp {φ : S₁ ⟶ S₂} {φ' : S₂ ⟶ S₃} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} {h₃ : S₃.RightHomologyData} (ψ : RightHomologyMapData φ h₁ h₂) (ψ' : RightHomologyMapData φ' h₂ h₃) : RightHomologyMapData (φ ≫ φ') h₁ h₃ where φQ := ψ.φQ ≫ ψ'.φQ φH := ψ.φH ≫ ψ'.φH instance : Subsingleton (RightHomologyMapData φ h₁ h₂) := ⟨fun ψ₁ ψ₂ => by have hQ : ψ₁.φQ = ψ₂.φQ := by rw [← cancel_epi h₁.p, commp, commp] have hH : ψ₁.φH = ψ₂.φH := by rw [← cancel_mono h₂.ι, commι, commι, hQ] cases ψ₁ cases ψ₂ congr⟩ instance : Inhabited (RightHomologyMapData φ h₁ h₂) := ⟨by let φQ : h₁.Q ⟶ h₂.Q := h₁.descQ (φ.τ₂ ≫ h₂.p) (by rw [← φ.comm₁₂_assoc, h₂.wp, comp_zero]) have commg' : φQ ≫ h₂.g' = h₁.g' ≫ φ.τ₃ := by rw [← cancel_epi h₁.p, RightHomologyData.p_descQ_assoc, assoc, RightHomologyData.p_g', φ.comm₂₃, RightHomologyData.p_g'_assoc] let φH : h₁.H ⟶ h₂.H := h₂.liftH (h₁.ι ≫ φQ) (by rw [assoc, commg', RightHomologyData.ι_g'_assoc, zero_comp]) exact ⟨φQ, φH, by simp [φQ], commg', by simp [φH]⟩⟩ instance : Unique (RightHomologyMapData φ h₁ h₂) := Unique.mk' _ variable {φ h₁ h₂} lemma congr_φH {γ₁ γ₂ : RightHomologyMapData φ h₁ h₂} (eq : γ₁ = γ₂) : γ₁.φH = γ₂.φH := by rw [eq] lemma congr_φQ {γ₁ γ₂ : RightHomologyMapData φ h₁ h₂} (eq : γ₁ = γ₂) : γ₁.φQ = γ₂.φQ := by rw [eq] /-- When `S₁.f`, `S₁.g`, `S₂.f` and `S₂.g` are all zero, the action on right homology of a morphism `φ : S₁ ⟶ S₂` is given by the action `φ.τ₂` on the middle objects. -/ @[simps] def ofZeros (φ : S₁ ⟶ S₂) (hf₁ : S₁.f = 0) (hg₁ : S₁.g = 0) (hf₂ : S₂.f = 0) (hg₂ : S₂.g = 0) : RightHomologyMapData φ (RightHomologyData.ofZeros S₁ hf₁ hg₁) (RightHomologyData.ofZeros S₂ hf₂ hg₂) where φQ := φ.τ₂ φH := φ.τ₂ /-- When `S₁.f` and `S₂.f` are zero and we have chosen limit kernel forks `c₁` and `c₂` for `S₁.g` and `S₂.g` respectively, the action on right homology of a morphism `φ : S₁ ⟶ S₂` of short complexes is given by the unique morphism `f : c₁.pt ⟶ c₂.pt` such that `c₁.ι ≫ φ.τ₂ = f ≫ c₂.ι`. -/ @[simps] def ofIsLimitKernelFork (φ : S₁ ⟶ S₂) (hf₁ : S₁.f = 0) (c₁ : KernelFork S₁.g) (hc₁ : IsLimit c₁) (hf₂ : S₂.f = 0) (c₂ : KernelFork S₂.g) (hc₂ : IsLimit c₂) (f : c₁.pt ⟶ c₂.pt) (comm : c₁.ι ≫ φ.τ₂ = f ≫ c₂.ι) : RightHomologyMapData φ (RightHomologyData.ofIsLimitKernelFork S₁ hf₁ c₁ hc₁) (RightHomologyData.ofIsLimitKernelFork S₂ hf₂ c₂ hc₂) where φQ := φ.τ₂ φH := f commg' := by simp only [RightHomologyData.ofIsLimitKernelFork_g', φ.comm₂₃] commι := comm.symm /-- When `S₁.g` and `S₂.g` are zero and we have chosen colimit cokernel coforks `c₁` and `c₂` for `S₁.f` and `S₂.f` respectively, the action on right homology of a morphism `φ : S₁ ⟶ S₂` of short complexes is given by the unique morphism `f : c₁.pt ⟶ c₂.pt` such that `φ.τ₂ ≫ c₂.π = c₁.π ≫ f`. -/ @[simps] def ofIsColimitCokernelCofork (φ : S₁ ⟶ S₂) (hg₁ : S₁.g = 0) (c₁ : CokernelCofork S₁.f) (hc₁ : IsColimit c₁) (hg₂ : S₂.g = 0) (c₂ : CokernelCofork S₂.f) (hc₂ : IsColimit c₂) (f : c₁.pt ⟶ c₂.pt) (comm : φ.τ₂ ≫ c₂.π = c₁.π ≫ f) : RightHomologyMapData φ (RightHomologyData.ofIsColimitCokernelCofork S₁ hg₁ c₁ hc₁) (RightHomologyData.ofIsColimitCokernelCofork S₂ hg₂ c₂ hc₂) where φQ := f φH := f commp := comm.symm variable (S) /-- When both maps `S.f` and `S.g` of a short complex `S` are zero, this is the right homology map data (for the identity of `S`) which relates the right homology data `RightHomologyData.ofIsLimitKernelFork` and `ofZeros` . -/ @[simps] def compatibilityOfZerosOfIsLimitKernelFork (hf : S.f = 0) (hg : S.g = 0) (c : KernelFork S.g) (hc : IsLimit c) : RightHomologyMapData (𝟙 S) (RightHomologyData.ofIsLimitKernelFork S hf c hc) (RightHomologyData.ofZeros S hf hg) where φQ := 𝟙 _ φH := c.ι /-- When both maps `S.f` and `S.g` of a short complex `S` are zero, this is the right homology map data (for the identity of `S`) which relates the right homology data `ofZeros` and `ofIsColimitCokernelCofork`. -/ @[simps] def compatibilityOfZerosOfIsColimitCokernelCofork (hf : S.f = 0) (hg : S.g = 0) (c : CokernelCofork S.f) (hc : IsColimit c) : RightHomologyMapData (𝟙 S) (RightHomologyData.ofZeros S hf hg) (RightHomologyData.ofIsColimitCokernelCofork S hg c hc) where φQ := c.π φH := c.π end RightHomologyMapData end section variable (S) variable [S.HasRightHomology] /-- The right homology of a short complex, given by the `H` field of a chosen right homology data. -/ noncomputable def rightHomology : C := S.rightHomologyData.H /-- The "opcycles" of a short complex, given by the `Q` field of a chosen right homology data. This is the dual notion to cycles. -/ noncomputable def opcycles : C := S.rightHomologyData.Q /-- The canonical map `S.rightHomology ⟶ S.opcycles`. -/ noncomputable def rightHomologyι : S.rightHomology ⟶ S.opcycles := S.rightHomologyData.ι /-- The projection `S.X₂ ⟶ S.opcycles`. -/ noncomputable def pOpcycles : S.X₂ ⟶ S.opcycles := S.rightHomologyData.p /-- The canonical map `S.opcycles ⟶ X₃`. -/ noncomputable def fromOpcycles : S.opcycles ⟶ S.X₃ := S.rightHomologyData.g' @[reassoc (attr := simp)] lemma f_pOpcycles : S.f ≫ S.pOpcycles = 0 := S.rightHomologyData.wp @[reassoc (attr := simp)] lemma p_fromOpcycles : S.pOpcycles ≫ S.fromOpcycles = S.g := S.rightHomologyData.p_g' instance : Epi S.pOpcycles := by dsimp only [pOpcycles] infer_instance instance : Mono S.rightHomologyι := by dsimp only [rightHomologyι] infer_instance lemma rightHomology_ext_iff {A : C} (f₁ f₂ : A ⟶ S.rightHomology) : f₁ = f₂ ↔ f₁ ≫ S.rightHomologyι = f₂ ≫ S.rightHomologyι := by rw [cancel_mono] @[ext] lemma rightHomology_ext {A : C} (f₁ f₂ : A ⟶ S.rightHomology) (h : f₁ ≫ S.rightHomologyι = f₂ ≫ S.rightHomologyι) : f₁ = f₂ := by simpa only [rightHomology_ext_iff] lemma opcycles_ext_iff {A : C} (f₁ f₂ : S.opcycles ⟶ A) : f₁ = f₂ ↔ S.pOpcycles ≫ f₁ = S.pOpcycles ≫ f₂ := by rw [cancel_epi] @[ext] lemma opcycles_ext {A : C} (f₁ f₂ : S.opcycles ⟶ A) (h : S.pOpcycles ≫ f₁ = S.pOpcycles ≫ f₂) : f₁ = f₂ := by simpa only [opcycles_ext_iff] lemma isIso_pOpcycles (hf : S.f = 0) : IsIso S.pOpcycles := RightHomologyData.isIso_p _ hf /-- When `S.f = 0`, this is the canonical isomorphism `S.opcycles ≅ S.X₂` induced by `S.pOpcycles`. -/ @[simps! inv] noncomputable def opcyclesIsoX₂ (hf : S.f = 0) : S.opcycles ≅ S.X₂ := by have := S.isIso_pOpcycles hf exact (asIso S.pOpcycles).symm @[reassoc (attr := simp)] lemma opcyclesIsoX₂_inv_hom_id (hf : S.f = 0) : S.pOpcycles ≫ (S.opcyclesIsoX₂ hf).hom = 𝟙 _ := (S.opcyclesIsoX₂ hf).inv_hom_id @[reassoc (attr := simp)] lemma opcyclesIsoX₂_hom_inv_id (hf : S.f = 0) : (S.opcyclesIsoX₂ hf).hom ≫ S.pOpcycles = 𝟙 _ := (S.opcyclesIsoX₂ hf).hom_inv_id lemma isIso_rightHomologyι (hg : S.g = 0) : IsIso S.rightHomologyι := RightHomologyData.isIso_ι _ hg /-- When `S.g = 0`, this is the canonical isomorphism `S.opcycles ≅ S.rightHomology` induced by `S.rightHomologyι`. -/ @[simps! inv] noncomputable def opcyclesIsoRightHomology (hg : S.g = 0) : S.opcycles ≅ S.rightHomology := by have := S.isIso_rightHomologyι hg exact (asIso S.rightHomologyι).symm @[reassoc (attr := simp)] lemma opcyclesIsoRightHomology_inv_hom_id (hg : S.g = 0) : S.rightHomologyι ≫ (S.opcyclesIsoRightHomology hg).hom = 𝟙 _ := (S.opcyclesIsoRightHomology hg).inv_hom_id @[reassoc (attr := simp)] lemma opcyclesIsoRightHomology_hom_inv_id (hg : S.g = 0) : (S.opcyclesIsoRightHomology hg).hom ≫ S.rightHomologyι = 𝟙 _ := (S.opcyclesIsoRightHomology hg).hom_inv_id end section variable (φ : S₁ ⟶ S₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) /-- The (unique) right homology map data associated to a morphism of short complexes that are both equipped with right homology data. -/ def rightHomologyMapData : RightHomologyMapData φ h₁ h₂ := default /-- Given a morphism `φ : S₁ ⟶ S₂` of short complexes and right homology data `h₁` and `h₂` for `S₁` and `S₂` respectively, this is the induced right homology map `h₁.H ⟶ h₁.H`. -/ def rightHomologyMap' : h₁.H ⟶ h₂.H := (rightHomologyMapData φ _ _).φH /-- Given a morphism `φ : S₁ ⟶ S₂` of short complexes and right homology data `h₁` and `h₂` for `S₁` and `S₂` respectively, this is the induced morphism `h₁.K ⟶ h₁.K` on opcycles. -/ def opcyclesMap' : h₁.Q ⟶ h₂.Q := (rightHomologyMapData φ _ _).φQ @[reassoc (attr := simp)] lemma p_opcyclesMap' : h₁.p ≫ opcyclesMap' φ h₁ h₂ = φ.τ₂ ≫ h₂.p := RightHomologyMapData.commp _ @[reassoc (attr := simp)] lemma opcyclesMap'_g' : opcyclesMap' φ h₁ h₂ ≫ h₂.g' = h₁.g' ≫ φ.τ₃ := by simp only [← cancel_epi h₁.p, assoc, φ.comm₂₃, p_opcyclesMap'_assoc, RightHomologyData.p_g'_assoc, RightHomologyData.p_g'] @[reassoc (attr := simp)] lemma rightHomologyι_naturality' : rightHomologyMap' φ h₁ h₂ ≫ h₂.ι = h₁.ι ≫ opcyclesMap' φ h₁ h₂ := RightHomologyMapData.commι _ end section variable [HasRightHomology S₁] [HasRightHomology S₂] (φ : S₁ ⟶ S₂) /-- The (right) homology map `S₁.rightHomology ⟶ S₂.rightHomology` induced by a morphism `S₁ ⟶ S₂` of short complexes. -/ noncomputable def rightHomologyMap : S₁.rightHomology ⟶ S₂.rightHomology := rightHomologyMap' φ _ _ /-- The morphism `S₁.opcycles ⟶ S₂.opcycles` induced by a morphism `S₁ ⟶ S₂` of short complexes. -/ noncomputable def opcyclesMap : S₁.opcycles ⟶ S₂.opcycles := opcyclesMap' φ _ _ @[reassoc (attr := simp)] lemma p_opcyclesMap : S₁.pOpcycles ≫ opcyclesMap φ = φ.τ₂ ≫ S₂.pOpcycles := p_opcyclesMap' _ _ _ @[reassoc (attr := simp)] lemma fromOpcycles_naturality : opcyclesMap φ ≫ S₂.fromOpcycles = S₁.fromOpcycles ≫ φ.τ₃ := opcyclesMap'_g' _ _ _ @[reassoc (attr := simp)] lemma rightHomologyι_naturality : rightHomologyMap φ ≫ S₂.rightHomologyι = S₁.rightHomologyι ≫ opcyclesMap φ := rightHomologyι_naturality' _ _ _ end namespace RightHomologyMapData variable {φ : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} (γ : RightHomologyMapData φ h₁ h₂) lemma rightHomologyMap'_eq : rightHomologyMap' φ h₁ h₂ = γ.φH := RightHomologyMapData.congr_φH (Subsingleton.elim _ _) lemma opcyclesMap'_eq : opcyclesMap' φ h₁ h₂ = γ.φQ := RightHomologyMapData.congr_φQ (Subsingleton.elim _ _) end RightHomologyMapData @[simp] lemma rightHomologyMap'_id (h : S.RightHomologyData) : rightHomologyMap' (𝟙 S) h h = 𝟙 _ := (RightHomologyMapData.id h).rightHomologyMap'_eq @[simp] lemma opcyclesMap'_id (h : S.RightHomologyData) : opcyclesMap' (𝟙 S) h h = 𝟙 _ := (RightHomologyMapData.id h).opcyclesMap'_eq variable (S) @[simp] lemma rightHomologyMap_id [HasRightHomology S] : rightHomologyMap (𝟙 S) = 𝟙 _ := rightHomologyMap'_id _ @[simp] lemma opcyclesMap_id [HasRightHomology S] : opcyclesMap (𝟙 S) = 𝟙 _ := opcyclesMap'_id _ @[simp] lemma rightHomologyMap'_zero (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : rightHomologyMap' 0 h₁ h₂ = 0 := (RightHomologyMapData.zero h₁ h₂).rightHomologyMap'_eq @[simp] lemma opcyclesMap'_zero (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : opcyclesMap' 0 h₁ h₂ = 0 := (RightHomologyMapData.zero h₁ h₂).opcyclesMap'_eq variable (S₁ S₂) @[simp] lemma rightHomologyMap_zero [HasRightHomology S₁] [HasRightHomology S₂] : rightHomologyMap (0 : S₁ ⟶ S₂) = 0 := rightHomologyMap'_zero _ _ @[simp] lemma opcyclesMap_zero [HasRightHomology S₁] [HasRightHomology S₂] : opcyclesMap (0 : S₁ ⟶ S₂) = 0 := opcyclesMap'_zero _ _ variable {S₁ S₂} @[reassoc] lemma rightHomologyMap'_comp (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) (h₃ : S₃.RightHomologyData) : rightHomologyMap' (φ₁ ≫ φ₂) h₁ h₃ = rightHomologyMap' φ₁ h₁ h₂ ≫ rightHomologyMap' φ₂ h₂ h₃ := by let γ₁ := rightHomologyMapData φ₁ h₁ h₂ let γ₂ := rightHomologyMapData φ₂ h₂ h₃ rw [γ₁.rightHomologyMap'_eq, γ₂.rightHomologyMap'_eq, (γ₁.comp γ₂).rightHomologyMap'_eq, RightHomologyMapData.comp_φH] @[reassoc] lemma opcyclesMap'_comp (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) (h₃ : S₃.RightHomologyData) : opcyclesMap' (φ₁ ≫ φ₂) h₁ h₃ = opcyclesMap' φ₁ h₁ h₂ ≫ opcyclesMap' φ₂ h₂ h₃ := by let γ₁ := rightHomologyMapData φ₁ h₁ h₂ let γ₂ := rightHomologyMapData φ₂ h₂ h₃ rw [γ₁.opcyclesMap'_eq, γ₂.opcyclesMap'_eq, (γ₁.comp γ₂).opcyclesMap'_eq, RightHomologyMapData.comp_φQ] @[simp] lemma rightHomologyMap_comp [HasRightHomology S₁] [HasRightHomology S₂] [HasRightHomology S₃] (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) : rightHomologyMap (φ₁ ≫ φ₂) = rightHomologyMap φ₁ ≫ rightHomologyMap φ₂ := rightHomologyMap'_comp _ _ _ _ _ @[simp] lemma opcyclesMap_comp [HasRightHomology S₁] [HasRightHomology S₂] [HasRightHomology S₃] (φ₁ : S₁ ⟶ S₂) (φ₂ : S₂ ⟶ S₃) : opcyclesMap (φ₁ ≫ φ₂) = opcyclesMap φ₁ ≫ opcyclesMap φ₂ := opcyclesMap'_comp _ _ _ _ _ attribute [simp] rightHomologyMap_comp opcyclesMap_comp /-- An isomorphism of short complexes `S₁ ≅ S₂` induces an isomorphism on the `H` fields of right homology data of `S₁` and `S₂`. -/ @[simps] def rightHomologyMapIso' (e : S₁ ≅ S₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : h₁.H ≅ h₂.H where hom := rightHomologyMap' e.hom h₁ h₂ inv := rightHomologyMap' e.inv h₂ h₁ hom_inv_id := by rw [← rightHomologyMap'_comp, e.hom_inv_id, rightHomologyMap'_id] inv_hom_id := by rw [← rightHomologyMap'_comp, e.inv_hom_id, rightHomologyMap'_id] instance isIso_rightHomologyMap'_of_isIso (φ : S₁ ⟶ S₂) [IsIso φ] (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : IsIso (rightHomologyMap' φ h₁ h₂) := (inferInstance : IsIso (rightHomologyMapIso' (asIso φ) h₁ h₂).hom) /-- An isomorphism of short complexes `S₁ ≅ S₂` induces an isomorphism on the `Q` fields of right homology data of `S₁` and `S₂`. -/ @[simps] def opcyclesMapIso' (e : S₁ ≅ S₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : h₁.Q ≅ h₂.Q where hom := opcyclesMap' e.hom h₁ h₂ inv := opcyclesMap' e.inv h₂ h₁ hom_inv_id := by rw [← opcyclesMap'_comp, e.hom_inv_id, opcyclesMap'_id] inv_hom_id := by rw [← opcyclesMap'_comp, e.inv_hom_id, opcyclesMap'_id] instance isIso_opcyclesMap'_of_isIso (φ : S₁ ⟶ S₂) [IsIso φ] (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : IsIso (opcyclesMap' φ h₁ h₂) := (inferInstance : IsIso (opcyclesMapIso' (asIso φ) h₁ h₂).hom) /-- The isomorphism `S₁.rightHomology ≅ S₂.rightHomology` induced by an isomorphism of short complexes `S₁ ≅ S₂`. -/ @[simps] noncomputable def rightHomologyMapIso (e : S₁ ≅ S₂) [S₁.HasRightHomology] [S₂.HasRightHomology] : S₁.rightHomology ≅ S₂.rightHomology where hom := rightHomologyMap e.hom inv := rightHomologyMap e.inv hom_inv_id := by rw [← rightHomologyMap_comp, e.hom_inv_id, rightHomologyMap_id] inv_hom_id := by rw [← rightHomologyMap_comp, e.inv_hom_id, rightHomologyMap_id] instance isIso_rightHomologyMap_of_iso (φ : S₁ ⟶ S₂) [IsIso φ] [S₁.HasRightHomology] [S₂.HasRightHomology] : IsIso (rightHomologyMap φ) := (inferInstance : IsIso (rightHomologyMapIso (asIso φ)).hom) /-- The isomorphism `S₁.opcycles ≅ S₂.opcycles` induced by an isomorphism of short complexes `S₁ ≅ S₂`. -/ @[simps] noncomputable def opcyclesMapIso (e : S₁ ≅ S₂) [S₁.HasRightHomology] [S₂.HasRightHomology] : S₁.opcycles ≅ S₂.opcycles where hom := opcyclesMap e.hom inv := opcyclesMap e.inv hom_inv_id := by rw [← opcyclesMap_comp, e.hom_inv_id, opcyclesMap_id] inv_hom_id := by rw [← opcyclesMap_comp, e.inv_hom_id, opcyclesMap_id] instance isIso_opcyclesMap_of_iso (φ : S₁ ⟶ S₂) [IsIso φ] [S₁.HasRightHomology] [S₂.HasRightHomology] : IsIso (opcyclesMap φ) := (inferInstance : IsIso (opcyclesMapIso (asIso φ)).hom) variable {S} namespace RightHomologyData variable (h : S.RightHomologyData) [S.HasRightHomology] /-- The isomorphism `S.rightHomology ≅ h.H` induced by a right homology data `h` for a short complex `S`. -/ noncomputable def rightHomologyIso : S.rightHomology ≅ h.H := rightHomologyMapIso' (Iso.refl _) _ _ /-- The isomorphism `S.opcycles ≅ h.Q` induced by a right homology data `h` for a short complex `S`. -/ noncomputable def opcyclesIso : S.opcycles ≅ h.Q := opcyclesMapIso' (Iso.refl _) _ _ @[reassoc (attr := simp)] lemma p_comp_opcyclesIso_inv : h.p ≫ h.opcyclesIso.inv = S.pOpcycles := by dsimp [pOpcycles, RightHomologyData.opcyclesIso] simp only [p_opcyclesMap', id_τ₂, id_comp] @[reassoc (attr := simp)] lemma pOpcycles_comp_opcyclesIso_hom : S.pOpcycles ≫ h.opcyclesIso.hom = h.p := by simp only [← h.p_comp_opcyclesIso_inv, assoc, Iso.inv_hom_id, comp_id] @[reassoc (attr := simp)] lemma rightHomologyIso_inv_comp_rightHomologyι : h.rightHomologyIso.inv ≫ S.rightHomologyι = h.ι ≫ h.opcyclesIso.inv := by dsimp only [rightHomologyι, rightHomologyIso, opcyclesIso, rightHomologyMapIso', opcyclesMapIso', Iso.refl] rw [rightHomologyι_naturality'] @[reassoc (attr := simp)] lemma rightHomologyIso_hom_comp_ι : h.rightHomologyIso.hom ≫ h.ι = S.rightHomologyι ≫ h.opcyclesIso.hom := by simp only [← cancel_mono h.opcyclesIso.inv, ← cancel_epi h.rightHomologyIso.inv, assoc, Iso.inv_hom_id_assoc, Iso.hom_inv_id, comp_id, rightHomologyIso_inv_comp_rightHomologyι] end RightHomologyData namespace RightHomologyMapData variable {φ : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} (γ : RightHomologyMapData φ h₁ h₂) lemma rightHomologyMap_eq [S₁.HasRightHomology] [S₂.HasRightHomology] : rightHomologyMap φ = h₁.rightHomologyIso.hom ≫ γ.φH ≫ h₂.rightHomologyIso.inv := by dsimp [RightHomologyData.rightHomologyIso, rightHomologyMapIso'] rw [← γ.rightHomologyMap'_eq, ← rightHomologyMap'_comp, ← rightHomologyMap'_comp, id_comp, comp_id] rfl lemma opcyclesMap_eq [S₁.HasRightHomology] [S₂.HasRightHomology] : opcyclesMap φ = h₁.opcyclesIso.hom ≫ γ.φQ ≫ h₂.opcyclesIso.inv := by dsimp [RightHomologyData.opcyclesIso, cyclesMapIso'] rw [← γ.opcyclesMap'_eq, ← opcyclesMap'_comp, ← opcyclesMap'_comp, id_comp, comp_id] rfl lemma rightHomologyMap_comm [S₁.HasRightHomology] [S₂.HasRightHomology] : rightHomologyMap φ ≫ h₂.rightHomologyIso.hom = h₁.rightHomologyIso.hom ≫ γ.φH := by simp only [γ.rightHomologyMap_eq, assoc, Iso.inv_hom_id, comp_id] lemma opcyclesMap_comm [S₁.HasRightHomology] [S₂.HasRightHomology] : opcyclesMap φ ≫ h₂.opcyclesIso.hom = h₁.opcyclesIso.hom ≫ γ.φQ := by simp only [γ.opcyclesMap_eq, assoc, Iso.inv_hom_id, comp_id] end RightHomologyMapData section variable (C) variable [HasKernels C] [HasCokernels C] /-- The right homology functor `ShortComplex C ⥤ C`, where the right homology of a short complex `S` is understood as a kernel of the obvious map `S.fromOpcycles : S.opcycles ⟶ S.X₃` where `S.opcycles` is a cokernel of `S.f : S.X₁ ⟶ S.X₂`. -/ @[simps] noncomputable def rightHomologyFunctor : ShortComplex C ⥤ C where obj S := S.rightHomology map := rightHomologyMap /-- The opcycles functor `ShortComplex C ⥤ C` which sends a short complex `S` to `S.opcycles` which is a cokernel of `S.f : S.X₁ ⟶ S.X₂`. -/ @[simps] noncomputable def opcyclesFunctor : ShortComplex C ⥤ C where obj S := S.opcycles map := opcyclesMap /-- The natural transformation `S.rightHomology ⟶ S.opcycles` for all short complexes `S`. -/ @[simps] noncomputable def rightHomologyιNatTrans : rightHomologyFunctor C ⟶ opcyclesFunctor C where app S := rightHomologyι S naturality := fun _ _ φ => rightHomologyι_naturality φ /-- The natural transformation `S.X₂ ⟶ S.opcycles` for all short complexes `S`. -/ @[simps] noncomputable def pOpcyclesNatTrans : ShortComplex.π₂ ⟶ opcyclesFunctor C where app S := S.pOpcycles /-- The natural transformation `S.opcycles ⟶ S.X₃` for all short complexes `S`. -/ @[simps] noncomputable def fromOpcyclesNatTrans : opcyclesFunctor C ⟶ π₃ where app S := S.fromOpcycles naturality := fun _ _ φ => fromOpcycles_naturality φ end /-- A left homology map data for a morphism of short complexes induces a right homology map data in the opposite category. -/ @[simps] def LeftHomologyMapData.op {S₁ S₂ : ShortComplex C} {φ : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} (ψ : LeftHomologyMapData φ h₁ h₂) : RightHomologyMapData (opMap φ) h₂.op h₁.op where φQ := ψ.φK.op φH := ψ.φH.op commp := Quiver.Hom.unop_inj (by simp) commg' := Quiver.Hom.unop_inj (by simp) commι := Quiver.Hom.unop_inj (by simp) /-- A left homology map data for a morphism of short complexes in the opposite category induces a right homology map data in the original category. -/ @[simps] def LeftHomologyMapData.unop {S₁ S₂ : ShortComplex Cᵒᵖ} {φ : S₁ ⟶ S₂} {h₁ : S₁.LeftHomologyData} {h₂ : S₂.LeftHomologyData} (ψ : LeftHomologyMapData φ h₁ h₂) : RightHomologyMapData (unopMap φ) h₂.unop h₁.unop where φQ := ψ.φK.unop φH := ψ.φH.unop commp := Quiver.Hom.op_inj (by simp) commg' := Quiver.Hom.op_inj (by simp) commι := Quiver.Hom.op_inj (by simp) /-- A right homology map data for a morphism of short complexes induces a left homology map data in the opposite category. -/ @[simps] def RightHomologyMapData.op {S₁ S₂ : ShortComplex C} {φ : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} (ψ : RightHomologyMapData φ h₁ h₂) : LeftHomologyMapData (opMap φ) h₂.op h₁.op where φK := ψ.φQ.op φH := ψ.φH.op commi := Quiver.Hom.unop_inj (by simp) commf' := Quiver.Hom.unop_inj (by simp) commπ := Quiver.Hom.unop_inj (by simp) /-- A right homology map data for a morphism of short complexes in the opposite category induces a left homology map data in the original category. -/ @[simps] def RightHomologyMapData.unop {S₁ S₂ : ShortComplex Cᵒᵖ} {φ : S₁ ⟶ S₂} {h₁ : S₁.RightHomologyData} {h₂ : S₂.RightHomologyData} (ψ : RightHomologyMapData φ h₁ h₂) : LeftHomologyMapData (unopMap φ) h₂.unop h₁.unop where φK := ψ.φQ.unop φH := ψ.φH.unop commi := Quiver.Hom.op_inj (by simp) commf' := Quiver.Hom.op_inj (by simp) commπ := Quiver.Hom.op_inj (by simp) variable (S) /-- The right homology in the opposite category of the opposite of a short complex identifies to the left homology of this short complex. -/ noncomputable def rightHomologyOpIso [S.HasLeftHomology] : S.op.rightHomology ≅ Opposite.op S.leftHomology := S.leftHomologyData.op.rightHomologyIso /-- The left homology in the opposite category of the opposite of a short complex identifies to the right homology of this short complex. -/ noncomputable def leftHomologyOpIso [S.HasRightHomology] : S.op.leftHomology ≅ Opposite.op S.rightHomology := S.rightHomologyData.op.leftHomologyIso /-- The opcycles in the opposite category of the opposite of a short complex identifies to the cycles of this short complex. -/ noncomputable def opcyclesOpIso [S.HasLeftHomology] : S.op.opcycles ≅ Opposite.op S.cycles := S.leftHomologyData.op.opcyclesIso /-- The cycles in the opposite category of the opposite of a short complex identifies to the opcycles of this short complex. -/ noncomputable def cyclesOpIso [S.HasRightHomology] : S.op.cycles ≅ Opposite.op S.opcycles := S.rightHomologyData.op.cyclesIso @[simp] lemma leftHomologyMap'_op (φ : S₁ ⟶ S₂) (h₁ : S₁.LeftHomologyData) (h₂ : S₂.LeftHomologyData) : (leftHomologyMap' φ h₁ h₂).op = rightHomologyMap' (opMap φ) h₂.op h₁.op := by let γ : LeftHomologyMapData φ h₁ h₂ := leftHomologyMapData φ h₁ h₂ simp only [γ.leftHomologyMap'_eq, γ.op.rightHomologyMap'_eq, LeftHomologyMapData.op_φH] lemma leftHomologyMap_op (φ : S₁ ⟶ S₂) [S₁.HasLeftHomology] [S₂.HasLeftHomology] : (leftHomologyMap φ).op = S₂.rightHomologyOpIso.inv ≫ rightHomologyMap (opMap φ) ≫ S₁.rightHomologyOpIso.hom := by dsimp [rightHomologyOpIso, RightHomologyData.rightHomologyIso, rightHomologyMap, leftHomologyMap] simp only [← rightHomologyMap'_comp, comp_id, id_comp, leftHomologyMap'_op] @[simp] lemma rightHomologyMap'_op (φ : S₁ ⟶ S₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : (rightHomologyMap' φ h₁ h₂).op = leftHomologyMap' (opMap φ) h₂.op h₁.op := by let γ : RightHomologyMapData φ h₁ h₂ := rightHomologyMapData φ h₁ h₂ simp only [γ.rightHomologyMap'_eq, γ.op.leftHomologyMap'_eq, RightHomologyMapData.op_φH] lemma rightHomologyMap_op (φ : S₁ ⟶ S₂) [S₁.HasRightHomology] [S₂.HasRightHomology] : (rightHomologyMap φ).op = S₂.leftHomologyOpIso.inv ≫ leftHomologyMap (opMap φ) ≫ S₁.leftHomologyOpIso.hom := by dsimp [leftHomologyOpIso, LeftHomologyData.leftHomologyIso, leftHomologyMap, rightHomologyMap] simp only [← leftHomologyMap'_comp, comp_id, id_comp, rightHomologyMap'_op] namespace RightHomologyData section variable (φ : S₁ ⟶ S₂) (h : RightHomologyData S₁) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a right homology data for `S₁` induces a right homology data for `S₂` with the same `Q` and `H` fields. This is obtained by dualising `LeftHomologyData.ofEpiOfIsIsoOfMono'`. The inverse construction is `ofEpiOfIsIsoOfMono'`. -/ noncomputable def ofEpiOfIsIsoOfMono : RightHomologyData S₂ := by haveI : Epi (opMap φ).τ₁ := by dsimp; infer_instance haveI : IsIso (opMap φ).τ₂ := by dsimp; infer_instance haveI : Mono (opMap φ).τ₃ := by dsimp; infer_instance exact (LeftHomologyData.ofEpiOfIsIsoOfMono' (opMap φ) h.op).unop @[simp] lemma ofEpiOfIsIsoOfMono_Q : (ofEpiOfIsIsoOfMono φ h).Q = h.Q := rfl @[simp] lemma ofEpiOfIsIsoOfMono_H : (ofEpiOfIsIsoOfMono φ h).H = h.H := rfl @[simp] lemma ofEpiOfIsIsoOfMono_p : (ofEpiOfIsIsoOfMono φ h).p = inv φ.τ₂ ≫ h.p := by simp [ofEpiOfIsIsoOfMono, opMap] @[simp] lemma ofEpiOfIsIsoOfMono_ι : (ofEpiOfIsIsoOfMono φ h).ι = h.ι := rfl @[simp] lemma ofEpiOfIsIsoOfMono_g' : (ofEpiOfIsIsoOfMono φ h).g' = h.g' ≫ φ.τ₃ := by simp [ofEpiOfIsIsoOfMono, opMap] end section variable (φ : S₁ ⟶ S₂) (h : RightHomologyData S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a right homology data for `S₂` induces a right homology data for `S₁` with the same `Q` and `H` fields. This is obtained by dualising `LeftHomologyData.ofEpiOfIsIsoOfMono`. The inverse construction is `ofEpiOfIsIsoOfMono`. -/ noncomputable def ofEpiOfIsIsoOfMono' : RightHomologyData S₁ := by haveI : Epi (opMap φ).τ₁ := by dsimp; infer_instance haveI : IsIso (opMap φ).τ₂ := by dsimp; infer_instance haveI : Mono (opMap φ).τ₃ := by dsimp; infer_instance exact (LeftHomologyData.ofEpiOfIsIsoOfMono (opMap φ) h.op).unop @[simp] lemma ofEpiOfIsIsoOfMono'_Q : (ofEpiOfIsIsoOfMono' φ h).Q = h.Q := rfl @[simp] lemma ofEpiOfIsIsoOfMono'_H : (ofEpiOfIsIsoOfMono' φ h).H = h.H := rfl @[simp] lemma ofEpiOfIsIsoOfMono'_p : (ofEpiOfIsIsoOfMono' φ h).p = φ.τ₂ ≫ h.p := by simp [ofEpiOfIsIsoOfMono', opMap] @[simp] lemma ofEpiOfIsIsoOfMono'_ι : (ofEpiOfIsIsoOfMono' φ h).ι = h.ι := rfl @[simp] lemma ofEpiOfIsIsoOfMono'_g'_τ₃ : (ofEpiOfIsIsoOfMono' φ h).g' ≫ φ.τ₃ = h.g' := by rw [← cancel_epi (ofEpiOfIsIsoOfMono' φ h).p, p_g'_assoc, ofEpiOfIsIsoOfMono'_p, assoc, p_g', φ.comm₂₃] end /-- If `e : S₁ ≅ S₂` is an isomorphism of short complexes and `h₁ : RightomologyData S₁`, this is the right homology data for `S₂` deduced from the isomorphism. -/ noncomputable def ofIso (e : S₁ ≅ S₂) (h₁ : RightHomologyData S₁) : RightHomologyData S₂ := h₁.ofEpiOfIsIsoOfMono e.hom end RightHomologyData lemma hasRightHomology_of_epi_of_isIso_of_mono (φ : S₁ ⟶ S₂) [HasRightHomology S₁] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HasRightHomology S₂ := HasRightHomology.mk' (RightHomologyData.ofEpiOfIsIsoOfMono φ S₁.rightHomologyData) lemma hasRightHomology_of_epi_of_isIso_of_mono' (φ : S₁ ⟶ S₂) [HasRightHomology S₂] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : HasRightHomology S₁ := HasRightHomology.mk' (RightHomologyData.ofEpiOfIsIsoOfMono' φ S₂.rightHomologyData) lemma hasRightHomology_of_iso {S₁ S₂ : ShortComplex C} (e : S₁ ≅ S₂) [HasRightHomology S₁] : HasRightHomology S₂ := hasRightHomology_of_epi_of_isIso_of_mono e.hom namespace RightHomologyMapData /-- This right homology map data expresses compatibilities of the right homology data constructed by `RightHomologyData.ofEpiOfIsIsoOfMono` -/ @[simps] def ofEpiOfIsIsoOfMono (φ : S₁ ⟶ S₂) (h : RightHomologyData S₁) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : RightHomologyMapData φ h (RightHomologyData.ofEpiOfIsIsoOfMono φ h) where φQ := 𝟙 _ φH := 𝟙 _ /-- This right homology map data expresses compatibilities of the right homology data constructed by `RightHomologyData.ofEpiOfIsIsoOfMono'` -/ @[simps] noncomputable def ofEpiOfIsIsoOfMono' (φ : S₁ ⟶ S₂) (h : RightHomologyData S₂) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : RightHomologyMapData φ (RightHomologyData.ofEpiOfIsIsoOfMono' φ h) h where φQ := 𝟙 _ φH := 𝟙 _ end RightHomologyMapData instance (φ : S₁ ⟶ S₂) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : IsIso (rightHomologyMap' φ h₁ h₂) := by let h₂' := RightHomologyData.ofEpiOfIsIsoOfMono φ h₁ haveI : IsIso (rightHomologyMap' φ h₁ h₂') := by rw [(RightHomologyMapData.ofEpiOfIsIsoOfMono φ h₁).rightHomologyMap'_eq] dsimp infer_instance have eq := rightHomologyMap'_comp φ (𝟙 S₂) h₁ h₂' h₂ rw [comp_id] at eq rw [eq] infer_instance /-- If a morphism of short complexes `φ : S₁ ⟶ S₂` is such that `φ.τ₁` is epi, `φ.τ₂` is an iso, and `φ.τ₃` is mono, then the induced morphism on right homology is an isomorphism. -/ instance (φ : S₁ ⟶ S₂) [S₁.HasRightHomology] [S₂.HasRightHomology] [Epi φ.τ₁] [IsIso φ.τ₂] [Mono φ.τ₃] : IsIso (rightHomologyMap φ) := by dsimp only [rightHomologyMap] infer_instance variable (C) section variable [HasKernels C] [HasCokernels C] [HasKernels Cᵒᵖ] [HasCokernels Cᵒᵖ] /-- The opposite of the right homology functor is the left homology functor. -/ @[simps!] noncomputable def rightHomologyFunctorOpNatIso : (rightHomologyFunctor C).op ≅ opFunctor C ⋙ leftHomologyFunctor Cᵒᵖ := NatIso.ofComponents (fun S => (leftHomologyOpIso S.unop).symm) (by simp [rightHomologyMap_op]) /-- The opposite of the left homology functor is the right homology functor. -/ @[simps!] noncomputable def leftHomologyFunctorOpNatIso : (leftHomologyFunctor C).op ≅ opFunctor C ⋙ rightHomologyFunctor Cᵒᵖ := NatIso.ofComponents (fun S => (rightHomologyOpIso S.unop).symm) (by simp [leftHomologyMap_op]) end section variable {C} variable (h : RightHomologyData S) {A : C} (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) [HasRightHomology S] /-- A morphism `k : S.X₂ ⟶ A` such that `S.f ≫ k = 0` descends to a morphism `S.opcycles ⟶ A`. -/ noncomputable def descOpcycles : S.opcycles ⟶ A := S.rightHomologyData.descQ k hk @[reassoc (attr := simp)] lemma p_descOpcycles : S.pOpcycles ≫ S.descOpcycles k hk = k := RightHomologyData.p_descQ _ k hk @[reassoc] lemma descOpcycles_comp {A' : C} (α : A ⟶ A') : S.descOpcycles k hk ≫ α = S.descOpcycles (k ≫ α) (by rw [reassoc_of% hk, zero_comp]) := by simp only [← cancel_epi S.pOpcycles, p_descOpcycles_assoc, p_descOpcycles] /-- Via `S.pOpcycles : S.X₂ ⟶ S.opcycles`, the object `S.opcycles` identifies to the cokernel of `S.f : S.X₁ ⟶ S.X₂`. -/ noncomputable def opcyclesIsCokernel : IsColimit (CokernelCofork.ofπ S.pOpcycles S.f_pOpcycles) := S.rightHomologyData.hp /-- The canonical isomorphism `S.opcycles ≅ cokernel S.f`. -/ @[simps] noncomputable def opcyclesIsoCokernel [HasCokernel S.f] : S.opcycles ≅ cokernel S.f where hom := S.descOpcycles (cokernel.π S.f) (by simp) inv := cokernel.desc S.f S.pOpcycles (by simp) /-- The morphism `S.rightHomology ⟶ A` obtained from a morphism `k : S.X₂ ⟶ A` such that `S.f ≫ k = 0.` -/ @[simp] noncomputable def descRightHomology : S.rightHomology ⟶ A := S.rightHomologyι ≫ S.descOpcycles k hk @[reassoc] lemma rightHomologyι_descOpcycles_π_eq_zero_of_boundary (x : S.X₃ ⟶ A) (hx : k = S.g ≫ x) : S.rightHomologyι ≫ S.descOpcycles k (by rw [hx, S.zero_assoc, zero_comp]) = 0 := RightHomologyData.ι_descQ_eq_zero_of_boundary _ k x hx @[reassoc (attr := simp)] lemma rightHomologyι_comp_fromOpcycles : S.rightHomologyι ≫ S.fromOpcycles = 0 := S.rightHomologyι_descOpcycles_π_eq_zero_of_boundary S.g (𝟙 _) (by rw [comp_id]) /-- Via `S.rightHomologyι : S.rightHomology ⟶ S.opcycles`, the object `S.rightHomology` identifies to the kernel of `S.fromOpcycles : S.opcycles ⟶ S.X₃`. -/ noncomputable def rightHomologyIsKernel : IsLimit (KernelFork.ofι S.rightHomologyι S.rightHomologyι_comp_fromOpcycles) := S.rightHomologyData.hι variable {S} @[reassoc (attr := simp)] lemma opcyclesMap_comp_descOpcycles (φ : S₁ ⟶ S) [S₁.HasRightHomology] : opcyclesMap φ ≫ S.descOpcycles k hk = S₁.descOpcycles (φ.τ₂ ≫ k) (by rw [← φ.comm₁₂_assoc, hk, comp_zero]) := by simp only [← cancel_epi (S₁.pOpcycles), p_opcyclesMap_assoc, p_descOpcycles] @[reassoc (attr := simp)] lemma RightHomologyData.opcyclesIso_inv_comp_descOpcycles : h.opcyclesIso.inv ≫ S.descOpcycles k hk = h.descQ k hk := by simp only [← cancel_epi h.p, p_comp_opcyclesIso_inv_assoc, p_descOpcycles, p_descQ] @[simp] lemma RightHomologyData.opcyclesIso_hom_comp_descQ : h.opcyclesIso.hom ≫ h.descQ k hk = S.descOpcycles k hk := by rw [← h.opcyclesIso_inv_comp_descOpcycles, Iso.hom_inv_id_assoc] end variable {C} namespace HasRightHomology lemma hasCokernel [S.HasRightHomology] : HasCokernel S.f := ⟨⟨⟨_, S.rightHomologyData.hp⟩⟩⟩ lemma hasKernel [S.HasRightHomology] [HasCokernel S.f] : HasKernel (cokernel.desc S.f S.g S.zero) := by let h := S.rightHomologyData haveI : HasLimit (parallelPair h.g' 0) := ⟨⟨⟨_, h.hι'⟩⟩⟩ let e : parallelPair (cokernel.desc S.f S.g S.zero) 0 ≅ parallelPair h.g' 0 := parallelPair.ext (IsColimit.coconePointUniqueUpToIso (colimit.isColimit _) h.hp) (Iso.refl _) (coequalizer.hom_ext (by simp)) (by aesop_cat) exact hasLimitOfIso e.symm end HasRightHomology /-- The right homology of a short complex `S` identifies to the kernel of the canonical morphism `cokernel S.f ⟶ S.X₃`. -/ noncomputable def rightHomologyIsoKernelDesc [S.HasRightHomology] [HasCokernel S.f] [HasKernel (cokernel.desc S.f S.g S.zero)] : S.rightHomology ≅ kernel (cokernel.desc S.f S.g S.zero) := (RightHomologyData.ofHasCokernelOfHasKernel S).rightHomologyIso /-! The following lemmas and instance gives a sufficient condition for a morphism of short complexes to induce an isomorphism on opcycles. -/ lemma isIso_opcyclesMap'_of_isIso_of_epi (φ : S₁ ⟶ S₂) (h₂ : IsIso φ.τ₂) (h₁ : Epi φ.τ₁) (h₁ : S₁.RightHomologyData) (h₂ : S₂.RightHomologyData) : IsIso (opcyclesMap' φ h₁ h₂) := by refine ⟨h₂.descQ (inv φ.τ₂ ≫ h₁.p) ?_, ?_, ?_⟩ · simp only [← cancel_epi φ.τ₁, comp_zero, φ.comm₁₂_assoc, IsIso.hom_inv_id_assoc, h₁.wp] · simp only [← cancel_epi h₁.p, p_opcyclesMap'_assoc, h₂.p_descQ, IsIso.hom_inv_id_assoc, comp_id] · simp only [← cancel_epi h₂.p, h₂.p_descQ_assoc, assoc, p_opcyclesMap', IsIso.inv_hom_id_assoc, comp_id] lemma isIso_opcyclesMap_of_isIso_of_epi' (φ : S₁ ⟶ S₂) (h₂ : IsIso φ.τ₂) (h₁ : Epi φ.τ₁) [S₁.HasRightHomology] [S₂.HasRightHomology] : IsIso (opcyclesMap φ) := isIso_opcyclesMap'_of_isIso_of_epi φ h₂ h₁ _ _ instance isIso_opcyclesMap_of_isIso_of_epi (φ : S₁ ⟶ S₂) [IsIso φ.τ₂] [Epi φ.τ₁] [S₁.HasRightHomology] [S₂.HasRightHomology] : IsIso (opcyclesMap φ) := isIso_opcyclesMap_of_isIso_of_epi' φ inferInstance inferInstance end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\ShortExact.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ShortComplex.Exact import Mathlib.CategoryTheory.Preadditive.Injective /-! # Short exact short complexes A short complex `S : ShortComplex C` is short exact (`S.ShortExact`) when it is exact, `S.f` is a mono and `S.g` is an epi. -/ namespace CategoryTheory open Category Limits ZeroObject variable {C D : Type*} [Category C] [Category D] namespace ShortComplex section variable [HasZeroMorphisms C] [HasZeroMorphisms D] (S : ShortComplex C) {S₁ S₂ : ShortComplex C} /-- A short complex `S` is short exact if it is exact, `S.f` is a mono and `S.g` is an epi. -/ structure ShortExact : Prop where exact : S.Exact [mono_f : Mono S.f] [epi_g : Epi S.g] variable {S} lemma ShortExact.mk' (h : S.Exact) (_ : Mono S.f) (_ : Epi S.g) : S.ShortExact where exact := h lemma shortExact_of_iso (e : S₁ ≅ S₂) (h : S₁.ShortExact) : S₂.ShortExact where exact := exact_of_iso e h.exact mono_f := by suffices Mono (S₂.f ≫ e.inv.τ₂) by exact mono_of_mono _ e.inv.τ₂ have := h.mono_f rw [← e.inv.comm₁₂] apply mono_comp epi_g := by suffices Epi (e.hom.τ₂ ≫ S₂.g) by exact epi_of_epi e.hom.τ₂ _ have := h.epi_g rw [e.hom.comm₂₃] apply epi_comp lemma shortExact_iff_of_iso (e : S₁ ≅ S₂) : S₁.ShortExact ↔ S₂.ShortExact := by constructor · exact shortExact_of_iso e · exact shortExact_of_iso e.symm lemma ShortExact.op (h : S.ShortExact) : S.op.ShortExact where exact := h.exact.op mono_f := by have := h.epi_g dsimp infer_instance epi_g := by have := h.mono_f dsimp infer_instance lemma ShortExact.unop {S : ShortComplex Cᵒᵖ} (h : S.ShortExact) : S.unop.ShortExact where exact := h.exact.unop mono_f := by have := h.epi_g dsimp infer_instance epi_g := by have := h.mono_f dsimp infer_instance variable (S) lemma shortExact_iff_op : S.ShortExact ↔ S.op.ShortExact := ⟨ShortExact.op, ShortExact.unop⟩ lemma shortExact_iff_unop (S : ShortComplex Cᵒᵖ) : S.ShortExact ↔ S.unop.ShortExact := S.unop.shortExact_iff_op.symm variable {S} lemma ShortExact.map (h : S.ShortExact) (F : C ⥤ D) [F.PreservesZeroMorphisms] [F.PreservesLeftHomologyOf S] [F.PreservesRightHomologyOf S] [Mono (F.map S.f)] [Epi (F.map S.g)] : (S.map F).ShortExact where exact := h.exact.map F mono_f := (inferInstance : Mono (F.map S.f)) epi_g := (inferInstance : Epi (F.map S.g)) lemma ShortExact.map_of_exact (hS : S.ShortExact) (F : C ⥤ D) [F.PreservesZeroMorphisms] [PreservesFiniteLimits F] [PreservesFiniteColimits F] : (S.map F).ShortExact := by have := hS.mono_f have := hS.epi_g have := preserves_mono_of_preservesLimit F S.f have := preserves_epi_of_preservesColimit F S.g exact hS.map F end section Preadditive variable [Preadditive C] lemma ShortExact.isIso_f_iff {S : ShortComplex C} (hS : S.ShortExact) [Balanced C] : IsIso S.f ↔ IsZero S.X₃ := by have := hS.exact.hasZeroObject have := hS.mono_f have := hS.epi_g constructor · intro hf simp only [IsZero.iff_id_eq_zero, ← cancel_epi S.g, ← cancel_epi S.f, S.zero_assoc, zero_comp] · intro hX₃ have : Epi S.f := (S.exact_iff_epi (hX₃.eq_of_tgt _ _)).1 hS.exact apply isIso_of_mono_of_epi lemma ShortExact.isIso_g_iff {S : ShortComplex C} (hS : S.ShortExact) [Balanced C] : IsIso S.g ↔ IsZero S.X₁ := by have := hS.exact.hasZeroObject have := hS.mono_f have := hS.epi_g constructor · intro hf simp only [IsZero.iff_id_eq_zero, ← cancel_mono S.f, ← cancel_mono S.g, S.zero, zero_comp, assoc, comp_zero] · intro hX₁ have : Mono S.g := (S.exact_iff_mono (hX₁.eq_of_src _ _)).1 hS.exact apply isIso_of_mono_of_epi lemma isIso₂_of_shortExact_of_isIso₁₃ [Balanced C] {S₁ S₂ : ShortComplex C} (φ : S₁ ⟶ S₂) (h₁ : S₁.ShortExact) (h₂ : S₂.ShortExact) [IsIso φ.τ₁] [IsIso φ.τ₃] : IsIso φ.τ₂ := by have := h₁.mono_f have := h₂.mono_f have := h₁.epi_g have := h₂.epi_g have := mono_τ₂_of_exact_of_mono φ h₁.exact have := epi_τ₂_of_exact_of_epi φ h₂.exact apply isIso_of_mono_of_epi lemma isIso₂_of_shortExact_of_isIso₁₃' [Balanced C] {S₁ S₂ : ShortComplex C} (φ : S₁ ⟶ S₂) (h₁ : S₁.ShortExact) (h₂ : S₂.ShortExact) (_ : IsIso φ.τ₁) (_ : IsIso φ.τ₃) : IsIso φ.τ₂ := isIso₂_of_shortExact_of_isIso₁₃ φ h₁ h₂ /-- If `S` is a short exact short complex in a balanced category, then `S.X₁` is the kernel of `S.g`. -/ noncomputable def ShortExact.fIsKernel [Balanced C] {S : ShortComplex C} (hS : S.ShortExact) : IsLimit (KernelFork.ofι S.f S.zero) := by have := hS.mono_f exact hS.exact.fIsKernel /-- If `S` is a short exact short complex in a balanced category, then `S.X₃` is the cokernel of `S.f`. -/ noncomputable def ShortExact.gIsCokernel [Balanced C] {S : ShortComplex C} (hS : S.ShortExact) : IsColimit (CokernelCofork.ofπ S.g S.zero) := by have := hS.epi_g exact hS.exact.gIsCokernel /-- A split short complex is short exact. -/ lemma Splitting.shortExact {S : ShortComplex C} [HasZeroObject C] (s : S.Splitting) : S.ShortExact where exact := s.exact mono_f := s.mono_f epi_g := s.epi_g namespace ShortExact /-- A choice of splitting for a short exact short complex `S` in a balanced category such that `S.X₁` is injective. -/ noncomputable def splittingOfInjective {S : ShortComplex C} (hS : S.ShortExact) [Injective S.X₁] [Balanced C] : S.Splitting := have := hS.mono_f Splitting.ofExactOfRetraction S hS.exact (Injective.factorThru (𝟙 S.X₁) S.f) (by simp) hS.epi_g /-- A choice of splitting for a short exact short complex `S` in a balanced category such that `S.X₃` is projective. -/ noncomputable def splittingOfProjective {S : ShortComplex C} (hS : S.ShortExact) [Projective S.X₃] [Balanced C] : S.Splitting := have := hS.epi_g Splitting.ofExactOfSection S hS.exact (Projective.factorThru (𝟙 S.X₃) S.g) (by simp) hS.mono_f end ShortExact end Preadditive end ShortComplex end CategoryTheory
Algebra\Homology\ShortComplex\SnakeLemma.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.ExactSequence import Mathlib.Algebra.Homology.ShortComplex.Limits import Mathlib.CategoryTheory.Abelian.Refinements /-! # The snake lemma The snake lemma is a standard tool in homological algebra. The basic situation is when we have a diagram as follows in an abelian category `C`, with exact rows: L₁.X₁ ⟶ L₁.X₂ ⟶ L₁.X₃ ⟶ 0 | | | |v₁₂.τ₁ |v₁₂.τ₂ |v₁₂.τ₃ v v v 0 ⟶ L₂.X₁ ⟶ L₂.X₂ ⟶ L₂.X₃ We shall think of this diagram as the datum of a morphism `v₁₂ : L₁ ⟶ L₂` in the category `ShortComplex C` such that both `L₁` and `L₂` are exact, and `L₁.g` is epi and `L₂.f` is a mono (which is equivalent to saying that `L₁.X₃` is the cokernel of `L₁.f` and `L₂.X₁` is the kernel of `L₂.g`). Then, we may introduce the kernels and cokernels of the vertical maps. In other words, we may introduce short complexes `L₀` and `L₃` that are respectively the kernel and the cokernel of `v₁₂`. All these data constitute a `SnakeInput C`. Given such a `S : SnakeInput C`, we define a connecting homomorphism `S.δ : L₀.X₃ ⟶ L₃.X₁` and show that it is part of an exact sequence `L₀.X₁ ⟶ L₀.X₂ ⟶ L₀.X₃ ⟶ L₃.X₁ ⟶ L₃.X₂ ⟶ L₃.X₃`. Each of the four exactness statement is first stated separately as lemmas `L₀_exact`, `L₁'_exact`, `L₂'_exact` and `L₃_exact` and the full 6-term exact sequence is stated as `snake_lemma`. This sequence can even be extended with an extra `0` on the left (see `mono_L₀_f`) if `L₁.X₁ ⟶ L₁.X₂` is a mono (i.e. `L₁` is short exact), and similarly an extra `0` can be added on the right (`epi_L₃_g`) if `L₂.X₂ ⟶ L₂.X₃` is an epi (i.e. `L₂` is short exact). These results were also obtained in the Liquid Tensor Experiment. The code and the proof here are slightly easier because of the use of the category `ShortComplex C`, the use of duality (which allows to construct only half of the sequence, and deducing the other half by arguing in the opposite category), and the use of "refinements" (see `CategoryTheory.Abelian.Refinements`) instead of a weak form of pseudo-elements. -/ namespace CategoryTheory open Category Limits Preadditive variable (C : Type*) [Category C] [Abelian C] namespace ShortComplex /-- A snake input in an abelian category `C` consists of morphisms of short complexes `L₀ ⟶ L₁ ⟶ L₂ ⟶ L₃` (which should be visualized vertically) such that `L₀` and `L₃` are respectively the kernel and the cokernel of `L₁ ⟶ L₂`, `L₁` and `L₂` are exact, `L₁.g` is epi and `L₂.f` is mono. -/ structure SnakeInput where /-- the zeroth row -/ L₀ : ShortComplex C /-- the first row -/ L₁ : ShortComplex C /-- the second row -/ L₂ : ShortComplex C /-- the third row -/ L₃ : ShortComplex C /-- the morphism from the zeroth row to the first row -/ v₀₁ : L₀ ⟶ L₁ /-- the morphism from the first row to the second row -/ v₁₂ : L₁ ⟶ L₂ /-- the morphism from the second row to the third row -/ v₂₃ : L₂ ⟶ L₃ w₀₂ : v₀₁ ≫ v₁₂ = 0 := by aesop_cat w₁₃ : v₁₂ ≫ v₂₃ = 0 := by aesop_cat /-- `L₀` is the kernel of `v₁₂ : L₁ ⟶ L₂`. -/ h₀ : IsLimit (KernelFork.ofι _ w₀₂) /-- `L₃` is the cokernel of `v₁₂ : L₁ ⟶ L₂`. -/ h₃ : IsColimit (CokernelCofork.ofπ _ w₁₃) L₁_exact : L₁.Exact epi_L₁_g : Epi L₁.g L₂_exact : L₂.Exact mono_L₂_f : Mono L₂.f initialize_simps_projections SnakeInput (-h₀, -h₃) namespace SnakeInput attribute [reassoc (attr := simp)] w₀₂ w₁₃ attribute [instance] epi_L₁_g attribute [instance] mono_L₂_f variable {C} variable (S : SnakeInput C) /-- The snake input in the opposite category that is deduced from a snake input. -/ @[simps] noncomputable def op : SnakeInput Cᵒᵖ where L₀ := S.L₃.op L₁ := S.L₂.op L₂ := S.L₁.op L₃ := S.L₀.op epi_L₁_g := by dsimp; infer_instance mono_L₂_f := by dsimp; infer_instance v₀₁ := opMap S.v₂₃ v₁₂ := opMap S.v₁₂ v₂₃ := opMap S.v₀₁ w₀₂ := congr_arg opMap S.w₁₃ w₁₃ := congr_arg opMap S.w₀₂ h₀ := isLimitForkMapOfIsLimit' (ShortComplex.opEquiv C).functor _ (CokernelCofork.IsColimit.ofπOp _ _ S.h₃) h₃ := isColimitCoforkMapOfIsColimit' (ShortComplex.opEquiv C).functor _ (KernelFork.IsLimit.ofιOp _ _ S.h₀) L₁_exact := S.L₂_exact.op L₂_exact := S.L₁_exact.op @[reassoc (attr := simp)] lemma w₀₂_τ₁ : S.v₀₁.τ₁ ≫ S.v₁₂.τ₁ = 0 := by rw [← comp_τ₁, S.w₀₂, zero_τ₁] @[reassoc (attr := simp)] lemma w₀₂_τ₂ : S.v₀₁.τ₂ ≫ S.v₁₂.τ₂ = 0 := by rw [← comp_τ₂, S.w₀₂, zero_τ₂] @[reassoc (attr := simp)] lemma w₀₂_τ₃ : S.v₀₁.τ₃ ≫ S.v₁₂.τ₃ = 0 := by rw [← comp_τ₃, S.w₀₂, zero_τ₃] @[reassoc (attr := simp)] lemma w₁₃_τ₁ : S.v₁₂.τ₁ ≫ S.v₂₃.τ₁ = 0 := by rw [← comp_τ₁, S.w₁₃, zero_τ₁] @[reassoc (attr := simp)] lemma w₁₃_τ₂ : S.v₁₂.τ₂ ≫ S.v₂₃.τ₂ = 0 := by rw [← comp_τ₂, S.w₁₃, zero_τ₂] @[reassoc (attr := simp)] lemma w₁₃_τ₃ : S.v₁₂.τ₃ ≫ S.v₂₃.τ₃ = 0 := by rw [← comp_τ₃, S.w₁₃, zero_τ₃] /-- `L₀.X₁` is the kernel of `v₁₂.τ₁ : L₁.X₁ ⟶ L₂.X₁`. -/ noncomputable def h₀τ₁ : IsLimit (KernelFork.ofι S.v₀₁.τ₁ S.w₀₂_τ₁) := isLimitForkMapOfIsLimit' π₁ S.w₀₂ S.h₀ /-- `L₀.X₂` is the kernel of `v₁₂.τ₂ : L₁.X₂ ⟶ L₂.X₂`. -/ noncomputable def h₀τ₂ : IsLimit (KernelFork.ofι S.v₀₁.τ₂ S.w₀₂_τ₂) := isLimitForkMapOfIsLimit' π₂ S.w₀₂ S.h₀ /-- `L₀.X₃` is the kernel of `v₁₂.τ₃ : L₁.X₃ ⟶ L₂.X₃`. -/ noncomputable def h₀τ₃ : IsLimit (KernelFork.ofι S.v₀₁.τ₃ S.w₀₂_τ₃) := isLimitForkMapOfIsLimit' π₃ S.w₀₂ S.h₀ instance mono_v₀₁_τ₁ : Mono S.v₀₁.τ₁ := mono_of_isLimit_fork S.h₀τ₁ instance mono_v₀₁_τ₂ : Mono S.v₀₁.τ₂ := mono_of_isLimit_fork S.h₀τ₂ instance mono_v₀₁_τ₃ : Mono S.v₀₁.τ₃ := mono_of_isLimit_fork S.h₀τ₃ /-- The upper part of the first column of the snake diagram is exact. -/ lemma exact_C₁_up : (ShortComplex.mk S.v₀₁.τ₁ S.v₁₂.τ₁ (by rw [← comp_τ₁, S.w₀₂, zero_τ₁])).Exact := exact_of_f_is_kernel _ S.h₀τ₁ /-- The upper part of the second column of the snake diagram is exact. -/ lemma exact_C₂_up : (ShortComplex.mk S.v₀₁.τ₂ S.v₁₂.τ₂ (by rw [← comp_τ₂, S.w₀₂, zero_τ₂])).Exact := exact_of_f_is_kernel _ S.h₀τ₂ /-- The upper part of the third column of the snake diagram is exact. -/ lemma exact_C₃_up : (ShortComplex.mk S.v₀₁.τ₃ S.v₁₂.τ₃ (by rw [← comp_τ₃, S.w₀₂, zero_τ₃])).Exact := exact_of_f_is_kernel _ S.h₀τ₃ instance mono_L₀_f [Mono S.L₁.f] : Mono S.L₀.f := by have : Mono (S.L₀.f ≫ S.v₀₁.τ₂) := by rw [← S.v₀₁.comm₁₂] apply mono_comp exact mono_of_mono _ S.v₀₁.τ₂ /-- `L₃.X₁` is the cokernel of `v₁₂.τ₁ : L₁.X₁ ⟶ L₂.X₁`. -/ noncomputable def h₃τ₁ : IsColimit (CokernelCofork.ofπ S.v₂₃.τ₁ S.w₁₃_τ₁) := isColimitCoforkMapOfIsColimit' π₁ S.w₁₃ S.h₃ /-- `L₃.X₂` is the cokernel of `v₁₂.τ₂ : L₁.X₂ ⟶ L₂.X₂`. -/ noncomputable def h₃τ₂ : IsColimit (CokernelCofork.ofπ S.v₂₃.τ₂ S.w₁₃_τ₂) := isColimitCoforkMapOfIsColimit' π₂ S.w₁₃ S.h₃ /-- `L₃.X₃` is the cokernel of `v₁₂.τ₃ : L₁.X₃ ⟶ L₂.X₃`. -/ noncomputable def h₃τ₃ : IsColimit (CokernelCofork.ofπ S.v₂₃.τ₃ S.w₁₃_τ₃) := isColimitCoforkMapOfIsColimit' π₃ S.w₁₃ S.h₃ instance epi_v₂₃_τ₁ : Epi S.v₂₃.τ₁ := epi_of_isColimit_cofork S.h₃τ₁ instance epi_v₂₃_τ₂ : Epi S.v₂₃.τ₂ := epi_of_isColimit_cofork S.h₃τ₂ instance epi_v₂₃_τ₃ : Epi S.v₂₃.τ₃ := epi_of_isColimit_cofork S.h₃τ₃ /-- The lower part of the first column of the snake diagram is exact. -/ lemma exact_C₁_down : (ShortComplex.mk S.v₁₂.τ₁ S.v₂₃.τ₁ (by rw [← comp_τ₁, S.w₁₃, zero_τ₁])).Exact := exact_of_g_is_cokernel _ S.h₃τ₁ /-- The lower part of the second column of the snake diagram is exact. -/ lemma exact_C₂_down : (ShortComplex.mk S.v₁₂.τ₂ S.v₂₃.τ₂ (by rw [← comp_τ₂, S.w₁₃, zero_τ₂])).Exact := exact_of_g_is_cokernel _ S.h₃τ₂ /-- The lower part of the third column of the snake diagram is exact. -/ lemma exact_C₃_down : (ShortComplex.mk S.v₁₂.τ₃ S.v₂₃.τ₃ (by rw [← comp_τ₃, S.w₁₃, zero_τ₃])).Exact := exact_of_g_is_cokernel _ S.h₃τ₃ instance epi_L₃_g [Epi S.L₂.g] : Epi S.L₃.g := by have : Epi (S.v₂₃.τ₂ ≫ S.L₃.g) := by rw [S.v₂₃.comm₂₃] apply epi_comp exact epi_of_epi S.v₂₃.τ₂ _ lemma L₀_exact : S.L₀.Exact := by rw [ShortComplex.exact_iff_exact_up_to_refinements] intro A x₂ hx₂ obtain ⟨A₁, π₁, hπ₁, y₁, hy₁⟩ := S.L₁_exact.exact_up_to_refinements (x₂ ≫ S.v₀₁.τ₂) (by rw [assoc, S.v₀₁.comm₂₃, reassoc_of% hx₂, zero_comp]) have hy₁' : y₁ ≫ S.v₁₂.τ₁ = 0 := by simp only [← cancel_mono S.L₂.f, assoc, zero_comp, S.v₁₂.comm₁₂, ← reassoc_of% hy₁, w₀₂_τ₂, comp_zero] obtain ⟨x₁, hx₁⟩ : ∃ x₁, x₁ ≫ S.v₀₁.τ₁ = y₁ := ⟨_, S.exact_C₁_up.lift_f y₁ hy₁'⟩ refine ⟨A₁, π₁, hπ₁, x₁, ?_⟩ simp only [← cancel_mono S.v₀₁.τ₂, assoc, ← S.v₀₁.comm₁₂, reassoc_of% hx₁, hy₁] lemma L₃_exact : S.L₃.Exact := S.op.L₀_exact.unop /-- The fiber product of `L₁.X₂` and `L₀.X₃` over `L₁.X₃`. This is an auxiliary object in the construction of the morphism `δ : L₀.X₃ ⟶ L₃.X₁`. -/ noncomputable def P := pullback S.L₁.g S.v₀₁.τ₃ /-- The canonical map `P ⟶ L₂.X₂`. -/ noncomputable def φ₂ : S.P ⟶ S.L₂.X₂ := pullback.fst _ _ ≫ S.v₁₂.τ₂ @[reassoc (attr := simp)] lemma lift_φ₂ {A : C} (a : A ⟶ S.L₁.X₂) (b : A ⟶ S.L₀.X₃) (h : a ≫ S.L₁.g = b ≫ S.v₀₁.τ₃) : pullback.lift a b h ≫ S.φ₂ = a ≫ S.v₁₂.τ₂ := by simp [φ₂] /-- The canonical map `P ⟶ L₂.X₁`. -/ noncomputable def φ₁ : S.P ⟶ S.L₂.X₁ := S.L₂_exact.lift S.φ₂ (by simp only [φ₂, assoc, S.v₁₂.comm₂₃, pullback.condition_assoc, w₀₂_τ₃, comp_zero]) @[reassoc (attr := simp)] lemma φ₁_L₂_f : S.φ₁ ≫ S.L₂.f = S.φ₂ := S.L₂_exact.lift_f _ _ /-- The short complex that is part of an exact sequence `L₁.X₁ ⟶ P ⟶ L₀.X₃ ⟶ 0`. -/ noncomputable def L₀' : ShortComplex C where X₁ := S.L₁.X₁ X₂ := S.P X₃ := S.L₀.X₃ f := pullback.lift S.L₁.f 0 (by simp) g := pullback.snd _ _ zero := by simp @[reassoc (attr := simp)] lemma L₁_f_φ₁ : S.L₀'.f ≫ S.φ₁ = S.v₁₂.τ₁ := by dsimp only [L₀'] simp only [← cancel_mono S.L₂.f, assoc, φ₁_L₂_f, φ₂, pullback.lift_fst_assoc, S.v₁₂.comm₁₂] instance : Epi S.L₀'.g := by dsimp only [L₀']; infer_instance instance [Mono S.L₁.f] : Mono S.L₀'.f := mono_of_mono_fac (show S.L₀'.f ≫ pullback.fst _ _ = S.L₁.f by simp [L₀']) lemma L₀'_exact : S.L₀'.Exact := by rw [ShortComplex.exact_iff_exact_up_to_refinements] intro A x₂ hx₂ dsimp [L₀'] at x₂ hx₂ obtain ⟨A', π, hπ, x₁, fac⟩ := S.L₁_exact.exact_up_to_refinements (x₂ ≫ pullback.fst _ _) (by rw [assoc, pullback.condition, reassoc_of% hx₂, zero_comp]) exact ⟨A', π, hπ, x₁, pullback.hom_ext (by simpa [L₀'] using fac) (by simp [L₀', hx₂])⟩ /-- The connecting homomorphism `δ : L₀.X₃ ⟶ L₃.X₁`. -/ noncomputable def δ : S.L₀.X₃ ⟶ S.L₃.X₁ := S.L₀'_exact.desc (S.φ₁ ≫ S.v₂₃.τ₁) (by simp only [L₁_f_φ₁_assoc, w₁₃_τ₁]) @[reassoc (attr := simp)] lemma snd_δ : (pullback.snd _ _ : S.P ⟶ _) ≫ S.δ = S.φ₁ ≫ S.v₂₃.τ₁ := S.L₀'_exact.g_desc _ _ /-- The pushout of `L₂.X₂` and `L₃.X₁` along `L₂.X₁`. -/ noncomputable def P' := pushout S.L₂.f S.v₂₃.τ₁ lemma snd_δ_inr : (pullback.snd _ _ : S.P ⟶ _) ≫ S.δ ≫ (pushout.inr _ _ : _ ⟶ S.P') = pullback.fst _ _ ≫ S.v₁₂.τ₂ ≫ pushout.inl _ _ := by simp only [snd_δ_assoc, ← pushout.condition, φ₂, φ₁_L₂_f_assoc, assoc] /-- The canonical morphism `L₀.X₂ ⟶ P`. -/ @[simp] noncomputable def L₀X₂ToP : S.L₀.X₂ ⟶ S.P := pullback.lift S.v₀₁.τ₂ S.L₀.g S.v₀₁.comm₂₃ @[reassoc] lemma L₀X₂ToP_comp_pullback_snd : S.L₀X₂ToP ≫ pullback.snd _ _ = S.L₀.g := by simp @[reassoc] lemma L₀X₂ToP_comp_φ₁ : S.L₀X₂ToP ≫ S.φ₁ = 0 := by simp only [← cancel_mono S.L₂.f, L₀X₂ToP, assoc, φ₂, φ₁_L₂_f, pullback.lift_fst_assoc, w₀₂_τ₂, zero_comp] lemma L₀_g_δ : S.L₀.g ≫ S.δ = 0 := by erw [← L₀X₂ToP_comp_pullback_snd, assoc, S.L₀'_exact.g_desc, L₀X₂ToP_comp_φ₁_assoc, zero_comp] lemma δ_L₃_f : S.δ ≫ S.L₃.f = 0 := by erw [← cancel_epi S.L₀'.g, S.L₀'_exact.g_desc_assoc, assoc, S.v₂₃.comm₁₂, S.φ₁_L₂_f_assoc, φ₂, assoc, w₁₃_τ₂, comp_zero, comp_zero] /-- The short complex `L₀.X₂ ⟶ L₀.X₃ ⟶ L₃.X₁`. -/ @[simps] noncomputable def L₁' : ShortComplex C := ShortComplex.mk _ _ S.L₀_g_δ /-- The short complex `L₀.X₃ ⟶ L₃.X₁ ⟶ L₃.X₂`. -/ @[simps] noncomputable def L₂' : ShortComplex C := ShortComplex.mk _ _ S.δ_L₃_f /-- Exactness of `L₀.X₂ ⟶ L₀.X₃ ⟶ L₃.X₁`. -/ lemma L₁'_exact : S.L₁'.Exact := by rw [ShortComplex.exact_iff_exact_up_to_refinements] intro A₀ x₃ hx₃ dsimp at x₃ hx₃ obtain ⟨A₁, π₁, hπ₁, p, hp⟩ := surjective_up_to_refinements_of_epi S.L₀'.g x₃ dsimp [L₀'] at p hp have hp' : (p ≫ S.φ₁) ≫ S.v₂₃.τ₁ = 0 := by rw [assoc, ← S.snd_δ, ← reassoc_of% hp, hx₃, comp_zero] obtain ⟨A₂, π₂, hπ₂, x₁, hx₁⟩ := S.exact_C₁_down.exact_up_to_refinements (p ≫ S.φ₁) hp' dsimp at x₁ hx₁ let x₂' := x₁ ≫ S.L₁.f let x₂ := π₂ ≫ p ≫ pullback.fst _ _ have hx₂' : (x₂ - x₂') ≫ S.v₁₂.τ₂ = 0 := by simp only [x₂, x₂', sub_comp, assoc, ← S.v₁₂.comm₁₂, ← reassoc_of% hx₁, φ₂, φ₁_L₂_f, sub_self] let k₂ : A₂ ⟶ S.L₀.X₂ := S.exact_C₂_up.lift _ hx₂' have hk₂ : k₂ ≫ S.v₀₁.τ₂ = x₂ - x₂' := S.exact_C₂_up.lift_f _ _ have hk₂' : k₂ ≫ S.L₀.g = π₂ ≫ p ≫ pullback.snd _ _ := by simp only [x₂, x₂', ← cancel_mono S.v₀₁.τ₃, assoc, ← S.v₀₁.comm₂₃, reassoc_of% hk₂, sub_comp, S.L₁.zero, comp_zero, sub_zero, pullback.condition] exact ⟨A₂, π₂ ≫ π₁, epi_comp _ _, k₂, by simp only [assoc, L₁'_f, ← hk₂', hp]⟩ /-- The duality isomorphism `S.P ≅ Opposite.unop S.op.P'`. -/ noncomputable def PIsoUnopOpP' : S.P ≅ Opposite.unop S.op.P' := pullbackIsoUnopPushout _ _ /-- The duality isomorphism `S.P' ≅ Opposite.unop S.op.P`. -/ noncomputable def P'IsoUnopOpP : S.P' ≅ Opposite.unop S.op.P := pushoutIsoUnopPullback _ _ lemma op_δ : S.op.δ = S.δ.op := Quiver.Hom.unop_inj (by rw [Quiver.Hom.unop_op, ← cancel_mono (pushout.inr _ _ : _ ⟶ S.P'), ← cancel_epi (pullback.snd _ _ : S.P ⟶ _), S.snd_δ_inr, ← cancel_mono S.P'IsoUnopOpP.hom, ← cancel_epi S.PIsoUnopOpP'.inv, P'IsoUnopOpP, PIsoUnopOpP', assoc, assoc, assoc, assoc, pushoutIsoUnopPullback_inr_hom, pullbackIsoUnopPushout_inv_snd_assoc, pushoutIsoUnopPullback_inl_hom, pullbackIsoUnopPushout_inv_fst_assoc] apply Quiver.Hom.op_inj simpa only [op_comp, Quiver.Hom.op_unop, assoc] using S.op.snd_δ_inr) /-- The duality isomorphism `S.L₂'.op ≅ S.op.L₁'`. -/ noncomputable def L₂'OpIso : S.L₂'.op ≅ S.op.L₁' := ShortComplex.isoMk (Iso.refl _) (Iso.refl _) (Iso.refl _) (by aesop_cat) (by dsimp; simp only [id_comp, comp_id, S.op_δ]) /-- Exactness of `L₀.X₃ ⟶ L₃.X₁ ⟶ L₃.X₂`. -/ lemma L₂'_exact : S.L₂'.Exact := by rw [← exact_op_iff, exact_iff_of_iso S.L₂'OpIso] exact S.op.L₁'_exact /-- The diagram `S.L₀.X₁ ⟶ S.L₀.X₂ ⟶ S.L₀.X₃ ⟶ S.L₃.X₁ ⟶ S.L₃.X₂ ⟶ S.L₃.X₃` for any `S : SnakeInput C`. -/ noncomputable abbrev composableArrows : ComposableArrows C 5 := ComposableArrows.mk₅ S.L₀.f S.L₀.g S.δ S.L₃.f S.L₃.g open ComposableArrows in /-- The diagram `S.L₀.X₁ ⟶ S.L₀.X₂ ⟶ S.L₀.X₃ ⟶ S.L₃.X₁ ⟶ S.L₃.X₂ ⟶ S.L₃.X₃` is exact for any `S : SnakeInput C`. -/ lemma snake_lemma : S.composableArrows.Exact := exact_of_δ₀ S.L₀_exact.exact_toComposableArrows (exact_of_δ₀ S.L₁'_exact.exact_toComposableArrows (exact_of_δ₀ S.L₂'_exact.exact_toComposableArrows S.L₃_exact.exact_toComposableArrows)) lemma δ_eq {A : C} (x₃ : A ⟶ S.L₀.X₃) (x₂ : A ⟶ S.L₁.X₂) (x₁ : A ⟶ S.L₂.X₁) (h₂ : x₂ ≫ S.L₁.g = x₃ ≫ S.v₀₁.τ₃) (h₁ : x₁ ≫ S.L₂.f = x₂ ≫ S.v₁₂.τ₂) : x₃ ≫ S.δ = x₁ ≫ S.v₂₃.τ₁ := by have H := (pullback.lift x₂ x₃ h₂) ≫= S.snd_δ rw [pullback.lift_snd_assoc] at H rw [H, ← assoc] congr 1 simp only [← cancel_mono S.L₂.f, assoc, φ₁_L₂_f, lift_φ₂, h₁] variable (S₁ S₂ S₃ : SnakeInput C) /-- A morphism of snake inputs involve four morphisms of short complexes which make the obvious diagram commute. -/ @[ext] structure Hom := /-- a morphism between the zeroth lines -/ f₀ : S₁.L₀ ⟶ S₂.L₀ /-- a morphism between the first lines -/ f₁ : S₁.L₁ ⟶ S₂.L₁ /-- a morphism between the second lines -/ f₂ : S₁.L₂ ⟶ S₂.L₂ /-- a morphism between the third lines -/ f₃ : S₁.L₃ ⟶ S₂.L₃ comm₀₁ : f₀ ≫ S₂.v₀₁ = S₁.v₀₁ ≫ f₁ := by aesop_cat comm₁₂ : f₁ ≫ S₂.v₁₂ = S₁.v₁₂ ≫ f₂ := by aesop_cat comm₂₃ : f₂ ≫ S₂.v₂₃ = S₁.v₂₃ ≫ f₃ := by aesop_cat namespace Hom attribute [reassoc] comm₀₁ comm₁₂ comm₂₃ /-- The identity morphism of a snake input. -/ @[simps] def id : Hom S S where f₀ := 𝟙 _ f₁ := 𝟙 _ f₂ := 𝟙 _ f₃ := 𝟙 _ variable {S₁ S₂ S₃} /-- The composition of morphisms of snake inputs. -/ @[simps] def comp (f : Hom S₁ S₂) (g : Hom S₂ S₃) : Hom S₁ S₃ where f₀ := f.f₀ ≫ g.f₀ f₁ := f.f₁ ≫ g.f₁ f₂ := f.f₂ ≫ g.f₂ f₃ := f.f₃ ≫ g.f₃ comm₀₁ := by simp only [assoc, comm₀₁, comm₀₁_assoc] comm₁₂ := by simp only [assoc, comm₁₂, comm₁₂_assoc] comm₂₃ := by simp only [assoc, comm₂₃, comm₂₃_assoc] end Hom instance : Category (SnakeInput C) where Hom := Hom id := Hom.id comp := Hom.comp variable {S₁ S₂ S₃} @[simp] lemma id_f₀ : Hom.f₀ (𝟙 S) = 𝟙 _ := rfl @[simp] lemma id_f₁ : Hom.f₁ (𝟙 S) = 𝟙 _ := rfl @[simp] lemma id_f₂ : Hom.f₂ (𝟙 S) = 𝟙 _ := rfl @[simp] lemma id_f₃ : Hom.f₃ (𝟙 S) = 𝟙 _ := rfl section variable (f : S₁ ⟶ S₂) (g : S₂ ⟶ S₃) @[simp, reassoc] lemma comp_f₀ : (f ≫ g).f₀ = f.f₀ ≫ g.f₀ := rfl @[simp, reassoc] lemma comp_f₁ : (f ≫ g).f₁ = f.f₁ ≫ g.f₁ := rfl @[simp, reassoc] lemma comp_f₂ : (f ≫ g).f₂ = f.f₂ ≫ g.f₂ := rfl @[simp, reassoc] lemma comp_f₃ : (f ≫ g).f₃ = f.f₃ ≫ g.f₃ := rfl end /-- The functor which sends `S : SnakeInput C` to its zeroth line `S.L₀`. -/ @[simps] def functorL₀ : SnakeInput C ⥤ ShortComplex C where obj S := S.L₀ map f := f.f₀ /-- The functor which sends `S : SnakeInput C` to its zeroth line `S.L₁`. -/ @[simps] def functorL₁ : SnakeInput C ⥤ ShortComplex C where obj S := S.L₁ map f := f.f₁ /-- The functor which sends `S : SnakeInput C` to its second line `S.L₂`. -/ @[simps] def functorL₂ : SnakeInput C ⥤ ShortComplex C where obj S := S.L₂ map f := f.f₂ /-- The functor which sends `S : SnakeInput C` to its third line `S.L₃`. -/ @[simps] def functorL₃ : SnakeInput C ⥤ ShortComplex C where obj S := S.L₃ map f := f.f₃ /-- The functor which sends `S : SnakeInput C` to the auxiliary object `S.P`, which is `pullback S.L₁.g S.v₀₁.τ₃`. -/ @[simps] noncomputable def functorP : SnakeInput C ⥤ C where obj S := S.P map f := pullback.map _ _ _ _ f.f₁.τ₂ f.f₀.τ₃ f.f₁.τ₃ f.f₁.comm₂₃.symm (congr_arg ShortComplex.Hom.τ₃ f.comm₀₁.symm) map_id _ := by dsimp [P]; aesop_cat map_comp _ _ := by dsimp [P]; aesop_cat @[reassoc] lemma naturality_φ₂ (f : S₁ ⟶ S₂) : S₁.φ₂ ≫ f.f₂.τ₂ = functorP.map f ≫ S₂.φ₂ := by dsimp [φ₂] simp only [assoc, pullback.lift_fst_assoc, ← comp_τ₂, f.comm₁₂] @[reassoc] lemma naturality_φ₁ (f : S₁ ⟶ S₂) : S₁.φ₁ ≫ f.f₂.τ₁ = functorP.map f ≫ S₂.φ₁ := by simp only [← cancel_mono S₂.L₂.f, assoc, φ₁_L₂_f, ← naturality_φ₂, f.f₂.comm₁₂, φ₁_L₂_f_assoc] @[reassoc] lemma naturality_δ (f : S₁ ⟶ S₂) : S₁.δ ≫ f.f₃.τ₁ = f.f₀.τ₃ ≫ S₂.δ := by rw [← cancel_epi (pullback.snd _ _ : S₁.P ⟶ _), S₁.snd_δ_assoc, ← comp_τ₁, ← f.comm₂₃, comp_τ₁, naturality_φ₁_assoc, ← S₂.snd_δ, functorP_map, pullback.lift_snd_assoc, assoc] /-- The functor which sends `S : SnakeInput C` to `S.L₁'` which is `S.L₀.X₂ ⟶ S.L₀.X₃ ⟶ S.L₃.X₁`. -/ @[simps] noncomputable def functorL₁' : SnakeInput C ⥤ ShortComplex C where obj S := S.L₁' map f := { τ₁ := f.f₀.τ₂ τ₂ := f.f₀.τ₃ τ₃ := f.f₃.τ₁ comm₁₂ := f.f₀.comm₂₃ comm₂₃ := (naturality_δ f).symm } /-- The functor which sends `S : SnakeInput C` to `S.L₂'` which is `S.L₀.X₃ ⟶ S.L₃.X₁ ⟶ S.L₃.X₂`. -/ @[simps] noncomputable def functorL₂' : SnakeInput C ⥤ ShortComplex C where obj S := S.L₂' map f := { τ₁ := f.f₀.τ₃ τ₂ := f.f₃.τ₁ τ₃ := f.f₃.τ₂ comm₁₂ := (naturality_δ f).symm comm₂₃ := f.f₃.comm₁₂ } /-- The functor which maps `S : SnakeInput C` to the diagram `S.L₀.X₁ ⟶ S.L₀.X₂ ⟶ S.L₀.X₃ ⟶ S.L₃.X₁ ⟶ S.L₃.X₂ ⟶ S.L₃.X₃`. -/ @[simps] noncomputable def composableArrowsFunctor : SnakeInput C ⥤ ComposableArrows C 5 where obj S := S.composableArrows map f := ComposableArrows.homMk₅ f.f₀.τ₁ f.f₀.τ₂ f.f₀.τ₃ f.f₃.τ₁ f.f₃.τ₂ f.f₃.τ₃ f.f₀.comm₁₂.symm f.f₀.comm₂₃.symm (naturality_δ f) f.f₃.comm₁₂.symm f.f₃.comm₂₃.symm end SnakeInput end ShortComplex end CategoryTheory
Algebra\Jordan\Basic.lean
/- Copyright (c) 2021 Christopher Hoskin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Christopher Hoskin -/ import Mathlib.Algebra.Lie.OfAssociative /-! # Jordan rings Let `A` be a non-unital, non-associative ring. Then `A` is said to be a (commutative, linear) Jordan ring if the multiplication is commutative and satisfies a weak associativity law known as the Jordan Identity: for all `a` and `b` in `A`, ``` (a * b) * a^2 = a * (b * a^2) ``` i.e. the operators of multiplication by `a` and `a^2` commute. A more general concept of a (non-commutative) Jordan ring can also be defined, as a (non-commutative, non-associative) ring `A` where, for each `a` in `A`, the operators of left and right multiplication by `a` and `a^2` commute. Every associative algebra can be equipped with a symmetrized multiplication (characterized by `SymAlg.sym_mul_sym`) making it into a commutative Jordan algebra (`IsCommJordan`). Jordan algebras arising this way are said to be special. A real Jordan algebra `A` can be introduced by ```lean variable {A : Type*} [NonUnitalNonAssocCommRing A] [Module ℝ A] [SMulCommClass ℝ A A] [IsScalarTower ℝ A A] [IsCommJordan A] ``` ## Main results - `two_nsmul_lie_lmul_lmul_add_add_eq_zero` : Linearisation of the commutative Jordan axiom ## Implementation notes We shall primarily be interested in linear Jordan algebras (i.e. over rings of characteristic not two) leaving quadratic algebras to those better versed in that theory. The conventional way to linearise the Jordan axiom is to equate coefficients (more formally, assume that the axiom holds in all field extensions). For simplicity we use brute force algebraic expansion and substitution instead. ## Motivation Every Jordan algebra `A` has a triple product defined, for `a` `b` and `c` in `A` by $$ {a\,b\,c} = (a * b) * c - (a * c) * b + a * (b * c). $$ Via this triple product Jordan algebras are related to a number of other mathematical structures: Jordan triples, partial Jordan triples, Jordan pairs and quadratic Jordan algebras. In addition to their considerable algebraic interest ([mccrimmon2004]) these structures have been shown to have deep connections to mathematical physics, functional analysis and differential geometry. For more information about these connections the interested reader is referred to [alfsenshultz2003], [chu2012], [friedmanscarr2005], [iordanescu2003] and [upmeier1987]. There are also exceptional Jordan algebras which can be shown not to be the symmetrization of any associative algebra. The 3x3 matrices of octonions is the canonical example. Non-commutative Jordan algebras have connections to the Vidav-Palmer theorem [cabreragarciarodriguezpalacios2014]. ## References * [Cabrera García and Rodríguez Palacios, Non-associative normed algebras. Volume 1] [cabreragarciarodriguezpalacios2014] * [Hanche-Olsen and Størmer, Jordan Operator Algebras][hancheolsenstormer1984] * [McCrimmon, A taste of Jordan algebras][mccrimmon2004] -/ variable (A : Type*) /-- A (non-commutative) Jordan multiplication. -/ class IsJordan [Mul A] : Prop where lmul_comm_rmul : ∀ a b : A, a * b * a = a * (b * a) lmul_lmul_comm_lmul : ∀ a b : A, a * a * (a * b) = a * (a * a * b) lmul_lmul_comm_rmul : ∀ a b : A, a * a * (b * a) = a * a * b * a lmul_comm_rmul_rmul : ∀ a b : A, a * b * (a * a) = a * (b * (a * a)) rmul_comm_rmul_rmul : ∀ a b : A, b * a * (a * a) = b * (a * a) * a /-- A commutative Jordan multipication -/ class IsCommJordan [CommMagma A] : Prop where lmul_comm_rmul_rmul : ∀ a b : A, a * b * (a * a) = a * (b * (a * a)) -- see Note [lower instance priority] /-- A (commutative) Jordan multiplication is also a Jordan multipication -/ instance (priority := 100) IsCommJordan.toIsJordan [CommMagma A] [IsCommJordan A] : IsJordan A where lmul_comm_rmul a b := by rw [mul_comm, mul_comm a b] lmul_lmul_comm_lmul a b := by rw [mul_comm (a * a) (a * b), IsCommJordan.lmul_comm_rmul_rmul, mul_comm b (a * a)] lmul_comm_rmul_rmul := IsCommJordan.lmul_comm_rmul_rmul lmul_lmul_comm_rmul a b := by rw [mul_comm (a * a) (b * a), mul_comm b a, IsCommJordan.lmul_comm_rmul_rmul, mul_comm, mul_comm b (a * a)] rmul_comm_rmul_rmul a b := by rw [mul_comm b a, IsCommJordan.lmul_comm_rmul_rmul, mul_comm] -- see Note [lower instance priority] /-- Semigroup multiplication satisfies the (non-commutative) Jordan axioms-/ instance (priority := 100) Semigroup.isJordan [Semigroup A] : IsJordan A where lmul_comm_rmul a b := by rw [mul_assoc] lmul_lmul_comm_lmul a b := by rw [mul_assoc, mul_assoc] lmul_comm_rmul_rmul a b := by rw [mul_assoc] lmul_lmul_comm_rmul a b := by rw [← mul_assoc] rmul_comm_rmul_rmul a b := by rw [← mul_assoc, ← mul_assoc] -- see Note [lower instance priority] instance (priority := 100) CommSemigroup.isCommJordan [CommSemigroup A] : IsCommJordan A where lmul_comm_rmul_rmul _ _ := mul_assoc _ _ _ local notation "L" => AddMonoid.End.mulLeft local notation "R" => AddMonoid.End.mulRight /-! The Jordan axioms can be expressed in terms of commuting multiplication operators. -/ section Commute variable {A} [NonUnitalNonAssocRing A] [IsJordan A] @[simp] theorem commute_lmul_rmul (a : A) : Commute (L a) (R a) := AddMonoidHom.ext fun _ => (IsJordan.lmul_comm_rmul _ _).symm @[simp] theorem commute_lmul_lmul_sq (a : A) : Commute (L a) (L (a * a)) := AddMonoidHom.ext fun _ => (IsJordan.lmul_lmul_comm_lmul _ _).symm @[simp] theorem commute_lmul_rmul_sq (a : A) : Commute (L a) (R (a * a)) := AddMonoidHom.ext fun _ => (IsJordan.lmul_comm_rmul_rmul _ _).symm @[simp] theorem commute_lmul_sq_rmul (a : A) : Commute (L (a * a)) (R a) := AddMonoidHom.ext fun _ => IsJordan.lmul_lmul_comm_rmul _ _ @[simp] theorem commute_rmul_rmul_sq (a : A) : Commute (R a) (R (a * a)) := AddMonoidHom.ext fun _ => (IsJordan.rmul_comm_rmul_rmul _ _).symm end Commute variable {A} [NonUnitalNonAssocCommRing A] /-! The endomorphisms on an additive monoid `AddMonoid.End` form a `Ring`, and this may be equipped with a Lie Bracket via `Ring.bracket`. -/ theorem two_nsmul_lie_lmul_lmul_add_eq_lie_lmul_lmul_add [IsCommJordan A] (a b : A) : 2 • (⁅L a, L (a * b)⁆ + ⁅L b, L (b * a)⁆) = ⁅L (a * a), L b⁆ + ⁅L (b * b), L a⁆ := by suffices 2 • ⁅L a, L (a * b)⁆ + 2 • ⁅L b, L (b * a)⁆ + ⁅L b, L (a * a)⁆ + ⁅L a, L (b * b)⁆ = 0 by rwa [← sub_eq_zero, ← sub_sub, sub_eq_add_neg, sub_eq_add_neg, lie_skew, lie_skew, nsmul_add] convert (commute_lmul_lmul_sq (a + b)).lie_eq using 1 simp only [add_mul, mul_add, map_add, lie_add, add_lie, mul_comm b a, (commute_lmul_lmul_sq a).lie_eq, (commute_lmul_lmul_sq b).lie_eq, zero_add, add_zero, two_smul] abel -- Porting note: the monolithic `calc`-based proof of `two_nsmul_lie_lmul_lmul_add_add_eq_zero` -- has had four auxiliary parts `aux{0,1,2,3}` split off from it. private theorem aux0 {a b c : A} : ⁅L (a + b + c), L ((a + b + c) * (a + b + c))⁆ = ⁅L a + L b + L c, L (a * a) + L (b * b) + L (c * c) + 2 • L (a * b) + 2 • L (c * a) + 2 • L (b * c)⁆ := by rw [add_mul, add_mul] iterate 6 rw [mul_add] iterate 10 rw [map_add] rw [mul_comm b a, mul_comm c a, mul_comm c b] iterate 3 rw [two_smul] simp only [lie_add, add_lie, commute_lmul_lmul_sq, zero_add, add_zero] abel private theorem aux1 {a b c : A} : ⁅L a + L b + L c, L (a * a) + L (b * b) + L (c * c) + 2 • L (a * b) + 2 • L (c * a) + 2 • L (b * c)⁆ = ⁅L a, L (a * a)⁆ + ⁅L a, L (b * b)⁆ + ⁅L a, L (c * c)⁆ + ⁅L a, 2 • L (a * b)⁆ + ⁅L a, 2 • L (c * a)⁆ + ⁅L a, 2 • L (b * c)⁆ + (⁅L b, L (a * a)⁆ + ⁅L b, L (b * b)⁆ + ⁅L b, L (c * c)⁆ + ⁅L b, 2 • L (a * b)⁆ + ⁅L b, 2 • L (c * a)⁆ + ⁅L b, 2 • L (b * c)⁆) + (⁅L c, L (a * a)⁆ + ⁅L c, L (b * b)⁆ + ⁅L c, L (c * c)⁆ + ⁅L c, 2 • L (a * b)⁆ + ⁅L c, 2 • L (c * a)⁆ + ⁅L c, 2 • L (b * c)⁆) := by rw [add_lie, add_lie] iterate 15 rw [lie_add] variable [IsCommJordan A] private theorem aux2 {a b c : A} : ⁅L a, L (a * a)⁆ + ⁅L a, L (b * b)⁆ + ⁅L a, L (c * c)⁆ + ⁅L a, 2 • L (a * b)⁆ + ⁅L a, 2 • L (c * a)⁆ + ⁅L a, 2 • L (b * c)⁆ + (⁅L b, L (a * a)⁆ + ⁅L b, L (b * b)⁆ + ⁅L b, L (c * c)⁆ + ⁅L b, 2 • L (a * b)⁆ + ⁅L b, 2 • L (c * a)⁆ + ⁅L b, 2 • L (b * c)⁆) + (⁅L c, L (a * a)⁆ + ⁅L c, L (b * b)⁆ + ⁅L c, L (c * c)⁆ + ⁅L c, 2 • L (a * b)⁆ + ⁅L c, 2 • L (c * a)⁆ + ⁅L c, 2 • L (b * c)⁆) = ⁅L a, L (b * b)⁆ + ⁅L b, L (a * a)⁆ + 2 • (⁅L a, L (a * b)⁆ + ⁅L b, L (a * b)⁆) + (⁅L a, L (c * c)⁆ + ⁅L c, L (a * a)⁆ + 2 • (⁅L a, L (c * a)⁆ + ⁅L c, L (c * a)⁆)) + (⁅L b, L (c * c)⁆ + ⁅L c, L (b * b)⁆ + 2 • (⁅L b, L (b * c)⁆ + ⁅L c, L (b * c)⁆)) + (2 • ⁅L a, L (b * c)⁆ + 2 • ⁅L b, L (c * a)⁆ + 2 • ⁅L c, L (a * b)⁆) := by rw [(commute_lmul_lmul_sq a).lie_eq, (commute_lmul_lmul_sq b).lie_eq, (commute_lmul_lmul_sq c).lie_eq, zero_add, add_zero, add_zero] simp only [lie_nsmul] abel private theorem aux3 {a b c : A} : ⁅L a, L (b * b)⁆ + ⁅L b, L (a * a)⁆ + 2 • (⁅L a, L (a * b)⁆ + ⁅L b, L (a * b)⁆) + (⁅L a, L (c * c)⁆ + ⁅L c, L (a * a)⁆ + 2 • (⁅L a, L (c * a)⁆ + ⁅L c, L (c * a)⁆)) + (⁅L b, L (c * c)⁆ + ⁅L c, L (b * b)⁆ + 2 • (⁅L b, L (b * c)⁆ + ⁅L c, L (b * c)⁆)) + (2 • ⁅L a, L (b * c)⁆ + 2 • ⁅L b, L (c * a)⁆ + 2 • ⁅L c, L (a * b)⁆) = 2 • ⁅L a, L (b * c)⁆ + 2 • ⁅L b, L (c * a)⁆ + 2 • ⁅L c, L (a * b)⁆ := by rw [add_left_eq_self] -- Porting note: was `nth_rw` instead of `conv_lhs` conv_lhs => enter [1, 1, 2, 2, 2]; rw [mul_comm a b] conv_lhs => enter [1, 2, 2, 2, 1]; rw [mul_comm c a] conv_lhs => enter [ 2, 2, 2, 2]; rw [mul_comm b c] iterate 3 rw [two_nsmul_lie_lmul_lmul_add_eq_lie_lmul_lmul_add] iterate 2 rw [← lie_skew (L (a * a)), ← lie_skew (L (b * b)), ← lie_skew (L (c * c))] abel theorem two_nsmul_lie_lmul_lmul_add_add_eq_zero (a b c : A) : 2 • (⁅L a, L (b * c)⁆ + ⁅L b, L (c * a)⁆ + ⁅L c, L (a * b)⁆) = 0 := by symm calc 0 = ⁅L (a + b + c), L ((a + b + c) * (a + b + c))⁆ := by rw [(commute_lmul_lmul_sq (a + b + c)).lie_eq] _ = _ := by rw [aux0, aux1, aux2, aux3, nsmul_add, nsmul_add]
Algebra\Lie\Abelian.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.OfAssociative import Mathlib.Algebra.Lie.IdealOperations /-! # Trivial Lie modules and Abelian Lie algebras The action of a Lie algebra `L` on a module `M` is trivial if `⁅x, m⁆ = 0` for all `x ∈ L` and `m ∈ M`. In the special case that `M = L` with the adjoint action, triviality corresponds to the concept of an Abelian Lie algebra. In this file we define these concepts and provide some related definitions and results. ## Main definitions * `LieModule.IsTrivial` * `IsLieAbelian` * `commutative_ring_iff_abelian_lie_ring` * `LieModule.ker` * `LieModule.maxTrivSubmodule` * `LieAlgebra.center` ## Tags lie algebra, abelian, commutative, center -/ universe u v w w₁ w₂ /-- A Lie (ring) module is trivial iff all brackets vanish. -/ class LieModule.IsTrivial (L : Type v) (M : Type w) [Bracket L M] [Zero M] : Prop where trivial : ∀ (x : L) (m : M), ⁅x, m⁆ = 0 @[simp] theorem trivial_lie_zero (L : Type v) (M : Type w) [Bracket L M] [Zero M] [LieModule.IsTrivial L M] (x : L) (m : M) : ⁅x, m⁆ = 0 := LieModule.IsTrivial.trivial x m instance LieModule.instIsTrivialOfSubsingleton {L M : Type*} [LieRing L] [AddCommGroup M] [LieRingModule L M] [Subsingleton L] : LieModule.IsTrivial L M := ⟨fun x m ↦ by rw [Subsingleton.eq_zero x, zero_lie]⟩ instance LieModule.instIsTrivialOfSubsingleton' {L M : Type*} [LieRing L] [AddCommGroup M] [LieRingModule L M] [Subsingleton M] : LieModule.IsTrivial L M := ⟨fun x m ↦ by simp_rw [Subsingleton.eq_zero m, lie_zero]⟩ /-- A Lie algebra is Abelian iff it is trivial as a Lie module over itself. -/ abbrev IsLieAbelian (L : Type v) [Bracket L L] [Zero L] : Prop := LieModule.IsTrivial L L instance LieIdeal.isLieAbelian_of_trivial (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L) [h : LieModule.IsTrivial L I] : IsLieAbelian I where trivial x y := by apply h.trivial theorem Function.Injective.isLieAbelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R] [LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] {f : L₁ →ₗ⁅R⁆ L₂} (h₁ : Function.Injective f) (_ : IsLieAbelian L₂) : IsLieAbelian L₁ := { trivial := fun x y => h₁ <| calc f ⁅x, y⁆ = ⁅f x, f y⁆ := LieHom.map_lie f x y _ = 0 := trivial_lie_zero _ _ _ _ _ = f 0 := f.map_zero.symm} theorem Function.Surjective.isLieAbelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R] [LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] {f : L₁ →ₗ⁅R⁆ L₂} (h₁ : Function.Surjective f) (h₂ : IsLieAbelian L₁) : IsLieAbelian L₂ := { trivial := fun x y => by obtain ⟨u, rfl⟩ := h₁ x obtain ⟨v, rfl⟩ := h₁ y rw [← LieHom.map_lie, trivial_lie_zero, LieHom.map_zero] } theorem lie_abelian_iff_equiv_lie_abelian {R : Type u} {L₁ : Type v} {L₂ : Type w} [CommRing R] [LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] (e : L₁ ≃ₗ⁅R⁆ L₂) : IsLieAbelian L₁ ↔ IsLieAbelian L₂ := ⟨e.symm.injective.isLieAbelian, e.injective.isLieAbelian⟩ theorem commutative_ring_iff_abelian_lie_ring {A : Type v} [Ring A] : Std.Commutative (α := A) (· * ·) ↔ IsLieAbelian A := by have h₁ : Std.Commutative (α := A) (· * ·) ↔ ∀ a b : A, a * b = b * a := ⟨fun h => h.1, fun h => ⟨h⟩⟩ have h₂ : IsLieAbelian A ↔ ∀ a b : A, ⁅a, b⁆ = 0 := ⟨fun h => h.1, fun h => ⟨h⟩⟩ simp only [h₁, h₂, LieRing.of_associative_ring_bracket, sub_eq_zero] section Center variable (R : Type u) (L : Type v) (M : Type w) (N : Type w₁) variable [CommRing R] [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [AddCommGroup N] [Module R N] [LieRingModule L N] [LieModule R L N] namespace LieModule /-- The kernel of the action of a Lie algebra `L` on a Lie module `M` as a Lie ideal in `L`. -/ protected def ker : LieIdeal R L := (toEnd R L M).ker @[simp] protected theorem mem_ker (x : L) : x ∈ LieModule.ker R L M ↔ ∀ m : M, ⁅x, m⁆ = 0 := by simp only [LieModule.ker, LieHom.mem_ker, LinearMap.ext_iff, LinearMap.zero_apply, toEnd_apply_apply] /-- The largest submodule of a Lie module `M` on which the Lie algebra `L` acts trivially. -/ def maxTrivSubmodule : LieSubmodule R L M where carrier := { m | ∀ x : L, ⁅x, m⁆ = 0 } zero_mem' x := lie_zero x add_mem' {x y} hx hy z := by rw [lie_add, hx, hy, add_zero] smul_mem' c x hx y := by rw [lie_smul, hx, smul_zero] lie_mem {x m} hm y := by rw [hm, lie_zero] @[simp] theorem mem_maxTrivSubmodule (m : M) : m ∈ maxTrivSubmodule R L M ↔ ∀ x : L, ⁅x, m⁆ = 0 := Iff.rfl instance : IsTrivial L (maxTrivSubmodule R L M) where trivial x m := Subtype.ext (m.property x) @[simp] theorem ideal_oper_maxTrivSubmodule_eq_bot (I : LieIdeal R L) : ⁅I, maxTrivSubmodule R L M⁆ = ⊥ := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.bot_coeSubmodule, Submodule.span_eq_bot] rintro m ⟨⟨x, hx⟩, ⟨⟨m, hm⟩, rfl⟩⟩ exact hm x theorem le_max_triv_iff_bracket_eq_bot {N : LieSubmodule R L M} : N ≤ maxTrivSubmodule R L M ↔ ⁅(⊤ : LieIdeal R L), N⁆ = ⊥ := by refine ⟨fun h => ?_, fun h m hm => ?_⟩ · rw [← le_bot_iff, ← ideal_oper_maxTrivSubmodule_eq_bot R L M ⊤] exact LieSubmodule.mono_lie_right ⊤ h · rw [mem_maxTrivSubmodule] rw [LieSubmodule.lie_eq_bot_iff] at h exact fun x => h x (LieSubmodule.mem_top x) m hm theorem trivial_iff_le_maximal_trivial (N : LieSubmodule R L M) : IsTrivial L N ↔ N ≤ maxTrivSubmodule R L M := ⟨fun h m hm x => IsTrivial.casesOn h fun h => Subtype.ext_iff.mp (h x ⟨m, hm⟩), fun h => { trivial := fun x m => Subtype.ext (h m.2 x) }⟩ theorem isTrivial_iff_max_triv_eq_top : IsTrivial L M ↔ maxTrivSubmodule R L M = ⊤ := by constructor · rintro ⟨h⟩; ext; simp only [mem_maxTrivSubmodule, h, forall_const, LieSubmodule.mem_top] · intro h; constructor; intro x m; revert x rw [← mem_maxTrivSubmodule R L M, h]; exact LieSubmodule.mem_top m variable {R L M N} /-- `maxTrivSubmodule` is functorial. -/ def maxTrivHom (f : M →ₗ⁅R,L⁆ N) : maxTrivSubmodule R L M →ₗ⁅R,L⁆ maxTrivSubmodule R L N where toFun m := ⟨f m, fun x => (LieModuleHom.map_lie _ _ _).symm.trans <| (congr_arg f (m.property x)).trans (LieModuleHom.map_zero _)⟩ map_add' m n := by simp [Function.comp_apply]; rfl -- Porting note: map_smul' t m := by simp [Function.comp_apply]; rfl -- these two were `by simpa` map_lie' {x m} := by simp @[norm_cast, simp] theorem coe_maxTrivHom_apply (f : M →ₗ⁅R,L⁆ N) (m : maxTrivSubmodule R L M) : (maxTrivHom f m : N) = f m := rfl /-- The maximal trivial submodules of Lie-equivalent Lie modules are Lie-equivalent. -/ def maxTrivEquiv (e : M ≃ₗ⁅R,L⁆ N) : maxTrivSubmodule R L M ≃ₗ⁅R,L⁆ maxTrivSubmodule R L N := { maxTrivHom (e : M →ₗ⁅R,L⁆ N) with toFun := maxTrivHom (e : M →ₗ⁅R,L⁆ N) invFun := maxTrivHom (e.symm : N →ₗ⁅R,L⁆ M) left_inv := fun m => by ext; simp [LieModuleEquiv.coe_to_lieModuleHom] right_inv := fun n => by ext; simp [LieModuleEquiv.coe_to_lieModuleHom] } @[norm_cast, simp] theorem coe_maxTrivEquiv_apply (e : M ≃ₗ⁅R,L⁆ N) (m : maxTrivSubmodule R L M) : (maxTrivEquiv e m : N) = e ↑m := rfl @[simp] theorem maxTrivEquiv_of_refl_eq_refl : maxTrivEquiv (LieModuleEquiv.refl : M ≃ₗ⁅R,L⁆ M) = LieModuleEquiv.refl := by ext; simp only [coe_maxTrivEquiv_apply, LieModuleEquiv.refl_apply] @[simp] theorem maxTrivEquiv_of_equiv_symm_eq_symm (e : M ≃ₗ⁅R,L⁆ N) : (maxTrivEquiv e).symm = maxTrivEquiv e.symm := rfl /-- A linear map between two Lie modules is a morphism of Lie modules iff the Lie algebra action on it is trivial. -/ def maxTrivLinearMapEquivLieModuleHom : maxTrivSubmodule R L (M →ₗ[R] N) ≃ₗ[R] M →ₗ⁅R,L⁆ N where toFun f := { toLinearMap := f.val map_lie' := fun {x m} => by have hf : ⁅x, f.val⁆ m = 0 := by rw [f.property x, LinearMap.zero_apply] rw [LieHom.lie_apply, sub_eq_zero, ← LinearMap.toFun_eq_coe] at hf; exact hf.symm} map_add' f g := by ext; simp map_smul' F G := by ext; simp invFun F := ⟨F, fun x => by ext; simp⟩ left_inv f := by simp right_inv F := by simp @[simp] theorem coe_maxTrivLinearMapEquivLieModuleHom (f : maxTrivSubmodule R L (M →ₗ[R] N)) : (maxTrivLinearMapEquivLieModuleHom f : M → N) = f := by ext; rfl @[simp] theorem coe_maxTrivLinearMapEquivLieModuleHom_symm (f : M →ₗ⁅R,L⁆ N) : (maxTrivLinearMapEquivLieModuleHom.symm f : M → N) = f := rfl @[simp] theorem coe_linearMap_maxTrivLinearMapEquivLieModuleHom (f : maxTrivSubmodule R L (M →ₗ[R] N)) : (maxTrivLinearMapEquivLieModuleHom f : M →ₗ[R] N) = (f : M →ₗ[R] N) := by ext; rfl @[simp] theorem coe_linearMap_maxTrivLinearMapEquivLieModuleHom_symm (f : M →ₗ⁅R,L⁆ N) : (maxTrivLinearMapEquivLieModuleHom.symm f : M →ₗ[R] N) = (f : M →ₗ[R] N) := rfl end LieModule namespace LieAlgebra /-- The center of a Lie algebra is the set of elements that commute with everything. It can be viewed as the maximal trivial submodule of the Lie algebra as a Lie module over itself via the adjoint representation. -/ abbrev center : LieIdeal R L := LieModule.maxTrivSubmodule R L L instance : IsLieAbelian (center R L) := inferInstance @[simp] theorem ad_ker_eq_self_module_ker : (ad R L).ker = LieModule.ker R L L := rfl @[simp] theorem self_module_ker_eq_center : LieModule.ker R L L = center R L := by ext y simp only [LieModule.mem_maxTrivSubmodule, LieModule.mem_ker, ← lie_skew _ y, neg_eq_zero] theorem abelian_of_le_center (I : LieIdeal R L) (h : I ≤ center R L) : IsLieAbelian I := haveI : LieModule.IsTrivial L I := (LieModule.trivial_iff_le_maximal_trivial R L L I).mpr h LieIdeal.isLieAbelian_of_trivial R L I theorem isLieAbelian_iff_center_eq_top : IsLieAbelian L ↔ center R L = ⊤ := LieModule.isTrivial_iff_max_triv_eq_top R L L end LieAlgebra namespace LieModule variable {R L} variable {x : L} (hx : x ∈ LieAlgebra.center R L) (y : L) lemma commute_toEnd_of_mem_center_left : Commute (toEnd R L M x) (toEnd R L M y) := by rw [Commute.symm_iff, commute_iff_lie_eq, ← LieHom.map_lie, hx y, LieHom.map_zero] lemma commute_toEnd_of_mem_center_right : Commute (toEnd R L M y) (toEnd R L M x) := (LieModule.commute_toEnd_of_mem_center_left M hx y).symm end LieModule end Center section IdealOperations open LieSubmodule LieSubalgebra variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] (N N' : LieSubmodule R L M) (I J : LieIdeal R L) @[simp] theorem LieSubmodule.trivial_lie_oper_zero [LieModule.IsTrivial L M] : ⁅I, N⁆ = ⊥ := by suffices ⁅I, N⁆ ≤ ⊥ from le_bot_iff.mp this rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] rintro m ⟨x, n, h⟩; rw [trivial_lie_zero] at h; simp [← h] theorem LieSubmodule.lie_abelian_iff_lie_self_eq_bot : IsLieAbelian I ↔ ⁅I, I⁆ = ⊥ := by simp only [_root_.eq_bot_iff, lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le, LieSubmodule.bot_coe, Set.subset_singleton_iff, Set.mem_setOf_eq, exists_imp] refine ⟨fun h z x y hz => hz.symm.trans (((I : LieSubalgebra R L).coe_bracket x y).symm.trans ((coe_zero_iff_zero _ _).mpr (by apply h.trivial))), fun h => ⟨fun x y => ((I : LieSubalgebra R L).coe_zero_iff_zero _).mp (h _ x y rfl)⟩⟩ variable {I N} in lemma lie_eq_self_of_isAtom_of_ne_bot (hN : IsAtom N) (h : ⁅I, N⁆ ≠ ⊥) : ⁅I, N⁆ = N := (hN.le_iff_eq h).mp <| LieSubmodule.lie_le_right N I -- TODO: introduce typeclass for perfect Lie algebras and use it here in the conclusion lemma lie_eq_self_of_isAtom_of_nonabelian {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L) (hI : IsAtom I) (h : ¬IsLieAbelian I) : ⁅I, I⁆ = I := lie_eq_self_of_isAtom_of_ne_bot hI <| not_imp_not.mpr (lie_abelian_iff_lie_self_eq_bot I).mpr h end IdealOperations
Algebra\Lie\BaseChange.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Algebra.RestrictScalars import Mathlib.Algebra.Lie.TensorProduct import Mathlib.LinearAlgebra.TensorProduct.Tower import Mathlib.RingTheory.TensorProduct.Basic /-! # Extension and restriction of scalars for Lie algebras and Lie modules Lie algebras and their representations have a well-behaved theory of extension and restriction of scalars. ## Main definitions * `LieAlgebra.ExtendScalars.instLieAlgebra` * `LieAlgebra.ExtendScalars.instLieModule` * `LieAlgebra.RestrictScalars.lieAlgebra` ## Tags lie ring, lie algebra, extension of scalars, restriction of scalars, base change -/ suppress_compilation open scoped TensorProduct variable (R A L M : Type*) namespace LieAlgebra namespace ExtendScalars variable [CommRing R] [CommRing A] [Algebra R A] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] /-- The Lie bracket on the extension of a Lie algebra `L` over `R` by an algebra `A` over `R`. -/ private def bracket' : A ⊗[R] L →ₗ[A] A ⊗[R] M →ₗ[A] A ⊗[R] M := TensorProduct.curry <| TensorProduct.AlgebraTensorModule.map (LinearMap.mul' A A) (LieModule.toModuleHom R L M : L ⊗[R] M →ₗ[R] M) ∘ₗ (TensorProduct.AlgebraTensorModule.tensorTensorTensorComm R A A L A M).toLinearMap @[simp] private theorem bracket'_tmul (s t : A) (x : L) (m : M) : bracket' R A L M (s ⊗ₜ[R] x) (t ⊗ₜ[R] m) = (s * t) ⊗ₜ ⁅x, m⁆ := rfl instance : Bracket (A ⊗[R] L) (A ⊗[R] M) where bracket x m := bracket' R A L M x m private theorem bracket_def (x : A ⊗[R] L) (m : A ⊗[R] M) : ⁅x, m⁆ = bracket' R A L M x m := rfl @[simp] theorem bracket_tmul (s t : A) (x : L) (y : M) : ⁅s ⊗ₜ[R] x, t ⊗ₜ[R] y⁆ = (s * t) ⊗ₜ ⁅x, y⁆ := rfl private theorem bracket_lie_self (x : A ⊗[R] L) : ⁅x, x⁆ = 0 := by simp only [bracket_def] refine x.induction_on ?_ ?_ ?_ · simp only [LinearMap.map_zero, eq_self_iff_true, LinearMap.zero_apply] · intro a l simp only [bracket'_tmul, TensorProduct.tmul_zero, eq_self_iff_true, lie_self] · intro z₁ z₂ h₁ h₂ suffices bracket' R A L L z₁ z₂ + bracket' R A L L z₂ z₁ = 0 by rw [LinearMap.map_add, LinearMap.map_add, LinearMap.add_apply, LinearMap.add_apply, h₁, h₂, zero_add, add_zero, add_comm, this] refine z₁.induction_on ?_ ?_ ?_ · simp only [LinearMap.map_zero, add_zero, LinearMap.zero_apply] · intro a₁ l₁; refine z₂.induction_on ?_ ?_ ?_ · simp only [LinearMap.map_zero, add_zero, LinearMap.zero_apply] · intro a₂ l₂ simp only [← lie_skew l₂ l₁, mul_comm a₁ a₂, TensorProduct.tmul_neg, bracket'_tmul, add_right_neg] · intro y₁ y₂ hy₁ hy₂ simp only [hy₁, hy₂, add_add_add_comm, add_zero, LinearMap.add_apply, LinearMap.map_add] · intro y₁ y₂ hy₁ hy₂ simp only [add_add_add_comm, hy₁, hy₂, add_zero, LinearMap.add_apply, LinearMap.map_add] private theorem bracket_leibniz_lie (x y : A ⊗[R] L) (z : A ⊗[R] M) : ⁅x, ⁅y, z⁆⁆ = ⁅⁅x, y⁆, z⁆ + ⁅y, ⁅x, z⁆⁆ := by -- Porting note: replaced some `simp`s by `rw`s to avoid raising heartbeats simp only [bracket_def] refine x.induction_on ?_ ?_ ?_ · simp only [LinearMap.map_zero, add_zero, LinearMap.zero_apply] · intro a₁ l₁ refine y.induction_on ?_ ?_ ?_ · simp only [LinearMap.map_zero, add_zero, LinearMap.zero_apply] · intro a₂ l₂ refine z.induction_on ?_ ?_ ?_ · rw [LinearMap.map_zero, LinearMap.map_zero, LinearMap.map_zero, LinearMap.map_zero, add_zero] · intro a₃ l₃; simp only [bracket'_tmul] rw [mul_left_comm a₂ a₁ a₃, mul_assoc, leibniz_lie, TensorProduct.tmul_add] · intro u₁ u₂ h₁ h₂ rw [map_add, map_add, map_add, map_add, map_add, h₁, h₂, add_add_add_comm] · intro u₁ u₂ h₁ h₂ rw [map_add, LinearMap.add_apply, LinearMap.add_apply, map_add, map_add, map_add, LinearMap.add_apply, h₁, h₂, add_add_add_comm] · intro u₁ u₂ h₁ h₂ rw [map_add, LinearMap.add_apply, LinearMap.add_apply, map_add, map_add, LinearMap.add_apply, map_add, LinearMap.add_apply, h₁, h₂, add_add_add_comm] instance instLieRing : LieRing (A ⊗[R] L) where add_lie x y z := by simp only [bracket_def, LinearMap.add_apply, LinearMap.map_add] lie_add x y z := by simp only [bracket_def, LinearMap.map_add] lie_self := bracket_lie_self R A L leibniz_lie := bracket_leibniz_lie R A L L instance instLieAlgebra : LieAlgebra A (A ⊗[R] L) where lie_smul _a _x _y := map_smul _ _ _ instance instLieRingModule : LieRingModule (A ⊗[R] L) (A ⊗[R] M) where add_lie x y z := by simp only [bracket_def, LinearMap.add_apply, LinearMap.map_add] lie_add x y z := by simp only [bracket_def, LinearMap.map_add] leibniz_lie := bracket_leibniz_lie R A L M instance instLieModule : LieModule A (A ⊗[R] L) (A ⊗[R] M) where smul_lie t x m := by simp only [bracket_def, map_smul, LinearMap.smul_apply] lie_smul t x m := map_smul _ _ _ end ExtendScalars namespace RestrictScalars open RestrictScalars variable [h : LieRing L] instance : LieRing (RestrictScalars R A L) := h variable [CommRing A] [LieAlgebra A L] instance lieAlgebra [CommRing R] [Algebra R A] : LieAlgebra R (RestrictScalars R A L) where lie_smul t x y := (lie_smul (algebraMap R A t) (RestrictScalars.addEquiv R A L x) (RestrictScalars.addEquiv R A L y) : _) end RestrictScalars end LieAlgebra section ExtendScalars variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] [CommRing A] [Algebra R A] @[simp] lemma LieModule.toEnd_baseChange (x : L) : toEnd A (A ⊗[R] L) (A ⊗[R] M) (1 ⊗ₜ x) = (toEnd R L M x).baseChange A := by ext; simp namespace LieSubmodule variable (N : LieSubmodule R L M) open LieModule variable {R L M} in /-- If `A` is an `R`-algebra, any Lie submodule of a Lie module `M` with coefficients in `R` may be pushed forward to a Lie submodule of `A ⊗ M` with coefficients in `A`. This "base change" operation is also known as "extension of scalars". -/ def baseChange : LieSubmodule A (A ⊗[R] L) (A ⊗[R] M) := { (N : Submodule R M).baseChange A with lie_mem := by intro x m hm simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid] at hm ⊢ obtain ⟨c, rfl⟩ := (Finsupp.mem_span_iff_total _ _ _).mp hm refine x.induction_on (by simp) (fun a y ↦ ?_) (fun y z hy hz ↦ ?_) · change toEnd A (A ⊗[R] L) (A ⊗[R] M) _ _ ∈ _ simp_rw [Finsupp.total_apply, Finsupp.sum, map_sum, map_smul, toEnd_apply_apply] suffices ∀ n : (N : Submodule R M).map (TensorProduct.mk R A M 1), ⁅a ⊗ₜ[R] y, (n : A ⊗[R] M)⁆ ∈ (N : Submodule R M).baseChange A by exact Submodule.sum_mem _ fun n _ ↦ Submodule.smul_mem _ _ (this n) rintro ⟨-, ⟨n : M, hn : n ∈ N, rfl⟩⟩ exact Submodule.tmul_mem_baseChange_of_mem _ (N.lie_mem hn) · rw [add_lie] exact ((N : Submodule R M).baseChange A).add_mem hy hz } @[simp] lemma coe_baseChange : (N.baseChange A : Submodule A (A ⊗[R] M)) = (N : Submodule R M).baseChange A := rfl variable {N} variable {R A L M} in lemma tmul_mem_baseChange_of_mem (a : A) {m : M} (hm : m ∈ N) : a ⊗ₜ[R] m ∈ N.baseChange A := (N : Submodule R M).tmul_mem_baseChange_of_mem a hm lemma mem_baseChange_iff {m : A ⊗[R] M} : m ∈ N.baseChange A ↔ m ∈ Submodule.span A ((N : Submodule R M).map (TensorProduct.mk R A M 1)) := Iff.rfl @[simp] lemma baseChange_bot : (⊥ : LieSubmodule R L M).baseChange A = ⊥ := by simp only [baseChange, bot_coeSubmodule, Submodule.baseChange_bot, Submodule.bot_toAddSubmonoid] rfl @[simp] lemma baseChange_top : (⊤ : LieSubmodule R L M).baseChange A = ⊤ := by simp only [baseChange, top_coeSubmodule, Submodule.baseChange_top, Submodule.bot_toAddSubmonoid] rfl lemma lie_baseChange {I : LieIdeal R L} {N : LieSubmodule R L M} : ⁅I, N⁆.baseChange A = ⁅I.baseChange A, N.baseChange A⁆ := by set s : Set (A ⊗[R] M) := { m | ∃ x ∈ I, ∃ n ∈ N, 1 ⊗ₜ ⁅x, n⁆ = m} have : (TensorProduct.mk R A M 1) '' {m | ∃ x ∈ I, ∃ n ∈ N, ⁅x, n⁆ = m} = s := by ext; simp [s] rw [← coe_toSubmodule_eq_iff, coe_baseChange, lieIdeal_oper_eq_linear_span', Submodule.baseChange_span, this, lieIdeal_oper_eq_linear_span'] refine le_antisymm (Submodule.span_mono ?_) (Submodule.span_le.mpr ?_) · rintro - ⟨x, hx, m, hm, rfl⟩ exact ⟨1 ⊗ₜ x, tmul_mem_baseChange_of_mem 1 hx, 1 ⊗ₜ m, tmul_mem_baseChange_of_mem 1 hm, by simp⟩ · rintro - ⟨x, hx, m, hm, rfl⟩ revert m apply Submodule.span_induction (p := fun x' ↦ ∀ m' ∈ N.baseChange A, ⁅x', m'⁆ ∈ Submodule.span A s) hx · rintro _ ⟨y : L, hy : y ∈ I, rfl⟩ m hm apply Submodule.span_induction (p := fun m' ↦ ⁅(1 : A) ⊗ₜ[R] y, m'⁆ ∈ Submodule.span A s) hm · rintro - ⟨m', hm' : m' ∈ N, rfl⟩ rw [TensorProduct.mk_apply, LieAlgebra.ExtendScalars.bracket_tmul, mul_one] apply Submodule.subset_span exact ⟨y, hy, m', hm', rfl⟩ · simp · intro u v hu hv rw [lie_add] exact Submodule.add_mem _ hu hv · intro a u hu rw [lie_smul] exact Submodule.smul_mem _ a hu · simp · intro x y hx hy m' hm' rw [add_lie] exact Submodule.add_mem _ (hx _ hm') (hy _ hm') · intro a x hx m' hm' rw [smul_lie] exact Submodule.smul_mem _ a (hx _ hm') end LieSubmodule end ExtendScalars
Algebra\Lie\Basic.lean
/- Copyright (c) 2019 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Module.Submodule.Equiv import Mathlib.Algebra.Module.Equiv.Basic import Mathlib.Data.Bracket import Mathlib.Tactic.Abel /-! # Lie algebras This file defines Lie rings and Lie algebras over a commutative ring together with their modules, morphisms and equivalences, as well as various lemmas to make these definitions usable. ## Main definitions * `LieRing` * `LieAlgebra` * `LieRingModule` * `LieModule` * `LieHom` * `LieEquiv` * `LieModuleHom` * `LieModuleEquiv` ## Notation Working over a fixed commutative ring `R`, we introduce the notations: * `L →ₗ⁅R⁆ L'` for a morphism of Lie algebras, * `L ≃ₗ⁅R⁆ L'` for an equivalence of Lie algebras, * `M →ₗ⁅R,L⁆ N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`, * `M ≃ₗ⁅R,L⁆ N` for an equivalence of Lie algebra modules `M`, `N` over a Lie algebra `L`. ## Implementation notes Lie algebras are defined as modules with a compatible Lie ring structure and thus, like modules, are partially unbundled. ## References * [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975) ## Tags lie bracket, jacobi identity, lie ring, lie algebra, lie module -/ universe u v w w₁ w₂ open Function /-- A Lie ring is an additive group with compatible product, known as the bracket, satisfying the Jacobi identity. -/ class LieRing (L : Type v) extends AddCommGroup L, Bracket L L where /-- A Lie ring bracket is additive in its first component. -/ protected add_lie : ∀ x y z : L, ⁅x + y, z⁆ = ⁅x, z⁆ + ⁅y, z⁆ /-- A Lie ring bracket is additive in its second component. -/ protected lie_add : ∀ x y z : L, ⁅x, y + z⁆ = ⁅x, y⁆ + ⁅x, z⁆ /-- A Lie ring bracket vanishes on the diagonal in L × L. -/ protected lie_self : ∀ x : L, ⁅x, x⁆ = 0 /-- A Lie ring bracket satisfies a Leibniz / Jacobi identity. -/ protected leibniz_lie : ∀ x y z : L, ⁅x, ⁅y, z⁆⁆ = ⁅⁅x, y⁆, z⁆ + ⁅y, ⁅x, z⁆⁆ /-- A Lie algebra is a module with compatible product, known as the bracket, satisfying the Jacobi identity. Forgetting the scalar multiplication, every Lie algebra is a Lie ring. -/ class LieAlgebra (R : Type u) (L : Type v) [CommRing R] [LieRing L] extends Module R L where /-- A Lie algebra bracket is compatible with scalar multiplication in its second argument. The compatibility in the first argument is not a class property, but follows since every Lie algebra has a natural Lie module action on itself, see `LieModule`. -/ protected lie_smul : ∀ (t : R) (x y : L), ⁅x, t • y⁆ = t • ⁅x, y⁆ /-- A Lie ring module is an additive group, together with an additive action of a Lie ring on this group, such that the Lie bracket acts as the commutator of endomorphisms. (For representations of Lie *algebras* see `LieModule`.) -/ class LieRingModule (L : Type v) (M : Type w) [LieRing L] [AddCommGroup M] extends Bracket L M where /-- A Lie ring module bracket is additive in its first component. -/ protected add_lie : ∀ (x y : L) (m : M), ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆ /-- A Lie ring module bracket is additive in its second component. -/ protected lie_add : ∀ (x : L) (m n : M), ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆ /-- A Lie ring module bracket satisfies a Leibniz / Jacobi identity. -/ protected leibniz_lie : ∀ (x y : L) (m : M), ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆ /-- A Lie module is a module over a commutative ring, together with a linear action of a Lie algebra on this module, such that the Lie bracket acts as the commutator of endomorphisms. -/ class LieModule (R : Type u) (L : Type v) (M : Type w) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] : Prop where /-- A Lie module bracket is compatible with scalar multiplication in its first argument. -/ protected smul_lie : ∀ (t : R) (x : L) (m : M), ⁅t • x, m⁆ = t • ⁅x, m⁆ /-- A Lie module bracket is compatible with scalar multiplication in its second argument. -/ protected lie_smul : ∀ (t : R) (x : L) (m : M), ⁅x, t • m⁆ = t • ⁅x, m⁆ section BasicProperties variable {R : Type u} {L : Type v} {M : Type w} {N : Type w₁} variable [CommRing R] [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [AddCommGroup N] [Module R N] [LieRingModule L N] [LieModule R L N] variable (t : R) (x y z : L) (m n : M) @[simp] theorem add_lie : ⁅x + y, m⁆ = ⁅x, m⁆ + ⁅y, m⁆ := LieRingModule.add_lie x y m @[simp] theorem lie_add : ⁅x, m + n⁆ = ⁅x, m⁆ + ⁅x, n⁆ := LieRingModule.lie_add x m n @[simp] theorem smul_lie : ⁅t • x, m⁆ = t • ⁅x, m⁆ := LieModule.smul_lie t x m @[simp] theorem lie_smul : ⁅x, t • m⁆ = t • ⁅x, m⁆ := LieModule.lie_smul t x m theorem leibniz_lie : ⁅x, ⁅y, m⁆⁆ = ⁅⁅x, y⁆, m⁆ + ⁅y, ⁅x, m⁆⁆ := LieRingModule.leibniz_lie x y m @[simp] theorem lie_zero : ⁅x, 0⁆ = (0 : M) := (AddMonoidHom.mk' _ (lie_add x)).map_zero @[simp] theorem zero_lie : ⁅(0 : L), m⁆ = 0 := (AddMonoidHom.mk' (fun x : L => ⁅x, m⁆) fun x y => add_lie x y m).map_zero @[simp] theorem lie_self : ⁅x, x⁆ = 0 := LieRing.lie_self x instance lieRingSelfModule : LieRingModule L L := { (inferInstance : LieRing L) with } @[simp] theorem lie_skew : -⁅y, x⁆ = ⁅x, y⁆ := by have h : ⁅x + y, x⁆ + ⁅x + y, y⁆ = 0 := by rw [← lie_add]; apply lie_self simpa [neg_eq_iff_add_eq_zero] using h /-- Every Lie algebra is a module over itself. -/ instance lieAlgebraSelfModule : LieModule R L L where smul_lie t x m := by rw [← lie_skew, ← lie_skew x m, LieAlgebra.lie_smul, smul_neg] lie_smul := by apply LieAlgebra.lie_smul @[simp] theorem neg_lie : ⁅-x, m⁆ = -⁅x, m⁆ := by rw [← sub_eq_zero, sub_neg_eq_add, ← add_lie] simp @[simp] theorem lie_neg : ⁅x, -m⁆ = -⁅x, m⁆ := by rw [← sub_eq_zero, sub_neg_eq_add, ← lie_add] simp @[simp] theorem sub_lie : ⁅x - y, m⁆ = ⁅x, m⁆ - ⁅y, m⁆ := by simp [sub_eq_add_neg] @[simp] theorem lie_sub : ⁅x, m - n⁆ = ⁅x, m⁆ - ⁅x, n⁆ := by simp [sub_eq_add_neg] @[simp] theorem nsmul_lie (n : ℕ) : ⁅n • x, m⁆ = n • ⁅x, m⁆ := AddMonoidHom.map_nsmul { toFun := fun x : L => ⁅x, m⁆, map_zero' := zero_lie m, map_add' := fun _ _ => add_lie _ _ _ } _ _ @[simp] theorem lie_nsmul (n : ℕ) : ⁅x, n • m⁆ = n • ⁅x, m⁆ := AddMonoidHom.map_nsmul { toFun := fun m : M => ⁅x, m⁆, map_zero' := lie_zero x, map_add' := fun _ _ => lie_add _ _ _} _ _ @[simp] theorem zsmul_lie (a : ℤ) : ⁅a • x, m⁆ = a • ⁅x, m⁆ := AddMonoidHom.map_zsmul { toFun := fun x : L => ⁅x, m⁆, map_zero' := zero_lie m, map_add' := fun _ _ => add_lie _ _ _ } _ _ @[simp] theorem lie_zsmul (a : ℤ) : ⁅x, a • m⁆ = a • ⁅x, m⁆ := AddMonoidHom.map_zsmul { toFun := fun m : M => ⁅x, m⁆, map_zero' := lie_zero x, map_add' := fun _ _ => lie_add _ _ _ } _ _ @[simp] lemma lie_lie : ⁅⁅x, y⁆, m⁆ = ⁅x, ⁅y, m⁆⁆ - ⁅y, ⁅x, m⁆⁆ := by rw [leibniz_lie, add_sub_cancel_right] theorem lie_jacobi : ⁅x, ⁅y, z⁆⁆ + ⁅y, ⁅z, x⁆⁆ + ⁅z, ⁅x, y⁆⁆ = 0 := by rw [← neg_neg ⁅x, y⁆, lie_neg z, lie_skew y x, ← lie_skew, lie_lie] abel instance LieRing.instLieAlgebra : LieAlgebra ℤ L where lie_smul n x y := lie_zsmul x y n instance LinearMap.instLieRingModule : LieRingModule L (M →ₗ[R] N) where bracket x f := { toFun := fun m => ⁅x, f m⁆ - f ⁅x, m⁆ map_add' := fun m n => by simp only [lie_add, LinearMap.map_add] abel map_smul' := fun t m => by simp only [smul_sub, LinearMap.map_smul, lie_smul, RingHom.id_apply] } add_lie x y f := by ext n simp only [add_lie, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply, LinearMap.map_add] abel lie_add x f g := by ext n simp only [LinearMap.coe_mk, AddHom.coe_mk, lie_add, LinearMap.add_apply] abel leibniz_lie x y f := by ext n simp only [lie_lie, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.map_sub, LinearMap.add_apply, lie_sub] abel @[simp] theorem LieHom.lie_apply (f : M →ₗ[R] N) (x : L) (m : M) : ⁅x, f⁆ m = ⁅x, f m⁆ - f ⁅x, m⁆ := rfl instance LinearMap.instLieModule : LieModule R L (M →ₗ[R] N) where smul_lie t x f := by ext n simp only [smul_sub, smul_lie, LinearMap.smul_apply, LieHom.lie_apply, LinearMap.map_smul] lie_smul t x f := by ext n simp only [smul_sub, LinearMap.smul_apply, LieHom.lie_apply, lie_smul] /-- We could avoid defining this by instead defining a `LieRingModule L R` instance with a zero bracket and relying on `LinearMap.instLieRingModule`. We do not do this because in the case that `L = R` we would have a non-defeq diamond via `Ring.instBracket`. -/ instance Module.Dual.instLieRingModule : LieRingModule L (M →ₗ[R] R) where bracket := fun x f ↦ { toFun := fun m ↦ - f ⁅x, m⁆ map_add' := by simp [-neg_add_rev, neg_add] map_smul' := by simp } add_lie := fun x y m ↦ by ext n; simp [-neg_add_rev, neg_add] lie_add := fun x m n ↦ by ext p; simp [-neg_add_rev, neg_add] leibniz_lie := fun x m n ↦ by ext p; simp @[simp] lemma Module.Dual.lie_apply (f : M →ₗ[R] R) : ⁅x, f⁆ m = - f ⁅x, m⁆ := rfl instance Module.Dual.instLieModule : LieModule R L (M →ₗ[R] R) where smul_lie := fun t x m ↦ by ext n; simp lie_smul := fun t x m ↦ by ext n; simp end BasicProperties /-- A morphism of Lie algebras is a linear map respecting the bracket operations. -/ structure LieHom (R L L' : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] extends L →ₗ[R] L' where /-- A morphism of Lie algebras is compatible with brackets. -/ map_lie' : ∀ {x y : L}, toFun ⁅x, y⁆ = ⁅toFun x, toFun y⁆ @[inherit_doc] notation:25 L " →ₗ⁅" R:25 "⁆ " L':0 => LieHom R L L' namespace LieHom variable {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁} variable [CommRing R] variable [LieRing L₁] [LieAlgebra R L₁] variable [LieRing L₂] [LieAlgebra R L₂] variable [LieRing L₃] [LieAlgebra R L₃] attribute [coe] LieHom.toLinearMap instance : Coe (L₁ →ₗ⁅R⁆ L₂) (L₁ →ₗ[R] L₂) := ⟨LieHom.toLinearMap⟩ instance : FunLike (L₁ →ₗ⁅R⁆ L₂) L₁ L₂ := { coe := fun f => f.toFun, coe_injective' := fun x y h => by cases x; cases y; simp at h; simp [h] } initialize_simps_projections LieHom (toFun → apply) @[simp, norm_cast] theorem coe_toLinearMap (f : L₁ →ₗ⁅R⁆ L₂) : ⇑(f : L₁ →ₗ[R] L₂) = f := rfl @[simp] theorem toFun_eq_coe (f : L₁ →ₗ⁅R⁆ L₂) : f.toFun = ⇑f := rfl @[simp] theorem map_smul (f : L₁ →ₗ⁅R⁆ L₂) (c : R) (x : L₁) : f (c • x) = c • f x := LinearMap.map_smul (f : L₁ →ₗ[R] L₂) c x @[simp] theorem map_add (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x + y) = f x + f y := LinearMap.map_add (f : L₁ →ₗ[R] L₂) x y @[simp] theorem map_sub (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f (x - y) = f x - f y := LinearMap.map_sub (f : L₁ →ₗ[R] L₂) x y @[simp] theorem map_neg (f : L₁ →ₗ⁅R⁆ L₂) (x : L₁) : f (-x) = -f x := LinearMap.map_neg (f : L₁ →ₗ[R] L₂) x @[simp] theorem map_lie (f : L₁ →ₗ⁅R⁆ L₂) (x y : L₁) : f ⁅x, y⁆ = ⁅f x, f y⁆ := LieHom.map_lie' f @[simp] theorem map_zero (f : L₁ →ₗ⁅R⁆ L₂) : f 0 = 0 := (f : L₁ →ₗ[R] L₂).map_zero /-- The identity map is a morphism of Lie algebras. -/ def id : L₁ →ₗ⁅R⁆ L₁ := { (LinearMap.id : L₁ →ₗ[R] L₁) with map_lie' := rfl } @[simp] theorem coe_id : ⇑(id : L₁ →ₗ⁅R⁆ L₁) = _root_.id := rfl theorem id_apply (x : L₁) : (id : L₁ →ₗ⁅R⁆ L₁) x = x := rfl /-- The constant 0 map is a Lie algebra morphism. -/ instance : Zero (L₁ →ₗ⁅R⁆ L₂) := ⟨{ (0 : L₁ →ₗ[R] L₂) with map_lie' := by simp }⟩ @[norm_cast, simp] theorem coe_zero : ((0 : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = 0 := rfl theorem zero_apply (x : L₁) : (0 : L₁ →ₗ⁅R⁆ L₂) x = 0 := rfl /-- The identity map is a Lie algebra morphism. -/ instance : One (L₁ →ₗ⁅R⁆ L₁) := ⟨id⟩ @[simp] theorem coe_one : ((1 : L₁ →ₗ⁅R⁆ L₁) : L₁ → L₁) = _root_.id := rfl theorem one_apply (x : L₁) : (1 : L₁ →ₗ⁅R⁆ L₁) x = x := rfl instance : Inhabited (L₁ →ₗ⁅R⁆ L₂) := ⟨0⟩ theorem coe_injective : @Function.Injective (L₁ →ₗ⁅R⁆ L₂) (L₁ → L₂) (↑) := by rintro ⟨⟨⟨f, _⟩, _⟩, _⟩ ⟨⟨⟨g, _⟩, _⟩, _⟩ h congr @[ext] theorem ext {f g : L₁ →ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g := coe_injective <| funext h theorem congr_fun {f g : L₁ →ₗ⁅R⁆ L₂} (h : f = g) (x : L₁) : f x = g x := h ▸ rfl @[simp] theorem mk_coe (f : L₁ →ₗ⁅R⁆ L₂) (h₁ h₂ h₃) : (⟨⟨⟨f, h₁⟩, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) = f := by ext rfl @[simp] theorem coe_mk (f : L₁ → L₂) (h₁ h₂ h₃) : ((⟨⟨⟨f, h₁⟩, h₂⟩, h₃⟩ : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) = f := rfl /-- The composition of morphisms is a morphism. -/ def comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) : L₁ →ₗ⁅R⁆ L₃ := { LinearMap.comp f.toLinearMap g.toLinearMap with map_lie' := by intros x y change f (g ⁅x, y⁆) = ⁅f (g x), f (g y)⁆ rw [map_lie, map_lie] } theorem comp_apply (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) (x : L₁) : f.comp g x = f (g x) := rfl @[norm_cast, simp] theorem coe_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) : (f.comp g : L₁ → L₃) = f ∘ g := rfl @[norm_cast, simp] theorem coe_linearMap_comp (f : L₂ →ₗ⁅R⁆ L₃) (g : L₁ →ₗ⁅R⁆ L₂) : (f.comp g : L₁ →ₗ[R] L₃) = (f : L₂ →ₗ[R] L₃).comp (g : L₁ →ₗ[R] L₂) := rfl @[simp] theorem comp_id (f : L₁ →ₗ⁅R⁆ L₂) : f.comp (id : L₁ →ₗ⁅R⁆ L₁) = f := by ext rfl @[simp] theorem id_comp (f : L₁ →ₗ⁅R⁆ L₂) : (id : L₂ →ₗ⁅R⁆ L₂).comp f = f := by ext rfl /-- The inverse of a bijective morphism is a morphism. -/ def inverse (f : L₁ →ₗ⁅R⁆ L₂) (g : L₂ → L₁) (h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) : L₂ →ₗ⁅R⁆ L₁ := { LinearMap.inverse f.toLinearMap g h₁ h₂ with map_lie' := by intros x y calc g ⁅x, y⁆ = g ⁅f (g x), f (g y)⁆ := by conv_lhs => rw [← h₂ x, ← h₂ y] _ = g (f ⁅g x, g y⁆) := by rw [map_lie] _ = ⁅g x, g y⁆ := h₁ _ } end LieHom section ModulePullBack variable {R : Type u} {L₁ : Type v} {L₂ : Type w} (M : Type w₁) variable [CommRing R] [LieRing L₁] [LieAlgebra R L₁] [LieRing L₂] [LieAlgebra R L₂] variable [AddCommGroup M] [LieRingModule L₂ M] variable (f : L₁ →ₗ⁅R⁆ L₂) /-- A Lie ring module may be pulled back along a morphism of Lie algebras. See note [reducible non-instances]. -/ def LieRingModule.compLieHom : LieRingModule L₁ M where bracket x m := ⁅f x, m⁆ lie_add x := lie_add (f x) add_lie x y m := by simp only [LieHom.map_add, add_lie] leibniz_lie x y m := by simp only [lie_lie, sub_add_cancel, LieHom.map_lie] theorem LieRingModule.compLieHom_apply (x : L₁) (m : M) : haveI := LieRingModule.compLieHom M f ⁅x, m⁆ = ⁅f x, m⁆ := rfl /-- A Lie module may be pulled back along a morphism of Lie algebras. -/ theorem LieModule.compLieHom [Module R M] [LieModule R L₂ M] : @LieModule R L₁ M _ _ _ _ _ (LieRingModule.compLieHom M f) := { __ := LieRingModule.compLieHom M f smul_lie := fun t x m => by simp only [LieRingModule.compLieHom_apply, smul_lie, LieHom.map_smul] lie_smul := fun t x m => by simp only [LieRingModule.compLieHom_apply, lie_smul] } end ModulePullBack /-- An equivalence of Lie algebras is a morphism which is also a linear equivalence. We could instead define an equivalence to be a morphism which is also a (plain) equivalence. However it is more convenient to define via linear equivalence to get `.toLinearEquiv` for free. -/ structure LieEquiv (R : Type u) (L : Type v) (L' : Type w) [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] extends L →ₗ⁅R⁆ L' where /-- The inverse function of an equivalence of Lie algebras -/ invFun : L' → L /-- The inverse function of an equivalence of Lie algebras is a left inverse of the underlying function. -/ left_inv : Function.LeftInverse invFun toLieHom.toFun /-- The inverse function of an equivalence of Lie algebras is a right inverse of the underlying function. -/ right_inv : Function.RightInverse invFun toLieHom.toFun @[inherit_doc] notation:50 L " ≃ₗ⁅" R "⁆ " L' => LieEquiv R L L' namespace LieEquiv variable {R : Type u} {L₁ : Type v} {L₂ : Type w} {L₃ : Type w₁} variable [CommRing R] [LieRing L₁] [LieRing L₂] [LieRing L₃] variable [LieAlgebra R L₁] [LieAlgebra R L₂] [LieAlgebra R L₃] /-- Consider an equivalence of Lie algebras as a linear equivalence. -/ def toLinearEquiv (f : L₁ ≃ₗ⁅R⁆ L₂) : L₁ ≃ₗ[R] L₂ := { f.toLieHom, f with } instance hasCoeToLieHom : Coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ →ₗ⁅R⁆ L₂) := ⟨toLieHom⟩ instance hasCoeToLinearEquiv : Coe (L₁ ≃ₗ⁅R⁆ L₂) (L₁ ≃ₗ[R] L₂) := ⟨toLinearEquiv⟩ instance : EquivLike (L₁ ≃ₗ⁅R⁆ L₂) L₁ L₂ := { coe := fun f => f.toFun, inv := fun f => f.invFun, left_inv := fun f => f.left_inv, right_inv := fun f => f.right_inv, coe_injective' := fun f g h₁ h₂ => by cases f; cases g; simp at h₁ h₂; simp [*] } theorem coe_to_lieHom (e : L₁ ≃ₗ⁅R⁆ L₂) : ⇑(e : L₁ →ₗ⁅R⁆ L₂) = e := rfl @[simp] theorem coe_to_linearEquiv (e : L₁ ≃ₗ⁅R⁆ L₂) : ⇑(e : L₁ ≃ₗ[R] L₂) = e := rfl @[simp] theorem to_linearEquiv_mk (f : L₁ →ₗ⁅R⁆ L₂) (g h₁ h₂) : (mk f g h₁ h₂ : L₁ ≃ₗ[R] L₂) = { f with invFun := g left_inv := h₁ right_inv := h₂ } := rfl theorem coe_linearEquiv_injective : Injective ((↑) : (L₁ ≃ₗ⁅R⁆ L₂) → L₁ ≃ₗ[R] L₂) := by rintro ⟨⟨⟨⟨f, -⟩, -⟩, -⟩, f_inv⟩ ⟨⟨⟨⟨g, -⟩, -⟩, -⟩, g_inv⟩ intro h simp only [to_linearEquiv_mk, LinearEquiv.mk.injEq, LinearMap.mk.injEq, AddHom.mk.injEq] at h congr exacts [h.1, h.2] theorem coe_injective : @Injective (L₁ ≃ₗ⁅R⁆ L₂) (L₁ → L₂) (↑) := LinearEquiv.coe_injective.comp coe_linearEquiv_injective @[ext] theorem ext {f g : L₁ ≃ₗ⁅R⁆ L₂} (h : ∀ x, f x = g x) : f = g := coe_injective <| funext h instance : One (L₁ ≃ₗ⁅R⁆ L₁) := ⟨{ (1 : L₁ ≃ₗ[R] L₁) with map_lie' := rfl }⟩ @[simp] theorem one_apply (x : L₁) : (1 : L₁ ≃ₗ⁅R⁆ L₁) x = x := rfl instance : Inhabited (L₁ ≃ₗ⁅R⁆ L₁) := ⟨1⟩ lemma map_lie (e : L₁ ≃ₗ⁅R⁆ L₂) (x y : L₁) : e ⁅x, y⁆ = ⁅e x, e y⁆ := LieHom.map_lie e.toLieHom x y /-- Lie algebra equivalences are reflexive. -/ def refl : L₁ ≃ₗ⁅R⁆ L₁ := 1 @[simp] theorem refl_apply (x : L₁) : (refl : L₁ ≃ₗ⁅R⁆ L₁) x = x := rfl /-- Lie algebra equivalences are symmetric. -/ @[symm] def symm (e : L₁ ≃ₗ⁅R⁆ L₂) : L₂ ≃ₗ⁅R⁆ L₁ := { LieHom.inverse e.toLieHom e.invFun e.left_inv e.right_inv, e.toLinearEquiv.symm with } @[simp] theorem symm_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.symm = e := by ext rfl theorem symm_bijective : Function.Bijective (LieEquiv.symm : (L₁ ≃ₗ⁅R⁆ L₂) → L₂ ≃ₗ⁅R⁆ L₁) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ @[simp] theorem apply_symm_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e (e.symm x) = x := e.toLinearEquiv.apply_symm_apply @[simp] theorem symm_apply_apply (e : L₁ ≃ₗ⁅R⁆ L₂) : ∀ x, e.symm (e x) = x := e.toLinearEquiv.symm_apply_apply @[simp] theorem refl_symm : (refl : L₁ ≃ₗ⁅R⁆ L₁).symm = refl := rfl /-- Lie algebra equivalences are transitive. -/ @[trans] def trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) : L₁ ≃ₗ⁅R⁆ L₃ := { LieHom.comp e₂.toLieHom e₁.toLieHom, LinearEquiv.trans e₁.toLinearEquiv e₂.toLinearEquiv with } @[simp] theorem self_trans_symm (e : L₁ ≃ₗ⁅R⁆ L₂) : e.trans e.symm = refl := ext e.symm_apply_apply @[simp] theorem symm_trans_self (e : L₁ ≃ₗ⁅R⁆ L₂) : e.symm.trans e = refl := e.symm.self_trans_symm @[simp] theorem trans_apply (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) (x : L₁) : (e₁.trans e₂) x = e₂ (e₁ x) := rfl @[simp] theorem symm_trans (e₁ : L₁ ≃ₗ⁅R⁆ L₂) (e₂ : L₂ ≃ₗ⁅R⁆ L₃) : (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl protected theorem bijective (e : L₁ ≃ₗ⁅R⁆ L₂) : Function.Bijective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) := e.toLinearEquiv.bijective protected theorem injective (e : L₁ ≃ₗ⁅R⁆ L₂) : Function.Injective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) := e.toLinearEquiv.injective protected theorem surjective (e : L₁ ≃ₗ⁅R⁆ L₂) : Function.Surjective ((e : L₁ →ₗ⁅R⁆ L₂) : L₁ → L₂) := e.toLinearEquiv.surjective /-- A bijective morphism of Lie algebras yields an equivalence of Lie algebras. -/ @[simps!] noncomputable def ofBijective (f : L₁ →ₗ⁅R⁆ L₂) (h : Function.Bijective f) : L₁ ≃ₗ⁅R⁆ L₂ := { LinearEquiv.ofBijective (f : L₁ →ₗ[R] L₂) h with toFun := f map_lie' := by intros x y; exact f.map_lie x y } end LieEquiv section LieModuleMorphisms variable (R : Type u) (L : Type v) (M : Type w) (N : Type w₁) (P : Type w₂) variable [CommRing R] [LieRing L] variable [AddCommGroup M] [AddCommGroup N] [AddCommGroup P] variable [Module R M] [Module R N] [Module R P] variable [LieRingModule L M] [LieRingModule L N] [LieRingModule L P] /-- A morphism of Lie algebra modules is a linear map which commutes with the action of the Lie algebra. -/ structure LieModuleHom extends M →ₗ[R] N where /-- A module of Lie algebra modules is compatible with the action of the Lie algebra on the modules. -/ map_lie' : ∀ {x : L} {m : M}, toFun ⁅x, m⁆ = ⁅x, toFun m⁆ @[inherit_doc] notation:25 M " →ₗ⁅" R "," L:25 "⁆ " N:0 => LieModuleHom R L M N namespace LieModuleHom variable {R L M N P} attribute [coe] LieModuleHom.toLinearMap instance : CoeOut (M →ₗ⁅R,L⁆ N) (M →ₗ[R] N) := ⟨LieModuleHom.toLinearMap⟩ instance : FunLike (M →ₗ⁅R, L⁆ N) M N := { coe := fun f => f.toFun, coe_injective' := fun x y h => by cases x; cases y; simp at h; simp [h] } initialize_simps_projections LieModuleHom (toFun → apply) @[simp, norm_cast] theorem coe_toLinearMap (f : M →ₗ⁅R,L⁆ N) : ((f : M →ₗ[R] N) : M → N) = f := rfl @[simp] theorem map_smul (f : M →ₗ⁅R,L⁆ N) (c : R) (x : M) : f (c • x) = c • f x := LinearMap.map_smul (f : M →ₗ[R] N) c x @[simp] theorem map_add (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x + y) = f x + f y := LinearMap.map_add (f : M →ₗ[R] N) x y @[simp] theorem map_sub (f : M →ₗ⁅R,L⁆ N) (x y : M) : f (x - y) = f x - f y := LinearMap.map_sub (f : M →ₗ[R] N) x y @[simp] theorem map_neg (f : M →ₗ⁅R,L⁆ N) (x : M) : f (-x) = -f x := LinearMap.map_neg (f : M →ₗ[R] N) x @[simp] theorem map_lie (f : M →ₗ⁅R,L⁆ N) (x : L) (m : M) : f ⁅x, m⁆ = ⁅x, f m⁆ := LieModuleHom.map_lie' f variable [LieAlgebra R L] [LieModule R L N] [LieModule R L P] in theorem map_lie₂ (f : M →ₗ⁅R,L⁆ N →ₗ[R] P) (x : L) (m : M) (n : N) : ⁅x, f m n⁆ = f ⁅x, m⁆ n + f m ⁅x, n⁆ := by simp only [sub_add_cancel, map_lie, LieHom.lie_apply] @[simp] theorem map_zero (f : M →ₗ⁅R,L⁆ N) : f 0 = 0 := LinearMap.map_zero (f : M →ₗ[R] N) /-- The identity map is a morphism of Lie modules. -/ def id : M →ₗ⁅R,L⁆ M := { (LinearMap.id : M →ₗ[R] M) with map_lie' := rfl } @[simp] theorem coe_id : ((id : M →ₗ⁅R,L⁆ M) : M → M) = _root_.id := rfl theorem id_apply (x : M) : (id : M →ₗ⁅R,L⁆ M) x = x := rfl /-- The constant 0 map is a Lie module morphism. -/ instance : Zero (M →ₗ⁅R,L⁆ N) := ⟨{ (0 : M →ₗ[R] N) with map_lie' := by simp }⟩ @[norm_cast, simp] theorem coe_zero : ⇑(0 : M →ₗ⁅R,L⁆ N) = 0 := rfl theorem zero_apply (m : M) : (0 : M →ₗ⁅R,L⁆ N) m = 0 := rfl /-- The identity map is a Lie module morphism. -/ instance : One (M →ₗ⁅R,L⁆ M) := ⟨id⟩ instance : Inhabited (M →ₗ⁅R,L⁆ N) := ⟨0⟩ theorem coe_injective : @Function.Injective (M →ₗ⁅R,L⁆ N) (M → N) (↑) := by rintro ⟨⟨⟨f, _⟩⟩⟩ ⟨⟨⟨g, _⟩⟩⟩ h congr @[ext] theorem ext {f g : M →ₗ⁅R,L⁆ N} (h : ∀ m, f m = g m) : f = g := coe_injective <| funext h theorem congr_fun {f g : M →ₗ⁅R,L⁆ N} (h : f = g) (x : M) : f x = g x := h ▸ rfl @[simp] theorem mk_coe (f : M →ₗ⁅R,L⁆ N) (h) : (⟨f, h⟩ : M →ₗ⁅R,L⁆ N) = f := by rfl @[simp] theorem coe_mk (f : M →ₗ[R] N) (h) : ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M → N) = f := by rfl @[norm_cast] theorem coe_linear_mk (f : M →ₗ[R] N) (h) : ((⟨f, h⟩ : M →ₗ⁅R,L⁆ N) : M →ₗ[R] N) = f := by rfl /-- The composition of Lie module morphisms is a morphism. -/ def comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) : M →ₗ⁅R,L⁆ P := { LinearMap.comp f.toLinearMap g.toLinearMap with map_lie' := by intros x m change f (g ⁅x, m⁆) = ⁅x, f (g m)⁆ rw [map_lie, map_lie] } theorem comp_apply (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) (m : M) : f.comp g m = f (g m) := rfl @[norm_cast, simp] theorem coe_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) : ⇑(f.comp g) = f ∘ g := rfl @[norm_cast, simp] theorem coe_linearMap_comp (f : N →ₗ⁅R,L⁆ P) (g : M →ₗ⁅R,L⁆ N) : (f.comp g : M →ₗ[R] P) = (f : N →ₗ[R] P).comp (g : M →ₗ[R] N) := rfl /-- The inverse of a bijective morphism of Lie modules is a morphism of Lie modules. -/ def inverse (f : M →ₗ⁅R,L⁆ N) (g : N → M) (h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) : N →ₗ⁅R,L⁆ M := { LinearMap.inverse f.toLinearMap g h₁ h₂ with map_lie' := by intros x n calc g ⁅x, n⁆ = g ⁅x, f (g n)⁆ := by rw [h₂] _ = g (f ⁅x, g n⁆) := by rw [map_lie] _ = ⁅x, g n⁆ := h₁ _ } instance : Add (M →ₗ⁅R,L⁆ N) where add f g := { (f : M →ₗ[R] N) + (g : M →ₗ[R] N) with map_lie' := by simp } instance : Sub (M →ₗ⁅R,L⁆ N) where sub f g := { (f : M →ₗ[R] N) - (g : M →ₗ[R] N) with map_lie' := by simp } instance : Neg (M →ₗ⁅R,L⁆ N) where neg f := { -(f : M →ₗ[R] N) with map_lie' := by simp } @[norm_cast, simp] theorem coe_add (f g : M →ₗ⁅R,L⁆ N) : ⇑(f + g) = f + g := rfl theorem add_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f + g) m = f m + g m := rfl @[norm_cast, simp] theorem coe_sub (f g : M →ₗ⁅R,L⁆ N) : ⇑(f - g) = f - g := rfl theorem sub_apply (f g : M →ₗ⁅R,L⁆ N) (m : M) : (f - g) m = f m - g m := rfl @[norm_cast, simp] theorem coe_neg (f : M →ₗ⁅R,L⁆ N) : ⇑(-f) = -f := rfl theorem neg_apply (f : M →ₗ⁅R,L⁆ N) (m : M) : (-f) m = -f m := rfl instance hasNSMul : SMul ℕ (M →ₗ⁅R,L⁆ N) where smul n f := { n • (f : M →ₗ[R] N) with map_lie' := by simp } @[norm_cast, simp] theorem coe_nsmul (n : ℕ) (f : M →ₗ⁅R,L⁆ N) : ⇑(n • f) = n • (⇑f) := rfl theorem nsmul_apply (n : ℕ) (f : M →ₗ⁅R,L⁆ N) (m : M) : (n • f) m = n • f m := rfl instance hasZSMul : SMul ℤ (M →ₗ⁅R,L⁆ N) where smul z f := { z • (f : M →ₗ[R] N) with map_lie' := by simp } @[norm_cast, simp] theorem coe_zsmul (z : ℤ) (f : M →ₗ⁅R,L⁆ N) : ⇑(z • f) = z • (⇑f) := rfl theorem zsmul_apply (z : ℤ) (f : M →ₗ⁅R,L⁆ N) (m : M) : (z • f) m = z • f m := rfl instance : AddCommGroup (M →ₗ⁅R,L⁆ N) := coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) (fun _ _ => coe_zsmul _ _) variable [LieAlgebra R L] [LieModule R L N] instance : SMul R (M →ₗ⁅R,L⁆ N) where smul t f := { t • (f : M →ₗ[R] N) with map_lie' := by simp } @[norm_cast, simp] theorem coe_smul (t : R) (f : M →ₗ⁅R,L⁆ N) : ⇑(t • f) = t • (⇑f) := rfl theorem smul_apply (t : R) (f : M →ₗ⁅R,L⁆ N) (m : M) : (t • f) m = t • f m := rfl instance : Module R (M →ₗ⁅R,L⁆ N) := Function.Injective.module R { toFun := fun f => f.toLinearMap.toFun, map_zero' := rfl, map_add' := coe_add } coe_injective coe_smul end LieModuleHom /-- An equivalence of Lie algebra modules is a linear equivalence which is also a morphism of Lie algebra modules. -/ structure LieModuleEquiv extends M →ₗ⁅R,L⁆ N where /-- The inverse function of an equivalence of Lie modules -/ invFun : N → M /-- The inverse function of an equivalence of Lie modules is a left inverse of the underlying function. -/ left_inv : Function.LeftInverse invFun toFun /-- The inverse function of an equivalence of Lie modules is a right inverse of the underlying function. -/ right_inv : Function.RightInverse invFun toFun attribute [nolint docBlame] LieModuleEquiv.toLieModuleHom @[inherit_doc] notation:25 M " ≃ₗ⁅" R "," L:25 "⁆ " N:0 => LieModuleEquiv R L M N namespace LieModuleEquiv variable {R L M N P} /-- View an equivalence of Lie modules as a linear equivalence. -/ def toLinearEquiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ₗ[R] N := { e with } /-- View an equivalence of Lie modules as a type level equivalence. -/ def toEquiv (e : M ≃ₗ⁅R,L⁆ N) : M ≃ N := { e with } instance hasCoeToEquiv : CoeOut (M ≃ₗ⁅R,L⁆ N) (M ≃ N) := ⟨toEquiv⟩ instance hasCoeToLieModuleHom : Coe (M ≃ₗ⁅R,L⁆ N) (M →ₗ⁅R,L⁆ N) := ⟨toLieModuleHom⟩ instance hasCoeToLinearEquiv : CoeOut (M ≃ₗ⁅R,L⁆ N) (M ≃ₗ[R] N) := ⟨toLinearEquiv⟩ instance : EquivLike (M ≃ₗ⁅R,L⁆ N) M N := { coe := fun f => f.toFun, inv := fun f => f.invFun, left_inv := fun f => f.left_inv, right_inv := fun f => f.right_inv, coe_injective' := fun f g h₁ h₂ => by cases f; cases g; simp at h₁ h₂; simp [*] } @[simp] lemma coe_coe (e : M ≃ₗ⁅R,L⁆ N) : ⇑(e : M →ₗ⁅R,L⁆ N) = e := rfl theorem injective (e : M ≃ₗ⁅R,L⁆ N) : Function.Injective e := e.toEquiv.injective theorem surjective (e : M ≃ₗ⁅R,L⁆ N) : Function.Surjective e := e.toEquiv.surjective @[simp] theorem toEquiv_mk (f : M →ₗ⁅R,L⁆ N) (g : N → M) (h₁ h₂) : toEquiv (mk f g h₁ h₂ : M ≃ₗ⁅R,L⁆ N) = Equiv.mk f g h₁ h₂ := rfl @[simp] theorem coe_mk (f : M →ₗ⁅R,L⁆ N) (invFun h₁ h₂) : ((⟨f, invFun, h₁, h₂⟩ : M ≃ₗ⁅R,L⁆ N) : M → N) = f := rfl theorem coe_to_lieModuleHom (e : M ≃ₗ⁅R,L⁆ N) : ⇑(e : M →ₗ⁅R,L⁆ N) = e := rfl @[simp] theorem coe_to_linearEquiv (e : M ≃ₗ⁅R,L⁆ N) : ((e : M ≃ₗ[R] N) : M → N) = e := rfl theorem toEquiv_injective : Function.Injective (toEquiv : (M ≃ₗ⁅R,L⁆ N) → M ≃ N) := by rintro ⟨⟨⟨⟨f, -⟩, -⟩, -⟩, f_inv⟩ ⟨⟨⟨⟨g, -⟩, -⟩, -⟩, g_inv⟩ intro h simp only [toEquiv_mk, LieModuleHom.coe_mk, LinearMap.coe_mk, AddHom.coe_mk, Equiv.mk.injEq] at h congr exacts [h.1, h.2] @[ext] theorem ext (e₁ e₂ : M ≃ₗ⁅R,L⁆ N) (h : ∀ m, e₁ m = e₂ m) : e₁ = e₂ := toEquiv_injective (Equiv.ext h) instance : One (M ≃ₗ⁅R,L⁆ M) := ⟨{ (1 : M ≃ₗ[R] M) with map_lie' := rfl }⟩ @[simp] theorem one_apply (m : M) : (1 : M ≃ₗ⁅R,L⁆ M) m = m := rfl instance : Inhabited (M ≃ₗ⁅R,L⁆ M) := ⟨1⟩ /-- Lie module equivalences are reflexive. -/ @[refl] def refl : M ≃ₗ⁅R,L⁆ M := 1 @[simp] theorem refl_apply (m : M) : (refl : M ≃ₗ⁅R,L⁆ M) m = m := rfl /-- Lie module equivalences are symmetric. -/ @[symm] def symm (e : M ≃ₗ⁅R,L⁆ N) : N ≃ₗ⁅R,L⁆ M := { LieModuleHom.inverse e.toLieModuleHom e.invFun e.left_inv e.right_inv, (e : M ≃ₗ[R] N).symm with } @[simp] theorem apply_symm_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e (e.symm x) = x := e.toLinearEquiv.apply_symm_apply @[simp] theorem symm_apply_apply (e : M ≃ₗ⁅R,L⁆ N) : ∀ x, e.symm (e x) = x := e.toLinearEquiv.symm_apply_apply theorem apply_eq_iff_eq_symm_apply {m : M} {n : N} (e : M ≃ₗ⁅R,L⁆ N) : e m = n ↔ m = e.symm n := (e : M ≃ N).apply_eq_iff_eq_symm_apply @[simp] theorem symm_symm (e : M ≃ₗ⁅R,L⁆ N) : e.symm.symm = e := by rfl theorem symm_bijective : Function.Bijective (LieModuleEquiv.symm : (M ≃ₗ⁅R,L⁆ N) → N ≃ₗ⁅R,L⁆ M) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ /-- Lie module equivalences are transitive. -/ @[trans] def trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) : M ≃ₗ⁅R,L⁆ P := { LieModuleHom.comp e₂.toLieModuleHom e₁.toLieModuleHom, LinearEquiv.trans e₁.toLinearEquiv e₂.toLinearEquiv with } @[simp] theorem trans_apply (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) (m : M) : (e₁.trans e₂) m = e₂ (e₁ m) := rfl @[simp] theorem symm_trans (e₁ : M ≃ₗ⁅R,L⁆ N) (e₂ : N ≃ₗ⁅R,L⁆ P) : (e₁.trans e₂).symm = e₂.symm.trans e₁.symm := rfl @[simp] theorem self_trans_symm (e : M ≃ₗ⁅R,L⁆ N) : e.trans e.symm = refl := ext _ _ e.symm_apply_apply @[simp] theorem symm_trans_self (e : M ≃ₗ⁅R,L⁆ N) : e.symm.trans e = refl := ext _ _ e.apply_symm_apply end LieModuleEquiv end LieModuleMorphisms
Algebra\Lie\CartanExists.lean
/- Copyright (c) 2024 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Lie.CartanSubalgebra import Mathlib.Algebra.Lie.Rank /-! # Existence of Cartan subalgebras In this file we prove existence of Cartan subalgebras in finite-dimensional Lie algebras, following [barnes1967]. ## Main results * `exists_isCartanSubalgebra_of_finrank_le_card`: A Lie algebra `L` over a field `K` has a Cartan subalgebra, provided that the dimension of `L` over `K` is less than or equal to the cardinality of `K`. * `exists_isCartanSubalgebra`: A finite-dimensional Lie algebra `L` over an infinite field `K` has a Cartan subalgebra. ## References * [barnes1967]: "On Cartan subalgebras of Lie algebras" by D.W. Barnes. -/ namespace LieAlgebra section CommRing variable {K R L M : Type*} variable [Field K] [CommRing R] [Nontrivial R] variable [LieRing L] [LieAlgebra K L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [Module.Finite K L] variable [Module.Finite R L] [Module.Free R L] variable [Module.Finite R M] [Module.Free R M] open FiniteDimensional LieSubalgebra Module.Free Polynomial variable (K) namespace engel_isBot_of_isMin /-! ## Implementation details for the proof of `LieAlgebra.engel_isBot_of_isMin` In this section we provide some auxiliary definitions and lemmas that are used in the proof of `LieAlgebra.engel_isBot_of_isMin`, which is the following statement: Let `L` be a Lie algebra of dimension `n` over a field `K` with at least `n` elements. Given a Lie subalgebra `U` of `L`, and an element `x ∈ U` such that `U ≤ engel K x`. Suppose that `engel K x` is minimal amongst the Engel subalgebras `engel K y` for `y ∈ U`. Then `engel K x ≤ engel K y` for all `y ∈ U`. We follow the proof strategy of Lemma 2 in [barnes1967]. -/ variable (R M) variable (x y : L) open LieModule LinearMap local notation "φ" => LieModule.toEnd R L M /-- Let `x` and `y` be elements of a Lie `R`-algebra `L`, and `M` a Lie module over `M`. Then the characteristic polynomials of the family of endomorphisms `⁅r • y + x, _⁆` of `M` have coefficients that are polynomial in `r : R`. In other words, we obtain a polynomial over `R[X]` that specializes to the characteristic polynomial of `⁅r • y + x, _⁆` under the map `X ↦ r`. This polynomial is captured in `lieCharpoly R M x y`. -/ private noncomputable def lieCharpoly : Polynomial R[X] := letI bL := chooseBasis R L (polyCharpoly (LieHom.toLinearMap φ) bL).map <| RingHomClass.toRingHom <| MvPolynomial.aeval fun i ↦ C (bL.repr y i) * X + C (bL.repr x i) lemma lieCharpoly_monic : (lieCharpoly R M x y).Monic := (polyCharpoly_monic _ _).map _ lemma lieCharpoly_natDegree : (lieCharpoly R M x y).natDegree = finrank R M := by rw [lieCharpoly, (polyCharpoly_monic _ _).natDegree_map, polyCharpoly_natDegree] variable {R} in lemma lieCharpoly_map_eval (r : R) : (lieCharpoly R M x y).map (evalRingHom r) = (φ (r • y + x)).charpoly := by rw [lieCharpoly, map_map] set b := chooseBasis R L have aux : (fun i ↦ (b.repr y) i * r + (b.repr x) i) = b.repr (r • y + x) := by ext i; simp [mul_comm r] simp_rw [← coe_aeval_eq_evalRingHom, ← AlgHom.comp_toRingHom, MvPolynomial.comp_aeval, map_add, map_mul, aeval_C, Algebra.id.map_eq_id, RingHom.id_apply, aeval_X, aux, MvPolynomial.coe_aeval_eq_eval, polyCharpoly_map_eq_charpoly, LieHom.coe_toLinearMap] lemma lieCharpoly_coeff_natDegree (i j : ℕ) (hij : i + j = finrank R M) : ((lieCharpoly R M x y).coeff i).natDegree ≤ j := by classical rw [← mul_one j, lieCharpoly, coeff_map] apply MvPolynomial.aeval_natDegree_le · apply (polyCharpoly_coeff_isHomogeneous φ (chooseBasis R L) _ _ hij).totalDegree_le intro k apply Polynomial.natDegree_add_le_of_degree_le · apply (Polynomial.natDegree_C_mul_le _ _).trans simp only [natDegree_X, le_rfl] · simp only [natDegree_C, zero_le] end engel_isBot_of_isMin end CommRing section Field variable {K L : Type*} [Field K] [LieRing L] [LieAlgebra K L] [Module.Finite K L] open FiniteDimensional LieSubalgebra LieSubmodule Polynomial Cardinal LieModule engel_isBot_of_isMin #adaptation_note /-- otherwise there is a spurious warning on `contrapose!` below. -/ set_option linter.unusedVariables false in /-- Let `L` be a Lie algebra of dimension `n` over a field `K` with at least `n` elements. Given a Lie subalgebra `U` of `L`, and an element `x ∈ U` such that `U ≤ engel K x`. Suppose that `engel K x` is minimal amongst the Engel subalgebras `engel K y` for `y ∈ U`. Then `engel K x ≤ engel K y` for all `y ∈ U`. Lemma 2 in [barnes1967]. -/ lemma engel_isBot_of_isMin (hLK : finrank K L ≤ #K) (U : LieSubalgebra K L) (E : {engel K x | x ∈ U}) (hUle : U ≤ E) (hmin : IsMin E) : IsBot E := by rcases E with ⟨_, x, hxU, rfl⟩ rintro ⟨_, y, hyU, rfl⟩ -- It will be useful to repackage the Engel subalgebras set Ex : {engel K x | x ∈ U} := ⟨engel K x, x, hxU, rfl⟩ set Ey : {engel K y | y ∈ U} := ⟨engel K y, y, hyU, rfl⟩ replace hUle : U ≤ Ex := hUle replace hmin : ∀ E, E ≤ Ex → Ex ≤ E := @hmin -- We also repackage the Engel subalgebra `engel K x` -- as Lie submodule `E` of `L` over the Lie algebra `U`. let E : LieSubmodule K U L := { engel K x with lie_mem := by rintro ⟨u, hu⟩ y hy; exact (engel K x).lie_mem (hUle hu) hy } -- We may and do assume that `x ≠ 0`, since otherwise the statement is trivial. obtain rfl|hx₀ := eq_or_ne x 0 · simpa [Ex, Ey] using hmin Ey -- We denote by `Q` the quotient `L / E`, and by `r` the dimension of `E`. let Q := L ⧸ E let r := finrank K E -- If `r = finrank K L`, then `E = L`, and the statement is trivial. obtain hr|hr : r = finrank K L ∨ r < finrank K L := (Submodule.finrank_le _).eq_or_lt · suffices engel K y ≤ engel K x from hmin Ey this suffices engel K x = ⊤ by simp_rw [this, le_top] apply LieSubalgebra.to_submodule_injective apply Submodule.eq_top_of_finrank_eq hr -- So from now on, we assume that `r < finrank K L`. -- We denote by `x'` and `y'` the elements `x` and `y` viewed as terms of `U`. set x' : U := ⟨x, hxU⟩ set y' : U := ⟨y, hyU⟩ -- Let `u : U` denote `y - x`. let u : U := y' - x' -- We denote by `χ r` the characteristic polynomial of `⁅r • u + x, _⁆` -- viewed as endomorphism of `E`. Note that `χ` is polynomial in its argument `r`. -- Similarly: `ψ r` is the characteristic polynomial of `⁅r • u + x, _⁆` -- viewed as endomorphism of `Q`. Note that `ψ` is polynomial in its argument `r`. let χ : Polynomial (K[X]) := lieCharpoly K E x' u let ψ : Polynomial (K[X]) := lieCharpoly K Q x' u -- It suffices to show that `χ` is the monomial `X ^ r`. suffices χ = X ^ r by -- Indeed, by evaluating the coefficients at `1` apply_fun (fun p ↦ p.map (evalRingHom 1)) at this -- we find that the characteristic polynomial `χ 1` of `⁅y, _⁆` is equal to `X ^ r` simp_rw [Polynomial.map_pow, map_X, χ, lieCharpoly_map_eval, one_smul, u, sub_add_cancel, -- and therefore the endomorphism `⁅y, _⁆` acts nilpotently on `E`. r, LinearMap.charpoly_eq_X_pow_iff, Subtype.ext_iff, coe_toEnd_pow _ _ _ E, ZeroMemClass.coe_zero] at this -- We ultimately want to show `engel K x ≤ engel K y` intro z hz -- which holds by definition of Engel subalgebra and the nilpotency that we just established. rw [mem_engel_iff] exact this ⟨z, hz⟩ -- To show that `χ = X ^ r`, it suffices to show that all coefficients in degrees `< r` are `0`. suffices ∀ i < r, χ.coeff i = 0 by simp_rw [r, ← lieCharpoly_natDegree K E x' u] at this ⊢ rw [(lieCharpoly_monic K E x' u).eq_X_pow_iff_natDegree_le_natTrailingDegree] exact le_natTrailingDegree (lieCharpoly_monic K E x' u).ne_zero this -- Let us consider the `i`-th coefficient of `χ`, for `i < r`. intro i hi -- We separately consider the case `i = 0`. obtain rfl|hi0 := eq_or_ne i 0 · -- `The polynomial `coeff χ 0` is zero if it evaluates to zero on all elements of `K`, -- provided that its degree is stictly less than `#K`. apply eq_zero_of_forall_eval_zero_of_natDegree_lt_card _ _ ?deg case deg => -- We need to show `(natDegree (coeff χ 0)) < #K` and know that `finrank K L ≤ #K` apply lt_of_lt_of_le _ hLK rw [Nat.cast_lt] -- So we are left with showing `natDegree (coeff χ 0) < finrank K L` apply lt_of_le_of_lt _ hr apply lieCharpoly_coeff_natDegree _ _ _ _ 0 r (zero_add r) -- Fix an element of `K`. intro α -- We want to show that `α` is a root of `coeff χ 0`. -- So we need to show that there is a `z ≠ 0` in `E` satisfying `⁅α • u + x, z⁆ = 0`. rw [← coe_evalRingHom, ← coeff_map, lieCharpoly_map_eval, ← constantCoeff_apply, LinearMap.charpoly_constantCoeff_eq_zero_iff] -- We consider `z = α • u + x`, and split into the cases `z = 0` and `z ≠ 0`. let z := α • u + x' obtain hz₀|hz₀ := eq_or_ne z 0 · -- If `z = 0`, then `⁅α • u + x, x⁆` vanishes and we use our assumption `x ≠ 0`. refine ⟨⟨x, self_mem_engel K x⟩, ?_, ?_⟩ · simpa [coe_bracket_of_module, ne_eq, Submodule.mk_eq_zero] using hx₀ · dsimp only [z] at hz₀ simp only [coe_bracket_of_module, hz₀, LieHom.map_zero, LinearMap.zero_apply] -- If `z ≠ 0`, then `⁅α • u + x, z⁆` vanishes per axiom of Lie algebras refine ⟨⟨z, hUle z.2⟩, ?_, ?_⟩ · simpa only [coe_bracket_of_module, ne_eq, Submodule.mk_eq_zero, Subtype.ext_iff] using hz₀ · show ⁅z, _⁆ = (0 : E) ext exact lie_self z.1 -- We are left with the case `i ≠ 0`, and want to show `coeff χ i = 0`. -- We will do this once again by showing that `coeff χ i` vanishes -- on a sufficiently large subset `s` of `K`. -- But we first need to get our hands on that subset `s`. -- We start by observing that `ψ` has non-trivial constant coefficient. have hψ : constantCoeff ψ ≠ 0 := by -- Suppose that `ψ` in fact has trivial constant coefficient. intro H -- Then there exists a `z ≠ 0` in `Q` such that `⁅x, z⁆ = 0`. obtain ⟨z, hz0, hxz⟩ : ∃ z : Q, z ≠ 0 ∧ ⁅x', z⁆ = 0 := by -- Indeed, if the constant coefficient of `ψ` is trivial, -- then `0` is a root of the characteristic polynomial of `⁅0 • u + x, _⁆` acting on `Q`, -- and hence we find an eigenvector `z` as desired. apply_fun (evalRingHom 0) at H rw [constantCoeff_apply, ← coeff_map, lieCharpoly_map_eval, ← constantCoeff_apply, map_zero, LinearMap.charpoly_constantCoeff_eq_zero_iff] at H simpa only [coe_bracket_of_module, ne_eq, zero_smul, zero_add, toEnd_apply_apply] using H -- It suffices to show `z = 0` (in `Q`) to obtain a contradiction. apply hz0 -- We replace `z : Q` by a representative in `L`. obtain ⟨z, rfl⟩ := LieSubmodule.Quotient.surjective_mk' E z -- The assumption `⁅x, z⁆ = 0` is equivalent to `⁅x, z⁆ ∈ E`. have : ⁅x, z⁆ ∈ E := by rwa [← LieSubmodule.Quotient.mk_eq_zero'] -- From this we deduce that there exists an `n` such that `⁅x, _⁆ ^ n` vanishes on `⁅x, z⁆`. -- On the other hand, our goal is to show `z = 0` in `Q`, -- which is equivalent to showing that `⁅x, _⁆ ^ n` vanishes on `z`, for some `n`. simp only [coe_bracket_of_module, LieSubmodule.mem_mk_iff', mem_coe_submodule, mem_engel_iff, LieSubmodule.Quotient.mk'_apply, LieSubmodule.Quotient.mk_eq_zero', E, Q] at this ⊢ -- Hence we win. obtain ⟨n, hn⟩ := this use n+1 rwa [pow_succ] -- Now we find a subset `s` of `K` of size `≥ r` -- such that `constantCoeff ψ` takes non-zero values on all of `s`. -- This turns out to be the subset that we alluded to earlier. obtain ⟨s, hs, hsψ⟩ : ∃ s : Finset K, r ≤ s.card ∧ ∀ α ∈ s, (constantCoeff ψ).eval α ≠ 0 := by classical -- Let `t` denote the set of roots of `constantCoeff ψ`. let t := (constantCoeff ψ).roots.toFinset -- We show that `t` has cardinality at most `finrank K L - r`. have ht : t.card ≤ finrank K L - r := by refine (Multiset.toFinset_card_le _).trans ?_ refine (card_roots' _).trans ?_ rw [constantCoeff_apply] -- Indeed, `constantCoeff ψ` has degree at most `finrank K Q = finrank K L - r`. apply lieCharpoly_coeff_natDegree suffices finrank K Q + r = finrank K L by rw [← this, zero_add, Nat.add_sub_cancel] apply Submodule.finrank_quotient_add_finrank -- Hence there exists a subset of size `≥ r` in the complement of `t`, -- and `constantCoeff ψ` takes non-zero values on all of this subset. obtain ⟨s, hs⟩ := exists_finset_le_card K _ hLK use s \ t refine ⟨?_, ?_⟩ · refine le_trans ?_ (Finset.le_card_sdiff _ _) omega · intro α hα simp only [Finset.mem_sdiff, Multiset.mem_toFinset, mem_roots', IsRoot.def, not_and, t] at hα exact hα.2 hψ -- So finally we can continue our proof strategy by showing that `coeff χ i` vanishes on `s`. apply eq_zero_of_natDegree_lt_card_of_eval_eq_zero' _ s _ ?hcard case hcard => -- We need to show that `natDegree (coeff χ i) < s.card` -- Which follows from our assumptions `i < r` and `r ≤ s.card` -- and the fact that the degree of `coeff χ i` is less than or equal to `r - i`. apply lt_of_le_of_lt (lieCharpoly_coeff_natDegree _ _ _ _ i (r - i) _) · omega · dsimp only [r] at hi ⊢ rw [Nat.add_sub_cancel' hi.le] -- We need to show that for all `α ∈ s`, the polynomial `coeff χ i` evaluates to zero at `α`. intro α hα -- Once again, we are left with showing that `⁅y, _⁆` acts nilpotently on `E`. rw [← coe_evalRingHom, ← coeff_map, lieCharpoly_map_eval, (LinearMap.charpoly_eq_X_pow_iff _).mpr, coeff_X_pow, if_neg hi.ne] -- To do so, it suffices to show that the Engel subalgebra of `v = a • u + x` is contained in `E`. let v := α • u + x' suffices engel K (v : L) ≤ engel K x by -- Indeed, in that case the minimality assumption on `E` implies -- that `E` is contained in the Engel subalgebra of `v`. replace this : engel K x ≤ engel K (v : L) := (hmin ⟨_, v, v.2, rfl⟩ this).ge intro z -- And so we are done, by the definition of Engel subalgebra. simpa only [mem_engel_iff, Subtype.ext_iff, coe_toEnd_pow _ _ _ E] using this z.2 -- Now we are in good shape. -- Fix an element `z` in the Engel subalgebra of `y`. intro z hz -- We need to show that `z` is in `E`, or alternatively that `z = 0` in `Q`. show z ∈ E rw [← LieSubmodule.Quotient.mk_eq_zero] -- We denote the image of `z` in `Q` by `z'`. set z' : Q := LieSubmodule.Quotient.mk' E z -- First we observe that `z'` is killed by a power of `⁅v, _⁆`. have hz' : ∃ n : ℕ, (toEnd K U Q v ^ n) z' = 0 := by rw [mem_engel_iff] at hz obtain ⟨n, hn⟩ := hz use n apply_fun LieSubmodule.Quotient.mk' E at hn rw [LieModuleHom.map_zero] at hn rw [← hn] clear hn induction n with | zero => simp only [Nat.zero_eq, pow_zero, LinearMap.one_apply] | succ n ih => rw [pow_succ', pow_succ', LinearMap.mul_apply, ih]; rfl classical -- Now let `n` be the smallest power such that `⁅v, _⁆ ^ n` kills `z'`. set n := Nat.find hz' with _hn have hn : (toEnd K U Q v ^ n) z' = 0 := Nat.find_spec hz' -- If `n = 0`, then we are done. obtain hn₀|⟨k, hk⟩ : n = 0 ∨ ∃ k, n = k + 1 := by cases n <;> simp · simpa only [hn₀, pow_zero, LinearMap.one_apply] using hn -- If `n = k + 1`, then we can write `⁅v, _⁆ ^ n = ⁅v, _⁆ ∘ ⁅v, _⁆ ^ k`. -- Recall that `constantCoeff ψ` is non-zero on `α`, and `v = α • u + x`. specialize hsψ α hα -- Hence `⁅v, _⁆` acts injectively on `Q`. rw [← coe_evalRingHom, constantCoeff_apply, ← coeff_map, lieCharpoly_map_eval, ← constantCoeff_apply, ne_eq, LinearMap.charpoly_constantCoeff_eq_zero_iff] at hsψ -- We deduce from this that `z' = 0`, arguing by contraposition. contrapose! hsψ -- Indeed `⁅v, _⁆` kills `⁅v, _⁆ ^ k` applied to `z'`. use (toEnd K U Q v ^ k) z' refine ⟨?_, ?_⟩ · -- And `⁅v, _⁆ ^ k` applied to `z'` is non-zero by definition of `n`. apply Nat.find_min hz'; omega · rw [← hn, hk, pow_succ', LinearMap.mul_apply] variable (K L) lemma exists_isCartanSubalgebra_engel_of_finrank_le_card (h : finrank K L ≤ #K) : ∃ x : L, IsCartanSubalgebra (engel K x) := by obtain ⟨x, hx⟩ := exists_isRegular_of_finrank_le_card K L h use x refine ⟨?_, normalizer_engel _ _⟩ apply isNilpotent_of_forall_le_engel intro y hy set Ex : {engel K z | z ∈ engel K x} := ⟨engel K x, x, self_mem_engel _ _, rfl⟩ suffices IsBot Ex from @this ⟨engel K y, y, hy, rfl⟩ apply engel_isBot_of_isMin h (engel K x) Ex le_rfl rintro ⟨_, y, hy, rfl⟩ hyx suffices finrank K (engel K x) ≤ finrank K (engel K y) by suffices engel K y = engel K x from this.ge apply LieSubalgebra.to_submodule_injective exact eq_of_le_of_finrank_le hyx this rw [(isRegular_iff_finrank_engel_eq_rank K x).mp hx] apply rank_le_finrank_engel lemma exists_isCartanSubalgebra_engel [Infinite K] : ∃ x : L, IsCartanSubalgebra (engel K x) := by apply exists_isCartanSubalgebra_engel_of_finrank_le_card exact (Cardinal.nat_lt_aleph0 _).le.trans <| Cardinal.infinite_iff.mp ‹Infinite K› end Field end LieAlgebra
Algebra\Lie\CartanMatrix.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Free import Mathlib.Algebra.Lie.Quotient import Mathlib.Data.Matrix.Notation /-! # Lie algebras from Cartan matrices Split semi-simple Lie algebras are uniquely determined by their Cartan matrix. Indeed, if `A` is an `l × l` Cartan matrix, the corresponding Lie algebra may be obtained as the Lie algebra on `3l` generators: $H_1, H_2, \ldots H_l, E_1, E_2, \ldots, E_l, F_1, F_2, \ldots, F_l$ subject to the following relations: $$ \begin{align} [H_i, H_j] &= 0\\ [E_i, F_i] &= H_i\\ [E_i, F_j] &= 0 \quad\text{if $i \ne j$}\\ [H_i, E_j] &= A_{ij}E_j\\ [H_i, F_j] &= -A_{ij}F_j\\ ad(E_i)^{1 - A_{ij}}(E_j) &= 0 \quad\text{if $i \ne j$}\\ ad(F_i)^{1 - A_{ij}}(F_j) &= 0 \quad\text{if $i \ne j$}\\ \end{align} $$ In this file we provide the above construction. It is defined for any square matrix of integers but the results for non-Cartan matrices should be regarded as junk. Recall that a Cartan matrix is a square matrix of integers `A` such that: * For diagonal values we have: `A i i = 2`. * For off-diagonal values (`i ≠ j`) we have: `A i j ∈ {-3, -2, -1, 0}`. * `A i j = 0 ↔ A j i = 0`. * There exists a diagonal matrix `D` over ℝ such that `D * A * D⁻¹` is symmetric positive definite. ## Alternative construction This construction is sometimes performed within the free unital associative algebra `FreeAlgebra R X`, rather than within the free Lie algebra `FreeLieAlgebra R X`, as we do here. However the difference is illusory since the construction stays inside the Lie subalgebra of `FreeAlgebra R X` generated by `X`, and this is naturally isomorphic to `FreeLieAlgebra R X` (though the proof of this seems to require Poincaré–Birkhoff–Witt). ## Definitions of exceptional Lie algebras This file also contains the Cartan matrices of the exceptional Lie algebras. By using these in the above construction, it thus provides definitions of the exceptional Lie algebras. These definitions make sense over any commutative ring. When the ring is ℝ, these are the split real forms of the exceptional semisimple Lie algebras. ## References * [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 4--6*](bourbaki1968) plates V -- IX, pages 275--290 * [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 7--9*](bourbaki1975b) chapter VIII, §4.3 * [J.P. Serre, *Complex Semisimple Lie Algebras*](serre1965) chapter VI, appendix ## Main definitions * `Matrix.ToLieAlgebra` * `CartanMatrix.E₆` * `CartanMatrix.E₇` * `CartanMatrix.E₈` * `CartanMatrix.F₄` * `CartanMatrix.G₂` * `LieAlgebra.e₆` * `LieAlgebra.e₇` * `LieAlgebra.e₈` * `LieAlgebra.f₄` * `LieAlgebra.g₂` ## Tags lie algebra, semi-simple, cartan matrix -/ universe u v w noncomputable section variable (R : Type u) {B : Type v} [CommRing R] variable (A : Matrix B B ℤ) namespace CartanMatrix variable (B) /-- The generators of the free Lie algebra from which we construct the Lie algebra of a Cartan matrix as a quotient. -/ inductive Generators | H : B → Generators | E : B → Generators | F : B → Generators instance [Inhabited B] : Inhabited (Generators B) := ⟨Generators.H default⟩ variable {B} namespace Relations open Function local notation "H" => FreeLieAlgebra.of R ∘ Generators.H local notation "E" => FreeLieAlgebra.of R ∘ Generators.E local notation "F" => FreeLieAlgebra.of R ∘ Generators.F local notation "ad" => LieAlgebra.ad R (FreeLieAlgebra R (Generators B)) /-- The terms corresponding to the `⁅H, H⁆`-relations. -/ def HH : B × B → FreeLieAlgebra R (Generators B) := uncurry fun i j => ⁅H i, H j⁆ /-- The terms corresponding to the `⁅E, F⁆`-relations. -/ def EF [DecidableEq B] : B × B → FreeLieAlgebra R (Generators B) := uncurry fun i j => if i = j then ⁅E i, F i⁆ - H i else ⁅E i, F j⁆ /-- The terms corresponding to the `⁅H, E⁆`-relations. -/ def HE : B × B → FreeLieAlgebra R (Generators B) := uncurry fun i j => ⁅H i, E j⁆ - A i j • E j /-- The terms corresponding to the `⁅H, F⁆`-relations. -/ def HF : B × B → FreeLieAlgebra R (Generators B) := uncurry fun i j => ⁅H i, F j⁆ + A i j • F j /-- The terms corresponding to the `ad E`-relations. Note that we use `Int.toNat` so that we can take the power and that we do not bother restricting to the case `i ≠ j` since these relations are zero anyway. We also defensively ensure this with `adE_of_eq_eq_zero`. -/ def adE : B × B → FreeLieAlgebra R (Generators B) := uncurry fun i j => ad (E i) ^ (-A i j).toNat <| ⁅E i, E j⁆ /-- The terms corresponding to the `ad F`-relations. See also `adE` docstring. -/ def adF : B × B → FreeLieAlgebra R (Generators B) := uncurry fun i j => ad (F i) ^ (-A i j).toNat <| ⁅F i, F j⁆ private theorem adE_of_eq_eq_zero (i : B) (h : A i i = 2) : adE R A ⟨i, i⟩ = 0 := by have h' : (-2 : ℤ).toNat = 0 := rfl simp [adE, h, h'] private theorem adF_of_eq_eq_zero (i : B) (h : A i i = 2) : adF R A ⟨i, i⟩ = 0 := by have h' : (-2 : ℤ).toNat = 0 := rfl simp [adF, h, h'] /-- The union of all the relations as a subset of the free Lie algebra. -/ def toSet [DecidableEq B] : Set (FreeLieAlgebra R (Generators B)) := (Set.range <| HH R) ∪ (Set.range <| EF R) ∪ (Set.range <| HE R A) ∪ (Set.range <| HF R A) ∪ (Set.range <| adE R A) ∪ (Set.range <| adF R A) /-- The ideal of the free Lie algebra generated by the relations. -/ def toIdeal [DecidableEq B] : LieIdeal R (FreeLieAlgebra R (Generators B)) := LieSubmodule.lieSpan R _ <| toSet R A end Relations end CartanMatrix variable [DecidableEq B] /-- The Lie algebra corresponding to a Cartan matrix. Note that it is defined for any matrix of integers. Its value for non-Cartan matrices should be regarded as junk. -/ def Matrix.ToLieAlgebra := FreeLieAlgebra R _ ⧸ CartanMatrix.Relations.toIdeal R A -- Porting note: the following were derived automatically in mathlib3. instance Matrix.ToLieAlgebra.instLieRing : LieRing (Matrix.ToLieAlgebra R A) := inferInstanceAs (LieRing (FreeLieAlgebra R _ ⧸ CartanMatrix.Relations.toIdeal R A)) instance Matrix.ToLieAlgebra.instInhabited : Inhabited (Matrix.ToLieAlgebra R A) := inferInstanceAs (Inhabited (FreeLieAlgebra R _ ⧸ CartanMatrix.Relations.toIdeal R A)) instance Matrix.ToLieAlgebra.instLieAlgebra : LieAlgebra R (Matrix.ToLieAlgebra R A) := inferInstanceAs (LieAlgebra R (FreeLieAlgebra R _ ⧸ CartanMatrix.Relations.toIdeal R A)) namespace CartanMatrix /-- The Cartan matrix of type e₆. See [bourbaki1968] plate V, page 277. The corresponding Dynkin diagram is: ``` o | o --- o --- o --- o --- o ``` -/ def E₆ : Matrix (Fin 6) (Fin 6) ℤ := !![2, 0, -1, 0, 0, 0; 0, 2, 0, -1, 0, 0; -1, 0, 2, -1, 0, 0; 0, -1, -1, 2, -1, 0; 0, 0, 0, -1, 2, -1; 0, 0, 0, 0, -1, 2] /-- The Cartan matrix of type e₇. See [bourbaki1968] plate VI, page 281. The corresponding Dynkin diagram is: ``` o | o --- o --- o --- o --- o --- o ``` -/ def E₇ : Matrix (Fin 7) (Fin 7) ℤ := !![2, 0, -1, 0, 0, 0, 0; 0, 2, 0, -1, 0, 0, 0; -1, 0, 2, -1, 0, 0, 0; 0, -1, -1, 2, -1, 0, 0; 0, 0, 0, -1, 2, -1, 0; 0, 0, 0, 0, -1, 2, -1; 0, 0, 0, 0, 0, -1, 2] /-- The Cartan matrix of type e₈. See [bourbaki1968] plate VII, page 285. The corresponding Dynkin diagram is: ``` o | o --- o --- o --- o --- o --- o --- o ``` -/ def E₈ : Matrix (Fin 8) (Fin 8) ℤ := !![2, 0, -1, 0, 0, 0, 0, 0; 0, 2, 0, -1, 0, 0, 0, 0; -1, 0, 2, -1, 0, 0, 0, 0; 0, -1, -1, 2, -1, 0, 0, 0; 0, 0, 0, -1, 2, -1, 0, 0; 0, 0, 0, 0, -1, 2, -1, 0; 0, 0, 0, 0, 0, -1, 2, -1; 0, 0, 0, 0, 0, 0, -1, 2] /-- The Cartan matrix of type f₄. See [bourbaki1968] plate VIII, page 288. The corresponding Dynkin diagram is: ``` o --- o =>= o --- o ``` -/ def F₄ : Matrix (Fin 4) (Fin 4) ℤ := !![2, -1, 0, 0; -1, 2, -2, 0; 0, -1, 2, -1; 0, 0, -1, 2] /-- The Cartan matrix of type g₂. See [bourbaki1968] plate IX, page 290. The corresponding Dynkin diagram is: ``` o ≡>≡ o ``` Actually we are using the transpose of Bourbaki's matrix. This is to make this matrix consistent with `CartanMatrix.F₄`, in the sense that all non-zero values below the diagonal are -1. -/ def G₂ : Matrix (Fin 2) (Fin 2) ℤ := !![2, -3; -1, 2] end CartanMatrix namespace LieAlgebra /-- The exceptional split Lie algebra of type e₆. -/ abbrev e₆ := CartanMatrix.E₆.ToLieAlgebra R /-- The exceptional split Lie algebra of type e₇. -/ abbrev e₇ := CartanMatrix.E₇.ToLieAlgebra R /-- The exceptional split Lie algebra of type e₈. -/ abbrev e₈ := CartanMatrix.E₈.ToLieAlgebra R /-- The exceptional split Lie algebra of type f₄. -/ abbrev f₄ := CartanMatrix.F₄.ToLieAlgebra R /-- The exceptional split Lie algebra of type g₂. -/ abbrev g₂ := CartanMatrix.G₂.ToLieAlgebra R end LieAlgebra
Algebra\Lie\CartanSubalgebra.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Nilpotent import Mathlib.Algebra.Lie.Normalizer /-! # Cartan subalgebras Cartan subalgebras are one of the most important concepts in Lie theory. We define them here. The standard example is the set of diagonal matrices in the Lie algebra of matrices. ## Main definitions * `LieSubmodule.IsUcsLimit` * `LieSubalgebra.IsCartanSubalgebra` * `LieSubalgebra.isCartanSubalgebra_iff_isUcsLimit` ## Tags lie subalgebra, normalizer, idealizer, cartan subalgebra -/ universe u v w w₁ w₂ variable {R : Type u} {L : Type v} variable [CommRing R] [LieRing L] [LieAlgebra R L] (H : LieSubalgebra R L) /-- Given a Lie module `M` of a Lie algebra `L`, `LieSubmodule.IsUcsLimit` is the proposition that a Lie submodule `N ⊆ M` is the limiting value for the upper central series. This is a characteristic property of Cartan subalgebras with the roles of `L`, `M`, `N` played by `H`, `L`, `H`, respectively. See `LieSubalgebra.isCartanSubalgebra_iff_isUcsLimit`. -/ def LieSubmodule.IsUcsLimit {M : Type*} [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] (N : LieSubmodule R L M) : Prop := ∃ k, ∀ l, k ≤ l → (⊥ : LieSubmodule R L M).ucs l = N namespace LieSubalgebra /-- A Cartan subalgebra is a nilpotent, self-normalizing subalgebra. A _splitting_ Cartan subalgebra can be defined by mixing in `LieModule.IsTriangularizable R H L`. -/ class IsCartanSubalgebra : Prop where nilpotent : LieAlgebra.IsNilpotent R H self_normalizing : H.normalizer = H instance [H.IsCartanSubalgebra] : LieAlgebra.IsNilpotent R H := IsCartanSubalgebra.nilpotent @[simp] theorem normalizer_eq_self_of_isCartanSubalgebra (H : LieSubalgebra R L) [H.IsCartanSubalgebra] : H.toLieSubmodule.normalizer = H.toLieSubmodule := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, coe_normalizer_eq_normalizer, IsCartanSubalgebra.self_normalizing, coe_toLieSubmodule] @[simp] theorem ucs_eq_self_of_isCartanSubalgebra (H : LieSubalgebra R L) [H.IsCartanSubalgebra] (k : ℕ) : H.toLieSubmodule.ucs k = H.toLieSubmodule := by induction' k with k ih · simp · simp [ih] theorem isCartanSubalgebra_iff_isUcsLimit : H.IsCartanSubalgebra ↔ H.toLieSubmodule.IsUcsLimit := by constructor · intro h have h₁ : LieAlgebra.IsNilpotent R H := by infer_instance obtain ⟨k, hk⟩ := H.toLieSubmodule.isNilpotent_iff_exists_self_le_ucs.mp h₁ replace hk : H.toLieSubmodule = LieSubmodule.ucs k ⊥ := le_antisymm hk (LieSubmodule.ucs_le_of_normalizer_eq_self H.normalizer_eq_self_of_isCartanSubalgebra k) refine ⟨k, fun l hl => ?_⟩ rw [← Nat.sub_add_cancel hl, LieSubmodule.ucs_add, ← hk, LieSubalgebra.ucs_eq_self_of_isCartanSubalgebra] · rintro ⟨k, hk⟩ exact { nilpotent := by dsimp only [LieAlgebra.IsNilpotent] erw [H.toLieSubmodule.isNilpotent_iff_exists_lcs_eq_bot] use k rw [_root_.eq_bot_iff, LieSubmodule.lcs_le_iff, hk k (le_refl k)] self_normalizing := by have hk' := hk (k + 1) k.le_succ rw [LieSubmodule.ucs_succ, hk k (le_refl k)] at hk' rw [← LieSubalgebra.coe_to_submodule_eq_iff, ← LieSubalgebra.coe_normalizer_eq_normalizer, hk', LieSubalgebra.coe_toLieSubmodule] } lemma ne_bot_of_isCartanSubalgebra [Nontrivial L] (H : LieSubalgebra R L) [H.IsCartanSubalgebra] : H ≠ ⊥ := by intro e obtain ⟨x, hx⟩ := exists_ne (0 : L) have : x ∈ H.normalizer := by simp [LieSubalgebra.mem_normalizer_iff, e] exact hx (by rwa [LieSubalgebra.IsCartanSubalgebra.self_normalizing, e] at this) instance (priority := 500) [Nontrivial L] (H : LieSubalgebra R L) [H.IsCartanSubalgebra] : Nontrivial H := by refine (subsingleton_or_nontrivial H).elim (fun inst ↦ False.elim ?_) id apply ne_bot_of_isCartanSubalgebra H rw [eq_bot_iff] exact fun x hx ↦ congr_arg Subtype.val (Subsingleton.elim (⟨x, hx⟩ : H) 0) end LieSubalgebra @[simp] theorem LieIdeal.normalizer_eq_top {R : Type u} {L : Type v} [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L) : (I : LieSubalgebra R L).normalizer = ⊤ := by ext x simpa only [LieSubalgebra.mem_normalizer_iff, LieSubalgebra.mem_top, iff_true_iff] using fun y hy => I.lie_mem hy open LieIdeal /-- A nilpotent Lie algebra is its own Cartan subalgebra. -/ instance LieAlgebra.top_isCartanSubalgebra_of_nilpotent [LieAlgebra.IsNilpotent R L] : LieSubalgebra.IsCartanSubalgebra (⊤ : LieSubalgebra R L) where nilpotent := inferInstance self_normalizing := by rw [← top_coe_lieSubalgebra, normalizer_eq_top, top_coe_lieSubalgebra]
Algebra\Lie\Character.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Abelian import Mathlib.Algebra.Lie.Solvable import Mathlib.LinearAlgebra.Dual /-! # Characters of Lie algebras A character of a Lie algebra `L` over a commutative ring `R` is a morphism of Lie algebras `L → R`, where `R` is regarded as a Lie algebra over itself via the ring commutator. For an Abelian Lie algebra (e.g., a Cartan subalgebra of a semisimple Lie algebra) a character is just a linear form. ## Main definitions * `LieAlgebra.LieCharacter` * `LieAlgebra.lieCharacterEquivLinearDual` ## Tags lie algebra, lie character -/ universe u v w w₁ namespace LieAlgebra variable (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L] /-- A character of a Lie algebra is a morphism to the scalars. -/ abbrev LieCharacter := L →ₗ⁅R⁆ R variable {R L} -- @[simp] -- Porting note: simp normal form is the LHS of `lieCharacter_apply_lie'` theorem lieCharacter_apply_lie (χ : LieCharacter R L) (x y : L) : χ ⁅x, y⁆ = 0 := by rw [LieHom.map_lie, LieRing.of_associative_ring_bracket, mul_comm, sub_self] @[simp] theorem lieCharacter_apply_lie' (χ : LieCharacter R L) (x y : L) : ⁅χ x, χ y⁆ = 0 := by rw [LieRing.of_associative_ring_bracket, mul_comm, sub_self] theorem lieCharacter_apply_of_mem_derived (χ : LieCharacter R L) {x : L} (h : x ∈ derivedSeries R L 1) : χ x = 0 := by rw [derivedSeries_def, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_zero, ← LieSubmodule.mem_coeSubmodule, LieSubmodule.lieIdeal_oper_eq_linear_span] at h refine Submodule.span_induction h ?_ ?_ ?_ ?_ · rintro y ⟨⟨z, hz⟩, ⟨⟨w, hw⟩, rfl⟩⟩; apply lieCharacter_apply_lie · exact χ.map_zero · intro y z hy hz; rw [LieHom.map_add, hy, hz, add_zero] · intro t y hy; rw [LieHom.map_smul, hy, smul_zero] /-- For an Abelian Lie algebra, characters are just linear forms. -/ @[simps! apply symm_apply] def lieCharacterEquivLinearDual [IsLieAbelian L] : LieCharacter R L ≃ Module.Dual R L where toFun χ := (χ : L →ₗ[R] R) invFun ψ := { ψ with map_lie' := fun {x y} => by rw [LieModule.IsTrivial.trivial, LieRing.of_associative_ring_bracket, mul_comm, sub_self, LinearMap.toFun_eq_coe, LinearMap.map_zero] } left_inv χ := by ext; rfl right_inv ψ := by ext; rfl end LieAlgebra
Algebra\Lie\Classical.lean
/- Copyright (c) 2020 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Data.Matrix.Basis import Mathlib.Data.Matrix.DMatrix import Mathlib.Algebra.Lie.Abelian import Mathlib.LinearAlgebra.Matrix.Trace import Mathlib.Algebra.Lie.SkewAdjoint import Mathlib.LinearAlgebra.SymplecticGroup /-! # Classical Lie algebras This file is the place to find definitions and basic properties of the classical Lie algebras: * Aₗ = sl(l+1) * Bₗ ≃ so(l+1, l) ≃ so(2l+1) * Cₗ = sp(l) * Dₗ ≃ so(l, l) ≃ so(2l) ## Main definitions * `LieAlgebra.SpecialLinear.sl` * `LieAlgebra.Symplectic.sp` * `LieAlgebra.Orthogonal.so` * `LieAlgebra.Orthogonal.so'` * `LieAlgebra.Orthogonal.soIndefiniteEquiv` * `LieAlgebra.Orthogonal.typeD` * `LieAlgebra.Orthogonal.typeB` * `LieAlgebra.Orthogonal.typeDEquivSo'` * `LieAlgebra.Orthogonal.typeBEquivSo'` ## Implementation notes ### Matrices or endomorphisms Given a finite type and a commutative ring, the corresponding square matrices are equivalent to the endomorphisms of the corresponding finite-rank free module as Lie algebras, see `lieEquivMatrix'`. We can thus define the classical Lie algebras as Lie subalgebras either of matrices or of endomorphisms. We have opted for the former. At the time of writing (August 2020) it is unclear which approach should be preferred so the choice should be assumed to be somewhat arbitrary. ### Diagonal quadratic form or diagonal Cartan subalgebra For the algebras of type `B` and `D`, there are two natural definitions. For example since the `2l × 2l` matrix: $$ J = \left[\begin{array}{cc} 0_l & 1_l\\ 1_l & 0_l \end{array}\right] $$ defines a symmetric bilinear form equivalent to that defined by the identity matrix `I`, we can define the algebras of type `D` to be the Lie subalgebra of skew-adjoint matrices either for `J` or for `I`. Both definitions have their advantages (in particular the `J`-skew-adjoint matrices define a Lie algebra for which the diagonal matrices form a Cartan subalgebra) and so we provide both. We thus also provide equivalences `typeDEquivSo'`, `soIndefiniteEquiv` which show the two definitions are equivalent. Similarly for the algebras of type `B`. ## Tags classical lie algebra, special linear, symplectic, orthogonal -/ universe u₁ u₂ namespace LieAlgebra open Matrix open scoped Matrix variable (n p q l : Type*) (R : Type u₂) variable [DecidableEq n] [DecidableEq p] [DecidableEq q] [DecidableEq l] variable [CommRing R] @[simp] theorem matrix_trace_commutator_zero [Fintype n] (X Y : Matrix n n R) : Matrix.trace ⁅X, Y⁆ = 0 := calc _ = Matrix.trace (X * Y) - Matrix.trace (Y * X) := trace_sub _ _ _ = Matrix.trace (X * Y) - Matrix.trace (X * Y) := (congr_arg (fun x => _ - x) (Matrix.trace_mul_comm Y X)) _ = 0 := sub_self _ namespace SpecialLinear /-- The special linear Lie algebra: square matrices of trace zero. -/ def sl [Fintype n] : LieSubalgebra R (Matrix n n R) := { LinearMap.ker (Matrix.traceLinearMap n R R) with lie_mem' := fun _ _ => LinearMap.mem_ker.2 <| matrix_trace_commutator_zero _ _ _ _ } theorem sl_bracket [Fintype n] (A B : sl n R) : ⁅A, B⁆.val = A.val * B.val - B.val * A.val := rfl section ElementaryBasis variable {n} [Fintype n] (i j : n) /-- When j ≠ i, the elementary matrices are elements of sl n R, in fact they are part of a natural basis of `sl n R`. -/ def Eb (h : j ≠ i) : sl n R := ⟨Matrix.stdBasisMatrix i j (1 : R), show Matrix.stdBasisMatrix i j (1 : R) ∈ LinearMap.ker (Matrix.traceLinearMap n R R) from Matrix.StdBasisMatrix.trace_zero i j (1 : R) h⟩ @[simp] theorem eb_val (h : j ≠ i) : (Eb R i j h).val = Matrix.stdBasisMatrix i j 1 := rfl end ElementaryBasis theorem sl_non_abelian [Fintype n] [Nontrivial R] (h : 1 < Fintype.card n) : ¬IsLieAbelian (sl n R) := by rcases Fintype.exists_pair_of_one_lt_card h with ⟨j, i, hij⟩ let A := Eb R i j hij let B := Eb R j i hij.symm intro c have c' : A.val * B.val = B.val * A.val := by rw [← sub_eq_zero, ← sl_bracket, c.trivial, ZeroMemClass.coe_zero] simpa [A, B, stdBasisMatrix, Matrix.mul_apply, hij] using congr_fun (congr_fun c' i) i end SpecialLinear namespace Symplectic /-- The symplectic Lie algebra: skew-adjoint matrices with respect to the canonical skew-symmetric bilinear form. -/ def sp [Fintype l] : LieSubalgebra R (Matrix (l ⊕ l) (l ⊕ l) R) := skewAdjointMatricesLieSubalgebra (Matrix.J l R) end Symplectic namespace Orthogonal /-- The definite orthogonal Lie subalgebra: skew-adjoint matrices with respect to the symmetric bilinear form defined by the identity matrix. -/ def so [Fintype n] : LieSubalgebra R (Matrix n n R) := skewAdjointMatricesLieSubalgebra (1 : Matrix n n R) @[simp] theorem mem_so [Fintype n] (A : Matrix n n R) : A ∈ so n R ↔ Aᵀ = -A := by rw [so, mem_skewAdjointMatricesLieSubalgebra, mem_skewAdjointMatricesSubmodule] simp only [Matrix.IsSkewAdjoint, Matrix.IsAdjointPair, Matrix.mul_one, Matrix.one_mul] /-- The indefinite diagonal matrix with `p` 1s and `q` -1s. -/ def indefiniteDiagonal : Matrix (p ⊕ q) (p ⊕ q) R := Matrix.diagonal <| Sum.elim (fun _ => 1) fun _ => -1 /-- The indefinite orthogonal Lie subalgebra: skew-adjoint matrices with respect to the symmetric bilinear form defined by the indefinite diagonal matrix. -/ def so' [Fintype p] [Fintype q] : LieSubalgebra R (Matrix (p ⊕ q) (p ⊕ q) R) := skewAdjointMatricesLieSubalgebra <| indefiniteDiagonal p q R /-- A matrix for transforming the indefinite diagonal bilinear form into the definite one, provided the parameter `i` is a square root of -1. -/ def Pso (i : R) : Matrix (p ⊕ q) (p ⊕ q) R := Matrix.diagonal <| Sum.elim (fun _ => 1) fun _ => i variable [Fintype p] [Fintype q] theorem pso_inv {i : R} (hi : i * i = -1) : Pso p q R i * Pso p q R (-i) = 1 := by ext (x y); rcases x with ⟨x⟩|⟨x⟩ <;> rcases y with ⟨y⟩|⟨y⟩ · -- x y : p by_cases h : x = y <;> simp [Pso, indefiniteDiagonal, h, one_apply] · -- x : p, y : q simp [Pso, indefiniteDiagonal] · -- x : q, y : p simp [Pso, indefiniteDiagonal] · -- x y : q by_cases h : x = y <;> simp [Pso, indefiniteDiagonal, h, hi, one_apply] /-- There is a constructive inverse of `Pso p q R i`. -/ def invertiblePso {i : R} (hi : i * i = -1) : Invertible (Pso p q R i) := invertibleOfRightInverse _ _ (pso_inv p q R hi) theorem indefiniteDiagonal_transform {i : R} (hi : i * i = -1) : (Pso p q R i)ᵀ * indefiniteDiagonal p q R * Pso p q R i = 1 := by ext (x y); rcases x with ⟨x⟩|⟨x⟩ <;> rcases y with ⟨y⟩|⟨y⟩ · -- x y : p by_cases h : x = y <;> simp [Pso, indefiniteDiagonal, h, one_apply] · -- x : p, y : q simp [Pso, indefiniteDiagonal] · -- x : q, y : p simp [Pso, indefiniteDiagonal] · -- x y : q by_cases h : x = y <;> simp [Pso, indefiniteDiagonal, h, hi, one_apply] /-- An equivalence between the indefinite and definite orthogonal Lie algebras, over a ring containing a square root of -1. -/ noncomputable def soIndefiniteEquiv {i : R} (hi : i * i = -1) : so' p q R ≃ₗ⁅R⁆ so (p ⊕ q) R := by apply (skewAdjointMatricesLieSubalgebraEquiv (indefiniteDiagonal p q R) (Pso p q R i) (invertiblePso p q R hi)).trans apply LieEquiv.ofEq ext A; rw [indefiniteDiagonal_transform p q R hi]; rfl theorem soIndefiniteEquiv_apply {i : R} (hi : i * i = -1) (A : so' p q R) : (soIndefiniteEquiv p q R hi A : Matrix (p ⊕ q) (p ⊕ q) R) = (Pso p q R i)⁻¹ * (A : Matrix (p ⊕ q) (p ⊕ q) R) * Pso p q R i := by rw [soIndefiniteEquiv, LieEquiv.trans_apply, LieEquiv.ofEq_apply] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [skewAdjointMatricesLieSubalgebraEquiv_apply] /-- A matrix defining a canonical even-rank symmetric bilinear form. It looks like this as a `2l x 2l` matrix of `l x l` blocks: [ 0 1 ] [ 1 0 ] -/ def JD : Matrix (l ⊕ l) (l ⊕ l) R := Matrix.fromBlocks 0 1 1 0 /-- The classical Lie algebra of type D as a Lie subalgebra of matrices associated to the matrix `JD`. -/ def typeD [Fintype l] := skewAdjointMatricesLieSubalgebra (JD l R) /-- A matrix transforming the bilinear form defined by the matrix `JD` into a split-signature diagonal matrix. It looks like this as a `2l x 2l` matrix of `l x l` blocks: [ 1 -1 ] [ 1 1 ] -/ def PD : Matrix (l ⊕ l) (l ⊕ l) R := Matrix.fromBlocks 1 (-1) 1 1 /-- The split-signature diagonal matrix. -/ def S := indefiniteDiagonal l l R theorem s_as_blocks : S l R = Matrix.fromBlocks 1 0 0 (-1) := by rw [← Matrix.diagonal_one, Matrix.diagonal_neg, Matrix.fromBlocks_diagonal] rfl theorem jd_transform [Fintype l] : (PD l R)ᵀ * JD l R * PD l R = (2 : R) • S l R := by have h : (PD l R)ᵀ * JD l R = Matrix.fromBlocks 1 1 1 (-1) := by simp [PD, JD, Matrix.fromBlocks_transpose, Matrix.fromBlocks_multiply] rw [h, PD, s_as_blocks, Matrix.fromBlocks_multiply, Matrix.fromBlocks_smul] simp [two_smul] theorem pd_inv [Fintype l] [Invertible (2 : R)] : PD l R * ⅟ (2 : R) • (PD l R)ᵀ = 1 := by rw [PD, Matrix.fromBlocks_transpose, Matrix.fromBlocks_smul, Matrix.fromBlocks_multiply] simp instance invertiblePD [Fintype l] [Invertible (2 : R)] : Invertible (PD l R) := invertibleOfRightInverse _ _ (pd_inv l R) /-- An equivalence between two possible definitions of the classical Lie algebra of type D. -/ noncomputable def typeDEquivSo' [Fintype l] [Invertible (2 : R)] : typeD l R ≃ₗ⁅R⁆ so' l l R := by apply (skewAdjointMatricesLieSubalgebraEquiv (JD l R) (PD l R) (by infer_instance)).trans apply LieEquiv.ofEq ext A rw [jd_transform, ← val_unitOfInvertible (2 : R), ← Units.smul_def, LieSubalgebra.mem_coe, mem_skewAdjointMatricesLieSubalgebra_unit_smul] rfl /-- A matrix defining a canonical odd-rank symmetric bilinear form. It looks like this as a `(2l+1) x (2l+1)` matrix of blocks: [ 2 0 0 ] [ 0 0 1 ] [ 0 1 0 ] where sizes of the blocks are: [`1 x 1` `1 x l` `1 x l`] [`l x 1` `l x l` `l x l`] [`l x 1` `l x l` `l x l`] -/ def JB := Matrix.fromBlocks ((2 : R) • (1 : Matrix Unit Unit R)) 0 0 (JD l R) /-- The classical Lie algebra of type B as a Lie subalgebra of matrices associated to the matrix `JB`. -/ def typeB [Fintype l] := skewAdjointMatricesLieSubalgebra (JB l R) /-- A matrix transforming the bilinear form defined by the matrix `JB` into an almost-split-signature diagonal matrix. It looks like this as a `(2l+1) x (2l+1)` matrix of blocks: [ 1 0 0 ] [ 0 1 -1 ] [ 0 1 1 ] where sizes of the blocks are: [`1 x 1` `1 x l` `1 x l`] [`l x 1` `l x l` `l x l`] [`l x 1` `l x l` `l x l`] -/ def PB := Matrix.fromBlocks (1 : Matrix Unit Unit R) 0 0 (PD l R) variable [Fintype l] theorem pb_inv [Invertible (2 : R)] : PB l R * Matrix.fromBlocks 1 0 0 (⅟ (PD l R)) = 1 := by rw [PB, Matrix.fromBlocks_multiply, mul_invOf_self] simp only [Matrix.mul_zero, Matrix.mul_one, Matrix.zero_mul, zero_add, add_zero, Matrix.fromBlocks_one] instance invertiblePB [Invertible (2 : R)] : Invertible (PB l R) := invertibleOfRightInverse _ _ (pb_inv l R) theorem jb_transform : (PB l R)ᵀ * JB l R * PB l R = (2 : R) • Matrix.fromBlocks 1 0 0 (S l R) := by simp [PB, JB, jd_transform, Matrix.fromBlocks_transpose, Matrix.fromBlocks_multiply, Matrix.fromBlocks_smul] theorem indefiniteDiagonal_assoc : indefiniteDiagonal (Unit ⊕ l) l R = Matrix.reindexLieEquiv (Equiv.sumAssoc Unit l l).symm (Matrix.fromBlocks 1 0 0 (indefiniteDiagonal l l R)) := by ext ⟨⟨i₁ | i₂⟩ | i₃⟩ ⟨⟨j₁ | j₂⟩ | j₃⟩ <;> -- Porting note: added `Sum.inl_injective.eq_iff`, `Sum.inr_injective.eq_iff` simp only [indefiniteDiagonal, Matrix.diagonal_apply, Equiv.sumAssoc_apply_inl_inl, Matrix.reindexLieEquiv_apply, Matrix.submatrix_apply, Equiv.symm_symm, Matrix.reindex_apply, Sum.elim_inl, if_true, eq_self_iff_true, Matrix.one_apply_eq, Matrix.fromBlocks_apply₁₁, DMatrix.zero_apply, Equiv.sumAssoc_apply_inl_inr, if_false, Matrix.fromBlocks_apply₁₂, Matrix.fromBlocks_apply₂₁, Matrix.fromBlocks_apply₂₂, Equiv.sumAssoc_apply_inr, Sum.elim_inr, Sum.inl_injective.eq_iff, Sum.inr_injective.eq_iff] <;> congr 1 /-- An equivalence between two possible definitions of the classical Lie algebra of type B. -/ noncomputable def typeBEquivSo' [Invertible (2 : R)] : typeB l R ≃ₗ⁅R⁆ so' (Unit ⊕ l) l R := by apply (skewAdjointMatricesLieSubalgebraEquiv (JB l R) (PB l R) (by infer_instance)).trans symm apply (skewAdjointMatricesLieSubalgebraEquivTranspose (indefiniteDiagonal (Sum Unit l) l R) (Matrix.reindexAlgEquiv _ _ (Equiv.sumAssoc PUnit l l)) (Matrix.transpose_reindex _ _)).trans apply LieEquiv.ofEq ext A rw [jb_transform, ← val_unitOfInvertible (2 : R), ← Units.smul_def, LieSubalgebra.mem_coe, LieSubalgebra.mem_coe, mem_skewAdjointMatricesLieSubalgebra_unit_smul] simp [indefiniteDiagonal_assoc, S] end Orthogonal end LieAlgebra
Algebra\Lie\DirectSum.lean
/- Copyright (c) 2020 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.DirectSum.Module import Mathlib.Algebra.Lie.OfAssociative import Mathlib.Algebra.Lie.Submodule import Mathlib.Algebra.Lie.Basic /-! # Direct sums of Lie algebras and Lie modules Direct sums of Lie algebras and Lie modules carry natural algebra and module structures. ## Tags lie algebra, lie module, direct sum -/ universe u v w w₁ namespace DirectSum open DFinsupp open scoped DirectSum variable {R : Type u} {ι : Type v} [CommRing R] section Modules /-! The direct sum of Lie modules over a fixed Lie algebra carries a natural Lie module structure. -/ variable {L : Type w₁} {M : ι → Type w} variable [LieRing L] [LieAlgebra R L] variable [∀ i, AddCommGroup (M i)] [∀ i, Module R (M i)] variable [∀ i, LieRingModule L (M i)] [∀ i, LieModule R L (M i)] instance : LieRingModule L (⨁ i, M i) where bracket x m := m.mapRange (fun i m' => ⁅x, m'⁆) fun i => lie_zero x add_lie x y m := by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [mapRange_apply, add_apply, add_lie] lie_add x m n := by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [mapRange_apply, add_apply, lie_add] leibniz_lie x y m := by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [mapRange_apply, lie_lie, add_apply, sub_add_cancel] @[simp] theorem lie_module_bracket_apply (x : L) (m : ⨁ i, M i) (i : ι) : ⁅x, m⁆ i = ⁅x, m i⁆ := mapRange_apply _ _ m i instance : LieModule R L (⨁ i, M i) where smul_lie t x m := by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext i` simp only [smul_lie, lie_module_bracket_apply, smul_apply] lie_smul t x m := by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext i` simp only [lie_smul, lie_module_bracket_apply, smul_apply] variable (R ι L M) /-- The inclusion of each component into a direct sum as a morphism of Lie modules. -/ def lieModuleOf [DecidableEq ι] (j : ι) : M j →ₗ⁅R,L⁆ ⨁ i, M i := { lof R ι M j with map_lie' := fun {x m} => by refine DFinsupp.ext fun i => ?_ -- Porting note: Originally `ext i` by_cases h : j = i · rw [← h]; simp · -- This used to be the end of the proof before leanprover/lean4#2644 -- old proof `simp [lof, lsingle, h]` simp only [lof, lsingle, AddHom.toFun_eq_coe, lie_module_bracket_apply] erw [AddHom.coe_mk] simp [h] } /-- The projection map onto one component, as a morphism of Lie modules. -/ def lieModuleComponent (j : ι) : (⨁ i, M i) →ₗ⁅R,L⁆ M j := { component R ι M j with map_lie' := fun {x m} => by simp [component, lapply] } end Modules section Algebras /-! The direct sum of Lie algebras carries a natural Lie algebra structure. -/ variable (L : ι → Type w) variable [∀ i, LieRing (L i)] [∀ i, LieAlgebra R (L i)] instance lieRing : LieRing (⨁ i, L i) := { (inferInstance : AddCommGroup _) with bracket := zipWith (fun i => fun x y => ⁅x, y⁆) fun i => lie_zero 0 add_lie := fun x y z => by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [zipWith_apply, add_apply, add_lie] lie_add := fun x y z => by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [zipWith_apply, add_apply, lie_add] lie_self := fun x => by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [zipWith_apply, add_apply, lie_self, zero_apply] leibniz_lie := fun x y z => by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [sub_apply, zipWith_apply, add_apply, zero_apply] apply leibniz_lie } @[simp] theorem bracket_apply (x y : ⨁ i, L i) (i : ι) : ⁅x, y⁆ i = ⁅x i, y i⁆ := zipWith_apply _ _ x y i theorem lie_of_same [DecidableEq ι] {i : ι} (x y : L i) : ⁅of L i x, of L i y⁆ = of L i ⁅x, y⁆ := DFinsupp.zipWith_single_single _ _ _ _ theorem lie_of_of_ne [DecidableEq ι] {i j : ι} (hij : i ≠ j) (x : L i) (y : L j) : ⁅of L i x, of L j y⁆ = 0 := by refine DFinsupp.ext fun k => ?_ rw [bracket_apply] obtain rfl | hik := Decidable.eq_or_ne i k · rw [of_eq_of_ne _ _ _ hij.symm, lie_zero, zero_apply] · rw [of_eq_of_ne _ _ _ hik, zero_lie, zero_apply] @[simp] theorem lie_of [DecidableEq ι] {i j : ι} (x : L i) (y : L j) : ⁅of L i x, of L j y⁆ = if hij : i = j then of L i ⁅x, hij.symm.recOn y⁆ else 0 := by obtain rfl | hij := Decidable.eq_or_ne i j · simp only [lie_of_same L x y, dif_pos] · simp only [lie_of_of_ne L hij x y, hij, dif_neg, dite_false] instance lieAlgebra : LieAlgebra R (⨁ i, L i) := { (inferInstance : Module R _) with lie_smul := fun c x y => by refine DFinsupp.ext fun _ => ?_ -- Porting note: Originally `ext` simp only [zipWith_apply, smul_apply, bracket_apply, lie_smul] } variable (R ι) /-- The inclusion of each component into the direct sum as morphism of Lie algebras. -/ @[simps] def lieAlgebraOf [DecidableEq ι] (j : ι) : L j →ₗ⁅R⁆ ⨁ i, L i := { lof R ι L j with toFun := of L j map_lie' := fun {x y} => by refine DFinsupp.ext fun i => ?_ -- Porting note: Originally `ext i` by_cases h : j = i · rw [← h] -- This used to be the end of the proof before leanprover/lean4#2644 -- with `simp [of, singleAddHom]` simp only [of, singleAddHom, bracket_apply] erw [AddHom.coe_mk, single_apply, single_apply] · simp? [h] says simp only [h, ↓reduceDIte, single_apply] · intros erw [single_add] · -- This used to be the end of the proof before leanprover/lean4#2644 -- with `simp [of, singleAddHom]` simp only [of, singleAddHom, bracket_apply] erw [AddHom.coe_mk, single_apply, single_apply] · simp only [h, dite_false, single_apply, lie_self] · intros erw [single_add] } /-- The projection map onto one component, as a morphism of Lie algebras. -/ @[simps] def lieAlgebraComponent (j : ι) : (⨁ i, L i) →ₗ⁅R⁆ L j := { component R ι L j with toFun := component R ι L j map_lie' := fun {x y} => by simp [component, lapply] } -- Note(kmill): `ext` cannot generate an iff theorem here since `x` and `y` do not determine `R`. @[ext (iff := false)] theorem lieAlgebra_ext {x y : ⨁ i, L i} (h : ∀ i, lieAlgebraComponent R ι L i x = lieAlgebraComponent R ι L i y) : x = y := DFinsupp.ext h variable {R L ι} /-- Given a family of Lie algebras `L i`, together with a family of morphisms of Lie algebras `f i : L i →ₗ⁅R⁆ L'` into a fixed Lie algebra `L'`, we have a natural linear map: `(⨁ i, L i) →ₗ[R] L'`. If in addition `⁅f i x, f j y⁆ = 0` for any `x ∈ L i` and `y ∈ L j` (`i ≠ j`) then this map is a morphism of Lie algebras. -/ @[simps] def toLieAlgebra [DecidableEq ι] (L' : Type w₁) [LieRing L'] [LieAlgebra R L'] (f : ∀ i, L i →ₗ⁅R⁆ L') (hf : Pairwise fun i j => ∀ (x : L i) (y : L j), ⁅f i x, f j y⁆ = 0) : (⨁ i, L i) →ₗ⁅R⁆ L' := { toModule R ι L' fun i => (f i : L i →ₗ[R] L') with toFun := toModule R ι L' fun i => (f i : L i →ₗ[R] L') map_lie' := fun {x y} => by let f' i := (f i : L i →ₗ[R] L') /- The goal is linear in `y`. We can use this to reduce to the case that `y` has only one non-zero component. -/ suffices ∀ (i : ι) (y : L i), toModule R ι L' f' ⁅x, of L i y⁆ = ⁅toModule R ι L' f' x, toModule R ι L' f' (of L i y)⁆ by simp only [← LieAlgebra.ad_apply R] rw [← LinearMap.comp_apply, ← LinearMap.comp_apply] congr; clear y; ext i y; exact this i y -- Similarly, we can reduce to the case that `x` has only one non-zero component. suffices ∀ (i j) (y : L i) (x : L j), toModule R ι L' f' ⁅of L j x, of L i y⁆ = ⁅toModule R ι L' f' (of L j x), toModule R ι L' f' (of L i y)⁆ by intro i y rw [← lie_skew x, ← lie_skew (toModule R ι L' f' x)] simp only [LinearMap.map_neg, neg_inj, ← LieAlgebra.ad_apply R] rw [← LinearMap.comp_apply, ← LinearMap.comp_apply] congr; clear x; ext j x; exact this j i x y intro i j y x simp only [f', coe_toModule_eq_coe_toAddMonoid, toAddMonoid_of] -- And finish with trivial case analysis. obtain rfl | hij := Decidable.eq_or_ne i j · simp_rw [lie_of_same, toAddMonoid_of, LinearMap.toAddMonoidHom_coe, LieHom.coe_toLinearMap, LieHom.map_lie] · simp_rw [lie_of_of_ne _ hij.symm, map_zero, LinearMap.toAddMonoidHom_coe, LieHom.coe_toLinearMap, hf hij.symm x y] } end Algebras section Ideals variable {L : Type w} [LieRing L] [LieAlgebra R L] (I : ι → LieIdeal R L) /-- The fact that this instance is necessary seems to be a bug in typeclass inference. See [this Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/ Typeclass.20resolution.20under.20binders/near/245151099). -/ instance lieRingOfIdeals : LieRing (⨁ i, I i) := DirectSum.lieRing fun i => ↥(I i) /-- See `DirectSum.lieRingOfIdeals` comment. -/ instance lieAlgebraOfIdeals : LieAlgebra R (⨁ i, I i) := DirectSum.lieAlgebra fun i => ↥(I i) end Ideals end DirectSum
Algebra\Lie\Engel.lean
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Nilpotent import Mathlib.Algebra.Lie.Normalizer /-! # Engel's theorem This file contains a proof of Engel's theorem providing necessary and sufficient conditions for Lie algebras and Lie modules to be nilpotent. The key result `LieModule.isNilpotent_iff_forall` says that if `M` is a Lie module of a Noetherian Lie algebra `L`, then `M` is nilpotent iff the image of `L → End(M)` consists of nilpotent elements. In the special case that we have the adjoint representation `M = L`, this says that a Lie algebra is nilpotent iff `ad x : End(L)` is nilpotent for all `x : L`. Engel's theorem is true for any coefficients (i.e., it is really a theorem about Lie rings) and so we work with coefficients in any commutative ring `R` throughout. On the other hand, Engel's theorem is not true for infinite-dimensional Lie algebras and so a finite-dimensionality assumption is required. We prove the theorem subject to the assumption that the Lie algebra is Noetherian as an `R`-module, though actually we only need the slightly weaker property that the relation `>` is well-founded on the complete lattice of Lie subalgebras. ## Remarks about the proof Engel's theorem is usually proved in the special case that the coefficients are a field, and uses an inductive argument on the dimension of the Lie algebra. One begins by choosing either a maximal proper Lie subalgebra (in some proofs) or a maximal nilpotent Lie subalgebra (in other proofs, at the cost of obtaining a weaker end result). Since we work with general coefficients, we cannot induct on dimension and an alternate approach must be taken. The key ingredient is the concept of nilpotency, not just for Lie algebras, but for Lie modules. Using this concept, we define an _Engelian Lie algebra_ `LieAlgebra.IsEngelian` to be one for which a Lie module is nilpotent whenever the action consists of nilpotent endomorphisms. The argument then proceeds by selecting a maximal Engelian Lie subalgebra and showing that it cannot be proper. The first part of the traditional statement of Engel's theorem consists of the statement that if `M` is a non-trivial `R`-module and `L ⊆ End(M)` is a finite-dimensional Lie subalgebra of nilpotent elements, then there exists a non-zero element `m : M` that is annihilated by every element of `L`. This follows trivially from the result established here `LieModule.isNilpotent_iff_forall`, that `M` is a nilpotent Lie module over `L`, since the last non-zero term in the lower central series will consist of such elements `m` (see: `LieModule.nontrivial_max_triv_of_isNilpotent`). It seems that this result has not previously been established at this level of generality. The second part of the traditional statement of Engel's theorem concerns nilpotency of the Lie algebra and a proof of this for general coefficients appeared in the literature as long ago [as 1937](zorn1937). This also follows trivially from `LieModule.isNilpotent_iff_forall` simply by taking `M = L`. It is pleasing that the two parts of the traditional statements of Engel's theorem are thus unified into a single statement about nilpotency of Lie modules. This is not usually emphasised. ## Main definitions * `LieAlgebra.IsEngelian` * `LieAlgebra.isEngelian_of_isNoetherian` * `LieModule.isNilpotent_iff_forall` * `LieAlgebra.isNilpotent_iff_forall` -/ universe u₁ u₂ u₃ u₄ variable {R : Type u₁} {L : Type u₂} {L₂ : Type u₃} {M : Type u₄} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L₂] [LieAlgebra R L₂] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieSubmodule open LieModule variable {I : LieIdeal R L} {x : L} (hxI : (R ∙ x) ⊔ I = ⊤) theorem exists_smul_add_of_span_sup_eq_top (y : L) : ∃ t : R, ∃ z ∈ I, y = t • x + z := by have hy : y ∈ (⊤ : Submodule R L) := Submodule.mem_top simp only [← hxI, Submodule.mem_sup, Submodule.mem_span_singleton] at hy obtain ⟨-, ⟨t, rfl⟩, z, hz, rfl⟩ := hy exact ⟨t, z, hz, rfl⟩ theorem lie_top_eq_of_span_sup_eq_top (N : LieSubmodule R L M) : (↑⁅(⊤ : LieIdeal R L), N⁆ : Submodule R M) = (N : Submodule R M).map (toEnd R L M x) ⊔ (↑⁅I, N⁆ : Submodule R M) := by simp only [lieIdeal_oper_eq_linear_span', Submodule.sup_span, mem_top, exists_prop, true_and, Submodule.map_coe, toEnd_apply_apply] refine le_antisymm (Submodule.span_le.mpr ?_) (Submodule.span_mono fun z hz => ?_) · rintro z ⟨y, n, hn : n ∈ N, rfl⟩ obtain ⟨t, z, hz, rfl⟩ := exists_smul_add_of_span_sup_eq_top hxI y simp only [SetLike.mem_coe, Submodule.span_union, Submodule.mem_sup] exact ⟨t • ⁅x, n⁆, Submodule.subset_span ⟨t • n, N.smul_mem' t hn, lie_smul t x n⟩, ⁅z, n⁆, Submodule.subset_span ⟨z, hz, n, hn, rfl⟩, by simp⟩ · rcases hz with (⟨m, hm, rfl⟩ | ⟨y, -, m, hm, rfl⟩) exacts [⟨x, m, hm, rfl⟩, ⟨y, m, hm, rfl⟩] theorem lcs_le_lcs_of_is_nilpotent_span_sup_eq_top {n i j : ℕ} (hxn : toEnd R L M x ^ n = 0) (hIM : lowerCentralSeries R L M i ≤ I.lcs M j) : lowerCentralSeries R L M (i + n) ≤ I.lcs M (j + 1) := by suffices ∀ l, ((⊤ : LieIdeal R L).lcs M (i + l) : Submodule R M) ≤ (I.lcs M j : Submodule R M).map (toEnd R L M x ^ l) ⊔ (I.lcs M (j + 1) : Submodule R M) by simpa only [bot_sup_eq, LieIdeal.incl_coe, Submodule.map_zero, hxn] using this n intro l induction' l with l ih · simp only [Nat.zero_eq, add_zero, LieIdeal.lcs_succ, pow_zero, LinearMap.one_eq_id, Submodule.map_id] exact le_sup_of_le_left hIM · simp only [LieIdeal.lcs_succ, i.add_succ l, lie_top_eq_of_span_sup_eq_top hxI, sup_le_iff] refine ⟨(Submodule.map_mono ih).trans ?_, le_sup_of_le_right ?_⟩ · rw [Submodule.map_sup, ← Submodule.map_comp, ← LinearMap.mul_eq_comp, ← pow_succ', ← I.lcs_succ] exact sup_le_sup_left coe_map_toEnd_le _ · refine le_trans (mono_lie_right I ?_) (mono_lie_right I hIM) exact antitone_lowerCentralSeries R L M le_self_add theorem isNilpotentOfIsNilpotentSpanSupEqTop (hnp : IsNilpotent <| toEnd R L M x) (hIM : IsNilpotent R I M) : IsNilpotent R L M := by obtain ⟨n, hn⟩ := hnp obtain ⟨k, hk⟩ := hIM have hk' : I.lcs M k = ⊥ := by simp only [← coe_toSubmodule_eq_iff, I.coe_lcs_eq, hk, bot_coeSubmodule] suffices ∀ l, lowerCentralSeries R L M (l * n) ≤ I.lcs M l by use k * n simpa [hk'] using this k intro l induction' l with l ih · simp · exact (l.succ_mul n).symm ▸ lcs_le_lcs_of_is_nilpotent_span_sup_eq_top hxI hn ih end LieSubmodule section LieAlgebra -- Porting note: somehow this doesn't hide `LieModule.IsNilpotent`, so `_root_.IsNilpotent` is used -- a number of times below. open LieModule hiding IsNilpotent variable (R L) /-- A Lie algebra `L` is said to be Engelian if a sufficient condition for any `L`-Lie module `M` to be nilpotent is that the image of the map `L → End(M)` consists of nilpotent elements. Engel's theorem `LieAlgebra.isEngelian_of_isNoetherian` states that any Noetherian Lie algebra is Engelian. -/ def LieAlgebra.IsEngelian : Prop := ∀ (M : Type u₄) [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M], (∀ x : L, _root_.IsNilpotent (toEnd R L M x)) → LieModule.IsNilpotent R L M variable {R L} theorem LieAlgebra.isEngelian_of_subsingleton [Subsingleton L] : LieAlgebra.IsEngelian R L := by intro M _i1 _i2 _i3 _i4 _h use 1 suffices (⊤ : LieIdeal R L) = ⊥ by simp [this] subsingleton [(LieSubmodule.subsingleton_iff R L L).mpr inferInstance] theorem Function.Surjective.isEngelian {f : L →ₗ⁅R⁆ L₂} (hf : Function.Surjective f) (h : LieAlgebra.IsEngelian.{u₁, u₂, u₄} R L) : LieAlgebra.IsEngelian.{u₁, u₃, u₄} R L₂ := by intro M _i1 _i2 _i3 _i4 h' letI : LieRingModule L M := LieRingModule.compLieHom M f letI : LieModule R L M := compLieHom M f have hnp : ∀ x, IsNilpotent (toEnd R L M x) := fun x => h' (f x) have surj_id : Function.Surjective (LinearMap.id : M →ₗ[R] M) := Function.surjective_id haveI : LieModule.IsNilpotent R L M := h M hnp apply hf.lieModuleIsNilpotent surj_id -- porting note (#10745): was `simp` intros; simp only [LinearMap.id_coe, id_eq]; rfl theorem LieEquiv.isEngelian_iff (e : L ≃ₗ⁅R⁆ L₂) : LieAlgebra.IsEngelian.{u₁, u₂, u₄} R L ↔ LieAlgebra.IsEngelian.{u₁, u₃, u₄} R L₂ := ⟨e.surjective.isEngelian, e.symm.surjective.isEngelian⟩ -- Porting note: changed statement from `∃ ∃ ..` to `∃ .. ∧ ..` theorem LieAlgebra.exists_engelian_lieSubalgebra_of_lt_normalizer {K : LieSubalgebra R L} (hK₁ : LieAlgebra.IsEngelian.{u₁, u₂, u₄} R K) (hK₂ : K < K.normalizer) : ∃ (K' : LieSubalgebra R L), LieAlgebra.IsEngelian.{u₁, u₂, u₄} R K' ∧ K < K' := by obtain ⟨x, hx₁, hx₂⟩ := SetLike.exists_of_lt hK₂ let K' : LieSubalgebra R L := { (R ∙ x) ⊔ (K : Submodule R L) with lie_mem' := fun {y z} => LieSubalgebra.lie_mem_sup_of_mem_normalizer hx₁ } have hxK' : x ∈ K' := Submodule.mem_sup_left (Submodule.subset_span (Set.mem_singleton _)) have hKK' : K ≤ K' := (LieSubalgebra.coe_submodule_le_coe_submodule K K').mp le_sup_right have hK' : K' ≤ K.normalizer := by rw [← LieSubalgebra.coe_submodule_le_coe_submodule] exact sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx₁) hK₂.le refine ⟨K', ?_, lt_iff_le_and_ne.mpr ⟨hKK', fun contra => hx₂ (contra.symm ▸ hxK')⟩⟩ intro M _i1 _i2 _i3 _i4 h obtain ⟨I, hI₁ : (I : LieSubalgebra R K') = LieSubalgebra.ofLe hKK'⟩ := LieSubalgebra.exists_nested_lieIdeal_ofLe_normalizer hKK' hK' have hI₂ : (R ∙ (⟨x, hxK'⟩ : K')) ⊔ (LieSubmodule.toSubmodule I) = ⊤ := by rw [← LieIdeal.coe_to_lieSubalgebra_to_submodule R K' I, hI₁] apply Submodule.map_injective_of_injective (K' : Submodule R L).injective_subtype simp have e : K ≃ₗ⁅R⁆ I := (LieSubalgebra.equivOfLe hKK').trans (LieEquiv.ofEq _ _ ((LieSubalgebra.coe_set_eq _ _).mpr hI₁.symm)) have hI₃ : LieAlgebra.IsEngelian R I := e.isEngelian_iff.mp hK₁ exact LieSubmodule.isNilpotentOfIsNilpotentSpanSupEqTop hI₂ (h _) (hI₃ _ fun x => h x) attribute [local instance] LieSubalgebra.subsingleton_bot /-- *Engel's theorem*. Note that this implies all traditional forms of Engel's theorem via `LieModule.nontrivial_max_triv_of_isNilpotent`, `LieModule.isNilpotent_iff_forall`, `LieAlgebra.isNilpotent_iff_forall`. -/ theorem LieAlgebra.isEngelian_of_isNoetherian [IsNoetherian R L] : LieAlgebra.IsEngelian R L := by intro M _i1 _i2 _i3 _i4 h rw [← isNilpotent_range_toEnd_iff] let L' := (toEnd R L M).range replace h : ∀ y : L', _root_.IsNilpotent (y : Module.End R M) := by rintro ⟨-, ⟨y, rfl⟩⟩ simp [h] change LieModule.IsNilpotent R L' M let s := {K : LieSubalgebra R L' | LieAlgebra.IsEngelian R K} have hs : s.Nonempty := ⟨⊥, LieAlgebra.isEngelian_of_subsingleton⟩ suffices ⊤ ∈ s by rw [← isNilpotent_of_top_iff] apply this M simp [LieSubalgebra.toEnd_eq, h] have : ∀ K ∈ s, K ≠ ⊤ → ∃ K' ∈ s, K < K' := by rintro K (hK₁ : LieAlgebra.IsEngelian R K) hK₂ apply LieAlgebra.exists_engelian_lieSubalgebra_of_lt_normalizer hK₁ apply lt_of_le_of_ne K.le_normalizer rw [Ne, eq_comm, K.normalizer_eq_self_iff, ← Ne, ← LieSubmodule.nontrivial_iff_ne_bot R K] have : Nontrivial (L' ⧸ K.toLieSubmodule) := by replace hK₂ : K.toLieSubmodule ≠ ⊤ := by rwa [Ne, ← LieSubmodule.coe_toSubmodule_eq_iff, K.coe_toLieSubmodule, LieSubmodule.top_coeSubmodule, ← LieSubalgebra.top_coe_submodule, K.coe_to_submodule_eq_iff] exact Submodule.Quotient.nontrivial_of_lt_top _ hK₂.lt_top have : LieModule.IsNilpotent R K (L' ⧸ K.toLieSubmodule) := by -- Porting note: was refine' hK₁ _ fun x => _ apply hK₁ intro x have hx := LieAlgebra.isNilpotent_ad_of_isNilpotent (h x) apply Module.End.IsNilpotent.mapQ ?_ hx -- Porting note: mathlib3 solved this on its own with `submodule.mapq_linear._proof_5` intro X HX simp only [LieSubalgebra.coe_toLieSubmodule, LieSubalgebra.mem_coe_submodule] at HX simp only [LieSubalgebra.coe_toLieSubmodule, Submodule.mem_comap, ad_apply, LieSubalgebra.mem_coe_submodule] exact LieSubalgebra.lie_mem K x.prop HX exact nontrivial_max_triv_of_isNilpotent R K (L' ⧸ K.toLieSubmodule) haveI _i5 : IsNoetherian R L' := by -- Porting note: was -- isNoetherian_of_surjective L _ (LinearMap.range_rangeRestrict (toEnd R L M)) -- abusing the relation between `LieHom.rangeRestrict` and `LinearMap.rangeRestrict` refine isNoetherian_of_surjective L (LieHom.rangeRestrict (toEnd R L M)) ?_ simp only [LieHom.range_coeSubmodule, LieHom.coe_toLinearMap, LinearMap.range_eq_top] exact LieHom.surjective_rangeRestrict (toEnd R L M) obtain ⟨K, hK₁, hK₂⟩ := (LieSubalgebra.wellFounded_of_noetherian R L').has_min s hs have hK₃ : K = ⊤ := by by_contra contra obtain ⟨K', hK'₁, hK'₂⟩ := this K hK₁ contra exact hK₂ K' hK'₁ hK'₂ exact hK₃ ▸ hK₁ /-- Engel's theorem. See also `LieModule.isNilpotent_iff_forall'` which assumes that `M` is Noetherian instead of `L`. -/ theorem LieModule.isNilpotent_iff_forall [IsNoetherian R L] : LieModule.IsNilpotent R L M ↔ ∀ x, _root_.IsNilpotent <| toEnd R L M x := ⟨fun _ ↦ isNilpotent_toEnd_of_isNilpotent R L M, fun h => LieAlgebra.isEngelian_of_isNoetherian M h⟩ /-- Engel's theorem. -/ theorem LieModule.isNilpotent_iff_forall' [IsNoetherian R M] : LieModule.IsNilpotent R L M ↔ ∀ x, _root_.IsNilpotent <| toEnd R L M x := by rw [← isNilpotent_range_toEnd_iff, LieModule.isNilpotent_iff_forall]; simp /-- Engel's theorem. -/ theorem LieAlgebra.isNilpotent_iff_forall [IsNoetherian R L] : LieAlgebra.IsNilpotent R L ↔ ∀ x, _root_.IsNilpotent <| LieAlgebra.ad R L x := LieModule.isNilpotent_iff_forall end LieAlgebra
Algebra\Lie\EngelSubalgebra.lean
/- Copyright (c) 2024 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Lie.Engel import Mathlib.Algebra.Lie.Normalizer import Mathlib.Algebra.Lie.OfAssociative import Mathlib.Algebra.Lie.Subalgebra import Mathlib.Data.Finset.NatAntidiagonal /-! # Engel subalgebras This file defines Engel subalgebras of a Lie algebra and provides basic related properties. The Engel subalgebra `LieSubalgebra.Engel R x` consists of all `y : L` such that `(ad R L x)^n` kills `y` for some `n`. ## Main results Engel subalgebras are self-normalizing (`LieSubalgebra.normalizer_engel`), and minimal ones are nilpotent (TODO), hence Cartan subalgebras. * `LieSubalgebra.normalizer_eq_self_of_engel_le`: Lie subalgebras containing an Engel subalgebra are self-normalizing, provided the ambient Lie algebra is Artinian. * `LieSubalgebra.isNilpotent_of_forall_le_engel`: A Lie subalgebra of a Noetherian Lie algebra is nilpotent if it is contained in the Engel subalgebra of all its elements. -/ open LieAlgebra LieModule variable {R L M : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieSubalgebra variable (R) /-- The Engel subalgebra `Engel R x` consists of all `y : L` such that `(ad R L x)^n` kills `y` for some `n`. Engel subalgebras are self-normalizing (`LieSubalgebra.normalizer_engel`), and minimal ones are nilpotent, hence Cartan subalgebras. -/ @[simps!] def engel (x : L) : LieSubalgebra R L := { (ad R L x).maxGenEigenspace 0 with lie_mem' := by simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, Module.End.mem_maxGenEigenspace, zero_smul, sub_zero, forall_exists_index] intro y z m hm n hn refine ⟨m + n, ?_⟩ rw [ad_pow_lie] apply Finset.sum_eq_zero intro ij hij obtain (h|h) : m ≤ ij.1 ∨ n ≤ ij.2 := by rw [Finset.mem_antidiagonal] at hij; omega all_goals simp [LinearMap.pow_map_zero_of_le h, hm, hn] } lemma mem_engel_iff (x y : L) : y ∈ engel R x ↔ ∃ n : ℕ, ((ad R L x) ^ n) y = 0 := (Module.End.mem_maxGenEigenspace _ _ _).trans <| by simp only [zero_smul, sub_zero] lemma self_mem_engel (x : L) : x ∈ engel R x := by simp only [mem_engel_iff] exact ⟨1, by simp⟩ @[simp] lemma engel_zero : engel R (0 : L) = ⊤ := by rw [eq_top_iff] rintro x - rw [mem_engel_iff, LieHom.map_zero] use 1 simp only [pow_one, LinearMap.zero_apply] /-- Engel subalgebras are self-normalizing. See `LieSubalgebra.normalizer_eq_self_of_engel_le` for a proof that Lie-subalgebras containing an Engel subalgebra are also self-normalizing, provided that the ambient Lie algebra is artinina. -/ @[simp] lemma normalizer_engel (x : L) : normalizer (engel R x) = engel R x := by apply le_antisymm _ (le_normalizer _) intro y hy rw [mem_normalizer_iff] at hy specialize hy x (self_mem_engel R x) rw [← lie_skew, neg_mem_iff (G := L), mem_engel_iff] at hy rcases hy with ⟨n, hn⟩ rw [mem_engel_iff] use n+1 rw [pow_succ, LinearMap.mul_apply] exact hn variable {R} open Filter in /-- A Lie-subalgebra of an Artinian Lie algebra is self-normalizing if it contains an Engel subalgebra. See `LieSubalgebra.normalizer_engel` for a proof that Engel subalgebras are self-normalizing, avoiding the Artinian condition. -/ lemma normalizer_eq_self_of_engel_le [IsArtinian R L] (H : LieSubalgebra R L) (x : L) (h : engel R x ≤ H) : normalizer H = H := by set N := normalizer H apply le_antisymm _ (le_normalizer H) calc N.toSubmodule ≤ (engel R x).toSubmodule ⊔ H.toSubmodule := ?_ _ = H := by rwa [sup_eq_right] have aux₁ : ∀ n ∈ N, ⁅x, n⁆ ∈ H := by intro n hn rw [mem_normalizer_iff] at hn specialize hn x (h (self_mem_engel R x)) rwa [← lie_skew, neg_mem_iff (G := L)] have aux₂ : ∀ n ∈ N, ⁅x, n⁆ ∈ N := fun n hn ↦ le_normalizer H (aux₁ _ hn) let dx : N →ₗ[R] N := (ad R L x).restrict aux₂ obtain ⟨k, hk⟩ : ∃ a, ∀ b ≥ a, Codisjoint (LinearMap.ker (dx ^ b)) (LinearMap.range (dx ^ b)) := eventually_atTop.mp <| dx.eventually_codisjoint_ker_pow_range_pow specialize hk (k+1) (Nat.le_add_right k 1) rw [← Submodule.map_subtype_top N.toSubmodule, Submodule.map_le_iff_le_comap] apply hk · rw [← Submodule.map_le_iff_le_comap] apply le_sup_of_le_left rw [Submodule.map_le_iff_le_comap] intro y hy simp only [Submodule.mem_comap, mem_engel_iff, mem_coe_submodule] use k+1 clear hk; revert hy generalize k+1 = k induction k generalizing y with | zero => cases y; intro hy; simpa using hy | succ k ih => simp only [pow_succ, LinearMap.mem_ker, LinearMap.mul_apply] at ih ⊢; apply ih · rw [← Submodule.map_le_iff_le_comap] apply le_sup_of_le_right rw [Submodule.map_le_iff_le_comap] rintro _ ⟨y, rfl⟩ simp only [pow_succ', LinearMap.mul_apply, Submodule.mem_comap, mem_coe_submodule] apply aux₁ simp only [Submodule.coeSubtype, SetLike.coe_mem] /-- A Lie subalgebra of a Noetherian Lie algebra is nilpotent if it is contained in the Engel subalgebra of all its elements. -/ lemma isNilpotent_of_forall_le_engel [IsNoetherian R L] (H : LieSubalgebra R L) (h : ∀ x ∈ H, H ≤ engel R x) : LieAlgebra.IsNilpotent R H := by rw [LieAlgebra.isNilpotent_iff_forall] intro x let K : ℕ →o Submodule R H := ⟨fun n ↦ LinearMap.ker ((ad R H x) ^ n), fun m n hmn ↦ ?mono⟩ case mono => intro y hy rw [LinearMap.mem_ker] at hy ⊢ exact LinearMap.pow_map_zero_of_le hmn hy obtain ⟨n, hn⟩ := monotone_stabilizes_iff_noetherian.mpr inferInstance K use n ext y rw [coe_ad_pow] specialize h x x.2 y.2 rw [mem_engel_iff] at h obtain ⟨m, hm⟩ := h obtain (hmn|hmn) : m ≤ n ∨ n ≤ m := le_total m n · exact LinearMap.pow_map_zero_of_le hmn hm · have : ∀ k : ℕ, ((ad R L) x ^ k) y = 0 ↔ y ∈ K k := by simp [K, Subtype.ext_iff, coe_ad_pow] rwa [this, ← hn m hmn, ← this] at hm end LieSubalgebra
Algebra\Lie\Free.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.FreeNonUnitalNonAssocAlgebra import Mathlib.Algebra.Lie.NonUnitalNonAssocAlgebra import Mathlib.Algebra.Lie.UniversalEnveloping import Mathlib.GroupTheory.GroupAction.Ring /-! # Free Lie algebras Given a commutative ring `R` and a type `X` we construct the free Lie algebra on `X` with coefficients in `R` together with its universal property. ## Main definitions * `FreeLieAlgebra` * `FreeLieAlgebra.lift` * `FreeLieAlgebra.of` * `FreeLieAlgebra.universalEnvelopingEquivFreeAlgebra` ## Implementation details ### Quotient of free non-unital, non-associative algebra We follow [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975) and construct the free Lie algebra as a quotient of the free non-unital, non-associative algebra. Since we do not currently have definitions of ideals, lattices of ideals, and quotients for `NonUnitalNonAssocSemiring`, we construct our quotient using the low-level `Quot` function on an inductively-defined relation. ### Alternative construction (needs PBW) An alternative construction of the free Lie algebra on `X` is to start with the free unital associative algebra on `X`, regard it as a Lie algebra via the ring commutator, and take its smallest Lie subalgebra containing `X`. I.e.: `LieSubalgebra.lieSpan R (FreeAlgebra R X) (Set.range (FreeAlgebra.ι R))`. However with this definition there does not seem to be an easy proof that the required universal property holds, and I don't know of a proof that avoids invoking the Poincaré–Birkhoff–Witt theorem. A related MathOverflow question is [this one](https://mathoverflow.net/questions/396680/). ## Tags lie algebra, free algebra, non-unital, non-associative, universal property, forgetful functor, adjoint functor -/ universe u v w noncomputable section variable (R : Type u) (X : Type v) [CommRing R] /- We save characters by using Bourbaki's name `lib` (as in «libre») for `FreeNonUnitalNonAssocAlgebra` in this file. -/ local notation "lib" => FreeNonUnitalNonAssocAlgebra local notation "lib.lift" => FreeNonUnitalNonAssocAlgebra.lift local notation "lib.of" => FreeNonUnitalNonAssocAlgebra.of local notation "lib.lift_of_apply" => FreeNonUnitalNonAssocAlgebra.lift_of_apply local notation "lib.lift_comp_of" => FreeNonUnitalNonAssocAlgebra.lift_comp_of namespace FreeLieAlgebra /-- The quotient of `lib R X` by the equivalence relation generated by this relation will give us the free Lie algebra. -/ inductive Rel : lib R X → lib R X → Prop | lie_self (a : lib R X) : Rel (a * a) 0 | leibniz_lie (a b c : lib R X) : Rel (a * (b * c)) (a * b * c + b * (a * c)) | smul (t : R) {a b : lib R X} : Rel a b → Rel (t • a) (t • b) | add_right {a b : lib R X} (c : lib R X) : Rel a b → Rel (a + c) (b + c) | mul_left (a : lib R X) {b c : lib R X} : Rel b c → Rel (a * b) (a * c) | mul_right {a b : lib R X} (c : lib R X) : Rel a b → Rel (a * c) (b * c) variable {R X} theorem Rel.addLeft (a : lib R X) {b c : lib R X} (h : Rel R X b c) : Rel R X (a + b) (a + c) := by rw [add_comm _ b, add_comm _ c]; exact h.add_right _ theorem Rel.neg {a b : lib R X} (h : Rel R X a b) : Rel R X (-a) (-b) := by simpa only [neg_one_smul] using h.smul (-1) theorem Rel.subLeft (a : lib R X) {b c : lib R X} (h : Rel R X b c) : Rel R X (a - b) (a - c) := by simpa only [sub_eq_add_neg] using h.neg.addLeft a theorem Rel.subRight {a b : lib R X} (c : lib R X) (h : Rel R X a b) : Rel R X (a - c) (b - c) := by simpa only [sub_eq_add_neg] using h.add_right (-c) theorem Rel.smulOfTower {S : Type*} [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] (t : S) (a b : lib R X) (h : Rel R X a b) : Rel R X (t • a) (t • b) := by rw [← smul_one_smul R t a, ← smul_one_smul R t b] exact h.smul _ end FreeLieAlgebra /-- The free Lie algebra on the type `X` with coefficients in the commutative ring `R`. -/ def FreeLieAlgebra := Quot (FreeLieAlgebra.Rel R X) instance : Inhabited (FreeLieAlgebra R X) := by rw [FreeLieAlgebra]; infer_instance namespace FreeLieAlgebra instance {S : Type*} [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] : SMul S (FreeLieAlgebra R X) where smul t := Quot.map (t • ·) (Rel.smulOfTower t) instance {S : Type*} [Monoid S] [DistribMulAction S R] [DistribMulAction Sᵐᵒᵖ R] [IsScalarTower S R R] [IsCentralScalar S R] : IsCentralScalar S (FreeLieAlgebra R X) where op_smul_eq_smul t := Quot.ind fun a => congr_arg (Quot.mk _) (op_smul_eq_smul t a) instance : Zero (FreeLieAlgebra R X) where zero := Quot.mk _ 0 instance : Add (FreeLieAlgebra R X) where add := Quot.map₂ (· + ·) (fun _ _ _ => Rel.addLeft _) fun _ _ _ => Rel.add_right _ instance : Neg (FreeLieAlgebra R X) where neg := Quot.map Neg.neg fun _ _ => Rel.neg instance : Sub (FreeLieAlgebra R X) where sub := Quot.map₂ Sub.sub (fun _ _ _ => Rel.subLeft _) fun _ _ _ => Rel.subRight _ instance : AddGroup (FreeLieAlgebra R X) := Function.Surjective.addGroup (Quot.mk _) (surjective_quot_mk _) rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl instance : AddCommSemigroup (FreeLieAlgebra R X) := Function.Surjective.addCommSemigroup (Quot.mk _) (surjective_quot_mk _) fun _ _ => rfl instance : AddCommGroup (FreeLieAlgebra R X) := { (inferInstance : AddGroup (FreeLieAlgebra R X)), (inferInstance : AddCommSemigroup (FreeLieAlgebra R X)) with } instance {S : Type*} [Semiring S] [Module S R] [IsScalarTower S R R] : Module S (FreeLieAlgebra R X) := Function.Surjective.module S ⟨⟨Quot.mk (Rel R X), rfl⟩, fun _ _ => rfl⟩ (surjective_quot_mk _) (fun _ _ => rfl) /-- Note that here we turn the `Mul` coming from the `NonUnitalNonAssocSemiring` structure on `lib R X` into a `Bracket` on `FreeLieAlgebra`. -/ instance : LieRing (FreeLieAlgebra R X) where bracket := Quot.map₂ (· * ·) (fun _ _ _ => Rel.mul_left _) fun _ _ _ => Rel.mul_right _ add_lie := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; change Quot.mk _ _ = Quot.mk _ _; simp_rw [add_mul] lie_add := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; change Quot.mk _ _ = Quot.mk _ _; simp_rw [mul_add] lie_self := by rintro ⟨a⟩; exact Quot.sound (Rel.lie_self a) leibniz_lie := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; exact Quot.sound (Rel.leibniz_lie a b c) instance : LieAlgebra R (FreeLieAlgebra R X) where lie_smul := by rintro t ⟨a⟩ ⟨c⟩ change Quot.mk _ (a • t • c) = Quot.mk _ (t • a • c) rw [← smul_comm] variable {X} /-- The embedding of `X` into the free Lie algebra of `X` with coefficients in the commutative ring `R`. -/ def of : X → FreeLieAlgebra R X := fun x => Quot.mk _ (lib.of R x) variable {L : Type w} [LieRing L] [LieAlgebra R L] /-- An auxiliary definition used to construct the equivalence `lift` below. -/ def liftAux (f : X → CommutatorRing L) := lib.lift R f theorem liftAux_map_smul (f : X → L) (t : R) (a : lib R X) : liftAux R f (t • a) = t • liftAux R f a := NonUnitalAlgHom.map_smul _ t a theorem liftAux_map_add (f : X → L) (a b : lib R X) : liftAux R f (a + b) = liftAux R f a + liftAux R f b := NonUnitalAlgHom.map_add _ a b theorem liftAux_map_mul (f : X → L) (a b : lib R X) : liftAux R f (a * b) = ⁅liftAux R f a, liftAux R f b⁆ := NonUnitalAlgHom.map_mul _ a b theorem liftAux_spec (f : X → L) (a b : lib R X) (h : FreeLieAlgebra.Rel R X a b) : liftAux R f a = liftAux R f b := by induction h with | lie_self a' => simp only [liftAux_map_mul, NonUnitalAlgHom.map_zero, lie_self] | leibniz_lie a' b' c' => simp only [liftAux_map_mul, liftAux_map_add, sub_add_cancel, lie_lie] | smul b' _ h₂ => simp only [liftAux_map_smul, h₂] | add_right c' _ h₂ => simp only [liftAux_map_add, h₂] | mul_left c' _ h₂ => simp only [liftAux_map_mul, h₂] | mul_right c' _ h₂ => simp only [liftAux_map_mul, h₂] /-- The quotient map as a `NonUnitalAlgHom`. -/ def mk : lib R X →ₙₐ[R] CommutatorRing (FreeLieAlgebra R X) where toFun := Quot.mk (Rel R X) map_smul' _ _ := rfl map_zero' := rfl map_add' _ _ := rfl map_mul' _ _ := rfl /-- The functor `X ↦ FreeLieAlgebra R X` from the category of types to the category of Lie algebras over `R` is adjoint to the forgetful functor in the other direction. -/ def lift : (X → L) ≃ (FreeLieAlgebra R X →ₗ⁅R⁆ L) where toFun f := { toFun := fun c => Quot.liftOn c (liftAux R f) (liftAux_spec R f) map_add' := by rintro ⟨a⟩ ⟨b⟩; rw [← liftAux_map_add]; rfl map_smul' := by rintro t ⟨a⟩; rw [← liftAux_map_smul]; rfl map_lie' := by rintro ⟨a⟩ ⟨b⟩; rw [← liftAux_map_mul]; rfl } invFun F := F ∘ of R left_inv f := by ext x simp only [liftAux, of, Quot.liftOn_mk, LieHom.coe_mk, Function.comp_apply, lib.lift_of_apply] right_inv F := by ext ⟨a⟩ let F' := F.toNonUnitalAlgHom.comp (mk R) exact NonUnitalAlgHom.congr_fun (lib.lift_comp_of R F') a @[simp] theorem lift_symm_apply (F : FreeLieAlgebra R X →ₗ⁅R⁆ L) : (lift R).symm F = F ∘ of R := rfl variable {R} @[simp] theorem of_comp_lift (f : X → L) : lift R f ∘ of R = f := (lift R).left_inv f @[simp] theorem lift_unique (f : X → L) (g : FreeLieAlgebra R X →ₗ⁅R⁆ L) : g ∘ of R = f ↔ g = lift R f := (lift R).symm_apply_eq @[simp] theorem lift_of_apply (f : X → L) (x) : lift R f (of R x) = f x := by rw [← @Function.comp_apply _ _ _ (lift R f) (of R) x, of_comp_lift] @[simp] theorem lift_comp_of (F : FreeLieAlgebra R X →ₗ⁅R⁆ L) : lift R (F ∘ of R) = F := by rw [← lift_symm_apply]; exact (lift R).apply_symm_apply F @[ext] theorem hom_ext {F₁ F₂ : FreeLieAlgebra R X →ₗ⁅R⁆ L} (h : ∀ x, F₁ (of R x) = F₂ (of R x)) : F₁ = F₂ := have h' : (lift R).symm F₁ = (lift R).symm F₂ := by ext; simp [h] (lift R).symm.injective h' variable (R X) /-- The universal enveloping algebra of the free Lie algebra is just the free unital associative algebra. -/ @[simps!] def universalEnvelopingEquivFreeAlgebra : UniversalEnvelopingAlgebra R (FreeLieAlgebra R X) ≃ₐ[R] FreeAlgebra R X := AlgEquiv.ofAlgHom (UniversalEnvelopingAlgebra.lift R <| FreeLieAlgebra.lift R <| FreeAlgebra.ι R) (FreeAlgebra.lift R <| UniversalEnvelopingAlgebra.ι R ∘ FreeLieAlgebra.of R) (by ext; simp) (by ext; simp) end FreeLieAlgebra
Algebra\Lie\IdealOperations.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Submodule /-! # Ideal operations for Lie algebras Given a Lie module `M` over a Lie algebra `L`, there is a natural action of the Lie ideals of `L` on the Lie submodules of `M`. In the special case that `M = L` with the adjoint action, this provides a pairing of Lie ideals which is especially important. For example, it can be used to define solvability / nilpotency of a Lie algebra via the derived / lower-central series. ## Main definitions * `LieSubmodule.hasBracket` * `LieSubmodule.lieIdeal_oper_eq_linear_span` * `LieIdeal.map_bracket_le` * `LieIdeal.comap_bracket_le` ## Notation Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N ⊆ M` and a Lie ideal `I ⊆ L`, we introduce the notation `⁅I, N⁆` for the Lie submodule of `M` corresponding to the action defined in this file. ## Tags lie algebra, ideal operation -/ universe u v w w₁ w₂ namespace LieSubmodule variable {R : Type u} {L : Type v} {M : Type w} {M₂ : Type w₁} variable [CommRing R] [LieRing L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] variable [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] variable (N N' : LieSubmodule R L M) (N₂ : LieSubmodule R L M₂) variable (f : M →ₗ⁅R,L⁆ M₂) section LieIdealOperations theorem map_comap_le : map f (comap f N₂) ≤ N₂ := (N₂ : Set M₂).image_preimage_subset f theorem map_comap_eq (hf : N₂ ≤ f.range) : map f (comap f N₂) = N₂ := by rw [SetLike.ext'_iff] exact Set.image_preimage_eq_of_subset hf theorem le_comap_map : N ≤ comap f (map f N) := (N : Set M).subset_preimage_image f theorem comap_map_eq (hf : f.ker = ⊥) : comap f (map f N) = N := by rw [SetLike.ext'_iff] exact (N : Set M).preimage_image_eq (f.ker_eq_bot.mp hf) @[simp] theorem map_comap_incl : map N.incl (comap N.incl N') = N ⊓ N' := by rw [← coe_toSubmodule_eq_iff] exact (N : Submodule R M).map_comap_subtype N' variable [LieAlgebra R L] [LieModule R L M₂] (I J : LieIdeal R L) /-- Given a Lie module `M` over a Lie algebra `L`, the set of Lie ideals of `L` acts on the set of submodules of `M`. -/ instance hasBracket : Bracket (LieIdeal R L) (LieSubmodule R L M) := ⟨fun I N => lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m }⟩ theorem lieIdeal_oper_eq_span : ⁅I, N⁆ = lieSpan R L { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } := rfl /-- See also `LieSubmodule.lieIdeal_oper_eq_linear_span'` and `LieSubmodule.lieIdeal_oper_eq_tensor_map_range`. -/ theorem lieIdeal_oper_eq_linear_span [LieModule R L M] : (↑⁅I, N⁆ : Submodule R M) = Submodule.span R { m | ∃ (x : I) (n : N), ⁅(x : L), (n : M)⁆ = m } := by apply le_antisymm · let s := { m : M | ∃ (x : ↥I) (n : ↥N), ⁅(x : L), (n : M)⁆ = m } have aux : ∀ (y : L), ∀ m' ∈ Submodule.span R s, ⁅y, m'⁆ ∈ Submodule.span R s := by intro y m' hm' refine Submodule.span_induction (R := R) (M := M) (s := s) (p := fun m' ↦ ⁅y, m'⁆ ∈ Submodule.span R s) hm' ?_ ?_ ?_ ?_ · rintro m'' ⟨x, n, hm''⟩; rw [← hm'', leibniz_lie] refine Submodule.add_mem _ ?_ ?_ <;> apply Submodule.subset_span · use ⟨⁅y, ↑x⁆, I.lie_mem x.property⟩, n · use x, ⟨⁅y, ↑n⁆, N.lie_mem n.property⟩ · simp only [lie_zero, Submodule.zero_mem] · intro m₁ m₂ hm₁ hm₂; rw [lie_add]; exact Submodule.add_mem _ hm₁ hm₂ · intro t m'' hm''; rw [lie_smul]; exact Submodule.smul_mem _ t hm'' change _ ≤ ({ Submodule.span R s with lie_mem := fun hm' => aux _ _ hm' } : LieSubmodule R L M) rw [lieIdeal_oper_eq_span, lieSpan_le] exact Submodule.subset_span · rw [lieIdeal_oper_eq_span]; apply submodule_span_le_lieSpan theorem lieIdeal_oper_eq_linear_span' [LieModule R L M] : (↑⁅I, N⁆ : Submodule R M) = Submodule.span R { m | ∃ x ∈ I, ∃ n ∈ N, ⁅x, n⁆ = m } := by rw [lieIdeal_oper_eq_linear_span] congr ext m constructor · rintro ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ exact ⟨x, hx, n, hn, rfl⟩ · rintro ⟨x, hx, n, hn, rfl⟩ exact ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩ theorem lie_le_iff : ⁅I, N⁆ ≤ N' ↔ ∀ x ∈ I, ∀ m ∈ N, ⁅x, m⁆ ∈ N' := by rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] refine ⟨fun h x hx m hm => h ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, ?_⟩ rintro h _ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩ exact h x hx m hm variable {N I} in theorem lie_coe_mem_lie (x : I) (m : N) : ⁅(x : L), (m : M)⁆ ∈ ⁅I, N⁆ := by rw [lieIdeal_oper_eq_span]; apply subset_lieSpan; use x, m variable {N I} in theorem lie_mem_lie {x : L} {m : M} (hx : x ∈ I) (hm : m ∈ N) : ⁅x, m⁆ ∈ ⁅I, N⁆ := lie_coe_mem_lie ⟨x, hx⟩ ⟨m, hm⟩ theorem lie_comm : ⁅I, J⁆ = ⁅J, I⁆ := by suffices ∀ I J : LieIdeal R L, ⁅I, J⁆ ≤ ⁅J, I⁆ by exact le_antisymm (this I J) (this J I) clear! I J; intro I J rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro x ⟨y, z, h⟩; rw [← h] rw [← lie_skew, ← lie_neg, ← LieSubmodule.coe_neg] apply lie_coe_mem_lie theorem lie_le_right : ⁅I, N⁆ ≤ N := by rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro m ⟨x, n, hn⟩; rw [← hn] exact N.lie_mem n.property theorem lie_le_left : ⁅I, J⁆ ≤ I := by rw [lie_comm]; exact lie_le_right I J theorem lie_le_inf : ⁅I, J⁆ ≤ I ⊓ J := by rw [le_inf_iff]; exact ⟨lie_le_left I J, lie_le_right J I⟩ @[simp] theorem lie_bot : ⁅I, (⊥ : LieSubmodule R L M)⁆ = ⊥ := by rw [eq_bot_iff]; apply lie_le_right @[simp] theorem bot_lie : ⁅(⊥ : LieIdeal R L), N⁆ = ⊥ := by suffices ⁅(⊥ : LieIdeal R L), N⁆ ≤ ⊥ by exact le_bot_iff.mp this rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro m ⟨⟨x, hx⟩, n, hn⟩; rw [← hn] change x ∈ (⊥ : LieIdeal R L) at hx; rw [mem_bot] at hx; simp [hx] theorem lie_eq_bot_iff : ⁅I, N⁆ = ⊥ ↔ ∀ x ∈ I, ∀ m ∈ N, ⁅(x : L), m⁆ = 0 := by rw [lieIdeal_oper_eq_span, LieSubmodule.lieSpan_eq_bot_iff] refine ⟨fun h x hx m hm => h ⁅x, m⁆ ⟨⟨x, hx⟩, ⟨m, hm⟩, rfl⟩, ?_⟩ rintro h - ⟨⟨x, hx⟩, ⟨⟨n, hn⟩, rfl⟩⟩ exact h x hx n hn variable {I J N N'} in theorem mono_lie (h₁ : I ≤ J) (h₂ : N ≤ N') : ⁅I, N⁆ ≤ ⁅J, N'⁆ := by intro m h rw [lieIdeal_oper_eq_span, mem_lieSpan] at h; rw [lieIdeal_oper_eq_span, mem_lieSpan] intro N hN; apply h; rintro m' ⟨⟨x, hx⟩, ⟨n, hn⟩, hm⟩; rw [← hm]; apply hN use ⟨x, h₁ hx⟩, ⟨n, h₂ hn⟩ variable {I J} in theorem mono_lie_left (h : I ≤ J) : ⁅I, N⁆ ≤ ⁅J, N⁆ := mono_lie h (le_refl N) variable {N N'} in theorem mono_lie_right (h : N ≤ N') : ⁅I, N⁆ ≤ ⁅I, N'⁆ := mono_lie (le_refl I) h @[simp] theorem lie_sup : ⁅I, N ⊔ N'⁆ = ⁅I, N⁆ ⊔ ⁅I, N'⁆ := by have h : ⁅I, N⁆ ⊔ ⁅I, N'⁆ ≤ ⁅I, N ⊔ N'⁆ := by rw [sup_le_iff]; constructor <;> apply mono_lie_right <;> [exact le_sup_left; exact le_sup_right] suffices ⁅I, N ⊔ N'⁆ ≤ ⁅I, N⁆ ⊔ ⁅I, N'⁆ by exact le_antisymm this h rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro m ⟨x, ⟨n, hn⟩, h⟩; erw [LieSubmodule.mem_sup] erw [LieSubmodule.mem_sup] at hn; rcases hn with ⟨n₁, hn₁, n₂, hn₂, hn'⟩ use ⁅(x : L), (⟨n₁, hn₁⟩ : N)⁆; constructor; · apply lie_coe_mem_lie use ⁅(x : L), (⟨n₂, hn₂⟩ : N')⁆; constructor; · apply lie_coe_mem_lie simp [← h, ← hn'] @[simp] theorem sup_lie : ⁅I ⊔ J, N⁆ = ⁅I, N⁆ ⊔ ⁅J, N⁆ := by have h : ⁅I, N⁆ ⊔ ⁅J, N⁆ ≤ ⁅I ⊔ J, N⁆ := by rw [sup_le_iff]; constructor <;> apply mono_lie_left <;> [exact le_sup_left; exact le_sup_right] suffices ⁅I ⊔ J, N⁆ ≤ ⁅I, N⁆ ⊔ ⁅J, N⁆ by exact le_antisymm this h rw [lieIdeal_oper_eq_span, lieSpan_le]; rintro m ⟨⟨x, hx⟩, n, h⟩; erw [LieSubmodule.mem_sup] erw [LieSubmodule.mem_sup] at hx; rcases hx with ⟨x₁, hx₁, x₂, hx₂, hx'⟩ use ⁅((⟨x₁, hx₁⟩ : I) : L), (n : N)⁆; constructor; · apply lie_coe_mem_lie use ⁅((⟨x₂, hx₂⟩ : J) : L), (n : N)⁆; constructor; · apply lie_coe_mem_lie simp [← h, ← hx'] -- @[simp] -- Porting note: not in simpNF theorem lie_inf : ⁅I, N ⊓ N'⁆ ≤ ⁅I, N⁆ ⊓ ⁅I, N'⁆ := by rw [le_inf_iff]; constructor <;> apply mono_lie_right <;> [exact inf_le_left; exact inf_le_right] -- @[simp] -- Porting note: not in simpNF theorem inf_lie : ⁅I ⊓ J, N⁆ ≤ ⁅I, N⁆ ⊓ ⁅J, N⁆ := by rw [le_inf_iff]; constructor <;> apply mono_lie_left <;> [exact inf_le_left; exact inf_le_right] theorem map_bracket_eq [LieModule R L M] : map f ⁅I, N⁆ = ⁅I, map f N⁆ := by rw [← coe_toSubmodule_eq_iff, coeSubmodule_map, lieIdeal_oper_eq_linear_span, lieIdeal_oper_eq_linear_span, Submodule.map_span] congr ext m constructor · rintro ⟨-, ⟨⟨x, ⟨n, hn⟩, rfl⟩, hm⟩⟩ simp only [LieModuleHom.coe_toLinearMap, LieModuleHom.map_lie] at hm exact ⟨x, ⟨f n, (mem_map (f n)).mpr ⟨n, hn, rfl⟩⟩, hm⟩ · rintro ⟨x, ⟨m₂, hm₂ : m₂ ∈ map f N⟩, rfl⟩ obtain ⟨n, hn, rfl⟩ := (mem_map m₂).mp hm₂ exact ⟨⁅x, n⁆, ⟨x, ⟨n, hn⟩, rfl⟩, by simp⟩ theorem comap_bracket_eq [LieModule R L M] (hf₁ : f.ker = ⊥) (hf₂ : N₂ ≤ f.range) : comap f ⁅I, N₂⁆ = ⁅I, comap f N₂⁆ := by conv_lhs => rw [← map_comap_eq N₂ f hf₂] rw [← map_bracket_eq, comap_map_eq _ f hf₁] end LieIdealOperations end LieSubmodule namespace LieIdeal open LieAlgebra variable {R : Type u} {L : Type v} {L' : Type w₂} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] variable (f : L →ₗ⁅R⁆ L') (I : LieIdeal R L) (J : LieIdeal R L') /-- Note that the inequality can be strict; e.g., the inclusion of an Abelian subalgebra of a simple algebra. -/ theorem map_bracket_le {I₁ I₂ : LieIdeal R L} : map f ⁅I₁, I₂⁆ ≤ ⁅map f I₁, map f I₂⁆ := by rw [map_le_iff_le_comap]; erw [LieSubmodule.lieSpan_le] intro x hx; obtain ⟨⟨y₁, hy₁⟩, ⟨y₂, hy₂⟩, hx⟩ := hx; rw [← hx] let fy₁ : ↥(map f I₁) := ⟨f y₁, mem_map hy₁⟩ let fy₂ : ↥(map f I₂) := ⟨f y₂, mem_map hy₂⟩ change _ ∈ comap f ⁅map f I₁, map f I₂⁆ simp only [Submodule.coe_mk, mem_comap, LieHom.map_lie] exact LieSubmodule.lie_coe_mem_lie fy₁ fy₂ theorem map_bracket_eq {I₁ I₂ : LieIdeal R L} (h : Function.Surjective f) : map f ⁅I₁, I₂⁆ = ⁅map f I₁, map f I₂⁆ := by suffices ⁅map f I₁, map f I₂⁆ ≤ map f ⁅I₁, I₂⁆ by exact le_antisymm (map_bracket_le f) this rw [← LieSubmodule.coeSubmodule_le_coeSubmodule, coe_map_of_surjective h, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.lieIdeal_oper_eq_linear_span, LinearMap.map_span] apply Submodule.span_mono rintro x ⟨⟨z₁, h₁⟩, ⟨z₂, h₂⟩, rfl⟩ obtain ⟨y₁, rfl⟩ := mem_map_of_surjective h h₁ obtain ⟨y₂, rfl⟩ := mem_map_of_surjective h h₂ exact ⟨⁅(y₁ : L), (y₂ : L)⁆, ⟨y₁, y₂, rfl⟩, by apply f.map_lie⟩ theorem comap_bracket_le {J₁ J₂ : LieIdeal R L'} : ⁅comap f J₁, comap f J₂⁆ ≤ comap f ⁅J₁, J₂⁆ := by rw [← map_le_iff_le_comap] exact le_trans (map_bracket_le f) (LieSubmodule.mono_lie map_comap_le map_comap_le) variable {f} theorem map_comap_incl {I₁ I₂ : LieIdeal R L} : map I₁.incl (comap I₁.incl I₂) = I₁ ⊓ I₂ := by conv_rhs => rw [← I₁.incl_idealRange] rw [← map_comap_eq] exact I₁.incl_isIdealMorphism theorem comap_bracket_eq {J₁ J₂ : LieIdeal R L'} (h : f.IsIdealMorphism) : comap f ⁅f.idealRange ⊓ J₁, f.idealRange ⊓ J₂⁆ = ⁅comap f J₁, comap f J₂⁆ ⊔ f.ker := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, comap_coeSubmodule, LieSubmodule.sup_coe_toSubmodule, f.ker_coeSubmodule, ← Submodule.comap_map_eq, LieSubmodule.lieIdeal_oper_eq_linear_span, LieSubmodule.lieIdeal_oper_eq_linear_span, LinearMap.map_span] congr; simp only [LieHom.coe_toLinearMap, Set.mem_setOf_eq]; ext y constructor · rintro ⟨⟨x₁, hx₁⟩, ⟨x₂, hx₂⟩, hy⟩; rw [← hy] erw [LieSubmodule.mem_inf, f.mem_idealRange_iff h] at hx₁ hx₂ obtain ⟨⟨z₁, hz₁⟩, hz₁'⟩ := hx₁; rw [← hz₁] at hz₁' obtain ⟨⟨z₂, hz₂⟩, hz₂'⟩ := hx₂; rw [← hz₂] at hz₂' refine ⟨⁅z₁, z₂⁆, ⟨⟨z₁, hz₁'⟩, ⟨z₂, hz₂'⟩, rfl⟩, ?_⟩ simp only [hz₁, hz₂, Submodule.coe_mk, LieHom.map_lie] · rintro ⟨x, ⟨⟨z₁, hz₁⟩, ⟨z₂, hz₂⟩, hx⟩, hy⟩; rw [← hy, ← hx] have hz₁' : f z₁ ∈ f.idealRange ⊓ J₁ := by rw [LieSubmodule.mem_inf]; exact ⟨f.mem_idealRange z₁, hz₁⟩ have hz₂' : f z₂ ∈ f.idealRange ⊓ J₂ := by rw [LieSubmodule.mem_inf]; exact ⟨f.mem_idealRange z₂, hz₂⟩ use ⟨f z₁, hz₁'⟩, ⟨f z₂, hz₂'⟩; simp only [Submodule.coe_mk, LieHom.map_lie] theorem map_comap_bracket_eq {J₁ J₂ : LieIdeal R L'} (h : f.IsIdealMorphism) : map f ⁅comap f J₁, comap f J₂⁆ = ⁅f.idealRange ⊓ J₁, f.idealRange ⊓ J₂⁆ := by rw [← map_sup_ker_eq_map, ← comap_bracket_eq h, map_comap_eq h, inf_eq_right] exact le_trans (LieSubmodule.lie_le_left _ _) inf_le_left theorem comap_bracket_incl {I₁ I₂ : LieIdeal R L} : ⁅comap I.incl I₁, comap I.incl I₂⁆ = comap I.incl ⁅I ⊓ I₁, I ⊓ I₂⁆ := by conv_rhs => congr next => skip rw [← I.incl_idealRange] rw [comap_bracket_eq] · simp only [ker_incl, sup_bot_eq] · exact I.incl_isIdealMorphism /-- This is a very useful result; it allows us to use the fact that inclusion distributes over the Lie bracket operation on ideals, subject to the conditions shown. -/ theorem comap_bracket_incl_of_le {I₁ I₂ : LieIdeal R L} (h₁ : I₁ ≤ I) (h₂ : I₂ ≤ I) : ⁅comap I.incl I₁, comap I.incl I₂⁆ = comap I.incl ⁅I₁, I₂⁆ := by rw [comap_bracket_incl]; rw [← inf_eq_right] at h₁ h₂; rw [h₁, h₂] end LieIdeal
Algebra\Lie\InvariantForm.lean
/- Copyright (c) 2024 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Lie.Semisimple.Defs import Mathlib.LinearAlgebra.BilinearForm.Orthogonal /-! # Lie algebras with non-degenerate invariant bilinear forms are semisimple In this file we prove that a finite-dimensional Lie algebra over a field is semisimple if it does not have non-trivial abelian ideals and it admits a non-degenerate reflexive invariant bilinear form. Here a form is *invariant* if it invariant under the Lie bracket in the sense that `⁅x, Φ⁆ = 0` for all `x` or equivalently, `Φ ⁅x, y⁆ z = Φ x ⁅y, z⁆`. ## Main results * `LieAlgebra.InvariantForm.orthogonal`: given a Lie submodule `N` of a Lie module `M`, we define its orthogonal complement with respect to a non-degenerate invariant bilinear form `Φ` as the Lie ideal of elements `x` such that `Φ n x = 0` for all `n ∈ N`. * `LieAlgebra.InvariantForm.isSemisimple_of_nondegenerate`: the main result of this file; a finite-dimensional Lie algebra over a field is semisimple if it does not have non-trivial abelian ideals and admits a non-degenerate invariant reflexive bilinear form. ## References We follow the short and excellent paper [dieudonne1953]. -/ namespace LieAlgebra namespace InvariantForm section ring variable {R L M : Type*} variable [CommRing R] [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] variable (Φ : LinearMap.BilinForm R M) (hΦ_nondeg : Φ.Nondegenerate) variable (L) in /-- A bilinear form on a Lie module `M` of a Lie algebra `L` is *invariant* if for all `x : L` and `y z : M` the condition `Φ ⁅x, y⁆ z = -Φ y ⁅x, z⁆` holds. -/ def _root_.LinearMap.BilinForm.lieInvariant : Prop := ∀ (x : L) (y z : M), Φ ⁅x, y⁆ z = -Φ y ⁅x, z⁆ lemma _root_.LinearMap.BilinForm.lieInvariant_iff [LieModule R L M] : Φ.lieInvariant L ↔ Φ ∈ LieModule.maxTrivSubmodule R L (LinearMap.BilinForm R M) := by refine ⟨fun h x ↦ ?_, fun h x y z ↦ ?_⟩ · ext y z rw [LieHom.lie_apply, LinearMap.sub_apply, Module.Dual.lie_apply, LinearMap.zero_apply, LinearMap.zero_apply, h, sub_self] · replace h := LinearMap.congr_fun₂ (h x) y z simp only [LieHom.lie_apply, LinearMap.sub_apply, Module.Dual.lie_apply, LinearMap.zero_apply, sub_eq_zero] at h simp [← h] variable (hΦ_inv : Φ.lieInvariant L) /-- The orthogonal complement of a Lie submodule `N` with respect to an invariant bilinear form `Φ` is the Lie submodule of elements `y` such that `Φ x y = 0` for all `x ∈ N`. -/ @[simps!] def orthogonal (N : LieSubmodule R L M) : LieSubmodule R L M where __ := Φ.orthogonal N lie_mem {x y} := by suffices (∀ n ∈ N, Φ n y = 0) → ∀ n ∈ N, Φ n ⁅x, y⁆ = 0 by simpa only [LinearMap.BilinForm.isOrtho_def, -- and some default simp lemmas AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, LinearMap.BilinForm.mem_orthogonal_iff, LieSubmodule.mem_coeSubmodule] intro H a ha rw [← neg_eq_zero, ← hΦ_inv] exact H _ <| N.lie_mem ha @[simp] lemma orthogonal_toSubmodule (N : LieSubmodule R L M) : (orthogonal Φ hΦ_inv N).toSubmodule = Φ.orthogonal N.toSubmodule := rfl lemma mem_orthogonal (N : LieSubmodule R L M) (y : M) : y ∈ orthogonal Φ hΦ_inv N ↔ ∀ x ∈ N, Φ x y = 0 := by simp [orthogonal, LinearMap.BilinForm.isOrtho_def, LinearMap.BilinForm.mem_orthogonal_iff] lemma orthogonal_disjoint (Φ : LinearMap.BilinForm R L) (hΦ_nondeg : Φ.Nondegenerate) (hΦ_inv : Φ.lieInvariant L) -- TODO: replace the following assumption by a typeclass assumption `[HasNonAbelianAtoms]` (hL : ∀ I : LieIdeal R L, IsAtom I → ¬IsLieAbelian I) (I : LieIdeal R L) (hI : IsAtom I) : Disjoint I (orthogonal Φ hΦ_inv I) := by rw [disjoint_iff, ← hI.lt_iff, lt_iff_le_and_ne] suffices ¬I ≤ orthogonal Φ hΦ_inv I by simpa intro contra apply hI.1 rw [eq_bot_iff, ← lie_eq_self_of_isAtom_of_nonabelian I hI (hL I hI), LieSubmodule.lieIdeal_oper_eq_span, LieSubmodule.lieSpan_le] rintro _ ⟨x, y, rfl⟩ simp only [LieSubmodule.bot_coe, Set.mem_singleton_iff] apply hΦ_nondeg intro z rw [hΦ_inv, neg_eq_zero] have hyz : ⁅(x : L), z⁆ ∈ I := lie_mem_left _ _ _ _ _ x.2 exact contra hyz y y.2 end ring section field variable {K L M : Type*} variable [Field K] [LieRing L] [LieAlgebra K L] variable [AddCommGroup M] [Module K M] [LieRingModule L M] variable [Module.Finite K L] variable (Φ : LinearMap.BilinForm K L) (hΦ_nondeg : Φ.Nondegenerate) variable (hΦ_inv : Φ.lieInvariant L) (hΦ_refl : Φ.IsRefl) -- TODO: replace the following assumption by a typeclass assumption `[HasNonAbelianAtoms]` variable (hL : ∀ I : LieIdeal K L, IsAtom I → ¬IsLieAbelian I) open FiniteDimensional Submodule in lemma orthogonal_isCompl_coe_submodule (I : LieIdeal K L) (hI : IsAtom I) : IsCompl I.toSubmodule (orthogonal Φ hΦ_inv I).toSubmodule := by rw [orthogonal_toSubmodule, LinearMap.BilinForm.isCompl_orthogonal_iff_disjoint hΦ_refl, ← orthogonal_toSubmodule _ hΦ_inv, ← LieSubmodule.disjoint_iff_coe_toSubmodule] exact orthogonal_disjoint Φ hΦ_nondeg hΦ_inv hL I hI open FiniteDimensional Submodule in lemma orthogonal_isCompl (I : LieIdeal K L) (hI : IsAtom I) : IsCompl I (orthogonal Φ hΦ_inv I) := by rw [LieSubmodule.isCompl_iff_coe_toSubmodule] exact orthogonal_isCompl_coe_submodule Φ hΦ_nondeg hΦ_inv hΦ_refl hL I hI lemma restrict_nondegenerate (I : LieIdeal K L) (hI : IsAtom I) : (Φ.restrict I).Nondegenerate := by rw [LinearMap.BilinForm.restrict_nondegenerate_iff_isCompl_orthogonal hΦ_refl] exact orthogonal_isCompl_coe_submodule Φ hΦ_nondeg hΦ_inv hΦ_refl hL I hI lemma restrict_orthogonal_nondegenerate (I : LieIdeal K L) (hI : IsAtom I) : (Φ.restrict (orthogonal Φ hΦ_inv I)).Nondegenerate := by rw [LinearMap.BilinForm.restrict_nondegenerate_iff_isCompl_orthogonal hΦ_refl] simp only [LieIdeal.coe_to_lieSubalgebra_to_submodule, orthogonal_toSubmodule, LinearMap.BilinForm.orthogonal_orthogonal hΦ_nondeg hΦ_refl] exact (orthogonal_isCompl_coe_submodule Φ hΦ_nondeg hΦ_inv hΦ_refl hL I hI).symm open FiniteDimensional Submodule in lemma atomistic : ∀ I : LieIdeal K L, sSup {J : LieIdeal K L | IsAtom J ∧ J ≤ I} = I := by intro I apply le_antisymm · apply sSup_le rintro J ⟨-, hJ'⟩ exact hJ' by_cases hI : I = ⊥ · exact hI.le.trans bot_le obtain ⟨J, hJ, hJI⟩ := (eq_bot_or_exists_atom_le I).resolve_left hI let J' := orthogonal Φ hΦ_inv J suffices I ≤ J ⊔ (J' ⊓ I) by refine this.trans ?_ apply sup_le · exact le_sSup ⟨hJ, hJI⟩ rw [← atomistic (J' ⊓ I)] apply sSup_le_sSup simp only [le_inf_iff, Set.setOf_subset_setOf, and_imp] tauto suffices J ⊔ J' = ⊤ by rw [← sup_inf_assoc_of_le _ hJI, this, top_inf_eq] exact (orthogonal_isCompl Φ hΦ_nondeg hΦ_inv hΦ_refl hL J hJ).codisjoint.eq_top termination_by I => finrank K I decreasing_by apply finrank_lt_finrank_of_lt suffices ¬I ≤ J' by simpa intro hIJ' apply hJ.1 rw [eq_bot_iff] exact orthogonal_disjoint Φ hΦ_nondeg hΦ_inv hL J hJ le_rfl (hJI.trans hIJ') open LieSubmodule in /-- A finite-dimensional Lie algebra over a field is semisimple if it does not have non-trivial abelian ideals and it admits a non-degenerate reflexive invariant bilinear form. Here a form is *invariant* if it is compatible with the Lie bracket: `Φ ⁅x, y⁆ z = Φ x ⁅y, z⁆`. -/ theorem isSemisimple_of_nondegenerate : IsSemisimple K L := by refine ⟨?_, ?_, hL⟩ · simpa using atomistic Φ hΦ_nondeg hΦ_inv hΦ_refl hL ⊤ intro I hI apply (orthogonal_disjoint Φ hΦ_nondeg hΦ_inv hL I hI).mono_right apply sSup_le simp only [Set.mem_diff, Set.mem_setOf_eq, Set.mem_singleton_iff, and_imp] intro J hJ hJI rw [← lie_eq_self_of_isAtom_of_nonabelian J hJ (hL J hJ), lieIdeal_oper_eq_span, lieSpan_le] rintro _ ⟨x, y, rfl⟩ simp only [orthogonal_carrier, Φ.isOrtho_def, Set.mem_setOf_eq] intro z hz rw [← neg_eq_zero, ← hΦ_inv] suffices ⁅(x : L), z⁆ = 0 by simp only [this, map_zero, LinearMap.zero_apply] rw [← LieSubmodule.mem_bot (R := K) (L := L), ← (hJ.disjoint_of_ne hI hJI).eq_bot] apply lie_le_inf exact lie_mem_lie x.2 hz end field end InvariantForm end LieAlgebra
Algebra\Lie\Killing.lean
/- Copyright (c) 2023 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.InvariantForm import Mathlib.Algebra.Lie.Semisimple.Basic import Mathlib.Algebra.Lie.TraceForm /-! # Lie algebras with non-degenerate Killing forms. In characteristic zero, the following three conditions are equivalent: 1. The solvable radical of a Lie algebra is trivial 2. A Lie algebra is a direct sum of its simple ideals 3. A Lie algebra has non-degenerate Killing form In positive characteristic, it is still true that 3 implies 2, and that 2 implies 1, but there are counterexamples to the remaining implications. Thus condition 3 is the strongest assumption. Furthermore, much of the Cartan-Killing classification of semisimple Lie algebras in characteristic zero, continues to hold in positive characteristic (over a perfect field) if the Lie algebra has a non-degenerate Killing form. This file contains basic definitions and results for such Lie algebras. ## Main declarations * `LieAlgebra.IsKilling`: a typeclass encoding the fact that a Lie algebra has a non-singular Killing form. * `LieAlgebra.IsKilling.instSemisimple`: if a finite-dimensional Lie algebra over a field has non-singular Killing form then it is semisimple. * `LieAlgebra.IsKilling.instHasTrivialRadical`: if a Lie algebra over a PID has non-singular Killing form then it has trivial radical. ## TODO * Prove that in characteristic zero, a semisimple Lie algebra has non-singular Killing form. -/ variable (R K L M : Type*) [CommRing R] [Field K] [LieRing L] [LieAlgebra R L] [LieAlgebra K L] namespace LieAlgebra /-- We say a Lie algebra is Killing if its Killing form is non-singular. NB: This is not standard terminology (the literature does not seem to name Lie algebras with this property). -/ class IsKilling : Prop := /-- We say a Lie algebra is Killing if its Killing form is non-singular. -/ killingCompl_top_eq_bot : LieIdeal.killingCompl R L ⊤ = ⊥ attribute [simp] IsKilling.killingCompl_top_eq_bot namespace IsKilling variable [Module.Free R L] [Module.Finite R L] [IsKilling R L] @[simp] lemma ker_killingForm_eq_bot : LinearMap.ker (killingForm R L) = ⊥ := by simp [← LieIdeal.coe_killingCompl_top, killingCompl_top_eq_bot] lemma killingForm_nondegenerate : (killingForm R L).Nondegenerate := by simp [LinearMap.BilinForm.nondegenerate_iff_ker_eq_bot] variable {R L} in lemma ideal_eq_bot_of_isLieAbelian [IsDomain R] [IsPrincipalIdealRing R] (I : LieIdeal R L) [IsLieAbelian I] : I = ⊥ := by rw [eq_bot_iff, ← killingCompl_top_eq_bot] exact I.le_killingCompl_top_of_isLieAbelian instance instSemisimple [IsKilling K L] [Module.Finite K L] : IsSemisimple K L := by apply InvariantForm.isSemisimple_of_nondegenerate (Φ := killingForm K L) · exact IsKilling.killingForm_nondegenerate _ _ · exact LieModule.traceForm_lieInvariant _ _ _ · exact (LieModule.traceForm_isSymm K L L).isRefl · intro I h₁ h₂ exact h₁.1 <| IsKilling.ideal_eq_bot_of_isLieAbelian I /-- The converse of this is true over a field of characteristic zero. There are counterexamples over fields with positive characteristic. Note that when the coefficients are a field this instance is redundant since we have `LieAlgebra.IsKilling.instSemisimple` and `LieAlgebra.IsSemisimple.instHasTrivialRadical`. -/ instance instHasTrivialRadical [IsDomain R] [IsPrincipalIdealRing R] : HasTrivialRadical R L := (hasTrivialRadical_iff_no_abelian_ideals R L).mpr IsKilling.ideal_eq_bot_of_isLieAbelian end IsKilling section LieEquiv variable {R L} variable {L' : Type*} [LieRing L'] [LieAlgebra R L'] /-- Given an equivalence `e` of Lie algebras from `L` to `L'`, and elements `x y : L`, the respective Killing forms of `L` and `L'` satisfy `κ'(e x, e y) = κ(x, y)`. -/ @[simp] lemma killingForm_of_equiv_apply (e : L ≃ₗ⁅R⁆ L') (x y : L) : killingForm R L' (e x) (e y) = killingForm R L x y := by simp_rw [killingForm_apply_apply, ← LieAlgebra.conj_ad_apply, ← LinearEquiv.conj_comp, LinearMap.trace_conj'] /-- Given a Killing Lie algebra `L`, if `L'` is isomorphic to `L`, then `L'` is Killing too. -/ lemma isKilling_of_equiv [IsKilling R L] (e : L ≃ₗ⁅R⁆ L') : IsKilling R L' := by constructor ext x' simp_rw [LieIdeal.mem_killingCompl, LieModule.traceForm_comm] refine ⟨fun hx' ↦ ?_, fun hx y _ ↦ hx ▸ LinearMap.map_zero₂ (killingForm R L') y⟩ suffices e.symm x' ∈ LinearMap.ker (killingForm R L) by rw [IsKilling.ker_killingForm_eq_bot] at this simpa using (e : L ≃ₗ[R] L').congr_arg this ext y replace hx' : ∀ y', killingForm R L' x' y' = 0 := by simpa using hx' specialize hx' (e y) rwa [← e.apply_symm_apply x', killingForm_of_equiv_apply] at hx' alias _root_.LieEquiv.isKilling := LieAlgebra.isKilling_of_equiv end LieEquiv end LieAlgebra
Algebra\Lie\Matrix.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.OfAssociative import Mathlib.LinearAlgebra.Matrix.Reindex import Mathlib.LinearAlgebra.Matrix.ToLinearEquiv /-! # Lie algebras of matrices An important class of Lie algebras are those arising from the associative algebra structure on square matrices over a commutative ring. This file provides some very basic definitions whose primary value stems from their utility when constructing the classical Lie algebras using matrices. ## Main definitions * `lieEquivMatrix'` * `Matrix.lieConj` * `Matrix.reindexLieEquiv` ## Tags lie algebra, matrix -/ universe u v w w₁ w₂ section Matrices open scoped Matrix variable {R : Type u} [CommRing R] variable {n : Type w} [DecidableEq n] [Fintype n] /-- The natural equivalence between linear endomorphisms of finite free modules and square matrices is compatible with the Lie algebra structures. -/ def lieEquivMatrix' : Module.End R (n → R) ≃ₗ⁅R⁆ Matrix n n R := { LinearMap.toMatrix' with map_lie' := fun {T S} => by let f := @LinearMap.toMatrix' R _ n n _ _ change f (T.comp S - S.comp T) = f T * f S - f S * f T have h : ∀ T S : Module.End R _, f (T.comp S) = f T * f S := LinearMap.toMatrix'_comp rw [map_sub, h, h] } @[simp] theorem lieEquivMatrix'_apply (f : Module.End R (n → R)) : lieEquivMatrix' f = LinearMap.toMatrix' f := rfl @[simp] theorem lieEquivMatrix'_symm_apply (A : Matrix n n R) : (@lieEquivMatrix' R _ n _ _).symm A = Matrix.toLin' A := rfl /-- An invertible matrix induces a Lie algebra equivalence from the space of matrices to itself. -/ def Matrix.lieConj (P : Matrix n n R) (h : Invertible P) : Matrix n n R ≃ₗ⁅R⁆ Matrix n n R := ((@lieEquivMatrix' R _ n _ _).symm.trans (P.toLinearEquiv' h).lieConj).trans lieEquivMatrix' @[simp] theorem Matrix.lieConj_apply (P A : Matrix n n R) (h : Invertible P) : P.lieConj h A = P * A * P⁻¹ := by simp [LinearEquiv.conj_apply, Matrix.lieConj, LinearMap.toMatrix'_comp, LinearMap.toMatrix'_toLin'] @[simp] theorem Matrix.lieConj_symm_apply (P A : Matrix n n R) (h : Invertible P) : (P.lieConj h).symm A = P⁻¹ * A * P := by simp [LinearEquiv.symm_conj_apply, Matrix.lieConj, LinearMap.toMatrix'_comp, LinearMap.toMatrix'_toLin'] variable {m : Type w₁} [DecidableEq m] [Fintype m] (e : n ≃ m) /-- For square matrices, the natural map that reindexes a matrix's rows and columns with equivalent types, `Matrix.reindex`, is an equivalence of Lie algebras. -/ def Matrix.reindexLieEquiv : Matrix n n R ≃ₗ⁅R⁆ Matrix m m R := { Matrix.reindexLinearEquiv R R e e with toFun := Matrix.reindex e e map_lie' := fun {_ _} => by simp only [LieRing.of_associative_ring_bracket, Matrix.reindex_apply, Matrix.submatrix_mul_equiv, Matrix.submatrix_sub, Pi.sub_apply] } @[simp] theorem Matrix.reindexLieEquiv_apply (M : Matrix n n R) : Matrix.reindexLieEquiv e M = Matrix.reindex e e M := rfl @[simp] theorem Matrix.reindexLieEquiv_symm : (Matrix.reindexLieEquiv e : _ ≃ₗ⁅R⁆ _).symm = Matrix.reindexLieEquiv e.symm := rfl end Matrices
Algebra\Lie\Nilpotent.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.BaseChange import Mathlib.Algebra.Lie.Solvable import Mathlib.Algebra.Lie.Quotient import Mathlib.Algebra.Lie.Normalizer import Mathlib.LinearAlgebra.Eigenspace.Basic import Mathlib.Order.Filter.AtTopBot import Mathlib.RingTheory.Artinian import Mathlib.RingTheory.Nilpotent.Lemmas /-! # Nilpotent Lie algebras Like groups, Lie algebras admit a natural concept of nilpotency. More generally, any Lie module carries a natural concept of nilpotency. We define these here via the lower central series. ## Main definitions * `LieModule.lowerCentralSeries` * `LieModule.IsNilpotent` ## Tags lie algebra, lower central series, nilpotent -/ universe u v w w₁ w₂ section NilpotentModules variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] variable (k : ℕ) (N : LieSubmodule R L M) namespace LieSubmodule /-- A generalisation of the lower central series. The zeroth term is a specified Lie submodule of a Lie module. In the case when we specify the top ideal `⊤` of the Lie algebra, regarded as a Lie module over itself, we get the usual lower central series of a Lie algebra. It can be more convenient to work with this generalisation when considering the lower central series of a Lie submodule, regarded as a Lie module in its own right, since it provides a type-theoretic expression of the fact that the terms of the Lie submodule's lower central series are also Lie submodules of the enclosing Lie module. See also `LieSubmodule.lowerCentralSeries_eq_lcs_comap` and `LieSubmodule.lowerCentralSeries_map_eq_lcs` below, as well as `LieSubmodule.ucs`. -/ def lcs : LieSubmodule R L M → LieSubmodule R L M := (fun N => ⁅(⊤ : LieIdeal R L), N⁆)^[k] @[simp] theorem lcs_zero (N : LieSubmodule R L M) : N.lcs 0 = N := rfl @[simp] theorem lcs_succ : N.lcs (k + 1) = ⁅(⊤ : LieIdeal R L), N.lcs k⁆ := Function.iterate_succ_apply' (fun N' => ⁅⊤, N'⁆) k N @[simp] lemma lcs_sup {N₁ N₂ : LieSubmodule R L M} {k : ℕ} : (N₁ ⊔ N₂).lcs k = N₁.lcs k ⊔ N₂.lcs k := by induction' k with k ih · simp · simp only [LieSubmodule.lcs_succ, ih, LieSubmodule.lie_sup] end LieSubmodule namespace LieModule variable (R L M) /-- The lower central series of Lie submodules of a Lie module. -/ def lowerCentralSeries : LieSubmodule R L M := (⊤ : LieSubmodule R L M).lcs k @[simp] theorem lowerCentralSeries_zero : lowerCentralSeries R L M 0 = ⊤ := rfl @[simp] theorem lowerCentralSeries_succ : lowerCentralSeries R L M (k + 1) = ⁅(⊤ : LieIdeal R L), lowerCentralSeries R L M k⁆ := (⊤ : LieSubmodule R L M).lcs_succ k end LieModule namespace LieSubmodule open LieModule theorem lcs_le_self : N.lcs k ≤ N := by induction' k with k ih · simp · simp only [lcs_succ] exact (LieSubmodule.mono_lie_right ⊤ ih).trans (N.lie_le_right ⊤) variable [LieModule R L M] theorem lowerCentralSeries_eq_lcs_comap : lowerCentralSeries R L N k = (N.lcs k).comap N.incl := by induction' k with k ih · simp · simp only [lcs_succ, lowerCentralSeries_succ] at ih ⊢ have : N.lcs k ≤ N.incl.range := by rw [N.range_incl] apply lcs_le_self rw [ih, LieSubmodule.comap_bracket_eq _ N.incl _ N.ker_incl this] theorem lowerCentralSeries_map_eq_lcs : (lowerCentralSeries R L N k).map N.incl = N.lcs k := by rw [lowerCentralSeries_eq_lcs_comap, LieSubmodule.map_comap_incl, inf_eq_right] apply lcs_le_self end LieSubmodule namespace LieModule variable {M₂ : Type w₁} [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂] variable (R L M) theorem antitone_lowerCentralSeries : Antitone <| lowerCentralSeries R L M := by intro l k induction' k with k ih generalizing l <;> intro h · exact (Nat.le_zero.mp h).symm ▸ le_rfl · rcases Nat.of_le_succ h with (hk | hk) · rw [lowerCentralSeries_succ] exact (LieSubmodule.mono_lie_right ⊤ (ih hk)).trans (LieSubmodule.lie_le_right _ _) · exact hk.symm ▸ le_rfl theorem eventually_iInf_lowerCentralSeries_eq [IsArtinian R M] : ∀ᶠ l in Filter.atTop, ⨅ k, lowerCentralSeries R L M k = lowerCentralSeries R L M l := by have h_wf : WellFounded ((· > ·) : (LieSubmodule R L M)ᵒᵈ → (LieSubmodule R L M)ᵒᵈ → Prop) := LieSubmodule.wellFounded_of_isArtinian R L M obtain ⟨n, hn : ∀ m, n ≤ m → lowerCentralSeries R L M n = lowerCentralSeries R L M m⟩ := WellFounded.monotone_chain_condition.mp h_wf ⟨_, antitone_lowerCentralSeries R L M⟩ refine Filter.eventually_atTop.mpr ⟨n, fun l hl ↦ le_antisymm (iInf_le _ _) (le_iInf fun m ↦ ?_)⟩ rcases le_or_lt l m with h | h · rw [← hn _ hl, ← hn _ (hl.trans h)] · exact antitone_lowerCentralSeries R L M (le_of_lt h) theorem trivial_iff_lower_central_eq_bot : IsTrivial L M ↔ lowerCentralSeries R L M 1 = ⊥ := by constructor <;> intro h · erw [eq_bot_iff, LieSubmodule.lieSpan_le]; rintro m ⟨x, n, hn⟩; rw [← hn, h.trivial]; simp · rw [LieSubmodule.eq_bot_iff] at h; apply IsTrivial.mk; intro x m; apply h apply LieSubmodule.subset_lieSpan -- Porting note: was `use x, m; rfl` simp only [LieSubmodule.top_coe, Subtype.exists, LieSubmodule.mem_top, exists_prop, true_and, Set.mem_setOf] exact ⟨x, m, rfl⟩ section variable [LieModule R L M] theorem iterate_toEnd_mem_lowerCentralSeries (x : L) (m : M) (k : ℕ) : (toEnd R L M x)^[k] m ∈ lowerCentralSeries R L M k := by induction' k with k ih · simp only [Nat.zero_eq, Function.iterate_zero, lowerCentralSeries_zero, LieSubmodule.mem_top] · simp only [lowerCentralSeries_succ, Function.comp_apply, Function.iterate_succ', toEnd_apply_apply] exact LieSubmodule.lie_mem_lie (LieSubmodule.mem_top x) ih theorem iterate_toEnd_mem_lowerCentralSeries₂ (x y : L) (m : M) (k : ℕ) : (toEnd R L M x ∘ₗ toEnd R L M y)^[k] m ∈ lowerCentralSeries R L M (2 * k) := by induction' k with k ih · simp have hk : 2 * k.succ = (2 * k + 1) + 1 := rfl simp only [lowerCentralSeries_succ, Function.comp_apply, Function.iterate_succ', hk, toEnd_apply_apply, LinearMap.coe_comp, toEnd_apply_apply] refine LieSubmodule.lie_mem_lie (LieSubmodule.mem_top x) ?_ exact LieSubmodule.lie_mem_lie (LieSubmodule.mem_top y) ih variable {R L M} theorem map_lowerCentralSeries_le (f : M →ₗ⁅R,L⁆ M₂) : (lowerCentralSeries R L M k).map f ≤ lowerCentralSeries R L M₂ k := by induction' k with k ih · simp only [Nat.zero_eq, lowerCentralSeries_zero, le_top] · simp only [LieModule.lowerCentralSeries_succ, LieSubmodule.map_bracket_eq] exact LieSubmodule.mono_lie_right ⊤ ih lemma map_lowerCentralSeries_eq {f : M →ₗ⁅R,L⁆ M₂} (hf : Function.Surjective f) : (lowerCentralSeries R L M k).map f = lowerCentralSeries R L M₂ k := by apply le_antisymm (map_lowerCentralSeries_le k f) induction' k with k ih · rwa [lowerCentralSeries_zero, lowerCentralSeries_zero, top_le_iff, f.map_top, f.range_eq_top] · simp only [lowerCentralSeries_succ, LieSubmodule.map_bracket_eq] apply LieSubmodule.mono_lie_right assumption end open LieAlgebra theorem derivedSeries_le_lowerCentralSeries (k : ℕ) : derivedSeries R L k ≤ lowerCentralSeries R L L k := by induction' k with k h · rw [derivedSeries_def, derivedSeriesOfIdeal_zero, lowerCentralSeries_zero] · have h' : derivedSeries R L k ≤ ⊤ := by simp only [le_top] rw [derivedSeries_def, derivedSeriesOfIdeal_succ, lowerCentralSeries_succ] exact LieSubmodule.mono_lie h' h /-- A Lie module is nilpotent if its lower central series reaches 0 (in a finite number of steps). -/ class IsNilpotent : Prop where nilpotent : ∃ k, lowerCentralSeries R L M k = ⊥ theorem exists_lowerCentralSeries_eq_bot_of_isNilpotent [IsNilpotent R L M] : ∃ k, lowerCentralSeries R L M k = ⊥ := IsNilpotent.nilpotent @[simp] lemma iInf_lowerCentralSeries_eq_bot_of_isNilpotent [IsNilpotent R L M] : ⨅ k, lowerCentralSeries R L M k = ⊥ := by obtain ⟨k, hk⟩ := exists_lowerCentralSeries_eq_bot_of_isNilpotent R L M rw [eq_bot_iff, ← hk] exact iInf_le _ _ /-- See also `LieModule.isNilpotent_iff_exists_ucs_eq_top`. -/ theorem isNilpotent_iff : IsNilpotent R L M ↔ ∃ k, lowerCentralSeries R L M k = ⊥ := ⟨fun h => h.nilpotent, fun h => ⟨h⟩⟩ section variable {R L M} variable [LieModule R L M] theorem _root_.LieSubmodule.isNilpotent_iff_exists_lcs_eq_bot (N : LieSubmodule R L M) : LieModule.IsNilpotent R L N ↔ ∃ k, N.lcs k = ⊥ := by rw [isNilpotent_iff] refine exists_congr fun k => ?_ rw [N.lowerCentralSeries_eq_lcs_comap k, LieSubmodule.comap_incl_eq_bot, inf_eq_right.mpr (N.lcs_le_self k)] variable (R L M) instance (priority := 100) trivialIsNilpotent [IsTrivial L M] : IsNilpotent R L M := ⟨by use 1; change ⁅⊤, ⊤⁆ = ⊥; simp⟩ theorem exists_forall_pow_toEnd_eq_zero [hM : IsNilpotent R L M] : ∃ k : ℕ, ∀ x : L, toEnd R L M x ^ k = 0 := by obtain ⟨k, hM⟩ := hM use k intro x; ext m rw [LinearMap.pow_apply, LinearMap.zero_apply, ← @LieSubmodule.mem_bot R L M, ← hM] exact iterate_toEnd_mem_lowerCentralSeries R L M x m k theorem isNilpotent_toEnd_of_isNilpotent [IsNilpotent R L M] (x : L) : _root_.IsNilpotent (toEnd R L M x) := by change ∃ k, toEnd R L M x ^ k = 0 have := exists_forall_pow_toEnd_eq_zero R L M tauto theorem isNilpotent_toEnd_of_isNilpotent₂ [IsNilpotent R L M] (x y : L) : _root_.IsNilpotent (toEnd R L M x ∘ₗ toEnd R L M y) := by obtain ⟨k, hM⟩ := exists_lowerCentralSeries_eq_bot_of_isNilpotent R L M replace hM : lowerCentralSeries R L M (2 * k) = ⊥ := by rw [eq_bot_iff, ← hM]; exact antitone_lowerCentralSeries R L M (by omega) use k ext m rw [LinearMap.pow_apply, LinearMap.zero_apply, ← LieSubmodule.mem_bot (R := R) (L := L), ← hM] exact iterate_toEnd_mem_lowerCentralSeries₂ R L M x y m k @[simp] lemma maxGenEigenSpace_toEnd_eq_top [IsNilpotent R L M] (x : L) : ((toEnd R L M x).maxGenEigenspace 0) = ⊤ := by ext m simp only [Module.End.mem_maxGenEigenspace, zero_smul, sub_zero, Submodule.mem_top, iff_true] obtain ⟨k, hk⟩ := exists_forall_pow_toEnd_eq_zero R L M exact ⟨k, by simp [hk x]⟩ /-- If the quotient of a Lie module `M` by a Lie submodule on which the Lie algebra acts trivially is nilpotent then `M` is nilpotent. This is essentially the Lie module equivalent of the fact that a central extension of nilpotent Lie algebras is nilpotent. See `LieAlgebra.nilpotent_of_nilpotent_quotient` below for the corresponding result for Lie algebras. -/ theorem nilpotentOfNilpotentQuotient {N : LieSubmodule R L M} (h₁ : N ≤ maxTrivSubmodule R L M) (h₂ : IsNilpotent R L (M ⧸ N)) : IsNilpotent R L M := by obtain ⟨k, hk⟩ := h₂ use k + 1 simp only [lowerCentralSeries_succ] suffices lowerCentralSeries R L M k ≤ N by replace this := LieSubmodule.mono_lie_right ⊤ (le_trans this h₁) rwa [ideal_oper_maxTrivSubmodule_eq_bot, le_bot_iff] at this rw [← LieSubmodule.Quotient.map_mk'_eq_bot_le, ← le_bot_iff, ← hk] exact map_lowerCentralSeries_le k (LieSubmodule.Quotient.mk' N) theorem isNilpotent_quotient_iff : IsNilpotent R L (M ⧸ N) ↔ ∃ k, lowerCentralSeries R L M k ≤ N := by rw [LieModule.isNilpotent_iff] refine exists_congr fun k ↦ ?_ rw [← LieSubmodule.Quotient.map_mk'_eq_bot_le, map_lowerCentralSeries_eq k (LieSubmodule.Quotient.surjective_mk' N)] theorem iInf_lcs_le_of_isNilpotent_quot (h : IsNilpotent R L (M ⧸ N)) : ⨅ k, lowerCentralSeries R L M k ≤ N := by obtain ⟨k, hk⟩ := (isNilpotent_quotient_iff R L M N).mp h exact iInf_le_of_le k hk end /-- Given a nilpotent Lie module `M` with lower central series `M = C₀ ≥ C₁ ≥ ⋯ ≥ Cₖ = ⊥`, this is the natural number `k` (the number of inclusions). For a non-nilpotent module, we use the junk value 0. -/ noncomputable def nilpotencyLength : ℕ := sInf {k | lowerCentralSeries R L M k = ⊥} @[simp] theorem nilpotencyLength_eq_zero_iff [IsNilpotent R L M] : nilpotencyLength R L M = 0 ↔ Subsingleton M := by let s := {k | lowerCentralSeries R L M k = ⊥} have hs : s.Nonempty := by obtain ⟨k, hk⟩ := (by infer_instance : IsNilpotent R L M) exact ⟨k, hk⟩ change sInf s = 0 ↔ _ rw [← LieSubmodule.subsingleton_iff R L M, ← subsingleton_iff_bot_eq_top, ← lowerCentralSeries_zero, @eq_comm (LieSubmodule R L M)] refine ⟨fun h => h ▸ Nat.sInf_mem hs, fun h => ?_⟩ rw [Nat.sInf_eq_zero] exact Or.inl h theorem nilpotencyLength_eq_succ_iff (k : ℕ) : nilpotencyLength R L M = k + 1 ↔ lowerCentralSeries R L M (k + 1) = ⊥ ∧ lowerCentralSeries R L M k ≠ ⊥ := by let s := {k | lowerCentralSeries R L M k = ⊥} change sInf s = k + 1 ↔ k + 1 ∈ s ∧ k ∉ s have hs : ∀ k₁ k₂, k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s := by rintro k₁ k₂ h₁₂ (h₁ : lowerCentralSeries R L M k₁ = ⊥) exact eq_bot_iff.mpr (h₁ ▸ antitone_lowerCentralSeries R L M h₁₂) exact Nat.sInf_upward_closed_eq_succ_iff hs k @[simp] theorem nilpotencyLength_eq_one_iff [Nontrivial M] : nilpotencyLength R L M = 1 ↔ IsTrivial L M := by rw [nilpotencyLength_eq_succ_iff, ← trivial_iff_lower_central_eq_bot] simp theorem isTrivial_of_nilpotencyLength_le_one [IsNilpotent R L M] (h : nilpotencyLength R L M ≤ 1) : IsTrivial L M := by nontriviality M cases' Nat.le_one_iff_eq_zero_or_eq_one.mp h with h h · rw [nilpotencyLength_eq_zero_iff] at h; infer_instance · rwa [nilpotencyLength_eq_one_iff] at h /-- Given a non-trivial nilpotent Lie module `M` with lower central series `M = C₀ ≥ C₁ ≥ ⋯ ≥ Cₖ = ⊥`, this is the `k-1`th term in the lower central series (the last non-trivial term). For a trivial or non-nilpotent module, this is the bottom submodule, `⊥`. -/ noncomputable def lowerCentralSeriesLast : LieSubmodule R L M := match nilpotencyLength R L M with | 0 => ⊥ | k + 1 => lowerCentralSeries R L M k theorem lowerCentralSeriesLast_le_max_triv [LieModule R L M] : lowerCentralSeriesLast R L M ≤ maxTrivSubmodule R L M := by rw [lowerCentralSeriesLast] cases' h : nilpotencyLength R L M with k · exact bot_le · rw [le_max_triv_iff_bracket_eq_bot] rw [nilpotencyLength_eq_succ_iff, lowerCentralSeries_succ] at h exact h.1 theorem nontrivial_lowerCentralSeriesLast [Nontrivial M] [IsNilpotent R L M] : Nontrivial (lowerCentralSeriesLast R L M) := by rw [LieSubmodule.nontrivial_iff_ne_bot, lowerCentralSeriesLast] cases h : nilpotencyLength R L M · rw [nilpotencyLength_eq_zero_iff, ← not_nontrivial_iff_subsingleton] at h contradiction · rw [nilpotencyLength_eq_succ_iff] at h exact h.2 theorem lowerCentralSeriesLast_le_of_not_isTrivial [IsNilpotent R L M] (h : ¬ IsTrivial L M) : lowerCentralSeriesLast R L M ≤ lowerCentralSeries R L M 1 := by rw [lowerCentralSeriesLast] replace h : 1 < nilpotencyLength R L M := by by_contra contra have := isTrivial_of_nilpotencyLength_le_one R L M (not_lt.mp contra) contradiction cases' hk : nilpotencyLength R L M with k <;> rw [hk] at h · contradiction · exact antitone_lowerCentralSeries _ _ _ (Nat.lt_succ.mp h) variable [LieModule R L M] /-- For a nilpotent Lie module `M` of a Lie algebra `L`, the first term in the lower central series of `M` contains a non-zero element on which `L` acts trivially unless the entire action is trivial. Taking `M = L`, this provides a useful characterisation of Abelian-ness for nilpotent Lie algebras. -/ lemma disjoint_lowerCentralSeries_maxTrivSubmodule_iff [IsNilpotent R L M] : Disjoint (lowerCentralSeries R L M 1) (maxTrivSubmodule R L M) ↔ IsTrivial L M := by refine ⟨fun h ↦ ?_, fun h ↦ by simp⟩ nontriviality M by_contra contra have : lowerCentralSeriesLast R L M ≤ lowerCentralSeries R L M 1 ⊓ maxTrivSubmodule R L M := le_inf_iff.mpr ⟨lowerCentralSeriesLast_le_of_not_isTrivial R L M contra, lowerCentralSeriesLast_le_max_triv R L M⟩ suffices ¬ Nontrivial (lowerCentralSeriesLast R L M) by exact this (nontrivial_lowerCentralSeriesLast R L M) rw [h.eq_bot, le_bot_iff] at this exact this ▸ not_nontrivial _ theorem nontrivial_max_triv_of_isNilpotent [Nontrivial M] [IsNilpotent R L M] : Nontrivial (maxTrivSubmodule R L M) := Set.nontrivial_mono (lowerCentralSeriesLast_le_max_triv R L M) (nontrivial_lowerCentralSeriesLast R L M) @[simp] theorem coe_lcs_range_toEnd_eq (k : ℕ) : (lowerCentralSeries R (toEnd R L M).range M k : Submodule R M) = lowerCentralSeries R L M k := by induction' k with k ih · simp · simp only [lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span', ← (lowerCentralSeries R (toEnd R L M).range M k).mem_coeSubmodule, ih] congr ext m constructor · rintro ⟨⟨-, ⟨y, rfl⟩⟩, -, n, hn, rfl⟩ exact ⟨y, LieSubmodule.mem_top _, n, hn, rfl⟩ · rintro ⟨x, -, n, hn, rfl⟩ exact ⟨⟨toEnd R L M x, LieHom.mem_range_self _ x⟩, LieSubmodule.mem_top _, n, hn, rfl⟩ @[simp] theorem isNilpotent_range_toEnd_iff : IsNilpotent R (toEnd R L M).range M ↔ IsNilpotent R L M := by constructor <;> rintro ⟨k, hk⟩ <;> use k <;> rw [← LieSubmodule.coe_toSubmodule_eq_iff] at hk ⊢ <;> simpa using hk end LieModule namespace LieSubmodule variable {N₁ N₂ : LieSubmodule R L M} variable [LieModule R L M] /-- The upper (aka ascending) central series. See also `LieSubmodule.lcs`. -/ def ucs (k : ℕ) : LieSubmodule R L M → LieSubmodule R L M := normalizer^[k] @[simp] theorem ucs_zero : N.ucs 0 = N := rfl @[simp] theorem ucs_succ (k : ℕ) : N.ucs (k + 1) = (N.ucs k).normalizer := Function.iterate_succ_apply' normalizer k N theorem ucs_add (k l : ℕ) : N.ucs (k + l) = (N.ucs l).ucs k := Function.iterate_add_apply normalizer k l N @[gcongr, mono] theorem ucs_mono (k : ℕ) (h : N₁ ≤ N₂) : N₁.ucs k ≤ N₂.ucs k := by induction' k with k ih · simpa simp only [ucs_succ] gcongr theorem ucs_eq_self_of_normalizer_eq_self (h : N₁.normalizer = N₁) (k : ℕ) : N₁.ucs k = N₁ := by induction' k with k ih · simp · rwa [ucs_succ, ih] /-- If a Lie module `M` contains a self-normalizing Lie submodule `N`, then all terms of the upper central series of `M` are contained in `N`. An important instance of this situation arises from a Cartan subalgebra `H ⊆ L` with the roles of `L`, `M`, `N` played by `H`, `L`, `H`, respectively. -/ theorem ucs_le_of_normalizer_eq_self (h : N₁.normalizer = N₁) (k : ℕ) : (⊥ : LieSubmodule R L M).ucs k ≤ N₁ := by rw [← ucs_eq_self_of_normalizer_eq_self h k] gcongr simp theorem lcs_add_le_iff (l k : ℕ) : N₁.lcs (l + k) ≤ N₂ ↔ N₁.lcs l ≤ N₂.ucs k := by induction' k with k ih generalizing l · simp rw [(by abel : l + (k + 1) = l + 1 + k), ih, ucs_succ, lcs_succ, top_lie_le_iff_le_normalizer] theorem lcs_le_iff (k : ℕ) : N₁.lcs k ≤ N₂ ↔ N₁ ≤ N₂.ucs k := by -- Porting note: `convert` needed type annotations convert lcs_add_le_iff (R := R) (L := L) (M := M) 0 k rw [zero_add] theorem gc_lcs_ucs (k : ℕ) : GaloisConnection (fun N : LieSubmodule R L M => N.lcs k) fun N : LieSubmodule R L M => N.ucs k := fun _ _ => lcs_le_iff k theorem ucs_eq_top_iff (k : ℕ) : N.ucs k = ⊤ ↔ LieModule.lowerCentralSeries R L M k ≤ N := by rw [eq_top_iff, ← lcs_le_iff]; rfl theorem _root_.LieModule.isNilpotent_iff_exists_ucs_eq_top : LieModule.IsNilpotent R L M ↔ ∃ k, (⊥ : LieSubmodule R L M).ucs k = ⊤ := by rw [LieModule.isNilpotent_iff]; exact exists_congr fun k => by simp [ucs_eq_top_iff] theorem ucs_comap_incl (k : ℕ) : ((⊥ : LieSubmodule R L M).ucs k).comap N.incl = (⊥ : LieSubmodule R L N).ucs k := by induction' k with k ih · exact N.ker_incl · simp [← ih] theorem isNilpotent_iff_exists_self_le_ucs : LieModule.IsNilpotent R L N ↔ ∃ k, N ≤ (⊥ : LieSubmodule R L M).ucs k := by simp_rw [LieModule.isNilpotent_iff_exists_ucs_eq_top, ← ucs_comap_incl, comap_incl_eq_top] theorem ucs_bot_one : (⊥ : LieSubmodule R L M).ucs 1 = LieModule.maxTrivSubmodule R L M := by simp [LieSubmodule.normalizer_bot_eq_maxTrivSubmodule] end LieSubmodule section Morphisms open LieModule Function variable [LieModule R L M] variable {L₂ M₂ : Type*} [LieRing L₂] [LieAlgebra R L₂] variable [AddCommGroup M₂] [Module R M₂] [LieRingModule L₂ M₂] [LieModule R L₂ M₂] variable {f : L →ₗ⁅R⁆ L₂} {g : M →ₗ[R] M₂} variable (hf : Surjective f) (hg : Surjective g) (hfg : ∀ x m, ⁅f x, g m⁆ = g ⁅x, m⁆) theorem Function.Surjective.lieModule_lcs_map_eq (k : ℕ) : (lowerCentralSeries R L M k : Submodule R M).map g = lowerCentralSeries R L₂ M₂ k := by induction' k with k ih · simpa [LinearMap.range_eq_top] · suffices g '' {m | ∃ (x : L) (n : _), n ∈ lowerCentralSeries R L M k ∧ ⁅x, n⁆ = m} = {m | ∃ (x : L₂) (n : _), n ∈ lowerCentralSeries R L M k ∧ ⁅x, g n⁆ = m} by simp only [← LieSubmodule.mem_coeSubmodule] at this -- Porting note: was -- simp [← LieSubmodule.mem_coeSubmodule, ← ih, LieSubmodule.lieIdeal_oper_eq_linear_span', -- Submodule.map_span, -Submodule.span_image, this, -- -LieSubmodule.mem_coeSubmodule] simp_rw [lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span', Submodule.map_span, LieSubmodule.mem_top, true_and, ← LieSubmodule.mem_coeSubmodule, this, ← ih, Submodule.mem_map, exists_exists_and_eq_and] ext m₂ constructor · rintro ⟨m, ⟨x, n, hn, rfl⟩, rfl⟩ exact ⟨f x, n, hn, hfg x n⟩ · rintro ⟨x, n, hn, rfl⟩ obtain ⟨y, rfl⟩ := hf x exact ⟨⁅y, n⁆, ⟨y, n, hn, rfl⟩, (hfg y n).symm⟩ theorem Function.Surjective.lieModuleIsNilpotent [IsNilpotent R L M] : IsNilpotent R L₂ M₂ := by obtain ⟨k, hk⟩ := id (by infer_instance : IsNilpotent R L M) use k rw [← LieSubmodule.coe_toSubmodule_eq_iff] at hk ⊢ simp [← hf.lieModule_lcs_map_eq hg hfg k, hk] theorem Equiv.lieModule_isNilpotent_iff (f : L ≃ₗ⁅R⁆ L₂) (g : M ≃ₗ[R] M₂) (hfg : ∀ x m, ⁅f x, g m⁆ = g ⁅x, m⁆) : IsNilpotent R L M ↔ IsNilpotent R L₂ M₂ := by constructor <;> intro h · have hg : Surjective (g : M →ₗ[R] M₂) := g.surjective exact f.surjective.lieModuleIsNilpotent hg hfg · have hg : Surjective (g.symm : M₂ →ₗ[R] M) := g.symm.surjective refine f.symm.surjective.lieModuleIsNilpotent hg fun x m => ?_ rw [LinearEquiv.coe_coe, LieEquiv.coe_to_lieHom, ← g.symm_apply_apply ⁅f.symm x, g.symm m⁆, ← hfg, f.apply_symm_apply, g.apply_symm_apply] @[simp] theorem LieModule.isNilpotent_of_top_iff : IsNilpotent R (⊤ : LieSubalgebra R L) M ↔ IsNilpotent R L M := Equiv.lieModule_isNilpotent_iff LieSubalgebra.topEquiv (1 : M ≃ₗ[R] M) fun _ _ => rfl @[simp] lemma LieModule.isNilpotent_of_top_iff' : IsNilpotent R L {x // x ∈ (⊤ : LieSubmodule R L M)} ↔ IsNilpotent R L M := Equiv.lieModule_isNilpotent_iff 1 (LinearEquiv.ofTop ⊤ rfl) fun _ _ ↦ rfl end Morphisms end NilpotentModules instance (priority := 100) LieAlgebra.isSolvable_of_isNilpotent (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L] [hL : LieModule.IsNilpotent R L L] : LieAlgebra.IsSolvable R L := by obtain ⟨k, h⟩ : ∃ k, LieModule.lowerCentralSeries R L L k = ⊥ := hL.nilpotent use k; rw [← le_bot_iff] at h ⊢ exact le_trans (LieModule.derivedSeries_le_lowerCentralSeries R L k) h section NilpotentAlgebras variable (R : Type u) (L : Type v) (L' : Type w) variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] /-- We say a Lie algebra is nilpotent when it is nilpotent as a Lie module over itself via the adjoint representation. -/ abbrev LieAlgebra.IsNilpotent (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L] : Prop := LieModule.IsNilpotent R L L open LieAlgebra theorem LieAlgebra.nilpotent_ad_of_nilpotent_algebra [IsNilpotent R L] : ∃ k : ℕ, ∀ x : L, ad R L x ^ k = 0 := LieModule.exists_forall_pow_toEnd_eq_zero R L L -- TODO Generalise the below to Lie modules if / when we define morphisms, equivs of Lie modules -- covering a Lie algebra morphism of (possibly different) Lie algebras. variable {R L L'} open LieModule (lowerCentralSeries) /-- Given an ideal `I` of a Lie algebra `L`, the lower central series of `L ⧸ I` is the same whether we regard `L ⧸ I` as an `L` module or an `L ⧸ I` module. TODO: This result obviously generalises but the generalisation requires the missing definition of morphisms between Lie modules over different Lie algebras. -/ -- Porting note: added `LieSubmodule.toSubmodule` in the statement theorem coe_lowerCentralSeries_ideal_quot_eq {I : LieIdeal R L} (k : ℕ) : LieSubmodule.toSubmodule (lowerCentralSeries R L (L ⧸ I) k) = LieSubmodule.toSubmodule (lowerCentralSeries R (L ⧸ I) (L ⧸ I) k) := by induction' k with k ih · simp only [Nat.zero_eq, LieModule.lowerCentralSeries_zero, LieSubmodule.top_coeSubmodule, LieIdeal.top_coe_lieSubalgebra, LieSubalgebra.top_coe_submodule] · simp only [LieModule.lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span] congr ext x constructor · rintro ⟨⟨y, -⟩, ⟨z, hz⟩, rfl : ⁅y, z⁆ = x⟩ erw [← LieSubmodule.mem_coeSubmodule, ih, LieSubmodule.mem_coeSubmodule] at hz exact ⟨⟨LieSubmodule.Quotient.mk y, LieSubmodule.mem_top _⟩, ⟨z, hz⟩, rfl⟩ · rintro ⟨⟨⟨y⟩, -⟩, ⟨z, hz⟩, rfl : ⁅y, z⁆ = x⟩ erw [← LieSubmodule.mem_coeSubmodule, ← ih, LieSubmodule.mem_coeSubmodule] at hz exact ⟨⟨y, LieSubmodule.mem_top _⟩, ⟨z, hz⟩, rfl⟩ /-- Note that the below inequality can be strict. For example the ideal of strictly-upper-triangular 2x2 matrices inside the Lie algebra of upper-triangular 2x2 matrices with `k = 1`. -/ -- Porting note: added `LieSubmodule.toSubmodule` in the statement theorem LieModule.coe_lowerCentralSeries_ideal_le {I : LieIdeal R L} (k : ℕ) : LieSubmodule.toSubmodule (lowerCentralSeries R I I k) ≤ lowerCentralSeries R L I k := by induction' k with k ih · simp · simp only [LieModule.lowerCentralSeries_succ, LieSubmodule.lieIdeal_oper_eq_linear_span] apply Submodule.span_mono rintro x ⟨⟨y, -⟩, ⟨z, hz⟩, rfl : ⁅y, z⁆ = x⟩ exact ⟨⟨y.val, LieSubmodule.mem_top _⟩, ⟨z, ih hz⟩, rfl⟩ /-- A central extension of nilpotent Lie algebras is nilpotent. -/ theorem LieAlgebra.nilpotent_of_nilpotent_quotient {I : LieIdeal R L} (h₁ : I ≤ center R L) (h₂ : IsNilpotent R (L ⧸ I)) : IsNilpotent R L := by suffices LieModule.IsNilpotent R L (L ⧸ I) by exact LieModule.nilpotentOfNilpotentQuotient R L L h₁ this obtain ⟨k, hk⟩ := h₂ use k simp [← LieSubmodule.coe_toSubmodule_eq_iff, coe_lowerCentralSeries_ideal_quot_eq, hk] theorem LieAlgebra.non_trivial_center_of_isNilpotent [Nontrivial L] [IsNilpotent R L] : Nontrivial <| center R L := LieModule.nontrivial_max_triv_of_isNilpotent R L L theorem LieIdeal.map_lowerCentralSeries_le (k : ℕ) {f : L →ₗ⁅R⁆ L'} : LieIdeal.map f (lowerCentralSeries R L L k) ≤ lowerCentralSeries R L' L' k := by induction' k with k ih · simp only [Nat.zero_eq, LieModule.lowerCentralSeries_zero, le_top] · simp only [LieModule.lowerCentralSeries_succ] exact le_trans (LieIdeal.map_bracket_le f) (LieSubmodule.mono_lie le_top ih) theorem LieIdeal.lowerCentralSeries_map_eq (k : ℕ) {f : L →ₗ⁅R⁆ L'} (h : Function.Surjective f) : LieIdeal.map f (lowerCentralSeries R L L k) = lowerCentralSeries R L' L' k := by have h' : (⊤ : LieIdeal R L).map f = ⊤ := by rw [← f.idealRange_eq_map] exact f.idealRange_eq_top_of_surjective h induction' k with k ih · simp only [LieModule.lowerCentralSeries_zero]; exact h' · simp only [LieModule.lowerCentralSeries_succ, LieIdeal.map_bracket_eq f h, ih, h'] theorem Function.Injective.lieAlgebra_isNilpotent [h₁ : IsNilpotent R L'] {f : L →ₗ⁅R⁆ L'} (h₂ : Function.Injective f) : IsNilpotent R L := { nilpotent := by obtain ⟨k, hk⟩ := id h₁ use k apply LieIdeal.bot_of_map_eq_bot h₂; rw [eq_bot_iff, ← hk] apply LieIdeal.map_lowerCentralSeries_le } theorem Function.Surjective.lieAlgebra_isNilpotent [h₁ : IsNilpotent R L] {f : L →ₗ⁅R⁆ L'} (h₂ : Function.Surjective f) : IsNilpotent R L' := { nilpotent := by obtain ⟨k, hk⟩ := id h₁ use k rw [← LieIdeal.lowerCentralSeries_map_eq k h₂, hk] simp only [LieIdeal.map_eq_bot_iff, bot_le] } theorem LieEquiv.nilpotent_iff_equiv_nilpotent (e : L ≃ₗ⁅R⁆ L') : IsNilpotent R L ↔ IsNilpotent R L' := by constructor <;> intro h · exact e.symm.injective.lieAlgebra_isNilpotent · exact e.injective.lieAlgebra_isNilpotent theorem LieHom.isNilpotent_range [IsNilpotent R L] (f : L →ₗ⁅R⁆ L') : IsNilpotent R f.range := f.surjective_rangeRestrict.lieAlgebra_isNilpotent /-- Note that this result is not quite a special case of `LieModule.isNilpotent_range_toEnd_iff` which concerns nilpotency of the `(ad R L).range`-module `L`, whereas this result concerns nilpotency of the `(ad R L).range`-module `(ad R L).range`. -/ @[simp] theorem LieAlgebra.isNilpotent_range_ad_iff : IsNilpotent R (ad R L).range ↔ IsNilpotent R L := by refine ⟨fun h => ?_, ?_⟩ · have : (ad R L).ker = center R L := by simp exact LieAlgebra.nilpotent_of_nilpotent_quotient (le_of_eq this) ((ad R L).quotKerEquivRange.nilpotent_iff_equiv_nilpotent.mpr h) · intro h exact (ad R L).isNilpotent_range instance [h : LieAlgebra.IsNilpotent R L] : LieAlgebra.IsNilpotent R (⊤ : LieSubalgebra R L) := LieSubalgebra.topEquiv.nilpotent_iff_equiv_nilpotent.mpr h end NilpotentAlgebras namespace LieIdeal open LieModule variable {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L) variable (M : Type*) [AddCommGroup M] [Module R M] [LieRingModule L M] variable (k : ℕ) /-- Given a Lie module `M` over a Lie algebra `L` together with an ideal `I` of `L`, this is the lower central series of `M` as an `I`-module. The advantage of using this definition instead of `LieModule.lowerCentralSeries R I M` is that its terms are Lie submodules of `M` as an `L`-module, rather than just as an `I`-module. See also `LieIdeal.coe_lcs_eq`. -/ def lcs : LieSubmodule R L M := (fun N => ⁅I, N⁆)^[k] ⊤ @[simp] theorem lcs_zero : I.lcs M 0 = ⊤ := rfl @[simp] theorem lcs_succ : I.lcs M (k + 1) = ⁅I, I.lcs M k⁆ := Function.iterate_succ_apply' (fun N => ⁅I, N⁆) k ⊤ theorem lcs_top : (⊤ : LieIdeal R L).lcs M k = lowerCentralSeries R L M k := rfl -- Porting note: added `LieSubmodule.toSubmodule` in the statement theorem coe_lcs_eq [LieModule R L M] : LieSubmodule.toSubmodule (I.lcs M k) = lowerCentralSeries R I M k := by induction' k with k ih · simp · simp_rw [lowerCentralSeries_succ, lcs_succ, LieSubmodule.lieIdeal_oper_eq_linear_span', ← (I.lcs M k).mem_coeSubmodule, ih, LieSubmodule.mem_coeSubmodule, LieSubmodule.mem_top, true_and, (I : LieSubalgebra R L).coe_bracket_of_module] congr ext m constructor · rintro ⟨x, hx, m, hm, rfl⟩ exact ⟨⟨x, hx⟩, m, hm, rfl⟩ · rintro ⟨⟨x, hx⟩, m, hm, rfl⟩ exact ⟨x, hx, m, hm, rfl⟩ end LieIdeal section OfAssociative variable (R : Type u) {A : Type v} [CommRing R] [Ring A] [Algebra R A] theorem _root_.LieAlgebra.ad_nilpotent_of_nilpotent {a : A} (h : IsNilpotent a) : IsNilpotent (LieAlgebra.ad R A a) := by rw [LieAlgebra.ad_eq_lmul_left_sub_lmul_right] have hl : IsNilpotent (LinearMap.mulLeft R a) := by rwa [LinearMap.isNilpotent_mulLeft_iff] have hr : IsNilpotent (LinearMap.mulRight R a) := by rwa [LinearMap.isNilpotent_mulRight_iff] have := @LinearMap.commute_mulLeft_right R A _ _ _ _ _ a a exact this.isNilpotent_sub hl hr variable {R} theorem _root_.LieSubalgebra.isNilpotent_ad_of_isNilpotent_ad {L : Type v} [LieRing L] [LieAlgebra R L] (K : LieSubalgebra R L) {x : K} (h : IsNilpotent (LieAlgebra.ad R L ↑x)) : IsNilpotent (LieAlgebra.ad R K x) := by obtain ⟨n, hn⟩ := h use n exact LinearMap.submodule_pow_eq_zero_of_pow_eq_zero (K.ad_comp_incl_eq x) hn theorem _root_.LieAlgebra.isNilpotent_ad_of_isNilpotent {L : LieSubalgebra R A} {x : L} (h : IsNilpotent (x : A)) : IsNilpotent (LieAlgebra.ad R L x) := L.isNilpotent_ad_of_isNilpotent_ad <| LieAlgebra.ad_nilpotent_of_nilpotent R h end OfAssociative section ExtendScalars open LieModule TensorProduct variable (R A L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] [CommRing A] [Algebra R A] @[simp] lemma LieSubmodule.lowerCentralSeries_tensor_eq_baseChange (k : ℕ) : lowerCentralSeries A (A ⊗[R] L) (A ⊗[R] M) k = (lowerCentralSeries R L M k).baseChange A := by induction' k with k ih · simp simp only [lowerCentralSeries_succ, ih, ← baseChange_top, lie_baseChange] instance LieModule.instIsNilpotentTensor [IsNilpotent R L M] : IsNilpotent A (A ⊗[R] L) (A ⊗[R] M) := by obtain ⟨k, hk⟩ := inferInstanceAs (IsNilpotent R L M) exact ⟨k, by simp [hk]⟩ end ExtendScalars
Algebra\Lie\NonUnitalNonAssocAlgebra.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Algebra.NonUnitalHom import Mathlib.Algebra.Lie.Basic /-! # Lie algebras as non-unital, non-associative algebras The definition of Lie algebras uses the `Bracket` typeclass for multiplication whereas we have a separate `Mul` typeclass used for general algebras. It is useful to have a special typeclass for Lie algebras because: * it enables us to use the traditional notation `⁅x, y⁆` for the Lie multiplication, * associative algebras carry a natural Lie algebra structure via the ring commutator and so we need them to carry both `Mul` and `Bracket` simultaneously, * more generally, Poisson algebras (not yet defined) need both typeclasses. However there are times when it is convenient to be able to regard a Lie algebra as a general algebra and we provide some basic definitions for doing so here. ## Main definitions * `CommutatorRing` turns a Lie ring into a `NonUnitalNonAssocSemiring` by turning its `Bracket` (denoted `⁅, ⁆`) into a `Mul` (denoted `*`). * `LieHom.toNonUnitalAlgHom` ## Tags lie algebra, non-unital, non-associative -/ universe u v w variable (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L] /-- Type synonym for turning a `LieRing` into a `NonUnitalNonAssocSemiring`. A `LieRing` can be regarded as a `NonUnitalNonAssocSemiring` by turning its `Bracket` (denoted `⁅, ⁆`) into a `Mul` (denoted `*`). -/ def CommutatorRing (L : Type v) : Type v := L /-- A `LieRing` can be regarded as a `NonUnitalNonAssocSemiring` by turning its `Bracket` (denoted `⁅, ⁆`) into a `Mul` (denoted `*`). -/ instance : NonUnitalNonAssocSemiring (CommutatorRing L) := show NonUnitalNonAssocSemiring L from { (inferInstance : AddCommMonoid L) with mul := Bracket.bracket left_distrib := lie_add right_distrib := add_lie zero_mul := zero_lie mul_zero := lie_zero } namespace LieAlgebra instance (L : Type v) [Nonempty L] : Nonempty (CommutatorRing L) := ‹Nonempty L› instance (L : Type v) [Inhabited L] : Inhabited (CommutatorRing L) := ‹Inhabited L› instance : LieRing (CommutatorRing L) := show LieRing L by infer_instance instance : LieAlgebra R (CommutatorRing L) := show LieAlgebra R L by infer_instance /-- Regarding the `LieRing` of a `LieAlgebra` as a `NonUnitalNonAssocSemiring`, we can reinterpret the `smul_lie` law as an `IsScalarTower`. -/ instance isScalarTower : IsScalarTower R (CommutatorRing L) (CommutatorRing L) := ⟨smul_lie⟩ /-- Regarding the `LieRing` of a `LieAlgebra` as a `NonUnitalNonAssocSemiring`, we can reinterpret the `lie_smul` law as an `SMulCommClass`. -/ instance smulCommClass : SMulCommClass R (CommutatorRing L) (CommutatorRing L) := ⟨fun t x y => (lie_smul t x y).symm⟩ end LieAlgebra namespace LieHom variable {R L} variable {L₂ : Type w} [LieRing L₂] [LieAlgebra R L₂] /-- Regarding the `LieRing` of a `LieAlgebra` as a `NonUnitalNonAssocSemiring`, we can regard a `LieHom` as a `NonUnitalAlgHom`. -/ @[simps] def toNonUnitalAlgHom (f : L →ₗ⁅R⁆ L₂) : CommutatorRing L →ₙₐ[R] CommutatorRing L₂ := { f with toFun := f map_zero' := f.map_zero map_mul' := f.map_lie } theorem toNonUnitalAlgHom_injective : Function.Injective (toNonUnitalAlgHom : _ → CommutatorRing L →ₙₐ[R] CommutatorRing L₂) := fun _ _ h => ext <| NonUnitalAlgHom.congr_fun h end LieHom
Algebra\Lie\Normalizer.lean
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Abelian import Mathlib.Algebra.Lie.IdealOperations import Mathlib.Algebra.Lie.Quotient /-! # The normalizer of Lie submodules and subalgebras. Given a Lie module `M` over a Lie subalgebra `L`, the normalizer of a Lie submodule `N ⊆ M` is the Lie submodule with underlying set `{ m | ∀ (x : L), ⁅x, m⁆ ∈ N }`. The lattice of Lie submodules thus has two natural operations, the normalizer: `N ↦ N.normalizer` and the ideal operation: `N ↦ ⁅⊤, N⁆`; these are adjoint, i.e., they form a Galois connection. This adjointness is the reason that we may define nilpotency in terms of either the upper or lower central series. Given a Lie subalgebra `H ⊆ L`, we may regard `H` as a Lie submodule of `L` over `H`, and thus consider the normalizer. This turns out to be a Lie subalgebra. ## Main definitions * `LieSubmodule.normalizer` * `LieSubalgebra.normalizer` * `LieSubmodule.gc_top_lie_normalizer` ## Tags lie algebra, normalizer -/ variable {R L M M' : Type*} variable [CommRing R] [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [AddCommGroup M'] [Module R M'] [LieRingModule L M'] [LieModule R L M'] namespace LieSubmodule variable (N : LieSubmodule R L M) {N₁ N₂ : LieSubmodule R L M} /-- The normalizer of a Lie submodule. See also `LieSubmodule.idealizer`. -/ def normalizer : LieSubmodule R L M where carrier := {m | ∀ x : L, ⁅x, m⁆ ∈ N} add_mem' hm₁ hm₂ x := by rw [lie_add]; exact N.add_mem' (hm₁ x) (hm₂ x) zero_mem' x := by simp smul_mem' t m hm x := by rw [lie_smul]; exact N.smul_mem' t (hm x) lie_mem {x m} hm y := by rw [leibniz_lie]; exact N.add_mem' (hm ⁅y, x⁆) (N.lie_mem (hm y)) @[simp] theorem mem_normalizer (m : M) : m ∈ N.normalizer ↔ ∀ x : L, ⁅x, m⁆ ∈ N := Iff.rfl @[simp] theorem le_normalizer : N ≤ N.normalizer := by intro m hm rw [mem_normalizer] exact fun x => N.lie_mem hm theorem normalizer_inf : (N₁ ⊓ N₂).normalizer = N₁.normalizer ⊓ N₂.normalizer := by ext; simp [← forall_and] @[gcongr, mono] theorem normalizer_mono (h : N₁ ≤ N₂) : normalizer N₁ ≤ normalizer N₂ := by intro m hm rw [mem_normalizer] at hm ⊢ exact fun x ↦ h (hm x) theorem monotone_normalizer : Monotone (normalizer : LieSubmodule R L M → LieSubmodule R L M) := fun _ _ ↦ normalizer_mono @[simp] theorem comap_normalizer (f : M' →ₗ⁅R,L⁆ M) : N.normalizer.comap f = (N.comap f).normalizer := by ext; simp theorem top_lie_le_iff_le_normalizer (N' : LieSubmodule R L M) : ⁅(⊤ : LieIdeal R L), N⁆ ≤ N' ↔ N ≤ N'.normalizer := by rw [lie_le_iff]; tauto theorem gc_top_lie_normalizer : GaloisConnection (fun N : LieSubmodule R L M => ⁅(⊤ : LieIdeal R L), N⁆) normalizer := top_lie_le_iff_le_normalizer variable (R L M) in theorem normalizer_bot_eq_maxTrivSubmodule : (⊥ : LieSubmodule R L M).normalizer = LieModule.maxTrivSubmodule R L M := rfl /-- The idealizer of a Lie submodule. See also `LieSubmodule.normalizer`. -/ def idealizer : LieIdeal R L where carrier := {x : L | ∀ m : M, ⁅x, m⁆ ∈ N} add_mem' := fun {x} {y} hx hy m ↦ by rw [add_lie]; exact N.add_mem (hx m) (hy m) zero_mem' := by simp smul_mem' := fun t {x} hx m ↦ by rw [smul_lie]; exact N.smul_mem t (hx m) lie_mem := fun {x} {y} hy m ↦ by rw [lie_lie]; exact sub_mem (N.lie_mem (hy m)) (hy ⁅x, m⁆) @[simp] lemma mem_idealizer {x : L} : x ∈ N.idealizer ↔ ∀ m : M, ⁅x, m⁆ ∈ N := Iff.rfl @[simp] lemma _root_.LieIdeal.idealizer_eq_normalizer (I : LieIdeal R L) : I.idealizer = I.normalizer := by ext x; exact forall_congr' fun y ↦ by simp only [← lie_skew x y, neg_mem_iff] end LieSubmodule namespace LieSubalgebra variable (H : LieSubalgebra R L) /-- Regarding a Lie subalgebra `H ⊆ L` as a module over itself, its normalizer is in fact a Lie subalgebra. -/ def normalizer : LieSubalgebra R L := { H.toLieSubmodule.normalizer with lie_mem' := fun {y z} hy hz x => by rw [coe_bracket_of_module, mem_toLieSubmodule, leibniz_lie, ← lie_skew y, ← sub_eq_add_neg] exact H.sub_mem (hz ⟨_, hy x⟩) (hy ⟨_, hz x⟩) } theorem mem_normalizer_iff' (x : L) : x ∈ H.normalizer ↔ ∀ y : L, y ∈ H → ⁅y, x⁆ ∈ H := by rw [Subtype.forall']; rfl theorem mem_normalizer_iff (x : L) : x ∈ H.normalizer ↔ ∀ y : L, y ∈ H → ⁅x, y⁆ ∈ H := by rw [mem_normalizer_iff'] refine forall₂_congr fun y hy => ?_ rw [← lie_skew, neg_mem_iff (G := L)] theorem le_normalizer : H ≤ H.normalizer := H.toLieSubmodule.le_normalizer theorem coe_normalizer_eq_normalizer : (H.toLieSubmodule.normalizer : Submodule R L) = H.normalizer := rfl variable {H} theorem lie_mem_sup_of_mem_normalizer {x y z : L} (hx : x ∈ H.normalizer) (hy : y ∈ (R ∙ x) ⊔ ↑H) (hz : z ∈ (R ∙ x) ⊔ ↑H) : ⁅y, z⁆ ∈ (R ∙ x) ⊔ ↑H := by rw [Submodule.mem_sup] at hy hz obtain ⟨u₁, hu₁, v, hv : v ∈ H, rfl⟩ := hy obtain ⟨u₂, hu₂, w, hw : w ∈ H, rfl⟩ := hz obtain ⟨t, rfl⟩ := Submodule.mem_span_singleton.mp hu₁ obtain ⟨s, rfl⟩ := Submodule.mem_span_singleton.mp hu₂ apply Submodule.mem_sup_right simp only [LieSubalgebra.mem_coe_submodule, smul_lie, add_lie, zero_add, lie_add, smul_zero, lie_smul, lie_self] refine H.add_mem (H.smul_mem s ?_) (H.add_mem (H.smul_mem t ?_) (H.lie_mem hv hw)) exacts [(H.mem_normalizer_iff' x).mp hx v hv, (H.mem_normalizer_iff x).mp hx w hw] /-- A Lie subalgebra is an ideal of its normalizer. -/ theorem ideal_in_normalizer {x y : L} (hx : x ∈ H.normalizer) (hy : y ∈ H) : ⁅x, y⁆ ∈ H := by rw [← lie_skew, neg_mem_iff (G := L)] exact hx ⟨y, hy⟩ /-- A Lie subalgebra `H` is an ideal of any Lie subalgebra `K` containing `H` and contained in the normalizer of `H`. -/ theorem exists_nested_lieIdeal_ofLe_normalizer {K : LieSubalgebra R L} (h₁ : H ≤ K) (h₂ : K ≤ H.normalizer) : ∃ I : LieIdeal R K, (I : LieSubalgebra R K) = ofLe h₁ := by rw [exists_nested_lieIdeal_coe_eq_iff] exact fun x y hx hy => ideal_in_normalizer (h₂ hx) hy variable (H) theorem normalizer_eq_self_iff : H.normalizer = H ↔ (LieModule.maxTrivSubmodule R H <| L ⧸ H.toLieSubmodule) = ⊥ := by rw [LieSubmodule.eq_bot_iff] refine ⟨fun h => ?_, fun h => le_antisymm ?_ H.le_normalizer⟩ · rintro ⟨x⟩ hx suffices x ∈ H by rwa [Submodule.Quotient.quot_mk_eq_mk, Submodule.Quotient.mk_eq_zero, coe_toLieSubmodule, mem_coe_submodule] rw [← h, H.mem_normalizer_iff'] intro y hy replace hx : ⁅_, LieSubmodule.Quotient.mk' _ x⁆ = 0 := hx ⟨y, hy⟩ rwa [← LieModuleHom.map_lie, LieSubmodule.Quotient.mk_eq_zero] at hx · intro x hx let y := LieSubmodule.Quotient.mk' H.toLieSubmodule x have hy : y ∈ LieModule.maxTrivSubmodule R H (L ⧸ H.toLieSubmodule) := by rintro ⟨z, hz⟩ rw [← LieModuleHom.map_lie, LieSubmodule.Quotient.mk_eq_zero, coe_bracket_of_module, Submodule.coe_mk, mem_toLieSubmodule] exact (H.mem_normalizer_iff' x).mp hx z hz simpa [y] using h y hy end LieSubalgebra
Algebra\Lie\OfAssociative.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Basic import Mathlib.Algebra.Lie.Subalgebra import Mathlib.Algebra.Lie.Submodule import Mathlib.Algebra.Algebra.Subalgebra.Basic /-! # Lie algebras of associative algebras This file defines the Lie algebra structure that arises on an associative algebra via the ring commutator. Since the linear endomorphisms of a Lie algebra form an associative algebra, one can define the adjoint action as a morphism of Lie algebras from a Lie algebra to its linear endomorphisms. We make such a definition in this file. ## Main definitions * `LieAlgebra.ofAssociativeAlgebra` * `LieAlgebra.ofAssociativeAlgebraHom` * `LieModule.toEnd` * `LieAlgebra.ad` * `LinearEquiv.lieConj` * `AlgEquiv.toLieEquiv` ## Tags lie algebra, ring commutator, adjoint action -/ universe u v w w₁ w₂ section OfAssociative variable {A : Type v} [Ring A] namespace LieRing /-- An associative ring gives rise to a Lie ring by taking the bracket to be the ring commutator. -/ instance (priority := 100) ofAssociativeRing : LieRing A where add_lie _ _ _ := by simp only [Ring.lie_def, right_distrib, left_distrib]; abel lie_add _ _ _ := by simp only [Ring.lie_def, right_distrib, left_distrib]; abel lie_self := by simp only [Ring.lie_def, forall_const, sub_self] leibniz_lie _ _ _ := by simp only [Ring.lie_def, mul_sub_left_distrib, mul_sub_right_distrib, mul_assoc]; abel theorem of_associative_ring_bracket (x y : A) : ⁅x, y⁆ = x * y - y * x := rfl @[simp] theorem lie_apply {α : Type*} (f g : α → A) (a : α) : ⁅f, g⁆ a = ⁅f a, g a⁆ := rfl end LieRing section AssociativeModule variable {M : Type w} [AddCommGroup M] [Module A M] /-- We can regard a module over an associative ring `A` as a Lie ring module over `A` with Lie bracket equal to its ring commutator. Note that this cannot be a global instance because it would create a diamond when `M = A`, specifically we can build two mathematically-different `bracket A A`s: 1. `@Ring.bracket A _` which says `⁅a, b⁆ = a * b - b * a` 2. `(@LieRingModule.ofAssociativeModule A _ A _ _).toBracket` which says `⁅a, b⁆ = a • b` (and thus `⁅a, b⁆ = a * b`) See note [reducible non-instances] -/ abbrev LieRingModule.ofAssociativeModule : LieRingModule A M where bracket := (· • ·) add_lie := add_smul lie_add := smul_add leibniz_lie := by simp [LieRing.of_associative_ring_bracket, sub_smul, mul_smul, sub_add_cancel] attribute [local instance] LieRingModule.ofAssociativeModule theorem lie_eq_smul (a : A) (m : M) : ⁅a, m⁆ = a • m := rfl end AssociativeModule section LieAlgebra variable {R : Type u} [CommRing R] [Algebra R A] /-- An associative algebra gives rise to a Lie algebra by taking the bracket to be the ring commutator. -/ instance (priority := 100) LieAlgebra.ofAssociativeAlgebra : LieAlgebra R A where lie_smul t x y := by rw [LieRing.of_associative_ring_bracket, LieRing.of_associative_ring_bracket, Algebra.mul_smul_comm, Algebra.smul_mul_assoc, smul_sub] attribute [local instance] LieRingModule.ofAssociativeModule section AssociativeRepresentation variable {M : Type w} [AddCommGroup M] [Module R M] [Module A M] [IsScalarTower R A M] /-- A representation of an associative algebra `A` is also a representation of `A`, regarded as a Lie algebra via the ring commutator. See the comment at `LieRingModule.ofAssociativeModule` for why the possibility `M = A` means this cannot be a global instance. -/ theorem LieModule.ofAssociativeModule : LieModule R A M where smul_lie := smul_assoc lie_smul := smul_algebra_smul_comm instance Module.End.instLieRingModule : LieRingModule (Module.End R M) M := LieRingModule.ofAssociativeModule instance Module.End.instLieModule : LieModule R (Module.End R M) M := LieModule.ofAssociativeModule @[simp] lemma Module.End.lie_apply (f : Module.End R M) (m : M) : ⁅f, m⁆ = f m := rfl end AssociativeRepresentation namespace AlgHom variable {B : Type w} {C : Type w₁} [Ring B] [Ring C] [Algebra R B] [Algebra R C] variable (f : A →ₐ[R] B) (g : B →ₐ[R] C) /-- The map `ofAssociativeAlgebra` associating a Lie algebra to an associative algebra is functorial. -/ def toLieHom : A →ₗ⁅R⁆ B := { f.toLinearMap with map_lie' := fun {_ _} => by simp [LieRing.of_associative_ring_bracket] } instance : Coe (A →ₐ[R] B) (A →ₗ⁅R⁆ B) := ⟨toLieHom⟩ /- Porting note: is a syntactic tautology @[simp] theorem toLieHom_coe : f.toLieHom = ↑f := rfl -/ @[simp] theorem coe_toLieHom : ((f : A →ₗ⁅R⁆ B) : A → B) = f := rfl theorem toLieHom_apply (x : A) : f.toLieHom x = f x := rfl @[simp] theorem toLieHom_id : (AlgHom.id R A : A →ₗ⁅R⁆ A) = LieHom.id := rfl @[simp] theorem toLieHom_comp : (g.comp f : A →ₗ⁅R⁆ C) = (g : B →ₗ⁅R⁆ C).comp (f : A →ₗ⁅R⁆ B) := rfl theorem toLieHom_injective {f g : A →ₐ[R] B} (h : (f : A →ₗ⁅R⁆ B) = (g : A →ₗ⁅R⁆ B)) : f = g := by ext a; exact LieHom.congr_fun h a end AlgHom end LieAlgebra end OfAssociative section AdjointAction variable (R : Type u) (L : Type v) (M : Type w) variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] [LieModule R L M] /-- A Lie module yields a Lie algebra morphism into the linear endomorphisms of the module. See also `LieModule.toModuleHom`. -/ @[simps] def LieModule.toEnd : L →ₗ⁅R⁆ Module.End R M where toFun x := { toFun := fun m => ⁅x, m⁆ map_add' := lie_add x map_smul' := fun t => lie_smul t x } map_add' x y := by ext m; apply add_lie map_smul' t x := by ext m; apply smul_lie map_lie' {x y} := by ext m; apply lie_lie /-- The adjoint action of a Lie algebra on itself. -/ def LieAlgebra.ad : L →ₗ⁅R⁆ Module.End R L := LieModule.toEnd R L L @[simp] theorem LieAlgebra.ad_apply (x y : L) : LieAlgebra.ad R L x y = ⁅x, y⁆ := rfl @[simp] theorem LieModule.toEnd_module_end : LieModule.toEnd R (Module.End R M) M = LieHom.id := by ext g m; simp [lie_eq_smul] theorem LieSubalgebra.toEnd_eq (K : LieSubalgebra R L) {x : K} : LieModule.toEnd R K M x = LieModule.toEnd R L M x := rfl @[simp] theorem LieSubalgebra.toEnd_mk (K : LieSubalgebra R L) {x : L} (hx : x ∈ K) : LieModule.toEnd R K M ⟨x, hx⟩ = LieModule.toEnd R L M x := rfl section open LieAlgebra LieModule lemma LieSubmodule.coe_toEnd (N : LieSubmodule R L M) (x : L) (y : N) : (toEnd R L N x y : M) = toEnd R L M x y := rfl lemma LieSubmodule.coe_toEnd_pow (N : LieSubmodule R L M) (x : L) (y : N) (n : ℕ) : ((toEnd R L N x ^ n) y : M) = (toEnd R L M x ^ n) y := by induction n generalizing y with | zero => rfl | succ n ih => simp only [pow_succ', LinearMap.mul_apply, ih, LieSubmodule.coe_toEnd] lemma LieSubalgebra.coe_ad (H : LieSubalgebra R L) (x y : H) : (ad R H x y : L) = ad R L x y := rfl lemma LieSubalgebra.coe_ad_pow (H : LieSubalgebra R L) (x y : H) (n : ℕ) : ((ad R H x ^ n) y : L) = (ad R L x ^ n) y := LieSubmodule.coe_toEnd_pow R H L H.toLieSubmodule x y n variable {L M} local notation "φ" => LieModule.toEnd R L M lemma LieModule.toEnd_lie (x y : L) (z : M) : (φ x) ⁅y, z⁆ = ⁅ad R L x y, z⁆ + ⁅y, φ x z⁆ := by simp lemma LieAlgebra.ad_lie (x y z : L) : (ad R L x) ⁅y, z⁆ = ⁅ad R L x y, z⁆ + ⁅y, ad R L x z⁆ := toEnd_lie _ x y z open Finset in lemma LieModule.toEnd_pow_lie (x y : L) (z : M) (n : ℕ) : ((φ x) ^ n) ⁅y, z⁆ = ∑ ij ∈ antidiagonal n, n.choose ij.1 • ⁅((ad R L x) ^ ij.1) y, ((φ x) ^ ij.2) z⁆ := by induction n with | zero => simp | succ n ih => rw [Finset.sum_antidiagonal_choose_succ_nsmul (fun i j ↦ ⁅((ad R L x) ^ i) y, ((φ x) ^ j) z⁆) n] simp only [pow_succ', LinearMap.mul_apply, ih, map_sum, map_nsmul, toEnd_lie, nsmul_add, sum_add_distrib] rw [add_comm, add_left_cancel_iff, sum_congr rfl] rintro ⟨i, j⟩ hij rw [mem_antidiagonal] at hij rw [Nat.choose_symm_of_eq_add hij.symm] open Finset in lemma LieAlgebra.ad_pow_lie (x y z : L) (n : ℕ) : ((ad R L x) ^ n) ⁅y, z⁆ = ∑ ij ∈ antidiagonal n, n.choose ij.1 • ⁅((ad R L x) ^ ij.1) y, ((ad R L x) ^ ij.2) z⁆ := toEnd_pow_lie _ x y z n end variable {R L M} namespace LieModule variable {M₂ : Type w₁} [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂] (f : M →ₗ⁅R,L⁆ M₂) (k : ℕ) (x : L) lemma toEnd_pow_comp_lieHom : (toEnd R L M₂ x ^ k) ∘ₗ f = f ∘ₗ toEnd R L M x ^ k := by apply LinearMap.commute_pow_left_of_commute ext simp lemma toEnd_pow_apply_map (m : M) : (toEnd R L M₂ x ^ k) (f m) = f ((toEnd R L M x ^ k) m) := LinearMap.congr_fun (toEnd_pow_comp_lieHom f k x) m end LieModule namespace LieSubmodule open LieModule Set variable {N : LieSubmodule R L M} {x : L} theorem coe_map_toEnd_le : (N : Submodule R M).map (LieModule.toEnd R L M x) ≤ N := by rintro n ⟨m, hm, rfl⟩ exact N.lie_mem hm variable (N x) theorem toEnd_comp_subtype_mem (m : M) (hm : m ∈ (N : Submodule R M)) : (toEnd R L M x).comp (N : Submodule R M).subtype ⟨m, hm⟩ ∈ (N : Submodule R M) := by simpa using N.lie_mem hm @[simp] theorem toEnd_restrict_eq_toEnd (h := N.toEnd_comp_subtype_mem x) : (toEnd R L M x).restrict h = toEnd R L N x := by ext; simp [LinearMap.restrict_apply] lemma mapsTo_pow_toEnd_sub_algebraMap {φ : R} {k : ℕ} {x : L} : MapsTo ((toEnd R L M x - algebraMap R (Module.End R M) φ) ^ k) N N := by rw [LinearMap.coe_pow] exact MapsTo.iterate (fun m hm ↦ N.sub_mem (N.lie_mem hm) (N.smul_mem _ hm)) k end LieSubmodule open LieAlgebra theorem LieAlgebra.ad_eq_lmul_left_sub_lmul_right (A : Type v) [Ring A] [Algebra R A] : (ad R A : A → Module.End R A) = LinearMap.mulLeft R - LinearMap.mulRight R := by ext a b; simp [LieRing.of_associative_ring_bracket] theorem LieSubalgebra.ad_comp_incl_eq (K : LieSubalgebra R L) (x : K) : (ad R L ↑x).comp (K.incl : K →ₗ[R] L) = (K.incl : K →ₗ[R] L).comp (ad R K x) := by ext y simp only [ad_apply, LieHom.coe_toLinearMap, LieSubalgebra.coe_incl, LinearMap.coe_comp, LieSubalgebra.coe_bracket, Function.comp_apply] end AdjointAction /-- A subalgebra of an associative algebra is a Lie subalgebra of the associated Lie algebra. -/ def lieSubalgebraOfSubalgebra (R : Type u) [CommRing R] (A : Type v) [Ring A] [Algebra R A] (A' : Subalgebra R A) : LieSubalgebra R A := { Subalgebra.toSubmodule A' with lie_mem' := fun {x y} hx hy => by change ⁅x, y⁆ ∈ A'; change x ∈ A' at hx; change y ∈ A' at hy rw [LieRing.of_associative_ring_bracket] have hxy := A'.mul_mem hx hy have hyx := A'.mul_mem hy hx exact Submodule.sub_mem (Subalgebra.toSubmodule A') hxy hyx } namespace LinearEquiv variable {R : Type u} {M₁ : Type v} {M₂ : Type w} variable [CommRing R] [AddCommGroup M₁] [Module R M₁] [AddCommGroup M₂] [Module R M₂] variable (e : M₁ ≃ₗ[R] M₂) /-- A linear equivalence of two modules induces a Lie algebra equivalence of their endomorphisms. -/ def lieConj : Module.End R M₁ ≃ₗ⁅R⁆ Module.End R M₂ := { e.conj with map_lie' := fun {f g} => show e.conj ⁅f, g⁆ = ⁅e.conj f, e.conj g⁆ by simp only [LieRing.of_associative_ring_bracket, LinearMap.mul_eq_comp, e.conj_comp, map_sub] } @[simp] theorem lieConj_apply (f : Module.End R M₁) : e.lieConj f = e.conj f := rfl @[simp] theorem lieConj_symm : e.lieConj.symm = e.symm.lieConj := rfl end LinearEquiv namespace AlgEquiv variable {R : Type u} {A₁ : Type v} {A₂ : Type w} variable [CommRing R] [Ring A₁] [Ring A₂] [Algebra R A₁] [Algebra R A₂] variable (e : A₁ ≃ₐ[R] A₂) /-- An equivalence of associative algebras is an equivalence of associated Lie algebras. -/ def toLieEquiv : A₁ ≃ₗ⁅R⁆ A₂ := { e.toLinearEquiv with toFun := e.toFun map_lie' := fun {x y} => by have : e.toEquiv.toFun = e := rfl simp_rw [LieRing.of_associative_ring_bracket, this, map_sub, map_mul] } @[simp] theorem toLieEquiv_apply (x : A₁) : e.toLieEquiv x = e x := rfl @[simp] theorem toLieEquiv_symm_apply (x : A₂) : e.toLieEquiv.symm x = e.symm x := rfl end AlgEquiv namespace LieAlgebra variable {R L L' : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] open LieEquiv /-- Given an equivalence `e` of Lie algebras from `L` to `L'`, and an element `x : L`, the conjugate of the endomorphism `ad(x)` of `L` by `e` is the endomorphism `ad(e x)` of `L'`. -/ @[simp] lemma conj_ad_apply (e : L ≃ₗ⁅R⁆ L') (x : L) : LinearEquiv.conj e (ad R L x) = ad R L' (e x) := by ext y' rw [LinearEquiv.conj_apply_apply, ad_apply, ad_apply, coe_to_linearEquiv, map_lie, ← coe_to_linearEquiv, LinearEquiv.apply_symm_apply] end LieAlgebra
Algebra\Lie\Quotient.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Submodule import Mathlib.Algebra.Lie.OfAssociative import Mathlib.LinearAlgebra.Isomorphisms /-! # Quotients of Lie algebras and Lie modules Given a Lie submodule of a Lie module, the quotient carries a natural Lie module structure. In the special case that the Lie module is the Lie algebra itself via the adjoint action, the submodule is a Lie ideal and the quotient carries a natural Lie algebra structure. We define these quotient structures here. A notable omission at the time of writing (February 2021) is a statement and proof of the universal property of these quotients. ## Main definitions * `LieSubmodule.Quotient.lieQuotientLieModule` * `LieSubmodule.Quotient.lieQuotientLieAlgebra` ## Tags lie algebra, quotient -/ universe u v w w₁ w₂ namespace LieSubmodule variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] variable (N N' : LieSubmodule R L M) /-- The quotient of a Lie module by a Lie submodule. It is a Lie module. -/ instance : HasQuotient M (LieSubmodule R L M) := ⟨fun N => M ⧸ N.toSubmodule⟩ namespace Quotient variable {N I} instance addCommGroup : AddCommGroup (M ⧸ N) := Submodule.Quotient.addCommGroup _ instance module' {S : Type*} [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : Module S (M ⧸ N) := Submodule.Quotient.module' _ instance module : Module R (M ⧸ N) := Submodule.Quotient.module _ instance isCentralScalar {S : Type*} [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] [SMul Sᵐᵒᵖ R] [Module Sᵐᵒᵖ M] [IsScalarTower Sᵐᵒᵖ R M] [IsCentralScalar S M] : IsCentralScalar S (M ⧸ N) := Submodule.Quotient.isCentralScalar _ instance inhabited : Inhabited (M ⧸ N) := ⟨0⟩ /-- Map sending an element of `M` to the corresponding element of `M/N`, when `N` is a lie_submodule of the lie_module `N`. -/ abbrev mk : M → M ⧸ N := Submodule.Quotient.mk -- Porting note: added to replace `mk_eq_zero` as simp lemma. @[simp] theorem mk_eq_zero' {m : M} : mk (N := N) m = 0 ↔ m ∈ N := Submodule.Quotient.mk_eq_zero N.toSubmodule theorem is_quotient_mk (m : M) : Quotient.mk'' m = (mk m : M ⧸ N) := rfl variable [LieAlgebra R L] [LieModule R L M] (I J : LieIdeal R L) /-- Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N ⊆ M`, there is a natural linear map from `L` to the endomorphisms of `M` leaving `N` invariant. -/ def lieSubmoduleInvariant : L →ₗ[R] Submodule.compatibleMaps N.toSubmodule N.toSubmodule := LinearMap.codRestrict _ (LieModule.toEnd R L M) fun _ _ => N.lie_mem variable (N) /-- Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N ⊆ M`, there is a natural Lie algebra morphism from `L` to the linear endomorphism of the quotient `M/N`. -/ def actionAsEndoMap : L →ₗ⁅R⁆ Module.End R (M ⧸ N) := { LinearMap.comp (Submodule.mapQLinear (N : Submodule R M) (N : Submodule R M)) lieSubmoduleInvariant with map_lie' := fun {_ _} => Submodule.linearMap_qext _ <| LinearMap.ext fun _ => congr_arg mk <| lie_lie _ _ _ } /-- Given a Lie module `M` over a Lie algebra `L`, together with a Lie submodule `N ⊆ M`, there is a natural bracket action of `L` on the quotient `M/N`. -/ instance actionAsEndoMapBracket : Bracket L (M ⧸ N) := ⟨fun x n => actionAsEndoMap N x n⟩ instance lieQuotientLieRingModule : LieRingModule L (M ⧸ N) := { LieRingModule.compLieHom _ (actionAsEndoMap N) with bracket := Bracket.bracket } /-- The quotient of a Lie module by a Lie submodule, is a Lie module. -/ instance lieQuotientLieModule : LieModule R L (M ⧸ N) := LieModule.compLieHom _ (actionAsEndoMap N) instance lieQuotientHasBracket : Bracket (L ⧸ I) (L ⧸ I) := ⟨by intro x y apply Quotient.liftOn₂' x y fun x' y' => mk ⁅x', y'⁆ intro x₁ x₂ y₁ y₂ h₁ h₂ apply (Submodule.Quotient.eq I.toSubmodule).2 rw [Submodule.quotientRel_r_def] at h₁ h₂ have h : ⁅x₁, x₂⁆ - ⁅y₁, y₂⁆ = ⁅x₁, x₂ - y₂⁆ + ⁅x₁ - y₁, y₂⁆ := by simp [-lie_skew, sub_eq_add_neg, add_assoc] rw [h] apply Submodule.add_mem · apply lie_mem_right R L I x₁ (x₂ - y₂) h₂ · apply lie_mem_left R L I (x₁ - y₁) y₂ h₁⟩ @[simp] theorem mk_bracket (x y : L) : mk ⁅x, y⁆ = ⁅(mk x : L ⧸ I), (mk y : L ⧸ I)⁆ := rfl instance lieQuotientLieRing : LieRing (L ⧸ I) where add_lie := by intro x' y' z'; refine Quotient.inductionOn₃' x' y' z' ?_; intro x y z repeat' first | rw [is_quotient_mk] | rw [← mk_bracket] | rw [← Submodule.Quotient.mk_add (R := R) (M := L)] apply congr_arg; apply add_lie lie_add := by intro x' y' z'; refine Quotient.inductionOn₃' x' y' z' ?_; intro x y z repeat' first | rw [is_quotient_mk] | rw [← mk_bracket] | rw [← Submodule.Quotient.mk_add (R := R) (M := L)] apply congr_arg; apply lie_add lie_self := by intro x'; refine Quotient.inductionOn' x' ?_; intro x rw [is_quotient_mk, ← mk_bracket] apply congr_arg; apply lie_self leibniz_lie := by intro x' y' z'; refine Quotient.inductionOn₃' x' y' z' ?_; intro x y z repeat' first | rw [is_quotient_mk] | rw [← mk_bracket] | rw [← Submodule.Quotient.mk_add (R := R) (M := L)] apply congr_arg; apply leibniz_lie instance lieQuotientLieAlgebra : LieAlgebra R (L ⧸ I) where lie_smul := by intro t x' y'; refine Quotient.inductionOn₂' x' y' ?_; intro x y repeat' first | rw [is_quotient_mk] | rw [← mk_bracket] | rw [← Submodule.Quotient.mk_smul (R := R) (M := L)] apply congr_arg; apply lie_smul /-- `LieSubmodule.Quotient.mk` as a `LieModuleHom`. -/ @[simps] def mk' : M →ₗ⁅R,L⁆ M ⧸ N := { N.toSubmodule.mkQ with toFun := mk map_lie' := fun {_ _} => rfl } @[simp] theorem surjective_mk' : Function.Surjective (mk' N) := surjective_quot_mk _ @[simp] theorem range_mk' : LieModuleHom.range (mk' N) = ⊤ := by simp [LieModuleHom.range_eq_top] instance isNoetherian [IsNoetherian R M] : IsNoetherian R (M ⧸ N) := inferInstanceAs (IsNoetherian R (M ⧸ (N : Submodule R M))) -- Porting note: LHS simplifies @[simp] theorem mk_eq_zero {m : M} : mk' N m = 0 ↔ m ∈ N := Submodule.Quotient.mk_eq_zero N.toSubmodule @[simp] theorem mk'_ker : (mk' N).ker = N := by ext; simp @[simp] theorem map_mk'_eq_bot_le : map (mk' N) N' = ⊥ ↔ N' ≤ N := by rw [← LieModuleHom.le_ker_iff_map, mk'_ker] /-- Two `LieModuleHom`s from a quotient lie module are equal if their compositions with `LieSubmodule.Quotient.mk'` are equal. See note [partially-applied ext lemmas]. -/ @[ext] theorem lieModuleHom_ext ⦃f g : M ⧸ N →ₗ⁅R,L⁆ M⦄ (h : f.comp (mk' N) = g.comp (mk' N)) : f = g := LieModuleHom.ext fun x => Quotient.inductionOn' x <| LieModuleHom.congr_fun h lemma toEnd_comp_mk' (x : L) : LieModule.toEnd R L (M ⧸ N) x ∘ₗ mk' N = mk' N ∘ₗ LieModule.toEnd R L M x := rfl end Quotient end LieSubmodule namespace LieHom variable {R L L' : Type*} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] variable (f : L →ₗ⁅R⁆ L') /-- The first isomorphism theorem for morphisms of Lie algebras. -/ @[simps] noncomputable def quotKerEquivRange : (L ⧸ f.ker) ≃ₗ⁅R⁆ f.range := { (f : L →ₗ[R] L').quotKerEquivRange with toFun := (f : L →ₗ[R] L').quotKerEquivRange map_lie' := by rintro ⟨x⟩ ⟨y⟩ rw [← SetLike.coe_eq_coe, LieSubalgebra.coe_bracket] simp only [Submodule.Quotient.quot_mk_eq_mk, LinearMap.quotKerEquivRange_apply_mk, ← LieSubmodule.Quotient.mk_bracket, coe_toLinearMap, map_lie] } end LieHom
Algebra\Lie\Rank.lean
/- Copyright (c) 2024 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.Lie.EngelSubalgebra import Mathlib.Algebra.Lie.OfAssociative import Mathlib.Algebra.Module.LinearMap.Polynomial import Mathlib.LinearAlgebra.Eigenspace.Zero /-! # Rank of a Lie algebra and regular elements Let `L` be a Lie algebra over a nontrivial commutative ring `R`, and assume that `L` is finite free as `R`-module. Then the coefficients of the characteristic polynomial of `ad R L x` are polynomial in `x`. The *rank* of `L` is the smallest `n` for which the `n`-th coefficient is not the zero polynomial. Continuing to write `n` for the rank of `L`, an element `x` of `L` is *regular* if the `n`-th coefficient of the characteristic polynomial of `ad R L x` is non-zero. ## Main declarations * `LieAlgebra.rank R L` is the rank of a Lie algebra `L` over a commutative ring `R`. * `LieAlgebra.IsRegular R x` is the predicate that an element `x` of a Lie algebra `L` is regular. ## References * [barnes1967]: "On Cartan subalgebras of Lie algebras" by D.W. Barnes. -/ variable {R A L M ι ιₘ : Type*} variable [CommRing R] variable [CommRing A] [Algebra R A] variable [LieRing L] [LieAlgebra R L] [Module.Finite R L] [Module.Free R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [Module.Finite R M] [Module.Free R M] variable [Fintype ι] variable [Fintype ιₘ] variable (b : Basis ι R L) (bₘ : Basis ιₘ R M) (x : L) namespace LieModule open LieAlgebra LinearMap Module.Free variable (R L M) local notation "φ" => LieHom.toLinearMap (LieModule.toEnd R L M) /-- Let `M` be a representation of a Lie algebra `L` over a nontrivial commutative ring `R`, and assume that `L` and `M` are finite free as `R`-module. Then the coefficients of the characteristic polynomial of `⁅x, ·⁆` are polynomial in `x`. The *rank* of `M` is the smallest `n` for which the `n`-th coefficient is not the zero polynomial. -/ noncomputable def rank : ℕ := nilRank φ lemma polyCharpoly_coeff_rank_ne_zero [Nontrivial R] [DecidableEq ι] : (polyCharpoly φ b).coeff (rank R L M) ≠ 0 := polyCharpoly_coeff_nilRank_ne_zero _ _ lemma rank_eq_natTrailingDegree [Nontrivial R] [DecidableEq ι] : rank R L M = (polyCharpoly φ b).natTrailingDegree := by apply nilRank_eq_polyCharpoly_natTrailingDegree open FiniteDimensional lemma rank_le_card [Nontrivial R] : rank R L M ≤ Fintype.card ιₘ := nilRank_le_card _ bₘ open FiniteDimensional lemma rank_le_finrank [Nontrivial R] : rank R L M ≤ finrank R M := nilRank_le_finrank _ variable {L} lemma rank_le_natTrailingDegree_charpoly_ad [Nontrivial R] : rank R L M ≤ (toEnd R L M x).charpoly.natTrailingDegree := nilRank_le_natTrailingDegree_charpoly _ _ /-- Let `x` be an element of a Lie algebra `L` over `R`, and write `n` for `rank R L`. Then `x` is *regular* if the `n`-th coefficient of the characteristic polynomial of `ad R L x` is non-zero. -/ def IsRegular (x : L) : Prop := LinearMap.IsNilRegular φ x lemma isRegular_def : IsRegular R M x ↔ (toEnd R L M x).charpoly.coeff (rank R L M) ≠ 0 := Iff.rfl lemma isRegular_iff_coeff_polyCharpoly_rank_ne_zero [DecidableEq ι] : IsRegular R M x ↔ MvPolynomial.eval (b.repr x) ((polyCharpoly φ b).coeff (rank R L M)) ≠ 0 := LinearMap.isNilRegular_iff_coeff_polyCharpoly_nilRank_ne_zero _ _ _ lemma isRegular_iff_natTrailingDegree_charpoly_eq_rank [Nontrivial R] : IsRegular R M x ↔ (toEnd R L M x).charpoly.natTrailingDegree = rank R L M := LinearMap.isNilRegular_iff_natTrailingDegree_charpoly_eq_nilRank _ _ section IsDomain variable (L) variable [IsDomain R] open Cardinal FiniteDimensional MvPolynomial in lemma exists_isRegular_of_finrank_le_card (h : finrank R M ≤ #R) : ∃ x : L, IsRegular R M x := LinearMap.exists_isNilRegular_of_finrank_le_card _ h lemma exists_isRegular [Infinite R] : ∃ x : L, IsRegular R M x := LinearMap.exists_isNilRegular _ end IsDomain end LieModule namespace LieAlgebra open LieAlgebra LinearMap Module.Free variable (R L) /-- Let `L` be a Lie algebra over a nontrivial commutative ring `R`, and assume that `L` is finite free as `R`-module. Then the coefficients of the characteristic polynomial of `ad R L x` are polynomial in `x`. The *rank* of `L` is the smallest `n` for which the `n`-th coefficient is not the zero polynomial. -/ noncomputable abbrev rank : ℕ := LieModule.rank R L L lemma polyCharpoly_coeff_rank_ne_zero [Nontrivial R] [DecidableEq ι] : (polyCharpoly (ad R L).toLinearMap b).coeff (rank R L) ≠ 0 := polyCharpoly_coeff_nilRank_ne_zero _ _ lemma rank_eq_natTrailingDegree [Nontrivial R] [DecidableEq ι] : rank R L = (polyCharpoly (ad R L).toLinearMap b).natTrailingDegree := by apply nilRank_eq_polyCharpoly_natTrailingDegree open FiniteDimensional lemma rank_le_card [Nontrivial R] : rank R L ≤ Fintype.card ι := nilRank_le_card _ b lemma rank_le_finrank [Nontrivial R] : rank R L ≤ finrank R L := nilRank_le_finrank _ variable {L} lemma rank_le_natTrailingDegree_charpoly_ad [Nontrivial R] : rank R L ≤ (ad R L x).charpoly.natTrailingDegree := nilRank_le_natTrailingDegree_charpoly _ _ /-- Let `x` be an element of a Lie algebra `L` over `R`, and write `n` for `rank R L`. Then `x` is *regular* if the `n`-th coefficient of the characteristic polynomial of `ad R L x` is non-zero. -/ abbrev IsRegular (x : L) : Prop := LieModule.IsRegular R L x lemma isRegular_def : IsRegular R x ↔ (Polynomial.coeff (ad R L x).charpoly (rank R L) ≠ 0) := Iff.rfl lemma isRegular_iff_coeff_polyCharpoly_rank_ne_zero [DecidableEq ι] : IsRegular R x ↔ MvPolynomial.eval (b.repr x) ((polyCharpoly (ad R L).toLinearMap b).coeff (rank R L)) ≠ 0 := LinearMap.isNilRegular_iff_coeff_polyCharpoly_nilRank_ne_zero _ _ _ lemma isRegular_iff_natTrailingDegree_charpoly_eq_rank [Nontrivial R] : IsRegular R x ↔ (ad R L x).charpoly.natTrailingDegree = rank R L := LinearMap.isNilRegular_iff_natTrailingDegree_charpoly_eq_nilRank _ _ section IsDomain variable (L) variable [IsDomain R] open Cardinal FiniteDimensional MvPolynomial in lemma exists_isRegular_of_finrank_le_card (h : finrank R L ≤ #R) : ∃ x : L, IsRegular R x := LinearMap.exists_isNilRegular_of_finrank_le_card _ h lemma exists_isRegular [Infinite R] : ∃ x : L, IsRegular R x := LinearMap.exists_isNilRegular _ end IsDomain end LieAlgebra namespace LieAlgebra variable (K : Type*) {L : Type*} [Field K] [LieRing L] [LieAlgebra K L] [Module.Finite K L] open FiniteDimensional LieSubalgebra lemma finrank_engel (x : L) : finrank K (engel K x) = (ad K L x).charpoly.natTrailingDegree := (ad K L x).finrank_maxGenEigenspace lemma rank_le_finrank_engel (x : L) : rank K L ≤ finrank K (engel K x) := (rank_le_natTrailingDegree_charpoly_ad K x).trans (finrank_engel K x).ge lemma isRegular_iff_finrank_engel_eq_rank (x : L) : IsRegular K x ↔ finrank K (engel K x) = rank K L := by rw [isRegular_iff_natTrailingDegree_charpoly_eq_rank, finrank_engel] end LieAlgebra
Algebra\Lie\SkewAdjoint.lean
/- Copyright (c) 2020 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Matrix import Mathlib.LinearAlgebra.Matrix.SesquilinearForm import Mathlib.Tactic.NoncommRing /-! # Lie algebras of skew-adjoint endomorphisms of a bilinear form When a module carries a bilinear form, the Lie algebra of endomorphisms of the module contains a distinguished Lie subalgebra: the skew-adjoint endomorphisms. Such subalgebras are important because they provide a simple, explicit construction of the so-called classical Lie algebras. This file defines the Lie subalgebra of skew-adjoint endomorphisms cut out by a bilinear form on a module and proves some basic related results. It also provides the corresponding definitions and results for the Lie algebra of square matrices. ## Main definitions * `skewAdjointLieSubalgebra` * `skewAdjointLieSubalgebraEquiv` * `skewAdjointMatricesLieSubalgebra` * `skewAdjointMatricesLieSubalgebraEquiv` ## Tags lie algebra, skew-adjoint, bilinear form -/ universe u v w w₁ section SkewAdjointEndomorphisms open LinearMap (BilinForm) variable {R : Type u} {M : Type v} [CommRing R] [AddCommGroup M] [Module R M] variable (B : BilinForm R M) -- Porting note: Changed `(f g)` to `{f g}` for convenience in `skewAdjointLieSubalgebra` theorem LinearMap.BilinForm.isSkewAdjoint_bracket {f g : Module.End R M} (hf : f ∈ B.skewAdjointSubmodule) (hg : g ∈ B.skewAdjointSubmodule) : ⁅f, g⁆ ∈ B.skewAdjointSubmodule := by rw [mem_skewAdjointSubmodule] at * have hfg : IsAdjointPair B B (f * g) (g * f) := by rw [← neg_mul_neg g f]; exact hf.mul hg have hgf : IsAdjointPair B B (g * f) (f * g) := by rw [← neg_mul_neg f g]; exact hg.mul hf change IsAdjointPair B B (f * g - g * f) (-(f * g - g * f)); rw [neg_sub] exact hfg.sub hgf /-- Given an `R`-module `M`, equipped with a bilinear form, the skew-adjoint endomorphisms form a Lie subalgebra of the Lie algebra of endomorphisms. -/ def skewAdjointLieSubalgebra : LieSubalgebra R (Module.End R M) := { B.skewAdjointSubmodule with lie_mem' := B.isSkewAdjoint_bracket } variable {N : Type w} [AddCommGroup N] [Module R N] (e : N ≃ₗ[R] M) /-- An equivalence of modules with bilinear forms gives equivalence of Lie algebras of skew-adjoint endomorphisms. -/ def skewAdjointLieSubalgebraEquiv : skewAdjointLieSubalgebra (B.compl₁₂ (↑e : N →ₗ[R] M) ↑e) ≃ₗ⁅R⁆ skewAdjointLieSubalgebra B := by apply LieEquiv.ofSubalgebras _ _ e.lieConj ext f simp only [LieSubalgebra.mem_coe, Submodule.mem_map_equiv, LieSubalgebra.mem_map_submodule, LinearEquiv.coe_coe] exact (LinearMap.isPairSelfAdjoint_equiv (B := -B) (F := B) e f).symm @[simp] theorem skewAdjointLieSubalgebraEquiv_apply (f : skewAdjointLieSubalgebra (B.compl₁₂ (Qₗ := N) (Qₗ' := N) ↑e ↑e)) : ↑(skewAdjointLieSubalgebraEquiv B e f) = e.lieConj f := by simp [skewAdjointLieSubalgebraEquiv] @[simp] theorem skewAdjointLieSubalgebraEquiv_symm_apply (f : skewAdjointLieSubalgebra B) : ↑((skewAdjointLieSubalgebraEquiv B e).symm f) = e.symm.lieConj f := by simp [skewAdjointLieSubalgebraEquiv] end SkewAdjointEndomorphisms section SkewAdjointMatrices open scoped Matrix variable {R : Type u} {n : Type w} [CommRing R] [DecidableEq n] [Fintype n] variable (J : Matrix n n R) theorem Matrix.lie_transpose (A B : Matrix n n R) : ⁅A, B⁆ᵀ = ⁅Bᵀ, Aᵀ⁆ := show (A * B - B * A)ᵀ = Bᵀ * Aᵀ - Aᵀ * Bᵀ by simp -- Porting note: Changed `(A B)` to `{A B}` for convenience in `skewAdjointMatricesLieSubalgebra` theorem Matrix.isSkewAdjoint_bracket {A B : Matrix n n R} (hA : A ∈ skewAdjointMatricesSubmodule J) (hB : B ∈ skewAdjointMatricesSubmodule J) : ⁅A, B⁆ ∈ skewAdjointMatricesSubmodule J := by simp only [mem_skewAdjointMatricesSubmodule] at * change ⁅A, B⁆ᵀ * J = J * (-⁅A, B⁆) change Aᵀ * J = J * (-A) at hA change Bᵀ * J = J * (-B) at hB rw [Matrix.lie_transpose, LieRing.of_associative_ring_bracket, LieRing.of_associative_ring_bracket, sub_mul, mul_assoc, mul_assoc, hA, hB, ← mul_assoc, ← mul_assoc, hA, hB] noncomm_ring /-- The Lie subalgebra of skew-adjoint square matrices corresponding to a square matrix `J`. -/ def skewAdjointMatricesLieSubalgebra : LieSubalgebra R (Matrix n n R) := { skewAdjointMatricesSubmodule J with lie_mem' := J.isSkewAdjoint_bracket } @[simp] theorem mem_skewAdjointMatricesLieSubalgebra (A : Matrix n n R) : A ∈ skewAdjointMatricesLieSubalgebra J ↔ A ∈ skewAdjointMatricesSubmodule J := Iff.rfl /-- An invertible matrix `P` gives a Lie algebra equivalence between those endomorphisms that are skew-adjoint with respect to a square matrix `J` and those with respect to `PᵀJP`. -/ def skewAdjointMatricesLieSubalgebraEquiv (P : Matrix n n R) (h : Invertible P) : skewAdjointMatricesLieSubalgebra J ≃ₗ⁅R⁆ skewAdjointMatricesLieSubalgebra (Pᵀ * J * P) := LieEquiv.ofSubalgebras _ _ (P.lieConj h).symm <| by ext A suffices P.lieConj h A ∈ skewAdjointMatricesSubmodule J ↔ A ∈ skewAdjointMatricesSubmodule (Pᵀ * J * P) by simp only [LieSubalgebra.mem_coe, Submodule.mem_map_equiv, LieSubalgebra.mem_map_submodule, LinearEquiv.coe_coe] exact this simp [Matrix.IsSkewAdjoint, J.isAdjointPair_equiv _ _ P (isUnit_of_invertible P)] -- TODO(mathlib4#6607): fix elaboration so annotation on `A` isn't needed theorem skewAdjointMatricesLieSubalgebraEquiv_apply (P : Matrix n n R) (h : Invertible P) (A : skewAdjointMatricesLieSubalgebra J) : ↑(skewAdjointMatricesLieSubalgebraEquiv J P h A) = P⁻¹ * (A : Matrix n n R) * P := by simp [skewAdjointMatricesLieSubalgebraEquiv] /-- An equivalence of matrix algebras commuting with the transpose endomorphisms restricts to an equivalence of Lie algebras of skew-adjoint matrices. -/ def skewAdjointMatricesLieSubalgebraEquivTranspose {m : Type w} [DecidableEq m] [Fintype m] (e : Matrix n n R ≃ₐ[R] Matrix m m R) (h : ∀ A, (e A)ᵀ = e Aᵀ) : skewAdjointMatricesLieSubalgebra J ≃ₗ⁅R⁆ skewAdjointMatricesLieSubalgebra (e J) := LieEquiv.ofSubalgebras _ _ e.toLieEquiv <| by ext A suffices J.IsSkewAdjoint (e.symm A) ↔ (e J).IsSkewAdjoint A by -- Porting note: Originally `simpa [this]` simpa [- LieSubalgebra.mem_map, LieSubalgebra.mem_map_submodule] simp only [Matrix.IsSkewAdjoint, Matrix.IsAdjointPair, ← h, ← Function.Injective.eq_iff e.injective, map_mul, AlgEquiv.apply_symm_apply, map_neg] @[simp] theorem skewAdjointMatricesLieSubalgebraEquivTranspose_apply {m : Type w} [DecidableEq m] [Fintype m] (e : Matrix n n R ≃ₐ[R] Matrix m m R) (h : ∀ A, (e A)ᵀ = e Aᵀ) (A : skewAdjointMatricesLieSubalgebra J) : (skewAdjointMatricesLieSubalgebraEquivTranspose J e h A : Matrix m m R) = e A := rfl theorem mem_skewAdjointMatricesLieSubalgebra_unit_smul (u : Rˣ) (J A : Matrix n n R) : A ∈ skewAdjointMatricesLieSubalgebra (u • J) ↔ A ∈ skewAdjointMatricesLieSubalgebra J := by change A ∈ skewAdjointMatricesSubmodule (u • J) ↔ A ∈ skewAdjointMatricesSubmodule J simp only [mem_skewAdjointMatricesSubmodule, Matrix.IsSkewAdjoint, Matrix.IsAdjointPair] constructor <;> intro h · simpa using congr_arg (fun B => u⁻¹ • B) h · simp [h] end SkewAdjointMatrices
Algebra\Lie\Sl2.lean
/- Copyright (c) 2024 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.OfAssociative import Mathlib.LinearAlgebra.Eigenspace.Basic import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition /-! # The Lie algebra `sl₂` and its representations The Lie algebra `sl₂` is the unique simple Lie algebra of minimal rank, 1, and as such occupies a distinguished position in the general theory. This file provides some basic definitions and results about `sl₂`. ## Main definitions: * `IsSl2Triple`: a structure representing a triple of elements in a Lie algebra which satisfy the standard relations for `sl₂`. * `IsSl2Triple.HasPrimitiveVectorWith`: a structure representing a primitive vector in a representation of a Lie algebra relative to a distinguished `sl₂` triple. * `IsSl2Triple.HasPrimitiveVectorWith.exists_nat`: the eigenvalue of a primitive vector must be a natural number if the representation is finite-dimensional. -/ variable (R L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] open LieModule Set variable {L} in /-- An `sl₂` triple within a Lie ring `L` is a triple of elements `h`, `e`, `f` obeying relations which ensure that the Lie subalgebra they generate is equivalent to `sl₂`. -/ structure IsSl2Triple (h e f : L) : Prop where h_ne_zero : h ≠ 0 lie_e_f : ⁅e, f⁆ = h lie_h_e_nsmul : ⁅h, e⁆ = 2 • e lie_h_f_nsmul : ⁅h, f⁆ = - (2 • f) namespace IsSl2Triple variable {L M} variable {h e f : L} lemma symm (ht : IsSl2Triple h e f) : IsSl2Triple (-h) f e where h_ne_zero := by simpa using ht.h_ne_zero lie_e_f := by rw [← neg_eq_iff_eq_neg, lie_skew, ht.lie_e_f] lie_h_e_nsmul := by rw [neg_lie, neg_eq_iff_eq_neg, ht.lie_h_f_nsmul] lie_h_f_nsmul := by rw [neg_lie, neg_inj, ht.lie_h_e_nsmul] @[simp] lemma symm_iff : IsSl2Triple (-h) f e ↔ IsSl2Triple h e f := ⟨fun t ↦ neg_neg h ▸ t.symm, symm⟩ lemma lie_h_e_smul (t : IsSl2Triple h e f) : ⁅h, e⁆ = (2 : R) • e := by simp [t.lie_h_e_nsmul, two_smul] lemma lie_lie_smul_f (t : IsSl2Triple h e f) : ⁅h, f⁆ = -((2 : R) • f) := by simp [t.lie_h_f_nsmul, two_smul] lemma e_ne_zero (t : IsSl2Triple h e f) : e ≠ 0 := by have := t.h_ne_zero contrapose! this simpa [this] using t.lie_e_f.symm lemma f_ne_zero (t : IsSl2Triple h e f) : f ≠ 0 := by have := t.h_ne_zero contrapose! this simpa [this] using t.lie_e_f.symm variable {R} /-- Given a representation of a Lie algebra with distinguished `sl₂` triple, a vector is said to be primitive if it is a simultaneous eigenvector for the action of both `h`, `e`, and the eigenvalue for `e` is zero. -/ structure HasPrimitiveVectorWith (t : IsSl2Triple h e f) (m : M) (μ : R) : Prop where ne_zero : m ≠ 0 lie_h : ⁅h, m⁆ = μ • m lie_e : ⁅e, m⁆ = 0 /-- Given a representation of a Lie algebra with distinguished `sl₂` triple, a simultaneous eigenvector for the action of both `h` and `e` necessarily has eigenvalue zero for `e`. -/ lemma HasPrimitiveVectorWith.mk' [NoZeroSMulDivisors ℤ M] (t : IsSl2Triple h e f) (m : M) (μ ρ : R) (hm : m ≠ 0) (hm' : ⁅h, m⁆ = μ • m) (he : ⁅e, m⁆ = ρ • m) : HasPrimitiveVectorWith t m μ where ne_zero := hm lie_h := hm' lie_e := by suffices 2 • ⁅e, m⁆ = 0 by simpa using this rw [← nsmul_lie, ← t.lie_h_e_nsmul, lie_lie, hm', lie_smul, he, lie_smul, hm', smul_smul, smul_smul, mul_comm ρ μ, sub_self] namespace HasPrimitiveVectorWith variable {m : M} {μ : R} {t : IsSl2Triple h e f} (P : HasPrimitiveVectorWith t m μ) local notation "ψ" n => ((toEnd R L M f) ^ n) m lemma lie_h_pow_toEnd_f (n : ℕ) : ⁅h, ψ n⁆ = (μ - 2 * n) • ψ n := by induction' n with n ih · simpa using P.lie_h · rw [pow_succ', LinearMap.mul_apply, toEnd_apply_apply, Nat.cast_add, Nat.cast_one, leibniz_lie h, t.lie_lie_smul_f R, ← neg_smul, ih, lie_smul, smul_lie, ← add_smul] congr ring -- Although this is true by definition, we include this lemma (and the assumption) to mirror the API -- for `lie_h_pow_toEnd_f` and `lie_e_pow_succ_toEnd_f`. set_option linter.unusedVariables false in @[nolint unusedArguments] lemma lie_f_pow_toEnd_f (P : HasPrimitiveVectorWith t m μ) (n : ℕ) : ⁅f, ψ n⁆ = ψ (n + 1) := by simp [pow_succ'] lemma lie_e_pow_succ_toEnd_f (n : ℕ) : ⁅e, ψ (n + 1)⁆ = ((n + 1) * (μ - n)) • ψ n := by induction' n with n ih · simp only [zero_add, pow_one, toEnd_apply_apply, Nat.cast_zero, sub_zero, one_mul, pow_zero, LinearMap.one_apply, leibniz_lie e, t.lie_e_f, P.lie_e, P.lie_h, lie_zero, add_zero] · rw [pow_succ', LinearMap.mul_apply, toEnd_apply_apply, leibniz_lie e, t.lie_e_f, lie_h_pow_toEnd_f P, ih, lie_smul, lie_f_pow_toEnd_f P, ← add_smul, Nat.cast_add, Nat.cast_one] congr ring /-- The eigenvalue of a primitive vector must be a natural number if the representation is finite-dimensional. -/ lemma exists_nat [IsNoetherian R M] [NoZeroSMulDivisors R M] [IsDomain R] [CharZero R] : ∃ n : ℕ, μ = n := by suffices ∃ n : ℕ, (ψ n) = 0 by obtain ⟨n, hn₁, hn₂⟩ := Nat.exists_not_and_succ_of_not_zero_of_exists P.ne_zero this refine ⟨n, ?_⟩ have := lie_e_pow_succ_toEnd_f P n rw [hn₂, lie_zero, eq_comm, smul_eq_zero_iff_left hn₁, mul_eq_zero, sub_eq_zero] at this exact this.resolve_left <| Nat.cast_add_one_ne_zero n have hs : (range <| fun (n : ℕ) ↦ μ - 2 * n).Infinite := by rw [infinite_range_iff (fun n m ↦ by simp)]; infer_instance by_contra! contra exact hs ((toEnd R L M h).eigenvectors_linearIndependent {μ - 2 * n | n : ℕ} (fun ⟨s, hs⟩ ↦ ψ Classical.choose hs) (fun ⟨r, hr⟩ ↦ by simp [lie_h_pow_toEnd_f P, Classical.choose_spec hr, contra, Module.End.HasEigenvector, Module.End.mem_eigenspace_iff])).finite lemma pow_toEnd_f_ne_zero_of_eq_nat [CharZero R] [NoZeroSMulDivisors R M] {n : ℕ} (hn : μ = n) {i} (hi : i ≤ n) : (ψ i) ≠ 0 := by intro H induction i · exact P.ne_zero (by simpa using H) · next i IH => have : ((i + 1) * (n - i) : ℤ) • (toEnd R L M f ^ i) m = 0 := by have := congr_arg (⁅e, ·⁆) H simpa [← Int.cast_smul_eq_zsmul R, P.lie_e_pow_succ_toEnd_f, hn] using this rw [← Int.cast_smul_eq_zsmul R, smul_eq_zero, Int.cast_eq_zero, mul_eq_zero, sub_eq_zero, Nat.cast_inj, ← @Nat.cast_one ℤ, ← Nat.cast_add, Nat.cast_eq_zero] at this simp only [add_eq_zero, one_ne_zero, and_false, false_or] at this exact (hi.trans_eq (this.resolve_right (IH (i.le_succ.trans hi)))).not_lt i.lt_succ_self lemma pow_toEnd_f_eq_zero_of_eq_nat [IsNoetherian R M] [NoZeroSMulDivisors R M] [IsDomain R] [CharZero R] {n : ℕ} (hn : μ = n) : (ψ (n + 1)) = 0 := by by_contra h have : t.HasPrimitiveVectorWith (ψ (n + 1)) (n - 2 * (n + 1) : R) := { ne_zero := h lie_h := (P.lie_h_pow_toEnd_f _).trans (by simp [hn]) lie_e := (P.lie_e_pow_succ_toEnd_f _).trans (by simp [hn]) } obtain ⟨m, hm⟩ := this.exists_nat have : (n : ℤ) < m + 2 * (n + 1) := by linarith exact this.ne (Int.cast_injective (α := R) <| by simpa [sub_eq_iff_eq_add] using hm) end HasPrimitiveVectorWith end IsSl2Triple
Algebra\Lie\Solvable.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Abelian import Mathlib.Algebra.Lie.IdealOperations import Mathlib.Order.Hom.Basic /-! # Solvable Lie algebras Like groups, Lie algebras admit a natural concept of solvability. We define this here via the derived series and prove some related results. We also define the radical of a Lie algebra and prove that it is solvable when the Lie algebra is Noetherian. ## Main definitions * `LieAlgebra.derivedSeriesOfIdeal` * `LieAlgebra.derivedSeries` * `LieAlgebra.IsSolvable` * `LieAlgebra.isSolvableAdd` * `LieAlgebra.radical` * `LieAlgebra.radicalIsSolvable` * `LieAlgebra.derivedLengthOfIdeal` * `LieAlgebra.derivedLength` * `LieAlgebra.derivedAbelianOfIdeal` ## Tags lie algebra, derived series, derived length, solvable, radical -/ universe u v w w₁ w₂ variable (R : Type u) (L : Type v) (M : Type w) {L' : Type w₁} variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L'] [LieAlgebra R L'] variable (I J : LieIdeal R L) {f : L' →ₗ⁅R⁆ L} namespace LieAlgebra /-- A generalisation of the derived series of a Lie algebra, whose zeroth term is a specified ideal. It can be more convenient to work with this generalisation when considering the derived series of an ideal since it provides a type-theoretic expression of the fact that the terms of the ideal's derived series are also ideals of the enclosing algebra. See also `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_comap` and `LieIdeal.derivedSeries_eq_derivedSeriesOfIdeal_map` below. -/ def derivedSeriesOfIdeal (k : ℕ) : LieIdeal R L → LieIdeal R L := (fun I => ⁅I, I⁆)^[k] @[simp] theorem derivedSeriesOfIdeal_zero : derivedSeriesOfIdeal R L 0 I = I := rfl @[simp] theorem derivedSeriesOfIdeal_succ (k : ℕ) : derivedSeriesOfIdeal R L (k + 1) I = ⁅derivedSeriesOfIdeal R L k I, derivedSeriesOfIdeal R L k I⁆ := Function.iterate_succ_apply' (fun I => ⁅I, I⁆) k I /-- The derived series of Lie ideals of a Lie algebra. -/ abbrev derivedSeries (k : ℕ) : LieIdeal R L := derivedSeriesOfIdeal R L k ⊤ theorem derivedSeries_def (k : ℕ) : derivedSeries R L k = derivedSeriesOfIdeal R L k ⊤ := rfl variable {R L} local notation "D" => derivedSeriesOfIdeal R L theorem derivedSeriesOfIdeal_add (k l : ℕ) : D (k + l) I = D k (D l I) := by induction' k with k ih · rw [Nat.zero_add, derivedSeriesOfIdeal_zero] · rw [Nat.succ_add k l, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ, ih] @[mono] theorem derivedSeriesOfIdeal_le {I J : LieIdeal R L} {k l : ℕ} (h₁ : I ≤ J) (h₂ : l ≤ k) : D k I ≤ D l J := by revert l; induction' k with k ih <;> intro l h₂ · rw [le_zero_iff] at h₂; rw [h₂, derivedSeriesOfIdeal_zero]; exact h₁ · have h : l = k.succ ∨ l ≤ k := by rwa [le_iff_eq_or_lt, Nat.lt_succ_iff] at h₂ cases' h with h h · rw [h, derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_succ] exact LieSubmodule.mono_lie (ih (le_refl k)) (ih (le_refl k)) · rw [derivedSeriesOfIdeal_succ]; exact le_trans (LieSubmodule.lie_le_left _ _) (ih h) theorem derivedSeriesOfIdeal_succ_le (k : ℕ) : D (k + 1) I ≤ D k I := derivedSeriesOfIdeal_le (le_refl I) k.le_succ theorem derivedSeriesOfIdeal_le_self (k : ℕ) : D k I ≤ I := derivedSeriesOfIdeal_le (le_refl I) (zero_le k) theorem derivedSeriesOfIdeal_mono {I J : LieIdeal R L} (h : I ≤ J) (k : ℕ) : D k I ≤ D k J := derivedSeriesOfIdeal_le h (le_refl k) theorem derivedSeriesOfIdeal_antitone {k l : ℕ} (h : l ≤ k) : D k I ≤ D l I := derivedSeriesOfIdeal_le (le_refl I) h theorem derivedSeriesOfIdeal_add_le_add (J : LieIdeal R L) (k l : ℕ) : D (k + l) (I + J) ≤ D k I + D l J := by let D₁ : LieIdeal R L →o LieIdeal R L := { toFun := fun I => ⁅I, I⁆ monotone' := fun I J h => LieSubmodule.mono_lie h h } have h₁ : ∀ I J : LieIdeal R L, D₁ (I ⊔ J) ≤ D₁ I ⊔ J := by simp [D₁, LieSubmodule.lie_le_right, LieSubmodule.lie_le_left, le_sup_of_le_right] rw [← D₁.iterate_sup_le_sup_iff] at h₁ exact h₁ k l I J theorem derivedSeries_of_bot_eq_bot (k : ℕ) : derivedSeriesOfIdeal R L k ⊥ = ⊥ := by rw [eq_bot_iff]; exact derivedSeriesOfIdeal_le_self ⊥ k theorem abelian_iff_derived_one_eq_bot : IsLieAbelian I ↔ derivedSeriesOfIdeal R L 1 I = ⊥ := by rw [derivedSeriesOfIdeal_succ, derivedSeriesOfIdeal_zero, LieSubmodule.lie_abelian_iff_lie_self_eq_bot] theorem abelian_iff_derived_succ_eq_bot (I : LieIdeal R L) (k : ℕ) : IsLieAbelian (derivedSeriesOfIdeal R L k I) ↔ derivedSeriesOfIdeal R L (k + 1) I = ⊥ := by rw [add_comm, derivedSeriesOfIdeal_add I 1 k, abelian_iff_derived_one_eq_bot] end LieAlgebra namespace LieIdeal open LieAlgebra variable {R L} theorem derivedSeries_eq_derivedSeriesOfIdeal_comap (k : ℕ) : derivedSeries R I k = (derivedSeriesOfIdeal R L k I).comap I.incl := by induction' k with k ih · simp only [Nat.zero_eq, derivedSeries_def, comap_incl_self, derivedSeriesOfIdeal_zero] · simp only [derivedSeries_def, derivedSeriesOfIdeal_succ] at ih ⊢; rw [ih] exact comap_bracket_incl_of_le I (derivedSeriesOfIdeal_le_self I k) (derivedSeriesOfIdeal_le_self I k) theorem derivedSeries_eq_derivedSeriesOfIdeal_map (k : ℕ) : (derivedSeries R I k).map I.incl = derivedSeriesOfIdeal R L k I := by rw [derivedSeries_eq_derivedSeriesOfIdeal_comap, map_comap_incl, inf_eq_right] apply derivedSeriesOfIdeal_le_self theorem derivedSeries_eq_bot_iff (k : ℕ) : derivedSeries R I k = ⊥ ↔ derivedSeriesOfIdeal R L k I = ⊥ := by rw [← derivedSeries_eq_derivedSeriesOfIdeal_map, map_eq_bot_iff, ker_incl, eq_bot_iff] theorem derivedSeries_add_eq_bot {k l : ℕ} {I J : LieIdeal R L} (hI : derivedSeries R I k = ⊥) (hJ : derivedSeries R J l = ⊥) : derivedSeries R (I + J) (k + l) = ⊥ := by rw [LieIdeal.derivedSeries_eq_bot_iff] at hI hJ ⊢ rw [← le_bot_iff] let D := derivedSeriesOfIdeal R L; change D k I = ⊥ at hI; change D l J = ⊥ at hJ calc D (k + l) (I + J) ≤ D k I + D l J := derivedSeriesOfIdeal_add_le_add I J k l _ ≤ ⊥ := by rw [hI, hJ]; simp theorem derivedSeries_map_le (k : ℕ) : (derivedSeries R L' k).map f ≤ derivedSeries R L k := by induction' k with k ih · simp only [Nat.zero_eq, derivedSeries_def, derivedSeriesOfIdeal_zero, le_top] · simp only [derivedSeries_def, derivedSeriesOfIdeal_succ] at ih ⊢ exact le_trans (map_bracket_le f) (LieSubmodule.mono_lie ih ih) theorem derivedSeries_map_eq (k : ℕ) (h : Function.Surjective f) : (derivedSeries R L' k).map f = derivedSeries R L k := by induction' k with k ih · change (⊤ : LieIdeal R L').map f = ⊤ rw [← f.idealRange_eq_map] exact f.idealRange_eq_top_of_surjective h · simp only [derivedSeries_def, map_bracket_eq f h, ih, derivedSeriesOfIdeal_succ] theorem derivedSeries_succ_eq_top_iff (n : ℕ) : derivedSeries R L (n + 1) = ⊤ ↔ derivedSeries R L 1 = ⊤ := by simp only [derivedSeries_def] induction' n with n ih; · simp rw [derivedSeriesOfIdeal_succ] refine ⟨fun h ↦ ?_, fun h ↦ by rwa [ih.mpr h]⟩ rw [← ih, eq_top_iff] conv_lhs => rw [← h] exact LieSubmodule.lie_le_right _ _ theorem derivedSeries_eq_top (n : ℕ) (h : derivedSeries R L 1 = ⊤) : derivedSeries R L n = ⊤ := by cases n · rfl · rwa [derivedSeries_succ_eq_top_iff] end LieIdeal namespace LieAlgebra /-- A Lie algebra is solvable if its derived series reaches 0 (in a finite number of steps). -/ class IsSolvable : Prop where solvable : ∃ k, derivedSeries R L k = ⊥ instance isSolvableBot : IsSolvable R (↥(⊥ : LieIdeal R L)) := ⟨⟨0, Subsingleton.elim _ ⊥⟩⟩ instance isSolvableAdd {I J : LieIdeal R L} [hI : IsSolvable R I] [hJ : IsSolvable R J] : IsSolvable R (↥(I + J)) := by obtain ⟨k, hk⟩ := id hI; obtain ⟨l, hl⟩ := id hJ exact ⟨⟨k + l, LieIdeal.derivedSeries_add_eq_bot hk hl⟩⟩ theorem derivedSeries_lt_top_of_solvable [IsSolvable R L] [Nontrivial L] : derivedSeries R L 1 < ⊤ := by obtain ⟨n, hn⟩ := IsSolvable.solvable (R := R) (L := L) rw [lt_top_iff_ne_top] intro contra rw [LieIdeal.derivedSeries_eq_top n contra] at hn exact top_ne_bot hn end LieAlgebra variable {R L} namespace Function open LieAlgebra theorem Injective.lieAlgebra_isSolvable [h₁ : IsSolvable R L] (h₂ : Injective f) : IsSolvable R L' := by obtain ⟨k, hk⟩ := id h₁ use k apply LieIdeal.bot_of_map_eq_bot h₂; rw [eq_bot_iff, ← hk] apply LieIdeal.derivedSeries_map_le theorem Surjective.lieAlgebra_isSolvable [h₁ : IsSolvable R L'] (h₂ : Surjective f) : IsSolvable R L := by obtain ⟨k, hk⟩ := id h₁ use k rw [← LieIdeal.derivedSeries_map_eq k h₂, hk] simp only [LieIdeal.map_eq_bot_iff, bot_le] end Function theorem LieHom.isSolvable_range (f : L' →ₗ⁅R⁆ L) [LieAlgebra.IsSolvable R L'] : LieAlgebra.IsSolvable R f.range := f.surjective_rangeRestrict.lieAlgebra_isSolvable namespace LieAlgebra theorem solvable_iff_equiv_solvable (e : L' ≃ₗ⁅R⁆ L) : IsSolvable R L' ↔ IsSolvable R L := by constructor <;> intro h · exact e.symm.injective.lieAlgebra_isSolvable · exact e.injective.lieAlgebra_isSolvable theorem le_solvable_ideal_solvable {I J : LieIdeal R L} (h₁ : I ≤ J) (_ : IsSolvable R J) : IsSolvable R I := (LieIdeal.inclusion_injective h₁).lieAlgebra_isSolvable variable (R L) instance (priority := 100) ofAbelianIsSolvable [IsLieAbelian L] : IsSolvable R L := by use 1 rw [← abelian_iff_derived_one_eq_bot, lie_abelian_iff_equiv_lie_abelian LieIdeal.topEquiv] infer_instance /-- The (solvable) radical of Lie algebra is the `sSup` of all solvable ideals. -/ def radical := sSup { I : LieIdeal R L | IsSolvable R I } /-- The radical of a Noetherian Lie algebra is solvable. -/ instance radicalIsSolvable [IsNoetherian R L] : IsSolvable R (radical R L) := by have hwf := LieSubmodule.wellFounded_of_noetherian R L L rw [← CompleteLattice.isSupClosedCompact_iff_wellFounded] at hwf refine hwf { I : LieIdeal R L | IsSolvable R I } ⟨⊥, ?_⟩ fun I hI J hJ => ?_ · exact LieAlgebra.isSolvableBot R L · rw [Set.mem_setOf_eq] at hI hJ ⊢ apply LieAlgebra.isSolvableAdd R L /-- The `→` direction of this lemma is actually true without the `IsNoetherian` assumption. -/ theorem LieIdeal.solvable_iff_le_radical [IsNoetherian R L] (I : LieIdeal R L) : IsSolvable R I ↔ I ≤ radical R L := ⟨fun h => le_sSup h, fun h => le_solvable_ideal_solvable h inferInstance⟩ theorem center_le_radical : center R L ≤ radical R L := have h : IsSolvable R (center R L) := inferInstance le_sSup h instance [IsSolvable R L] : IsSolvable R (⊤ : LieSubalgebra R L) := by rwa [solvable_iff_equiv_solvable LieSubalgebra.topEquiv] @[simp] lemma radical_eq_top_of_isSolvable [IsSolvable R L] : radical R L = ⊤ := by rw [eq_top_iff]; exact le_sSup <| inferInstanceAs (IsSolvable R (⊤ : LieIdeal R L)) /-- Given a solvable Lie ideal `I` with derived series `I = D₀ ≥ D₁ ≥ ⋯ ≥ Dₖ = ⊥`, this is the natural number `k` (the number of inclusions). For a non-solvable ideal, the value is 0. -/ noncomputable def derivedLengthOfIdeal (I : LieIdeal R L) : ℕ := sInf { k | derivedSeriesOfIdeal R L k I = ⊥ } /-- The derived length of a Lie algebra is the derived length of its 'top' Lie ideal. See also `LieAlgebra.derivedLength_eq_derivedLengthOfIdeal`. -/ noncomputable abbrev derivedLength : ℕ := derivedLengthOfIdeal R L ⊤ theorem derivedSeries_of_derivedLength_succ (I : LieIdeal R L) (k : ℕ) : derivedLengthOfIdeal R L I = k + 1 ↔ IsLieAbelian (derivedSeriesOfIdeal R L k I) ∧ derivedSeriesOfIdeal R L k I ≠ ⊥ := by rw [abelian_iff_derived_succ_eq_bot] let s := { k | derivedSeriesOfIdeal R L k I = ⊥ } change sInf s = k + 1 ↔ k + 1 ∈ s ∧ k ∉ s have hs : ∀ k₁ k₂ : ℕ, k₁ ≤ k₂ → k₁ ∈ s → k₂ ∈ s := by intro k₁ k₂ h₁₂ h₁ suffices derivedSeriesOfIdeal R L k₂ I ≤ ⊥ by exact eq_bot_iff.mpr this change derivedSeriesOfIdeal R L k₁ I = ⊥ at h₁; rw [← h₁] exact derivedSeriesOfIdeal_antitone I h₁₂ exact Nat.sInf_upward_closed_eq_succ_iff hs k theorem derivedLength_eq_derivedLengthOfIdeal (I : LieIdeal R L) : derivedLength R I = derivedLengthOfIdeal R L I := by let s₁ := { k | derivedSeries R I k = ⊥ } let s₂ := { k | derivedSeriesOfIdeal R L k I = ⊥ } change sInf s₁ = sInf s₂ congr; ext k; exact I.derivedSeries_eq_bot_iff k variable {R L} /-- Given a solvable Lie ideal `I` with derived series `I = D₀ ≥ D₁ ≥ ⋯ ≥ Dₖ = ⊥`, this is the `k-1`th term in the derived series (and is therefore an Abelian ideal contained in `I`). For a non-solvable ideal, this is the zero ideal, `⊥`. -/ noncomputable def derivedAbelianOfIdeal (I : LieIdeal R L) : LieIdeal R L := match derivedLengthOfIdeal R L I with | 0 => ⊥ | k + 1 => derivedSeriesOfIdeal R L k I theorem abelian_derivedAbelianOfIdeal (I : LieIdeal R L) : IsLieAbelian (derivedAbelianOfIdeal I) := by dsimp only [derivedAbelianOfIdeal] cases' h : derivedLengthOfIdeal R L I with k · infer_instance · rw [derivedSeries_of_derivedLength_succ] at h; exact h.1 theorem derivedLength_zero (I : LieIdeal R L) [hI : IsSolvable R I] : derivedLengthOfIdeal R L I = 0 ↔ I = ⊥ := by let s := { k | derivedSeriesOfIdeal R L k I = ⊥ } change sInf s = 0 ↔ _ have hne : s ≠ ∅ := by obtain ⟨k, hk⟩ := id hI refine Set.Nonempty.ne_empty ⟨k, ?_⟩ rw [derivedSeries_def, LieIdeal.derivedSeries_eq_bot_iff] at hk; exact hk simp [s, hne] theorem abelian_of_solvable_ideal_eq_bot_iff (I : LieIdeal R L) [h : IsSolvable R I] : derivedAbelianOfIdeal I = ⊥ ↔ I = ⊥ := by dsimp only [derivedAbelianOfIdeal] split -- Porting note: Original tactic was `cases' h : derivedAbelianOfIdeal R L I with k` · rename_i h rw [derivedLength_zero] at h rw [h] · rename_i k h obtain ⟨_, h₂⟩ := (derivedSeries_of_derivedLength_succ R L I k).mp h have h₃ : I ≠ ⊥ := by intro contra; apply h₂; rw [contra]; apply derivedSeries_of_bot_eq_bot simp only [h₂, h₃] end LieAlgebra
Algebra\Lie\Subalgebra.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Basic import Mathlib.RingTheory.Noetherian /-! # Lie subalgebras This file defines Lie subalgebras of a Lie algebra and provides basic related definitions and results. ## Main definitions * `LieSubalgebra` * `LieSubalgebra.incl` * `LieSubalgebra.map` * `LieHom.range` * `LieEquiv.ofInjective` * `LieEquiv.ofEq` * `LieEquiv.ofSubalgebras` ## Tags lie algebra, lie subalgebra -/ universe u v w w₁ w₂ section LieSubalgebra variable (R : Type u) (L : Type v) [CommRing R] [LieRing L] [LieAlgebra R L] /-- A Lie subalgebra of a Lie algebra is submodule that is closed under the Lie bracket. This is a sufficient condition for the subset itself to form a Lie algebra. -/ structure LieSubalgebra extends Submodule R L where /-- A Lie subalgebra is closed under Lie bracket. -/ lie_mem' : ∀ {x y}, x ∈ carrier → y ∈ carrier → ⁅x, y⁆ ∈ carrier /-- The zero algebra is a subalgebra of any Lie algebra. -/ instance : Zero (LieSubalgebra R L) := ⟨⟨0, @fun x y hx _hy ↦ by rw [(Submodule.mem_bot R).1 hx, zero_lie] exact Submodule.zero_mem 0⟩⟩ instance : Inhabited (LieSubalgebra R L) := ⟨0⟩ instance : Coe (LieSubalgebra R L) (Submodule R L) := ⟨LieSubalgebra.toSubmodule⟩ namespace LieSubalgebra instance : SetLike (LieSubalgebra R L) L where coe L' := L'.carrier coe_injective' L' L'' h := by rcases L' with ⟨⟨⟩⟩ rcases L'' with ⟨⟨⟩⟩ congr exact SetLike.coe_injective' h instance : AddSubgroupClass (LieSubalgebra R L) L where add_mem := Submodule.add_mem _ zero_mem L' := L'.zero_mem' neg_mem {L'} x hx := show -x ∈ (L' : Submodule R L) from neg_mem hx /-- A Lie subalgebra forms a new Lie ring. -/ instance lieRing (L' : LieSubalgebra R L) : LieRing L' where bracket x y := ⟨⁅x.val, y.val⁆, L'.lie_mem' x.property y.property⟩ lie_add := by intros apply SetCoe.ext apply lie_add add_lie := by intros apply SetCoe.ext apply add_lie lie_self := by intros apply SetCoe.ext apply lie_self leibniz_lie := by intros apply SetCoe.ext apply leibniz_lie section variable {R₁ : Type*} [Semiring R₁] /-- A Lie subalgebra inherits module structures from `L`. -/ instance [SMul R₁ R] [Module R₁ L] [IsScalarTower R₁ R L] (L' : LieSubalgebra R L) : Module R₁ L' := L'.toSubmodule.module' instance [SMul R₁ R] [SMul R₁ᵐᵒᵖ R] [Module R₁ L] [Module R₁ᵐᵒᵖ L] [IsScalarTower R₁ R L] [IsScalarTower R₁ᵐᵒᵖ R L] [IsCentralScalar R₁ L] (L' : LieSubalgebra R L) : IsCentralScalar R₁ L' := L'.toSubmodule.isCentralScalar instance [SMul R₁ R] [Module R₁ L] [IsScalarTower R₁ R L] (L' : LieSubalgebra R L) : IsScalarTower R₁ R L' := L'.toSubmodule.isScalarTower instance (L' : LieSubalgebra R L) [IsNoetherian R L] : IsNoetherian R L' := isNoetherian_submodule' _ end /-- A Lie subalgebra forms a new Lie algebra. -/ instance lieAlgebra (L' : LieSubalgebra R L) : LieAlgebra R L' where lie_smul := by { intros apply SetCoe.ext apply lie_smul } variable {R L} variable (L' : LieSubalgebra R L) @[simp] protected theorem zero_mem : (0 : L) ∈ L' := zero_mem L' protected theorem add_mem {x y : L} : x ∈ L' → y ∈ L' → (x + y : L) ∈ L' := add_mem protected theorem sub_mem {x y : L} : x ∈ L' → y ∈ L' → (x - y : L) ∈ L' := sub_mem theorem smul_mem (t : R) {x : L} (h : x ∈ L') : t • x ∈ L' := (L' : Submodule R L).smul_mem t h theorem lie_mem {x y : L} (hx : x ∈ L') (hy : y ∈ L') : (⁅x, y⁆ : L) ∈ L' := L'.lie_mem' hx hy theorem mem_carrier {x : L} : x ∈ L'.carrier ↔ x ∈ (L' : Set L) := Iff.rfl @[simp] theorem mem_mk_iff (S : Set L) (h₁ h₂ h₃ h₄) {x : L} : x ∈ (⟨⟨⟨⟨S, h₁⟩, h₂⟩, h₃⟩, h₄⟩ : LieSubalgebra R L) ↔ x ∈ S := Iff.rfl @[simp] theorem mem_coe_submodule {x : L} : x ∈ (L' : Submodule R L) ↔ x ∈ L' := Iff.rfl theorem mem_coe {x : L} : x ∈ (L' : Set L) ↔ x ∈ L' := Iff.rfl @[simp, norm_cast] theorem coe_bracket (x y : L') : (↑⁅x, y⁆ : L) = ⁅(↑x : L), ↑y⁆ := rfl theorem ext_iff (x y : L') : x = y ↔ (x : L) = y := Subtype.ext_iff theorem coe_zero_iff_zero (x : L') : (x : L) = 0 ↔ x = 0 := (ext_iff L' x 0).symm @[ext] theorem ext (L₁' L₂' : LieSubalgebra R L) (h : ∀ x, x ∈ L₁' ↔ x ∈ L₂') : L₁' = L₂' := SetLike.ext h theorem ext_iff' (L₁' L₂' : LieSubalgebra R L) : L₁' = L₂' ↔ ∀ x, x ∈ L₁' ↔ x ∈ L₂' := SetLike.ext_iff @[simp] theorem mk_coe (S : Set L) (h₁ h₂ h₃ h₄) : ((⟨⟨⟨⟨S, h₁⟩, h₂⟩, h₃⟩, h₄⟩ : LieSubalgebra R L) : Set L) = S := rfl theorem coe_to_submodule_mk (p : Submodule R L) (h) : (({ p with lie_mem' := h } : LieSubalgebra R L) : Submodule R L) = p := by cases p rfl theorem coe_injective : Function.Injective ((↑) : LieSubalgebra R L → Set L) := SetLike.coe_injective @[norm_cast] theorem coe_set_eq (L₁' L₂' : LieSubalgebra R L) : (L₁' : Set L) = L₂' ↔ L₁' = L₂' := SetLike.coe_set_eq theorem to_submodule_injective : Function.Injective ((↑) : LieSubalgebra R L → Submodule R L) := fun L₁' L₂' h ↦ by rw [SetLike.ext'_iff] at h rw [← coe_set_eq] exact h @[simp] theorem coe_to_submodule_eq_iff (L₁' L₂' : LieSubalgebra R L) : (L₁' : Submodule R L) = (L₂' : Submodule R L) ↔ L₁' = L₂' := to_submodule_injective.eq_iff theorem coe_to_submodule : ((L' : Submodule R L) : Set L) = L' := rfl section LieModule variable {M : Type w} [AddCommGroup M] [LieRingModule L M] variable {N : Type w₁} [AddCommGroup N] [LieRingModule L N] [Module R N] /-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie ring module `M` of `L`, we may regard `M` as a Lie ring module of `L'` by restriction. -/ instance lieRingModule : LieRingModule L' M where bracket x m := ⁅(x : L), m⁆ add_lie x y m := add_lie (x : L) y m lie_add x y m := lie_add (x : L) y m leibniz_lie x y m := leibniz_lie (x : L) y m @[simp] theorem coe_bracket_of_module (x : L') (m : M) : ⁅x, m⁆ = ⁅(x : L), m⁆ := rfl variable [Module R M] /-- Given a Lie algebra `L` containing a Lie subalgebra `L' ⊆ L`, together with a Lie module `M` of `L`, we may regard `M` as a Lie module of `L'` by restriction. -/ instance lieModule [LieModule R L M] : LieModule R L' M where smul_lie t x m := by simp only [coe_bracket_of_module, smul_lie, Submodule.coe_smul_of_tower] lie_smul t x m := by simp only [coe_bracket_of_module, lie_smul] /-- An `L`-equivariant map of Lie modules `M → N` is `L'`-equivariant for any Lie subalgebra `L' ⊆ L`. -/ def _root_.LieModuleHom.restrictLie (f : M →ₗ⁅R,L⁆ N) (L' : LieSubalgebra R L) : M →ₗ⁅R,L'⁆ N := { (f : M →ₗ[R] N) with map_lie' := @fun x m ↦ f.map_lie (↑x) m } @[simp] theorem _root_.LieModuleHom.coe_restrictLie (f : M →ₗ⁅R,L⁆ N) : ⇑(f.restrictLie L') = f := rfl end LieModule /-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie algebras. -/ def incl : L' →ₗ⁅R⁆ L := { (L' : Submodule R L).subtype with map_lie' := rfl } @[simp] theorem coe_incl : ⇑L'.incl = ((↑) : L' → L) := rfl /-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie modules. -/ def incl' : L' →ₗ⁅R,L'⁆ L := { (L' : Submodule R L).subtype with map_lie' := rfl } @[simp] theorem coe_incl' : ⇑L'.incl' = ((↑) : L' → L) := rfl end LieSubalgebra variable {R L} variable {L₂ : Type w} [LieRing L₂] [LieAlgebra R L₂] variable (f : L →ₗ⁅R⁆ L₂) namespace LieHom /-- The range of a morphism of Lie algebras is a Lie subalgebra. -/ def range : LieSubalgebra R L₂ := { LinearMap.range (f : L →ₗ[R] L₂) with lie_mem' := by rintro - - ⟨x, rfl⟩ ⟨y, rfl⟩ exact ⟨⁅x, y⁆, f.map_lie x y⟩ } @[simp] theorem range_coe : (f.range : Set L₂) = Set.range f := LinearMap.range_coe (f : L →ₗ[R] L₂) @[simp] theorem mem_range (x : L₂) : x ∈ f.range ↔ ∃ y : L, f y = x := LinearMap.mem_range theorem mem_range_self (x : L) : f x ∈ f.range := LinearMap.mem_range_self (f : L →ₗ[R] L₂) x /-- We can restrict a morphism to a (surjective) map to its range. -/ def rangeRestrict : L →ₗ⁅R⁆ f.range := { (f : L →ₗ[R] L₂).rangeRestrict with map_lie' := @fun x y ↦ by apply Subtype.ext exact f.map_lie x y } @[simp] theorem rangeRestrict_apply (x : L) : f.rangeRestrict x = ⟨f x, f.mem_range_self x⟩ := rfl theorem surjective_rangeRestrict : Function.Surjective f.rangeRestrict := by rintro ⟨y, hy⟩ erw [mem_range] at hy; obtain ⟨x, rfl⟩ := hy use x simp only [Subtype.mk_eq_mk, rangeRestrict_apply] /-- A Lie algebra is equivalent to its range under an injective Lie algebra morphism. -/ noncomputable def equivRangeOfInjective (h : Function.Injective f) : L ≃ₗ⁅R⁆ f.range := LieEquiv.ofBijective f.rangeRestrict ⟨fun x y hxy ↦ by simp only [Subtype.mk_eq_mk, rangeRestrict_apply] at hxy exact h hxy, f.surjective_rangeRestrict⟩ @[simp] theorem equivRangeOfInjective_apply (h : Function.Injective f) (x : L) : f.equivRangeOfInjective h x = ⟨f x, mem_range_self f x⟩ := rfl end LieHom theorem Submodule.exists_lieSubalgebra_coe_eq_iff (p : Submodule R L) : (∃ K : LieSubalgebra R L, ↑K = p) ↔ ∀ x y : L, x ∈ p → y ∈ p → ⁅x, y⁆ ∈ p := by constructor · rintro ⟨K, rfl⟩ _ _ exact K.lie_mem' · intro h use { p with lie_mem' := h _ _ } namespace LieSubalgebra variable (K K' : LieSubalgebra R L) (K₂ : LieSubalgebra R L₂) @[simp] theorem incl_range : K.incl.range = K := by rw [← coe_to_submodule_eq_iff] exact (K : Submodule R L).range_subtype /-- The image of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the codomain. -/ def map : LieSubalgebra R L₂ := { (K : Submodule R L).map (f : L →ₗ[R] L₂) with lie_mem' := @fun x y hx hy ↦ by erw [Submodule.mem_map] at hx rcases hx with ⟨x', hx', hx⟩ rw [← hx] erw [Submodule.mem_map] at hy rcases hy with ⟨y', hy', hy⟩ rw [← hy] erw [Submodule.mem_map] exact ⟨⁅x', y'⁆, K.lie_mem hx' hy', f.map_lie x' y'⟩ } @[simp] theorem mem_map (x : L₂) : x ∈ K.map f ↔ ∃ y : L, y ∈ K ∧ f y = x := Submodule.mem_map -- TODO Rename and state for homs instead of equivs. theorem mem_map_submodule (e : L ≃ₗ⁅R⁆ L₂) (x : L₂) : x ∈ K.map (e : L →ₗ⁅R⁆ L₂) ↔ x ∈ (K : Submodule R L).map (e : L →ₗ[R] L₂) := Iff.rfl /-- The preimage of a Lie subalgebra under a Lie algebra morphism is a Lie subalgebra of the domain. -/ def comap : LieSubalgebra R L := { (K₂ : Submodule R L₂).comap (f : L →ₗ[R] L₂) with lie_mem' := @fun x y hx hy ↦ by suffices ⁅f x, f y⁆ ∈ K₂ by simp [this] exact K₂.lie_mem hx hy } section LatticeStructure open Set instance : PartialOrder (LieSubalgebra R L) := { PartialOrder.lift ((↑) : LieSubalgebra R L → Set L) coe_injective with le := fun N N' ↦ ∀ ⦃x⦄, x ∈ N → x ∈ N' } theorem le_def : K ≤ K' ↔ (K : Set L) ⊆ K' := Iff.rfl @[simp] theorem coe_submodule_le_coe_submodule : (K : Submodule R L) ≤ K' ↔ K ≤ K' := Iff.rfl instance : Bot (LieSubalgebra R L) := ⟨0⟩ @[simp] theorem bot_coe : ((⊥ : LieSubalgebra R L) : Set L) = {0} := rfl @[simp] theorem bot_coe_submodule : ((⊥ : LieSubalgebra R L) : Submodule R L) = ⊥ := rfl @[simp] theorem mem_bot (x : L) : x ∈ (⊥ : LieSubalgebra R L) ↔ x = 0 := mem_singleton_iff instance : Top (LieSubalgebra R L) := ⟨{ (⊤ : Submodule R L) with lie_mem' := @fun x y _ _ ↦ mem_univ ⁅x, y⁆ }⟩ @[simp] theorem top_coe : ((⊤ : LieSubalgebra R L) : Set L) = univ := rfl @[simp] theorem top_coe_submodule : ((⊤ : LieSubalgebra R L) : Submodule R L) = ⊤ := rfl @[simp] theorem mem_top (x : L) : x ∈ (⊤ : LieSubalgebra R L) := mem_univ x theorem _root_.LieHom.range_eq_map : f.range = map f ⊤ := by ext simp instance : Inf (LieSubalgebra R L) := ⟨fun K K' ↦ { (K ⊓ K' : Submodule R L) with lie_mem' := fun hx hy ↦ mem_inter (K.lie_mem hx.1 hy.1) (K'.lie_mem hx.2 hy.2) }⟩ instance : InfSet (LieSubalgebra R L) := ⟨fun S ↦ { sInf {(s : Submodule R L) | s ∈ S} with lie_mem' := @fun x y hx hy ↦ by simp only [Submodule.mem_carrier, mem_iInter, Submodule.sInf_coe, mem_setOf_eq, forall_apply_eq_imp_iff₂, exists_imp, and_imp] at hx hy ⊢ intro K hK exact K.lie_mem (hx K hK) (hy K hK) }⟩ @[simp] theorem inf_coe : (↑(K ⊓ K') : Set L) = (K : Set L) ∩ (K' : Set L) := rfl @[simp] theorem sInf_coe_to_submodule (S : Set (LieSubalgebra R L)) : (↑(sInf S) : Submodule R L) = sInf {(s : Submodule R L) | s ∈ S} := rfl @[simp] theorem sInf_coe (S : Set (LieSubalgebra R L)) : (↑(sInf S) : Set L) = ⋂ s ∈ S, (s : Set L) := by rw [← coe_to_submodule, sInf_coe_to_submodule, Submodule.sInf_coe] ext x simp theorem sInf_glb (S : Set (LieSubalgebra R L)) : IsGLB S (sInf S) := by have h : ∀ K K' : LieSubalgebra R L, (K : Set L) ≤ K' ↔ K ≤ K' := by intros exact Iff.rfl apply IsGLB.of_image @h simp only [sInf_coe] exact isGLB_biInf /-- The set of Lie subalgebras of a Lie algebra form a complete lattice. We provide explicit values for the fields `bot`, `top`, `inf` to get more convenient definitions than we would otherwise obtain from `completeLatticeOfInf`. -/ instance completeLattice : CompleteLattice (LieSubalgebra R L) := { completeLatticeOfInf _ sInf_glb with bot := ⊥ bot_le := fun N _ h ↦ by rw [mem_bot] at h rw [h] exact N.zero_mem' top := ⊤ le_top := fun _ _ _ ↦ trivial inf := (· ⊓ ·) le_inf := fun N₁ N₂ N₃ h₁₂ h₁₃ m hm ↦ ⟨h₁₂ hm, h₁₃ hm⟩ inf_le_left := fun _ _ _ ↦ And.left inf_le_right := fun _ _ _ ↦ And.right } instance : Add (LieSubalgebra R L) where add := Sup.sup instance : Zero (LieSubalgebra R L) where zero := ⊥ instance addCommMonoid : AddCommMonoid (LieSubalgebra R L) where add_assoc := sup_assoc zero_add := bot_sup_eq add_zero := sup_bot_eq add_comm := sup_comm nsmul := nsmulRec instance : CanonicallyOrderedAddCommMonoid (LieSubalgebra R L) := { LieSubalgebra.addCommMonoid, LieSubalgebra.completeLattice with add_le_add_left := fun _a _b ↦ sup_le_sup_left exists_add_of_le := @fun _a b h ↦ ⟨b, (sup_eq_right.2 h).symm⟩ le_self_add := fun _a _b ↦ le_sup_left } @[simp] theorem add_eq_sup : K + K' = K ⊔ K' := rfl @[simp] theorem inf_coe_to_submodule : (↑(K ⊓ K') : Submodule R L) = (K : Submodule R L) ⊓ (K' : Submodule R L) := rfl @[simp] theorem mem_inf (x : L) : x ∈ K ⊓ K' ↔ x ∈ K ∧ x ∈ K' := by rw [← mem_coe_submodule, ← mem_coe_submodule, ← mem_coe_submodule, inf_coe_to_submodule, Submodule.mem_inf] theorem eq_bot_iff : K = ⊥ ↔ ∀ x : L, x ∈ K → x = 0 := by rw [_root_.eq_bot_iff] exact Iff.rfl instance subsingleton_of_bot : Subsingleton (LieSubalgebra R (⊥ : LieSubalgebra R L)) := by apply subsingleton_of_bot_eq_top ext ⟨x, hx⟩; change x ∈ ⊥ at hx; rw [LieSubalgebra.mem_bot] at hx; subst hx simp only [true_iff_iff, eq_self_iff_true, Submodule.mk_eq_zero, mem_bot, mem_top] theorem subsingleton_bot : Subsingleton (⊥ : LieSubalgebra R L) := show Subsingleton ((⊥ : LieSubalgebra R L) : Set L) by simp variable (R L) theorem wellFounded_of_noetherian [IsNoetherian R L] : WellFounded ((· > ·) : LieSubalgebra R L → LieSubalgebra R L → Prop) := let f : ((· > ·) : LieSubalgebra R L → LieSubalgebra R L → Prop) →r ((· > ·) : Submodule R L → Submodule R L → Prop) := { toFun := (↑) map_rel' := @fun _ _ h ↦ h } RelHomClass.wellFounded f (isNoetherian_iff_wellFounded.mp inferInstance) variable {R L K K' f} section NestedSubalgebras variable (h : K ≤ K') /-- Given two nested Lie subalgebras `K ⊆ K'`, the inclusion `K ↪ K'` is a morphism of Lie algebras. -/ def inclusion : K →ₗ⁅R⁆ K' := { Submodule.inclusion h with map_lie' := @fun _ _ ↦ rfl } @[simp] theorem coe_inclusion (x : K) : (inclusion h x : L) = x := rfl theorem inclusion_apply (x : K) : inclusion h x = ⟨x.1, h x.2⟩ := rfl theorem inclusion_injective : Function.Injective (inclusion h) := fun x y ↦ by simp only [inclusion_apply, imp_self, Subtype.mk_eq_mk, SetLike.coe_eq_coe] /-- Given two nested Lie subalgebras `K ⊆ K'`, we can view `K` as a Lie subalgebra of `K'`, regarded as Lie algebra in its own right. -/ def ofLe : LieSubalgebra R K' := (inclusion h).range @[simp] theorem mem_ofLe (x : K') : x ∈ ofLe h ↔ (x : L) ∈ K := by simp only [ofLe, inclusion_apply, LieHom.mem_range] constructor · rintro ⟨y, rfl⟩ exact y.property · intro h use ⟨(x : L), h⟩ theorem ofLe_eq_comap_incl : ofLe h = K.comap K'.incl := by ext rw [mem_ofLe] rfl @[simp] theorem coe_ofLe : (ofLe h : Submodule R K') = LinearMap.range (Submodule.inclusion h) := rfl /-- Given nested Lie subalgebras `K ⊆ K'`, there is a natural equivalence from `K` to its image in `K'`. -/ noncomputable def equivOfLe : K ≃ₗ⁅R⁆ ofLe h := (inclusion h).equivRangeOfInjective (inclusion_injective h) @[simp] theorem equivOfLe_apply (x : K) : equivOfLe h x = ⟨inclusion h x, (inclusion h).mem_range_self x⟩ := rfl end NestedSubalgebras theorem map_le_iff_le_comap {K : LieSubalgebra R L} {K' : LieSubalgebra R L₂} : map f K ≤ K' ↔ K ≤ comap f K' := Set.image_subset_iff theorem gc_map_comap : GaloisConnection (map f) (comap f) := fun _ _ ↦ map_le_iff_le_comap end LatticeStructure section LieSpan variable (R L) (s : Set L) /-- The Lie subalgebra of a Lie algebra `L` generated by a subset `s ⊆ L`. -/ def lieSpan : LieSubalgebra R L := sInf { N | s ⊆ N } variable {R L s} theorem mem_lieSpan {x : L} : x ∈ lieSpan R L s ↔ ∀ K : LieSubalgebra R L, s ⊆ K → x ∈ K := by change x ∈ (lieSpan R L s : Set L) ↔ _ erw [sInf_coe] exact Set.mem_iInter₂ theorem subset_lieSpan : s ⊆ lieSpan R L s := by intro m hm erw [mem_lieSpan] intro K hK exact hK hm theorem submodule_span_le_lieSpan : Submodule.span R s ≤ lieSpan R L s := by rw [Submodule.span_le] apply subset_lieSpan theorem lieSpan_le {K} : lieSpan R L s ≤ K ↔ s ⊆ K := by constructor · exact Set.Subset.trans subset_lieSpan · intro hs m hm rw [mem_lieSpan] at hm exact hm _ hs theorem lieSpan_mono {t : Set L} (h : s ⊆ t) : lieSpan R L s ≤ lieSpan R L t := by rw [lieSpan_le] exact Set.Subset.trans h subset_lieSpan theorem lieSpan_eq : lieSpan R L (K : Set L) = K := le_antisymm (lieSpan_le.mpr rfl.subset) subset_lieSpan theorem coe_lieSpan_submodule_eq_iff {p : Submodule R L} : (lieSpan R L (p : Set L) : Submodule R L) = p ↔ ∃ K : LieSubalgebra R L, ↑K = p := by rw [p.exists_lieSubalgebra_coe_eq_iff]; constructor <;> intro h · intro x m hm rw [← h, mem_coe_submodule] exact lie_mem _ (subset_lieSpan hm) · rw [← coe_to_submodule_mk p @h, coe_to_submodule, coe_to_submodule_eq_iff, lieSpan_eq] variable (R L) /-- `lieSpan` forms a Galois insertion with the coercion from `LieSubalgebra` to `Set`. -/ protected def gi : GaloisInsertion (lieSpan R L : Set L → LieSubalgebra R L) (↑) where choice s _ := lieSpan R L s gc _ _ := lieSpan_le le_l_u _ := subset_lieSpan choice_eq _ _ := rfl @[simp] theorem span_empty : lieSpan R L (∅ : Set L) = ⊥ := (LieSubalgebra.gi R L).gc.l_bot @[simp] theorem span_univ : lieSpan R L (Set.univ : Set L) = ⊤ := eq_top_iff.2 <| SetLike.le_def.2 <| subset_lieSpan variable {L} theorem span_union (s t : Set L) : lieSpan R L (s ∪ t) = lieSpan R L s ⊔ lieSpan R L t := (LieSubalgebra.gi R L).gc.l_sup theorem span_iUnion {ι} (s : ι → Set L) : lieSpan R L (⋃ i, s i) = ⨆ i, lieSpan R L (s i) := (LieSubalgebra.gi R L).gc.l_iSup /-- If a predicate `p` is true on some set `s ⊆ L`, true for `0`, stable by scalar multiplication, by addition and by Lie bracket, then the predicate is true on the Lie span of `s`. (Since `s` can be empty, and the Lie span always contains `0`, the assumption that `p 0` holds cannot be removed.) -/ @[elab_as_elim] theorem lieSpan_induction {p : L → Prop} {x : L} (h : x ∈ lieSpan R L s) (mem : ∀ x ∈ s, p x) (zero : p 0) (smul : ∀ (r : R), ∀ {x : L}, p x → p (r • x)) (add : ∀ x y, p x → p y → p (x + y)) (lie : ∀ x y, p x → p y → p ⁅x, y⁆) : p x := let S : LieSubalgebra R L := { carrier := p add_mem' := add _ _ zero_mem' := zero smul_mem' := smul lie_mem' := lie _ _ } lieSpan_le.mpr (show s ≤ S from mem) h end LieSpan end LieSubalgebra end LieSubalgebra namespace LieEquiv variable {R : Type u} {L₁ : Type v} {L₂ : Type w} variable [CommRing R] [LieRing L₁] [LieRing L₂] [LieAlgebra R L₁] [LieAlgebra R L₂] /-- An injective Lie algebra morphism is an equivalence onto its range. -/ noncomputable def ofInjective (f : L₁ →ₗ⁅R⁆ L₂) (h : Function.Injective f) : L₁ ≃ₗ⁅R⁆ f.range := { LinearEquiv.ofInjective (f : L₁ →ₗ[R] L₂) <| by rwa [LieHom.coe_toLinearMap] with map_lie' := @fun x y ↦ SetCoe.ext <| f.map_lie x y } @[simp] theorem ofInjective_apply (f : L₁ →ₗ⁅R⁆ L₂) (h : Function.Injective f) (x : L₁) : ↑(ofInjective f h x) = f x := rfl variable (L₁' L₁'' : LieSubalgebra R L₁) (L₂' : LieSubalgebra R L₂) /-- Lie subalgebras that are equal as sets are equivalent as Lie algebras. -/ def ofEq (h : (L₁' : Set L₁) = L₁'') : L₁' ≃ₗ⁅R⁆ L₁'' := { LinearEquiv.ofEq (L₁' : Submodule R L₁) (L₁'' : Submodule R L₁) (by ext x change x ∈ (L₁' : Set L₁) ↔ x ∈ (L₁'' : Set L₁) rw [h]) with map_lie' := @fun x y ↦ rfl } @[simp] theorem ofEq_apply (L L' : LieSubalgebra R L₁) (h : (L : Set L₁) = L') (x : L) : (↑(ofEq L L' h x) : L₁) = x := rfl variable (e : L₁ ≃ₗ⁅R⁆ L₂) /-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its image. -/ def lieSubalgebraMap : L₁'' ≃ₗ⁅R⁆ (L₁''.map e : LieSubalgebra R L₂) := { LinearEquiv.submoduleMap (e : L₁ ≃ₗ[R] L₂) ↑L₁'' with map_lie' := @fun x y ↦ by apply SetCoe.ext exact LieHom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y } @[simp] theorem lieSubalgebraMap_apply (x : L₁'') : ↑(e.lieSubalgebraMap _ x) = e x := rfl /-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its image. -/ def ofSubalgebras (h : L₁'.map ↑e = L₂') : L₁' ≃ₗ⁅R⁆ L₂' := { LinearEquiv.ofSubmodules (e : L₁ ≃ₗ[R] L₂) (↑L₁') (↑L₂') (by rw [← h] rfl) with map_lie' := @fun x y ↦ by apply SetCoe.ext exact LieHom.map_lie (↑e : L₁ →ₗ⁅R⁆ L₂) ↑x ↑y } @[simp] theorem ofSubalgebras_apply (h : L₁'.map ↑e = L₂') (x : L₁') : ↑(e.ofSubalgebras _ _ h x) = e x := rfl @[simp] theorem ofSubalgebras_symm_apply (h : L₁'.map ↑e = L₂') (x : L₂') : ↑((e.ofSubalgebras _ _ h).symm x) = e.symm x := rfl end LieEquiv
Algebra\Lie\Submodule.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Subalgebra import Mathlib.RingTheory.Noetherian import Mathlib.RingTheory.Artinian /-! # Lie submodules of a Lie algebra In this file we define Lie submodules and Lie ideals, we construct the lattice structure on Lie submodules and we use it to define various important operations, notably the Lie span of a subset of a Lie module. ## Main definitions * `LieSubmodule` * `LieSubmodule.wellFounded_of_noetherian` * `LieSubmodule.lieSpan` * `LieSubmodule.map` * `LieSubmodule.comap` * `LieIdeal` * `LieIdeal.map` * `LieIdeal.comap` ## Tags lie algebra, lie submodule, lie ideal, lattice structure -/ universe u v w w₁ w₂ section LieSubmodule variable (R : Type u) (L : Type v) (M : Type w) variable [CommRing R] [LieRing L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] /-- A Lie submodule of a Lie module is a submodule that is closed under the Lie bracket. This is a sufficient condition for the subset itself to form a Lie module. -/ structure LieSubmodule extends Submodule R M where lie_mem : ∀ {x : L} {m : M}, m ∈ carrier → ⁅x, m⁆ ∈ carrier attribute [nolint docBlame] LieSubmodule.toSubmodule attribute [coe] LieSubmodule.toSubmodule namespace LieSubmodule variable {R L M} variable (N N' : LieSubmodule R L M) instance : SetLike (LieSubmodule R L M) M where coe s := s.carrier coe_injective' N O h := by cases N; cases O; congr; exact SetLike.coe_injective' h instance : AddSubgroupClass (LieSubmodule R L M) M where add_mem {N} _ _ := N.add_mem' zero_mem N := N.zero_mem' neg_mem {N} x hx := show -x ∈ N.toSubmodule from neg_mem hx instance instSMulMemClass : SMulMemClass (LieSubmodule R L M) R M where smul_mem {s} c _ h := s.smul_mem' c h /-- The zero module is a Lie submodule of any Lie module. -/ instance : Zero (LieSubmodule R L M) := ⟨{ (0 : Submodule R M) with lie_mem := fun {x m} h ↦ by rw [(Submodule.mem_bot R).1 h]; apply lie_zero }⟩ instance : Inhabited (LieSubmodule R L M) := ⟨0⟩ instance coeSubmodule : CoeOut (LieSubmodule R L M) (Submodule R M) := ⟨toSubmodule⟩ instance instCanLiftSubmoduleLieSubmodule : CanLift (Submodule R M) (LieSubmodule R L M) (·) (fun N ↦ ∀ {x : L} {m : M}, m ∈ N → ⁅x, m⁆ ∈ N) where prf N hN := ⟨⟨N, hN⟩, rfl⟩ -- Syntactic tautology @[norm_cast] theorem coe_toSubmodule : ((N : Submodule R M) : Set M) = N := rfl -- Porting note (#10618): `simp` can prove this after `mem_coeSubmodule` is added to the simp set, -- but `dsimp` can't. @[simp, nolint simpNF] theorem mem_carrier {x : M} : x ∈ N.carrier ↔ x ∈ (N : Set M) := Iff.rfl theorem mem_mk_iff (S : Set M) (h₁ h₂ h₃ h₄) {x : M} : x ∈ (⟨⟨⟨⟨S, h₁⟩, h₂⟩, h₃⟩, h₄⟩ : LieSubmodule R L M) ↔ x ∈ S := Iff.rfl @[simp] theorem mem_mk_iff' (p : Submodule R M) (h) {x : M} : x ∈ (⟨p, h⟩ : LieSubmodule R L M) ↔ x ∈ p := Iff.rfl @[simp] theorem mem_coeSubmodule {x : M} : x ∈ (N : Submodule R M) ↔ x ∈ N := Iff.rfl theorem mem_coe {x : M} : x ∈ (N : Set M) ↔ x ∈ N := Iff.rfl @[simp] protected theorem zero_mem : (0 : M) ∈ N := zero_mem N -- Porting note (#10618): @[simp] can prove this theorem mk_eq_zero {x} (h : x ∈ N) : (⟨x, h⟩ : N) = 0 ↔ x = 0 := Subtype.ext_iff_val @[simp] theorem coe_toSet_mk (S : Set M) (h₁ h₂ h₃ h₄) : ((⟨⟨⟨⟨S, h₁⟩, h₂⟩, h₃⟩, h₄⟩ : LieSubmodule R L M) : Set M) = S := rfl theorem coe_toSubmodule_mk (p : Submodule R M) (h) : (({ p with lie_mem := h } : LieSubmodule R L M) : Submodule R M) = p := by cases p; rfl theorem coeSubmodule_injective : Function.Injective (toSubmodule : LieSubmodule R L M → Submodule R M) := fun x y h ↦ by cases x; cases y; congr @[ext] theorem ext (h : ∀ m, m ∈ N ↔ m ∈ N') : N = N' := SetLike.ext h @[simp] theorem coe_toSubmodule_eq_iff : (N : Submodule R M) = (N' : Submodule R M) ↔ N = N' := coeSubmodule_injective.eq_iff /-- Copy of a `LieSubmodule` with a new `carrier` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (s : Set M) (hs : s = ↑N) : LieSubmodule R L M where carrier := s -- Porting note: all the proofs below were in term mode zero_mem' := by exact hs.symm ▸ N.zero_mem' add_mem' x y := by rw [hs] at x y ⊢; exact N.add_mem' x y smul_mem' := by exact hs.symm ▸ N.smul_mem' lie_mem := by exact hs.symm ▸ N.lie_mem @[simp] theorem coe_copy (S : LieSubmodule R L M) (s : Set M) (hs : s = ↑S) : (S.copy s hs : Set M) = s := rfl theorem copy_eq (S : LieSubmodule R L M) (s : Set M) (hs : s = ↑S) : S.copy s hs = S := SetLike.coe_injective hs instance : LieRingModule L N where bracket (x : L) (m : N) := ⟨⁅x, m.val⁆, N.lie_mem m.property⟩ add_lie := by intro x y m; apply SetCoe.ext; apply add_lie lie_add := by intro x m n; apply SetCoe.ext; apply lie_add leibniz_lie := by intro x y m; apply SetCoe.ext; apply leibniz_lie instance module' {S : Type*} [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : Module S N := N.toSubmodule.module' instance : Module R N := N.toSubmodule.module instance {S : Type*} [Semiring S] [SMul S R] [SMul Sᵐᵒᵖ R] [Module S M] [Module Sᵐᵒᵖ M] [IsScalarTower S R M] [IsScalarTower Sᵐᵒᵖ R M] [IsCentralScalar S M] : IsCentralScalar S N := N.toSubmodule.isCentralScalar @[simp, norm_cast] theorem coe_zero : ((0 : N) : M) = (0 : M) := rfl @[simp, norm_cast] theorem coe_add (m m' : N) : (↑(m + m') : M) = (m : M) + (m' : M) := rfl @[simp, norm_cast] theorem coe_neg (m : N) : (↑(-m) : M) = -(m : M) := rfl @[simp, norm_cast] theorem coe_sub (m m' : N) : (↑(m - m') : M) = (m : M) - (m' : M) := rfl @[simp, norm_cast] theorem coe_smul (t : R) (m : N) : (↑(t • m) : M) = t • (m : M) := rfl @[simp, norm_cast] theorem coe_bracket (x : L) (m : N) : (↑⁅x, m⁆ : M) = ⁅x, ↑m⁆ := rfl variable [LieAlgebra R L] [LieModule R L M] instance instLieModule : LieModule R L N where lie_smul := by intro t x y; apply SetCoe.ext; apply lie_smul smul_lie := by intro t x y; apply SetCoe.ext; apply smul_lie instance [Subsingleton M] : Unique (LieSubmodule R L M) := ⟨⟨0⟩, fun _ ↦ (coe_toSubmodule_eq_iff _ _).mp (Subsingleton.elim _ _)⟩ end LieSubmodule section LieIdeal variable [LieAlgebra R L] [LieModule R L M] /-- An ideal of a Lie algebra is a Lie submodule of the Lie algebra as a Lie module over itself. -/ abbrev LieIdeal := LieSubmodule R L L theorem lie_mem_right (I : LieIdeal R L) (x y : L) (h : y ∈ I) : ⁅x, y⁆ ∈ I := I.lie_mem h theorem lie_mem_left (I : LieIdeal R L) (x y : L) (h : x ∈ I) : ⁅x, y⁆ ∈ I := by rw [← lie_skew, ← neg_lie]; apply lie_mem_right; assumption /-- An ideal of a Lie algebra is a Lie subalgebra. -/ def lieIdealSubalgebra (I : LieIdeal R L) : LieSubalgebra R L := { I.toSubmodule with lie_mem' := by intro x y _ hy; apply lie_mem_right; exact hy } instance : Coe (LieIdeal R L) (LieSubalgebra R L) := ⟨lieIdealSubalgebra R L⟩ @[simp] theorem LieIdeal.coe_toSubalgebra (I : LieIdeal R L) : ((I : LieSubalgebra R L) : Set L) = I := rfl @[simp] theorem LieIdeal.coe_to_lieSubalgebra_to_submodule (I : LieIdeal R L) : ((I : LieSubalgebra R L) : Submodule R L) = LieSubmodule.toSubmodule I := rfl /-- An ideal of `L` is a Lie subalgebra of `L`, so it is a Lie ring. -/ instance LieIdeal.lieRing (I : LieIdeal R L) : LieRing I := LieSubalgebra.lieRing R L ↑I /-- Transfer the `LieAlgebra` instance from the coercion `LieIdeal → LieSubalgebra`. -/ instance LieIdeal.lieAlgebra (I : LieIdeal R L) : LieAlgebra R I := LieSubalgebra.lieAlgebra R L ↑I /-- Transfer the `LieRingModule` instance from the coercion `LieIdeal → LieSubalgebra`. -/ instance LieIdeal.lieRingModule {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L) [LieRingModule L M] : LieRingModule I M := LieSubalgebra.lieRingModule (I : LieSubalgebra R L) @[simp] theorem LieIdeal.coe_bracket_of_module {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (I : LieIdeal R L) [LieRingModule L M] (x : I) (m : M) : ⁅x, m⁆ = ⁅(↑x : L), m⁆ := LieSubalgebra.coe_bracket_of_module (I : LieSubalgebra R L) x m /-- Transfer the `LieModule` instance from the coercion `LieIdeal → LieSubalgebra`. -/ instance LieIdeal.lieModule (I : LieIdeal R L) : LieModule R I M := LieSubalgebra.lieModule (I : LieSubalgebra R L) end LieIdeal variable {R M} theorem Submodule.exists_lieSubmodule_coe_eq_iff (p : Submodule R M) : (∃ N : LieSubmodule R L M, ↑N = p) ↔ ∀ (x : L) (m : M), m ∈ p → ⁅x, m⁆ ∈ p := by constructor · rintro ⟨N, rfl⟩ _ _; exact N.lie_mem · intro h; use { p with lie_mem := @h } namespace LieSubalgebra variable {L} variable [LieAlgebra R L] variable (K : LieSubalgebra R L) /-- Given a Lie subalgebra `K ⊆ L`, if we view `L` as a `K`-module by restriction, it contains a distinguished Lie submodule for the action of `K`, namely `K` itself. -/ def toLieSubmodule : LieSubmodule R K L := { (K : Submodule R L) with lie_mem := fun {x _} hy ↦ K.lie_mem x.property hy } @[simp] theorem coe_toLieSubmodule : (K.toLieSubmodule : Submodule R L) = K := rfl variable {K} @[simp] theorem mem_toLieSubmodule (x : L) : x ∈ K.toLieSubmodule ↔ x ∈ K := Iff.rfl theorem exists_lieIdeal_coe_eq_iff : (∃ I : LieIdeal R L, ↑I = K) ↔ ∀ x y : L, y ∈ K → ⁅x, y⁆ ∈ K := by simp only [← coe_to_submodule_eq_iff, LieIdeal.coe_to_lieSubalgebra_to_submodule, Submodule.exists_lieSubmodule_coe_eq_iff L] exact Iff.rfl theorem exists_nested_lieIdeal_coe_eq_iff {K' : LieSubalgebra R L} (h : K ≤ K') : (∃ I : LieIdeal R K', ↑I = ofLe h) ↔ ∀ x y : L, x ∈ K' → y ∈ K → ⁅x, y⁆ ∈ K := by simp only [exists_lieIdeal_coe_eq_iff, coe_bracket, mem_ofLe] constructor · intro h' x y hx hy; exact h' ⟨x, hx⟩ ⟨y, h hy⟩ hy · rintro h' ⟨x, hx⟩ ⟨y, hy⟩ hy'; exact h' x y hx hy' end LieSubalgebra end LieSubmodule namespace LieSubmodule variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] [AddCommGroup M] [Module R M] variable [LieRingModule L M] variable (N N' : LieSubmodule R L M) section LatticeStructure open Set theorem coe_injective : Function.Injective ((↑) : LieSubmodule R L M → Set M) := SetLike.coe_injective @[simp, norm_cast] theorem coeSubmodule_le_coeSubmodule : (N : Submodule R M) ≤ N' ↔ N ≤ N' := Iff.rfl instance : Bot (LieSubmodule R L M) := ⟨0⟩ @[simp] theorem bot_coe : ((⊥ : LieSubmodule R L M) : Set M) = {0} := rfl @[simp] theorem bot_coeSubmodule : ((⊥ : LieSubmodule R L M) : Submodule R M) = ⊥ := rfl @[simp] theorem coeSubmodule_eq_bot_iff : (N : Submodule R M) = ⊥ ↔ N = ⊥ := by rw [← coe_toSubmodule_eq_iff, bot_coeSubmodule] @[simp] theorem mk_eq_bot_iff {N : Submodule R M} {h} : (⟨N, h⟩ : LieSubmodule R L M) = ⊥ ↔ N = ⊥ := by rw [← coe_toSubmodule_eq_iff, bot_coeSubmodule] @[simp] theorem mem_bot (x : M) : x ∈ (⊥ : LieSubmodule R L M) ↔ x = 0 := mem_singleton_iff instance : Top (LieSubmodule R L M) := ⟨{ (⊤ : Submodule R M) with lie_mem := fun {x m} _ ↦ mem_univ ⁅x, m⁆ }⟩ @[simp] theorem top_coe : ((⊤ : LieSubmodule R L M) : Set M) = univ := rfl @[simp] theorem top_coeSubmodule : ((⊤ : LieSubmodule R L M) : Submodule R M) = ⊤ := rfl @[simp] theorem coeSubmodule_eq_top_iff : (N : Submodule R M) = ⊤ ↔ N = ⊤ := by rw [← coe_toSubmodule_eq_iff, top_coeSubmodule] @[simp] theorem mk_eq_top_iff {N : Submodule R M} {h} : (⟨N, h⟩ : LieSubmodule R L M) = ⊤ ↔ N = ⊤ := by rw [← coe_toSubmodule_eq_iff, top_coeSubmodule] @[simp] theorem mem_top (x : M) : x ∈ (⊤ : LieSubmodule R L M) := mem_univ x instance : Inf (LieSubmodule R L M) := ⟨fun N N' ↦ { (N ⊓ N' : Submodule R M) with lie_mem := fun h ↦ mem_inter (N.lie_mem h.1) (N'.lie_mem h.2) }⟩ instance : InfSet (LieSubmodule R L M) := ⟨fun S ↦ { toSubmodule := sInf {(s : Submodule R M) | s ∈ S} lie_mem := fun {x m} h ↦ by simp only [Submodule.mem_carrier, mem_iInter, Submodule.sInf_coe, mem_setOf_eq, forall_apply_eq_imp_iff₂, forall_exists_index, and_imp] at h ⊢ intro N hN; apply N.lie_mem (h N hN) }⟩ @[simp] theorem inf_coe : (↑(N ⊓ N') : Set M) = ↑N ∩ ↑N' := rfl @[norm_cast, simp] theorem inf_coe_toSubmodule : (↑(N ⊓ N') : Submodule R M) = (N : Submodule R M) ⊓ (N' : Submodule R M) := rfl @[simp] theorem sInf_coe_toSubmodule (S : Set (LieSubmodule R L M)) : (↑(sInf S) : Submodule R M) = sInf {(s : Submodule R M) | s ∈ S} := rfl theorem sInf_coe_toSubmodule' (S : Set (LieSubmodule R L M)) : (↑(sInf S) : Submodule R M) = ⨅ N ∈ S, (N : Submodule R M) := by rw [sInf_coe_toSubmodule, ← Set.image, sInf_image] @[simp] theorem iInf_coe_toSubmodule {ι} (p : ι → LieSubmodule R L M) : (↑(⨅ i, p i) : Submodule R M) = ⨅ i, (p i : Submodule R M) := by rw [iInf, sInf_coe_toSubmodule]; ext; simp @[simp] theorem sInf_coe (S : Set (LieSubmodule R L M)) : (↑(sInf S) : Set M) = ⋂ s ∈ S, (s : Set M) := by rw [← LieSubmodule.coe_toSubmodule, sInf_coe_toSubmodule, Submodule.sInf_coe] ext m simp only [mem_iInter, mem_setOf_eq, forall_apply_eq_imp_iff₂, exists_imp, and_imp, SetLike.mem_coe, mem_coeSubmodule] @[simp] theorem iInf_coe {ι} (p : ι → LieSubmodule R L M) : (↑(⨅ i, p i) : Set M) = ⋂ i, ↑(p i) := by rw [iInf, sInf_coe]; simp only [Set.mem_range, Set.iInter_exists, Set.iInter_iInter_eq'] @[simp] theorem mem_iInf {ι} (p : ι → LieSubmodule R L M) {x} : (x ∈ ⨅ i, p i) ↔ ∀ i, x ∈ p i := by rw [← SetLike.mem_coe, iInf_coe, Set.mem_iInter]; rfl instance : Sup (LieSubmodule R L M) where sup N N' := { toSubmodule := (N : Submodule R M) ⊔ (N' : Submodule R M) lie_mem := by rintro x m (hm : m ∈ (N : Submodule R M) ⊔ (N' : Submodule R M)) change ⁅x, m⁆ ∈ (N : Submodule R M) ⊔ (N' : Submodule R M) rw [Submodule.mem_sup] at hm ⊢ obtain ⟨y, hy, z, hz, rfl⟩ := hm exact ⟨⁅x, y⁆, N.lie_mem hy, ⁅x, z⁆, N'.lie_mem hz, (lie_add _ _ _).symm⟩ } instance : SupSet (LieSubmodule R L M) where sSup S := { toSubmodule := sSup {(p : Submodule R M) | p ∈ S} lie_mem := by intro x m (hm : m ∈ sSup {(p : Submodule R M) | p ∈ S}) change ⁅x, m⁆ ∈ sSup {(p : Submodule R M) | p ∈ S} obtain ⟨s, hs, hsm⟩ := Submodule.mem_sSup_iff_exists_finset.mp hm clear hm classical induction' s using Finset.induction_on with q t hqt ih generalizing m · replace hsm : m = 0 := by simpa using hsm simp [hsm] · rw [Finset.iSup_insert] at hsm obtain ⟨m', hm', u, hu, rfl⟩ := Submodule.mem_sup.mp hsm rw [lie_add] refine add_mem ?_ (ih (Subset.trans (by simp) hs) hu) obtain ⟨p, hp, rfl⟩ : ∃ p ∈ S, ↑p = q := hs (Finset.mem_insert_self q t) suffices p ≤ sSup {(p : Submodule R M) | p ∈ S} by exact this (p.lie_mem hm') exact le_sSup ⟨p, hp, rfl⟩ } @[norm_cast, simp] theorem sup_coe_toSubmodule : (↑(N ⊔ N') : Submodule R M) = (N : Submodule R M) ⊔ (N' : Submodule R M) := by rfl @[simp] theorem sSup_coe_toSubmodule (S : Set (LieSubmodule R L M)) : (↑(sSup S) : Submodule R M) = sSup {(s : Submodule R M) | s ∈ S} := rfl theorem sSup_coe_toSubmodule' (S : Set (LieSubmodule R L M)) : (↑(sSup S) : Submodule R M) = ⨆ N ∈ S, (N : Submodule R M) := by rw [sSup_coe_toSubmodule, ← Set.image, sSup_image] @[simp] theorem iSup_coe_toSubmodule {ι} (p : ι → LieSubmodule R L M) : (↑(⨆ i, p i) : Submodule R M) = ⨆ i, (p i : Submodule R M) := by rw [iSup, sSup_coe_toSubmodule]; ext; simp [Submodule.mem_sSup, Submodule.mem_iSup] /-- The set of Lie submodules of a Lie module form a complete lattice. -/ instance : CompleteLattice (LieSubmodule R L M) := { coeSubmodule_injective.completeLattice toSubmodule sup_coe_toSubmodule inf_coe_toSubmodule sSup_coe_toSubmodule' sInf_coe_toSubmodule' rfl rfl with toPartialOrder := SetLike.instPartialOrder } theorem mem_iSup_of_mem {ι} {b : M} {N : ι → LieSubmodule R L M} (i : ι) (h : b ∈ N i) : b ∈ ⨆ i, N i := (le_iSup N i) h lemma iSup_induction {ι} (N : ι → LieSubmodule R L M) {C : M → Prop} {x : M} (hx : x ∈ ⨆ i, N i) (hN : ∀ i, ∀ y ∈ N i, C y) (h0 : C 0) (hadd : ∀ y z, C y → C z → C (y + z)) : C x := by rw [← LieSubmodule.mem_coeSubmodule, LieSubmodule.iSup_coe_toSubmodule] at hx exact Submodule.iSup_induction (C := C) (fun i ↦ (N i : Submodule R M)) hx hN h0 hadd @[elab_as_elim] theorem iSup_induction' {ι} (N : ι → LieSubmodule R L M) {C : (x : M) → (x ∈ ⨆ i, N i) → Prop} (hN : ∀ (i) (x) (hx : x ∈ N i), C x (mem_iSup_of_mem i hx)) (h0 : C 0 (zero_mem _)) (hadd : ∀ x y hx hy, C x hx → C y hy → C (x + y) (add_mem ‹_› ‹_›)) {x : M} (hx : x ∈ ⨆ i, N i) : C x hx := by refine Exists.elim ?_ fun (hx : x ∈ ⨆ i, N i) (hc : C x hx) => hc refine iSup_induction N (C := fun x : M ↦ ∃ (hx : x ∈ ⨆ i, N i), C x hx) hx (fun i x hx => ?_) ?_ fun x y => ?_ · exact ⟨_, hN _ _ hx⟩ · exact ⟨_, h0⟩ · rintro ⟨_, Cx⟩ ⟨_, Cy⟩ exact ⟨_, hadd _ _ _ _ Cx Cy⟩ theorem disjoint_iff_coe_toSubmodule : Disjoint N N' ↔ Disjoint (N : Submodule R M) (N' : Submodule R M) := by rw [disjoint_iff, disjoint_iff, ← coe_toSubmodule_eq_iff, inf_coe_toSubmodule, bot_coeSubmodule, ← disjoint_iff] theorem codisjoint_iff_coe_toSubmodule : Codisjoint N N' ↔ Codisjoint (N : Submodule R M) (N' : Submodule R M) := by rw [codisjoint_iff, codisjoint_iff, ← coe_toSubmodule_eq_iff, sup_coe_toSubmodule, top_coeSubmodule, ← codisjoint_iff] theorem isCompl_iff_coe_toSubmodule : IsCompl N N' ↔ IsCompl (N : Submodule R M) (N' : Submodule R M) := by simp only [isCompl_iff, disjoint_iff_coe_toSubmodule, codisjoint_iff_coe_toSubmodule] theorem independent_iff_coe_toSubmodule {ι : Type*} {N : ι → LieSubmodule R L M} : CompleteLattice.Independent N ↔ CompleteLattice.Independent fun i ↦ (N i : Submodule R M) := by simp [CompleteLattice.independent_def, disjoint_iff_coe_toSubmodule] theorem iSup_eq_top_iff_coe_toSubmodule {ι : Sort*} {N : ι → LieSubmodule R L M} : ⨆ i, N i = ⊤ ↔ ⨆ i, (N i : Submodule R M) = ⊤ := by rw [← iSup_coe_toSubmodule, ← top_coeSubmodule (L := L), coe_toSubmodule_eq_iff] instance : Add (LieSubmodule R L M) where add := Sup.sup instance : Zero (LieSubmodule R L M) where zero := ⊥ instance : AddCommMonoid (LieSubmodule R L M) where add_assoc := sup_assoc zero_add := bot_sup_eq add_zero := sup_bot_eq add_comm := sup_comm nsmul := nsmulRec @[simp] theorem add_eq_sup : N + N' = N ⊔ N' := rfl @[simp] theorem mem_inf (x : M) : x ∈ N ⊓ N' ↔ x ∈ N ∧ x ∈ N' := by rw [← mem_coeSubmodule, ← mem_coeSubmodule, ← mem_coeSubmodule, inf_coe_toSubmodule, Submodule.mem_inf] theorem mem_sup (x : M) : x ∈ N ⊔ N' ↔ ∃ y ∈ N, ∃ z ∈ N', y + z = x := by rw [← mem_coeSubmodule, sup_coe_toSubmodule, Submodule.mem_sup]; exact Iff.rfl nonrec theorem eq_bot_iff : N = ⊥ ↔ ∀ m : M, m ∈ N → m = 0 := by rw [eq_bot_iff]; exact Iff.rfl instance subsingleton_of_bot : Subsingleton (LieSubmodule R L ↑(⊥ : LieSubmodule R L M)) := by apply subsingleton_of_bot_eq_top ext ⟨x, hx⟩; change x ∈ ⊥ at hx; rw [Submodule.mem_bot] at hx; subst hx simp only [true_iff_iff, eq_self_iff_true, Submodule.mk_eq_zero, LieSubmodule.mem_bot, mem_top] instance : IsModularLattice (LieSubmodule R L M) where sup_inf_le_assoc_of_le _ _ := by simp only [← coeSubmodule_le_coeSubmodule, sup_coe_toSubmodule, inf_coe_toSubmodule] exact IsModularLattice.sup_inf_le_assoc_of_le _ variable (R L M) /-- The natural functor that forgets the action of `L` as an order embedding. -/ @[simps] def toSubmodule_orderEmbedding : LieSubmodule R L M ↪o Submodule R M := { toFun := (↑) inj' := coeSubmodule_injective map_rel_iff' := Iff.rfl } theorem wellFounded_of_noetherian [IsNoetherian R M] : WellFounded ((· > ·) : LieSubmodule R L M → LieSubmodule R L M → Prop) := RelHomClass.wellFounded (toSubmodule_orderEmbedding R L M).dual.ltEmbedding <| isNoetherian_iff_wellFounded.mp inferInstance theorem wellFounded_of_isArtinian [IsArtinian R M] : WellFounded ((· < ·) : LieSubmodule R L M → LieSubmodule R L M → Prop) := RelHomClass.wellFounded (toSubmodule_orderEmbedding R L M).ltEmbedding <| IsArtinian.wellFounded_submodule_lt R M instance [IsArtinian R M] : IsAtomic (LieSubmodule R L M) := isAtomic_of_orderBot_wellFounded_lt <| wellFounded_of_isArtinian R L M @[simp] theorem subsingleton_iff : Subsingleton (LieSubmodule R L M) ↔ Subsingleton M := have h : Subsingleton (LieSubmodule R L M) ↔ Subsingleton (Submodule R M) := by rw [← subsingleton_iff_bot_eq_top, ← subsingleton_iff_bot_eq_top, ← coe_toSubmodule_eq_iff, top_coeSubmodule, bot_coeSubmodule] h.trans <| Submodule.subsingleton_iff R @[simp] theorem nontrivial_iff : Nontrivial (LieSubmodule R L M) ↔ Nontrivial M := not_iff_not.mp ((not_nontrivial_iff_subsingleton.trans <| subsingleton_iff R L M).trans not_nontrivial_iff_subsingleton.symm) instance [Nontrivial M] : Nontrivial (LieSubmodule R L M) := (nontrivial_iff R L M).mpr ‹_› theorem nontrivial_iff_ne_bot {N : LieSubmodule R L M} : Nontrivial N ↔ N ≠ ⊥ := by constructor <;> contrapose! · rintro rfl ⟨⟨m₁, h₁ : m₁ ∈ (⊥ : LieSubmodule R L M)⟩, ⟨m₂, h₂ : m₂ ∈ (⊥ : LieSubmodule R L M)⟩, h₁₂⟩ simp [(LieSubmodule.mem_bot _).mp h₁, (LieSubmodule.mem_bot _).mp h₂] at h₁₂ · rw [not_nontrivial_iff_subsingleton, LieSubmodule.eq_bot_iff] rintro ⟨h⟩ m hm simpa using h ⟨m, hm⟩ ⟨_, N.zero_mem⟩ variable {R L M} section InclusionMaps /-- The inclusion of a Lie submodule into its ambient space is a morphism of Lie modules. -/ def incl : N →ₗ⁅R,L⁆ M := { Submodule.subtype (N : Submodule R M) with map_lie' := fun {_ _} ↦ rfl } @[simp] theorem incl_coe : (N.incl : N →ₗ[R] M) = (N : Submodule R M).subtype := rfl @[simp] theorem incl_apply (m : N) : N.incl m = m := rfl theorem incl_eq_val : (N.incl : N → M) = Subtype.val := rfl theorem injective_incl : Function.Injective N.incl := Subtype.coe_injective variable {N N'} variable (h : N ≤ N') /-- Given two nested Lie submodules `N ⊆ N'`, the inclusion `N ↪ N'` is a morphism of Lie modules. -/ def inclusion : N →ₗ⁅R,L⁆ N' where __ := Submodule.inclusion (show N.toSubmodule ≤ N'.toSubmodule from h) map_lie' := rfl @[simp] theorem coe_inclusion (m : N) : (inclusion h m : M) = m := rfl theorem inclusion_apply (m : N) : inclusion h m = ⟨m.1, h m.2⟩ := rfl theorem inclusion_injective : Function.Injective (inclusion h) := fun x y ↦ by simp only [inclusion_apply, imp_self, Subtype.mk_eq_mk, SetLike.coe_eq_coe] end InclusionMaps section LieSpan variable (R L) (s : Set M) /-- The `lieSpan` of a set `s ⊆ M` is the smallest Lie submodule of `M` that contains `s`. -/ def lieSpan : LieSubmodule R L M := sInf { N | s ⊆ N } variable {R L s} theorem mem_lieSpan {x : M} : x ∈ lieSpan R L s ↔ ∀ N : LieSubmodule R L M, s ⊆ N → x ∈ N := by change x ∈ (lieSpan R L s : Set M) ↔ _; erw [sInf_coe]; exact mem_iInter₂ theorem subset_lieSpan : s ⊆ lieSpan R L s := by intro m hm erw [mem_lieSpan] intro N hN exact hN hm theorem submodule_span_le_lieSpan : Submodule.span R s ≤ lieSpan R L s := by rw [Submodule.span_le] apply subset_lieSpan @[simp] theorem lieSpan_le {N} : lieSpan R L s ≤ N ↔ s ⊆ N := by constructor · exact Subset.trans subset_lieSpan · intro hs m hm; rw [mem_lieSpan] at hm; exact hm _ hs theorem lieSpan_mono {t : Set M} (h : s ⊆ t) : lieSpan R L s ≤ lieSpan R L t := by rw [lieSpan_le] exact Subset.trans h subset_lieSpan theorem lieSpan_eq : lieSpan R L (N : Set M) = N := le_antisymm (lieSpan_le.mpr rfl.subset) subset_lieSpan theorem coe_lieSpan_submodule_eq_iff {p : Submodule R M} : (lieSpan R L (p : Set M) : Submodule R M) = p ↔ ∃ N : LieSubmodule R L M, ↑N = p := by rw [p.exists_lieSubmodule_coe_eq_iff L]; constructor <;> intro h · intro x m hm; rw [← h, mem_coeSubmodule]; exact lie_mem _ (subset_lieSpan hm) · rw [← coe_toSubmodule_mk p @h, coe_toSubmodule, coe_toSubmodule_eq_iff, lieSpan_eq] variable (R L M) /-- `lieSpan` forms a Galois insertion with the coercion from `LieSubmodule` to `Set`. -/ protected def gi : GaloisInsertion (lieSpan R L : Set M → LieSubmodule R L M) (↑) where choice s _ := lieSpan R L s gc _ _ := lieSpan_le le_l_u _ := subset_lieSpan choice_eq _ _ := rfl @[simp] theorem span_empty : lieSpan R L (∅ : Set M) = ⊥ := (LieSubmodule.gi R L M).gc.l_bot @[simp] theorem span_univ : lieSpan R L (Set.univ : Set M) = ⊤ := eq_top_iff.2 <| SetLike.le_def.2 <| subset_lieSpan theorem lieSpan_eq_bot_iff : lieSpan R L s = ⊥ ↔ ∀ m ∈ s, m = (0 : M) := by rw [_root_.eq_bot_iff, lieSpan_le, bot_coe, subset_singleton_iff] variable {M} theorem span_union (s t : Set M) : lieSpan R L (s ∪ t) = lieSpan R L s ⊔ lieSpan R L t := (LieSubmodule.gi R L M).gc.l_sup theorem span_iUnion {ι} (s : ι → Set M) : lieSpan R L (⋃ i, s i) = ⨆ i, lieSpan R L (s i) := (LieSubmodule.gi R L M).gc.l_iSup lemma isCompactElement_lieSpan_singleton (m : M) : CompleteLattice.IsCompactElement (lieSpan R L {m}) := by rw [CompleteLattice.isCompactElement_iff_le_of_directed_sSup_le] intro s hne hdir hsup replace hsup : m ∈ (↑(sSup s) : Set M) := (SetLike.le_def.mp hsup) (subset_lieSpan rfl) suffices (↑(sSup s) : Set M) = ⋃ N ∈ s, ↑N by obtain ⟨N : LieSubmodule R L M, hN : N ∈ s, hN' : m ∈ N⟩ := by simp_rw [this, Set.mem_iUnion, SetLike.mem_coe, exists_prop] at hsup; assumption exact ⟨N, hN, by simpa⟩ replace hne : Nonempty s := Set.nonempty_coe_sort.mpr hne have := Submodule.coe_iSup_of_directed _ hdir.directed_val simp_rw [← iSup_coe_toSubmodule, Set.iUnion_coe_set, coe_toSubmodule] at this rw [← this, SetLike.coe_set_eq, sSup_eq_iSup, iSup_subtype] @[simp] lemma sSup_image_lieSpan_singleton : sSup ((fun x ↦ lieSpan R L {x}) '' N) = N := by refine le_antisymm (sSup_le <| by simp) ?_ simp_rw [← coeSubmodule_le_coeSubmodule, sSup_coe_toSubmodule, Set.mem_image, SetLike.mem_coe] refine fun m hm ↦ Submodule.mem_sSup.mpr fun N' hN' ↦ ?_ replace hN' : ∀ m ∈ N, lieSpan R L {m} ≤ N' := by simpa using hN' exact hN' _ hm (subset_lieSpan rfl) instance instIsCompactlyGenerated : IsCompactlyGenerated (LieSubmodule R L M) := ⟨fun N ↦ ⟨(fun x ↦ lieSpan R L {x}) '' N, fun _ ⟨m, _, hm⟩ ↦ hm ▸ isCompactElement_lieSpan_singleton R L m, N.sSup_image_lieSpan_singleton⟩⟩ end LieSpan end LatticeStructure end LieSubmodule section LieSubmoduleMapAndComap variable {R : Type u} {L : Type v} {L' : Type w₂} {M : Type w} {M' : Type w₁} variable [CommRing R] [LieRing L] [LieRing L'] [LieAlgebra R L'] variable [AddCommGroup M] [Module R M] [LieRingModule L M] variable [AddCommGroup M'] [Module R M'] [LieRingModule L M'] namespace LieSubmodule variable (f : M →ₗ⁅R,L⁆ M') (N N₂ : LieSubmodule R L M) (N' : LieSubmodule R L M') /-- A morphism of Lie modules `f : M → M'` pushes forward Lie submodules of `M` to Lie submodules of `M'`. -/ def map : LieSubmodule R L M' := { (N : Submodule R M).map (f : M →ₗ[R] M') with lie_mem := fun {x m'} h ↦ by rcases h with ⟨m, hm, hfm⟩; use ⁅x, m⁆; constructor · apply N.lie_mem hm · norm_cast at hfm; simp [hfm] } @[simp] theorem coe_map : (N.map f : Set M') = f '' N := rfl @[simp] theorem coeSubmodule_map : (N.map f : Submodule R M') = (N : Submodule R M).map (f : M →ₗ[R] M') := rfl /-- A morphism of Lie modules `f : M → M'` pulls back Lie submodules of `M'` to Lie submodules of `M`. -/ def comap : LieSubmodule R L M := { (N' : Submodule R M').comap (f : M →ₗ[R] M') with lie_mem := fun {x m} h ↦ by suffices ⁅x, f m⁆ ∈ N' by simp [this] apply N'.lie_mem h } @[simp] theorem coeSubmodule_comap : (N'.comap f : Submodule R M) = (N' : Submodule R M').comap (f : M →ₗ[R] M') := rfl variable {f N N₂ N'} theorem map_le_iff_le_comap : map f N ≤ N' ↔ N ≤ comap f N' := Set.image_subset_iff variable (f) theorem gc_map_comap : GaloisConnection (map f) (comap f) := fun _ _ ↦ map_le_iff_le_comap variable {f} theorem map_inf_le : (N ⊓ N₂).map f ≤ N.map f ⊓ N₂.map f := Set.image_inter_subset f N N₂ theorem map_inf (hf : Function.Injective f) : (N ⊓ N₂).map f = N.map f ⊓ N₂.map f := SetLike.coe_injective <| Set.image_inter hf @[simp] theorem map_sup : (N ⊔ N₂).map f = N.map f ⊔ N₂.map f := (gc_map_comap f).l_sup @[simp] theorem comap_inf {N₂' : LieSubmodule R L M'} : (N' ⊓ N₂').comap f = N'.comap f ⊓ N₂'.comap f := rfl @[simp] theorem map_iSup {ι : Sort*} (N : ι → LieSubmodule R L M) : (⨆ i, N i).map f = ⨆ i, (N i).map f := (gc_map_comap f : GaloisConnection (map f) (comap f)).l_iSup @[simp] theorem mem_map (m' : M') : m' ∈ N.map f ↔ ∃ m, m ∈ N ∧ f m = m' := Submodule.mem_map theorem mem_map_of_mem {m : M} (h : m ∈ N) : f m ∈ N.map f := Set.mem_image_of_mem _ h @[simp] theorem mem_comap {m : M} : m ∈ comap f N' ↔ f m ∈ N' := Iff.rfl theorem comap_incl_eq_top : N₂.comap N.incl = ⊤ ↔ N ≤ N₂ := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.coeSubmodule_comap, LieSubmodule.incl_coe, LieSubmodule.top_coeSubmodule, Submodule.comap_subtype_eq_top, coeSubmodule_le_coeSubmodule] theorem comap_incl_eq_bot : N₂.comap N.incl = ⊥ ↔ N ⊓ N₂ = ⊥ := by simp only [← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.coeSubmodule_comap, LieSubmodule.incl_coe, LieSubmodule.bot_coeSubmodule, ← Submodule.disjoint_iff_comap_eq_bot, disjoint_iff, inf_coe_toSubmodule] @[mono] theorem map_mono (h : N ≤ N₂) : N.map f ≤ N₂.map f := Set.image_subset _ h theorem map_comp {M'' : Type*} [AddCommGroup M''] [Module R M''] [LieRingModule L M''] {g : M' →ₗ⁅R,L⁆ M''} : N.map (g.comp f) = (N.map f).map g := SetLike.coe_injective <| by simp only [← Set.image_comp, coe_map, LinearMap.coe_comp, LieModuleHom.coe_comp] @[simp] theorem map_id : N.map LieModuleHom.id = N := by ext; simp @[simp] theorem map_bot : (⊥ : LieSubmodule R L M).map f = ⊥ := by ext m; simp [eq_comm] lemma map_le_map_iff (hf : Function.Injective f) : N.map f ≤ N₂.map f ↔ N ≤ N₂ := Set.image_subset_image_iff hf lemma map_injective_of_injective (hf : Function.Injective f) : Function.Injective (map f) := fun {N N'} h ↦ SetLike.coe_injective <| hf.image_injective <| by simp only [← coe_map, h] /-- An injective morphism of Lie modules embeds the lattice of submodules of the domain into that of the target. -/ @[simps] def mapOrderEmbedding {f : M →ₗ⁅R,L⁆ M'} (hf : Function.Injective f) : LieSubmodule R L M ↪o LieSubmodule R L M' where toFun := LieSubmodule.map f inj' := map_injective_of_injective hf map_rel_iff' := Set.image_subset_image_iff hf variable (N) in /-- For an injective morphism of Lie modules, any Lie submodule is equivalent to its image. -/ noncomputable def equivMapOfInjective (hf : Function.Injective f) : N ≃ₗ⁅R,L⁆ N.map f := { Submodule.equivMapOfInjective (f : M →ₗ[R] M') hf N with -- Note: #8386 had to specify `invFun` explicitly this way, otherwise we'd get a type mismatch invFun := by exact DFunLike.coe (Submodule.equivMapOfInjective (f : M →ₗ[R] M') hf N).symm map_lie' := by rintro x ⟨m, hm : m ∈ N⟩; ext; exact f.map_lie x m } /-- An equivalence of Lie modules yields an order-preserving equivalence of their lattices of Lie Submodules. -/ @[simps] def orderIsoMapComap (e : M ≃ₗ⁅R,L⁆ M') : LieSubmodule R L M ≃o LieSubmodule R L M' where toFun := map e invFun := comap e left_inv := fun N ↦ by ext; simp right_inv := fun N ↦ by ext; simp [e.apply_eq_iff_eq_symm_apply] map_rel_iff' := fun {N N'} ↦ Set.image_subset_image_iff e.injective end LieSubmodule namespace LieIdeal variable [LieAlgebra R L] [LieModule R L M] [LieModule R L M'] variable (f : L →ₗ⁅R⁆ L') (I I₂ : LieIdeal R L) (J : LieIdeal R L') @[simp] theorem top_coe_lieSubalgebra : ((⊤ : LieIdeal R L) : LieSubalgebra R L) = ⊤ := rfl /-- A morphism of Lie algebras `f : L → L'` pushes forward Lie ideals of `L` to Lie ideals of `L'`. Note that unlike `LieSubmodule.map`, we must take the `lieSpan` of the image. Mathematically this is because although `f` makes `L'` into a Lie module over `L`, in general the `L` submodules of `L'` are not the same as the ideals of `L'`. -/ def map : LieIdeal R L' := LieSubmodule.lieSpan R L' <| (I : Submodule R L).map (f : L →ₗ[R] L') /-- A morphism of Lie algebras `f : L → L'` pulls back Lie ideals of `L'` to Lie ideals of `L`. Note that `f` makes `L'` into a Lie module over `L` (turning `f` into a morphism of Lie modules) and so this is a special case of `LieSubmodule.comap` but we do not exploit this fact. -/ def comap : LieIdeal R L := { (J : Submodule R L').comap (f : L →ₗ[R] L') with lie_mem := fun {x y} h ↦ by suffices ⁅f x, f y⁆ ∈ J by simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, Submodule.mem_comap, LieHom.coe_toLinearMap, LieHom.map_lie, LieSubalgebra.mem_coe_submodule] exact this apply J.lie_mem h } @[simp] theorem map_coeSubmodule (h : ↑(map f I) = f '' I) : LieSubmodule.toSubmodule (map f I) = (LieSubmodule.toSubmodule I).map (f : L →ₗ[R] L') := by rw [SetLike.ext'_iff, LieSubmodule.coe_toSubmodule, h, Submodule.map_coe]; rfl @[simp] theorem comap_coeSubmodule : (LieSubmodule.toSubmodule (comap f J)) = (LieSubmodule.toSubmodule J).comap (f : L →ₗ[R] L') := rfl theorem map_le : map f I ≤ J ↔ f '' I ⊆ J := LieSubmodule.lieSpan_le variable {f I I₂ J} theorem mem_map {x : L} (hx : x ∈ I) : f x ∈ map f I := by apply LieSubmodule.subset_lieSpan use x exact ⟨hx, rfl⟩ @[simp] theorem mem_comap {x : L} : x ∈ comap f J ↔ f x ∈ J := Iff.rfl theorem map_le_iff_le_comap : map f I ≤ J ↔ I ≤ comap f J := by rw [map_le] exact Set.image_subset_iff variable (f) theorem gc_map_comap : GaloisConnection (map f) (comap f) := fun _ _ ↦ map_le_iff_le_comap variable {f} @[simp] theorem map_sup : (I ⊔ I₂).map f = I.map f ⊔ I₂.map f := (gc_map_comap f).l_sup theorem map_comap_le : map f (comap f J) ≤ J := by rw [map_le_iff_le_comap] /-- See also `LieIdeal.map_comap_eq`. -/ theorem comap_map_le : I ≤ comap f (map f I) := by rw [← map_le_iff_le_comap] @[mono] theorem map_mono : Monotone (map f) := fun I₁ I₂ h ↦ by rw [SetLike.le_def] at h apply LieSubmodule.lieSpan_mono (Set.image_subset (⇑f) h) @[mono] theorem comap_mono : Monotone (comap f) := fun J₁ J₂ h ↦ by rw [← SetLike.coe_subset_coe] at h ⊢ dsimp only [SetLike.coe] exact Set.preimage_mono h theorem map_of_image (h : f '' I = J) : I.map f = J := by apply le_antisymm · erw [LieSubmodule.lieSpan_le, Submodule.map_coe, h] · rw [← SetLike.coe_subset_coe, ← h]; exact LieSubmodule.subset_lieSpan /-- Note that this is not a special case of `LieSubmodule.subsingleton_of_bot`. Indeed, given `I : LieIdeal R L`, in general the two lattices `LieIdeal R I` and `LieSubmodule R L I` are different (though the latter does naturally inject into the former). In other words, in general, ideals of `I`, regarded as a Lie algebra in its own right, are not the same as ideals of `L` contained in `I`. -/ instance subsingleton_of_bot : Subsingleton (LieIdeal R (⊥ : LieIdeal R L)) := by apply subsingleton_of_bot_eq_top ext ⟨x, hx⟩ rw [LieSubmodule.bot_coeSubmodule, Submodule.mem_bot] at hx subst hx simp only [Submodule.mk_eq_zero, LieSubmodule.mem_bot, LieSubmodule.mem_top] end LieIdeal namespace LieHom variable [LieAlgebra R L] [LieModule R L M] [LieModule R L M'] variable (f : L →ₗ⁅R⁆ L') (I : LieIdeal R L) (J : LieIdeal R L') /-- The kernel of a morphism of Lie algebras, as an ideal in the domain. -/ def ker : LieIdeal R L := LieIdeal.comap f ⊥ /-- The range of a morphism of Lie algebras as an ideal in the codomain. -/ def idealRange : LieIdeal R L' := LieSubmodule.lieSpan R L' f.range theorem idealRange_eq_lieSpan_range : f.idealRange = LieSubmodule.lieSpan R L' f.range := rfl theorem idealRange_eq_map : f.idealRange = LieIdeal.map f ⊤ := by ext simp only [idealRange, range_eq_map] rfl /-- The condition that the range of a morphism of Lie algebras is an ideal. -/ def IsIdealMorphism : Prop := (f.idealRange : LieSubalgebra R L') = f.range @[simp] theorem isIdealMorphism_def : f.IsIdealMorphism ↔ (f.idealRange : LieSubalgebra R L') = f.range := Iff.rfl variable {f} in theorem IsIdealMorphism.eq (hf : f.IsIdealMorphism) : f.idealRange = f.range := hf theorem isIdealMorphism_iff : f.IsIdealMorphism ↔ ∀ (x : L') (y : L), ∃ z : L, ⁅x, f y⁆ = f z := by simp only [isIdealMorphism_def, idealRange_eq_lieSpan_range, ← LieSubalgebra.coe_to_submodule_eq_iff, ← f.range.coe_to_submodule, LieIdeal.coe_to_lieSubalgebra_to_submodule, LieSubmodule.coe_lieSpan_submodule_eq_iff, LieSubalgebra.mem_coe_submodule, mem_range, exists_imp, Submodule.exists_lieSubmodule_coe_eq_iff] constructor · intro h x y; obtain ⟨z, hz⟩ := h x (f y) y rfl; use z; exact hz.symm · intro h x y z hz; obtain ⟨w, hw⟩ := h x z; use w; rw [← hw, hz] theorem range_subset_idealRange : (f.range : Set L') ⊆ f.idealRange := LieSubmodule.subset_lieSpan theorem map_le_idealRange : I.map f ≤ f.idealRange := by rw [f.idealRange_eq_map] exact LieIdeal.map_mono le_top theorem ker_le_comap : f.ker ≤ J.comap f := LieIdeal.comap_mono bot_le @[simp] theorem ker_coeSubmodule : LieSubmodule.toSubmodule (ker f) = LinearMap.ker (f : L →ₗ[R] L') := rfl @[simp] theorem mem_ker {x : L} : x ∈ ker f ↔ f x = 0 := show x ∈ LieSubmodule.toSubmodule (f.ker) ↔ _ by simp only [ker_coeSubmodule, LinearMap.mem_ker, coe_toLinearMap] theorem mem_idealRange (x : L) : f x ∈ idealRange f := by rw [idealRange_eq_map] exact LieIdeal.mem_map (LieSubmodule.mem_top x) @[simp] theorem mem_idealRange_iff (h : IsIdealMorphism f) {y : L'} : y ∈ idealRange f ↔ ∃ x : L, f x = y := by rw [f.isIdealMorphism_def] at h rw [← LieSubmodule.mem_coe, ← LieIdeal.coe_toSubalgebra, h, f.range_coe, Set.mem_range] theorem le_ker_iff : I ≤ f.ker ↔ ∀ x, x ∈ I → f x = 0 := by constructor <;> intro h x hx · specialize h hx; rw [mem_ker] at h; exact h · rw [mem_ker]; apply h x hx theorem ker_eq_bot : f.ker = ⊥ ↔ Function.Injective f := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, ker_coeSubmodule, LieSubmodule.bot_coeSubmodule, LinearMap.ker_eq_bot, coe_toLinearMap] @[simp] theorem range_coeSubmodule : (f.range : Submodule R L') = LinearMap.range (f : L →ₗ[R] L') := rfl theorem range_eq_top : f.range = ⊤ ↔ Function.Surjective f := by rw [← LieSubalgebra.coe_to_submodule_eq_iff, range_coeSubmodule, LieSubalgebra.top_coe_submodule] exact LinearMap.range_eq_top @[simp] theorem idealRange_eq_top_of_surjective (h : Function.Surjective f) : f.idealRange = ⊤ := by rw [← f.range_eq_top] at h rw [idealRange_eq_lieSpan_range, h, ← LieSubalgebra.coe_to_submodule, ← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.top_coeSubmodule, LieSubalgebra.top_coe_submodule, LieSubmodule.coe_lieSpan_submodule_eq_iff] use ⊤ exact LieSubmodule.top_coeSubmodule theorem isIdealMorphism_of_surjective (h : Function.Surjective f) : f.IsIdealMorphism := by rw [isIdealMorphism_def, f.idealRange_eq_top_of_surjective h, f.range_eq_top.mpr h, LieIdeal.top_coe_lieSubalgebra] end LieHom namespace LieIdeal variable [LieAlgebra R L] [LieModule R L M] [LieModule R L M'] variable {f : L →ₗ⁅R⁆ L'} {I : LieIdeal R L} {J : LieIdeal R L'} @[simp] theorem map_eq_bot_iff : I.map f = ⊥ ↔ I ≤ f.ker := by rw [← le_bot_iff] exact LieIdeal.map_le_iff_le_comap theorem coe_map_of_surjective (h : Function.Surjective f) : LieSubmodule.toSubmodule (I.map f) = (LieSubmodule.toSubmodule I).map (f : L →ₗ[R] L') := by let J : LieIdeal R L' := { (I : Submodule R L).map (f : L →ₗ[R] L') with lie_mem := fun {x y} hy ↦ by have hy' : ∃ x : L, x ∈ I ∧ f x = y := by simpa [hy] obtain ⟨z₂, hz₂, rfl⟩ := hy' obtain ⟨z₁, rfl⟩ := h x simp only [LieHom.coe_toLinearMap, SetLike.mem_coe, Set.mem_image, LieSubmodule.mem_coeSubmodule, Submodule.mem_carrier, Submodule.map_coe] use ⁅z₁, z₂⁆ exact ⟨I.lie_mem hz₂, f.map_lie z₁ z₂⟩ } erw [LieSubmodule.coe_lieSpan_submodule_eq_iff] use J theorem mem_map_of_surjective {y : L'} (h₁ : Function.Surjective f) (h₂ : y ∈ I.map f) : ∃ x : I, f x = y := by rw [← LieSubmodule.mem_coeSubmodule, coe_map_of_surjective h₁, Submodule.mem_map] at h₂ obtain ⟨x, hx, rfl⟩ := h₂ use ⟨x, hx⟩ rw [LieHom.coe_toLinearMap] theorem bot_of_map_eq_bot {I : LieIdeal R L} (h₁ : Function.Injective f) (h₂ : I.map f = ⊥) : I = ⊥ := by rw [← f.ker_eq_bot, LieHom.ker] at h₁ rw [eq_bot_iff, map_le_iff_le_comap, h₁] at h₂ rw [eq_bot_iff]; exact h₂ /-- Given two nested Lie ideals `I₁ ⊆ I₂`, the inclusion `I₁ ↪ I₂` is a morphism of Lie algebras. -/ def inclusion {I₁ I₂ : LieIdeal R L} (h : I₁ ≤ I₂) : I₁ →ₗ⁅R⁆ I₂ where __ := Submodule.inclusion (show I₁.toSubmodule ≤ I₂.toSubmodule from h) map_lie' := rfl @[simp] theorem coe_inclusion {I₁ I₂ : LieIdeal R L} (h : I₁ ≤ I₂) (x : I₁) : (inclusion h x : L) = x := rfl theorem inclusion_apply {I₁ I₂ : LieIdeal R L} (h : I₁ ≤ I₂) (x : I₁) : inclusion h x = ⟨x.1, h x.2⟩ := rfl theorem inclusion_injective {I₁ I₂ : LieIdeal R L} (h : I₁ ≤ I₂) : Function.Injective (inclusion h) := fun x y ↦ by simp only [inclusion_apply, imp_self, Subtype.mk_eq_mk, SetLike.coe_eq_coe] -- Porting note: LHS simplifies, so moved @[simp] to new theorem `map_sup_ker_eq_map'` theorem map_sup_ker_eq_map : LieIdeal.map f (I ⊔ f.ker) = LieIdeal.map f I := by suffices LieIdeal.map f (I ⊔ f.ker) ≤ LieIdeal.map f I by exact le_antisymm this (LieIdeal.map_mono le_sup_left) apply LieSubmodule.lieSpan_mono rintro x ⟨y, hy₁, hy₂⟩; rw [← hy₂] erw [LieSubmodule.mem_sup] at hy₁;obtain ⟨z₁, hz₁, z₂, hz₂, hy⟩ := hy₁; rw [← hy] rw [f.coe_toLinearMap, f.map_add, f.mem_ker.mp hz₂, add_zero]; exact ⟨z₁, hz₁, rfl⟩ @[simp] theorem map_sup_ker_eq_map' : LieIdeal.map f I ⊔ LieIdeal.map f (LieHom.ker f) = LieIdeal.map f I := by simpa using map_sup_ker_eq_map (f := f) @[simp] theorem map_comap_eq (h : f.IsIdealMorphism) : map f (comap f J) = f.idealRange ⊓ J := by apply le_antisymm · rw [le_inf_iff]; exact ⟨f.map_le_idealRange _, map_comap_le⟩ · rw [f.isIdealMorphism_def] at h rw [← SetLike.coe_subset_coe, LieSubmodule.inf_coe, ← coe_toSubalgebra, h] rintro y ⟨⟨x, h₁⟩, h₂⟩; rw [← h₁] at h₂ ⊢; exact mem_map h₂ @[simp] theorem comap_map_eq (h : ↑(map f I) = f '' I) : comap f (map f I) = I ⊔ f.ker := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, comap_coeSubmodule, I.map_coeSubmodule f h, LieSubmodule.sup_coe_toSubmodule, f.ker_coeSubmodule, Submodule.comap_map_eq] variable (f I J) /-- Regarding an ideal `I` as a subalgebra, the inclusion map into its ambient space is a morphism of Lie algebras. -/ def incl : I →ₗ⁅R⁆ L := (I : LieSubalgebra R L).incl @[simp] theorem incl_range : I.incl.range = I := (I : LieSubalgebra R L).incl_range @[simp] theorem incl_apply (x : I) : I.incl x = x := rfl @[simp] theorem incl_coe : (I.incl.toLinearMap : I →ₗ[R] L) = (I : Submodule R L).subtype := rfl lemma incl_injective (I : LieIdeal R L) : Function.Injective I.incl := Subtype.val_injective @[simp] theorem comap_incl_self : comap I.incl I = ⊤ := by ext; simp -- porting note: `ext; simp` works also in mathlib3, though the proof used to be -- rw [← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.top_coeSubmodule, -- LieIdeal.comap_coeSubmodule, LieIdeal.incl_coe, Submodule.comap_subtype_self] @[simp] theorem ker_incl : I.incl.ker = ⊥ := by ext; simp -- porting note: `ext; simp` works also in mathlib3, though the proof used to be -- rw [← LieSubmodule.coe_toSubmodule_eq_iff, I.incl.ker_coeSubmodule, -- LieSubmodule.bot_coeSubmodule, incl_coe, Submodule.ker_subtype] @[simp] theorem incl_idealRange : I.incl.idealRange = I := by rw [LieHom.idealRange_eq_lieSpan_range, ← LieSubalgebra.coe_to_submodule, ← LieSubmodule.coe_toSubmodule_eq_iff, incl_range, coe_to_lieSubalgebra_to_submodule, LieSubmodule.coe_lieSpan_submodule_eq_iff] use I theorem incl_isIdealMorphism : I.incl.IsIdealMorphism := by rw [I.incl.isIdealMorphism_def, incl_idealRange] exact (I : LieSubalgebra R L).incl_range.symm end LieIdeal end LieSubmoduleMapAndComap namespace LieModuleHom variable {R : Type u} {L : Type v} {M : Type w} {N : Type w₁} variable [CommRing R] [LieRing L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] variable [AddCommGroup N] [Module R N] [LieRingModule L N] variable (f : M →ₗ⁅R,L⁆ N) /-- The kernel of a morphism of Lie algebras, as an ideal in the domain. -/ def ker : LieSubmodule R L M := LieSubmodule.comap f ⊥ @[simp] theorem ker_coeSubmodule : (f.ker : Submodule R M) = LinearMap.ker (f : M →ₗ[R] N) := rfl theorem ker_eq_bot : f.ker = ⊥ ↔ Function.Injective f := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, ker_coeSubmodule, LieSubmodule.bot_coeSubmodule, LinearMap.ker_eq_bot, coe_toLinearMap] variable {f} @[simp] theorem mem_ker (m : M) : m ∈ f.ker ↔ f m = 0 := Iff.rfl @[simp] theorem ker_id : (LieModuleHom.id : M →ₗ⁅R,L⁆ M).ker = ⊥ := rfl @[simp] theorem comp_ker_incl : f.comp f.ker.incl = 0 := by ext ⟨m, hm⟩; exact (mem_ker m).mp hm theorem le_ker_iff_map (M' : LieSubmodule R L M) : M' ≤ f.ker ↔ LieSubmodule.map f M' = ⊥ := by rw [ker, eq_bot_iff, LieSubmodule.map_le_iff_le_comap] variable (f) /-- The range of a morphism of Lie modules `f : M → N` is a Lie submodule of `N`. See Note [range copy pattern]. -/ def range : LieSubmodule R L N := (LieSubmodule.map f ⊤).copy (Set.range f) Set.image_univ.symm @[simp] theorem coe_range : (f.range : Set N) = Set.range f := rfl @[simp] theorem coeSubmodule_range : (f.range : Submodule R N) = LinearMap.range (f : M →ₗ[R] N) := rfl @[simp] theorem mem_range (n : N) : n ∈ f.range ↔ ∃ m, f m = n := Iff.rfl @[simp] theorem map_top : LieSubmodule.map f ⊤ = f.range := by ext; simp [LieSubmodule.mem_map] theorem range_eq_top : f.range = ⊤ ↔ Function.Surjective f := by rw [SetLike.ext'_iff, coe_range, LieSubmodule.top_coe, Set.range_iff_surjective] /-- A morphism of Lie modules `f : M → N` whose values lie in a Lie submodule `P ⊆ N` can be restricted to a morphism of Lie modules `M → P`. -/ def codRestrict (P : LieSubmodule R L N) (f : M →ₗ⁅R,L⁆ N) (h : ∀ m, f m ∈ P) : M →ₗ⁅R,L⁆ P where toFun := f.toLinearMap.codRestrict P h __ := f.toLinearMap.codRestrict P h map_lie' {x m} := by ext; simp @[simp] lemma codRestrict_apply (P : LieSubmodule R L N) (f : M →ₗ⁅R,L⁆ N) (h : ∀ m, f m ∈ P) (m : M) : (f.codRestrict P h m : N) = f m := rfl end LieModuleHom namespace LieSubmodule variable {R : Type u} {L : Type v} {M : Type w} variable [CommRing R] [LieRing L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] variable (N : LieSubmodule R L M) @[simp] theorem ker_incl : N.incl.ker = ⊥ := by simp [← LieSubmodule.coe_toSubmodule_eq_iff] @[simp] theorem range_incl : N.incl.range = N := by simp [← LieSubmodule.coe_toSubmodule_eq_iff] @[simp] theorem comap_incl_self : comap N.incl N = ⊤ := by simp [← LieSubmodule.coe_toSubmodule_eq_iff] theorem map_incl_top : (⊤ : LieSubmodule R L N).map N.incl = N := by simp variable {N} @[simp] lemma map_le_range {M' : Type*} [AddCommGroup M'] [Module R M'] [LieRingModule L M'] (f : M →ₗ⁅R,L⁆ M') : N.map f ≤ f.range := by rw [← LieModuleHom.map_top] exact LieSubmodule.map_mono le_top @[simp] lemma map_incl_lt_iff_lt_top {N' : LieSubmodule R L N} : N'.map (LieSubmodule.incl N) < N ↔ N' < ⊤ := by convert (LieSubmodule.mapOrderEmbedding (f := N.incl) Subtype.coe_injective).lt_iff_lt simp @[simp] lemma map_incl_le {N' : LieSubmodule R L N} : N'.map N.incl ≤ N := by conv_rhs => rw [← N.map_incl_top] exact LieSubmodule.map_mono le_top end LieSubmodule section TopEquiv variable (R : Type u) (L : Type v) variable [CommRing R] [LieRing L] variable (M : Type*) [AddCommGroup M] [Module R M] [LieRingModule L M] /-- The natural equivalence between the 'top' Lie submodule and the enclosing Lie module. -/ def LieModuleEquiv.ofTop : (⊤ : LieSubmodule R L M) ≃ₗ⁅R,L⁆ M := { LinearEquiv.ofTop ⊤ rfl with map_lie' := rfl } variable {R L} -- This lemma has always been bad, but leanprover/lean4#2644 made `simp` start noticing @[simp, nolint simpNF] lemma LieModuleEquiv.ofTop_apply (x : (⊤ : LieSubmodule R L M)) : LieModuleEquiv.ofTop R L M x = x := rfl @[simp] lemma LieModuleEquiv.range_coe {M' : Type*} [AddCommGroup M'] [Module R M'] [LieRingModule L M'] (e : M ≃ₗ⁅R,L⁆ M') : LieModuleHom.range (e : M →ₗ⁅R,L⁆ M') = ⊤ := by rw [LieModuleHom.range_eq_top] exact e.surjective variable [LieAlgebra R L] [LieModule R L M] /-- The natural equivalence between the 'top' Lie subalgebra and the enclosing Lie algebra. This is the Lie subalgebra version of `Submodule.topEquiv`. -/ def LieSubalgebra.topEquiv : (⊤ : LieSubalgebra R L) ≃ₗ⁅R⁆ L := { (⊤ : LieSubalgebra R L).incl with invFun := fun x ↦ ⟨x, Set.mem_univ x⟩ left_inv := fun x ↦ by ext; rfl right_inv := fun x ↦ rfl } @[simp] theorem LieSubalgebra.topEquiv_apply (x : (⊤ : LieSubalgebra R L)) : LieSubalgebra.topEquiv x = x := rfl /-- The natural equivalence between the 'top' Lie ideal and the enclosing Lie algebra. This is the Lie ideal version of `Submodule.topEquiv`. -/ def LieIdeal.topEquiv : (⊤ : LieIdeal R L) ≃ₗ⁅R⁆ L := LieSubalgebra.topEquiv -- This lemma has always been bad, but leanprover/lean4#2644 made `simp` start noticing @[simp, nolint simpNF] theorem LieIdeal.topEquiv_apply (x : (⊤ : LieIdeal R L)) : LieIdeal.topEquiv x = x := rfl end TopEquiv
Algebra\Lie\TensorProduct.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Abelian /-! # Tensor products of Lie modules Tensor products of Lie modules carry natural Lie module structures. ## Tags lie module, tensor product, universal property -/ suppress_compilation universe u v w w₁ w₂ w₃ variable {R : Type u} [CommRing R] open LieModule namespace TensorProduct open scoped TensorProduct namespace LieModule variable {L : Type v} {M : Type w} {N : Type w₁} {P : Type w₂} {Q : Type w₃} variable [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable [AddCommGroup N] [Module R N] [LieRingModule L N] [LieModule R L N] variable [AddCommGroup P] [Module R P] [LieRingModule L P] [LieModule R L P] variable [AddCommGroup Q] [Module R Q] [LieRingModule L Q] [LieModule R L Q] attribute [local ext] TensorProduct.ext /-- It is useful to define the bracket via this auxiliary function so that we have a type-theoretic expression of the fact that `L` acts by linear endomorphisms. It simplifies the proofs in `lieRingModule` below. -/ def hasBracketAux (x : L) : Module.End R (M ⊗[R] N) := (toEnd R L M x).rTensor N + (toEnd R L N x).lTensor M /-- The tensor product of two Lie modules is a Lie ring module. -/ instance lieRingModule : LieRingModule L (M ⊗[R] N) where bracket x := hasBracketAux x add_lie x y t := by simp only [hasBracketAux, LinearMap.lTensor_add, LinearMap.rTensor_add, LieHom.map_add, LinearMap.add_apply] abel lie_add x := LinearMap.map_add _ leibniz_lie x y t := by suffices (hasBracketAux x).comp (hasBracketAux y) = hasBracketAux ⁅x, y⁆ + (hasBracketAux y).comp (hasBracketAux x) by simp only [← LinearMap.add_apply]; rw [← LinearMap.comp_apply, this]; rfl ext m n simp only [hasBracketAux, AlgebraTensorModule.curry_apply, curry_apply, sub_tmul, tmul_sub, LinearMap.coe_restrictScalars, Function.comp_apply, LinearMap.coe_comp, LinearMap.rTensor_tmul, LieHom.map_lie, toEnd_apply_apply, LinearMap.add_apply, LinearMap.map_add, LieHom.lie_apply, Module.End.lie_apply, LinearMap.lTensor_tmul] abel /-- The tensor product of two Lie modules is a Lie module. -/ instance lieModule : LieModule R L (M ⊗[R] N) where smul_lie c x t := by change hasBracketAux (c • x) _ = c • hasBracketAux _ _ simp only [hasBracketAux, smul_add, LinearMap.rTensor_smul, LinearMap.smul_apply, LinearMap.lTensor_smul, LieHom.map_smul, LinearMap.add_apply] lie_smul c x := LinearMap.map_smul _ c @[simp] theorem lie_tmul_right (x : L) (m : M) (n : N) : ⁅x, m ⊗ₜ[R] n⁆ = ⁅x, m⁆ ⊗ₜ n + m ⊗ₜ ⁅x, n⁆ := show hasBracketAux x (m ⊗ₜ[R] n) = _ by simp only [hasBracketAux, LinearMap.rTensor_tmul, toEnd_apply_apply, LinearMap.add_apply, LinearMap.lTensor_tmul] variable (R L M N P Q) /-- The universal property for tensor product of modules of a Lie algebra: the `R`-linear tensor-hom adjunction is equivariant with respect to the `L` action. -/ def lift : (M →ₗ[R] N →ₗ[R] P) ≃ₗ⁅R,L⁆ M ⊗[R] N →ₗ[R] P := { TensorProduct.lift.equiv R M N P with map_lie' := fun {x f} => by ext m n simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, LinearEquiv.coe_coe, AlgebraTensorModule.curry_apply, curry_apply, LinearMap.coe_restrictScalars, lift.equiv_apply, LieHom.lie_apply, LinearMap.sub_apply, lie_tmul_right, map_add] abel } @[simp] theorem lift_apply (f : M →ₗ[R] N →ₗ[R] P) (m : M) (n : N) : lift R L M N P f (m ⊗ₜ n) = f m n := rfl /-- A weaker form of the universal property for tensor product of modules of a Lie algebra. Note that maps `f` of type `M →ₗ⁅R,L⁆ N →ₗ[R] P` are exactly those `R`-bilinear maps satisfying `⁅x, f m n⁆ = f ⁅x, m⁆ n + f m ⁅x, n⁆` for all `x, m, n` (see e.g, `LieModuleHom.map_lie₂`). -/ def liftLie : (M →ₗ⁅R,L⁆ N →ₗ[R] P) ≃ₗ[R] M ⊗[R] N →ₗ⁅R,L⁆ P := maxTrivLinearMapEquivLieModuleHom.symm ≪≫ₗ ↑(maxTrivEquiv (lift R L M N P)) ≪≫ₗ maxTrivLinearMapEquivLieModuleHom @[simp] theorem coe_liftLie_eq_lift_coe (f : M →ₗ⁅R,L⁆ N →ₗ[R] P) : ⇑(liftLie R L M N P f) = lift R L M N P f := by suffices (liftLie R L M N P f : M ⊗[R] N →ₗ[R] P) = lift R L M N P f by rw [← this, LieModuleHom.coe_toLinearMap] ext m n simp only [liftLie, LinearEquiv.trans_apply, LieModuleEquiv.coe_to_linearEquiv, coe_linearMap_maxTrivLinearMapEquivLieModuleHom, coe_maxTrivEquiv_apply, coe_linearMap_maxTrivLinearMapEquivLieModuleHom_symm] theorem liftLie_apply (f : M →ₗ⁅R,L⁆ N →ₗ[R] P) (m : M) (n : N) : liftLie R L M N P f (m ⊗ₜ n) = f m n := by simp only [coe_liftLie_eq_lift_coe, LieModuleHom.coe_toLinearMap, lift_apply] variable {R L M N P Q} /-- A pair of Lie module morphisms `f : M → P` and `g : N → Q`, induce a Lie module morphism: `M ⊗ N → P ⊗ Q`. -/ nonrec def map (f : M →ₗ⁅R,L⁆ P) (g : N →ₗ⁅R,L⁆ Q) : M ⊗[R] N →ₗ⁅R,L⁆ P ⊗[R] Q := { map (f : M →ₗ[R] P) (g : N →ₗ[R] Q) with map_lie' := fun {x t} => by simp only [LinearMap.toFun_eq_coe] refine t.induction_on ?_ ?_ ?_ · simp only [LinearMap.map_zero, lie_zero] · intro m n simp only [LieModuleHom.coe_toLinearMap, lie_tmul_right, LieModuleHom.map_lie, map_tmul, LinearMap.map_add] · intro t₁ t₂ ht₁ ht₂; simp only [ht₁, ht₂, lie_add, LinearMap.map_add] } @[simp] theorem coe_linearMap_map (f : M →ₗ⁅R,L⁆ P) (g : N →ₗ⁅R,L⁆ Q) : (map f g : M ⊗[R] N →ₗ[R] P ⊗[R] Q) = TensorProduct.map (f : M →ₗ[R] P) (g : N →ₗ[R] Q) := rfl @[simp] nonrec theorem map_tmul (f : M →ₗ⁅R,L⁆ P) (g : N →ₗ⁅R,L⁆ Q) (m : M) (n : N) : map f g (m ⊗ₜ n) = f m ⊗ₜ g n := map_tmul _ _ _ _ /-- Given Lie submodules `M' ⊆ M` and `N' ⊆ N`, this is the natural map: `M' ⊗ N' → M ⊗ N`. -/ def mapIncl (M' : LieSubmodule R L M) (N' : LieSubmodule R L N) : M' ⊗[R] N' →ₗ⁅R,L⁆ M ⊗[R] N := map M'.incl N'.incl @[simp] theorem mapIncl_def (M' : LieSubmodule R L M) (N' : LieSubmodule R L N) : mapIncl M' N' = map M'.incl N'.incl := rfl end LieModule end TensorProduct namespace LieModule open scoped TensorProduct variable (R) (L : Type v) (M : Type w) variable [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] /-- The action of the Lie algebra on one of its modules, regarded as a morphism of Lie modules. -/ def toModuleHom : L ⊗[R] M →ₗ⁅R,L⁆ M := TensorProduct.LieModule.liftLie R L L M M { (toEnd R L M : L →ₗ[R] M →ₗ[R] M) with map_lie' := fun {x m} => by ext n; simp [LieRing.of_associative_ring_bracket] } @[simp] theorem toModuleHom_apply (x : L) (m : M) : toModuleHom R L M (x ⊗ₜ m) = ⁅x, m⁆ := by simp only [toModuleHom, TensorProduct.LieModule.liftLie_apply, LieModuleHom.coe_mk, LinearMap.coe_mk, LinearMap.coe_toAddHom, LieHom.coe_toLinearMap, toEnd_apply_apply] end LieModule namespace LieSubmodule open scoped TensorProduct open TensorProduct.LieModule open LieModule variable {L : Type v} {M : Type w} variable [LieRing L] [LieAlgebra R L] variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable (I : LieIdeal R L) (N : LieSubmodule R L M) /-- A useful alternative characterisation of Lie ideal operations on Lie submodules. Given a Lie ideal `I ⊆ L` and a Lie submodule `N ⊆ M`, by tensoring the inclusion maps and then applying the action of `L` on `M`, we obtain morphism of Lie modules `f : I ⊗ N → L ⊗ M → M`. This lemma states that `⁅I, N⁆ = range f`. -/ theorem lieIdeal_oper_eq_tensor_map_range : ⁅I, N⁆ = ((toModuleHom R L M).comp (mapIncl I N : (↥I) ⊗[R] (↥N) →ₗ⁅R,L⁆ L ⊗[R] M)).range := by rw [← coe_toSubmodule_eq_iff, lieIdeal_oper_eq_linear_span, LieModuleHom.coeSubmodule_range, LieModuleHom.coe_linearMap_comp, LinearMap.range_comp, mapIncl_def, coe_linearMap_map, TensorProduct.map_range_eq_span_tmul, Submodule.map_span] congr; ext m; constructor · rintro ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩; use x ⊗ₜ n; constructor · use ⟨x, hx⟩, ⟨n, hn⟩; simp · simp · rintro ⟨t, ⟨⟨x, hx⟩, ⟨n, hn⟩, rfl⟩, h⟩; rw [← h]; use ⟨x, hx⟩, ⟨n, hn⟩; simp end LieSubmodule
Algebra\Lie\TraceForm.lean
/- Copyright (c) 2023 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.DirectSum.LinearMap import Mathlib.Algebra.Lie.InvariantForm import Mathlib.Algebra.Lie.Weights.Cartan import Mathlib.Algebra.Lie.Weights.Linear import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure import Mathlib.LinearAlgebra.PID /-! # The trace and Killing forms of a Lie algebra. Let `L` be a Lie algebra with coefficients in a commutative ring `R`. Suppose `M` is a finite, free `R`-module and we have a representation `φ : L → End M`. This data induces a natural bilinear form `B` on `L`, called the trace form associated to `M`; it is defined as `B(x, y) = Tr (φ x) (φ y)`. In the special case that `M` is `L` itself and `φ` is the adjoint representation, the trace form is known as the Killing form. We define the trace / Killing form in this file and prove some basic properties. ## Main definitions * `LieModule.traceForm`: a finite, free representation of a Lie algebra `L` induces a bilinear form on `L` called the trace Form. * `LieModule.traceForm_eq_zero_of_isNilpotent`: the trace form induced by a nilpotent representation of a Lie algebra vanishes. * `killingForm`: the adjoint representation of a (finite, free) Lie algebra `L` induces a bilinear form on `L` via the trace form construction. -/ variable (R K L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] [Module.Free R M] [Module.Finite R M] local notation "φ" => LieModule.toEnd R L M open LinearMap (trace) open Set FiniteDimensional namespace LieModule /-- A finite, free representation of a Lie algebra `L` induces a bilinear form on `L` called the trace Form. See also `killingForm`. -/ noncomputable def traceForm : LinearMap.BilinForm R L := ((LinearMap.mul _ _).compl₁₂ (φ).toLinearMap (φ).toLinearMap).compr₂ (trace R M) lemma traceForm_apply_apply (x y : L) : traceForm R L M x y = trace R _ (φ x ∘ₗ φ y) := rfl lemma traceForm_comm (x y : L) : traceForm R L M x y = traceForm R L M y x := LinearMap.trace_mul_comm R (φ x) (φ y) lemma traceForm_isSymm : LinearMap.IsSymm (traceForm R L M) := LieModule.traceForm_comm R L M @[simp] lemma traceForm_flip : LinearMap.flip (traceForm R L M) = traceForm R L M := Eq.symm <| LinearMap.ext₂ <| traceForm_comm R L M /-- The trace form of a Lie module is compatible with the action of the Lie algebra. See also `LieModule.traceForm_apply_lie_apply'`. -/ lemma traceForm_apply_lie_apply (x y z : L) : traceForm R L M ⁅x, y⁆ z = traceForm R L M x ⁅y, z⁆ := by calc traceForm R L M ⁅x, y⁆ z = trace R _ (φ ⁅x, y⁆ ∘ₗ φ z) := by simp only [traceForm_apply_apply] _ = trace R _ ((φ x * φ y - φ y * φ x) * φ z) := ?_ _ = trace R _ (φ x * (φ y * φ z)) - trace R _ (φ y * (φ x * φ z)) := ?_ _ = trace R _ (φ x * (φ y * φ z)) - trace R _ (φ x * (φ z * φ y)) := ?_ _ = traceForm R L M x ⁅y, z⁆ := ?_ · simp only [LieHom.map_lie, Ring.lie_def, ← LinearMap.mul_eq_comp] · simp only [sub_mul, mul_sub, map_sub, mul_assoc] · simp only [LinearMap.trace_mul_cycle' R (φ x) (φ z) (φ y)] · simp only [traceForm_apply_apply, LieHom.map_lie, Ring.lie_def, mul_sub, map_sub, ← LinearMap.mul_eq_comp] /-- Given a representation `M` of a Lie algebra `L`, the action of any `x : L` is skew-adjoint wrt the trace form. -/ lemma traceForm_apply_lie_apply' (x y z : L) : traceForm R L M ⁅x, y⁆ z = - traceForm R L M y ⁅x, z⁆ := calc traceForm R L M ⁅x, y⁆ z = - traceForm R L M ⁅y, x⁆ z := by rw [← lie_skew x y, map_neg, LinearMap.neg_apply] _ = - traceForm R L M y ⁅x, z⁆ := by rw [traceForm_apply_lie_apply] lemma traceForm_lieInvariant : (traceForm R L M).lieInvariant L := by intro x y z rw [← lie_skew, map_neg, LinearMap.neg_apply, LieModule.traceForm_apply_lie_apply R L M] /-- This lemma justifies the terminology "invariant" for trace forms. -/ @[simp] lemma lie_traceForm_eq_zero (x : L) : ⁅x, traceForm R L M⁆ = 0 := by ext y z rw [LieHom.lie_apply, LinearMap.sub_apply, Module.Dual.lie_apply, LinearMap.zero_apply, LinearMap.zero_apply, traceForm_apply_lie_apply', sub_self] @[simp] lemma traceForm_eq_zero_of_isNilpotent [IsReduced R] [IsNilpotent R L M] : traceForm R L M = 0 := by ext x y simp only [traceForm_apply_apply, LinearMap.zero_apply, ← isNilpotent_iff_eq_zero] apply LinearMap.isNilpotent_trace_of_isNilpotent exact isNilpotent_toEnd_of_isNilpotent₂ R L M x y @[simp] lemma traceForm_weightSpace_eq [IsDomain R] [IsPrincipalIdealRing R] [LieAlgebra.IsNilpotent R L] [IsNoetherian R M] [LinearWeights R L M] (χ : L → R) (x y : L) : traceForm R L (weightSpace M χ) x y = finrank R (weightSpace M χ) • (χ x * χ y) := by set d := finrank R (weightSpace M χ) have h₁ : χ y • d • χ x - χ y • χ x • (d : R) = 0 := by simp [mul_comm (χ x)] have h₂ : χ x • d • χ y = d • (χ x * χ y) := by simpa [nsmul_eq_mul, smul_eq_mul] using mul_left_comm (χ x) d (χ y) have := traceForm_eq_zero_of_isNilpotent R L (shiftedWeightSpace R L M χ) replace this := LinearMap.congr_fun (LinearMap.congr_fun this x) y rwa [LinearMap.zero_apply, LinearMap.zero_apply, traceForm_apply_apply, shiftedWeightSpace.toEnd_eq, shiftedWeightSpace.toEnd_eq, ← LinearEquiv.conj_comp, LinearMap.trace_conj', LinearMap.comp_sub, LinearMap.sub_comp, LinearMap.sub_comp, map_sub, map_sub, map_sub, LinearMap.comp_smul, LinearMap.smul_comp, LinearMap.comp_id, LinearMap.id_comp, LinearMap.map_smul, LinearMap.map_smul, trace_toEnd_weightSpace, trace_toEnd_weightSpace, LinearMap.comp_smul, LinearMap.smul_comp, LinearMap.id_comp, map_smul, map_smul, LinearMap.trace_id, ← traceForm_apply_apply, h₁, h₂, sub_zero, sub_eq_zero] at this /-- The upper and lower central series of `L` are orthogonal wrt the trace form of any Lie module `M`. -/ lemma traceForm_eq_zero_if_mem_lcs_of_mem_ucs {x y : L} (k : ℕ) (hx : x ∈ (⊤ : LieIdeal R L).lcs L k) (hy : y ∈ (⊥ : LieIdeal R L).ucs k) : traceForm R L M x y = 0 := by induction' k with k ih generalizing x y · replace hy : y = 0 := by simpa using hy simp [hy] · rw [LieSubmodule.ucs_succ, LieSubmodule.mem_normalizer] at hy simp_rw [LieIdeal.lcs_succ, ← LieSubmodule.mem_coeSubmodule, LieSubmodule.lieIdeal_oper_eq_linear_span', LieSubmodule.mem_top, true_and] at hx refine Submodule.span_induction hx ?_ ?_ (fun z w hz hw ↦ ?_) (fun t z hz ↦ ?_) · rintro - ⟨z, w, hw, rfl⟩ rw [← lie_skew, map_neg, LinearMap.neg_apply, neg_eq_zero, traceForm_apply_lie_apply] exact ih hw (hy _) · simp · simp [hz, hw] · simp [hz] lemma traceForm_apply_eq_zero_of_mem_lcs_of_mem_center {x y : L} (hx : x ∈ lowerCentralSeries R L L 1) (hy : y ∈ LieAlgebra.center R L) : traceForm R L M x y = 0 := by apply traceForm_eq_zero_if_mem_lcs_of_mem_ucs R L M 1 · simpa using hx · simpa using hy -- This is barely worth having: it usually follows from `LieModule.traceForm_eq_zero_of_isNilpotent` @[simp] lemma traceForm_eq_zero_of_isTrivial [IsTrivial L M] : traceForm R L M = 0 := by ext x y suffices φ x ∘ₗ φ y = 0 by simp [traceForm_apply_apply, this] ext m simp /-- Given a bilinear form `B` on a representation `M` of a nilpotent Lie algebra `L`, if `B` is invariant (in the sense that the action of `L` is skew-adjoint wrt `B`) then components of the Fitting decomposition of `M` are orthogonal wrt `B`. -/ lemma eq_zero_of_mem_weightSpace_mem_posFitting [LieAlgebra.IsNilpotent R L] {B : LinearMap.BilinForm R M} (hB : ∀ (x : L) (m n : M), B ⁅x, m⁆ n = - B m ⁅x, n⁆) {m₀ m₁ : M} (hm₀ : m₀ ∈ weightSpace M (0 : L → R)) (hm₁ : m₁ ∈ posFittingComp R L M) : B m₀ m₁ = 0 := by replace hB : ∀ x (k : ℕ) m n, B m ((φ x ^ k) n) = (- 1 : R) ^ k • B ((φ x ^ k) m) n := by intro x k induction k with | zero => simp | succ k ih => intro m n replace hB : ∀ m, B m (φ x n) = (- 1 : R) • B (φ x m) n := by simp [hB] have : (-1 : R) ^ k • (-1 : R) = (-1 : R) ^ (k + 1) := by rw [pow_succ (-1 : R), smul_eq_mul] conv_lhs => rw [pow_succ, LinearMap.mul_eq_comp, LinearMap.comp_apply, ih, hB, ← (φ x).comp_apply, ← LinearMap.mul_eq_comp, ← pow_succ', ← smul_assoc, this] suffices ∀ (x : L) m, m ∈ posFittingCompOf R M x → B m₀ m = 0 by apply LieSubmodule.iSup_induction _ hm₁ this (map_zero _) aesop clear hm₁ m₁; intro x m₁ hm₁ simp only [mem_weightSpace, Pi.zero_apply, zero_smul, sub_zero] at hm₀ obtain ⟨k, hk⟩ := hm₀ x obtain ⟨m, rfl⟩ := (mem_posFittingCompOf R x m₁).mp hm₁ k simp [hB, hk] lemma trace_toEnd_eq_zero_of_mem_lcs {k : ℕ} {x : L} (hk : 1 ≤ k) (hx : x ∈ lowerCentralSeries R L L k) : trace R _ (toEnd R L M x) = 0 := by replace hx : x ∈ lowerCentralSeries R L L 1 := antitone_lowerCentralSeries _ _ _ hk hx replace hx : x ∈ Submodule.span R {m | ∃ u v : L, ⁅u, v⁆ = m} := by rw [lowerCentralSeries_succ, ← LieSubmodule.mem_coeSubmodule, LieSubmodule.lieIdeal_oper_eq_linear_span'] at hx simpa using hx refine Submodule.span_induction (p := fun x ↦ trace R _ (toEnd R L M x) = 0) hx (fun y ⟨u, v, huv⟩ ↦ ?_) ?_ (fun u v hu hv ↦ ?_) (fun t u hu ↦ ?_) · simp [← huv] · simp · simp [hu, hv] · simp [hu] @[simp] lemma traceForm_lieSubalgebra_mk_left (L' : LieSubalgebra R L) {x : L} (hx : x ∈ L') (y : L') : traceForm R L' M ⟨x, hx⟩ y = traceForm R L M x y := rfl @[simp] lemma traceForm_lieSubalgebra_mk_right (L' : LieSubalgebra R L) {x : L'} {y : L} (hy : y ∈ L') : traceForm R L' M x ⟨y, hy⟩ = traceForm R L M x y := rfl open TensorProduct variable [LieAlgebra.IsNilpotent R L] [IsDomain R] [IsPrincipalIdealRing R] lemma traceForm_eq_sum_weightSpaceOf [IsTriangularizable R L M] (z : L) : traceForm R L M = ∑ χ ∈ (finite_weightSpaceOf_ne_bot R L M z).toFinset, traceForm R L (weightSpaceOf M χ z) := by ext x y have hxy : ∀ χ : R, MapsTo ((toEnd R L M x).comp (toEnd R L M y)) (weightSpaceOf M χ z) (weightSpaceOf M χ z) := fun χ m hm ↦ LieSubmodule.lie_mem _ <| LieSubmodule.lie_mem _ hm have hfin : {χ : R | (weightSpaceOf M χ z : Submodule R M) ≠ ⊥}.Finite := by convert finite_weightSpaceOf_ne_bot R L M z exact LieSubmodule.coeSubmodule_eq_bot_iff (weightSpaceOf M _ _) classical have hds := DirectSum.isInternal_submodule_of_independent_of_iSup_eq_top (LieSubmodule.independent_iff_coe_toSubmodule.mp <| independent_weightSpaceOf R L M z) (IsTriangularizable.iSup_eq_top z) simp only [LinearMap.coeFn_sum, Finset.sum_apply, traceForm_apply_apply, LinearMap.trace_eq_sum_trace_restrict' hds hfin hxy] exact Finset.sum_congr (by simp) (fun χ _ ↦ rfl) -- In characteristic zero (or even just `LinearWeights R L M`) a stronger result holds (no -- `⊓ LieAlgebra.center R L`) TODO prove this using `LieModule.traceForm_eq_sum_finrank_nsmul_mul`. lemma lowerCentralSeries_one_inf_center_le_ker_traceForm : lowerCentralSeries R L L 1 ⊓ LieAlgebra.center R L ≤ LinearMap.ker (traceForm R L M) := by /- Sketch of proof (due to Zassenhaus): Let `z ∈ lowerCentralSeries R L L 1 ⊓ LieAlgebra.center R L` and `x : L`. We must show that `trace (φ x ∘ φ z) = 0` where `φ z : End R M` indicates the action of `z` on `M` (and likewise for `φ x`). Because `z` belongs to the indicated intersection, it has two key properties: (a) the trace of the action of `z` vanishes on any Lie module of `L` (see `LieModule.trace_toEnd_eq_zero_of_mem_lcs`), (b) `z` commutes with all elements of `L`. If `φ x` were triangularizable, we could write `M` as a direct sum of generalized eigenspaces of `φ x`. Because `L` is nilpotent these are all Lie submodules, thus Lie modules in their own right, and thus by (a) above we learn that `trace (φ z) = 0` restricted to each generalized eigenspace. Because `z` commutes with `x`, this forces `trace (φ x ∘ φ z) = 0` on each generalized eigenspace, and so by summing the traces on each generalized eigenspace we learn the total trace is zero, as required (see `LinearMap.trace_comp_eq_zero_of_commute_of_trace_restrict_eq_zero`). To cater for the fact that `φ x` may not be triangularizable, we first extend the scalars from `R` to `AlgebraicClosure (FractionRing R)` and argue using the action of `A ⊗ L` on `A ⊗ M`. -/ rintro z ⟨hz : z ∈ lowerCentralSeries R L L 1, hzc : z ∈ LieAlgebra.center R L⟩ ext x rw [traceForm_apply_apply, LinearMap.zero_apply] let A := AlgebraicClosure (FractionRing R) suffices algebraMap R A (trace R _ ((φ z).comp (φ x))) = 0 by have _i : NoZeroSMulDivisors R A := NoZeroSMulDivisors.trans R (FractionRing R) A rw [← map_zero (algebraMap R A)] at this exact NoZeroSMulDivisors.algebraMap_injective R A this rw [← LinearMap.trace_baseChange, LinearMap.baseChange_comp, ← toEnd_baseChange, ← toEnd_baseChange] replace hz : 1 ⊗ₜ z ∈ lowerCentralSeries A (A ⊗[R] L) (A ⊗[R] L) 1 := by simp only [lowerCentralSeries_succ, lowerCentralSeries_zero] at hz ⊢ rw [← LieSubmodule.baseChange_top, ← LieSubmodule.lie_baseChange] exact Submodule.tmul_mem_baseChange_of_mem 1 hz replace hzc : 1 ⊗ₜ[R] z ∈ LieAlgebra.center A (A ⊗[R] L) := by simp only [mem_maxTrivSubmodule] at hzc ⊢ intro y exact y.induction_on rfl (fun a u ↦ by simp [hzc u]) (fun u v hu hv ↦ by simp [hu, hv]) apply LinearMap.trace_comp_eq_zero_of_commute_of_trace_restrict_eq_zero · exact IsTriangularizable.iSup_eq_top (1 ⊗ₜ[R] x) · exact fun μ ↦ trace_toEnd_eq_zero_of_mem_lcs A (A ⊗[R] L) (weightSpaceOf (A ⊗[R] M) μ (1 ⊗ₜ x)) (le_refl 1) hz · exact commute_toEnd_of_mem_center_right (A ⊗[R] M) hzc (1 ⊗ₜ x) /-- A nilpotent Lie algebra with a representation whose trace form is non-singular is Abelian. -/ lemma isLieAbelian_of_ker_traceForm_eq_bot (h : LinearMap.ker (traceForm R L M) = ⊥) : IsLieAbelian L := by simpa only [← disjoint_lowerCentralSeries_maxTrivSubmodule_iff R L L, disjoint_iff_inf_le, LieIdeal.coe_to_lieSubalgebra_to_submodule, LieSubmodule.coeSubmodule_eq_bot_iff, h] using lowerCentralSeries_one_inf_center_le_ker_traceForm R L M end LieModule namespace LieSubmodule open LieModule (traceForm) variable {R L M} variable [IsDomain R] [IsPrincipalIdealRing R] (N : LieSubmodule R L M) (I : LieIdeal R L) (h : I ≤ N.idealizer) (x : L) {y : L} (hy : y ∈ I) lemma trace_eq_trace_restrict_of_le_idealizer (hy' : ∀ m ∈ N, (φ x ∘ₗ φ y) m ∈ N := fun m _ ↦ N.lie_mem (N.mem_idealizer.mp (h hy) m)) : trace R M (φ x ∘ₗ φ y) = trace R N ((φ x ∘ₗ φ y).restrict hy') := by suffices ∀ m, ⁅x, ⁅y, m⁆⁆ ∈ N by simp [(φ x ∘ₗ φ y).trace_restrict_eq_of_forall_mem _ this] exact fun m ↦ N.lie_mem (h hy m) lemma traceForm_eq_of_le_idealizer : traceForm R I N = (traceForm R L M).restrict I := by ext ⟨x, hx⟩ ⟨y, hy⟩ change _ = trace R M (φ x ∘ₗ φ y) rw [N.trace_eq_trace_restrict_of_le_idealizer I h x hy] rfl /-- Note that this result is slightly stronger than it might look at first glance: we only assume that `N` is trivial over `I` rather than all of `L`. This means that it applies in the important case of an Abelian ideal (which has `M = L` and `N = I`). -/ lemma traceForm_eq_zero_of_isTrivial [LieModule.IsTrivial I N] : trace R M (φ x ∘ₗ φ y) = 0 := by let hy' : ∀ m ∈ N, (φ x ∘ₗ φ y) m ∈ N := fun m _ ↦ N.lie_mem (N.mem_idealizer.mp (h hy) m) suffices (φ x ∘ₗ φ y).restrict hy' = 0 by simp [this, N.trace_eq_trace_restrict_of_le_idealizer I h x hy] ext n suffices ⁅y, (n : M)⁆ = 0 by simp [this] exact Submodule.coe_eq_zero.mpr (LieModule.IsTrivial.trivial (⟨y, hy⟩ : I) n) end LieSubmodule section LieAlgebra variable [Module.Free R L] [Module.Finite R L] /-- A finite, free (as an `R`-module) Lie algebra `L` carries a bilinear form on `L`. This is a specialisation of `LieModule.traceForm` to the adjoint representation of `L`. -/ noncomputable abbrev killingForm : LinearMap.BilinForm R L := LieModule.traceForm R L L open LieAlgebra in lemma killingForm_apply_apply (x y : L) : killingForm R L x y = trace R L (ad R L x ∘ₗ ad R L y) := LieModule.traceForm_apply_apply R L L x y lemma killingForm_eq_zero_of_mem_zeroRoot_mem_posFitting (H : LieSubalgebra R L) [LieAlgebra.IsNilpotent R H] {x₀ x₁ : L} (hx₀ : x₀ ∈ LieAlgebra.zeroRootSubalgebra R L H) (hx₁ : x₁ ∈ LieModule.posFittingComp R H L) : killingForm R L x₀ x₁ = 0 := LieModule.eq_zero_of_mem_weightSpace_mem_posFitting R H L (fun x y z ↦ LieModule.traceForm_apply_lie_apply' R L L x y z) hx₀ hx₁ namespace LieIdeal variable (I : LieIdeal R L) /-- The orthogonal complement of an ideal with respect to the killing form is an ideal. -/ noncomputable def killingCompl : LieIdeal R L := LieAlgebra.InvariantForm.orthogonal (killingForm R L) (LieModule.traceForm_lieInvariant R L L) I @[simp] lemma toSubmodule_killingCompl : LieSubmodule.toSubmodule I.killingCompl = (killingForm R L).orthogonal I.toSubmodule := rfl @[simp] lemma mem_killingCompl {x : L} : x ∈ I.killingCompl ↔ ∀ y ∈ I, killingForm R L y x = 0 := by rfl lemma coe_killingCompl_top : killingCompl R L ⊤ = LinearMap.ker (killingForm R L) := by ext x simp [LinearMap.ext_iff, LinearMap.BilinForm.IsOrtho, LieModule.traceForm_comm R L L x] variable [IsDomain R] [IsPrincipalIdealRing R] lemma killingForm_eq : killingForm R I = (killingForm R L).restrict I := LieSubmodule.traceForm_eq_of_le_idealizer I I <| by simp lemma restrict_killingForm : (killingForm R L).restrict I = LieModule.traceForm R I L := rfl @[simp] lemma le_killingCompl_top_of_isLieAbelian [IsLieAbelian I] : I ≤ LieIdeal.killingCompl R L ⊤ := by intro x (hx : x ∈ I) simp only [mem_killingCompl, LieSubmodule.mem_top, forall_true_left] intro y rw [LieModule.traceForm_apply_apply] exact LieSubmodule.traceForm_eq_zero_of_isTrivial I I (by simp) _ hx end LieIdeal open LieModule FiniteDimensional open Submodule (span subset_span) namespace LieModule variable [Field K] [LieAlgebra K L] [Module K M] [LieModule K L M] [FiniteDimensional K M] variable [LieAlgebra.IsNilpotent K L] [LinearWeights K L M] [IsTriangularizable K L M] lemma traceForm_eq_sum_finrank_nsmul_mul (x y : L) : traceForm K L M x y = ∑ χ : Weight K L M, finrank K (weightSpace M χ) • (χ x * χ y) := by have hxy : ∀ χ : Weight K L M, MapsTo (toEnd K L M x ∘ₗ toEnd K L M y) (weightSpace M χ) (weightSpace M χ) := fun χ m hm ↦ LieSubmodule.lie_mem _ <| LieSubmodule.lie_mem _ hm classical have hds := DirectSum.isInternal_submodule_of_independent_of_iSup_eq_top (LieSubmodule.independent_iff_coe_toSubmodule.mp <| independent_weightSpace' K L M) (LieSubmodule.iSup_eq_top_iff_coe_toSubmodule.mp <| iSup_weightSpace_eq_top' K L M) simp_rw [traceForm_apply_apply, LinearMap.trace_eq_sum_trace_restrict hds hxy, ← traceForm_weightSpace_eq K L M _ x y] rfl lemma traceForm_eq_sum_finrank_nsmul : traceForm K L M = ∑ χ : Weight K L M, finrank K (weightSpace M χ) • (χ : L →ₗ[K] K).smulRight (χ : L →ₗ[K] K) := by ext rw [traceForm_eq_sum_finrank_nsmul_mul, ← Finset.sum_attach] simp -- The reverse inclusion should also hold: TODO prove this! lemma range_traceForm_le_span_weight : LinearMap.range (traceForm K L M) ≤ span K (range (Weight.toLinear K L M)) := by rintro - ⟨x, rfl⟩ rw [LieModule.traceForm_eq_sum_finrank_nsmul, LinearMap.coeFn_sum, Finset.sum_apply] refine Submodule.sum_mem _ fun χ _ ↦ ?_ simp_rw [LinearMap.smul_apply, LinearMap.coe_smulRight, Weight.toLinear_apply, ← Nat.cast_smul_eq_nsmul K] exact Submodule.smul_mem _ _ <| Submodule.smul_mem _ _ <| subset_span <| mem_range_self χ end LieModule end LieAlgebra
Algebra\Lie\UniversalEnveloping.lean
/- Copyright (c) 2020 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.OfAssociative import Mathlib.Algebra.RingQuot import Mathlib.LinearAlgebra.TensorAlgebra.Basic /-! # Universal enveloping algebra Given a commutative ring `R` and a Lie algebra `L` over `R`, we construct the universal enveloping algebra of `L`, together with its universal property. ## Main definitions * `UniversalEnvelopingAlgebra`: the universal enveloping algebra, endowed with an `R`-algebra structure. * `UniversalEnvelopingAlgebra.ι`: the Lie algebra morphism from `L` to its universal enveloping algebra. * `UniversalEnvelopingAlgebra.lift`: given an associative algebra `A`, together with a Lie algebra morphism `f : L →ₗ⁅R⁆ A`, `lift R L f : UniversalEnvelopingAlgebra R L →ₐ[R] A` is the unique morphism of algebras through which `f` factors. * `UniversalEnvelopingAlgebra.ι_comp_lift`: states that the lift of a morphism is indeed part of a factorisation. * `UniversalEnvelopingAlgebra.lift_unique`: states that lifts of morphisms are indeed unique. * `UniversalEnvelopingAlgebra.hom_ext`: a restatement of `lift_unique` as an extensionality lemma. ## Tags lie algebra, universal enveloping algebra, tensor algebra -/ universe u₁ u₂ u₃ variable (R : Type u₁) (L : Type u₂) variable [CommRing R] [LieRing L] [LieAlgebra R L] local notation "ιₜ" => TensorAlgebra.ι R namespace UniversalEnvelopingAlgebra /-- The quotient by the ideal generated by this relation is the universal enveloping algebra. Note that we have avoided using the more natural expression: | lie_compat (x y : L) : rel (ιₜ ⁅x, y⁆) ⁅ιₜ x, ιₜ y⁆ so that our construction needs only the semiring structure of the tensor algebra. -/ inductive Rel : TensorAlgebra R L → TensorAlgebra R L → Prop | lie_compat (x y : L) : Rel (ιₜ ⁅x, y⁆ + ιₜ y * ιₜ x) (ιₜ x * ιₜ y) end UniversalEnvelopingAlgebra /-- The universal enveloping algebra of a Lie algebra. -/ def UniversalEnvelopingAlgebra := RingQuot (UniversalEnvelopingAlgebra.Rel R L) namespace UniversalEnvelopingAlgebra -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5020): the next three -- instances were derived automatically in mathlib3. instance instInhabited : Inhabited (UniversalEnvelopingAlgebra R L) := inferInstanceAs (Inhabited (RingQuot (UniversalEnvelopingAlgebra.Rel R L))) instance instRing : Ring (UniversalEnvelopingAlgebra R L) := inferInstanceAs (Ring (RingQuot (UniversalEnvelopingAlgebra.Rel R L))) instance instAlgebra : Algebra R (UniversalEnvelopingAlgebra R L) := inferInstanceAs (Algebra R (RingQuot (UniversalEnvelopingAlgebra.Rel R L))) /-- The quotient map from the tensor algebra to the universal enveloping algebra as a morphism of associative algebras. -/ def mkAlgHom : TensorAlgebra R L →ₐ[R] UniversalEnvelopingAlgebra R L := RingQuot.mkAlgHom R (Rel R L) variable {L} /-- The natural Lie algebra morphism from a Lie algebra to its universal enveloping algebra. -/ @[simps!] -- Porting note (#11445): added def ι : L →ₗ⁅R⁆ UniversalEnvelopingAlgebra R L := { (mkAlgHom R L).toLinearMap.comp ιₜ with map_lie' := fun {x y} => by suffices mkAlgHom R L (ιₜ ⁅x, y⁆ + ιₜ y * ιₜ x) = mkAlgHom R L (ιₜ x * ιₜ y) by rw [map_mul] at this; simp [LieRing.of_associative_ring_bracket, ← this] exact RingQuot.mkAlgHom_rel _ (Rel.lie_compat x y) } variable {A : Type u₃} [Ring A] [Algebra R A] (f : L →ₗ⁅R⁆ A) /-- The universal property of the universal enveloping algebra: Lie algebra morphisms into associative algebras lift to associative algebra morphisms from the universal enveloping algebra. -/ def lift : (L →ₗ⁅R⁆ A) ≃ (UniversalEnvelopingAlgebra R L →ₐ[R] A) where toFun f := RingQuot.liftAlgHom R ⟨TensorAlgebra.lift R (f : L →ₗ[R] A), by intro a b h; induction' h with x y simp only [LieRing.of_associative_ring_bracket, map_add, TensorAlgebra.lift_ι_apply, LieHom.coe_toLinearMap, LieHom.map_lie, map_mul, sub_add_cancel]⟩ invFun F := (F : UniversalEnvelopingAlgebra R L →ₗ⁅R⁆ A).comp (ι R) left_inv f := by ext -- Porting note: was -- simp only [ι, mkAlgHom, TensorAlgebra.lift_ι_apply, LieHom.coe_toLinearMap, -- LinearMap.toFun_eq_coe, LinearMap.coe_comp, LieHom.coe_comp, AlgHom.coe_toLieHom, -- LieHom.coe_mk, Function.comp_apply, AlgHom.toLinearMap_apply, -- RingQuot.liftAlgHom_mkAlgHom_apply] simp only [LieHom.coe_comp, Function.comp_apply, AlgHom.coe_toLieHom, UniversalEnvelopingAlgebra.ι_apply, mkAlgHom] -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [RingQuot.liftAlgHom_mkAlgHom_apply] simp only [TensorAlgebra.lift_ι_apply, LieHom.coe_toLinearMap] right_inv F := by apply RingQuot.ringQuot_ext' ext -- Porting note: was -- simp only [ι, mkAlgHom, TensorAlgebra.lift_ι_apply, LieHom.coe_toLinearMap, -- LinearMap.toFun_eq_coe, LinearMap.coe_comp, LieHom.coe_linearMap_comp, -- AlgHom.comp_toLinearMap, Function.comp_apply, AlgHom.toLinearMap_apply, -- RingQuot.liftAlgHom_mkAlgHom_apply, AlgHom.coe_toLieHom, LieHom.coe_mk] -- extra `rfl` after leanprover/lean4#2644 simp [mkAlgHom]; rfl @[simp] theorem lift_symm_apply (F : UniversalEnvelopingAlgebra R L →ₐ[R] A) : (lift R).symm F = (F : UniversalEnvelopingAlgebra R L →ₗ⁅R⁆ A).comp (ι R) := rfl @[simp] theorem ι_comp_lift : lift R f ∘ ι R = f := funext <| LieHom.ext_iff.mp <| (lift R).symm_apply_apply f -- Porting note: moved `@[simp]` to the next theorem (LHS simplifies) theorem lift_ι_apply (x : L) : lift R f (ι R x) = f x := by rw [← Function.comp_apply (f := lift R f) (g := ι R) (x := x), ι_comp_lift] @[simp] theorem lift_ι_apply' (x : L) : lift R f ((UniversalEnvelopingAlgebra.mkAlgHom R L) (ιₜ x)) = f x := by simpa using lift_ι_apply R f x theorem lift_unique (g : UniversalEnvelopingAlgebra R L →ₐ[R] A) : g ∘ ι R = f ↔ g = lift R f := by refine Iff.trans ?_ (lift R).symm_apply_eq constructor <;> · intro h; ext; simp [← h] /-- See note [partially-applied ext lemmas]. -/ @[ext] theorem hom_ext {g₁ g₂ : UniversalEnvelopingAlgebra R L →ₐ[R] A} (h : (g₁ : UniversalEnvelopingAlgebra R L →ₗ⁅R⁆ A).comp (ι R) = (g₂ : UniversalEnvelopingAlgebra R L →ₗ⁅R⁆ A).comp (ι R)) : g₁ = g₂ := have h' : (lift R).symm g₁ = (lift R).symm g₂ := by ext; simp [h] (lift R).symm.injective h' end UniversalEnvelopingAlgebra
Algebra\Lie\Derivation\AdjointAction.lean
/- Copyright (c) 2024 Frédéric Marbach. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Marbach -/ import Mathlib.Algebra.Lie.Abelian import Mathlib.Algebra.Lie.Derivation.Basic import Mathlib.Algebra.Lie.OfAssociative /-! # Adjoint action of a Lie algebra on itself This file defines the *adjoint action* of a Lie algebra on itself, and establishes basic properties. ## Main definitions - `LieDerivation.ad`: The adjoint action of a Lie algebra `L` on itself, seen as a morphism of Lie algebras from `L` to the Lie algebra of its derivations. The adjoint action is also defined in the `Mathlib.Algebra.Lie.OfAssociative.lean` file, under the name `LieAlgebra.ad`, as the morphism with values in the endormophisms of `L`. ## Main statements - `LieDerivation.coe_ad_apply_eq_ad_apply`: when seen as endomorphisms, both definitions coincide, - `LieDerivation.ad_ker_eq_center`: the kernel of the adjoint action is the center of `L`, - `LieDerivation.lie_der_ad_eq_ad_der`: the commutator of a derivation `D` and `ad x` is `ad (D x)`, - `LieDerivation.ad_isIdealMorphism`: the range of the adjoint action is an ideal of the derivations. -/ namespace LieDerivation section AdjointAction variable (R L : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] /-- The adjoint action of a Lie algebra `L` on itself, seen as a morphism of Lie algebras from `L` to its derivations. Note the minus sign: this is chosen to so that `ad ⁅x, y⁆ = ⁅ad x, ad y⁆`. -/ @[simps!] def ad : L →ₗ⁅R⁆ LieDerivation R L L := { __ := - inner R L L map_lie' := by intro x y ext z simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, LinearMap.neg_apply, coe_neg, Pi.neg_apply, inner_apply_apply, commutator_apply] rw [leibniz_lie, neg_lie, neg_lie, ← lie_skew x] abel } variable {R L} /-- The definitions `LieDerivation.ad` and `LieAlgebra.ad` agree. -/ @[simp] lemma coe_ad_apply_eq_ad_apply (x : L) : ad R L x = LieAlgebra.ad R L x := by ext; simp lemma ad_apply_lieDerivation (x : L) (D : LieDerivation R L L) : ad R L (D x) = - ⁅x, D⁆ := rfl lemma lie_ad (x : L) (D : LieDerivation R L L) : ⁅ad R L x, D⁆ = ⁅x, D⁆ := by ext; simp variable (R L) in /-- The kernel of the adjoint action on a Lie algebra is equal to its center. -/ lemma ad_ker_eq_center : (ad R L).ker = LieAlgebra.center R L := by ext x rw [← LieAlgebra.self_module_ker_eq_center, LieHom.mem_ker, LieModule.mem_ker] simp [DFunLike.ext_iff] /-- If the center of a Lie algebra is trivial, then the adjoint action is injective. -/ lemma injective_ad_of_center_eq_bot (h : LieAlgebra.center R L = ⊥) : Function.Injective (ad R L) := by rw [← LieHom.ker_eq_bot, ad_ker_eq_center, h] /-- The commutator of a derivation `D` and a derivation of the form `ad x` is `ad (D x)`. -/ lemma lie_der_ad_eq_ad_der (D : LieDerivation R L L) (x : L) : ⁅D, ad R L x⁆ = ad R L (D x) := by rw [ad_apply_lieDerivation, ← lie_ad, lie_skew] variable (R L) in /-- The range of the adjoint action homomorphism from a Lie algebra `L` to the Lie algebra of its derivations is an ideal of the latter. -/ lemma ad_isIdealMorphism : (ad R L).IsIdealMorphism := by simp_rw [LieHom.isIdealMorphism_iff, lie_der_ad_eq_ad_der] tauto /-- A derivation `D` belongs to the ideal range of the adjoint action iff it is of the form `ad x` for some `x` in the Lie algebra `L`. -/ lemma mem_ad_idealRange_iff {D : LieDerivation R L L} : D ∈ (ad R L).idealRange ↔ ∃ x : L, ad R L x = D := (ad R L).mem_idealRange_iff (ad_isIdealMorphism R L) lemma maxTrivSubmodule_eq_bot_of_center_eq_bot (h : LieAlgebra.center R L = ⊥) : LieModule.maxTrivSubmodule R L (LieDerivation R L L) = ⊥ := by refine (LieSubmodule.eq_bot_iff _).mpr fun D hD ↦ ext fun x ↦ ?_ have : ad R L (D x) = 0 := by rw [LieModule.mem_maxTrivSubmodule] at hD simp [ad_apply_lieDerivation, hD] rw [← LieHom.mem_ker, ad_ker_eq_center, h, LieSubmodule.mem_bot] at this simp [this] end AdjointAction end LieDerivation
Algebra\Lie\Derivation\Basic.lean
/- Copyright (c) 2024 Frédéric Marbach. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Marbach -/ import Mathlib.Algebra.Lie.Basic import Mathlib.Algebra.Lie.OfAssociative import Mathlib.Algebra.Lie.Subalgebra /-! # Lie derivations This file defines *Lie derivations* and establishes some basic properties. ## Main definitions - `LieDerivation`: A Lie derivation `D` from the Lie `R`-algebra `L` to the `L`-module `M` is an `R`-linear map that satisfies the Leibniz rule `D [a, b] = [a, D b] - [b, D a]`. - `LieDerivation.inner`: The natural map from a Lie module to the derivations taking values in it. ## Main statements - `LieDerivation.eqOn_lieSpan`: two Lie derivations equal on a set are equal on its Lie span. - `LieDerivation.instLieAlgebra`: the set of Lie derivations from a Lie algebra to itself is a Lie algebra. ## Implementation notes - Mathematically, a Lie derivation is just a derivation on a Lie algebra. However, the current implementation of `RingTheory.Derivation` requires a commutative associative algebra, so is incompatible with the setting of Lie algebras. Initially, this file is a copy-pasted adaptation of the `RingTheory.Derivation.Basic.lean` file. - Since we don't have right actions of Lie algebras, the second term in the Leibniz rule is written as `- [b, D a]`. Within Lie algebras, skew symmetry restores the expected definition `[D a, b]`. -/ /-- A Lie derivation `D` from the Lie `R`-algebra `L` to the `L`-module `M` is an `R`-linear map that satisfies the Leibniz rule `D [a, b] = [a, D b] - [b, D a]`. -/ structure LieDerivation (R L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] extends L →ₗ[R] M where protected leibniz' (a b : L) : toLinearMap ⁅a, b⁆ = ⁅a, toLinearMap b⁆ - ⁅b, toLinearMap a⁆ /-- The `LinearMap` underlying a `LieDerivation`. -/ add_decl_doc LieDerivation.toLinearMap namespace LieDerivation section variable {R L M : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] variable (D : LieDerivation R L M) {D1 D2 : LieDerivation R L M} (a b : L) instance : FunLike (LieDerivation R L M) L M where coe D := D.toFun coe_injective' D1 D2 h := by cases D1; cases D2; congr; exact DFunLike.coe_injective h instance instLinearMapClass : LinearMapClass (LieDerivation R L M) R L M where map_add D := D.toLinearMap.map_add' map_smulₛₗ D := D.toLinearMap.map_smul theorem toFun_eq_coe : D.toFun = ⇑D := rfl /-- See Note [custom simps projection] -/ def Simps.apply (D : LieDerivation R L M) : L → M := D initialize_simps_projections LieDerivation (toFun → apply) attribute [coe] toLinearMap instance instCoeToLinearMap : Coe (LieDerivation R L M) (L →ₗ[R] M) := ⟨fun D => D.toLinearMap⟩ @[simp] theorem mk_coe (f : L →ₗ[R] M) (h₁) : ((⟨f, h₁⟩ : LieDerivation R L M) : L → M) = f := rfl @[simp, norm_cast] theorem coeFn_coe (f : LieDerivation R L M) : ⇑(f : L →ₗ[R] M) = f := rfl theorem coe_injective : @Function.Injective (LieDerivation R L M) (L → M) DFunLike.coe := DFunLike.coe_injective @[ext] theorem ext (H : ∀ a, D1 a = D2 a) : D1 = D2 := DFunLike.ext _ _ H theorem congr_fun (h : D1 = D2) (a : L) : D1 a = D2 a := DFunLike.congr_fun h a @[simp] lemma apply_lie_eq_sub (D : LieDerivation R L M) (a b : L) : D ⁅a, b⁆ = ⁅a, D b⁆ - ⁅b, D a⁆ := D.leibniz' a b /-- For a Lie derivation from a Lie algebra to itself, the usual Leibniz rule holds. -/ lemma apply_lie_eq_add (D : LieDerivation R L L) (a b : L) : D ⁅a, b⁆ = ⁅a, D b⁆ + ⁅D a, b⁆ := by rw [LieDerivation.apply_lie_eq_sub, sub_eq_add_neg, lie_skew] /-- Two Lie derivations equal on a set are equal on its Lie span. -/ theorem eqOn_lieSpan {s : Set L} (h : Set.EqOn D1 D2 s) : Set.EqOn D1 D2 (LieSubalgebra.lieSpan R L s) := fun z hz => have zero : D1 0 = D2 0 := by simp only [map_zero] have smul : ∀ (r : R), ∀ {x : L}, D1 x = D2 x → D1 (r • x) = D2 (r • x) := fun _ _ hx => by simp only [map_smul, hx] have add : ∀ x y, D1 x = D2 x → D1 y = D2 y → D1 (x + y) = D2 (x + y) := fun _ _ hx hy => by simp only [map_add, hx, hy] have lie : ∀ x y, D1 x = D2 x → D1 y = D2 y → D1 ⁅x, y⁆ = D2 ⁅x, y⁆ := fun _ _ hx hy => by simp only [apply_lie_eq_sub, hx, hy] LieSubalgebra.lieSpan_induction R (p := fun x => D1 x = D2 x) hz h zero smul add lie /-- If the Lie span of a set is the whole Lie algebra, then two Lie derivations equal on this set are equal on the whole Lie algebra. -/ theorem ext_of_lieSpan_eq_top (s : Set L) (hs : LieSubalgebra.lieSpan R L s = ⊤) (h : Set.EqOn D1 D2 s) : D1 = D2 := ext fun _ => eqOn_lieSpan h <| hs.symm ▸ trivial instance instZero : Zero (LieDerivation R L M) where zero := { toLinearMap := 0 leibniz' := fun a b => by simp only [LinearMap.zero_apply, lie_zero, sub_self] } @[simp] theorem coe_zero : ⇑(0 : LieDerivation R L M) = 0 := rfl @[simp] theorem coe_zero_linearMap : ↑(0 : LieDerivation R L M) = (0 : L →ₗ[R] M) := rfl theorem zero_apply (a : L) : (0 : LieDerivation R L M) a = 0 := rfl instance : Inhabited (LieDerivation R L M) := ⟨0⟩ instance instAdd : Add (LieDerivation R L M) where add D1 D2 := { toLinearMap := D1 + D2 leibniz' := fun a b ↦ by simp only [LinearMap.add_apply, coeFn_coe, apply_lie_eq_sub, lie_add, add_sub_add_comm] } @[simp] theorem coe_add (D1 D2 : LieDerivation R L M) : ⇑(D1 + D2) = D1 + D2 := rfl @[simp] theorem coe_add_linearMap (D1 D2 : LieDerivation R L M) : ↑(D1 + D2) = (D1 + D2 : L →ₗ[R] M) := rfl theorem add_apply : (D1 + D2) a = D1 a + D2 a := rfl protected theorem map_neg : D (-a) = -D a := map_neg D a protected theorem map_sub : D (a - b) = D a - D b := map_sub D a b instance instNeg : Neg (LieDerivation R L M) := ⟨fun D => mk (-D) fun a b => by simp only [LinearMap.neg_apply, coeFn_coe, apply_lie_eq_sub, neg_sub, lie_neg, sub_neg_eq_add, add_comm, ← sub_eq_add_neg] ⟩ @[simp] theorem coe_neg (D : LieDerivation R L M) : ⇑(-D) = -D := rfl @[simp] theorem coe_neg_linearMap (D : LieDerivation R L M) : ↑(-D) = (-D : L →ₗ[R] M) := rfl theorem neg_apply : (-D) a = -D a := rfl instance instSub : Sub (LieDerivation R L M) := ⟨fun D1 D2 => mk (D1 - D2 : L →ₗ[R] M) fun a b => by simp only [LinearMap.sub_apply, coeFn_coe, apply_lie_eq_sub, lie_sub, sub_sub_sub_comm]⟩ @[simp] theorem coe_sub (D1 D2 : LieDerivation R L M) : ⇑(D1 - D2) = D1 - D2 := rfl @[simp] theorem coe_sub_linearMap (D1 D2 : LieDerivation R L M) : ↑(D1 - D2) = (D1 - D2 : L →ₗ[R] M) := rfl theorem sub_apply {D1 D2 : LieDerivation R L M} : (D1 - D2) a = D1 a - D2 a := rfl section Scalar /-- A typeclass mixin saying that scalar multiplication and Lie bracket are left commutative. -/ class SMulBracketCommClass (S L α : Type*) [SMul S α] [LieRing L] [AddCommGroup α] [LieRingModule L α] : Prop where /-- `•` and `⁅⬝, ⬝⁆` are left commutative -/ smul_bracket_comm : ∀ (s : S) (l : L) (a : α), s • ⁅l, a⁆ = ⁅l, s • a⁆ variable {S T : Type*} variable [Monoid S] [DistribMulAction S M] [SMulCommClass R S M] [SMulBracketCommClass S L M] variable [Monoid T] [DistribMulAction T M] [SMulCommClass R T M] [SMulBracketCommClass T L M] instance instSMul : SMul S (LieDerivation R L M) where smul r D := { toLinearMap := r • D leibniz' := fun a b => by simp only [LinearMap.smul_apply, coeFn_coe, apply_lie_eq_sub, smul_sub, SMulBracketCommClass.smul_bracket_comm] } @[simp] theorem coe_smul (r : S) (D : LieDerivation R L M) : ⇑(r • D) = r • ⇑D := rfl @[simp] theorem coe_smul_linearMap (r : S) (D : LieDerivation R L M) : ↑(r • D) = r • (D : L →ₗ[R] M) := rfl theorem smul_apply (r : S) (D : LieDerivation R L M) : (r • D) a = r • D a := rfl instance instSMulBase : SMulBracketCommClass R L M := ⟨fun s l a ↦ (lie_smul s l a).symm⟩ instance instSMulNat : SMulBracketCommClass ℕ L M := ⟨fun s l a => (lie_nsmul l a s).symm⟩ instance instSMulInt : SMulBracketCommClass ℤ L M := ⟨fun s l a => (lie_zsmul l a s).symm⟩ instance instAddCommGroup : AddCommGroup (LieDerivation R L M) := coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => rfl) fun _ _ => rfl /-- `coe_fn` as an `AddMonoidHom`. -/ def coeFnAddMonoidHom : LieDerivation R L M →+ L → M where toFun := (↑) map_zero' := coe_zero map_add' := coe_add instance : DistribMulAction S (LieDerivation R L M) := Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul instance [SMul S T] [IsScalarTower S T M] : IsScalarTower S T (LieDerivation R L M) := ⟨fun _ _ _ => ext fun _ => smul_assoc _ _ _⟩ instance [SMulCommClass S T M] : SMulCommClass S T (LieDerivation R L M) := ⟨fun _ _ _ => ext fun _ => smul_comm _ _ _⟩ end Scalar instance instModule {S : Type*} [Semiring S] [Module S M] [SMulCommClass R S M] [SMulBracketCommClass S L M] : Module S (LieDerivation R L M) := Function.Injective.module S coeFnAddMonoidHom coe_injective coe_smul end section variable {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] /-- The commutator of two Lie derivations on a Lie algebra is a Lie derivation. -/ instance instBracket : Bracket (LieDerivation R L L) (LieDerivation R L L) where bracket D1 D2 := LieDerivation.mk ⁅(D1 : Module.End R L), (D2 : Module.End R L)⁆ (fun a b => by simp only [Ring.lie_def, apply_lie_eq_add, coeFn_coe, LinearMap.sub_apply, LinearMap.mul_apply, map_add, sub_lie, lie_sub, ← lie_skew b] abel) variable (D : LieDerivation R L L) {D1 D2 : LieDerivation R L L} @[simp] lemma commutator_coe_linear_map : ↑⁅D1, D2⁆ = ⁅(D1 : Module.End R L), (D2 : Module.End R L)⁆ := rfl lemma commutator_apply (a : L) : ⁅D1, D2⁆ a = D1 (D2 a) - D2 (D1 a) := rfl instance : LieRing (LieDerivation R L L) where add_lie d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; abel lie_add d e f := by ext a; simp only [commutator_apply, add_apply, map_add]; abel lie_self d := by ext a; simp only [commutator_apply, add_apply, map_add, zero_apply]; abel leibniz_lie d e f := by ext a; simp only [commutator_apply, add_apply, sub_apply, map_sub]; abel /-- The set of Lie derivations from a Lie algebra `L` to itself is a Lie algebra. -/ instance instLieAlgebra : LieAlgebra R (LieDerivation R L L) where lie_smul := fun r d e => by ext a; simp only [commutator_apply, map_smul, smul_sub, smul_apply] @[simp] lemma lie_apply (D₁ D₂ : LieDerivation R L L) (x : L) : ⁅D₁, D₂⁆ x = D₁ (D₂ x) - D₂ (D₁ x) := rfl end section variable (R L : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] /-- The Lie algebra morphism from Lie derivations into linear endormophisms. -/ def toLinearMapLieHom : LieDerivation R L L →ₗ⁅R⁆ L →ₗ[R] L where toFun := toLinearMap map_add' := by intro D1 D2; dsimp map_smul' := by intro D1 D2; dsimp map_lie' := by intro D1 D2; dsimp /-- The map from Lie derivations to linear endormophisms is injective. -/ lemma toLinearMapLieHom_injective : Function.Injective (toLinearMapLieHom R L) := fun _ _ h ↦ ext fun a ↦ congrFun (congrArg DFunLike.coe h) a /-- Lie derivations over a Noetherian Lie algebra form a Noetherian module. -/ instance instNoetherian [IsNoetherian R L] : IsNoetherian R (LieDerivation R L L) := isNoetherian_of_linearEquiv (LinearEquiv.ofInjective _ (toLinearMapLieHom_injective R L)).symm end section Inner variable (R L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] /-- The natural map from a Lie module to the derivations taking values in it. -/ @[simps!] def inner : M →ₗ[R] LieDerivation R L M where toFun m := { __ := (LieModule.toEnd R L M : L →ₗ[R] Module.End R M).flip m leibniz' := by simp } map_add' m n := by ext; simp map_smul' t m := by ext; simp instance instLieRingModule : LieRingModule L (LieDerivation R L M) where bracket x D := inner R L M (D x) add_lie x y D := by simp lie_add x D₁ D₂ := by simp leibniz_lie x y D := by simp @[simp] lemma lie_lieDerivation_apply (x y : L) (D : LieDerivation R L M) : ⁅x, D⁆ y = ⁅y, D x⁆ := rfl @[simp] lemma lie_coe_lieDerivation_apply (x : L) (D : LieDerivation R L M) : ⁅x, (D : L →ₗ[R] M)⁆ = ⁅x, D⁆ := by ext; simp instance instLieModule : LieModule R L (LieDerivation R L M) where smul_lie t x D := by ext; simp lie_smul t x D := by ext; simp protected lemma leibniz_lie (x : L) (D₁ D₂ : LieDerivation R L L) : ⁅x, ⁅D₁, D₂⁆⁆ = ⁅⁅x, D₁⁆, D₂⁆ + ⁅D₁, ⁅x, D₂⁆⁆ := by ext y simp [-lie_skew, ← lie_skew (D₁ x) (D₂ y), ← lie_skew (D₂ x) (D₁ y), sub_eq_neg_add] end Inner end LieDerivation
Algebra\Lie\Derivation\Killing.lean
/- Copyright (c) 2024 Frédéric Marbach. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Marbach -/ import Mathlib.Algebra.Lie.Derivation.AdjointAction import Mathlib.Algebra.Lie.Killing import Mathlib.LinearAlgebra.BilinearForm.Orthogonal /-! # Derivations of finite dimensional Killing Lie algebras This file establishes that all derivations of finite-dimensional Killing Lie algebras are inner. ## Main statements - `LieDerivation.Killing.ad_mem_orthogonal_of_mem_orthogonal`: if a derivation `D` is in the Killing orthogonal of the range of the adjoint action, then, for any `x : L`, `ad (D x)` is also in this orthogonal. - `LieDerivation.Killing.range_ad_eq_top`: in a finite-dimensional Lie algebra with non-degenerate Killing form, the range of the adjoint action is full, - `LieDerivation.Killing.exists_eq_ad`: in a finite-dimensional Lie algebra with non-degenerate Killing form, any derivation is an inner derivation. -/ namespace LieDerivation.IsKilling section variable (R L : Type*) [Field R] [LieRing L] [LieAlgebra R L] [Module.Finite R L] /-- A local notation for the set of (Lie) derivations on `L`. -/ local notation "𝔻" => (LieDerivation R L L) /-- A local notation for the range of `ad`. -/ local notation "𝕀" => (LieHom.range (ad R L)) /-- A local notation for the Killing complement of the ideal range of `ad`. -/ local notation "𝕀ᗮ" => LinearMap.BilinForm.orthogonal (killingForm R 𝔻) 𝕀 lemma killingForm_restrict_range_ad : (killingForm R 𝔻).restrict 𝕀 = killingForm R 𝕀 := by rw [← (ad_isIdealMorphism R L).eq, ← LieIdeal.killingForm_eq] rfl /-- The orthogonal complement of the inner derivations is a Lie submodule of all derivations. -/ @[simps!] noncomputable def rangeAdOrthogonal : LieSubmodule R L (LieDerivation R L L) where __ := 𝕀ᗮ lie_mem := by intro x D hD have : 𝕀ᗮ = (ad R L).idealRange.killingCompl := by simp [← (ad_isIdealMorphism R L).eq] change D ∈ 𝕀ᗮ at hD change ⁅x, D⁆ ∈ 𝕀ᗮ rw [this] at hD ⊢ rw [← lie_ad] exact lie_mem_right _ _ (ad R L).idealRange.killingCompl _ _ hD variable {R L} /-- If a derivation `D` is in the Killing orthogonal of the range of the adjoint action, then, for any `x : L`, `ad (D x)` is also in this orthogonal. -/ lemma ad_mem_orthogonal_of_mem_orthogonal {D : LieDerivation R L L} (hD : D ∈ 𝕀ᗮ) (x : L) : ad R L (D x) ∈ 𝕀ᗮ := by simp only [ad_apply_lieDerivation, LieHom.range_coeSubmodule, neg_mem_iff] exact (rangeAdOrthogonal R L).lie_mem hD lemma ad_mem_ker_killingForm_ad_range_of_mem_orthogonal {D : LieDerivation R L L} (hD : D ∈ 𝕀ᗮ) (x : L) : ad R L (D x) ∈ (LinearMap.ker (killingForm R 𝕀)).map (LieHom.range (ad R L)).subtype := by rw [← killingForm_restrict_range_ad] exact LinearMap.BilinForm.inf_orthogonal_self_le_ker_restrict (LieModule.traceForm_isSymm R 𝔻 𝔻).isRefl ⟨by simp, ad_mem_orthogonal_of_mem_orthogonal hD x⟩ variable (R L) variable [LieAlgebra.IsKilling R L] @[simp] lemma ad_apply_eq_zero_iff (x : L) : ad R L x = 0 ↔ x = 0 := by refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩ rwa [← LieHom.mem_ker, ad_ker_eq_center, LieAlgebra.HasTrivialRadical.center_eq_bot, LieSubmodule.mem_bot] at h instance instIsKilling_range_ad : LieAlgebra.IsKilling R 𝕀 := (LieEquiv.ofInjective (ad R L) (injective_ad_of_center_eq_bot <| by simp)).isKilling /-- The restriction of the Killing form of a finite-dimensional Killing Lie algebra to the range of the adjoint action is nondegenerate. -/ lemma killingForm_restrict_range_ad_nondegenerate : ((killingForm R 𝔻).restrict 𝕀).Nondegenerate := killingForm_restrict_range_ad R L ▸ LieAlgebra.IsKilling.killingForm_nondegenerate R _ /-- The range of the adjoint action on a finite-dimensional Killing Lie algebra is full. -/ @[simp] lemma range_ad_eq_top : 𝕀 = ⊤ := by rw [← LieSubalgebra.coe_to_submodule_eq_iff] apply LinearMap.BilinForm.eq_top_of_restrict_nondegenerate_of_orthogonal_eq_bot (LieModule.traceForm_isSymm R 𝔻 𝔻).isRefl (killingForm_restrict_range_ad_nondegenerate R L) refine (Submodule.eq_bot_iff _).mpr fun D hD ↦ ext fun x ↦ ?_ simpa using ad_mem_ker_killingForm_ad_range_of_mem_orthogonal hD x variable {R L} in /-- Every derivation of a finite-dimensional Killing Lie algebra is an inner derivation. -/ lemma exists_eq_ad (D : 𝔻) : ∃ x, ad R L x = D := by change D ∈ 𝕀 rw [range_ad_eq_top R L] exact Submodule.mem_top end end IsKilling end LieDerivation
Algebra\Lie\Semisimple\Basic.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Semisimple.Defs import Mathlib.Order.BooleanGenerators /-! # Semisimple Lie algebras The famous Cartan-Dynkin-Killing classification of semisimple Lie algebras renders them one of the most important classes of Lie algebras. In this file we prove basic results abot simple and semisimple Lie algebras. ## Main declarations * `LieAlgebra.IsSemisimple.instHasTrivialRadical`: A semisimple Lie algebra has trivial radical. * `LieAlgebra.IsSemisimple.instBooleanAlgebra`: The lattice of ideals in a semisimple Lie algebra is a boolean algebra. In particular, this implies that the lattice of ideals is atomistic: every ideal is a direct sum of atoms (simple ideals) in a unique way. * `LieAlgebra.hasTrivialRadical_iff_no_solvable_ideals` * `LieAlgebra.hasTrivialRadical_iff_no_abelian_ideals` * `LieAlgebra.abelian_radical_iff_solvable_is_abelian` ## Tags lie algebra, radical, simple, semisimple -/ section Irreducible variable (R L M : Type*) [CommRing R] [LieRing L] [AddCommGroup M] [Module R M] [LieRingModule L M] lemma LieModule.nontrivial_of_isIrreducible [LieModule.IsIrreducible R L M] : Nontrivial M where exists_pair_ne := by have aux : (⊥ : LieSubmodule R L M) ≠ ⊤ := bot_ne_top contrapose! aux ext m simpa using aux m 0 end Irreducible namespace LieAlgebra variable (R L : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] variable {R L} in theorem HasTrivialRadical.eq_bot_of_isSolvable [HasTrivialRadical R L] (I : LieIdeal R L) [hI : IsSolvable R I] : I = ⊥ := sSup_eq_bot.mp radical_eq_bot _ hI @[simp] theorem HasTrivialRadical.center_eq_bot [HasTrivialRadical R L] : center R L = ⊥ := HasTrivialRadical.eq_bot_of_isSolvable _ variable {R L} in theorem hasTrivialRadical_of_no_solvable_ideals (h : ∀ I : LieIdeal R L, IsSolvable R I → I = ⊥) : HasTrivialRadical R L := ⟨sSup_eq_bot.mpr h⟩ theorem hasTrivialRadical_iff_no_solvable_ideals : HasTrivialRadical R L ↔ ∀ I : LieIdeal R L, IsSolvable R I → I = ⊥ := ⟨@HasTrivialRadical.eq_bot_of_isSolvable _ _ _ _ _, hasTrivialRadical_of_no_solvable_ideals⟩ theorem hasTrivialRadical_iff_no_abelian_ideals : HasTrivialRadical R L ↔ ∀ I : LieIdeal R L, IsLieAbelian I → I = ⊥ := by rw [hasTrivialRadical_iff_no_solvable_ideals] constructor <;> intro h₁ I h₂ · exact h₁ _ <| LieAlgebra.ofAbelianIsSolvable R I · rw [← abelian_of_solvable_ideal_eq_bot_iff] exact h₁ _ <| abelian_derivedAbelianOfIdeal I namespace IsSimple variable [IsSimple R L] instance : LieModule.IsIrreducible R L L := by suffices Nontrivial (LieIdeal R L) from ⟨IsSimple.eq_bot_or_eq_top⟩ rw [LieSubmodule.nontrivial_iff, ← not_subsingleton_iff_nontrivial] have _i : ¬ IsLieAbelian L := IsSimple.non_abelian R contrapose! _i infer_instance variable {R L} in lemma eq_top_of_isAtom (I : LieIdeal R L) (hI : IsAtom I) : I = ⊤ := (IsSimple.eq_bot_or_eq_top I).resolve_left hI.1 lemma isAtom_top : IsAtom (⊤ : LieIdeal R L) := ⟨bot_ne_top.symm, fun _ h ↦ h.eq_bot⟩ variable {R L} in @[simp] lemma isAtom_iff_eq_top (I : LieIdeal R L) : IsAtom I ↔ I = ⊤ := ⟨eq_top_of_isAtom I, fun h ↦ h ▸ isAtom_top R L⟩ instance : HasTrivialRadical R L := by rw [hasTrivialRadical_iff_no_abelian_ideals] intro I hI apply (IsSimple.eq_bot_or_eq_top I).resolve_right rintro rfl rw [lie_abelian_iff_equiv_lie_abelian LieIdeal.topEquiv] at hI exact IsSimple.non_abelian R (L := L) hI end IsSimple namespace IsSemisimple open CompleteLattice IsCompactlyGenerated variable {R L} variable [IsSemisimple R L] lemma isSimple_of_isAtom (I : LieIdeal R L) (hI : IsAtom I) : IsSimple R I where non_abelian := IsSemisimple.non_abelian_of_isAtom I hI eq_bot_or_eq_top := by -- Suppose that `J` is an ideal of `I`. intro J -- We first show that `J` is also an ideal of the ambient Lie algebra `L`. let J' : LieIdeal R L := { __ := J.toSubmodule.map I.incl.toLinearMap lie_mem := by rintro x _ ⟨y, hy, rfl⟩ dsimp -- We need to show that `⁅x, y⁆ ∈ J` for any `x ∈ L` and `y ∈ J`. -- Since `L` is semisimple, `x` is contained -- in the supremum of `I` and the atoms not equal to `I`. have hx : x ∈ I ⊔ sSup ({I' : LieIdeal R L | IsAtom I'} \ {I}) := by nth_rewrite 1 [← sSup_singleton (a := I)] rw [← sSup_union, Set.union_diff_self, Set.union_eq_self_of_subset_left, IsSemisimple.sSup_atoms_eq_top] · apply LieSubmodule.mem_top · simp only [Set.singleton_subset_iff, Set.mem_setOf_eq, hI] -- Hence we can write `x` as `a + b` with `a ∈ I` -- and `b` in the supremum of the atoms not equal to `I`. rw [LieSubmodule.mem_sup] at hx obtain ⟨a, ha, b, hb, rfl⟩ := hx -- Therefore it suffices to show that `⁅a, y⁆ ∈ J` and `⁅b, y⁆ ∈ J`. simp only [add_lie, AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid] apply add_mem -- Now `⁅a, y⁆ ∈ J` since `a ∈ I`, `y ∈ J`, and `J` is an ideal of `I`. · simp only [Submodule.mem_map, LieSubmodule.mem_coeSubmodule, Submodule.coeSubtype, Subtype.exists, exists_and_right, exists_eq_right, ha, lie_mem_left, exists_true_left] exact lie_mem_right R I J ⟨a, ha⟩ y hy -- Finally `⁅b, y⁆ = 0`, by the independence of the atoms. · suffices ⁅b, y.val⁆ = 0 by simp only [this, zero_mem] rw [← LieSubmodule.mem_bot (R := R) (L := L), ← (IsSemisimple.setIndependent_isAtom hI).eq_bot] exact ⟨lie_mem_right R L I b y y.2, lie_mem_left _ _ _ _ _ hb⟩ } -- Now that we know that `J` is an ideal of `L`, -- we start with the proof that `I` is a simple Lie algebra. -- Assume that `J ≠ ⊤`. rw [or_iff_not_imp_right] intro hJ suffices J' = ⊥ by rw [eq_bot_iff] at this ⊢ intro x hx suffices x ∈ J → x = 0 from this hx simpa [J'] using @this x.1 -- We need to show that `J = ⊥`. -- Since `J` is an ideal of `L`, and `I` is an atom, -- it suffices to show that `J < I`. apply hI.2 rw [lt_iff_le_and_ne] constructor -- We know that `J ≤ I` since `J` is an ideal of `I`. · rintro _ ⟨x, -, rfl⟩ exact x.2 -- So we need to show `J ≠ I` as ideals of `L`. -- This follows from our assumption that `J ≠ ⊤` as ideals of `I`. contrapose! hJ rw [eq_top_iff] rintro ⟨x, hx⟩ - rw [← hJ] at hx rcases hx with ⟨y, hy, rfl⟩ exact hy /-- In a semisimple Lie algebra, Lie ideals that are contained in the supremum of a finite collection of atoms are themselves the supremum of a finite subcollection of those atoms. By a compactness argument, this statement can be extended to arbitrary sets of atoms. See `atomistic`. The proof is by induction on the finite set of atoms. -/ private lemma finitelyAtomistic : ∀ s : Finset (LieIdeal R L), ↑s ⊆ {I : LieIdeal R L | IsAtom I} → ∀ I : LieIdeal R L, I ≤ s.sup id → ∃ t ⊆ s, I = t.sup id := by intro s hs I hI let S := {I : LieIdeal R L | IsAtom I} obtain rfl | hI := hI.eq_or_lt · exact ⟨s, le_rfl, rfl⟩ -- We assume that `I` is strictly smaller than the supremum of `s`. -- Hence there must exist an atom `J` that is not contained in `I`. obtain ⟨J, hJs, hJI⟩ : ∃ J ∈ s, ¬ J ≤ I := by by_contra! H exact hI.ne (le_antisymm hI.le (s.sup_le H)) classical let s' := s.erase J have hs' : s' ⊂ s := Finset.erase_ssubset hJs have hs'S : ↑s' ⊆ S := Set.Subset.trans (Finset.coe_subset.mpr hs'.subset) hs -- If we show that `I` is contained in the supremum `K` of the complement of `J` in `s`, -- then we are done by recursion. set K := s'.sup id suffices I ≤ K by obtain ⟨t, hts', htI⟩ := finitelyAtomistic s' hs'S I this exact ⟨t, le_trans hts' hs'.subset, htI⟩ -- Since `I` is contained in the supremum of `J` with the supremum of `s'`, -- any element `x` of `I` can be written as `y + z` for some `y ∈ J` and `z ∈ K`. intro x hx obtain ⟨y, hy, z, hz, rfl⟩ : ∃ y ∈ id J, ∃ z ∈ K, y + z = x := by rw [← LieSubmodule.mem_sup, ← Finset.sup_insert, Finset.insert_erase hJs] exact hI.le hx -- If we show that `y` is contained in the center of `J`, -- then we find `x = z`, and hence `x` is contained in the supremum of `s'`. -- Since `x` was arbitrary, we have shown that `I` is contained in the supremum of `s'`. suffices ⟨y, hy⟩ ∈ LieAlgebra.center R J by have _inst := isSimple_of_isAtom J (hs hJs) rw [HasTrivialRadical.center_eq_bot R J, LieSubmodule.mem_bot] at this apply_fun Subtype.val at this dsimp at this rwa [this, zero_add] -- To show that `y` is in the center of `J`, -- we show that any `j ∈ J` brackets to `0` with `z` and with `x = y + z`. -- By a simple computation, that implies `⁅j, y⁆ = 0`, for all `j`, as desired. intro j suffices ⁅(j : L), z⁆ = 0 ∧ ⁅(j : L), y + z⁆ = 0 by rw [lie_add, this.1, add_zero] at this ext exact this.2 rw [← LieSubmodule.mem_bot (R := R) (L := L), ← LieSubmodule.mem_bot (R := R) (L := L)] constructor -- `j` brackets to `0` with `z`, since `⁅j, z⁆` is contained in `⁅J, K⁆ ≤ J ⊓ K`, -- and `J ⊓ K = ⊥` by the independence of the atoms. · apply (setIndependent_isAtom.disjoint_sSup (hs hJs) hs'S (Finset.not_mem_erase _ _)).le_bot apply LieSubmodule.lie_le_inf apply LieSubmodule.lie_mem_lie j.2 simpa only [K, Finset.sup_id_eq_sSup] using hz -- By similar reasoning, `j` brackets to `0` with `x = y + z ∈ I`, if we show `J ⊓ I = ⊥`. suffices J ⊓ I = ⊥ by apply this.le apply LieSubmodule.lie_le_inf exact LieSubmodule.lie_mem_lie j.2 hx -- Indeed `J ⊓ I = ⊥`, since `J` is an atom that is not contained in `I`. apply ((hs hJs).le_iff.mp _).resolve_right · contrapose! hJI rw [← hJI] exact inf_le_right exact inf_le_left termination_by s => s.card decreasing_by exact Finset.card_lt_card hs' variable (R L) in lemma booleanGenerators : BooleanGenerators {I : LieIdeal R L | IsAtom I} where isAtom _ hI := hI finitelyAtomistic _ _ hs _ hIs := finitelyAtomistic _ hs _ hIs instance (priority := 100) instDistribLattice : DistribLattice (LieIdeal R L) := (booleanGenerators R L).distribLattice_of_sSup_eq_top sSup_atoms_eq_top noncomputable instance (priority := 100) instBooleanAlgebra : BooleanAlgebra (LieIdeal R L) := (booleanGenerators R L).booleanAlgebra_of_sSup_eq_top sSup_atoms_eq_top /-- A semisimple Lie algebra has trivial radical. -/ instance (priority := 100) instHasTrivialRadical : HasTrivialRadical R L := by rw [hasTrivialRadical_iff_no_abelian_ideals] intro I hI apply (eq_bot_or_exists_atom_le I).resolve_right rintro ⟨J, hJ, hJ'⟩ apply IsSemisimple.non_abelian_of_isAtom J hJ constructor intro x y ext simp only [LieIdeal.coe_bracket_of_module, LieSubmodule.coe_bracket, ZeroMemClass.coe_zero] have : (⁅(⟨x, hJ' x.2⟩ : I), ⟨y, hJ' y.2⟩⁆ : I) = 0 := trivial_lie_zero _ _ _ _ apply_fun Subtype.val at this exact this end IsSemisimple /-- A simple Lie algebra is semisimple. -/ instance (priority := 100) IsSimple.instIsSemisimple [IsSimple R L] : IsSemisimple R L := by constructor · simp · simpa using CompleteLattice.setIndependent_singleton _ · intro I hI₁ hI₂ apply IsSimple.non_abelian (R := R) (L := L) rw [IsSimple.isAtom_iff_eq_top] at hI₁ rwa [hI₁, lie_abelian_iff_equiv_lie_abelian LieIdeal.topEquiv] at hI₂ /-- An abelian Lie algebra with trivial radical is trivial. -/ theorem subsingleton_of_hasTrivialRadical_lie_abelian [HasTrivialRadical R L] [h : IsLieAbelian L] : Subsingleton L := by rw [isLieAbelian_iff_center_eq_top R L, HasTrivialRadical.center_eq_bot] at h exact (LieSubmodule.subsingleton_iff R L L).mp (subsingleton_of_bot_eq_top h) theorem abelian_radical_of_hasTrivialRadical [HasTrivialRadical R L] : IsLieAbelian (radical R L) := by rw [HasTrivialRadical.radical_eq_bot]; infer_instance /-- The two properties shown to be equivalent here are possible definitions for a Lie algebra to be reductive. Note that there is absolutely [no agreement](https://mathoverflow.net/questions/284713/) on what the label 'reductive' should mean when the coefficients are not a field of characteristic zero. -/ theorem abelian_radical_iff_solvable_is_abelian [IsNoetherian R L] : IsLieAbelian (radical R L) ↔ ∀ I : LieIdeal R L, IsSolvable R I → IsLieAbelian I := by constructor · rintro h₁ I h₂ rw [LieIdeal.solvable_iff_le_radical] at h₂ exact (LieIdeal.inclusion_injective h₂).isLieAbelian h₁ · intro h; apply h; infer_instance theorem ad_ker_eq_bot_of_hasTrivialRadical [HasTrivialRadical R L] : (ad R L).ker = ⊥ := by simp end LieAlgebra
Algebra\Lie\Semisimple\Defs.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash, Johan Commelin -/ import Mathlib.Algebra.Lie.Solvable /-! # Semisimple Lie algebras In this file we define simple and semisimple Lie algebras, together with related concepts. ## Main declarations * `LieModule.IsIrreducible` * `LieAlgebra.IsSimple` * `LieAlgebra.HasTrivialRadical` * `LieAlgebra.IsSemisimple` ## Tags lie algebra, radical, simple, semisimple -/ variable (R L M : Type*) variable [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] /-- A nontrivial Lie module is *irreducible* if its only Lie submodules are `⊥` and `⊤`. -/ abbrev LieModule.IsIrreducible : Prop := IsSimpleOrder (LieSubmodule R L M) namespace LieAlgebra /-- A Lie algebra *has trivial radical* if its radical is trivial. This is equivalent to having no non-trivial solvable ideals, and further equivalent to having no non-trivial abelian ideals. In characteristic zero, it is also equivalent to `LieAlgebra.IsSemisimple`. Note that the label 'semisimple' is apparently not universally agreed [upon](https://mathoverflow.net/questions/149391/on-radicals-of-a-lie-algebra#comment383669_149391) for general coefficients. For example [Seligman, page 15](seligman1967) uses the label for `LieAlgebra.HasTrivialRadical`, whereas we reserve it for Lie algebras that are a direct sum of simple Lie algebras. -/ class HasTrivialRadical : Prop where radical_eq_bot : radical R L = ⊥ export HasTrivialRadical (radical_eq_bot) attribute [simp] radical_eq_bot /-- A Lie algebra is simple if it is irreducible as a Lie module over itself via the adjoint action, and it is non-Abelian. -/ class IsSimple : Prop where eq_bot_or_eq_top : ∀ I : LieIdeal R L, I = ⊥ ∨ I = ⊤ non_abelian : ¬IsLieAbelian L /-- A *semisimple* Lie algebra is one that is a direct sum of non-abelian atomic ideals. These ideals are simple Lie algebras, by `LieAlgebra.IsSemisimple.isSimple_of_isAtom`. Note that the label 'semisimple' is apparently not universally agreed [upon](https://mathoverflow.net/questions/149391/on-radicals-of-a-lie-algebra#comment383669_149391) for general coefficients. For example [Seligman, page 15](seligman1967) uses the label for `LieAlgebra.HasTrivialRadical`, the weakest of the various properties which are all equivalent over a field of characteristic zero. -/ class IsSemisimple : Prop where /-- In a semisimple Lie algebra, the supremum of the atoms is the whole Lie algebra. -/ sSup_atoms_eq_top : sSup {I : LieIdeal R L | IsAtom I} = ⊤ /-- In a semisimple Lie algebra, the atoms are independent. -/ setIndependent_isAtom : CompleteLattice.SetIndependent {I : LieIdeal R L | IsAtom I} /-- In a semisimple Lie algebra, the atoms are non-abelian. -/ non_abelian_of_isAtom : ∀ I : LieIdeal R L, IsAtom I → ¬ IsLieAbelian I end LieAlgebra
Algebra\Lie\Weights\Basic.lean
/- Copyright (c) 2021 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Ring.Divisibility.Lemmas import Mathlib.Algebra.Lie.Nilpotent import Mathlib.Algebra.Lie.Engel import Mathlib.LinearAlgebra.Eigenspace.Triangularizable import Mathlib.RingTheory.Artinian import Mathlib.LinearAlgebra.Trace import Mathlib.LinearAlgebra.FreeModule.PID /-! # Weight spaces of Lie modules of nilpotent Lie algebras Just as a key tool when studying the behaviour of a linear operator is to decompose the space on which it acts into a sum of (generalised) eigenspaces, a key tool when studying a representation `M` of Lie algebra `L` is to decompose `M` into a sum of simultaneous eigenspaces of `x` as `x` ranges over `L`. These simultaneous generalised eigenspaces are known as the weight spaces of `M`. When `L` is nilpotent, it follows from the binomial theorem that weight spaces are Lie submodules. Basic definitions and properties of the above ideas are provided in this file. ## Main definitions * `LieModule.weightSpaceOf` * `LieModule.weightSpace` * `LieModule.Weight` * `LieModule.posFittingCompOf` * `LieModule.posFittingComp` * `LieModule.iSup_ucs_eq_weightSpace_zero` * `LieModule.iInf_lowerCentralSeries_eq_posFittingComp` * `LieModule.isCompl_weightSpace_zero_posFittingComp` * `LieModule.independent_weightSpace` * `LieModule.iSup_weightSpace_eq_top` ## References * [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 7--9*](bourbaki1975b) ## Tags lie character, eigenvalue, eigenspace, weight, weight vector, root, root vector -/ variable {K R L M : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] [LieAlgebra.IsNilpotent R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieModule open Set Function LieAlgebra TensorProduct TensorProduct.LieModule open scoped TensorProduct section notation_weightSpaceOf /-- Until we define `LieModule.weightSpaceOf`, it is useful to have some notation as follows: -/ local notation3 "𝕎("M", " χ", " x")" => (toEnd R L M x).maxGenEigenspace χ /-- See also `bourbaki1975b` Chapter VII §1.1, Proposition 2 (ii). -/ protected theorem weight_vector_multiplication (M₁ M₂ M₃ : Type*) [AddCommGroup M₁] [Module R M₁] [LieRingModule L M₁] [LieModule R L M₁] [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂] [AddCommGroup M₃] [Module R M₃] [LieRingModule L M₃] [LieModule R L M₃] (g : M₁ ⊗[R] M₂ →ₗ⁅R,L⁆ M₃) (χ₁ χ₂ : R) (x : L) : LinearMap.range ((g : M₁ ⊗[R] M₂ →ₗ[R] M₃).comp (mapIncl 𝕎(M₁, χ₁, x) 𝕎(M₂, χ₂, x))) ≤ 𝕎(M₃, χ₁ + χ₂, x) := by -- Unpack the statement of the goal. intro m₃ simp only [TensorProduct.mapIncl, LinearMap.mem_range, LinearMap.coe_comp, LieModuleHom.coe_toLinearMap, Function.comp_apply, Pi.add_apply, exists_imp, Module.End.mem_maxGenEigenspace] rintro t rfl -- Set up some notation. let F : Module.End R M₃ := toEnd R L M₃ x - (χ₁ + χ₂) • ↑1 -- The goal is linear in `t` so use induction to reduce to the case that `t` is a pure tensor. refine t.induction_on ?_ ?_ ?_ · use 0; simp only [LinearMap.map_zero, LieModuleHom.map_zero] swap · rintro t₁ t₂ ⟨k₁, hk₁⟩ ⟨k₂, hk₂⟩; use max k₁ k₂ simp only [LieModuleHom.map_add, LinearMap.map_add, LinearMap.pow_map_zero_of_le (le_max_left k₁ k₂) hk₁, LinearMap.pow_map_zero_of_le (le_max_right k₁ k₂) hk₂, add_zero] -- Now the main argument: pure tensors. rintro ⟨m₁, hm₁⟩ ⟨m₂, hm₂⟩ change ∃ k, (F ^ k) ((g : M₁ ⊗[R] M₂ →ₗ[R] M₃) (m₁ ⊗ₜ m₂)) = (0 : M₃) -- Eliminate `g` from the picture. let f₁ : Module.End R (M₁ ⊗[R] M₂) := (toEnd R L M₁ x - χ₁ • ↑1).rTensor M₂ let f₂ : Module.End R (M₁ ⊗[R] M₂) := (toEnd R L M₂ x - χ₂ • ↑1).lTensor M₁ have h_comm_square : F ∘ₗ ↑g = (g : M₁ ⊗[R] M₂ →ₗ[R] M₃).comp (f₁ + f₂) := by ext m₁ m₂ simp only [f₁, f₂, F, ← g.map_lie x (m₁ ⊗ₜ m₂), add_smul, sub_tmul, tmul_sub, smul_tmul, lie_tmul_right, tmul_smul, toEnd_apply_apply, LieModuleHom.map_smul, LinearMap.one_apply, LieModuleHom.coe_toLinearMap, LinearMap.smul_apply, Function.comp_apply, LinearMap.coe_comp, LinearMap.rTensor_tmul, LieModuleHom.map_add, LinearMap.add_apply, LieModuleHom.map_sub, LinearMap.sub_apply, LinearMap.lTensor_tmul, AlgebraTensorModule.curry_apply, TensorProduct.curry_apply, LinearMap.toFun_eq_coe, LinearMap.coe_restrictScalars] abel rsuffices ⟨k, hk⟩ : ∃ k : ℕ, ((f₁ + f₂) ^ k) (m₁ ⊗ₜ m₂) = 0 · use k change (F ^ k) (g.toLinearMap (m₁ ⊗ₜ[R] m₂)) = 0 rw [← LinearMap.comp_apply, LinearMap.commute_pow_left_of_commute h_comm_square, LinearMap.comp_apply, hk, LinearMap.map_zero] -- Unpack the information we have about `m₁`, `m₂`. simp only [Module.End.mem_maxGenEigenspace] at hm₁ hm₂ obtain ⟨k₁, hk₁⟩ := hm₁ obtain ⟨k₂, hk₂⟩ := hm₂ have hf₁ : (f₁ ^ k₁) (m₁ ⊗ₜ m₂) = 0 := by simp only [f₁, hk₁, zero_tmul, LinearMap.rTensor_tmul, LinearMap.rTensor_pow] have hf₂ : (f₂ ^ k₂) (m₁ ⊗ₜ m₂) = 0 := by simp only [f₂, hk₂, tmul_zero, LinearMap.lTensor_tmul, LinearMap.lTensor_pow] -- It's now just an application of the binomial theorem. use k₁ + k₂ - 1 have hf_comm : Commute f₁ f₂ := by ext m₁ m₂ simp only [f₁, f₂, LinearMap.mul_apply, LinearMap.rTensor_tmul, LinearMap.lTensor_tmul, AlgebraTensorModule.curry_apply, LinearMap.toFun_eq_coe, LinearMap.lTensor_tmul, TensorProduct.curry_apply, LinearMap.coe_restrictScalars] rw [hf_comm.add_pow'] simp only [TensorProduct.mapIncl, Submodule.subtype_apply, Finset.sum_apply, Submodule.coe_mk, LinearMap.coeFn_sum, TensorProduct.map_tmul, LinearMap.smul_apply] -- The required sum is zero because each individual term is zero. apply Finset.sum_eq_zero rintro ⟨i, j⟩ hij -- Eliminate the binomial coefficients from the picture. suffices (f₁ ^ i * f₂ ^ j) (m₁ ⊗ₜ m₂) = 0 by rw [this]; apply smul_zero -- Finish off with appropriate case analysis. cases' Nat.le_or_le_of_add_eq_add_pred (Finset.mem_antidiagonal.mp hij) with hi hj · rw [(hf_comm.pow_pow i j).eq, LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hi hf₁, LinearMap.map_zero] · rw [LinearMap.mul_apply, LinearMap.pow_map_zero_of_le hj hf₂, LinearMap.map_zero] lemma lie_mem_maxGenEigenspace_toEnd {χ₁ χ₂ : R} {x y : L} {m : M} (hy : y ∈ 𝕎(L, χ₁, x)) (hm : m ∈ 𝕎(M, χ₂, x)) : ⁅y, m⁆ ∈ 𝕎(M, χ₁ + χ₂, x) := by apply LieModule.weight_vector_multiplication L M M (toModuleHom R L M) χ₁ χ₂ simp only [LieModuleHom.coe_toLinearMap, Function.comp_apply, LinearMap.coe_comp, TensorProduct.mapIncl, LinearMap.mem_range] use ⟨y, hy⟩ ⊗ₜ ⟨m, hm⟩ simp only [Submodule.subtype_apply, toModuleHom_apply, TensorProduct.map_tmul] variable (M) /-- If `M` is a representation of a nilpotent Lie algebra `L`, `χ` is a scalar, and `x : L`, then `weightSpaceOf M χ x` is the maximal generalized `χ`-eigenspace of the action of `x` on `M`. It is a Lie submodule because `L` is nilpotent. -/ def weightSpaceOf (χ : R) (x : L) : LieSubmodule R L M := { 𝕎(M, χ, x) with lie_mem := by intro y m hm simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid] at hm ⊢ rw [← zero_add χ] exact lie_mem_maxGenEigenspace_toEnd (by simp) hm } end notation_weightSpaceOf variable (M) theorem mem_weightSpaceOf (χ : R) (x : L) (m : M) : m ∈ weightSpaceOf M χ x ↔ ∃ k : ℕ, ((toEnd R L M x - χ • ↑1) ^ k) m = 0 := by simp [weightSpaceOf] theorem coe_weightSpaceOf_zero (x : L) : ↑(weightSpaceOf M (0 : R) x) = ⨆ k, LinearMap.ker (toEnd R L M x ^ k) := by simp [weightSpaceOf, Module.End.maxGenEigenspace] /-- If `M` is a representation of a nilpotent Lie algebra `L` and `χ : L → R` is a family of scalars, then `weightSpace M χ` is the intersection of the maximal generalized `χ x`-eigenspaces of the action of `x` on `M` as `x` ranges over `L`. It is a Lie submodule because `L` is nilpotent. -/ def weightSpace (χ : L → R) : LieSubmodule R L M := ⨅ x, weightSpaceOf M (χ x) x theorem mem_weightSpace (χ : L → R) (m : M) : m ∈ weightSpace M χ ↔ ∀ x, ∃ k : ℕ, ((toEnd R L M x - χ x • ↑1) ^ k) m = 0 := by simp [weightSpace, mem_weightSpaceOf] lemma weightSpace_le_weightSpaceOf (x : L) (χ : L → R) : weightSpace M χ ≤ weightSpaceOf M (χ x) x := iInf_le _ x variable (R L) in /-- A weight of a Lie module is a map `L → R` such that the corresponding weight space is non-trivial. -/ structure Weight where /-- The family of eigenvalues corresponding to a weight. -/ toFun : L → R weightSpace_ne_bot' : weightSpace M toFun ≠ ⊥ namespace Weight instance instFunLike : FunLike (Weight R L M) L R where coe χ := χ.1 coe_injective' χ₁ χ₂ h := by cases χ₁; cases χ₂; simp_all @[simp] lemma coe_weight_mk (χ : L → R) (h) : (↑(⟨χ, h⟩ : Weight R L M) : L → R) = χ := rfl lemma weightSpace_ne_bot (χ : Weight R L M) : weightSpace M χ ≠ ⊥ := χ.weightSpace_ne_bot' variable {M} @[ext] lemma ext {χ₁ χ₂ : Weight R L M} (h : ∀ x, χ₁ x = χ₂ x) : χ₁ = χ₂ := by cases' χ₁ with f₁ _; cases' χ₂ with f₂ _; aesop lemma ext_iff' {χ₁ χ₂ : Weight R L M} : (χ₁ : L → R) = χ₂ ↔ χ₁ = χ₂ := by aesop lemma exists_ne_zero (χ : Weight R L M) : ∃ x ∈ weightSpace M χ, x ≠ 0 := by simpa [LieSubmodule.eq_bot_iff] using χ.weightSpace_ne_bot instance [Subsingleton M] : IsEmpty (Weight R L M) := ⟨fun h ↦ h.2 (Subsingleton.elim _ _)⟩ instance [Nontrivial (weightSpace M (0 : L → R))] : Zero (Weight R L M) := ⟨0, fun e ↦ not_nontrivial (⊥ : LieSubmodule R L M) (e ▸ ‹_›)⟩ @[simp] lemma coe_zero [Nontrivial (weightSpace M (0 : L → R))] : ((0 : Weight R L M) : L → R) = 0 := rfl lemma zero_apply [Nontrivial (weightSpace M (0 : L → R))] (x) : (0 : Weight R L M) x = 0 := rfl /-- The proposition that a weight of a Lie module is zero. We make this definition because we cannot define a `Zero (Weight R L M)` instance since the weight space of the zero function can be trivial. -/ def IsZero (χ : Weight R L M) := (χ : L → R) = 0 @[simp] lemma IsZero.eq {χ : Weight R L M} (hχ : χ.IsZero) : (χ : L → R) = 0 := hχ @[simp] lemma coe_eq_zero_iff (χ : Weight R L M) : (χ : L → R) = 0 ↔ χ.IsZero := Iff.rfl lemma isZero_iff_eq_zero [Nontrivial (weightSpace M (0 : L → R))] {χ : Weight R L M} : χ.IsZero ↔ χ = 0 := Weight.ext_iff' (χ₂ := 0) lemma isZero_zero [Nontrivial (weightSpace M (0 : L → R))] : IsZero (0 : Weight R L M) := rfl /-- The proposition that a weight of a Lie module is non-zero. -/ abbrev IsNonZero (χ : Weight R L M) := ¬ IsZero (χ : Weight R L M) lemma isNonZero_iff_ne_zero [Nontrivial (weightSpace M (0 : L → R))] {χ : Weight R L M} : χ.IsNonZero ↔ χ ≠ 0 := isZero_iff_eq_zero.not variable (R L M) in /-- The set of weights is equivalent to a subtype. -/ def equivSetOf : Weight R L M ≃ {χ : L → R | weightSpace M χ ≠ ⊥} where toFun w := ⟨w.1, w.2⟩ invFun w := ⟨w.1, w.2⟩ left_inv w := by simp right_inv w := by simp lemma weightSpaceOf_ne_bot (χ : Weight R L M) (x : L) : weightSpaceOf M (χ x) x ≠ ⊥ := by have : ⨅ x, weightSpaceOf M (χ x) x ≠ ⊥ := χ.weightSpace_ne_bot contrapose! this rw [eq_bot_iff] exact le_of_le_of_eq (iInf_le _ _) this lemma hasEigenvalueAt (χ : Weight R L M) (x : L) : (toEnd R L M x).HasEigenvalue (χ x) := by obtain ⟨k : ℕ, hk : (toEnd R L M x).genEigenspace (χ x) k ≠ ⊥⟩ := by simpa [Module.End.maxGenEigenspace, weightSpaceOf] using χ.weightSpaceOf_ne_bot x exact Module.End.hasEigenvalue_of_hasGenEigenvalue hk lemma apply_eq_zero_of_isNilpotent [NoZeroSMulDivisors R M] [IsReduced R] (x : L) (h : _root_.IsNilpotent (toEnd R L M x)) (χ : Weight R L M) : χ x = 0 := ((χ.hasEigenvalueAt x).isNilpotent_of_isNilpotent h).eq_zero end Weight /-- See also the more useful form `LieModule.zero_weightSpace_eq_top_of_nilpotent`. -/ @[simp] theorem zero_weightSpace_eq_top_of_nilpotent' [IsNilpotent R L M] : weightSpace M (0 : L → R) = ⊤ := by ext simp [weightSpace, weightSpaceOf] theorem coe_weightSpace_of_top (χ : L → R) : (weightSpace M (χ ∘ (⊤ : LieSubalgebra R L).incl) : Submodule R M) = weightSpace M χ := by ext m simp only [mem_weightSpace, LieSubmodule.mem_coeSubmodule, Subtype.forall] apply forall_congr' simp @[simp] theorem zero_weightSpace_eq_top_of_nilpotent [IsNilpotent R L M] : weightSpace M (0 : (⊤ : LieSubalgebra R L) → R) = ⊤ := by ext m simp only [mem_weightSpace, Pi.zero_apply, zero_smul, sub_zero, Subtype.forall, forall_true_left, LieSubalgebra.toEnd_mk, LieSubalgebra.mem_top, LieSubmodule.mem_top, iff_true] intro x obtain ⟨k, hk⟩ := exists_forall_pow_toEnd_eq_zero R L M exact ⟨k, by simp [hk x]⟩ theorem exists_weightSpace_le_ker_of_isNoetherian [IsNoetherian R M] (χ : L → R) (x : L) : ∃ k : ℕ, weightSpace M χ ≤ LinearMap.ker ((toEnd R L M x - algebraMap R _ (χ x)) ^ k) := by use (toEnd R L M x).maxGenEigenspaceIndex (χ x) intro m hm replace hm : m ∈ (toEnd R L M x).maxGenEigenspace (χ x) := weightSpace_le_weightSpaceOf M x χ hm rwa [Module.End.maxGenEigenspace_eq] at hm variable (R) in theorem exists_weightSpace_zero_le_ker_of_isNoetherian [IsNoetherian R M] (x : L) : ∃ k : ℕ, weightSpace M (0 : L → R) ≤ LinearMap.ker (toEnd R L M x ^ k) := by simpa using exists_weightSpace_le_ker_of_isNoetherian M (0 : L → R) x lemma isNilpotent_toEnd_sub_algebraMap [IsNoetherian R M] (χ : L → R) (x : L) : _root_.IsNilpotent <| toEnd R L (weightSpace M χ) x - algebraMap R _ (χ x) := by have : toEnd R L (weightSpace M χ) x - algebraMap R _ (χ x) = (toEnd R L M x - algebraMap R _ (χ x)).restrict (fun m hm ↦ sub_mem (LieSubmodule.lie_mem _ hm) (Submodule.smul_mem _ _ hm)) := by rfl obtain ⟨k, hk⟩ := exists_weightSpace_le_ker_of_isNoetherian M χ x use k ext ⟨m, hm⟩ simpa [this, LinearMap.pow_restrict _, LinearMap.restrict_apply] using hk hm /-- A (nilpotent) Lie algebra acts nilpotently on the zero weight space of a Noetherian Lie module. -/ theorem isNilpotent_toEnd_weightSpace_zero [IsNoetherian R M] (x : L) : _root_.IsNilpotent <| toEnd R L (weightSpace M (0 : L → R)) x := by simpa using isNilpotent_toEnd_sub_algebraMap M (0 : L → R) x /-- By Engel's theorem, the zero weight space of a Noetherian Lie module is nilpotent. -/ instance [IsNoetherian R M] : IsNilpotent R L (weightSpace M (0 : L → R)) := isNilpotent_iff_forall'.mpr <| isNilpotent_toEnd_weightSpace_zero M variable (R L) @[simp] lemma weightSpace_zero_normalizer_eq_self : (weightSpace M (0 : L → R)).normalizer = weightSpace M 0 := by refine le_antisymm ?_ (LieSubmodule.le_normalizer _) intro m hm rw [LieSubmodule.mem_normalizer] at hm simp only [mem_weightSpace, Pi.zero_apply, zero_smul, sub_zero] at hm ⊢ intro y obtain ⟨k, hk⟩ := hm y y use k + 1 simpa [pow_succ, LinearMap.mul_eq_comp] lemma iSup_ucs_le_weightSpace_zero : ⨆ k, (⊥ : LieSubmodule R L M).ucs k ≤ weightSpace M (0 : L → R) := by simpa using LieSubmodule.ucs_le_of_normalizer_eq_self (weightSpace_zero_normalizer_eq_self R L M) /-- See also `LieModule.iInf_lowerCentralSeries_eq_posFittingComp`. -/ lemma iSup_ucs_eq_weightSpace_zero [IsNoetherian R M] : ⨆ k, (⊥ : LieSubmodule R L M).ucs k = weightSpace M (0 : L → R) := by obtain ⟨k, hk⟩ := (LieSubmodule.isNilpotent_iff_exists_self_le_ucs <| weightSpace M (0 : L → R)).mp inferInstance refine le_antisymm (iSup_ucs_le_weightSpace_zero R L M) (le_trans hk ?_) exact le_iSup (fun k ↦ (⊥ : LieSubmodule R L M).ucs k) k variable {L} /-- If `M` is a representation of a nilpotent Lie algebra `L`, and `x : L`, then `posFittingCompOf R M x` is the infimum of the decreasing system `range φₓ ⊇ range φₓ² ⊇ range φₓ³ ⊇ ⋯` where `φₓ : End R M := toEnd R L M x`. We call this the "positive Fitting component" because with appropriate assumptions (e.g., `R` is a field and `M` is finite-dimensional) `φₓ` induces the so-called Fitting decomposition: `M = M₀ ⊕ M₁` where `M₀ = weightSpaceOf M 0 x` and `M₁ = posFittingCompOf R M x`. It is a Lie submodule because `L` is nilpotent. -/ def posFittingCompOf (x : L) : LieSubmodule R L M := { toSubmodule := ⨅ k, LinearMap.range (toEnd R L M x ^ k) lie_mem := by set φ := toEnd R L M x intros y m hm simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, Submodule.mem_iInf, LinearMap.mem_range] at hm ⊢ intro k obtain ⟨N, hN⟩ := LieAlgebra.nilpotent_ad_of_nilpotent_algebra R L obtain ⟨m, rfl⟩ := hm (N + k) let f₁ : Module.End R (L ⊗[R] M) := (LieAlgebra.ad R L x).rTensor M let f₂ : Module.End R (L ⊗[R] M) := φ.lTensor L replace hN : f₁ ^ N = 0 := by ext; simp [f₁, hN] have h₁ : Commute f₁ f₂ := by ext; simp [f₁, f₂] have h₂ : φ ∘ₗ toModuleHom R L M = toModuleHom R L M ∘ₗ (f₁ + f₂) := by ext; simp [φ, f₁, f₂] obtain ⟨q, hq⟩ := h₁.add_pow_dvd_pow_of_pow_eq_zero_right (N + k).le_succ hN use toModuleHom R L M (q (y ⊗ₜ m)) change (φ ^ k).comp ((toModuleHom R L M : L ⊗[R] M →ₗ[R] M)) _ = _ simp [φ, f₁, f₂, LinearMap.commute_pow_left_of_commute h₂, LinearMap.comp_apply (g := (f₁ + f₂) ^ k), ← LinearMap.comp_apply (g := q), ← LinearMap.mul_eq_comp, ← hq] } variable {M} in lemma mem_posFittingCompOf (x : L) (m : M) : m ∈ posFittingCompOf R M x ↔ ∀ (k : ℕ), ∃ n, (toEnd R L M x ^ k) n = m := by simp [posFittingCompOf] @[simp] lemma posFittingCompOf_le_lowerCentralSeries (x : L) (k : ℕ) : posFittingCompOf R M x ≤ lowerCentralSeries R L M k := by suffices ∀ m l, (toEnd R L M x ^ l) m ∈ lowerCentralSeries R L M l by intro m hm obtain ⟨n, rfl⟩ := (mem_posFittingCompOf R x m).mp hm k exact this n k intro m l induction' l with l ih · simp simp only [lowerCentralSeries_succ, pow_succ', LinearMap.mul_apply] exact LieSubmodule.lie_mem_lie (LieSubmodule.mem_top x) ih @[simp] lemma posFittingCompOf_eq_bot_of_isNilpotent [IsNilpotent R L M] (x : L) : posFittingCompOf R M x = ⊥ := by simp_rw [eq_bot_iff, ← iInf_lowerCentralSeries_eq_bot_of_isNilpotent, le_iInf_iff, posFittingCompOf_le_lowerCentralSeries, forall_const] variable (L) /-- If `M` is a representation of a nilpotent Lie algebra `L` with coefficients in `R`, then `posFittingComp R L M` is the span of the positive Fitting components of the action of `x` on `M`, as `x` ranges over `L`. It is a Lie submodule because `L` is nilpotent. -/ def posFittingComp : LieSubmodule R L M := ⨆ x, posFittingCompOf R M x lemma mem_posFittingComp (m : M) : m ∈ posFittingComp R L M ↔ m ∈ ⨆ (x : L), posFittingCompOf R M x := by rfl lemma posFittingCompOf_le_posFittingComp (x : L) : posFittingCompOf R M x ≤ posFittingComp R L M := by rw [posFittingComp]; exact le_iSup (posFittingCompOf R M) x lemma posFittingComp_le_iInf_lowerCentralSeries : posFittingComp R L M ≤ ⨅ k, lowerCentralSeries R L M k := by simp [posFittingComp] /-- See also `LieModule.iSup_ucs_eq_weightSpace_zero`. -/ @[simp] lemma iInf_lowerCentralSeries_eq_posFittingComp [IsNoetherian R M] [IsArtinian R M] : ⨅ k, lowerCentralSeries R L M k = posFittingComp R L M := by refine le_antisymm ?_ (posFittingComp_le_iInf_lowerCentralSeries R L M) apply iInf_lcs_le_of_isNilpotent_quot rw [LieModule.isNilpotent_iff_forall'] intro x obtain ⟨k, hk⟩ := Filter.eventually_atTop.mp (toEnd R L M x).eventually_iInf_range_pow_eq use k ext ⟨m⟩ set F := posFittingComp R L M replace hk : (toEnd R L M x ^ k) m ∈ F := by apply posFittingCompOf_le_posFittingComp R L M x simp_rw [← LieSubmodule.mem_coeSubmodule, posFittingCompOf, hk k (le_refl k)] apply LinearMap.mem_range_self suffices (toEnd R L (M ⧸ F) x ^ k) (LieSubmodule.Quotient.mk (N := F) m) = LieSubmodule.Quotient.mk (N := F) ((toEnd R L M x ^ k) m) by simpa [this] have := LinearMap.congr_fun (LinearMap.commute_pow_left_of_commute (LieSubmodule.Quotient.toEnd_comp_mk' F x) k) m simpa using this @[simp] lemma posFittingComp_eq_bot_of_isNilpotent [IsNilpotent R L M] : posFittingComp R L M = ⊥ := by simp [posFittingComp] section map_comap variable {R L M} variable {M₂ : Type*} [AddCommGroup M₂] [Module R M₂] [LieRingModule L M₂] [LieModule R L M₂] {χ : L → R} (f : M →ₗ⁅R,L⁆ M₂) lemma map_posFittingComp_le : (posFittingComp R L M).map f ≤ posFittingComp R L M₂ := by rw [posFittingComp, posFittingComp, LieSubmodule.map_iSup] refine iSup_mono fun y ↦ LieSubmodule.map_le_iff_le_comap.mpr fun m hm ↦ ?_ simp only [mem_posFittingCompOf] at hm simp only [LieSubmodule.mem_comap, mem_posFittingCompOf] intro k obtain ⟨n, hn⟩ := hm k use f n rw [LieModule.toEnd_pow_apply_map, hn] lemma map_weightSpace_le : (weightSpace M χ).map f ≤ weightSpace M₂ χ := by rw [LieSubmodule.map_le_iff_le_comap] intro m hm simp only [LieSubmodule.mem_comap, mem_weightSpace] intro x have : (toEnd R L M₂ x - χ x • ↑1) ∘ₗ f = f ∘ₗ (toEnd R L M x - χ x • ↑1) := by ext; simp obtain ⟨k, h⟩ := (mem_weightSpace _ _ _).mp hm x exact ⟨k, by simpa [h] using LinearMap.congr_fun (LinearMap.commute_pow_left_of_commute this k) m⟩ variable {f} lemma comap_weightSpace_eq_of_injective (hf : Injective f) : (weightSpace M₂ χ).comap f = weightSpace M χ := by refine le_antisymm (fun m hm ↦ ?_) ?_ · simp only [LieSubmodule.mem_comap, mem_weightSpace] at hm simp only [mem_weightSpace] intro x have h : (toEnd R L M₂ x - χ x • ↑1) ∘ₗ f = f ∘ₗ (toEnd R L M x - χ x • ↑1) := by ext; simp obtain ⟨k, hk⟩ := hm x use k suffices f (((toEnd R L M x - χ x • ↑1) ^ k) m) = 0 by rw [← f.map_zero] at this; exact hf this simpa [hk] using (LinearMap.congr_fun (LinearMap.commute_pow_left_of_commute h k) m).symm · rw [← LieSubmodule.map_le_iff_le_comap] exact map_weightSpace_le f lemma map_weightSpace_eq_of_injective (hf : Injective f) : (weightSpace M χ).map f = weightSpace M₂ χ ⊓ f.range := by refine le_antisymm (le_inf_iff.mpr ⟨map_weightSpace_le f, LieSubmodule.map_le_range f⟩) ?_ rintro - ⟨hm, ⟨m, rfl⟩⟩ simp only [← comap_weightSpace_eq_of_injective hf, LieSubmodule.mem_map, LieSubmodule.mem_comap] exact ⟨m, hm, rfl⟩ lemma map_weightSpace_eq (e : M ≃ₗ⁅R,L⁆ M₂) : (weightSpace M χ).map e = weightSpace M₂ χ := by simp [map_weightSpace_eq_of_injective e.injective] lemma map_posFittingComp_eq (e : M ≃ₗ⁅R,L⁆ M₂) : (posFittingComp R L M).map e = posFittingComp R L M₂ := by refine le_antisymm (map_posFittingComp_le _) ?_ suffices posFittingComp R L M₂ = ((posFittingComp R L M₂).map (e.symm : M₂ →ₗ⁅R,L⁆ M)).map e by rw [this] exact LieSubmodule.map_mono (map_posFittingComp_le _) rw [← LieSubmodule.map_comp] convert LieSubmodule.map_id ext simp lemma posFittingComp_map_incl_sup_of_codisjoint [IsNoetherian R M] [IsArtinian R M] {N₁ N₂ : LieSubmodule R L M} (h : Codisjoint N₁ N₂) : (posFittingComp R L N₁).map N₁.incl ⊔ (posFittingComp R L N₂).map N₂.incl = posFittingComp R L M := by obtain ⟨l, hl⟩ := Filter.eventually_atTop.mp <| (eventually_iInf_lowerCentralSeries_eq R L N₁).and <| (eventually_iInf_lowerCentralSeries_eq R L N₂).and (eventually_iInf_lowerCentralSeries_eq R L M) obtain ⟨hl₁, hl₂, hl₃⟩ := hl l (le_refl _) simp_rw [← iInf_lowerCentralSeries_eq_posFittingComp, hl₁, hl₂, hl₃, LieSubmodule.lowerCentralSeries_map_eq_lcs, ← LieSubmodule.lcs_sup, lowerCentralSeries, h.eq_top] lemma weightSpace_weightSpaceOf_map_incl (x : L) (χ : L → R) : (weightSpace (weightSpaceOf M (χ x) x) χ).map (weightSpaceOf M (χ x) x).incl = weightSpace M χ := by simpa [map_weightSpace_eq_of_injective (weightSpaceOf M (χ x) x).injective_incl] using weightSpace_le_weightSpaceOf M x χ end map_comap section fitting_decomposition variable [IsNoetherian R M] [IsArtinian R M] lemma isCompl_weightSpaceOf_zero_posFittingCompOf (x : L) : IsCompl (weightSpaceOf M 0 x) (posFittingCompOf R M x) := by simpa only [isCompl_iff, codisjoint_iff, disjoint_iff, ← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.sup_coe_toSubmodule, LieSubmodule.inf_coe_toSubmodule, LieSubmodule.top_coeSubmodule, LieSubmodule.bot_coeSubmodule, coe_weightSpaceOf_zero] using (toEnd R L M x).isCompl_iSup_ker_pow_iInf_range_pow /-- This lemma exists only to simplify the proof of `LieModule.isCompl_weightSpace_zero_posFittingComp`. -/ private lemma isCompl_weightSpace_zero_posFittingComp_aux (h : ∀ N < (⊤ : LieSubmodule R L M), IsCompl (weightSpace N 0) (posFittingComp R L N)) : IsCompl (weightSpace M 0) (posFittingComp R L M) := by set M₀ := weightSpace M (0 : L → R) set M₁ := posFittingComp R L M rcases forall_or_exists_not (fun (x : L) ↦ weightSpaceOf M (0 : R) x = ⊤) with h | ⟨x, hx : weightSpaceOf M (0 : R) x ≠ ⊤⟩ · suffices IsNilpotent R L M by simp [M₀, M₁, isCompl_top_bot] replace h : M₀ = ⊤ := by simpa [M₀, weightSpace] rw [← LieModule.isNilpotent_of_top_iff', ← h] infer_instance · set M₀ₓ := weightSpaceOf M (0 : R) x set M₁ₓ := posFittingCompOf R M x set M₀ₓ₀ := weightSpace M₀ₓ (0 : L → R) set M₀ₓ₁ := posFittingComp R L M₀ₓ have h₁ : IsCompl M₀ₓ M₁ₓ := isCompl_weightSpaceOf_zero_posFittingCompOf R L M x have h₂ : IsCompl M₀ₓ₀ M₀ₓ₁ := h M₀ₓ hx.lt_top have h₃ : M₀ₓ₀.map M₀ₓ.incl = M₀ := by rw [map_weightSpace_eq_of_injective M₀ₓ.injective_incl, inf_eq_left, LieSubmodule.range_incl] exact iInf_le _ x have h₄ : M₀ₓ₁.map M₀ₓ.incl ⊔ M₁ₓ = M₁ := by apply le_antisymm <| sup_le_iff.mpr ⟨map_posFittingComp_le _, posFittingCompOf_le_posFittingComp R L M x⟩ rw [← posFittingComp_map_incl_sup_of_codisjoint h₁.codisjoint] exact sup_le_sup_left LieSubmodule.map_incl_le _ rw [← h₃, ← h₄] apply Disjoint.isCompl_sup_right_of_isCompl_sup_left · rw [disjoint_iff, ← LieSubmodule.map_inf M₀ₓ.injective_incl, h₂.inf_eq_bot, LieSubmodule.map_bot] · rwa [← LieSubmodule.map_sup, h₂.sup_eq_top, LieModuleHom.map_top, LieSubmodule.range_incl] /-- This is the Fitting decomposition of the Lie module `M`. -/ lemma isCompl_weightSpace_zero_posFittingComp : IsCompl (weightSpace M 0) (posFittingComp R L M) := by let P : LieSubmodule R L M → Prop := fun N ↦ IsCompl (weightSpace N 0) (posFittingComp R L N) suffices P ⊤ by let e := LieModuleEquiv.ofTop R L M rw [← map_weightSpace_eq e, ← map_posFittingComp_eq e] exact (LieSubmodule.orderIsoMapComap e).isCompl_iff.mp this refine (LieSubmodule.wellFounded_of_isArtinian R L M).induction (C := P) _ fun N hN ↦ ?_ refine isCompl_weightSpace_zero_posFittingComp_aux R L N fun N' hN' ↦ ?_ suffices IsCompl (weightSpace (N'.map N.incl) 0) (posFittingComp R L (N'.map N.incl)) by let e := LieSubmodule.equivMapOfInjective N' N.injective_incl rw [← map_weightSpace_eq e, ← map_posFittingComp_eq e] at this exact (LieSubmodule.orderIsoMapComap e).isCompl_iff.mpr this exact hN _ (LieSubmodule.map_incl_lt_iff_lt_top.mpr hN') end fitting_decomposition lemma disjoint_weightSpaceOf [NoZeroSMulDivisors R M] {x : L} {φ₁ φ₂ : R} (h : φ₁ ≠ φ₂) : Disjoint (weightSpaceOf M φ₁ x) (weightSpaceOf M φ₂ x) := by rw [LieSubmodule.disjoint_iff_coe_toSubmodule] exact Module.End.disjoint_iSup_genEigenspace _ h lemma disjoint_weightSpace [NoZeroSMulDivisors R M] {χ₁ χ₂ : L → R} (h : χ₁ ≠ χ₂) : Disjoint (weightSpace M χ₁) (weightSpace M χ₂) := by obtain ⟨x, hx⟩ : ∃ x, χ₁ x ≠ χ₂ x := Function.ne_iff.mp h exact (disjoint_weightSpaceOf R L M hx).mono (weightSpace_le_weightSpaceOf M x χ₁) (weightSpace_le_weightSpaceOf M x χ₂) lemma injOn_weightSpace [NoZeroSMulDivisors R M] : InjOn (fun (χ : L → R) ↦ weightSpace M χ) {χ | weightSpace M χ ≠ ⊥} := by rintro χ₁ _ χ₂ hχ₂ (hχ₁₂ : weightSpace M χ₁ = weightSpace M χ₂) contrapose! hχ₂ simpa [hχ₁₂] using disjoint_weightSpace R L M hχ₂ /-- Lie module weight spaces are independent. See also `LieModule.independent_weightSpace'`. -/ lemma independent_weightSpace [NoZeroSMulDivisors R M] : CompleteLattice.Independent fun (χ : L → R) ↦ weightSpace M χ := by classical suffices ∀ χ (s : Finset (L → R)) (_ : χ ∉ s), Disjoint (weightSpace M χ) (s.sup fun (χ : L → R) ↦ weightSpace M χ) by simpa only [CompleteLattice.independent_iff_supIndep_of_injOn (injOn_weightSpace R L M), Finset.supIndep_iff_disjoint_erase] using fun s χ _ ↦ this _ _ (s.not_mem_erase χ) intro χ₁ s induction' s using Finset.induction_on with χ₂ s _ ih · simp intro hχ₁₂ obtain ⟨hχ₁₂ : χ₁ ≠ χ₂, hχ₁ : χ₁ ∉ s⟩ := by rwa [Finset.mem_insert, not_or] at hχ₁₂ specialize ih hχ₁ rw [Finset.sup_insert, disjoint_iff, LieSubmodule.eq_bot_iff] rintro x ⟨hx, hx'⟩ simp only [SetLike.mem_coe, LieSubmodule.mem_coeSubmodule] at hx hx' suffices x ∈ weightSpace M χ₂ by rw [← LieSubmodule.mem_bot (R := R) (L := L), ← (disjoint_weightSpace R L M hχ₁₂).eq_bot] exact ⟨hx, this⟩ obtain ⟨y, hy, z, hz, rfl⟩ := (LieSubmodule.mem_sup _ _ _).mp hx'; clear hx' suffices ∀ l, ∃ (k : ℕ), ((toEnd R L M l - algebraMap R (Module.End R M) (χ₂ l)) ^ k) (y + z) ∈ weightSpace M χ₁ ⊓ Finset.sup s fun χ ↦ weightSpace M χ by simpa only [ih.eq_bot, LieSubmodule.mem_bot, mem_weightSpace] using this intro l let g : Module.End R M := toEnd R L M l - algebraMap R (Module.End R M) (χ₂ l) obtain ⟨k, hk : (g ^ k) y = 0⟩ := (mem_weightSpace _ _ _).mp hy l refine ⟨k, (LieSubmodule.mem_inf _ _ _).mp ⟨?_, ?_⟩⟩ · exact LieSubmodule.mapsTo_pow_toEnd_sub_algebraMap _ hx · rw [map_add, hk, zero_add] suffices (s.sup fun χ ↦ weightSpace M χ : Submodule R M).map (g ^ k) ≤ s.sup fun χ ↦ weightSpace M χ by refine this (Submodule.mem_map_of_mem ?_) simp_rw [← LieSubmodule.mem_coeSubmodule, Finset.sup_eq_iSup, LieSubmodule.iSup_coe_toSubmodule, ← Finset.sup_eq_iSup] at hz exact hz simp_rw [Finset.sup_eq_iSup, Submodule.map_iSup (ι := L → R), Submodule.map_iSup (ι := _ ∈ s), LieSubmodule.iSup_coe_toSubmodule] refine iSup₂_mono fun χ _ ↦ ?_ rintro - ⟨u, hu, rfl⟩ exact LieSubmodule.mapsTo_pow_toEnd_sub_algebraMap _ hu lemma independent_weightSpace' [NoZeroSMulDivisors R M] : CompleteLattice.Independent fun χ : Weight R L M ↦ weightSpace M χ := (independent_weightSpace R L M).comp <| Subtype.val_injective.comp (Weight.equivSetOf R L M).injective lemma independent_weightSpaceOf [NoZeroSMulDivisors R M] (x : L) : CompleteLattice.Independent fun (χ : R) ↦ weightSpaceOf M χ x := by rw [LieSubmodule.independent_iff_coe_toSubmodule] exact (toEnd R L M x).independent_genEigenspace lemma finite_weightSpaceOf_ne_bot [NoZeroSMulDivisors R M] [IsNoetherian R M] (x : L) : {χ : R | weightSpaceOf M χ x ≠ ⊥}.Finite := CompleteLattice.WellFounded.finite_ne_bot_of_independent (LieSubmodule.wellFounded_of_noetherian R L M) (independent_weightSpaceOf R L M x) lemma finite_weightSpace_ne_bot [NoZeroSMulDivisors R M] [IsNoetherian R M] : {χ : L → R | weightSpace M χ ≠ ⊥}.Finite := CompleteLattice.WellFounded.finite_ne_bot_of_independent (LieSubmodule.wellFounded_of_noetherian R L M) (independent_weightSpace R L M) instance Weight.instFinite [NoZeroSMulDivisors R M] [IsNoetherian R M] : Finite (Weight R L M) := by have : Finite {χ : L → R | weightSpace M χ ≠ ⊥} := finite_weightSpace_ne_bot R L M exact Finite.of_injective (equivSetOf R L M) (equivSetOf R L M).injective noncomputable instance Weight.instFintype [NoZeroSMulDivisors R M] [IsNoetherian R M] : Fintype (Weight R L M) := Fintype.ofFinite _ /-- A Lie module `M` of a Lie algebra `L` is triangularizable if the endomorhpism of `M` defined by any `x : L` is triangularizable. -/ class IsTriangularizable : Prop := iSup_eq_top : ∀ x, ⨆ φ, ⨆ k, (toEnd R L M x).genEigenspace φ k = ⊤ instance (L' : LieSubalgebra R L) [IsTriangularizable R L M] : IsTriangularizable R L' M where iSup_eq_top x := IsTriangularizable.iSup_eq_top (x : L) instance (I : LieIdeal R L) [IsTriangularizable R L M] : IsTriangularizable R I M where iSup_eq_top x := IsTriangularizable.iSup_eq_top (x : L) instance [IsTriangularizable R L M] : IsTriangularizable R (LieModule.toEnd R L M).range M where iSup_eq_top := by rintro ⟨-, x, rfl⟩; exact IsTriangularizable.iSup_eq_top x @[simp] lemma iSup_weightSpaceOf_eq_top [IsTriangularizable R L M] (x : L) : ⨆ (φ : R), weightSpaceOf M φ x = ⊤ := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.iSup_coe_toSubmodule, LieSubmodule.top_coeSubmodule] exact IsTriangularizable.iSup_eq_top x open LinearMap FiniteDimensional in @[simp] lemma trace_toEnd_weightSpace [IsDomain R] [IsPrincipalIdealRing R] [Module.Free R M] [Module.Finite R M] (χ : L → R) (x : L) : trace R _ (toEnd R L (weightSpace M χ) x) = finrank R (weightSpace M χ) • χ x := by suffices _root_.IsNilpotent ((toEnd R L (weightSpace M χ) x) - χ x • LinearMap.id) by replace this := (isNilpotent_trace_of_isNilpotent this).eq_zero rwa [map_sub, map_smul, trace_id, sub_eq_zero, smul_eq_mul, mul_comm, ← nsmul_eq_mul] at this rw [← Module.algebraMap_end_eq_smul_id] exact isNilpotent_toEnd_sub_algebraMap M χ x section field open FiniteDimensional variable (K) variable [Field K] [LieAlgebra K L] [Module K M] [LieModule K L M] [LieAlgebra.IsNilpotent K L] [FiniteDimensional K M] instance instIsTriangularizableOfIsAlgClosed [IsAlgClosed K] : IsTriangularizable K L M := ⟨fun _ ↦ Module.End.iSup_genEigenspace_eq_top _⟩ instance (N : LieSubmodule K L M) [IsTriangularizable K L M] : IsTriangularizable K L N := by refine ⟨fun y ↦ ?_⟩ rw [← N.toEnd_restrict_eq_toEnd y] exact Module.End.iSup_genEigenspace_restrict_eq_top _ (IsTriangularizable.iSup_eq_top y) /-- For a triangularizable Lie module in finite dimensions, the weight spaces span the entire space. See also `LieModule.iSup_weightSpace_eq_top'`. -/ lemma iSup_weightSpace_eq_top [IsTriangularizable K L M] : ⨆ χ : L → K, weightSpace M χ = ⊤ := by clear! R -- cf https://github.com/leanprover/lean4/issues/2452 induction' h_dim : finrank K M using Nat.strong_induction_on with n ih generalizing M obtain h' | ⟨y : L, hy : ¬ ∃ φ, weightSpaceOf M φ y = ⊤⟩ := forall_or_exists_not (fun (x : L) ↦ ∃ (φ : K), weightSpaceOf M φ x = ⊤) · choose χ hχ using h' replace hχ : weightSpace M χ = ⊤ := by simpa only [weightSpace, hχ] using iInf_top exact eq_top_iff.mpr <| hχ ▸ le_iSup (weightSpace M) χ · replace hy : ∀ φ, finrank K (weightSpaceOf M φ y) < n := fun φ ↦ by simp_rw [not_exists, ← lt_top_iff_ne_top] at hy; exact h_dim ▸ Submodule.finrank_lt (hy φ) replace ih : ∀ φ, ⨆ χ : L → K, weightSpace (weightSpaceOf M φ y) χ = ⊤ := fun φ ↦ ih _ (hy φ) (weightSpaceOf M φ y) rfl replace ih : ∀ φ, ⨆ (χ : L → K) (_ : χ y = φ), weightSpace (weightSpaceOf M φ y) χ = ⊤ := by intro φ suffices ∀ χ : L → K, χ y ≠ φ → weightSpace (weightSpaceOf M φ y) χ = ⊥ by specialize ih φ; rw [iSup_split, biSup_congr this] at ih; simpa using ih intro χ hχ rw [eq_bot_iff, ← (weightSpaceOf M φ y).ker_incl, LieModuleHom.ker, ← LieSubmodule.map_le_iff_le_comap, map_weightSpace_eq_of_injective (weightSpaceOf M φ y).injective_incl, LieSubmodule.range_incl, ← disjoint_iff_inf_le] exact (disjoint_weightSpaceOf K L M hχ).mono_left (weightSpace_le_weightSpaceOf M y χ) replace ih : ∀ φ, ⨆ (χ : L → K) (_ : χ y = φ), weightSpace M χ = weightSpaceOf M φ y := by intro φ have : ∀ (χ : L → K) (_ : χ y = φ), weightSpace M χ = (weightSpace (weightSpaceOf M φ y) χ).map (weightSpaceOf M φ y).incl := fun χ hχ ↦ by rw [← hχ, weightSpace_weightSpaceOf_map_incl] simp_rw [biSup_congr this, ← LieSubmodule.map_iSup, ih, LieModuleHom.map_top, LieSubmodule.range_incl] simpa only [← ih, iSup_comm (ι := K), iSup_iSup_eq_right] using iSup_weightSpaceOf_eq_top K L M y lemma iSup_weightSpace_eq_top' [IsTriangularizable K L M] : ⨆ χ : Weight K L M, weightSpace M χ = ⊤ := by have := iSup_weightSpace_eq_top K L M erw [← iSup_ne_bot_subtype, ← (Weight.equivSetOf K L M).iSup_comp] at this exact this end field end LieModule
Algebra\Lie\Weights\Cartan.lean
/- Copyright (c) 2023 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.CartanSubalgebra import Mathlib.Algebra.Lie.Weights.Basic /-! # Weights and roots of Lie modules and Lie algebras with respect to Cartan subalgebras Given a Lie algebra `L` which is not necessarily nilpotent, it may be useful to study its representations by restricting them to a nilpotent subalgebra (e.g., a Cartan subalgebra). In the particular case when we view `L` as a module over itself via the adjoint action, the weight spaces of `L` restricted to a nilpotent subalgebra are known as root spaces. Basic definitions and properties of the above ideas are provided in this file. ## Main definitions * `LieAlgebra.rootSpace` * `LieAlgebra.corootSpace` * `LieAlgebra.rootSpaceWeightSpaceProduct` * `LieAlgebra.rootSpaceProduct` * `LieAlgebra.zeroRootSubalgebra_eq_iff_is_cartan` -/ suppress_compilation open Set variable {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (H : LieSubalgebra R L) [LieAlgebra.IsNilpotent R H] {M : Type*} [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieAlgebra open scoped TensorProduct open TensorProduct.LieModule LieModule /-- Given a nilpotent Lie subalgebra `H ⊆ L`, the root space of a map `χ : H → R` is the weight space of `L` regarded as a module of `H` via the adjoint action. -/ abbrev rootSpace (χ : H → R) : LieSubmodule R H L := weightSpace L χ theorem zero_rootSpace_eq_top_of_nilpotent [IsNilpotent R L] : rootSpace (⊤ : LieSubalgebra R L) 0 = ⊤ := zero_weightSpace_eq_top_of_nilpotent L @[simp] theorem rootSpace_comap_eq_weightSpace (χ : H → R) : (rootSpace H χ).comap H.incl' = weightSpace H χ := comap_weightSpace_eq_of_injective Subtype.coe_injective variable {H} theorem lie_mem_weightSpace_of_mem_weightSpace {χ₁ χ₂ : H → R} {x : L} {m : M} (hx : x ∈ rootSpace H χ₁) (hm : m ∈ weightSpace M χ₂) : ⁅x, m⁆ ∈ weightSpace M (χ₁ + χ₂) := by rw [weightSpace, LieSubmodule.mem_iInf] intro y replace hx : x ∈ weightSpaceOf L (χ₁ y) y := by rw [rootSpace, weightSpace, LieSubmodule.mem_iInf] at hx; exact hx y replace hm : m ∈ weightSpaceOf M (χ₂ y) y := by rw [weightSpace, LieSubmodule.mem_iInf] at hm; exact hm y exact lie_mem_maxGenEigenspace_toEnd hx hm lemma toEnd_pow_apply_mem {χ₁ χ₂ : H → R} {x : L} {m : M} (hx : x ∈ rootSpace H χ₁) (hm : m ∈ weightSpace M χ₂) (n) : (toEnd R L M x ^ n : Module.End R M) m ∈ weightSpace M (n • χ₁ + χ₂) := by induction n with | zero => simpa using hm | succ n IH => simp only [pow_succ', LinearMap.mul_apply, toEnd_apply_apply, Nat.cast_add, Nat.cast_one, rootSpace] convert lie_mem_weightSpace_of_mem_weightSpace hx IH using 2 rw [succ_nsmul, ← add_assoc, add_comm (n • _)] variable (R L H M) /-- Auxiliary definition for `rootSpaceWeightSpaceProduct`, which is close to the deterministic timeout limit. -/ def rootSpaceWeightSpaceProductAux {χ₁ χ₂ χ₃ : H → R} (hχ : χ₁ + χ₂ = χ₃) : rootSpace H χ₁ →ₗ[R] weightSpace M χ₂ →ₗ[R] weightSpace M χ₃ where toFun x := { toFun := fun m => ⟨⁅(x : L), (m : M)⁆, hχ ▸ lie_mem_weightSpace_of_mem_weightSpace x.property m.property⟩ map_add' := fun m n => by simp only [LieSubmodule.coe_add, lie_add]; rfl map_smul' := fun t m => by dsimp only conv_lhs => congr rw [LieSubmodule.coe_smul, lie_smul] rfl } map_add' x y := by ext m simp only [AddSubmonoid.coe_add, Submodule.coe_toAddSubmonoid, add_lie, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply, AddSubmonoid.mk_add_mk] map_smul' t x := by simp only [RingHom.id_apply] ext m simp only [SetLike.val_smul, smul_lie, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.smul_apply, SetLike.mk_smul_mk] -- Porting note (#11083): this def is _really_ slow -- See https://github.com/leanprover-community/mathlib4/issues/5028 /-- Given a nilpotent Lie subalgebra `H ⊆ L` together with `χ₁ χ₂ : H → R`, there is a natural `R`-bilinear product of root vectors and weight vectors, compatible with the actions of `H`. -/ def rootSpaceWeightSpaceProduct (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) : rootSpace H χ₁ ⊗[R] weightSpace M χ₂ →ₗ⁅R,H⁆ weightSpace M χ₃ := liftLie R H (rootSpace H χ₁) (weightSpace M χ₂) (weightSpace M χ₃) { toLinearMap := rootSpaceWeightSpaceProductAux R L H M hχ map_lie' := fun {x y} => by ext m simp only [rootSpaceWeightSpaceProductAux, LieSubmodule.coe_bracket, LieSubalgebra.coe_bracket_of_module, lie_lie, LinearMap.coe_mk, AddHom.coe_mk, Subtype.coe_mk, LieHom.lie_apply, LieSubmodule.coe_sub] } @[simp] theorem coe_rootSpaceWeightSpaceProduct_tmul (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) (x : rootSpace H χ₁) (m : weightSpace M χ₂) : (rootSpaceWeightSpaceProduct R L H M χ₁ χ₂ χ₃ hχ (x ⊗ₜ m) : M) = ⁅(x : L), (m : M)⁆ := by simp only [rootSpaceWeightSpaceProduct, rootSpaceWeightSpaceProductAux, coe_liftLie_eq_lift_coe, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, lift_apply, LinearMap.coe_mk, AddHom.coe_mk, Submodule.coe_mk] theorem mapsTo_toEnd_weightSpace_add_of_mem_rootSpace (α χ : H → R) {x : L} (hx : x ∈ rootSpace H α) : MapsTo (toEnd R L M x) (weightSpace M χ) (weightSpace M (α + χ)) := by intro m hm let x' : rootSpace H α := ⟨x, hx⟩ let m' : weightSpace M χ := ⟨m, hm⟩ exact (rootSpaceWeightSpaceProduct R L H M α χ (α + χ) rfl (x' ⊗ₜ m')).property /-- Given a nilpotent Lie subalgebra `H ⊆ L` together with `χ₁ χ₂ : H → R`, there is a natural `R`-bilinear product of root vectors, compatible with the actions of `H`. -/ def rootSpaceProduct (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) : rootSpace H χ₁ ⊗[R] rootSpace H χ₂ →ₗ⁅R,H⁆ rootSpace H χ₃ := rootSpaceWeightSpaceProduct R L H L χ₁ χ₂ χ₃ hχ @[simp] theorem rootSpaceProduct_def : rootSpaceProduct R L H = rootSpaceWeightSpaceProduct R L H L := rfl theorem rootSpaceProduct_tmul (χ₁ χ₂ χ₃ : H → R) (hχ : χ₁ + χ₂ = χ₃) (x : rootSpace H χ₁) (y : rootSpace H χ₂) : (rootSpaceProduct R L H χ₁ χ₂ χ₃ hχ (x ⊗ₜ y) : L) = ⁅(x : L), (y : L)⁆ := by simp only [rootSpaceProduct_def, coe_rootSpaceWeightSpaceProduct_tmul] /-- Given a nilpotent Lie subalgebra `H ⊆ L`, the root space of the zero map `0 : H → R` is a Lie subalgebra of `L`. -/ def zeroRootSubalgebra : LieSubalgebra R L := { toSubmodule := (rootSpace H 0 : Submodule R L) lie_mem' := fun {x y hx hy} => by let xy : rootSpace H 0 ⊗[R] rootSpace H 0 := ⟨x, hx⟩ ⊗ₜ ⟨y, hy⟩ suffices (rootSpaceProduct R L H 0 0 0 (add_zero 0) xy : L) ∈ rootSpace H 0 by rwa [rootSpaceProduct_tmul, Subtype.coe_mk, Subtype.coe_mk] at this exact (rootSpaceProduct R L H 0 0 0 (add_zero 0) xy).property } @[simp] theorem coe_zeroRootSubalgebra : (zeroRootSubalgebra R L H : Submodule R L) = rootSpace H 0 := rfl theorem mem_zeroRootSubalgebra (x : L) : x ∈ zeroRootSubalgebra R L H ↔ ∀ y : H, ∃ k : ℕ, (toEnd R H L y ^ k) x = 0 := by change x ∈ rootSpace H 0 ↔ _ simp only [mem_weightSpace, Pi.zero_apply, zero_smul, sub_zero] theorem toLieSubmodule_le_rootSpace_zero : H.toLieSubmodule ≤ rootSpace H 0 := by intro x hx simp only [LieSubalgebra.mem_toLieSubmodule] at hx simp only [mem_weightSpace, Pi.zero_apply, sub_zero, zero_smul] intro y obtain ⟨k, hk⟩ := (inferInstance : IsNilpotent R H) use k let f : Module.End R H := toEnd R H H y let g : Module.End R L := toEnd R H L y have hfg : g.comp (H : Submodule R L).subtype = (H : Submodule R L).subtype.comp f := by ext z simp only [toEnd_apply_apply, Submodule.subtype_apply, LieSubalgebra.coe_bracket_of_module, LieSubalgebra.coe_bracket, Function.comp_apply, LinearMap.coe_comp] rfl change (g ^ k).comp (H : Submodule R L).subtype ⟨x, hx⟩ = 0 rw [LinearMap.commute_pow_left_of_commute hfg k] have h := iterate_toEnd_mem_lowerCentralSeries R H H y ⟨x, hx⟩ k rw [hk, LieSubmodule.mem_bot] at h simp only [Submodule.subtype_apply, Function.comp_apply, LinearMap.pow_apply, LinearMap.coe_comp, Submodule.coe_eq_zero] exact h /-- This enables the instance `Zero (Weight R H L)`. -/ instance [Nontrivial H] : Nontrivial (weightSpace L (0 : H → R)) := by obtain ⟨⟨x, hx⟩, ⟨y, hy⟩, e⟩ := exists_pair_ne H exact ⟨⟨x, toLieSubmodule_le_rootSpace_zero R L H hx⟩, ⟨y, toLieSubmodule_le_rootSpace_zero R L H hy⟩, by simpa using e⟩ theorem le_zeroRootSubalgebra : H ≤ zeroRootSubalgebra R L H := by rw [← LieSubalgebra.coe_submodule_le_coe_submodule, ← H.coe_toLieSubmodule, coe_zeroRootSubalgebra, LieSubmodule.coeSubmodule_le_coeSubmodule] exact toLieSubmodule_le_rootSpace_zero R L H @[simp] theorem zeroRootSubalgebra_normalizer_eq_self : (zeroRootSubalgebra R L H).normalizer = zeroRootSubalgebra R L H := by refine le_antisymm ?_ (LieSubalgebra.le_normalizer _) intro x hx rw [LieSubalgebra.mem_normalizer_iff] at hx rw [mem_zeroRootSubalgebra] rintro ⟨y, hy⟩ specialize hx y (le_zeroRootSubalgebra R L H hy) rw [mem_zeroRootSubalgebra] at hx obtain ⟨k, hk⟩ := hx ⟨y, hy⟩ rw [← lie_skew, LinearMap.map_neg, neg_eq_zero] at hk use k + 1 rw [LinearMap.iterate_succ, LinearMap.coe_comp, Function.comp_apply, toEnd_apply_apply, LieSubalgebra.coe_bracket_of_module, Submodule.coe_mk, hk] /-- If the zero root subalgebra of a nilpotent Lie subalgebra `H` is just `H` then `H` is a Cartan subalgebra. When `L` is Noetherian, it follows from Engel's theorem that the converse holds. See `LieAlgebra.zeroRootSubalgebra_eq_iff_is_cartan` -/ theorem is_cartan_of_zeroRootSubalgebra_eq (h : zeroRootSubalgebra R L H = H) : H.IsCartanSubalgebra := { nilpotent := inferInstance self_normalizing := by rw [← h]; exact zeroRootSubalgebra_normalizer_eq_self R L H } @[simp] theorem zeroRootSubalgebra_eq_of_is_cartan (H : LieSubalgebra R L) [H.IsCartanSubalgebra] [IsNoetherian R L] : zeroRootSubalgebra R L H = H := by refine le_antisymm ?_ (le_zeroRootSubalgebra R L H) suffices rootSpace H 0 ≤ H.toLieSubmodule by exact fun x hx => this hx obtain ⟨k, hk⟩ := (rootSpace H 0).isNilpotent_iff_exists_self_le_ucs.mp (by infer_instance) exact hk.trans (LieSubmodule.ucs_le_of_normalizer_eq_self (by simp) k) theorem zeroRootSubalgebra_eq_iff_is_cartan [IsNoetherian R L] : zeroRootSubalgebra R L H = H ↔ H.IsCartanSubalgebra := ⟨is_cartan_of_zeroRootSubalgebra_eq R L H, by intros; simp⟩ @[simp] theorem rootSpace_zero_eq (H : LieSubalgebra R L) [H.IsCartanSubalgebra] [IsNoetherian R L] : rootSpace H 0 = H.toLieSubmodule := by rw [← LieSubmodule.coe_toSubmodule_eq_iff, ← coe_zeroRootSubalgebra, zeroRootSubalgebra_eq_of_is_cartan R L H, LieSubalgebra.coe_toLieSubmodule] variable {R L H} variable [H.IsCartanSubalgebra] [IsNoetherian R L] (α : H → R) /-- Given a root `α` relative to a Cartan subalgebra `H`, this is the span of all products of an element of the `α` root space and an element of the `-α` root space. Informally it is often denoted `⁅H(α), H(-α)⁆`. If the Killing form is non-degenerate and the coefficients are a perfect field, this space is one-dimensional. See `LieAlgebra.IsKilling.coe_corootSpace_eq_span_singleton` and `LieAlgebra.IsKilling.coe_corootSpace_eq_span_singleton'`. Note that the name "coroot space" is not standard as this space does not seem to have a name in the informal literature. -/ def corootSpace : LieIdeal R H := LieModuleHom.range <| ((rootSpace H 0).incl.comp <| rootSpaceProduct R L H α (-α) 0 (add_neg_self α)).codRestrict H.toLieSubmodule (by rw [← rootSpace_zero_eq] exact fun p ↦ (rootSpaceProduct R L H α (-α) 0 (add_neg_self α) p).property) lemma mem_corootSpace {x : H} : x ∈ corootSpace α ↔ (x : L) ∈ Submodule.span R {⁅y, z⁆ | (y ∈ rootSpace H α) (z ∈ rootSpace H (-α))} := by have : x ∈ corootSpace α ↔ (x : L) ∈ LieSubmodule.map H.toLieSubmodule.incl (corootSpace α) := by rw [corootSpace] simpa using exists_congr fun _ ↦ H.toLieSubmodule.injective_incl.eq_iff.symm simp_rw [this, corootSpace, ← LieModuleHom.map_top, ← LieSubmodule.mem_coeSubmodule, LieSubmodule.coeSubmodule_map, LieSubmodule.top_coeSubmodule, ← TensorProduct.span_tmul_eq_top, LinearMap.map_span, Set.image, Set.mem_setOf_eq, exists_exists_exists_and_eq] change (x : L) ∈ Submodule.span R {x | ∃ (a : rootSpace H α) (b : rootSpace H (-α)), ⁅(a : L), (b : L)⁆ = x} ↔ _ simp lemma mem_corootSpace' {x : H} : x ∈ corootSpace α ↔ x ∈ Submodule.span R ({⁅y, z⁆ | (y ∈ rootSpace H α) (z ∈ rootSpace H (-α))} : Set H) := by set s : Set H := ({⁅y, z⁆ | (y ∈ rootSpace H α) (z ∈ rootSpace H (-α))} : Set H) suffices H.subtype '' s = {⁅y, z⁆ | (y ∈ rootSpace H α) (z ∈ rootSpace H (-α))} by obtain ⟨x, hx⟩ := x erw [← (H : Submodule R L).injective_subtype.mem_set_image (s := Submodule.span R s)] rw [mem_image] simp_rw [SetLike.mem_coe] rw [← Submodule.mem_map, Submodule.coeSubtype, Submodule.map_span, mem_corootSpace, ← this] ext u simp only [Submodule.coeSubtype, mem_image, Subtype.exists, LieSubalgebra.mem_coe_submodule, exists_and_right, exists_eq_right, mem_setOf_eq, s] refine ⟨fun ⟨_, y, hy, z, hz, hyz⟩ ↦ ⟨y, hy, z, hz, hyz⟩, fun ⟨y, hy, z, hz, hyz⟩ ↦ ⟨?_, y, hy, z, hz, hyz⟩⟩ convert (rootSpaceProduct R L H α (-α) 0 (add_neg_self α) (⟨y, hy⟩ ⊗ₜ[R] ⟨z, hz⟩)).property simp [hyz] end LieAlgebra
Algebra\Lie\Weights\Chain.lean
/- Copyright (c) 2024 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.DirectSum.LinearMap import Mathlib.Algebra.Lie.Weights.Cartan import Mathlib.Data.Int.Interval import Mathlib.LinearAlgebra.Trace /-! # Chains of roots and weights Given roots `α` and `β` of a Lie algebra, together with elements `x` in the `α`-root space and `y` in the `β`-root space, it follows from the Leibniz identity that `⁅x, y⁆` is either zero or belongs to the `α + β`-root space. Iterating this operation leads to the study of families of roots of the form `k • α + β`. Such a family is known as the `α`-chain through `β` (or sometimes, the `α`-string through `β`) and the study of the sum of the corresponding root spaces is an important technique. More generally if `α` is a root and `χ` is a weight of a representation, it is useful to study the `α`-chain through `χ`. We provide basic definitions and results to support `α`-chain techniques in this file. ## Main definitions / results * `LieModule.exists₂_weightSpace_smul_add_eq_bot`: given weights `χ₁`, `χ₂` if `χ₁ ≠ 0`, we can find `p < 0` and `q > 0` such that the weight spaces `p • χ₁ + χ₂` and `q • χ₁ + χ₂` are both trivial. * `LieModule.weightSpaceChain`: given weights `χ₁`, `χ₂` together with integers `p` and `q`, this is the sum of the weight spaces `k • χ₁ + χ₂` for `p < k < q`. * `LieModule.trace_toEnd_weightSpaceChain_eq_zero`: given a root `α` relative to a Cartan subalgebra `H`, there is a natural ideal `corootSpace α` in `H`. This lemma states that this ideal acts by trace-zero endomorphisms on the sum of root spaces of any `α`-chain, provided the weight spaces at the endpoints are both trivial. * `LieModule.exists_forall_mem_corootSpace_smul_add_eq_zero`: given a (potential) root `α` relative to a Cartan subalgebra `H`, if we restrict to the ideal `corootSpace α` of `H`, we may find an integral linear combination between `α` and any weight `χ` of a representation. -/ open FiniteDimensional Function Set variable {R L : Type*} [CommRing R] [LieRing L] [LieAlgebra R L] (M : Type*) [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieModule section IsNilpotent variable [LieAlgebra.IsNilpotent R L] (χ₁ χ₂ : L → R) (p q : ℤ) section variable [NoZeroSMulDivisors ℤ R] [NoZeroSMulDivisors R M] [IsNoetherian R M] (hχ₁ : χ₁ ≠ 0) lemma eventually_weightSpace_smul_add_eq_bot : ∀ᶠ (k : ℕ) in Filter.atTop, weightSpace M (k • χ₁ + χ₂) = ⊥ := by let f : ℕ → L → R := fun k ↦ k • χ₁ + χ₂ suffices Injective f by rw [← Nat.cofinite_eq_atTop, Filter.eventually_cofinite, ← finite_image_iff this.injOn] apply (finite_weightSpace_ne_bot R L M).subset simp [f] intro k l hkl replace hkl : (k : ℤ) • χ₁ = (l : ℤ) • χ₁ := by simpa only [f, add_left_inj, natCast_zsmul] using hkl exact Nat.cast_inj.mp <| smul_left_injective ℤ hχ₁ hkl lemma exists_weightSpace_smul_add_eq_bot : ∃ k > 0, weightSpace M (k • χ₁ + χ₂) = ⊥ := (Nat.eventually_pos.and <| eventually_weightSpace_smul_add_eq_bot M χ₁ χ₂ hχ₁).exists lemma exists₂_weightSpace_smul_add_eq_bot : ∃ᵉ (p < (0 : ℤ)) (q > (0 : ℤ)), weightSpace M (p • χ₁ + χ₂) = ⊥ ∧ weightSpace M (q • χ₁ + χ₂) = ⊥ := by obtain ⟨q, hq₀, hq⟩ := exists_weightSpace_smul_add_eq_bot M χ₁ χ₂ hχ₁ obtain ⟨p, hp₀, hp⟩ := exists_weightSpace_smul_add_eq_bot M (-χ₁) χ₂ (neg_ne_zero.mpr hχ₁) refine ⟨-(p : ℤ), by simpa, q, by simpa, ?_, ?_⟩ · rw [neg_smul, ← smul_neg, natCast_zsmul] exact hp · rw [natCast_zsmul] exact hq end /-- Given two (potential) weights `χ₁` and `χ₂` together with integers `p` and `q`, it is often useful to study the sum of weight spaces associated to the family of weights `k • χ₁ + χ₂` for `p < k < q`. -/ def weightSpaceChain : LieSubmodule R L M := ⨆ k ∈ Ioo p q, weightSpace M (k • χ₁ + χ₂) lemma weightSpaceChain_def : weightSpaceChain M χ₁ χ₂ p q = ⨆ k ∈ Ioo p q, weightSpace M (k • χ₁ + χ₂) := rfl lemma weightSpaceChain_def' : weightSpaceChain M χ₁ χ₂ p q = ⨆ k ∈ Finset.Ioo p q, weightSpace M (k • χ₁ + χ₂) := by have : ∀ (k : ℤ), k ∈ Ioo p q ↔ k ∈ Finset.Ioo p q := by simp simp_rw [weightSpaceChain_def, this] @[simp] lemma weightSpaceChain_neg : weightSpaceChain M (-χ₁) χ₂ (-q) (-p) = weightSpaceChain M χ₁ χ₂ p q := by let e : ℤ ≃ ℤ := neg_involutive.toPerm simp_rw [weightSpaceChain, ← e.biSup_comp (Ioo p q)] simp [e, -mem_Ioo, neg_mem_Ioo_iff] lemma weightSpace_le_weightSpaceChain {k : ℤ} (hk : k ∈ Ioo p q) : weightSpace M (k • χ₁ + χ₂) ≤ weightSpaceChain M χ₁ χ₂ p q := le_biSup (fun i ↦ weightSpace M (i • χ₁ + χ₂)) hk end IsNilpotent section LieSubalgebra open LieAlgebra variable {H : LieSubalgebra R L} (α χ : H → R) (p q : ℤ) lemma lie_mem_weightSpaceChain_of_weightSpace_eq_bot_right [LieAlgebra.IsNilpotent R H] (hq : weightSpace M (q • α + χ) = ⊥) {x : L} (hx : x ∈ rootSpace H α) {y : M} (hy : y ∈ weightSpaceChain M α χ p q) : ⁅x, y⁆ ∈ weightSpaceChain M α χ p q := by rw [weightSpaceChain, iSup_subtype'] at hy induction' hy using LieSubmodule.iSup_induction' with k z hz z₁ z₂ _ _ hz₁ hz₂ · obtain ⟨k, hk⟩ := k suffices weightSpace M ((k + 1) • α + χ) ≤ weightSpaceChain M α χ p q by apply this simpa using (rootSpaceWeightSpaceProduct R L H M α (k • α + χ) ((k + 1) • α + χ) (by rw [add_smul]; abel) (⟨x, hx⟩ ⊗ₜ ⟨z, hz⟩)).property rw [weightSpaceChain] rcases eq_or_ne (k + 1) q with rfl | hk'; · simp only [hq, bot_le] replace hk' : k + 1 ∈ Ioo p q := ⟨by linarith [hk.1], lt_of_le_of_ne hk.2 hk'⟩ exact le_biSup (fun k ↦ weightSpace M (k • α + χ)) hk' · simp · rw [lie_add] exact add_mem hz₁ hz₂ lemma lie_mem_weightSpaceChain_of_weightSpace_eq_bot_left [LieAlgebra.IsNilpotent R H] (hp : weightSpace M (p • α + χ) = ⊥) {x : L} (hx : x ∈ rootSpace H (-α)) {y : M} (hy : y ∈ weightSpaceChain M α χ p q) : ⁅x, y⁆ ∈ weightSpaceChain M α χ p q := by replace hp : weightSpace M ((-p) • (-α) + χ) = ⊥ := by rwa [smul_neg, neg_smul, neg_neg] rw [← weightSpaceChain_neg] at hy ⊢ exact lie_mem_weightSpaceChain_of_weightSpace_eq_bot_right M (-α) χ (-q) (-p) hp hx hy section IsCartanSubalgebra variable [H.IsCartanSubalgebra] [IsNoetherian R L] lemma trace_toEnd_weightSpaceChain_eq_zero (hp : weightSpace M (p • α + χ) = ⊥) (hq : weightSpace M (q • α + χ) = ⊥) {x : H} (hx : x ∈ corootSpace α) : LinearMap.trace R _ (toEnd R H (weightSpaceChain M α χ p q) x) = 0 := by rw [LieAlgebra.mem_corootSpace'] at hx induction hx using Submodule.span_induction' · next u hu => obtain ⟨y, hy, z, hz, hyz⟩ := hu let f : Module.End R (weightSpaceChain M α χ p q) := { toFun := fun ⟨m, hm⟩ ↦ ⟨⁅(y : L), m⁆, lie_mem_weightSpaceChain_of_weightSpace_eq_bot_right M α χ p q hq hy hm⟩ map_add' := fun _ _ ↦ by simp map_smul' := fun t m ↦ by simp } let g : Module.End R (weightSpaceChain M α χ p q) := { toFun := fun ⟨m, hm⟩ ↦ ⟨⁅(z : L), m⁆, lie_mem_weightSpaceChain_of_weightSpace_eq_bot_left M α χ p q hp hz hm⟩ map_add' := fun _ _ ↦ by simp map_smul' := fun t m ↦ by simp } have hfg : toEnd R H _ u = ⁅f, g⁆ := by ext; simp [f, g, ← hyz] simp [hfg] · simp · simp_all · simp_all /-- Given a (potential) root `α` relative to a Cartan subalgebra `H`, if we restrict to the ideal `I = corootSpace α` of `H` (informally, `I = ⁅H(α), H(-α)⁆`), we may find an integral linear combination between `α` and any weight `χ` of a representation. This is Proposition 4.4 from [carter2005] and is a key step in the proof that the roots of a semisimple Lie algebra form a root system. It shows that the restriction of `α` to `I` vanishes iff the restriction of every root to `I` vanishes (which cannot happen in a semisimple Lie algebra). -/ lemma exists_forall_mem_corootSpace_smul_add_eq_zero [IsDomain R] [IsPrincipalIdealRing R] [CharZero R] [NoZeroSMulDivisors R M] [IsNoetherian R M] (hα : α ≠ 0) (hχ : weightSpace M χ ≠ ⊥) : ∃ a b : ℤ, 0 < b ∧ ∀ x ∈ corootSpace α, (a • α + b • χ) x = 0 := by obtain ⟨p, hp₀, q, hq₀, hp, hq⟩ := exists₂_weightSpace_smul_add_eq_bot M α χ hα let a := ∑ i ∈ Finset.Ioo p q, finrank R (weightSpace M (i • α + χ)) • i let b := ∑ i ∈ Finset.Ioo p q, finrank R (weightSpace M (i • α + χ)) have hb : 0 < b := by replace hχ : Nontrivial (weightSpace M χ) := by rwa [LieSubmodule.nontrivial_iff_ne_bot] refine Finset.sum_pos' (fun _ _ ↦ zero_le _) ⟨0, Finset.mem_Ioo.mpr ⟨hp₀, hq₀⟩, ?_⟩ rw [zero_smul, zero_add] exact finrank_pos refine ⟨a, b, Int.ofNat_pos.mpr hb, fun x hx ↦ ?_⟩ let N : ℤ → Submodule R M := fun k ↦ weightSpace M (k • α + χ) have h₁ : CompleteLattice.Independent fun (i : Finset.Ioo p q) ↦ N i := by rw [← LieSubmodule.independent_iff_coe_toSubmodule] refine (independent_weightSpace R H M).comp fun i j hij ↦ ?_ exact SetCoe.ext <| smul_left_injective ℤ hα <| by rwa [add_left_inj] at hij have h₂ : ∀ i, MapsTo (toEnd R H M x) ↑(N i) ↑(N i) := fun _ _ ↦ LieSubmodule.lie_mem _ have h₃ : weightSpaceChain M α χ p q = ⨆ i ∈ Finset.Ioo p q, N i := by simp_rw [weightSpaceChain_def', LieSubmodule.iSup_coe_toSubmodule] rw [← trace_toEnd_weightSpaceChain_eq_zero M α χ p q hp hq hx, ← LieSubmodule.toEnd_restrict_eq_toEnd, LinearMap.trace_eq_sum_trace_restrict_of_eq_biSup _ h₁ h₂ (weightSpaceChain M α χ p q) h₃] simp_rw [LieSubmodule.toEnd_restrict_eq_toEnd, trace_toEnd_weightSpace, Pi.add_apply, Pi.smul_apply, smul_add, ← smul_assoc, Finset.sum_add_distrib, ← Finset.sum_smul, natCast_zsmul] end IsCartanSubalgebra end LieSubalgebra section variable {M} variable [LieAlgebra.IsNilpotent R L] variable [NoZeroSMulDivisors ℤ R] [NoZeroSMulDivisors R M] [IsNoetherian R M] variable (α : L → R) (β : Weight R L M) (hα : α ≠ 0) /-- This is the largest `n : ℕ` such that `i • α + β` is a weight for all `0 ≤ i ≤ n`. -/ noncomputable def chainTopCoeff : ℕ := letI := Classical.propDecidable if hα : α = 0 then 0 else Nat.pred <| Nat.find (show ∃ n, weightSpace M (n • α + β : L → R) = ⊥ from (eventually_weightSpace_smul_add_eq_bot M α β hα).exists) /-- This is the largest `n : ℕ` such that `-i • α + β` is a weight for all `0 ≤ i ≤ n`. -/ noncomputable def chainBotCoeff : ℕ := chainTopCoeff (-α) β @[simp] lemma chainTopCoeff_neg : chainTopCoeff (-α) β = chainBotCoeff α β := rfl @[simp] lemma chainBotCoeff_neg : chainBotCoeff (-α) β = chainTopCoeff α β := by rw [← chainTopCoeff_neg, neg_neg] @[simp] lemma chainTopCoeff_zero : chainTopCoeff 0 β = 0 := dif_pos rfl @[simp] lemma chainBotCoeff_zero : chainBotCoeff 0 β = 0 := dif_pos neg_zero lemma chainTopCoeff_add_one : letI := Classical.propDecidable chainTopCoeff α β + 1 = Nat.find (eventually_weightSpace_smul_add_eq_bot M α β hα).exists := by classical rw [chainTopCoeff, dif_neg hα] apply Nat.succ_pred_eq_of_pos rw [zero_lt_iff] intro e have : weightSpace M (0 • α + β : L → R) = ⊥ := by rw [← e] exact Nat.find_spec (eventually_weightSpace_smul_add_eq_bot M α β hα).exists exact β.weightSpace_ne_bot _ (by simpa only [zero_smul, zero_add] using this) lemma weightSpace_chainTopCoeff_add_one_nsmul_add : weightSpace M ((chainTopCoeff α β + 1) • α + β : L → R) = ⊥ := by classical rw [chainTopCoeff_add_one _ _ hα] exact Nat.find_spec (eventually_weightSpace_smul_add_eq_bot M α β hα).exists lemma weightSpace_chainTopCoeff_add_one_zsmul_add : weightSpace M ((chainTopCoeff α β + 1 : ℤ) • α + β : L → R) = ⊥ := by rw [← weightSpace_chainTopCoeff_add_one_nsmul_add α β hα, ← Nat.cast_smul_eq_nsmul ℤ, Nat.cast_add, Nat.cast_one] lemma weightSpace_nsmul_add_ne_bot_of_le {n} (hn : n ≤ chainTopCoeff α β) : weightSpace M (n • α + β : L → R) ≠ ⊥ := by by_cases hα : α = 0 · rw [hα, smul_zero, zero_add]; exact β.weightSpace_ne_bot classical rw [← Nat.lt_succ, Nat.succ_eq_add_one, chainTopCoeff_add_one _ _ hα] at hn exact Nat.find_min (eventually_weightSpace_smul_add_eq_bot M α β hα).exists hn lemma weightSpace_chainBotCoeff_sub_one_zsmul_sub : weightSpace M ((-chainBotCoeff α β - 1 : ℤ) • α + β : L → R) = ⊥ := by rw [sub_eq_add_neg, ← neg_add, neg_smul, ← smul_neg, chainBotCoeff, weightSpace_chainTopCoeff_add_one_zsmul_add _ _ (by simpa using hα)] lemma weightSpace_zsmul_add_ne_bot {n : ℤ} (hn : -chainBotCoeff α β ≤ n) (hn' : n ≤ chainTopCoeff α β) : weightSpace M (n • α + β : L → R) ≠ ⊥ := by rcases n with (n | n) · simp only [Int.ofNat_eq_coe, Nat.cast_le, Nat.cast_smul_eq_nsmul] at hn' ⊢ exact weightSpace_nsmul_add_ne_bot_of_le α β hn' · simp only [Int.negSucc_eq, ← Nat.cast_succ, neg_le_neg_iff, Nat.cast_le] at hn ⊢ rw [neg_smul, ← smul_neg, Nat.cast_smul_eq_nsmul] exact weightSpace_nsmul_add_ne_bot_of_le (-α) β hn lemma weightSpace_neg_zsmul_add_ne_bot {n : ℕ} (hn : n ≤ chainBotCoeff α β) : weightSpace M ((-n : ℤ) • α + β : L → R) ≠ ⊥ := by apply weightSpace_zsmul_add_ne_bot α β <;> omega /-- The last weight in an `α`-chain through `β`. -/ noncomputable def chainTop (α : L → R) (β : Weight R L M) : Weight R L M := ⟨chainTopCoeff α β • α + β, weightSpace_nsmul_add_ne_bot_of_le α β le_rfl⟩ /-- The first weight in an `α`-chain through `β`. -/ noncomputable def chainBot (α : L → R) (β : Weight R L M) : Weight R L M := ⟨(- chainBotCoeff α β : ℤ) • α + β, weightSpace_neg_zsmul_add_ne_bot α β le_rfl⟩ lemma coe_chainTop' : (chainTop α β : L → R) = chainTopCoeff α β • α + β := rfl @[simp] lemma coe_chainTop : (chainTop α β : L → R) = (chainTopCoeff α β : ℤ) • α + β := by rw [Nat.cast_smul_eq_nsmul ℤ]; rfl @[simp] lemma coe_chainBot : (chainBot α β : L → R) = (-chainBotCoeff α β : ℤ) • α + β := rfl @[simp] lemma chainTop_neg : chainTop (-α) β = chainBot α β := by ext; simp @[simp] lemma chainBot_neg : chainBot (-α) β = chainTop α β := by ext; simp @[simp] lemma chainTop_zero : chainTop 0 β = β := by ext; simp @[simp] lemma chainBot_zero : chainBot 0 β = β := by ext; simp lemma weightSpace_add_chainTop : weightSpace M (α + chainTop α β : L → R) = ⊥ := by rw [coe_chainTop', ← add_assoc, ← succ_nsmul', weightSpace_chainTopCoeff_add_one_nsmul_add _ _ hα] lemma weightSpace_neg_add_chainBot : weightSpace M (-α + chainBot α β : L → R) = ⊥ := by rw [← chainTop_neg, weightSpace_add_chainTop _ _ (by simpa using hα)] lemma chainTop_isNonZero' (hα' : weightSpace M α ≠ ⊥) : (chainTop α β).IsNonZero := by by_contra e apply hα' rw [← add_zero (α : L → R), ← e, weightSpace_add_chainTop _ _ hα] lemma chainTop_isNonZero (α β : Weight R L M) (hα : α.IsNonZero) : (chainTop α β).IsNonZero := chainTop_isNonZero' α β hα α.2 end end LieModule
Algebra\Lie\Weights\Killing.lean
/- Copyright (c) 2024 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Derivation.Killing import Mathlib.Algebra.Lie.Killing import Mathlib.Algebra.Lie.Sl2 import Mathlib.Algebra.Lie.Weights.Chain import Mathlib.LinearAlgebra.Eigenspace.Semisimple import Mathlib.LinearAlgebra.JordanChevalley /-! # Roots of Lie algebras with non-degenerate Killing forms The file contains definitions and results about roots of Lie algebras with non-degenerate Killing forms. ## Main definitions * `LieAlgebra.IsKilling.ker_restrict_eq_bot_of_isCartanSubalgebra`: if the Killing form of a Lie algebra is non-singular, it remains non-singular when restricted to a Cartan subalgebra. * `LieAlgebra.IsKilling.instIsLieAbelianOfIsCartanSubalgebra`: if the Killing form of a Lie algebra is non-singular, then its Cartan subalgebras are Abelian. * `LieAlgebra.IsKilling.isSemisimple_ad_of_mem_isCartanSubalgebra`: over a perfect field, if a Lie algebra has non-degenerate Killing form, Cartan subalgebras contain only semisimple elements. * `LieAlgebra.IsKilling.span_weight_eq_top`: given a splitting Cartan subalgebra `H` of a finite-dimensional Lie algebra with non-singular Killing form, the corresponding roots span the dual space of `H`. * `LieAlgebra.IsKilling.coroot`: the coroot corresponding to a root. * `LieAlgebra.IsKilling.isCompl_ker_weight_span_coroot`: given a root `α` with respect to a Cartan subalgebra `H`, we have a natural decomposition of `H` as the kernel of `α` and the span of the coroot corresponding to `α`. * `LieAlgebra.IsKilling.finrank_rootSpace_eq_one`: root spaces are one-dimensional. -/ variable (R K L : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [Field K] [LieAlgebra K L] namespace LieAlgebra namespace IsKilling variable [IsKilling R L] [Module.Finite R L] [Module.Free R L] /-- If the Killing form of a Lie algebra is non-singular, it remains non-singular when restricted to a Cartan subalgebra. -/ lemma ker_restrict_eq_bot_of_isCartanSubalgebra [IsNoetherian R L] [IsArtinian R L] (H : LieSubalgebra R L) [H.IsCartanSubalgebra] : LinearMap.ker ((killingForm R L).restrict H) = ⊥ := by have h : Codisjoint (rootSpace H 0) (LieModule.posFittingComp R H L) := (LieModule.isCompl_weightSpace_zero_posFittingComp R H L).codisjoint replace h : Codisjoint (H : Submodule R L) (LieModule.posFittingComp R H L : Submodule R L) := by rwa [codisjoint_iff, ← LieSubmodule.coe_toSubmodule_eq_iff, LieSubmodule.sup_coe_toSubmodule, LieSubmodule.top_coeSubmodule, rootSpace_zero_eq R L H, LieSubalgebra.coe_toLieSubmodule, ← codisjoint_iff] at h suffices this : ∀ m₀ ∈ H, ∀ m₁ ∈ LieModule.posFittingComp R H L, killingForm R L m₀ m₁ = 0 by simp [LinearMap.BilinForm.ker_restrict_eq_of_codisjoint h this] intro m₀ h₀ m₁ h₁ exact killingForm_eq_zero_of_mem_zeroRoot_mem_posFitting R L H (le_zeroRootSubalgebra R L H h₀) h₁ lemma restrict_killingForm (H : LieSubalgebra R L) : (killingForm R L).restrict H = LieModule.traceForm R H L := rfl @[simp] lemma ker_traceForm_eq_bot_of_isCartanSubalgebra [IsNoetherian R L] [IsArtinian R L] (H : LieSubalgebra R L) [H.IsCartanSubalgebra] : LinearMap.ker (LieModule.traceForm R H L) = ⊥ := ker_restrict_eq_bot_of_isCartanSubalgebra R L H lemma traceForm_cartan_nondegenerate [IsNoetherian R L] [IsArtinian R L] (H : LieSubalgebra R L) [H.IsCartanSubalgebra] : (LieModule.traceForm R H L).Nondegenerate := by simp [LinearMap.BilinForm.nondegenerate_iff_ker_eq_bot] instance instIsLieAbelianOfIsCartanSubalgebra [IsDomain R] [IsPrincipalIdealRing R] [IsArtinian R L] (H : LieSubalgebra R L) [H.IsCartanSubalgebra] : IsLieAbelian H := LieModule.isLieAbelian_of_ker_traceForm_eq_bot R H L <| ker_restrict_eq_bot_of_isCartanSubalgebra R L H end IsKilling section Field open FiniteDimensional LieModule Set open Submodule (span subset_span) variable [FiniteDimensional K L] (H : LieSubalgebra K L) [H.IsCartanSubalgebra] [IsTriangularizable K H L] /-- For any `α` and `β`, the corresponding root spaces are orthogonal with respect to the Killing form, provided `α + β ≠ 0`. -/ lemma killingForm_apply_eq_zero_of_mem_rootSpace_of_add_ne_zero {α β : H → K} {x y : L} (hx : x ∈ rootSpace H α) (hy : y ∈ rootSpace H β) (hαβ : α + β ≠ 0) : killingForm K L x y = 0 := by /- If `ad R L z` is semisimple for all `z ∈ H` then writing `⟪x, y⟫ = killingForm K L x y`, there is a slick proof of this lemma that requires only invariance of the Killing form as follows. For any `z ∈ H`, we have: `α z • ⟪x, y⟫ = ⟪α z • x, y⟫ = ⟪⁅z, x⁆, y⟫ = - ⟪x, ⁅z, y⁆⟫ = - ⟪x, β z • y⟫ = - β z • ⟪x, y⟫`. Since this is true for any `z`, we thus have: `(α + β) • ⟪x, y⟫ = 0`, and hence the result. However the semisimplicity of `ad R L z` is (a) non-trivial and (b) requires the assumption that `K` is a perfect field and `L` has non-degenerate Killing form. -/ let σ : (H → K) → (H → K) := fun γ ↦ α + (β + γ) have hσ : ∀ γ, σ γ ≠ γ := fun γ ↦ by simpa only [σ, ← add_assoc] using add_left_ne_self.mpr hαβ let f : Module.End K L := (ad K L x) ∘ₗ (ad K L y) have hf : ∀ γ, MapsTo f (rootSpace H γ) (rootSpace H (σ γ)) := fun γ ↦ (mapsTo_toEnd_weightSpace_add_of_mem_rootSpace K L H L α (β + γ) hx).comp <| mapsTo_toEnd_weightSpace_add_of_mem_rootSpace K L H L β γ hy classical have hds := DirectSum.isInternal_submodule_of_independent_of_iSup_eq_top (LieSubmodule.independent_iff_coe_toSubmodule.mp <| independent_weightSpace K H L) (LieSubmodule.iSup_eq_top_iff_coe_toSubmodule.mp <| iSup_weightSpace_eq_top K H L) exact LinearMap.trace_eq_zero_of_mapsTo_ne hds σ hσ hf /-- Elements of the `α` root space which are Killing-orthogonal to the `-α` root space are Killing-orthogonal to all of `L`. -/ lemma mem_ker_killingForm_of_mem_rootSpace_of_forall_rootSpace_neg {α : H → K} {x : L} (hx : x ∈ rootSpace H α) (hx' : ∀ y ∈ rootSpace H (-α), killingForm K L x y = 0) : x ∈ LinearMap.ker (killingForm K L) := by rw [LinearMap.mem_ker] ext y have hy : y ∈ ⨆ β, rootSpace H β := by simp [iSup_weightSpace_eq_top K H L] induction hy using LieSubmodule.iSup_induction' with | hN β y hy => by_cases hαβ : α + β = 0 · exact hx' _ (add_eq_zero_iff_neg_eq.mp hαβ ▸ hy) · exact killingForm_apply_eq_zero_of_mem_rootSpace_of_add_ne_zero K L H hx hy hαβ | h0 => simp | hadd => simp_all namespace IsKilling variable [IsKilling K L] /-- If a Lie algebra `L` has non-degenerate Killing form, the only element of a Cartan subalgebra whose adjoint action on `L` is nilpotent, is the zero element. Over a perfect field a much stronger result is true, see `LieAlgebra.IsKilling.isSemisimple_ad_of_mem_isCartanSubalgebra`. -/ lemma eq_zero_of_isNilpotent_ad_of_mem_isCartanSubalgebra {x : L} (hx : x ∈ H) (hx' : _root_.IsNilpotent (ad K L x)) : x = 0 := by suffices ⟨x, hx⟩ ∈ LinearMap.ker (traceForm K H L) by simpa using this simp only [LinearMap.mem_ker] ext y have comm : Commute (toEnd K H L ⟨x, hx⟩) (toEnd K H L y) := by rw [commute_iff_lie_eq, ← LieHom.map_lie, trivial_lie_zero, LieHom.map_zero] rw [traceForm_apply_apply, ← LinearMap.mul_eq_comp, LinearMap.zero_apply] exact (LinearMap.isNilpotent_trace_of_isNilpotent (comm.isNilpotent_mul_left hx')).eq_zero variable {K L} in /-- The restriction of the Killing form to a Cartan subalgebra, as a linear equivalence to the dual. -/ @[simps! apply_apply] noncomputable def cartanEquivDual : H ≃ₗ[K] Module.Dual K H := (traceForm K H L).toDual <| traceForm_cartan_nondegenerate K L H variable {K L H} in lemma lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg_aux {α : Weight K H L} {e f : L} (heα : e ∈ rootSpace H α) (hfα : f ∈ rootSpace H (-α)) (aux : ∀ (h : H), ⁅h, e⁆ = α h • e) : ⁅e, f⁆ = killingForm K L e f • (cartanEquivDual H).symm α := by set α' := (cartanEquivDual H).symm α rw [← sub_eq_zero, ← Submodule.mem_bot (R := K), ← ker_killingForm_eq_bot] apply mem_ker_killingForm_of_mem_rootSpace_of_forall_rootSpace_neg (α := (0 : H → K)) · simp only [rootSpace_zero_eq, LieSubalgebra.mem_toLieSubmodule] refine sub_mem ?_ (H.smul_mem _ α'.property) simpa using mapsTo_toEnd_weightSpace_add_of_mem_rootSpace K L H L α (-α) heα hfα · intro z hz replace hz : z ∈ H := by simpa using hz have he : ⁅z, e⁆ = α ⟨z, hz⟩ • e := aux ⟨z, hz⟩ have hαz : killingForm K L α' (⟨z, hz⟩ : H) = α ⟨z, hz⟩ := LinearMap.BilinForm.apply_toDual_symm_apply (hB := traceForm_cartan_nondegenerate K L H) _ _ simp [traceForm_comm K L L ⁅e, f⁆, ← traceForm_apply_lie_apply, he, mul_comm _ (α ⟨z, hz⟩), hαz] /-- This is Proposition 4.18 from [carter2005] except that we use `LieModule.exists_forall_lie_eq_smul` instead of Lie's theorem (and so avoid assuming `K` has characteristic zero). -/ lemma cartanEquivDual_symm_apply_mem_corootSpace (α : Weight K H L) : (cartanEquivDual H).symm α ∈ corootSpace α := by obtain ⟨e : L, he₀ : e ≠ 0, he : ∀ x, ⁅x, e⁆ = α x • e⟩ := exists_forall_lie_eq_smul K H L α have heα : e ∈ rootSpace H α := (mem_weightSpace L α e).mpr fun x ↦ ⟨1, by simp [← he x]⟩ obtain ⟨f, hfα, hf⟩ : ∃ f ∈ rootSpace H (-α), killingForm K L e f ≠ 0 := by contrapose! he₀ simpa using mem_ker_killingForm_of_mem_rootSpace_of_forall_rootSpace_neg K L H heα he₀ suffices ⁅e, f⁆ = killingForm K L e f • ((cartanEquivDual H).symm α : L) from (mem_corootSpace α).mpr <| Submodule.subset_span ⟨(killingForm K L e f)⁻¹ • e, Submodule.smul_mem _ _ heα, f, hfα, by simpa [inv_smul_eq_iff₀ hf]⟩ exact lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg_aux heα hfα he /-- Given a splitting Cartan subalgebra `H` of a finite-dimensional Lie algebra with non-singular Killing form, the corresponding roots span the dual space of `H`. -/ @[simp] lemma span_weight_eq_top : span K (range (Weight.toLinear K H L)) = ⊤ := by refine eq_top_iff.mpr (le_trans ?_ (LieModule.range_traceForm_le_span_weight K H L)) rw [← traceForm_flip K H L, ← LinearMap.dualAnnihilator_ker_eq_range_flip, ker_traceForm_eq_bot_of_isCartanSubalgebra, Submodule.dualAnnihilator_bot] @[simp] lemma span_weight_isNonZero_eq_top : span K ({α : Weight K H L | α.IsNonZero}.image (Weight.toLinear K H L)) = ⊤ := by rw [← span_weight_eq_top K L H] refine le_antisymm (Submodule.span_mono <| by simp) ?_ suffices range (Weight.toLinear K H L) ⊆ insert 0 ({α : Weight K H L | α.IsNonZero}.image (Weight.toLinear K H L)) by simpa only [Submodule.span_insert_zero] using Submodule.span_mono this rintro - ⟨α, rfl⟩ simp only [mem_insert_iff, Weight.coe_toLinear_eq_zero_iff, mem_image, mem_setOf_eq] tauto @[simp] lemma iInf_ker_weight_eq_bot : ⨅ α : Weight K H L, α.ker = ⊥ := by rw [← Subspace.dualAnnihilator_inj, Subspace.dualAnnihilator_iInf_eq, Submodule.dualAnnihilator_bot] simp [← LinearMap.range_dualMap_eq_dualAnnihilator_ker, ← Submodule.span_range_eq_iSup] @[simp] lemma corootSpace_zero_eq_bot : corootSpace (0 : H → K) = ⊥ := by refine eq_bot_iff.mpr fun x hx ↦ ?_ suffices {x | ∃ y ∈ H, ∃ z ∈ H, ⁅y, z⁆ = x} = {0} by simpa [mem_corootSpace, this] using hx refine eq_singleton_iff_unique_mem.mpr ⟨⟨0, H.zero_mem, 0, H.zero_mem, zero_lie 0⟩, ?_⟩ rintro - ⟨y, hy, z, hz, rfl⟩ suffices ⁅(⟨y, hy⟩ : H), (⟨z, hz⟩ : H)⁆ = 0 by simpa only [Subtype.ext_iff, LieSubalgebra.coe_bracket, ZeroMemClass.coe_zero] using this simp section PerfectField variable {K L H} variable [PerfectField K] open Module.End in lemma isSemisimple_ad_of_mem_isCartanSubalgebra {x : L} (hx : x ∈ H) : (ad K L x).IsSemisimple := by /- Using Jordan-Chevalley, write `ad K L x` as a sum of its semisimple and nilpotent parts. -/ obtain ⟨N, -, S, hS₀, hN, hS, hSN⟩ := (ad K L x).exists_isNilpotent_isSemisimple replace hS₀ : Commute (ad K L x) S := Algebra.commute_of_mem_adjoin_self hS₀ set x' : H := ⟨x, hx⟩ rw [eq_sub_of_add_eq hSN.symm] at hN /- Note that the semisimple part `S` is just a scalar action on each root space. -/ have aux {α : H → K} {y : L} (hy : y ∈ rootSpace H α) : S y = α x' • y := by replace hy : y ∈ (ad K L x).maxGenEigenspace (α x') := (weightSpace_le_weightSpaceOf L x' α) hy rw [maxGenEigenspace_eq] at hy set k := maxGenEigenspaceIndex (ad K L x) (α x') rw [apply_eq_of_mem_genEigenspace_of_comm_of_isSemisimple_of_isNilpotent_sub hy hS₀ hS hN] /- So `S` obeys the derivation axiom if we restrict to root spaces. -/ have h_der (y z : L) (α β : H → K) (hy : y ∈ rootSpace H α) (hz : z ∈ rootSpace H β) : S ⁅y, z⁆ = ⁅S y, z⁆ + ⁅y, S z⁆ := by have hyz : ⁅y, z⁆ ∈ rootSpace H (α + β) := mapsTo_toEnd_weightSpace_add_of_mem_rootSpace K L H L α β hy hz rw [aux hy, aux hz, aux hyz, smul_lie, lie_smul, ← add_smul, ← Pi.add_apply] /- Thus `S` is a derivation since root spaces span. -/ replace h_der (y z : L) : S ⁅y, z⁆ = ⁅S y, z⁆ + ⁅y, S z⁆ := by have hy : y ∈ ⨆ α : H → K, rootSpace H α := by simp [iSup_weightSpace_eq_top] have hz : z ∈ ⨆ α : H → K, rootSpace H α := by simp [iSup_weightSpace_eq_top] induction hy using LieSubmodule.iSup_induction' with | hN α y hy => induction hz using LieSubmodule.iSup_induction' with | hN β z hz => exact h_der y z α β hy hz | h0 => simp | hadd _ _ _ _ h h' => simp only [lie_add, map_add, h, h']; abel | h0 => simp | hadd _ _ _ _ h h' => simp only [add_lie, map_add, h, h']; abel /- An equivalent form of the derivation axiom used in `LieDerivation`. -/ replace h_der : ∀ y z : L, S ⁅y, z⁆ = ⁅y, S z⁆ - ⁅z, S y⁆ := by simp_rw [← lie_skew (S _) _, add_comm, ← sub_eq_add_neg] at h_der; assumption /- Bundle `S` as a `LieDerivation`. -/ let S' : LieDerivation K L L := ⟨S, h_der⟩ /- Since `L` has non-degenerate Killing form, `S` must be inner, corresponding to some `y : L`. -/ obtain ⟨y, hy⟩ := LieDerivation.IsKilling.exists_eq_ad S' /- `y` commutes with all elements of `H` because `S` has eigenvalue 0 on `H`, `S = ad K L y`. -/ have hy' (z : L) (hz : z ∈ H) : ⁅y, z⁆ = 0 := by rw [← LieSubalgebra.mem_toLieSubmodule, ← rootSpace_zero_eq] at hz simp [← ad_apply (R := K), ← LieDerivation.coe_ad_apply_eq_ad_apply, hy, aux hz] /- Thus `y` belongs to `H` since `H` is self-normalizing. -/ replace hy' : y ∈ H := by suffices y ∈ H.normalizer by rwa [LieSubalgebra.IsCartanSubalgebra.self_normalizing] at this exact (H.mem_normalizer_iff y).mpr fun z hz ↦ hy' z hz ▸ LieSubalgebra.zero_mem H /- It suffices to show `x = y` since `S = ad K L y` is semisimple. -/ suffices x = y by rwa [this, ← LieDerivation.coe_ad_apply_eq_ad_apply y, hy] rw [← sub_eq_zero] /- This will follow if we can show that `ad K L (x - y)` is nilpotent. -/ apply eq_zero_of_isNilpotent_ad_of_mem_isCartanSubalgebra K L H (H.sub_mem hx hy') /- Which is true because `ad K L (x - y) = N`. -/ replace hy : S = ad K L y := by rw [← LieDerivation.coe_ad_apply_eq_ad_apply y, hy] rwa [LieHom.map_sub, hSN, hy, add_sub_cancel_right, eq_sub_of_add_eq hSN.symm] lemma lie_eq_smul_of_mem_rootSpace {α : H → K} {x : L} (hx : x ∈ rootSpace H α) (h : H) : ⁅h, x⁆ = α h • x := by replace hx : x ∈ (ad K L h).maxGenEigenspace (α h) := weightSpace_le_weightSpaceOf L h α hx rw [(isSemisimple_ad_of_mem_isCartanSubalgebra h.property).maxGenEigenspace_eq_eigenspace, Module.End.mem_eigenspace_iff] at hx simpa using hx lemma lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg {α : Weight K H L} {e f : L} (heα : e ∈ rootSpace H α) (hfα : f ∈ rootSpace H (-α)) : ⁅e, f⁆ = killingForm K L e f • (cartanEquivDual H).symm α := by apply lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg_aux heα hfα exact lie_eq_smul_of_mem_rootSpace heα lemma coe_corootSpace_eq_span_singleton' (α : Weight K H L) : (corootSpace α).toSubmodule = K ∙ (cartanEquivDual H).symm α := by refine le_antisymm ?_ ?_ · intro ⟨x, hx⟩ hx' have : {⁅y, z⁆ | (y ∈ rootSpace H α) (z ∈ rootSpace H (-α))} ⊆ K ∙ ((cartanEquivDual H).symm α : L) := by rintro - ⟨e, heα, f, hfα, rfl⟩ rw [lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg heα hfα, SetLike.mem_coe, Submodule.mem_span_singleton] exact ⟨killingForm K L e f, rfl⟩ simp only [LieSubmodule.mem_coeSubmodule, mem_corootSpace] at hx' replace this := Submodule.span_mono this hx' rw [Submodule.span_span] at this rw [Submodule.mem_span_singleton] at this ⊢ obtain ⟨t, rfl⟩ := this use t simp [Subtype.ext_iff] · simp only [Submodule.span_singleton_le_iff_mem, LieSubmodule.mem_coeSubmodule] exact cartanEquivDual_symm_apply_mem_corootSpace K L H α end PerfectField section CharZero variable {K H L} variable [CharZero K] /-- The contrapositive of this result is very useful, taking `x` to be the element of `H` corresponding to a root `α` under the identification between `H` and `H^*` provided by the Killing form. -/ lemma eq_zero_of_apply_eq_zero_of_mem_corootSpace (x : H) (α : H → K) (hαx : α x = 0) (hx : x ∈ corootSpace α) : x = 0 := by rcases eq_or_ne α 0 with rfl | hα; · simpa using hx replace hx : x ∈ ⨅ β : Weight K H L, β.ker := by refine (Submodule.mem_iInf _).mpr fun β ↦ ?_ obtain ⟨a, b, hb, hab⟩ := exists_forall_mem_corootSpace_smul_add_eq_zero L α β hα β.weightSpace_ne_bot simpa [hαx, hb.ne'] using hab _ hx simpa using hx lemma disjoint_ker_weight_corootSpace (α : Weight K H L) : Disjoint α.ker (corootSpace α) := by rw [disjoint_iff] refine (Submodule.eq_bot_iff _).mpr fun x ⟨hαx, hx⟩ ↦ ?_ replace hαx : α x = 0 := by simpa using hαx exact eq_zero_of_apply_eq_zero_of_mem_corootSpace x α hαx hx /-- The coroot corresponding to a root. -/ noncomputable def coroot (α : Weight K H L) : H := 2 • (α <| (cartanEquivDual H).symm α)⁻¹ • (cartanEquivDual H).symm α lemma root_apply_cartanEquivDual_symm_ne_zero {α : Weight K H L} (hα : α.IsNonZero) : α ((cartanEquivDual H).symm α) ≠ 0 := by contrapose! hα suffices (cartanEquivDual H).symm α ∈ α.ker ⊓ corootSpace α by rw [(disjoint_ker_weight_corootSpace α).eq_bot] at this simpa using this exact Submodule.mem_inf.mp ⟨hα, cartanEquivDual_symm_apply_mem_corootSpace K L H α⟩ lemma root_apply_coroot {α : Weight K H L} (hα : α.IsNonZero) : α (coroot α) = 2 := by rw [← Weight.coe_coe] simpa [coroot] using inv_mul_cancel (root_apply_cartanEquivDual_symm_ne_zero hα) lemma traceForm_coroot (α : Weight K H L) (x : H) : traceForm K H L (coroot α) x = 2 • (α <| (cartanEquivDual H).symm α)⁻¹ • α x := by have : cartanEquivDual H ((cartanEquivDual H).symm α) x = α x := by rw [LinearEquiv.apply_symm_apply, Weight.toLinear_apply] rw [coroot, map_nsmul, map_smul, LinearMap.smul_apply, LinearMap.smul_apply] congr 2 @[simp] lemma coroot_eq_zero_iff {α : Weight K H L} : coroot α = 0 ↔ α.IsZero := by refine ⟨fun hα ↦ ?_, fun hα ↦ ?_⟩ · by_contra contra simpa [hα, ← α.coe_coe, map_zero] using root_apply_coroot contra · simp [coroot, Weight.coe_toLinear_eq_zero_iff.mpr hα] @[simp] lemma coroot_zero [Nontrivial L] : coroot (0 : Weight K H L) = 0 := by simp [Weight.isZero_zero] lemma coe_corootSpace_eq_span_singleton (α : Weight K H L) : (corootSpace α).toSubmodule = K ∙ coroot α := by if hα : α.IsZero then simp [hα.eq, coroot_eq_zero_iff.mpr hα] else set α' := (cartanEquivDual H).symm α suffices (K ∙ coroot α) = K ∙ α' by rw [coe_corootSpace_eq_span_singleton']; exact this.symm have : IsUnit (2 * (α α')⁻¹) := by simpa using root_apply_cartanEquivDual_symm_ne_zero hα change (K ∙ (2 • (α α')⁻¹ • α')) = _ simpa [← Nat.cast_smul_eq_nsmul K, smul_smul] using Submodule.span_singleton_smul_eq this _ @[simp] lemma corootSpace_eq_bot_iff {α : Weight K H L} : corootSpace α = ⊥ ↔ α.IsZero := by simp [← LieSubmodule.coeSubmodule_eq_bot_iff, coe_corootSpace_eq_span_singleton α] lemma isCompl_ker_weight_span_coroot (α : Weight K H L) : IsCompl α.ker (K ∙ coroot α) := by if hα : α.IsZero then simpa [Weight.coe_toLinear_eq_zero_iff.mpr hα, coroot_eq_zero_iff.mpr hα, Weight.ker] using isCompl_top_bot else rw [← coe_corootSpace_eq_span_singleton] apply Module.Dual.isCompl_ker_of_disjoint_of_ne_bot (by aesop) (disjoint_ker_weight_corootSpace α) replace hα : corootSpace α ≠ ⊥ := by simpa using hα rwa [ne_eq, ← LieSubmodule.coe_toSubmodule_eq_iff] at hα lemma traceForm_eq_zero_of_mem_ker_of_mem_span_coroot {α : Weight K H L} {x y : H} (hx : x ∈ α.ker) (hy : y ∈ K ∙ coroot α) : traceForm K H L x y = 0 := by rw [← coe_corootSpace_eq_span_singleton, LieSubmodule.mem_coeSubmodule, mem_corootSpace'] at hy induction hy using Submodule.span_induction' with | mem z hz => obtain ⟨u, hu, v, -, huv⟩ := hz change killingForm K L (x : L) (z : L) = 0 replace hx : α x = 0 := by simpa using hx rw [← huv, ← traceForm_apply_lie_apply, ← LieSubalgebra.coe_bracket_of_module, lie_eq_smul_of_mem_rootSpace hu, hx, zero_smul, map_zero, LinearMap.zero_apply] | zero => simp | add _ _ _ _ hx hy => simp [hx, hy] | smul _ _ _ hz => simp [hz] @[simp] lemma orthogonal_span_coroot_eq_ker (α : Weight K H L) : (traceForm K H L).orthogonal (K ∙ coroot α) = α.ker := by if hα : α.IsZero then have hα' : coroot α = 0 := by simpa replace hα : α.ker = ⊤ := by ext; simp [hα] simp [hα, hα'] else refine le_antisymm (fun x hx ↦ ?_) (fun x hx y hy ↦ ?_) · simp only [LinearMap.BilinForm.mem_orthogonal_iff] at hx specialize hx (coroot α) (Submodule.mem_span_singleton_self _) simp only [LinearMap.BilinForm.isOrtho_def, traceForm_coroot, smul_eq_mul, nsmul_eq_mul, Nat.cast_ofNat, mul_eq_zero, OfNat.ofNat_ne_zero, inv_eq_zero, false_or] at hx simpa using hx.resolve_left (root_apply_cartanEquivDual_symm_ne_zero hα) · have := traceForm_eq_zero_of_mem_ker_of_mem_span_coroot hx hy rwa [traceForm_comm] at this @[simp] lemma coroot_eq_iff (α β : Weight K H L) : coroot α = coroot β ↔ α = β := by refine ⟨fun hyp ↦ ?_, fun h ↦ by rw [h]⟩ if hα : α.IsZero then have hβ : β.IsZero := by rw [← coroot_eq_zero_iff] at hα ⊢ rwa [← hyp] ext simp [hα.eq, hβ.eq] else have hβ : β.IsNonZero := by contrapose! hα simp only [not_not, ← coroot_eq_zero_iff] at hα ⊢ rwa [hyp] have : α.ker = β.ker := by rw [← orthogonal_span_coroot_eq_ker α, hyp, orthogonal_span_coroot_eq_ker] suffices (α : H →ₗ[K] K) = β by ext x; simpa using LinearMap.congr_fun this x apply Module.Dual.eq_of_ker_eq_of_apply_eq (coroot α) this · rw [Weight.toLinear_apply, root_apply_coroot hα, hyp, Weight.toLinear_apply, root_apply_coroot hβ] · simp [root_apply_coroot hα] lemma exists_isSl2Triple_of_weight_isNonZero {α : Weight K H L} (hα : α.IsNonZero) : ∃ h e f : L, IsSl2Triple h e f ∧ e ∈ rootSpace H α ∧ f ∈ rootSpace H (- α) := by obtain ⟨e, heα : e ∈ rootSpace H α, he₀ : e ≠ 0⟩ := α.exists_ne_zero obtain ⟨f', hfα, hf⟩ : ∃ f ∈ rootSpace H (-α), killingForm K L e f ≠ 0 := by contrapose! he₀ simpa using mem_ker_killingForm_of_mem_rootSpace_of_forall_rootSpace_neg K L H heα he₀ have hef := lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg heα hfα let h : H := ⟨⁅e, f'⁆, hef ▸ Submodule.smul_mem _ _ (Submodule.coe_mem _)⟩ have hh : α h ≠ 0 := by have : h = killingForm K L e f' • (cartanEquivDual H).symm α := by simp [Subtype.ext_iff, hef] rw [this, map_smul, smul_eq_mul, ne_eq, mul_eq_zero, not_or] exact ⟨hf, root_apply_cartanEquivDual_symm_ne_zero hα⟩ let f := (2 * (α h)⁻¹) • f' replace hef : ⁅⁅e, f⁆, e⁆ = 2 • e := by have : ⁅⁅e, f'⁆, e⁆ = α h • e := lie_eq_smul_of_mem_rootSpace heα h rw [lie_smul, smul_lie, this, ← smul_assoc, smul_eq_mul, mul_assoc, inv_mul_cancel hh, mul_one, two_smul, two_smul] refine ⟨⁅e, f⁆, e, f, ⟨fun contra ↦ ?_, rfl, hef, ?_⟩, heα, Submodule.smul_mem _ _ hfα⟩ · rw [contra] at hef have _i : NoZeroSMulDivisors ℤ L := NoZeroSMulDivisors.int_of_charZero K L simp only [zero_lie, eq_comm (a := (0 : L)), smul_eq_zero, OfNat.ofNat_ne_zero, false_or] at hef contradiction · have : ⁅⁅e, f'⁆, f'⁆ = - α h • f' := lie_eq_smul_of_mem_rootSpace hfα h rw [lie_smul, lie_smul, smul_lie, this] simp [← smul_assoc, f, hh, mul_comm _ (2 * (α h)⁻¹)] lemma _root_.IsSl2Triple.h_eq_coroot {α : Weight K H L} (hα : α.IsNonZero) {h e f : L} (ht : IsSl2Triple h e f) (heα : e ∈ rootSpace H α) (hfα : f ∈ rootSpace H (- α)) : h = coroot α := by have hef := lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg heα hfα lift h to H using by simpa only [← ht.lie_e_f, hef] using H.smul_mem _ (Submodule.coe_mem _) congr 1 have key : α h = 2 := by have := lie_eq_smul_of_mem_rootSpace heα h rw [LieSubalgebra.coe_bracket_of_module, ht.lie_h_e_smul K] at this exact smul_left_injective K ht.e_ne_zero this.symm suffices ∃ s : K, s • h = coroot α by obtain ⟨s, hs⟩ := this replace this : s = 1 := by simpa [root_apply_coroot hα, key] using congr_arg α hs rwa [this, one_smul] at hs set α' := (cartanEquivDual H).symm α with hα' have h_eq : h = killingForm K L e f • α' := by simp only [hα', Subtype.ext_iff, Submodule.coe_smul_of_tower, ← ht.lie_e_f, hef] use (2 • (α α')⁻¹) * (killingForm K L e f)⁻¹ have hef₀ : killingForm K L e f ≠ 0 := by have := ht.h_ne_zero contrapose! this simpa [this] using h_eq rw [h_eq, smul_smul, mul_assoc, inv_mul_cancel hef₀, mul_one, smul_assoc, coroot] lemma finrank_rootSpace_eq_one (α : Weight K H L) (hα : α.IsNonZero) : finrank K (rootSpace H α) = 1 := by suffices ¬ 1 < finrank K (rootSpace H α) by have h₀ : finrank K (rootSpace H α) ≠ 0 := by simpa using α.weightSpace_ne_bot omega intro contra obtain ⟨h, e, f, ht, heα, hfα⟩ := exists_isSl2Triple_of_weight_isNonZero hα let F : rootSpace H α →ₗ[K] K := killingForm K L f ∘ₗ (rootSpace H α).subtype have hF : LinearMap.ker F ≠ ⊥ := F.ker_ne_bot_of_finrank_lt <| by rwa [finrank_self] obtain ⟨⟨y, hyα⟩, hy, hy₀⟩ := (Submodule.ne_bot_iff _).mp hF replace hy : ⁅y, f⁆ = 0 := by have : killingForm K L y f = 0 := by simpa [F, traceForm_comm] using hy simpa [this] using lie_eq_killingForm_smul_of_mem_rootSpace_of_mem_rootSpace_neg hyα hfα have P : ht.symm.HasPrimitiveVectorWith y (-2 : K) := { ne_zero := by simpa using hy₀ lie_h := by simp only [neg_smul, neg_lie, neg_inj, ht.h_eq_coroot hα heα hfα, ← H.coe_bracket_of_module, lie_eq_smul_of_mem_rootSpace hyα (coroot α), root_apply_coroot hα] lie_e := by rw [← lie_skew, hy, neg_zero] } obtain ⟨n, hn⟩ := P.exists_nat replace hn : -2 = (n : ℤ) := by norm_cast at hn omega end CharZero end IsKilling end Field end LieAlgebra namespace LieModule namespace Weight open LieAlgebra IsKilling variable {K L} variable [FiniteDimensional K L] variable [IsKilling K L] {H : LieSubalgebra K L} [H.IsCartanSubalgebra] [IsTriangularizable K H L] variable {α : Weight K H L} instance : InvolutiveNeg (Weight K H L) where neg α := ⟨-α, by by_cases hα : α.IsZero · convert α.weightSpace_ne_bot; rw [hα, neg_zero] · intro e obtain ⟨x, hx, x_ne0⟩ := α.exists_ne_zero have := mem_ker_killingForm_of_mem_rootSpace_of_forall_rootSpace_neg K L H hx (fun y hy ↦ by rw [rootSpace, e] at hy; rw [hy, map_zero]) rw [ker_killingForm_eq_bot] at this exact x_ne0 this⟩ neg_neg α := by ext; simp @[simp] lemma coe_neg : ((-α : Weight K H L) : H → K) = -α := rfl lemma IsZero.neg (h : α.IsZero) : (-α).IsZero := by ext; rw [coe_neg, h, neg_zero] @[simp] lemma isZero_neg : (-α).IsZero ↔ α.IsZero := ⟨fun h ↦ neg_neg α ▸ h.neg, fun h ↦ h.neg⟩ lemma IsNonZero.neg (h : α.IsNonZero) : (-α).IsNonZero := fun e ↦ h (by simpa using e.neg) @[simp] lemma isNonZero_neg {α : Weight K H L} : (-α).IsNonZero ↔ α.IsNonZero := isZero_neg.not @[simp] lemma toLinear_neg {α : Weight K H L} : (-α).toLinear = -α.toLinear := rfl variable [CharZero K] @[simp] lemma _root_.LieAlgebra.IsKilling.coroot_neg (α : Weight K H L) : coroot (-α) = -coroot α := by simp [coroot] end Weight end LieModule
Algebra\Lie\Weights\Linear.lean
/- Copyright (c) 2023 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Weights.Basic import Mathlib.LinearAlgebra.Trace import Mathlib.LinearAlgebra.FreeModule.PID /-! # Lie modules with linear weights Given a Lie module `M` over a nilpotent Lie algebra `L` with coefficients in `R`, one frequently studies `M` via its weights. These are functions `χ : L → R` whose corresponding weight space `LieModule.weightSpace M χ`, is non-trivial. If `L` is Abelian or if `R` has characteristic zero (and `M` is finite-dimensional) then such `χ` are necessarily `R`-linear. However in general non-linear weights do exist. For example if we take: * `R`: the field with two elements (or indeed any perfect field of characteristic two), * `L`: `sl₂` (this is nilpotent in characteristic two), * `M`: the natural two-dimensional representation of `L`, then there is a single weight and it is non-linear. (See remark following Proposition 9 of chapter VII, §1.3 in [N. Bourbaki, Chapters 7--9](bourbaki1975b).) We thus introduce a typeclass `LieModule.LinearWeights` to encode the fact that a Lie module does have linear weights and provide typeclass instances in the two important cases that `L` is Abelian or `R` has characteristic zero. ## Main definitions * `LieModule.LinearWeights`: a typeclass encoding the fact that a given Lie module has linear weights, and furthermore that the weights vanish on the derived ideal. * `LieModule.instLinearWeightsOfCharZero`: a typeclass instance encoding the fact that for an Abelian Lie algebra, the weights of any Lie module are linear. * `LieModule.instLinearWeightsOfIsLieAbelian`: a typeclass instance encoding the fact that in characteristic zero, the weights of any finite-dimensional Lie module are linear. * `LieModule.exists_forall_lie_eq_smul`: existence of simultaneous eigenvectors from existence of simultaneous generalized eigenvectors for Noetherian Lie modules with linear weights. -/ open Set variable (R L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieModule /-- A typeclass encoding the fact that a given Lie module has linear weights, vanishing on the derived ideal. -/ class LinearWeights [LieAlgebra.IsNilpotent R L] : Prop := map_add : ∀ χ : L → R, weightSpace M χ ≠ ⊥ → ∀ x y, χ (x + y) = χ x + χ y map_smul : ∀ χ : L → R, weightSpace M χ ≠ ⊥ → ∀ (t : R) x, χ (t • x) = t • χ x map_lie : ∀ χ : L → R, weightSpace M χ ≠ ⊥ → ∀ x y : L, χ ⁅x, y⁆ = 0 namespace Weight variable [LieAlgebra.IsNilpotent R L] [LinearWeights R L M] [NoZeroSMulDivisors R M] [IsNoetherian R M] (χ : Weight R L M) /-- A weight of a Lie module, bundled as a linear map. -/ @[simps] def toLinear : L →ₗ[R] R where toFun := χ map_add' := LinearWeights.map_add χ χ.weightSpace_ne_bot map_smul' := LinearWeights.map_smul χ χ.weightSpace_ne_bot instance instCoeLinearMap : CoeOut (Weight R L M) (L →ₗ[R] R) where coe := Weight.toLinear R L M instance instLinearMapClass : LinearMapClass (Weight R L M) R L R where map_add χ := LinearWeights.map_add χ χ.weightSpace_ne_bot map_smulₛₗ χ := LinearWeights.map_smul χ χ.weightSpace_ne_bot variable {R L M χ} @[simp] lemma apply_lie (x y : L) : χ ⁅x, y⁆ = 0 := LinearWeights.map_lie χ χ.weightSpace_ne_bot x y @[simp] lemma coe_coe : (↑(χ : L →ₗ[R] R) : L → R) = (χ : L → R) := rfl @[simp] lemma coe_toLinear_eq_zero_iff : (χ : L →ₗ[R] R) = 0 ↔ χ.IsZero := ⟨fun h ↦ funext fun x ↦ LinearMap.congr_fun h x, fun h ↦ by ext; simp [h.eq]⟩ lemma coe_toLinear_ne_zero_iff : (χ : L →ₗ[R] R) ≠ 0 ↔ χ.IsNonZero := by simp /-- The kernel of a weight of a Lie module with linear weights. -/ abbrev ker := LinearMap.ker (χ : L →ₗ[R] R) end Weight /-- For an Abelian Lie algebra, the weights of any Lie module are linear. -/ instance instLinearWeightsOfIsLieAbelian [IsLieAbelian L] [NoZeroSMulDivisors R M] : LinearWeights R L M := have aux : ∀ (χ : L → R), weightSpace M χ ≠ ⊥ → ∀ (x y : L), χ (x + y) = χ x + χ y := by have h : ∀ x y, Commute (toEnd R L M x) (toEnd R L M y) := fun x y ↦ by rw [commute_iff_lie_eq, ← LieHom.map_lie, trivial_lie_zero, LieHom.map_zero] intro χ hχ x y simp_rw [Ne, ← LieSubmodule.coe_toSubmodule_eq_iff, weightSpace, weightSpaceOf, LieSubmodule.iInf_coe_toSubmodule, LieSubmodule.bot_coeSubmodule] at hχ exact Module.End.map_add_of_iInf_genEigenspace_ne_bot_of_commute (toEnd R L M).toLinearMap χ hχ h x y { map_add := aux map_smul := fun χ hχ t x ↦ by simp_rw [Ne, ← LieSubmodule.coe_toSubmodule_eq_iff, weightSpace, weightSpaceOf, LieSubmodule.iInf_coe_toSubmodule, LieSubmodule.bot_coeSubmodule] at hχ exact Module.End.map_smul_of_iInf_genEigenspace_ne_bot (toEnd R L M).toLinearMap χ hχ t x map_lie := fun χ hχ t x ↦ by rw [trivial_lie_zero, ← add_left_inj (χ 0), ← aux χ hχ, zero_add, zero_add] } section FiniteDimensional open FiniteDimensional variable [IsDomain R] [IsPrincipalIdealRing R] [Module.Free R M] [Module.Finite R M] [LieAlgebra.IsNilpotent R L] lemma trace_comp_toEnd_weightSpace_eq (χ : L → R) : LinearMap.trace R _ ∘ₗ (toEnd R L (weightSpace M χ)).toLinearMap = finrank R (weightSpace M χ) • χ := by ext x let n := toEnd R L (weightSpace M χ) x - χ x • LinearMap.id have h₁ : toEnd R L (weightSpace M χ) x = n + χ x • LinearMap.id := eq_add_of_sub_eq rfl have h₂ : LinearMap.trace R _ n = 0 := IsReduced.eq_zero _ <| LinearMap.isNilpotent_trace_of_isNilpotent <| isNilpotent_toEnd_sub_algebraMap M χ x rw [LinearMap.comp_apply, LieHom.coe_toLinearMap, h₁, map_add, h₂] simp [mul_comm (χ x)] @[deprecated (since := "2024-04-06")] alias trace_comp_toEnd_weight_space_eq := trace_comp_toEnd_weightSpace_eq variable {R L M} in lemma zero_lt_finrank_weightSpace {χ : L → R} (hχ : weightSpace M χ ≠ ⊥) : 0 < finrank R (weightSpace M χ) := by rwa [← LieSubmodule.nontrivial_iff_ne_bot, ← rank_pos_iff_nontrivial (R := R), ← finrank_eq_rank, Nat.cast_pos] at hχ /-- In characteristic zero, the weights of any finite-dimensional Lie module are linear and vanish on the derived ideal. -/ instance instLinearWeightsOfCharZero [CharZero R] : LinearWeights R L M where map_add χ hχ x y := by rw [← smul_right_inj (zero_lt_finrank_weightSpace hχ).ne', smul_add, ← Pi.smul_apply, ← Pi.smul_apply, ← Pi.smul_apply, ← trace_comp_toEnd_weightSpace_eq, map_add] map_smul χ hχ t x := by rw [← smul_right_inj (zero_lt_finrank_weightSpace hχ).ne', smul_comm, ← Pi.smul_apply, ← Pi.smul_apply (finrank R _), ← trace_comp_toEnd_weightSpace_eq, map_smul] map_lie χ hχ x y := by rw [← smul_right_inj (zero_lt_finrank_weightSpace hχ).ne', nsmul_zero, ← Pi.smul_apply, ← trace_comp_toEnd_weightSpace_eq, LinearMap.comp_apply, LieHom.coe_toLinearMap, LieHom.map_lie, Ring.lie_def, map_sub, LinearMap.trace_mul_comm, sub_self] end FiniteDimensional variable [LieAlgebra.IsNilpotent R L] [LinearWeights R L M] (χ : L → R) /-- A type synonym for the `χ`-weight space but with the action of `x : L` on `m : weightSpace M χ`, shifted to act as `⁅x, m⁆ - χ x • m`. -/ def shiftedWeightSpace := weightSpace M χ namespace shiftedWeightSpace private lemma aux [h : Nontrivial (shiftedWeightSpace R L M χ)] : weightSpace M χ ≠ ⊥ := (LieSubmodule.nontrivial_iff_ne_bot _ _ _).mp h instance : LieRingModule L (shiftedWeightSpace R L M χ) where bracket x m := ⁅x, m⁆ - χ x • m add_lie x y m := by nontriviality shiftedWeightSpace R L M χ simp only [add_lie, LinearWeights.map_add χ (aux R L M χ), add_smul] abel lie_add x m n := by nontriviality shiftedWeightSpace R L M χ simp only [lie_add, LinearWeights.map_add χ (aux R L M χ), smul_add] abel leibniz_lie x y m := by nontriviality shiftedWeightSpace R L M χ simp only [lie_sub, lie_smul, lie_lie, LinearWeights.map_lie χ (aux R L M χ), zero_smul, sub_zero, smul_sub, smul_comm (χ x)] abel @[simp] lemma coe_lie_shiftedWeightSpace_apply (x : L) (m : shiftedWeightSpace R L M χ) : ⁅x, m⁆ = ⁅x, (m : M)⁆ - χ x • m := rfl instance : LieModule R L (shiftedWeightSpace R L M χ) where smul_lie t x m := by nontriviality shiftedWeightSpace R L M χ apply Subtype.ext simp only [coe_lie_shiftedWeightSpace_apply, smul_lie, LinearWeights.map_smul χ (aux R L M χ), SetLike.val_smul, smul_sub, sub_right_inj, smul_assoc t] lie_smul t x m := by nontriviality shiftedWeightSpace R L M χ apply Subtype.ext simp only [coe_lie_shiftedWeightSpace_apply, lie_smul, LinearWeights.map_smul χ (aux R L M χ), SetLike.val_smul, smul_sub, sub_right_inj, smul_comm t] /-- Forgetting the action of `L`, the spaces `weightSpace M χ` and `shiftedWeightSpace R L M χ` are equivalent. -/ @[simps!] def shift : weightSpace M χ ≃ₗ[R] shiftedWeightSpace R L M χ := LinearEquiv.refl R _ lemma toEnd_eq (x : L) : toEnd R L (shiftedWeightSpace R L M χ) x = (shift R L M χ).conj (toEnd R L (weightSpace M χ) x - χ x • LinearMap.id) := by ext; simp [LinearEquiv.conj_apply] /-- By Engel's theorem, if `M` is Noetherian, the shifted action `⁅x, m⁆ - χ x • m` makes the `χ`-weight space into a nilpotent Lie module. -/ instance [IsNoetherian R M] : IsNilpotent R L (shiftedWeightSpace R L M χ) := LieModule.isNilpotent_iff_forall'.mpr fun x ↦ isNilpotent_toEnd_sub_algebraMap M χ x end shiftedWeightSpace /-- Given a Lie module `M` of a Lie algebra `L` with coefficients in `R`, if a function `χ : L → R` has a simultaneous generalized eigenvector for the action of `L` then it has a simultaneous true eigenvector, provided `M` is Noetherian and has linear weights. -/ lemma exists_forall_lie_eq_smul [IsNoetherian R M] (χ : Weight R L M) : ∃ m : M, m ≠ 0 ∧ ∀ x : L, ⁅x, m⁆ = χ x • m := by replace hχ : Nontrivial (shiftedWeightSpace R L M χ) := (LieSubmodule.nontrivial_iff_ne_bot R L M).mpr χ.weightSpace_ne_bot obtain ⟨⟨⟨m, _⟩, hm₁⟩, hm₂⟩ := @exists_ne _ (nontrivial_max_triv_of_isNilpotent R L (shiftedWeightSpace R L M χ)) 0 simp_rw [LieSubmodule.mem_coeSubmodule, mem_maxTrivSubmodule, Subtype.ext_iff, shiftedWeightSpace.coe_lie_shiftedWeightSpace_apply, ZeroMemClass.coe_zero, sub_eq_zero] at hm₁ exact ⟨m, by simpa using hm₂, hm₁⟩ end LieModule
Algebra\Lie\Weights\RootSystem.lean
/- Copyright (c) 2024 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Algebra.Lie.Weights.Killing import Mathlib.LinearAlgebra.RootSystem.Basic import Mathlib.Algebra.Algebra.Rat /-! # The root system associated with a Lie algebra We show that the roots of a finite dimensional splitting semisimple Lie algebra over a field of characteristic 0 form a root system. We achieve this by studying root chains. ## Main results - `LieAlgebra.IsKilling.apply_coroot_eq_cast`: If `β - qα ... β ... β + rα` is the `α`-chain through `β`, then `β (coroot α) = q - r`. In particular, it is an integer. - `LieAlgebra.IsKilling.rootSpace_zsmul_add_ne_bot_iff`: The `α`-chain through `β` (`β - qα ... β ... β + rα`) are the only roots of the form `β + kα`. - `LieAlgebra.IsKilling.eq_neg_or_eq_of_eq_smul`: `±α` are the only `K`-multiples of a root `α` that are also (non-zero) roots. - `LieAlgebra.IsKilling.rootSystem`: The root system of a finite-dimensional Lie algebra with non-degenerate Killing form over a field of characteristic zero, relative to a splitting Cartan subalgebra. -/ noncomputable section namespace LieAlgebra.IsKilling open LieModule Module variable {K L : Type*} [Field K] [CharZero K] [LieRing L] [LieAlgebra K L] [IsKilling K L] [FiniteDimensional K L] {H : LieSubalgebra K L} [H.IsCartanSubalgebra] [IsTriangularizable K H L] variable (α β : Weight K H L) (hα : α.IsNonZero) private lemma chainLength_aux {x} (hx : x ∈ rootSpace H (chainTop α β)) : ∃ n : ℕ, n • x = ⁅coroot α, x⁆ := by by_cases hx' : x = 0 · exact ⟨0, by simp [hx']⟩ obtain ⟨h, e, f, isSl2, he, hf⟩ := exists_isSl2Triple_of_weight_isNonZero hα obtain rfl := isSl2.h_eq_coroot hα he hf have : isSl2.HasPrimitiveVectorWith x (chainTop α β (coroot α)) := have := lie_mem_weightSpace_of_mem_weightSpace he hx ⟨hx', by rw [← lie_eq_smul_of_mem_rootSpace hx]; rfl, by rwa [weightSpace_add_chainTop α β hα] at this⟩ obtain ⟨μ, hμ⟩ := this.exists_nat exact ⟨μ, by rw [← Nat.cast_smul_eq_nsmul K, ← hμ, lie_eq_smul_of_mem_rootSpace hx]⟩ /-- The length of the `α`-chain through `β`. See `chainBotCoeff_add_chainTopCoeff`. -/ def chainLength (α β : Weight K H L) : ℕ := letI := Classical.propDecidable if hα : α.IsZero then 0 else (chainLength_aux α β hα (chainTop α β).exists_ne_zero.choose_spec.1).choose lemma chainLength_of_isZero (hα : α.IsZero) : chainLength α β = 0 := dif_pos hα lemma chainLength_nsmul {x} (hx : x ∈ rootSpace H (chainTop α β)) : chainLength α β • x = ⁅coroot α, x⁆ := by by_cases hα : α.IsZero · rw [coroot_eq_zero_iff.mpr hα, chainLength_of_isZero _ _ hα, zero_smul, zero_lie] let x' := (chainTop α β).exists_ne_zero.choose have h : x' ∈ rootSpace H (chainTop α β) ∧ x' ≠ 0 := (chainTop α β).exists_ne_zero.choose_spec obtain ⟨k, rfl⟩ : ∃ k : K, k • x' = x := by simpa using (finrank_eq_one_iff_of_nonzero' ⟨x', h.1⟩ (by simpa using h.2)).mp (finrank_rootSpace_eq_one _ (chainTop_isNonZero α β hα)) ⟨_, hx⟩ rw [lie_smul, smul_comm, chainLength, dif_neg hα, (chainLength_aux α β hα h.1).choose_spec] lemma chainLength_smul {x} (hx : x ∈ rootSpace H (chainTop α β)) : (chainLength α β : K) • x = ⁅coroot α, x⁆ := by rw [Nat.cast_smul_eq_nsmul, chainLength_nsmul _ _ hx] lemma apply_coroot_eq_cast' : β (coroot α) = ↑(chainLength α β - 2 * chainTopCoeff α β : ℤ) := by by_cases hα : α.IsZero · rw [coroot_eq_zero_iff.mpr hα, chainLength, dif_pos hα, hα.eq, chainTopCoeff_zero, map_zero, CharP.cast_eq_zero, mul_zero, sub_self, Int.cast_zero] obtain ⟨x, hx, x_ne0⟩ := (chainTop α β).exists_ne_zero have := chainLength_smul _ _ hx rw [lie_eq_smul_of_mem_rootSpace hx, ← sub_eq_zero, ← sub_smul, smul_eq_zero_iff_left x_ne0, sub_eq_zero, coe_chainTop', nsmul_eq_mul, Pi.natCast_def, Pi.add_apply, Pi.mul_apply, root_apply_coroot hα] at this simp only [Int.cast_sub, Int.cast_natCast, Int.cast_mul, Int.cast_ofNat, eq_sub_iff_add_eq', this, mul_comm (2 : K)] lemma rootSpace_neg_nsmul_add_chainTop_of_le {n : ℕ} (hn : n ≤ chainLength α β) : rootSpace H (- (n • α) + chainTop α β) ≠ ⊥ := by by_cases hα : α.IsZero · simpa only [hα.eq, smul_zero, neg_zero, chainTop_zero, zero_add, ne_eq] using β.2 obtain ⟨x, hx, x_ne0⟩ := (chainTop α β).exists_ne_zero obtain ⟨h, e, f, isSl2, he, hf⟩ := exists_isSl2Triple_of_weight_isNonZero hα obtain rfl := isSl2.h_eq_coroot hα he hf have prim : isSl2.HasPrimitiveVectorWith x (chainLength α β : K) := have := lie_mem_weightSpace_of_mem_weightSpace he hx ⟨x_ne0, (chainLength_smul _ _ hx).symm, by rwa [weightSpace_add_chainTop _ _ hα] at this⟩ simp only [← smul_neg, ne_eq, LieSubmodule.eq_bot_iff, not_forall] exact ⟨_, toEnd_pow_apply_mem hf hx n, prim.pow_toEnd_f_ne_zero_of_eq_nat rfl hn⟩ lemma rootSpace_neg_nsmul_add_chainTop_of_lt {n : ℕ} (hn : chainLength α β < n) : rootSpace H (- (n • α) + chainTop α β) = ⊥ := by by_contra e let W : Weight K H L := ⟨_, e⟩ have hW : (W : H → K) = - (n • α) + chainTop α β := rfl have H₁ : 1 + n + chainTopCoeff (-α) W ≤ chainLength (-α) W := by have := apply_coroot_eq_cast' (-α) W simp only [coroot_neg, map_neg, hW, nsmul_eq_mul, Pi.natCast_def, coe_chainTop, zsmul_eq_mul, Int.cast_natCast, Pi.add_apply, Pi.neg_apply, Pi.mul_apply, root_apply_coroot hα, mul_two, neg_add_rev, apply_coroot_eq_cast' α β, Int.cast_sub, Int.cast_mul, Int.cast_ofNat, mul_comm (2 : K), add_sub_cancel, neg_neg, add_sub, Nat.cast_inj, eq_sub_iff_add_eq, ← Nat.cast_add, ← sub_eq_neg_add, sub_eq_iff_eq_add] at this linarith [this, hn] have H₂ : ((1 + n + chainTopCoeff (-α) W) • α + chainTop (-α) W : H → K) = (chainTopCoeff α β + 1) • α + β := by simp only [Weight.coe_neg, ← Nat.cast_smul_eq_nsmul ℤ, Nat.cast_add, Nat.cast_one, coe_chainTop, smul_neg, ← neg_smul, hW, ← add_assoc, ← add_smul, ← sub_eq_add_neg] congr 2 ring have := rootSpace_neg_nsmul_add_chainTop_of_le (-α) W H₁ rw [Weight.coe_neg, ← smul_neg, neg_neg, ← Weight.coe_neg, H₂] at this exact this (weightSpace_chainTopCoeff_add_one_nsmul_add α β hα) lemma chainTopCoeff_le_chainLength : chainTopCoeff α β ≤ chainLength α β := by by_cases hα : α.IsZero · simp only [hα.eq, chainTopCoeff_zero, zero_le] rw [← not_lt, ← Nat.succ_le] intro e apply weightSpace_nsmul_add_ne_bot_of_le α β (Nat.sub_le (chainTopCoeff α β) (chainLength α β).succ) rw [← Nat.cast_smul_eq_nsmul ℤ, Nat.cast_sub e, sub_smul, sub_eq_neg_add, add_assoc, ← coe_chainTop, Nat.cast_smul_eq_nsmul] exact rootSpace_neg_nsmul_add_chainTop_of_lt α β hα (Nat.lt_succ_self _) lemma chainBotCoeff_add_chainTopCoeff : chainBotCoeff α β + chainTopCoeff α β = chainLength α β := by by_cases hα : α.IsZero · rw [hα.eq, chainTopCoeff_zero, chainBotCoeff_zero, zero_add, chainLength_of_isZero α β hα] apply le_antisymm · rw [← Nat.le_sub_iff_add_le (chainTopCoeff_le_chainLength α β), ← not_lt, ← Nat.succ_le, chainBotCoeff, ← Weight.coe_neg] intro e apply weightSpace_nsmul_add_ne_bot_of_le _ _ e rw [← Nat.cast_smul_eq_nsmul ℤ, Nat.cast_succ, Nat.cast_sub (chainTopCoeff_le_chainLength α β), LieModule.Weight.coe_neg, smul_neg, ← neg_smul, neg_add_rev, neg_sub, sub_eq_neg_add, ← add_assoc, ← neg_add_rev, add_smul, add_assoc, ← coe_chainTop, neg_smul, ← @Nat.cast_one ℤ, ← Nat.cast_add, Nat.cast_smul_eq_nsmul] exact rootSpace_neg_nsmul_add_chainTop_of_lt α β hα (Nat.lt_succ_self _) · rw [← not_lt] intro e apply rootSpace_neg_nsmul_add_chainTop_of_le α β e rw [← Nat.succ_add, ← Nat.cast_smul_eq_nsmul ℤ, ← neg_smul, coe_chainTop, ← add_assoc, ← add_smul, Nat.cast_add, neg_add, add_assoc, neg_add_self, add_zero, neg_smul, ← smul_neg, Nat.cast_smul_eq_nsmul] exact weightSpace_chainTopCoeff_add_one_nsmul_add (-α) β (Weight.IsNonZero.neg hα) lemma chainTopCoeff_add_chainBotCoeff : chainTopCoeff α β + chainBotCoeff α β = chainLength α β := by rw [add_comm, chainBotCoeff_add_chainTopCoeff] lemma chainBotCoeff_le_chainLength : chainBotCoeff α β ≤ chainLength α β := (Nat.le_add_left _ _).trans_eq (chainTopCoeff_add_chainBotCoeff α β) @[simp] lemma chainLength_neg : chainLength (-α) β = chainLength α β := by rw [← chainBotCoeff_add_chainTopCoeff, ← chainBotCoeff_add_chainTopCoeff, add_comm, Weight.coe_neg, chainTopCoeff_neg, chainBotCoeff_neg] @[simp] lemma chainLength_zero [Nontrivial L] : chainLength 0 β = 0 := by simp [← chainBotCoeff_add_chainTopCoeff] /-- If `β - qα ... β ... β + rα` is the `α`-chain through `β`, then `β (coroot α) = q - r`. In particular, it is an integer. -/ lemma apply_coroot_eq_cast : β (coroot α) = (chainBotCoeff α β - chainTopCoeff α β : ℤ) := by rw [apply_coroot_eq_cast', ← chainTopCoeff_add_chainBotCoeff]; congr 1; omega lemma le_chainBotCoeff_of_rootSpace_ne_top (n : ℤ) (hn : rootSpace H (-n • α + β) ≠ ⊥) : n ≤ chainBotCoeff α β := by contrapose! hn lift n to ℕ using (Nat.cast_nonneg _).trans hn.le rw [Nat.cast_lt, ← @Nat.add_lt_add_iff_right (chainTopCoeff α β), chainBotCoeff_add_chainTopCoeff] at hn have := rootSpace_neg_nsmul_add_chainTop_of_lt α β hα hn rwa [← Nat.cast_smul_eq_nsmul ℤ, ← neg_smul, coe_chainTop, ← add_assoc, ← add_smul, Nat.cast_add, neg_add, add_assoc, neg_add_self, add_zero] at this /-- Members of the `α`-chain through `β` are the only roots of the form `β - kα`. -/ lemma rootSpace_zsmul_add_ne_bot_iff (n : ℤ) : rootSpace H (n • α + β) ≠ ⊥ ↔ n ≤ chainTopCoeff α β ∧ -n ≤ chainBotCoeff α β := by constructor · refine (fun hn ↦ ⟨?_, le_chainBotCoeff_of_rootSpace_ne_top α β hα _ (by rwa [neg_neg])⟩) rw [← chainBotCoeff_neg, ← Weight.coe_neg] apply le_chainBotCoeff_of_rootSpace_ne_top _ _ hα.neg rwa [neg_smul, Weight.coe_neg, smul_neg, neg_neg] · rintro ⟨h₁, h₂⟩ set k := chainTopCoeff α β - n with hk; clear_value k lift k to ℕ using (by rw [hk, le_sub_iff_add_le, zero_add]; exact h₁) rw [eq_sub_iff_add_eq, ← eq_sub_iff_add_eq'] at hk subst hk simp only [neg_sub, tsub_le_iff_right, ← Nat.cast_add, Nat.cast_le, chainBotCoeff_add_chainTopCoeff] at h₂ have := rootSpace_neg_nsmul_add_chainTop_of_le α β h₂ rwa [coe_chainTop, ← Nat.cast_smul_eq_nsmul ℤ, ← neg_smul, ← add_assoc, ← add_smul, ← sub_eq_neg_add] at this lemma rootSpace_zsmul_add_ne_bot_iff_mem (n : ℤ) : rootSpace H (n • α + β) ≠ ⊥ ↔ n ∈ Finset.Icc (-chainBotCoeff α β : ℤ) (chainTopCoeff α β) := by rw [rootSpace_zsmul_add_ne_bot_iff α β hα n, Finset.mem_Icc, and_comm, neg_le] lemma chainTopCoeff_of_eq_zsmul_add (β' : Weight K H L) (n : ℤ) (hβ' : (β' : H → K) = n • α + β) : chainTopCoeff α β' = chainTopCoeff α β - n := by apply le_antisymm · refine le_sub_iff_add_le.mpr ((rootSpace_zsmul_add_ne_bot_iff α β hα _).mp ?_).1 rw [add_smul, add_assoc, ← hβ', ← coe_chainTop] exact (chainTop α β').2 · refine ((rootSpace_zsmul_add_ne_bot_iff α β' hα _).mp ?_).1 rw [hβ', ← add_assoc, ← add_smul, sub_add_cancel, ← coe_chainTop] exact (chainTop α β).2 lemma chainBotCoeff_of_eq_zsmul_add (β' : Weight K H L) (n : ℤ) (hβ' : (β' : H → K) = n • α + β) : chainBotCoeff α β' = chainBotCoeff α β + n := by have : (β' : H → K) = -n • (-α) + β := by rwa [neg_smul, smul_neg, neg_neg] rw [chainBotCoeff, chainBotCoeff, ← Weight.coe_neg, chainTopCoeff_of_eq_zsmul_add (-α) β hα.neg β' (-n) this, sub_neg_eq_add] lemma chainLength_of_eq_zsmul_add (β' : Weight K H L) (n : ℤ) (hβ' : (β' : H → K) = n • α + β) : chainLength α β' = chainLength α β := by by_cases hα : α.IsZero · rw [chainLength_of_isZero _ _ hα, chainLength_of_isZero _ _ hα] · apply Nat.cast_injective (R := ℤ) rw [← chainTopCoeff_add_chainBotCoeff, ← chainTopCoeff_add_chainBotCoeff, Nat.cast_add, Nat.cast_add, chainTopCoeff_of_eq_zsmul_add α β hα β' n hβ', chainBotCoeff_of_eq_zsmul_add α β hα β' n hβ', sub_eq_add_neg, add_add_add_comm, neg_add_self, add_zero] lemma chainTopCoeff_zero_right [Nontrivial L] : chainTopCoeff α (0 : Weight K H L) = 1 := by symm apply eq_of_le_of_not_lt · rw [Nat.one_le_iff_ne_zero] intro e exact α.2 (by simpa [e, Weight.coe_zero] using weightSpace_chainTopCoeff_add_one_nsmul_add α (0 : Weight K H L) hα) obtain ⟨x, hx, x_ne0⟩ := (chainTop α (0 : Weight K H L)).exists_ne_zero obtain ⟨h, e, f, isSl2, he, hf⟩ := exists_isSl2Triple_of_weight_isNonZero hα obtain rfl := isSl2.h_eq_coroot hα he hf have prim : isSl2.HasPrimitiveVectorWith x (chainLength α (0 : Weight K H L) : K) := have := lie_mem_weightSpace_of_mem_weightSpace he hx ⟨x_ne0, (chainLength_smul _ _ hx).symm, by rwa [weightSpace_add_chainTop _ _ hα] at this⟩ obtain ⟨k, hk⟩ : ∃ k : K, k • f = (toEnd K L L f ^ (chainTopCoeff α (0 : Weight K H L) + 1)) x := by have : (toEnd K L L f ^ (chainTopCoeff α (0 : Weight K H L) + 1)) x ∈ rootSpace H (-α) := by convert toEnd_pow_apply_mem hf hx (chainTopCoeff α (0 : Weight K H L) + 1) using 2 rw [coe_chainTop', Weight.coe_zero, add_zero, succ_nsmul', add_assoc, smul_neg, neg_add_self, add_zero] simpa using (finrank_eq_one_iff_of_nonzero' ⟨f, hf⟩ (by simpa using isSl2.f_ne_zero)).mp (finrank_rootSpace_eq_one _ hα.neg) ⟨_, this⟩ apply_fun (⁅f, ·⁆) at hk simp only [lie_smul, lie_self, smul_zero, prim.lie_f_pow_toEnd_f] at hk intro e refine prim.pow_toEnd_f_ne_zero_of_eq_nat rfl ?_ hk.symm have := (apply_coroot_eq_cast' α 0).symm simp only [← @Nat.cast_two ℤ, ← Nat.cast_mul, Weight.zero_apply, Int.cast_eq_zero, sub_eq_zero, Nat.cast_inj] at this rwa [this, Nat.succ_le, two_mul, add_lt_add_iff_left] lemma chainBotCoeff_zero_right [Nontrivial L] : chainBotCoeff α (0 : Weight K H L) = 1 := chainTopCoeff_zero_right (-α) hα.neg lemma chainLength_zero_right [Nontrivial L] : chainLength α 0 = 2 := by rw [← chainBotCoeff_add_chainTopCoeff, chainTopCoeff_zero_right α hα, chainBotCoeff_zero_right α hα] lemma rootSpace_two_smul : rootSpace H (2 • α) = ⊥ := by cases subsingleton_or_nontrivial L · exact IsEmpty.elim inferInstance α simpa [chainTopCoeff_zero_right α hα] using weightSpace_chainTopCoeff_add_one_nsmul_add α (0 : Weight K H L) hα lemma rootSpace_one_div_two_smul : rootSpace H ((2⁻¹ : K) • α) = ⊥ := by by_contra h let W : Weight K H L := ⟨_, h⟩ have hW : 2 • (W : H → K) = α := by show 2 • (2⁻¹ : K) • (α : H → K) = α rw [← Nat.cast_smul_eq_nsmul K, smul_smul]; simp apply α.weightSpace_ne_bot have := rootSpace_two_smul W (fun (e : (W : H → K) = 0) ↦ hα <| by apply_fun (2 • ·) at e; simpa [hW] using e) rwa [hW] at this lemma eq_neg_one_or_eq_zero_or_eq_one_of_eq_smul (k : K) (h : (β : H → K) = k • α) : k = -1 ∨ k = 0 ∨ k = 1 := by cases subsingleton_or_nontrivial L · exact IsEmpty.elim inferInstance α have H := apply_coroot_eq_cast' α β rw [h] at H simp only [Pi.smul_apply, root_apply_coroot hα] at H rcases (chainLength α β).even_or_odd with (⟨n, hn⟩|⟨n, hn⟩) · rw [hn, ← two_mul] at H simp only [smul_eq_mul, Nat.cast_mul, Nat.cast_ofNat, ← mul_sub, ← mul_comm (2 : K), Int.cast_sub, Int.cast_mul, Int.cast_ofNat, Int.cast_natCast, mul_eq_mul_left_iff, OfNat.ofNat_ne_zero, or_false] at H rw [← Int.cast_natCast, ← Int.cast_natCast (chainTopCoeff α β), ← Int.cast_sub] at H have := (rootSpace_zsmul_add_ne_bot_iff_mem α 0 hα (n - chainTopCoeff α β)).mp (by rw [← Int.cast_smul_eq_zsmul K, ← H, ← h, Weight.coe_zero, add_zero]; exact β.2) rw [chainTopCoeff_zero_right α hα, chainBotCoeff_zero_right α hα, Nat.cast_one] at this set k' : ℤ := n - chainTopCoeff α β subst H have : k' ∈ ({-1, 0, 1} : Finset ℤ) := by show k' ∈ Finset.Icc (-1 : ℤ) (1 : ℤ) exact this simpa only [Int.reduceNeg, Finset.mem_insert, Finset.mem_singleton, ← @Int.cast_inj K, Int.cast_zero, Int.cast_neg, Int.cast_one] using this · apply_fun (· / 2) at H rw [hn, smul_eq_mul] at H have hk : k = n + 2⁻¹ - chainTopCoeff α β := by simpa [sub_div, add_div] using H have := (rootSpace_zsmul_add_ne_bot_iff α β hα (chainTopCoeff α β - n)).mpr ?_ swap · simp only [tsub_le_iff_right, le_add_iff_nonneg_right, Nat.cast_nonneg, neg_sub, true_and] rw [← Nat.cast_add, chainBotCoeff_add_chainTopCoeff, hn] omega rw [h, hk, ← Int.cast_smul_eq_zsmul K, ← add_smul] at this simp only [Int.cast_sub, Int.cast_natCast, sub_add_sub_cancel', add_sub_cancel_left, ne_eq] at this cases this (rootSpace_one_div_two_smul α hα) /-- `±α` are the only `K`-multiples of a root `α` that are also (non-zero) roots. -/ lemma eq_neg_or_eq_of_eq_smul (hβ : β.IsNonZero) (k : K) (h : (β : H → K) = k • α) : β = -α ∨ β = α := by by_cases hα : α.IsZero · rw [hα, smul_zero] at h; cases hβ h rcases eq_neg_one_or_eq_zero_or_eq_one_of_eq_smul α β hα k h with (rfl | rfl | rfl) · exact .inl (by ext; rw [h, neg_one_smul]; rfl) · cases hβ (by rwa [zero_smul] at h) · exact .inr (by ext; rw [h, one_smul]) /-- The reflection of a root along another. -/ def reflectRoot (α β : Weight K H L) : Weight K H L where toFun := β - β (coroot α) • α weightSpace_ne_bot' := by by_cases hα : α.IsZero · simpa [hα.eq] using β.weightSpace_ne_bot rw [sub_eq_neg_add, apply_coroot_eq_cast α β, ← neg_smul, ← Int.cast_neg, Int.cast_smul_eq_zsmul, rootSpace_zsmul_add_ne_bot_iff α β hα] omega lemma reflectRoot_isNonZero (α β : Weight K H L) (hβ : β.IsNonZero) : (reflectRoot α β).IsNonZero := by intro e have : β (coroot α) = 0 := by by_cases hα : α.IsZero · simp [coroot_eq_zero_iff.mpr hα] apply add_left_injective (β (coroot α)) simpa [root_apply_coroot hα, mul_two] using congr_fun (sub_eq_zero.mp e) (coroot α) have : reflectRoot α β = β := by ext; simp [reflectRoot, this] exact hβ (this ▸ e) variable (H) /-- The root system of a finite-dimensional Lie algebra with non-degenerate Killing form over a field of characteristic zero, relative to a splitting Cartan subalgebra. -/ def rootSystem : RootSystem {α : Weight K H L // α.IsNonZero} K (Dual K H) H := RootSystem.mk' IsReflexive.toPerfectPairingDual { toFun := (↑) inj' := by intro α β h; ext x; simpa using LinearMap.congr_fun h x } { toFun := coroot ∘ (↑) inj' := by rintro ⟨α, hα⟩ ⟨β, hβ⟩ h; simpa using h } (fun α ↦ by simpa using root_apply_coroot α.property) (by rintro ⟨α, hα⟩ - ⟨⟨β, hβ⟩, rfl⟩ simp only [Function.Embedding.coeFn_mk, IsReflexive.toPerfectPairingDual_toLin, Function.comp_apply, Set.mem_range, Subtype.exists, exists_prop] exact ⟨reflectRoot α β, reflectRoot_isNonZero α β hβ, rfl⟩) (by convert span_weight_isNonZero_eq_top K L H; ext; simp) @[simp] lemma rootSystem_toLin_apply (f x) : (rootSystem H).toLin f x = f x := rfl @[simp] lemma rootSystem_pairing_apply (α β) : (rootSystem H).pairing β α = β.1 (coroot α.1) := rfl @[simp] lemma rootSystem_root_apply (α) : (rootSystem H).root α = α := rfl @[simp] lemma rootSystem_coroot_apply (α) : (rootSystem H).coroot α = coroot α := rfl theorem isCrystallographic_rootSystem : (rootSystem H).IsCrystallographic := by rintro α _ ⟨β, rfl⟩ exact ⟨chainBotCoeff β.1 α.1 - chainTopCoeff β.1 α.1, by simp [apply_coroot_eq_cast β.1 α.1]⟩ theorem isReduced_rootSystem : (rootSystem H).IsReduced := by intro α β e rw [LinearIndependent.pair_iff' ((rootSystem H).ne_zero _), not_forall] at e simp only [Nat.succ_eq_add_one, Nat.reduceAdd, rootSystem_root_apply, ne_eq, not_not] at e obtain ⟨u, hu⟩ := e obtain (h | h) := eq_neg_or_eq_of_eq_smul α.1 β.1 β.2 u (by ext x; exact DFunLike.congr_fun hu.symm x) · right; ext x; simpa [neg_eq_iff_eq_neg] using DFunLike.congr_fun h.symm x · left; ext x; simpa using DFunLike.congr_fun h.symm x end LieAlgebra.IsKilling
Algebra\Module\Algebra.lean
/- Copyright (c) 2022 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Algebra.Basic /-! # Additional facts about modules over algebras. -/ namespace LinearMap section RestrictScalars variable (k : Type*) [CommSemiring k] (A : Type*) [Semiring A] [Algebra k A] variable (M : Type*) [AddCommMonoid M] [Module k M] [Module A M] [IsScalarTower k A M] variable (N : Type*) [AddCommMonoid N] [Module k N] [Module A N] [IsScalarTower k A N] /-- Restriction of scalars for linear maps between modules over a `k`-algebra is itself `k`-linear. -/ @[simps] def restrictScalarsLinearMap : (M →ₗ[A] N) →ₗ[k] M →ₗ[k] N where toFun := LinearMap.restrictScalars k map_add' _ _ := rfl map_smul' _ _ := rfl end RestrictScalars end LinearMap
Algebra\Module\Basic.lean
/- Copyright (c) 2015 Nathaniel Thomas. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Group.Action.Pi import Mathlib.Algebra.Group.Indicator import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Field.Basic import Mathlib.GroupTheory.GroupAction.Group /-! # Further basic results about modules. -/ assert_not_exists Nonneg.inv open Function Set universe u v variable {α R M M₂ : Type*} @[deprecated (since := "2024-04-17")] alias map_nat_cast_smul := map_natCast_smul theorem map_inv_natCast_smul [AddCommMonoid M] [AddCommMonoid M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [DivisionSemiring R] [DivisionSemiring S] [Module R M] [Module S M₂] (n : ℕ) (x : M) : f ((n⁻¹ : R) • x) = (n⁻¹ : S) • f x := by by_cases hR : (n : R) = 0 <;> by_cases hS : (n : S) = 0 · simp [hR, hS, map_zero f] · suffices ∀ y, f y = 0 by rw [this, this, smul_zero] clear x intro x rw [← inv_smul_smul₀ hS (f x), ← map_natCast_smul f R S] simp [hR, map_zero f] · suffices ∀ y, f y = 0 by simp [this] clear x intro x rw [← smul_inv_smul₀ hR x, map_natCast_smul f R S, hS, zero_smul] · rw [← inv_smul_smul₀ hS (f _), ← map_natCast_smul f R S, smul_inv_smul₀ hR] @[deprecated (since := "2024-04-17")] alias map_inv_nat_cast_smul := map_inv_natCast_smul theorem map_inv_intCast_smul [AddCommGroup M] [AddCommGroup M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [DivisionRing R] [DivisionRing S] [Module R M] [Module S M₂] (z : ℤ) (x : M) : f ((z⁻¹ : R) • x) = (z⁻¹ : S) • f x := by obtain ⟨n, rfl | rfl⟩ := z.eq_nat_or_neg · rw [Int.cast_natCast, Int.cast_natCast, map_inv_natCast_smul _ R S] · simp_rw [Int.cast_neg, Int.cast_natCast, inv_neg, neg_smul, map_neg, map_inv_natCast_smul _ R S] @[deprecated (since := "2024-04-17")] alias map_inv_int_cast_smul := map_inv_intCast_smul /-- If `E` is a vector space over two division semirings `R` and `S`, then scalar multiplications agree on inverses of natural numbers in `R` and `S`. -/ theorem inv_natCast_smul_eq {E : Type*} (R S : Type*) [AddCommMonoid E] [DivisionSemiring R] [DivisionSemiring S] [Module R E] [Module S E] (n : ℕ) (x : E) : (n⁻¹ : R) • x = (n⁻¹ : S) • x := map_inv_natCast_smul (AddMonoidHom.id E) R S n x @[deprecated (since := "2024-04-17")] alias inv_nat_cast_smul_eq := inv_natCast_smul_eq /-- If `E` is a vector space over two division rings `R` and `S`, then scalar multiplications agree on inverses of integer numbers in `R` and `S`. -/ theorem inv_intCast_smul_eq {E : Type*} (R S : Type*) [AddCommGroup E] [DivisionRing R] [DivisionRing S] [Module R E] [Module S E] (n : ℤ) (x : E) : (n⁻¹ : R) • x = (n⁻¹ : S) • x := map_inv_intCast_smul (AddMonoidHom.id E) R S n x @[deprecated (since := "2024-04-17")] alias inv_int_cast_smul_eq := inv_intCast_smul_eq /-- If `E` is a vector space over a division semiring `R` and has a monoid action by `α`, then that action commutes by scalar multiplication of inverses of natural numbers in `R`. -/ theorem inv_natCast_smul_comm {α E : Type*} (R : Type*) [AddCommMonoid E] [DivisionSemiring R] [Monoid α] [Module R E] [DistribMulAction α E] (n : ℕ) (s : α) (x : E) : (n⁻¹ : R) • s • x = s • (n⁻¹ : R) • x := (map_inv_natCast_smul (DistribMulAction.toAddMonoidHom E s) R R n x).symm @[deprecated (since := "2024-04-17")] alias inv_nat_cast_smul_comm := inv_natCast_smul_comm /-- If `E` is a vector space over a division ring `R` and has a monoid action by `α`, then that action commutes by scalar multiplication of inverses of integers in `R` -/ theorem inv_intCast_smul_comm {α E : Type*} (R : Type*) [AddCommGroup E] [DivisionRing R] [Monoid α] [Module R E] [DistribMulAction α E] (n : ℤ) (s : α) (x : E) : (n⁻¹ : R) • s • x = s • (n⁻¹ : R) • x := (map_inv_intCast_smul (DistribMulAction.toAddMonoidHom E s) R R n x).symm @[deprecated (since := "2024-04-17")] alias inv_int_cast_smul_comm := inv_intCast_smul_comm section NoZeroSMulDivisors section Module variable [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] instance [NoZeroSMulDivisors ℤ M] : NoZeroSMulDivisors ℕ M := ⟨fun {c x} hcx ↦ by rwa [← Nat.cast_smul_eq_nsmul ℤ c x, smul_eq_zero, Nat.cast_eq_zero] at hcx⟩ end Module section GroupWithZero variable [GroupWithZero R] [AddMonoid M] [DistribMulAction R M] -- see note [lower instance priority] /-- This instance applies to `DivisionSemiring`s, in particular `NNReal` and `NNRat`. -/ instance (priority := 100) GroupWithZero.toNoZeroSMulDivisors : NoZeroSMulDivisors R M := ⟨fun {a _} h ↦ or_iff_not_imp_left.2 fun ha ↦ (smul_eq_zero_iff_eq <| Units.mk0 a ha).1 h⟩ end GroupWithZero end NoZeroSMulDivisors namespace Function lemma support_smul_subset_left [Zero R] [Zero M] [SMulWithZero R M] (f : α → R) (g : α → M) : support (f • g) ⊆ support f := fun x hfg hf ↦ hfg <| by rw [Pi.smul_apply', hf, zero_smul] -- Changed (2024-01-21): this lemma was generalised; -- the old version is now called `support_const_smul_subset`. lemma support_smul_subset_right [Zero M] [SMulZeroClass R M] (f : α → R) (g : α → M) : support (f • g) ⊆ support g := fun x hbf hf ↦ hbf <| by rw [Pi.smul_apply', hf, smul_zero] lemma support_const_smul_of_ne_zero [Zero R] [Zero M] [SMulWithZero R M] [NoZeroSMulDivisors R M] (c : R) (g : α → M) (hc : c ≠ 0) : support (c • g) = support g := ext fun x ↦ by simp only [hc, mem_support, Pi.smul_apply, Ne, smul_eq_zero, false_or_iff] lemma support_smul [Zero R] [Zero M] [SMulWithZero R M] [NoZeroSMulDivisors R M] (f : α → R) (g : α → M) : support (f • g) = support f ∩ support g := ext fun _ => smul_ne_zero_iff lemma support_const_smul_subset [Zero M] [SMulZeroClass R M] (a : R) (f : α → M) : support (a • f) ⊆ support f := support_smul_subset_right (fun _ ↦ a) f end Function namespace Set section SMulZeroClass variable [Zero M] [SMulZeroClass R M] lemma indicator_smul_apply (s : Set α) (r : α → R) (f : α → M) (a : α) : indicator s (fun a ↦ r a • f a) a = r a • indicator s f a := by dsimp only [indicator] split_ifs exacts [rfl, (smul_zero (r a)).symm] lemma indicator_smul (s : Set α) (r : α → R) (f : α → M) : indicator s (fun a ↦ r a • f a) = fun a ↦ r a • indicator s f a := funext <| indicator_smul_apply s r f lemma indicator_const_smul_apply (s : Set α) (r : R) (f : α → M) (a : α) : indicator s (r • f ·) a = r • indicator s f a := indicator_smul_apply s (fun _ ↦ r) f a lemma indicator_const_smul (s : Set α) (r : R) (f : α → M) : indicator s (r • f ·) = (r • indicator s f ·) := funext <| indicator_const_smul_apply s r f end SMulZeroClass section SMulWithZero variable [Zero R] [Zero M] [SMulWithZero R M] lemma indicator_smul_apply_left (s : Set α) (r : α → R) (f : α → M) (a : α) : indicator s (fun a ↦ r a • f a) a = indicator s r a • f a := by dsimp only [indicator] split_ifs exacts [rfl, (zero_smul _ (f a)).symm] lemma indicator_smul_left (s : Set α) (r : α → R) (f : α → M) : indicator s (fun a ↦ r a • f a) = fun a ↦ indicator s r a • f a := funext <| indicator_smul_apply_left _ _ _ lemma indicator_smul_const_apply (s : Set α) (r : α → R) (m : M) (a : α) : indicator s (r · • m) a = indicator s r a • m := indicator_smul_apply_left _ _ _ _ lemma indicator_smul_const (s : Set α) (r : α → R) (m : M) : indicator s (r · • m) = (indicator s r · • m) := funext <| indicator_smul_const_apply _ _ _ end SMulWithZero section MulZeroOneClass variable [MulZeroOneClass R] lemma smul_indicator_one_apply (s : Set α) (r : R) (a : α) : r • s.indicator (1 : α → R) a = s.indicator (fun _ ↦ r) a := by simp_rw [← indicator_const_smul_apply, Pi.one_apply, smul_eq_mul, mul_one] end MulZeroOneClass end Set assert_not_exists Multiset
Algebra\Module\BigOperators.lean
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Yury Kudryashov, Yaël Dillies -/ import Mathlib.Algebra.Module.Defs import Mathlib.Data.Fintype.BigOperators import Mathlib.GroupTheory.GroupAction.BigOperators /-! # Finite sums over modules over a ring -/ variable {ι κ α β R M : Type*} section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] (r s : R) (x y : M) theorem List.sum_smul {l : List R} {x : M} : l.sum • x = (l.map fun r ↦ r • x).sum := map_list_sum ((smulAddHom R M).flip x) l theorem Multiset.sum_smul {l : Multiset R} {x : M} : l.sum • x = (l.map fun r ↦ r • x).sum := ((smulAddHom R M).flip x).map_multiset_sum l theorem Multiset.sum_smul_sum {s : Multiset R} {t : Multiset M} : s.sum • t.sum = ((s ×ˢ t).map fun p : R × M ↦ p.fst • p.snd).sum := by induction' s using Multiset.induction with a s ih · simp · simp [add_smul, ih, ← Multiset.smul_sum] theorem Finset.sum_smul {f : ι → R} {s : Finset ι} {x : M} : (∑ i ∈ s, f i) • x = ∑ i ∈ s, f i • x := map_sum ((smulAddHom R M).flip x) f s lemma Finset.sum_smul_sum (s : Finset α) (t : Finset β) {f : α → R} {g : β → M} : (∑ i ∈ s, f i) • ∑ j ∈ t, g j = ∑ i ∈ s, ∑ j ∈ t, f i • g j := by simp_rw [sum_smul, ← smul_sum] lemma Fintype.sum_smul_sum [Fintype α] [Fintype β] (f : α → R) (g : β → M) : (∑ i, f i) • ∑ j, g j = ∑ i, ∑ j, f i • g j := Finset.sum_smul_sum _ _ end AddCommMonoid theorem Finset.cast_card [CommSemiring R] (s : Finset α) : (s.card : R) = ∑ a ∈ s, 1 := by rw [Finset.sum_const, Nat.smul_one_eq_cast] open Finset namespace Fintype variable [DecidableEq ι] [Fintype ι] [AddCommMonoid α] lemma sum_piFinset_apply (f : κ → α) (s : Finset κ) (i : ι) : ∑ g ∈ piFinset fun _ : ι ↦ s, f (g i) = s.card ^ (card ι - 1) • ∑ b ∈ s, f b := by classical rw [Finset.sum_comp] simp only [eval_image_piFinset_const, card_filter_piFinset_const s, ite_smul, zero_smul, smul_sum, sum_ite_mem, inter_self] end Fintype
Algebra\Module\Bimodule.lean
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.RingTheory.TensorProduct.Basic /-! # Bimodules One frequently encounters situations in which several sets of scalars act on a single space, subject to compatibility condition(s). A distinguished instance of this is the theory of bimodules: one has two rings `R`, `S` acting on an additive group `M`, with `R` acting covariantly ("on the left") and `S` acting contravariantly ("on the right"). The compatibility condition is just: `(r • m) • s = r • (m • s)` for all `r : R`, `s : S`, `m : M`. This situation can be set up in Mathlib as: ```lean variable (R S M : Type*) [Ring R] [Ring S] variable [AddCommGroup M] [Module R M] [Module Sᵐᵒᵖ M] [SMulCommClass R Sᵐᵒᵖ M] ``` The key fact is: ```lean example : Module (R ⊗[ℕ] Sᵐᵒᵖ) M := TensorProduct.Algebra.module ``` Note that the corresponding result holds for the canonically isomorphic ring `R ⊗[ℤ] Sᵐᵒᵖ` but it is preferable to use the `R ⊗[ℕ] Sᵐᵒᵖ` instance since it works without additive inverses. Bimodules are thus just a special case of `Module`s and most of their properties follow from the theory of `Module`s. In particular a two-sided Submodule of a bimodule is simply a term of type `Submodule (R ⊗[ℕ] Sᵐᵒᵖ) M`. This file is a place to collect results which are specific to bimodules. ## Main definitions * `Subbimodule.mk` * `Subbimodule.smul_mem` * `Subbimodule.smul_mem'` * `Subbimodule.toSubmodule` * `Subbimodule.toSubmodule'` ## Implementation details For many definitions and lemmas it is preferable to set things up without opposites, i.e., as: `[Module S M] [SMulCommClass R S M]` rather than `[Module Sᵐᵒᵖ M] [SMulCommClass R Sᵐᵒᵖ M]`. The corresponding results for opposites then follow automatically and do not require taking advantage of the fact that `(Sᵐᵒᵖ)ᵐᵒᵖ` is defeq to `S`. ## TODO Develop the theory of two-sided ideals, which have type `Submodule (R ⊗[ℕ] Rᵐᵒᵖ) R`. -/ open TensorProduct attribute [local instance] TensorProduct.Algebra.module namespace Subbimodule section Algebra variable {R A B M : Type*} variable [CommSemiring R] [AddCommMonoid M] [Module R M] variable [Semiring A] [Semiring B] [Module A M] [Module B M] variable [Algebra R A] [Algebra R B] variable [IsScalarTower R A M] [IsScalarTower R B M] variable [SMulCommClass A B M] /-- A constructor for a subbimodule which demands closure under the two sets of scalars individually, rather than jointly via their tensor product. Note that `R` plays no role but it is convenient to make this generalisation to support the cases `R = ℕ` and `R = ℤ` which both show up naturally. See also `Subbimodule.baseChange`. -/ @[simps] def mk (p : AddSubmonoid M) (hA : ∀ (a : A) {m : M}, m ∈ p → a • m ∈ p) (hB : ∀ (b : B) {m : M}, m ∈ p → b • m ∈ p) : Submodule (A ⊗[R] B) M := { p with carrier := p smul_mem' := fun ab m => TensorProduct.induction_on ab (fun _ => by simpa only [zero_smul] using p.zero_mem) (fun a b hm => by simpa only [TensorProduct.Algebra.smul_def] using hA a (hB b hm)) fun z w hz hw hm => by simpa only [add_smul] using p.add_mem (hz hm) (hw hm) } theorem smul_mem (p : Submodule (A ⊗[R] B) M) (a : A) {m : M} (hm : m ∈ p) : a • m ∈ p := by suffices a • m = a ⊗ₜ[R] (1 : B) • m by exact this.symm ▸ p.smul_mem _ hm simp [TensorProduct.Algebra.smul_def] theorem smul_mem' (p : Submodule (A ⊗[R] B) M) (b : B) {m : M} (hm : m ∈ p) : b • m ∈ p := by suffices b • m = (1 : A) ⊗ₜ[R] b • m by exact this.symm ▸ p.smul_mem _ hm simp [TensorProduct.Algebra.smul_def] /-- If `A` and `B` are also `Algebra`s over yet another set of scalars `S` then we may "base change" from `R` to `S`. -/ @[simps!] def baseChange (S : Type*) [CommSemiring S] [Module S M] [Algebra S A] [Algebra S B] [IsScalarTower S A M] [IsScalarTower S B M] (p : Submodule (A ⊗[R] B) M) : Submodule (A ⊗[S] B) M := mk p.toAddSubmonoid (smul_mem p) (smul_mem' p) /-- Forgetting the `B` action, a `Submodule` over `A ⊗[R] B` is just a `Submodule` over `A`. -/ @[simps] def toSubmodule (p : Submodule (A ⊗[R] B) M) : Submodule A M := { p with carrier := p smul_mem' := smul_mem p } /-- Forgetting the `A` action, a `Submodule` over `A ⊗[R] B` is just a `Submodule` over `B`. -/ @[simps] def toSubmodule' (p : Submodule (A ⊗[R] B) M) : Submodule B M := { p with carrier := p smul_mem' := smul_mem' p } end Algebra section Ring variable (R S M : Type*) [Ring R] [Ring S] variable [AddCommGroup M] [Module R M] [Module S M] [SMulCommClass R S M] /-- A `Submodule` over `R ⊗[ℕ] S` is naturally also a `Submodule` over the canonically-isomorphic ring `R ⊗[ℤ] S`. -/ @[simps!] def toSubbimoduleInt (p : Submodule (R ⊗[ℕ] S) M) : Submodule (R ⊗[ℤ] S) M := baseChange ℤ p /-- A `Submodule` over `R ⊗[ℤ] S` is naturally also a `Submodule` over the canonically-isomorphic ring `R ⊗[ℕ] S`. -/ @[simps!] def toSubbimoduleNat (p : Submodule (R ⊗[ℤ] S) M) : Submodule (R ⊗[ℕ] S) M := baseChange ℕ p end Ring end Subbimodule
Algebra\Module\Card.lean
/- Copyright (c) 2023 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Algebra.Module.Defs import Mathlib.SetTheory.Cardinal.Basic /-! # Cardinality of a module This file proves that the cardinality of a module without zero divisors is at least the cardinality of its base ring. -/ open Function universe u v namespace Cardinal /-- The cardinality of a nontrivial module over a ring is at least the cardinality of the ring if there are no zero divisors (for instance if the ring is a field) -/ theorem mk_le_of_module (R : Type u) (E : Type v) [AddCommGroup E] [Ring R] [Module R E] [Nontrivial E] [NoZeroSMulDivisors R E] : Cardinal.lift.{v} (#R) ≤ Cardinal.lift.{u} (#E) := by obtain ⟨x, hx⟩ : ∃ (x : E), x ≠ 0 := exists_ne 0 have : Injective (fun k ↦ k • x) := smul_left_injective R hx exact lift_mk_le_lift_mk_of_injective this end Cardinal
Algebra\Module\CharacterModule.lean
/- Copyright (c) 2023 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang, Junyan Xu -/ import Mathlib.Algebra.Category.ModuleCat.Basic import Mathlib.Algebra.Category.Grp.Injective import Mathlib.Topology.Instances.AddCircle import Mathlib.LinearAlgebra.Isomorphisms /-! # Character module of a module For commutative ring `R` and an `R`-module `M` and an injective module `D`, its character module `M⋆` is defined to be `R`-linear maps `M ⟶ D`. `M⋆` also has an `R`-module structure given by `(r • f) m = f (r • m)`. ## Main results - `CharacterModuleFunctor` : the contravariant functor of `R`-modules where `M ↦ M⋆` and an `R`-linear map `l : M ⟶ N` induces an `R`-linear map `l⋆ : f ↦ f ∘ l` where `f : N⋆`. - `LinearMap.dual_surjective_of_injective` : If `l` is injective then `l⋆` is surjective, in another word taking character module as a functor sends monos to epis. - `CharacterModule.homEquiv` : there is a bijection between linear map `Hom(N, M⋆)` and `(N ⊗ M)⋆` given by `curry` and `uncurry`. -/ open CategoryTheory universe uR uA uB variable (R : Type uR) [CommRing R] variable (A : Type uA) [AddCommGroup A] variable (A' : Type*) [AddCommGroup A'] variable (B : Type uB) [AddCommGroup B] /-- The character module of an abelian group `A` in the unit rational circle is `A⋆ := Hom_ℤ(A, ℚ ⧸ ℤ)`. -/ def CharacterModule : Type uA := A →+ AddCircle (1 : ℚ) namespace CharacterModule instance : FunLike (CharacterModule A) A (AddCircle (1 : ℚ)) where coe c := c.toFun coe_injective' _ _ _ := by aesop instance : LinearMapClass (CharacterModule A) ℤ A (AddCircle (1 : ℚ)) where map_add _ _ _ := by rw [AddMonoidHom.map_add] map_smulₛₗ _ _ _ := by rw [AddMonoidHom.map_zsmul, RingHom.id_apply] instance : AddCommGroup (CharacterModule A) := inferInstanceAs (AddCommGroup (A →+ _)) @[ext] theorem ext {c c' : CharacterModule A} (h : ∀ x, c x = c' x) : c = c' := DFunLike.ext _ _ h section module variable [Module R A] [Module R A'] [Module R B] instance : Module R (CharacterModule A) := Module.compHom (A →+ _) (RingEquiv.toOpposite _ |>.toRingHom : R →+* Rᵈᵐᵃ) variable {R A B} @[simp] lemma smul_apply (c : CharacterModule A) (r : R) (a : A) : (r • c) a = c (r • a) := rfl /-- Given an abelian group homomorphism `f : A → B`, `f⋆(L) := L ∘ f` defines a linear map from `B⋆` to `A⋆`. -/ @[simps] def dual (f : A →ₗ[R] B) : CharacterModule B →ₗ[R] CharacterModule A where toFun L := L.comp f.toAddMonoidHom map_add' := by aesop map_smul' r c := by ext x; exact congr(c $(f.map_smul r x)).symm lemma dual_surjective_of_injective (f : A →ₗ[R] B) (hf : Function.Injective f) : Function.Surjective (dual f) := (Module.Baer.of_divisible _).extension_property_addMonoidHom _ hf /-- Two isomorphic modules have isomorphic character modules. -/ def congr (e : A ≃ₗ[R] B) : CharacterModule A ≃ₗ[R] CharacterModule B := .ofLinear (dual e.symm) (dual e) (by ext c _; exact congr(c $(e.right_inv _))) (by ext c _; exact congr(c $(e.left_inv _))) open TensorProduct /-- Any linear map `L : A → B⋆` induces a character in `(A ⊗ B)⋆` by `a ⊗ b ↦ L a b`. -/ @[simps] noncomputable def uncurry : (A →ₗ[R] CharacterModule B) →ₗ[R] CharacterModule (A ⊗[R] B) where toFun c := TensorProduct.liftAddHom c.toAddMonoidHom fun r a b ↦ congr($(c.map_smul r a) b) map_add' c c' := DFunLike.ext _ _ fun x ↦ by refine x.induction_on ?_ ?_ ?_ <;> aesop map_smul' r c := DFunLike.ext _ _ fun x ↦ x.induction_on (by simp_rw [map_zero]) (fun a b ↦ congr($(c.map_smul r a) b).symm) (by aesop) /-- Any character `c` in `(A ⊗ B)⋆` induces a linear map `A → B⋆` by `a ↦ b ↦ c (a ⊗ b)`. -/ @[simps] noncomputable def curry : CharacterModule (A ⊗[R] B) →ₗ[R] (A →ₗ[R] CharacterModule B) where toFun c := { toFun := (c.comp <| TensorProduct.mk R A B ·) map_add' := fun a a' ↦ DFunLike.ext _ _ fun b ↦ congr(c <| $(map_add (mk R A B) _ _) b).trans (c.map_add _ _) map_smul' := fun r a ↦ by ext; exact congr(c $(TensorProduct.tmul_smul _ _ _)).symm } map_add' c c' := rfl map_smul' r c := by ext; exact congr(c $(TensorProduct.tmul_smul _ _ _)).symm /-- Linear maps into a character module are exactly characters of the tensor product. -/ @[simps!] noncomputable def homEquiv : (A →ₗ[R] CharacterModule B) ≃ₗ[R] CharacterModule (A ⊗[R] B) := .ofLinear uncurry curry (by ext _ z; refine z.induction_on ?_ ?_ ?_ <;> aesop) (by aesop) theorem dual_rTensor_conj_homEquiv (f : A →ₗ[R] A') : homEquiv.symm.toLinearMap ∘ₗ dual (f.rTensor B) ∘ₗ homEquiv.toLinearMap = f.lcomp R _ := rfl end module /-- `ℤ⋆`, the character module of `ℤ` in the unit rational circle. -/ protected abbrev int : Type := CharacterModule ℤ /-- Given `n : ℕ`, the map `m ↦ m / n`. -/ protected abbrev int.divByNat (n : ℕ) : CharacterModule.int := LinearMap.toSpanSingleton ℤ _ (QuotientAddGroup.mk (n : ℚ)⁻¹) |>.toAddMonoidHom protected lemma int.divByNat_self (n : ℕ) : int.divByNat n n = 0 := by obtain rfl | h0 := eq_or_ne n 0 · apply map_zero exact (AddCircle.coe_eq_zero_iff _).mpr ⟨1, by simp [mul_inv_cancel (Nat.cast_ne_zero (R := ℚ).mpr h0)]⟩ variable {A} /-- The `ℤ`-submodule spanned by a single element `a` is isomorphic to the quotient of `ℤ` by the ideal generated by the order of `a`. -/ @[simps!] noncomputable def intSpanEquivQuotAddOrderOf (a : A) : (ℤ ∙ a) ≃ₗ[ℤ] ℤ ⧸ Ideal.span {(addOrderOf a : ℤ)} := LinearEquiv.ofEq _ _ (LinearMap.span_singleton_eq_range ℤ A a) ≪≫ₗ (LinearMap.quotKerEquivRange <| LinearMap.toSpanSingleton ℤ A a).symm ≪≫ₗ Submodule.quotEquivOfEq _ _ (by ext1 x rw [Ideal.mem_span_singleton, addOrderOf_dvd_iff_zsmul_eq_zero, LinearMap.mem_ker, LinearMap.toSpanSingleton_apply]) lemma intSpanEquivQuotAddOrderOf_apply_self (a : A) : intSpanEquivQuotAddOrderOf a ⟨a, Submodule.mem_span_singleton_self a⟩ = Submodule.Quotient.mk 1 := (LinearEquiv.eq_symm_apply _).mp <| Subtype.ext (one_zsmul _).symm /-- For an abelian group `A` and an element `a ∈ A`, there is a character `c : ℤ ∙ a → ℚ ⧸ ℤ` given by `m • a ↦ m / n` where `n` is the smallest positive integer such that `n • a = 0` and when such `n` does not exist, `c` is defined by `m • a ↦ m / 2`. -/ noncomputable def ofSpanSingleton (a : A) : CharacterModule (ℤ ∙ a) := let l : ℤ ⧸ Ideal.span {(addOrderOf a : ℤ)} →ₗ[ℤ] AddCircle (1 : ℚ) := Submodule.liftQSpanSingleton _ (CharacterModule.int.divByNat <| if addOrderOf a = 0 then 2 else addOrderOf a).toIntLinearMap <| by split_ifs with h · rw [h, Nat.cast_zero, map_zero] · apply CharacterModule.int.divByNat_self l ∘ₗ intSpanEquivQuotAddOrderOf a |>.toAddMonoidHom lemma eq_zero_of_ofSpanSingleton_apply_self (a : A) (h : ofSpanSingleton a ⟨a, Submodule.mem_span_singleton_self a⟩ = 0) : a = 0 := by erw [ofSpanSingleton, LinearMap.toAddMonoidHom_coe, LinearMap.comp_apply, intSpanEquivQuotAddOrderOf_apply_self, Submodule.liftQSpanSingleton_apply, AddMonoidHom.coe_toIntLinearMap, int.divByNat, LinearMap.toSpanSingleton_one, AddCircle.coe_eq_zero_iff] at h rcases h with ⟨n, hn⟩ apply_fun Rat.den at hn rw [zsmul_one, Rat.den_intCast, Rat.inv_natCast_den_of_pos] at hn · split_ifs at hn · cases hn · rwa [eq_comm, AddMonoid.addOrderOf_eq_one_iff] at hn · split_ifs with h · norm_num · exact Nat.pos_of_ne_zero h lemma exists_character_apply_ne_zero_of_ne_zero {a : A} (ne_zero : a ≠ 0) : ∃ (c : CharacterModule A), c a ≠ 0 := have ⟨c, hc⟩ := dual_surjective_of_injective _ (Submodule.injective_subtype _) (ofSpanSingleton a) ⟨c, fun h ↦ ne_zero <| eq_zero_of_ofSpanSingleton_apply_self a <| by rwa [← hc]⟩ lemma eq_zero_of_character_apply {a : A} (h : ∀ c : CharacterModule A, c a = 0) : a = 0 := by contrapose! h; exact exists_character_apply_ne_zero_of_ne_zero h variable [Module R A] [Module R A'] [Module R B] {R A' B} lemma dual_surjective_iff_injective {f : A →ₗ[R] A'} : Function.Surjective (dual f) ↔ Function.Injective f := ⟨fun h ↦ (injective_iff_map_eq_zero _).2 fun a h0 ↦ eq_zero_of_character_apply fun c ↦ by obtain ⟨c, rfl⟩ := h c; exact congr(c $h0).trans c.map_zero, dual_surjective_of_injective f⟩ theorem _root_.rTensor_injective_iff_lcomp_surjective {f : A →ₗ[R] A'} : Function.Injective (f.rTensor B) ↔ Function.Surjective (f.lcomp R <| CharacterModule B) := by simp [← dual_rTensor_conj_homEquiv, dual_surjective_iff_injective] end CharacterModule
Algebra\Module\DedekindDomain.lean
/- Copyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Pierre-Alexandre Bazin -/ import Mathlib.Algebra.Module.Torsion import Mathlib.RingTheory.DedekindDomain.Ideal /-! # Modules over a Dedekind domain Over a Dedekind domain, an `I`-torsion module is the internal direct sum of its `p i ^ e i`-torsion submodules, where `I = ∏ i, p i ^ e i` is its unique decomposition in prime ideals. Therefore, as any finitely generated torsion module is `I`-torsion for some `I`, it is an internal direct sum of its `p i ^ e i`-torsion submodules for some prime ideals `p i` and numbers `e i`. -/ universe u v variable {R : Type u} [CommRing R] [IsDomain R] {M : Type v} [AddCommGroup M] [Module R M] open scoped DirectSum namespace Submodule variable [IsDedekindDomain R] open UniqueFactorizationMonoid /-- Over a Dedekind domain, an `I`-torsion module is the internal direct sum of its `p i ^ e i`- torsion submodules, where `I = ∏ i, p i ^ e i` is its unique decomposition in prime ideals. -/ theorem isInternal_prime_power_torsion_of_is_torsion_by_ideal [DecidableEq (Ideal R)] {I : Ideal R} (hI : I ≠ ⊥) (hM : Module.IsTorsionBySet R M I) : DirectSum.IsInternal fun p : (factors I).toFinset => torsionBySet R M (p ^ (factors I).count ↑p : Ideal R) := by let P := factors I have prime_of_mem := fun p (hp : p ∈ P.toFinset) => prime_of_factor p (Multiset.mem_toFinset.mp hp) apply torsionBySet_isInternal (p := fun p => p ^ P.count p) _ · convert hM rw [← Finset.inf_eq_iInf, IsDedekindDomain.inf_prime_pow_eq_prod, ← Finset.prod_multiset_count, ← associated_iff_eq] · exact factors_prod hI · exact prime_of_mem · exact fun _ _ _ _ ij => ij · intro p hp q hq pq; dsimp rw [irreducible_pow_sup] · suffices (normalizedFactors _).count p = 0 by rw [this, zero_min, pow_zero, Ideal.one_eq_top] rw [Multiset.count_eq_zero, normalizedFactors_of_irreducible_pow (prime_of_mem q hq).irreducible, Multiset.mem_replicate] exact fun H => pq <| H.2.trans <| normalize_eq q · rw [← Ideal.zero_eq_bot]; apply pow_ne_zero; exact (prime_of_mem q hq).ne_zero · exact (prime_of_mem p hp).irreducible /-- A finitely generated torsion module over a Dedekind domain is an internal direct sum of its `p i ^ e i`-torsion submodules where `p i` are factors of `(⊤ : Submodule R M).annihilator` and `e i` are their multiplicities. -/ theorem isInternal_prime_power_torsion [DecidableEq (Ideal R)] [Module.Finite R M] (hM : Module.IsTorsion R M) : DirectSum.IsInternal fun p : (factors (⊤ : Submodule R M).annihilator).toFinset => torsionBySet R M (p ^ (factors (⊤ : Submodule R M).annihilator).count ↑p : Ideal R) := by have hM' := Module.isTorsionBySet_annihilator_top R M have hI := Submodule.annihilator_top_inter_nonZeroDivisors hM refine isInternal_prime_power_torsion_of_is_torsion_by_ideal ?_ hM' rw [← Set.nonempty_iff_ne_empty] at hI; rw [Submodule.ne_bot_iff] obtain ⟨x, H, hx⟩ := hI; exact ⟨x, H, nonZeroDivisors.ne_zero hx⟩ /-- A finitely generated torsion module over a Dedekind domain is an internal direct sum of its `p i ^ e i`-torsion submodules for some prime ideals `p i` and numbers `e i`. -/ theorem exists_isInternal_prime_power_torsion [Module.Finite R M] (hM : Module.IsTorsion R M) : ∃ (P : Finset <| Ideal R) (_ : DecidableEq P) (_ : ∀ p ∈ P, Prime p) (e : P → ℕ), DirectSum.IsInternal fun p : P => torsionBySet R M (p ^ e p : Ideal R) := by classical exact ⟨_, _, fun p hp => prime_of_factor p (Multiset.mem_toFinset.mp hp), _, isInternal_prime_power_torsion hM⟩ end Submodule
Algebra\Module\Defs.lean
/- Copyright (c) 2015 Nathaniel Thomas. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Group.Hom.End import Mathlib.Algebra.GroupWithZero.Action.Units import Mathlib.Algebra.Ring.Invertible import Mathlib.Algebra.Ring.Opposite import Mathlib.Algebra.SMulWithZero import Mathlib.Data.Int.Cast.Lemmas /-! # Modules over a ring In this file we define * `Module R M` : an additive commutative monoid `M` is a `Module` over a `Semiring R` if for `r : R` and `x : M` their "scalar multiplication" `r • x : M` is defined, and the operation `•` satisfies some natural associativity and distributivity axioms similar to those on a ring. ## Implementation notes In typical mathematical usage, our definition of `Module` corresponds to "semimodule", and the word "module" is reserved for `Module R M` where `R` is a `Ring` and `M` an `AddCommGroup`. If `R` is a `Field` and `M` an `AddCommGroup`, `M` would be called an `R`-vector space. Since those assumptions can be made by changing the typeclasses applied to `R` and `M`, without changing the axioms in `Module`, mathlib calls everything a `Module`. In older versions of mathlib3, we had separate abbreviations for semimodules and vector spaces. This caused inference issues in some cases, while not providing any real advantages, so we decided to use a canonical `Module` typeclass throughout. ## Tags semimodule, module, vector space -/ assert_not_exists Multiset assert_not_exists Set.indicator assert_not_exists Pi.single_smul₀ assert_not_exists Field open Function Set universe u v variable {α R k S M M₂ M₃ ι : Type*} /-- A module is a generalization of vector spaces to a scalar semiring. It consists of a scalar semiring `R` and an additive monoid of "vectors" `M`, connected by a "scalar multiplication" operation `r • x : M` (where `r : R` and `x : M`) with some natural associativity and distributivity axioms similar to those on a ring. -/ @[ext] class Module (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] extends DistribMulAction R M where /-- Scalar multiplication distributes over addition from the right. -/ protected add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x /-- Scalar multiplication by zero gives zero. -/ protected zero_smul : ∀ x : M, (0 : R) • x = 0 section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] (r s : R) (x y : M) -- see Note [lower instance priority] /-- A module over a semiring automatically inherits a `MulActionWithZero` structure. -/ instance (priority := 100) Module.toMulActionWithZero : MulActionWithZero R M := { (inferInstance : MulAction R M) with smul_zero := smul_zero zero_smul := Module.zero_smul } instance AddCommGroup.toNatModule : Module ℕ M where one_smul := one_nsmul mul_smul m n a := mul_nsmul' a m n smul_add n a b := nsmul_add a b n smul_zero := nsmul_zero zero_smul := zero_nsmul add_smul r s x := add_nsmul x r s theorem AddMonoid.End.natCast_def (n : ℕ) : (↑n : AddMonoid.End M) = DistribMulAction.toAddMonoidEnd ℕ M n := rfl theorem add_smul : (r + s) • x = r • x + s • x := Module.add_smul r s x theorem Convex.combo_self {a b : R} (h : a + b = 1) (x : M) : a • x + b • x = x := by rw [← add_smul, h, one_smul] variable (R) -- Porting note: this is the letter of the mathlib3 version, but not really the spirit theorem two_smul : (2 : R) • x = x + x := by rw [← one_add_one_eq_two, add_smul, one_smul] set_option linter.deprecated false in @[deprecated (since := "2022-12-31")] theorem two_smul' : (2 : R) • x = (2 : ℕ) • x := by rw [two_smul, two_nsmul] @[simp] theorem invOf_two_smul_add_invOf_two_smul [Invertible (2 : R)] (x : M) : (⅟ 2 : R) • x + (⅟ 2 : R) • x = x := Convex.combo_self invOf_two_add_invOf_two _ /-- Pullback a `Module` structure along an injective additive monoid homomorphism. See note [reducible non-instances]. -/ protected abbrev Function.Injective.module [AddCommMonoid M₂] [SMul R M₂] (f : M₂ →+ M) (hf : Injective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ := { hf.distribMulAction f smul with add_smul := fun c₁ c₂ x => hf <| by simp only [smul, f.map_add, add_smul] zero_smul := fun x => hf <| by simp only [smul, zero_smul, f.map_zero] } /-- Pushforward a `Module` structure along a surjective additive monoid homomorphism. See note [reducible non-instances]. -/ protected abbrev Function.Surjective.module [AddCommMonoid M₂] [SMul R M₂] (f : M →+ M₂) (hf : Surjective f) (smul : ∀ (c : R) (x), f (c • x) = c • f x) : Module R M₂ := { toDistribMulAction := hf.distribMulAction f smul add_smul := fun c₁ c₂ x => by rcases hf x with ⟨x, rfl⟩ simp only [add_smul, ← smul, ← f.map_add] zero_smul := fun x => by rcases hf x with ⟨x, rfl⟩ rw [← f.map_zero, ← smul, zero_smul] } /-- Push forward the action of `R` on `M` along a compatible surjective map `f : R →+* S`. See also `Function.Surjective.mulActionLeft` and `Function.Surjective.distribMulActionLeft`. -/ abbrev Function.Surjective.moduleLeft {R S M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] [Semiring S] [SMul S M] (f : R →+* S) (hf : Function.Surjective f) (hsmul : ∀ (c) (x : M), f c • x = c • x) : Module S M := { hf.distribMulActionLeft f.toMonoidHom hsmul with zero_smul := fun x => by rw [← f.map_zero, hsmul, zero_smul] add_smul := hf.forall₂.mpr fun a b x => by simp only [← f.map_add, hsmul, add_smul] } variable {R} (M) /-- Compose a `Module` with a `RingHom`, with action `f s • m`. See note [reducible non-instances]. -/ abbrev Module.compHom [Semiring S] (f : S →+* R) : Module S M := { MulActionWithZero.compHom M f.toMonoidWithZeroHom, DistribMulAction.compHom M (f : S →* R) with -- Porting note: the `show f (r + s) • x = f r • x + f s • x` wasn't needed in mathlib3. -- Somehow, now that `SMul` is heterogeneous, it can't unfold earlier fields of a definition for -- use in later fields. See -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Heterogeneous.20scalar.20multiplication add_smul := fun r s x => show f (r + s) • x = f r • x + f s • x by simp [add_smul] } variable (R) /-- `(•)` as an `AddMonoidHom`. This is a stronger version of `DistribMulAction.toAddMonoidEnd` -/ @[simps! apply_apply] def Module.toAddMonoidEnd : R →+* AddMonoid.End M := { DistribMulAction.toAddMonoidEnd R M with -- Porting note: the two `show`s weren't needed in mathlib3. -- Somehow, now that `SMul` is heterogeneous, it can't unfold earlier fields of a definition for -- use in later fields. See -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Heterogeneous.20scalar.20multiplication map_zero' := AddMonoidHom.ext fun r => show (0 : R) • r = 0 by simp map_add' := fun x y => AddMonoidHom.ext fun r => show (x + y) • r = x • r + y • r by simp [add_smul] } /-- A convenience alias for `Module.toAddMonoidEnd` as an `AddMonoidHom`, usually to allow the use of `AddMonoidHom.flip`. -/ def smulAddHom : R →+ M →+ M := (Module.toAddMonoidEnd R M).toAddMonoidHom variable {R M} @[simp] theorem smulAddHom_apply (r : R) (x : M) : smulAddHom R M r x = r • x := rfl theorem Module.eq_zero_of_zero_eq_one (zero_eq_one : (0 : R) = 1) : x = 0 := by rw [← one_smul R x, ← zero_eq_one, zero_smul] @[simp] theorem smul_add_one_sub_smul {R : Type*} [Ring R] [Module R M] {r : R} {m : M} : r • m + (1 - r) • m = m := by rw [← add_smul, add_sub_cancel, one_smul] end AddCommMonoid section AddCommGroup variable (R M) [Semiring R] [AddCommGroup M] instance AddCommGroup.toIntModule : Module ℤ M where one_smul := one_zsmul mul_smul m n a := mul_zsmul a m n smul_add n a b := zsmul_add a b n smul_zero := zsmul_zero zero_smul := zero_zsmul add_smul r s x := add_zsmul x r s theorem AddMonoid.End.intCast_def (z : ℤ) : (↑z : AddMonoid.End M) = DistribMulAction.toAddMonoidEnd ℤ M z := rfl variable {R M} theorem Convex.combo_eq_smul_sub_add [Module R M] {x y : M} {a b : R} (h : a + b = 1) : a • x + b • y = b • (y - x) + x := calc a • x + b • y = b • y - b • x + (a • x + b • x) := by rw [sub_add_add_cancel, add_comm] _ = b • (y - x) + x := by rw [smul_sub, Convex.combo_self h] end AddCommGroup -- We'll later use this to show `Module ℕ M` and `Module ℤ M` are subsingletons. /-- A variant of `Module.ext` that's convenient for term-mode. -/ theorem Module.ext' {R : Type*} [Semiring R] {M : Type*} [AddCommMonoid M] (P Q : Module R M) (w : ∀ (r : R) (m : M), (haveI := P; r • m) = (haveI := Q; r • m)) : P = Q := by ext exact w _ _ section Module variable [Ring R] [AddCommGroup M] [Module R M] (r s : R) (x y : M) @[simp] theorem neg_smul : -r • x = -(r • x) := eq_neg_of_add_eq_zero_left <| by rw [← add_smul, add_left_neg, zero_smul] -- Porting note (#10618): simp can prove this --@[simp] theorem neg_smul_neg : -r • -x = r • x := by rw [neg_smul, smul_neg, neg_neg] @[simp] theorem Units.neg_smul (u : Rˣ) (x : M) : -u • x = -(u • x) := by rw [Units.smul_def, Units.val_neg, _root_.neg_smul, Units.smul_def] variable (R) theorem neg_one_smul (x : M) : (-1 : R) • x = -x := by simp variable {R} theorem sub_smul (r s : R) (y : M) : (r - s) • y = r • y - s • y := by simp [add_smul, sub_eq_add_neg] end Module variable (R) /-- An `AddCommMonoid` that is a `Module` over a `Ring` carries a natural `AddCommGroup` structure. See note [reducible non-instances]. -/ abbrev Module.addCommMonoidToAddCommGroup [Ring R] [AddCommMonoid M] [Module R M] : AddCommGroup M := { (inferInstance : AddCommMonoid M) with neg := fun a => (-1 : R) • a add_left_neg := fun a => show (-1 : R) • a + a = 0 by nth_rw 2 [← one_smul R a] rw [← add_smul, add_left_neg, zero_smul] zsmul := fun z a => (z : R) • a zsmul_zero' := fun a => by simpa only [Int.cast_zero] using zero_smul R a zsmul_succ' := fun z a => by simp [add_comm, add_smul] zsmul_neg' := fun z a => by simp [← smul_assoc, neg_one_smul] } variable {R} /-- A module over a `Subsingleton` semiring is a `Subsingleton`. We cannot register this as an instance because Lean has no way to guess `R`. -/ protected theorem Module.subsingleton (R M : Type*) [Semiring R] [Subsingleton R] [AddCommMonoid M] [Module R M] : Subsingleton M := MulActionWithZero.subsingleton R M /-- A semiring is `Nontrivial` provided that there exists a nontrivial module over this semiring. -/ protected theorem Module.nontrivial (R M : Type*) [Semiring R] [Nontrivial M] [AddCommMonoid M] [Module R M] : Nontrivial R := MulActionWithZero.nontrivial R M -- see Note [lower instance priority] instance (priority := 910) Semiring.toModule [Semiring R] : Module R R where smul_add := mul_add add_smul := add_mul zero_smul := zero_mul smul_zero := mul_zero -- see Note [lower instance priority] /-- Like `Semiring.toModule`, but multiplies on the right. -/ instance (priority := 910) Semiring.toOppositeModule [Semiring R] : Module Rᵐᵒᵖ R := { MonoidWithZero.toOppositeMulActionWithZero R with smul_add := fun _ _ _ => add_mul _ _ _ add_smul := fun _ _ _ => mul_add _ _ _ } /-- A ring homomorphism `f : R →+* M` defines a module structure by `r • x = f r * x`. -/ def RingHom.toModule [Semiring R] [Semiring S] (f : R →+* S) : Module R S := Module.compHom S f /-- If the module action of `R` on `S` is compatible with multiplication on `S`, then `fun x ↦ x • 1` is a ring homomorphism from `R` to `S`. This is the `RingHom` version of `MonoidHom.smulOneHom`. When `R` is commutative, usually `algebraMap` should be preferred. -/ @[simps!] def RingHom.smulOneHom [Semiring R] [NonAssocSemiring S] [Module R S] [IsScalarTower R S S] : R →+* S where __ := MonoidHom.smulOneHom map_zero' := zero_smul R 1 map_add' := (add_smul · · 1) /-- A homomorphism between semirings R and S can be equivalently specified by a R-module structure on S such that S/S/R is a scalar tower. -/ def ringHomEquivModuleIsScalarTower [Semiring R] [Semiring S] : (R →+* S) ≃ {_inst : Module R S // IsScalarTower R S S} where toFun f := ⟨Module.compHom S f, SMul.comp.isScalarTower _⟩ invFun := fun ⟨_, _⟩ ↦ RingHom.smulOneHom left_inv f := RingHom.ext fun r ↦ mul_one (f r) right_inv := fun ⟨_, _⟩ ↦ Subtype.ext <| Module.ext <| funext₂ <| smul_one_smul S section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] section variable (R) /-- `nsmul` is equal to any other module structure via a cast. -/ lemma Nat.cast_smul_eq_nsmul (n : ℕ) (b : M) : (n : R) • b = n • b := by induction' n with n ih · rw [Nat.cast_zero, zero_smul, zero_smul] · rw [Nat.cast_succ, add_smul, add_smul, one_smul, ih, one_smul] /-- `nsmul` is equal to any other module structure via a cast. -/ -- See note [no_index around OfNat.ofNat] lemma ofNat_smul_eq_nsmul (n : ℕ) [n.AtLeastTwo] (b : M) : (no_index OfNat.ofNat n : R) • b = OfNat.ofNat n • b := Nat.cast_smul_eq_nsmul .. /-- `nsmul` is equal to any other module structure via a cast. -/ @[deprecated Nat.cast_smul_eq_nsmul (since := "2024-07-23")] lemma nsmul_eq_smul_cast (n : ℕ) (b : M) : n • b = (n : R) • b := (Nat.cast_smul_eq_nsmul ..).symm end /-- Convert back any exotic `ℕ`-smul to the canonical instance. This should not be needed since in mathlib all `AddCommMonoid`s should normally have exactly one `ℕ`-module structure by design. -/ theorem nat_smul_eq_nsmul (h : Module ℕ M) (n : ℕ) (x : M) : @SMul.smul ℕ M h.toSMul n x = n • x := Nat.cast_smul_eq_nsmul .. /-- All `ℕ`-module structures are equal. Not an instance since in mathlib all `AddCommMonoid` should normally have exactly one `ℕ`-module structure by design. -/ def AddCommMonoid.uniqueNatModule : Unique (Module ℕ M) where default := by infer_instance uniq P := (Module.ext' P _) fun n => by convert nat_smul_eq_nsmul P n instance AddCommMonoid.nat_isScalarTower : IsScalarTower ℕ R M where smul_assoc n x y := Nat.recOn n (by simp only [Nat.zero_eq, zero_smul]) fun n ih => by simp only [Nat.succ_eq_add_one, add_smul, one_smul, ih] end AddCommMonoid section AddCommGroup variable [Semiring S] [Ring R] [AddCommGroup M] [Module S M] [Module R M] section variable (R) /-- `zsmul` is equal to any other module structure via a cast. -/ lemma Int.cast_smul_eq_zsmul (n : ℤ) (b : M) : (n : R) • b = n • b := have : ((smulAddHom R M).flip b).comp (Int.castAddHom R) = (smulAddHom ℤ M).flip b := by apply AddMonoidHom.ext_int simp DFunLike.congr_fun this n @[deprecated (since := "2024-07-23")] alias intCast_smul := Int.cast_smul_eq_zsmul /-- `zsmul` is equal to any other module structure via a cast. -/ @[deprecated Int.cast_smul_eq_zsmul (since := "2024-07-23")] theorem zsmul_eq_smul_cast (n : ℤ) (b : M) : n • b = (n : R) • b := (Int.cast_smul_eq_zsmul ..).symm end /-- Convert back any exotic `ℤ`-smul to the canonical instance. This should not be needed since in mathlib all `AddCommGroup`s should normally have exactly one `ℤ`-module structure by design. -/ theorem int_smul_eq_zsmul (h : Module ℤ M) (n : ℤ) (x : M) : @SMul.smul ℤ M h.toSMul n x = n • x := Int.cast_smul_eq_zsmul .. /-- All `ℤ`-module structures are equal. Not an instance since in mathlib all `AddCommGroup` should normally have exactly one `ℤ`-module structure by design. -/ def AddCommGroup.uniqueIntModule : Unique (Module ℤ M) where default := by infer_instance uniq P := (Module.ext' P _) fun n => by convert int_smul_eq_zsmul P n end AddCommGroup theorem map_intCast_smul [AddCommGroup M] [AddCommGroup M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [Ring R] [Ring S] [Module R M] [Module S M₂] (x : ℤ) (a : M) : f ((x : R) • a) = (x : S) • f a := by simp only [Int.cast_smul_eq_zsmul, map_zsmul] theorem map_natCast_smul [AddCommMonoid M] [AddCommMonoid M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [Semiring R] [Semiring S] [Module R M] [Module S M₂] (x : ℕ) (a : M) : f ((x : R) • a) = (x : S) • f a := by simp only [Nat.cast_smul_eq_nsmul, AddMonoidHom.map_nsmul, map_nsmul] instance AddCommGroup.intIsScalarTower {R : Type u} {M : Type v} [Ring R] [AddCommGroup M] [Module R M] : IsScalarTower ℤ R M where smul_assoc n x y := ((smulAddHom R M).flip y).map_zsmul x n section NoZeroSMulDivisors /-! ### `NoZeroSMulDivisors` This section defines the `NoZeroSMulDivisors` class, and includes some tests for the vanishing of elements (especially in modules over division rings). -/ /-- `NoZeroSMulDivisors R M` states that a scalar multiple is `0` only if either argument is `0`. This is a version of saying that `M` is torsion free, without assuming `R` is zero-divisor free. The main application of `NoZeroSMulDivisors R M`, when `M` is a module, is the result `smul_eq_zero`: a scalar multiple is `0` iff either argument is `0`. It is a generalization of the `NoZeroDivisors` class to heterogeneous multiplication. -/ @[mk_iff] class NoZeroSMulDivisors (R M : Type*) [Zero R] [Zero M] [SMul R M] : Prop where /-- If scalar multiplication yields zero, either the scalar or the vector was zero. -/ eq_zero_or_eq_zero_of_smul_eq_zero : ∀ {c : R} {x : M}, c • x = 0 → c = 0 ∨ x = 0 export NoZeroSMulDivisors (eq_zero_or_eq_zero_of_smul_eq_zero) /-- Pullback a `NoZeroSMulDivisors` instance along an injective function. -/ theorem Function.Injective.noZeroSMulDivisors {R M N : Type*} [Zero R] [Zero M] [Zero N] [SMul R M] [SMul R N] [NoZeroSMulDivisors R N] (f : M → N) (hf : Function.Injective f) (h0 : f 0 = 0) (hs : ∀ (c : R) (x : M), f (c • x) = c • f x) : NoZeroSMulDivisors R M := ⟨fun {_ _} h => Or.imp_right (@hf _ _) <| h0.symm ▸ eq_zero_or_eq_zero_of_smul_eq_zero (by rw [← hs, h, h0])⟩ -- See note [lower instance priority] instance (priority := 100) NoZeroDivisors.toNoZeroSMulDivisors [Zero R] [Mul R] [NoZeroDivisors R] : NoZeroSMulDivisors R R := ⟨fun {_ _} => eq_zero_or_eq_zero_of_mul_eq_zero⟩ theorem smul_ne_zero [Zero R] [Zero M] [SMul R M] [NoZeroSMulDivisors R M] {c : R} {x : M} (hc : c ≠ 0) (hx : x ≠ 0) : c • x ≠ 0 := fun h => (eq_zero_or_eq_zero_of_smul_eq_zero h).elim hc hx section SMulWithZero variable [Zero R] [Zero M] [SMulWithZero R M] [NoZeroSMulDivisors R M] {c : R} {x : M} @[simp] theorem smul_eq_zero : c • x = 0 ↔ c = 0 ∨ x = 0 := ⟨eq_zero_or_eq_zero_of_smul_eq_zero, fun h => h.elim (fun h => h.symm ▸ zero_smul R x) fun h => h.symm ▸ smul_zero c⟩ theorem smul_ne_zero_iff : c • x ≠ 0 ↔ c ≠ 0 ∧ x ≠ 0 := by rw [Ne, smul_eq_zero, not_or] lemma smul_eq_zero_iff_left (hx : x ≠ 0) : c • x = 0 ↔ c = 0 := by simp [hx] lemma smul_eq_zero_iff_right (hc : c ≠ 0) : c • x = 0 ↔ x = 0 := by simp [hc] lemma smul_ne_zero_iff_left (hx : x ≠ 0) : c • x ≠ 0 ↔ c ≠ 0 := by simp [hx] lemma smul_ne_zero_iff_right (hc : c ≠ 0) : c • x ≠ 0 ↔ x ≠ 0 := by simp [hc] end SMulWithZero section Module section Nat theorem Nat.noZeroSMulDivisors (R) (M) [Semiring R] [CharZero R] [AddCommMonoid M] [Module R M] [NoZeroSMulDivisors R M] : NoZeroSMulDivisors ℕ M where eq_zero_or_eq_zero_of_smul_eq_zero {c x} := by rw [← Nat.cast_smul_eq_nsmul R, smul_eq_zero]; simp theorem two_nsmul_eq_zero (R) (M) [Semiring R] [CharZero R] [AddCommMonoid M] [Module R M] [NoZeroSMulDivisors R M] {v : M} : 2 • v = 0 ↔ v = 0 := by haveI := Nat.noZeroSMulDivisors R M simp [smul_eq_zero] end Nat variable [Semiring R] [AddCommMonoid M] [Module R M] variable (R M) /-- If `M` is an `R`-module with one and `M` has characteristic zero, then `R` has characteristic zero as well. Usually `M` is an `R`-algebra. -/ theorem CharZero.of_module (M) [AddCommMonoidWithOne M] [CharZero M] [Module R M] : CharZero R := by refine ⟨fun m n h => @Nat.cast_injective M _ _ _ _ ?_⟩ rw [← nsmul_one, ← nsmul_one, ← Nat.cast_smul_eq_nsmul R, ← Nat.cast_smul_eq_nsmul R, h] end Module section AddCommGroup -- `R` can still be a semiring here variable [Semiring R] [AddCommGroup M] [Module R M] section SMulInjective variable (M) theorem smul_right_injective [NoZeroSMulDivisors R M] {c : R} (hc : c ≠ 0) : Function.Injective (c • · : M → M) := (injective_iff_map_eq_zero (smulAddHom R M c)).2 fun _ ha => (smul_eq_zero.mp ha).resolve_left hc variable {M} theorem smul_right_inj [NoZeroSMulDivisors R M] {c : R} (hc : c ≠ 0) {x y : M} : c • x = c • y ↔ x = y := (smul_right_injective M hc).eq_iff end SMulInjective section Nat theorem self_eq_neg (R) (M) [Semiring R] [CharZero R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] {v : M} : v = -v ↔ v = 0 := by rw [← two_nsmul_eq_zero R M, two_smul, add_eq_zero_iff_eq_neg] theorem neg_eq_self (R) (M) [Semiring R] [CharZero R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] {v : M} : -v = v ↔ v = 0 := by rw [eq_comm, self_eq_neg R M] theorem self_ne_neg (R) (M) [Semiring R] [CharZero R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] {v : M} : v ≠ -v ↔ v ≠ 0 := (self_eq_neg R M).not theorem neg_ne_self (R) (M) [Semiring R] [CharZero R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] {v : M} : -v ≠ v ↔ v ≠ 0 := (neg_eq_self R M).not end Nat end AddCommGroup section Module variable [Ring R] [AddCommGroup M] [Module R M] section SMulInjective variable (R) variable [NoZeroSMulDivisors R M] theorem smul_left_injective {x : M} (hx : x ≠ 0) : Function.Injective fun c : R => c • x := fun c d h => sub_eq_zero.mp ((smul_eq_zero.mp (calc (c - d) • x = c • x - d • x := sub_smul c d x _ = 0 := sub_eq_zero.mpr h )).resolve_right hx) end SMulInjective instance [NoZeroSMulDivisors ℤ M] : NoZeroSMulDivisors ℕ M := ⟨fun {c x} hcx ↦ by rwa [← Nat.cast_smul_eq_nsmul ℤ, smul_eq_zero, Nat.cast_eq_zero] at hcx⟩ variable (R M) theorem NoZeroSMulDivisors.int_of_charZero (R) (M) [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] [CharZero R] : NoZeroSMulDivisors ℤ M := ⟨fun {z x} h ↦ by simpa [← smul_one_smul R z x] using h⟩ /-- Only a ring of characteristic zero can can have a non-trivial module without additive or scalar torsion. -/ theorem CharZero.of_noZeroSMulDivisors [Nontrivial M] [NoZeroSMulDivisors ℤ M] : CharZero R := by refine ⟨fun {n m h} ↦ ?_⟩ obtain ⟨x, hx⟩ := exists_ne (0 : M) replace h : (n : ℤ) • x = (m : ℤ) • x := by simp [← Nat.cast_smul_eq_nsmul R, h] simpa using smul_left_injective ℤ hx h end Module end NoZeroSMulDivisors -- Porting note (#10618): simp can prove this --@[simp] theorem Nat.smul_one_eq_cast {R : Type*} [NonAssocSemiring R] (m : ℕ) : m • (1 : R) = ↑m := by rw [nsmul_eq_mul, mul_one] -- Porting note (#10618): simp can prove this --@[simp] theorem Int.smul_one_eq_cast {R : Type*} [NonAssocRing R] (m : ℤ) : m • (1 : R) = ↑m := by rw [zsmul_eq_mul, mul_one] @[deprecated (since := "2024-05-03")] alias Nat.smul_one_eq_coe := Nat.smul_one_eq_cast @[deprecated (since := "2024-05-03")] alias Int.smul_one_eq_coe := Int.smul_one_eq_cast
Algebra\Module\FinitePresentation.lean
/- Copyright (c) 2024 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.RingTheory.Noetherian import Mathlib.Algebra.Module.LocalizedModule import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.LinearAlgebra.FreeModule.Finite.Basic /-! # Finitely Presented Modules ## Main definition - `Module.FinitePresentation`: A module is finitely presented if it is generated by some finite set `s` and the kernel of the presentation `Rˢ → M` is also finitely generated. ## Main results - `Module.finitePresentation_iff_finite`: If `R` is noetherian, then f.p. iff f.g. on `R`-modules. Suppose `0 → K → M → N → 0` is an exact sequence of `R`-modules. - `Module.finitePresentation_of_surjective`: If `M` is f.p., `K` is f.g., then `N` is f.p. - `Module.FinitePresentation.fg_ker`: If `M` is f.g., `N` is f.p., then `K` is f.g. - `Module.finitePresentation_of_ker`: If `N` and `K` is f.p., then `M` is also f.p. - `Module.FinitePresentation.isLocalizedModule_map`: If `M` and `N` are `R`-modules and `M` is f.p., and `S` is a submonoid of `R`, then `Hom(Mₛ, Nₛ)` is the localization of `Hom(M, N)`. Also the instances finite + free => f.p. => finite are also provided ## TODO Suppose `S` is an `R`-algebra, `M` is an `S`-module. Then 1. If `S` is f.p., then `M` is `R`-f.p. implies `M` is `S`-f.p. 2. If `S` is both f.p. (as an algebra) and finite (as a module), then `M` is `S`-fp implies that `M` is `R`-f.p. 3. If `S` is f.p. as a module, then `S` is f.p. as an algebra. In particular, 4. `S` is f.p. as an `R`-module iff it is f.p. as an algebra and is finite as a module. For finitely presented algebras, see `Algebra.FinitePresentation` in file `Mathlib.RingTheory.FinitePresentation`. -/ section Semiring variable (R M) [Semiring R] [AddCommMonoid M] [Module R M] /-- A module is finitely presented if it is finitely generated by some set `s` and the kernel of the presentation `Rˢ → M` is also finitely generated. -/ class Module.FinitePresentation : Prop where out : ∃ (s : Finset M), Submodule.span R (s : Set M) = ⊤ ∧ (LinearMap.ker (Finsupp.total s M R Subtype.val)).FG instance (priority := 100) [h : Module.FinitePresentation R M] : Module.Finite R M := by obtain ⟨s, hs₁, _⟩ := h exact ⟨s, hs₁⟩ end Semiring section Ring variable (R M N) [Ring R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] universe u in variable (R M : Type u) [Ring R] [AddCommGroup M] [Module R M] in /-- A finitely presented module is isomorphic to the quotient of a finite free module by a finitely generated submodule. -/ theorem Module.FinitePresentation.equiv_quotient [fp : Module.FinitePresentation R M] : ∃ (L : Type u) (_ : AddCommGroup L) (_ : Module R L) (K : Submodule R L) (_ : M ≃ₗ[R] L ⧸ K), Module.Free R L ∧ Module.Finite R L ∧ K.FG := by obtain ⟨ι, ⟨hι₁, hι₂⟩⟩ := fp use ι →₀ R, inferInstance, inferInstance use LinearMap.ker (Finsupp.total { x // x ∈ ι } M R Subtype.val) refine ⟨(LinearMap.quotKerEquivOfSurjective _ ?_).symm, inferInstance, inferInstance, hι₂⟩ apply LinearMap.range_eq_top.mp simpa only [Finsupp.range_total, Subtype.range_coe_subtype, Finset.setOf_mem] -- Ideally this should be an instance but it makes mathlib much slower. lemma Module.finitePresentation_of_finite [IsNoetherianRing R] [h : Module.Finite R M] : Module.FinitePresentation R M := by obtain ⟨s, hs⟩ := h exact ⟨s, hs, IsNoetherian.noetherian _⟩ lemma Module.finitePresentation_iff_finite [IsNoetherianRing R] : Module.FinitePresentation R M ↔ Module.Finite R M := ⟨fun _ ↦ inferInstance, fun _ ↦ finitePresentation_of_finite R M⟩ variable {R M N} lemma Module.finitePresentation_of_free_of_surjective [Module.Free R M] [Module.Finite R M] (l : M →ₗ[R] N) (hl : Function.Surjective l) (hl' : (LinearMap.ker l).FG) : Module.FinitePresentation R N := by classical let b := Module.Free.chooseBasis R M let π : Free.ChooseBasisIndex R M → (Set.finite_range (l ∘ b)).toFinset := fun i ↦ ⟨l (b i), by simp⟩ have : π.Surjective := fun ⟨x, hx⟩ ↦ by obtain ⟨y, rfl⟩ : ∃ a, l (b a) = x := by simpa using hx exact ⟨y, rfl⟩ choose σ hσ using this have hπ : Subtype.val ∘ π = l ∘ b := rfl have hσ₁ : π ∘ σ = id := by ext i; exact congr_arg Subtype.val (hσ i) have hσ₂ : l ∘ b ∘ σ = Subtype.val := by ext i; exact congr_arg Subtype.val (hσ i) refine ⟨(Set.finite_range (l ∘ b)).toFinset, by simpa [Set.range_comp, LinearMap.range_eq_top], ?_⟩ let f : M →ₗ[R] (Set.finite_range (l ∘ b)).toFinset →₀ R := Finsupp.lmapDomain _ _ π ∘ₗ b.repr.toLinearMap convert hl'.map f ext x; simp only [LinearMap.mem_ker, Submodule.mem_map] constructor · intro hx refine ⟨b.repr.symm (x.mapDomain σ), ?_, ?_⟩ · simp [Finsupp.apply_total, hσ₂, hx] · simp only [f, LinearMap.comp_apply, b.repr.apply_symm_apply, LinearEquiv.coe_toLinearMap, Finsupp.lmapDomain_apply] rw [← Finsupp.mapDomain_comp, hσ₁, Finsupp.mapDomain_id] · rintro ⟨y, hy, rfl⟩ simp [f, hπ, ← Finsupp.apply_total, hy] -- Ideally this should be an instance but it makes mathlib much slower. variable (R M) in lemma Module.finitePresentation_of_free [Module.Free R M] [Module.Finite R M] : Module.FinitePresentation R M := Module.finitePresentation_of_free_of_surjective LinearMap.id (⟨·, rfl⟩) (by simpa using Submodule.fg_bot) variable {ι} [_root_.Finite ι] instance : Module.FinitePresentation R R := Module.finitePresentation_of_free _ _ instance : Module.FinitePresentation R (ι →₀ R) := Module.finitePresentation_of_free _ _ instance : Module.FinitePresentation R (ι → R) := Module.finitePresentation_of_free _ _ lemma Module.finitePresentation_of_surjective [h : Module.FinitePresentation R M] (l : M →ₗ[R] N) (hl : Function.Surjective l) (hl' : (LinearMap.ker l).FG) : Module.FinitePresentation R N := by classical obtain ⟨s, hs, hs'⟩ := h obtain ⟨t, ht⟩ := hl' have H : Function.Surjective (Finsupp.total s M R Subtype.val) := LinearMap.range_eq_top.mp (by rw [Finsupp.range_total, Subtype.range_val, ← hs]; rfl) apply Module.finitePresentation_of_free_of_surjective (l ∘ₗ Finsupp.total s M R Subtype.val) (hl.comp H) choose σ hσ using (show _ from H) have : Finsupp.total s M R Subtype.val '' (σ '' t) = t := by simp only [Set.image_image, hσ, Set.image_id'] rw [LinearMap.ker_comp, ← ht, ← this, ← Submodule.map_span, Submodule.comap_map_eq, ← Finset.coe_image] exact Submodule.FG.sup ⟨_, rfl⟩ hs' lemma Module.FinitePresentation.fg_ker [Module.Finite R M] [h : Module.FinitePresentation R N] (l : M →ₗ[R] N) (hl : Function.Surjective l) : (LinearMap.ker l).FG := by classical obtain ⟨s, hs, hs'⟩ := h have H : Function.Surjective (Finsupp.total s N R Subtype.val) := LinearMap.range_eq_top.mp (by rw [Finsupp.range_total, Subtype.range_val, ← hs]; rfl) obtain ⟨f, hf⟩ : ∃ f : (s →₀ R) →ₗ[R] M, l ∘ₗ f = (Finsupp.total s N R Subtype.val) := by choose f hf using show _ from hl exact ⟨Finsupp.total s M R (fun i ↦ f i), by ext; simp [hf]⟩ have : (LinearMap.ker l).map (LinearMap.range f).mkQ = ⊤ := by rw [← top_le_iff] rintro x - obtain ⟨x, rfl⟩ := Submodule.mkQ_surjective _ x obtain ⟨y, hy⟩ := H (l x) rw [← hf, LinearMap.comp_apply, eq_comm, ← sub_eq_zero, ← map_sub] at hy exact ⟨_, hy, by simp⟩ apply Submodule.fg_of_fg_map_of_fg_inf_ker f.range.mkQ · rw [this] exact Module.Finite.out · rw [Submodule.ker_mkQ, inf_comm, ← Submodule.map_comap_eq, ← LinearMap.ker_comp, hf] exact hs'.map f lemma Module.FinitePresentation.fg_ker_iff [Module.FinitePresentation R M] (l : M →ₗ[R] N) (hl : Function.Surjective l) : Submodule.FG (LinearMap.ker l) ↔ Module.FinitePresentation R N := ⟨finitePresentation_of_surjective l hl, fun _ ↦ fg_ker l hl⟩ lemma Module.finitePresentation_of_ker [Module.FinitePresentation R N] (l : M →ₗ[R] N) (hl : Function.Surjective l) [Module.FinitePresentation R (LinearMap.ker l)] : Module.FinitePresentation R M := by obtain ⟨s, hs⟩ : (⊤ : Submodule R M).FG := by apply Submodule.fg_of_fg_map_of_fg_inf_ker l · rw [Submodule.map_top, LinearMap.range_eq_top.mpr hl]; exact Module.Finite.out · rw [top_inf_eq, ← Submodule.fg_top]; exact Module.Finite.out refine ⟨s, hs, ?_⟩ let π := Finsupp.total s M R Subtype.val have H : Function.Surjective π := LinearMap.range_eq_top.mp (by rw [Finsupp.range_total, Subtype.range_val, ← hs]; rfl) have inst : Module.Finite R (LinearMap.ker (l ∘ₗ π)) := by constructor rw [Submodule.fg_top]; exact Module.FinitePresentation.fg_ker _ (hl.comp H) letI : AddCommGroup (LinearMap.ker (l ∘ₗ π)) := inferInstance let f : LinearMap.ker (l ∘ₗ π) →ₗ[R] LinearMap.ker l := LinearMap.restrict π (fun x ↦ id) have e : π ∘ₗ Submodule.subtype _ = Submodule.subtype _ ∘ₗ f := by ext; rfl have hf : Function.Surjective f := by rw [← LinearMap.range_eq_top] apply Submodule.map_injective_of_injective (Submodule.injective_subtype _) rw [Submodule.map_top, Submodule.range_subtype, ← LinearMap.range_comp, ← e, LinearMap.range_comp, Submodule.range_subtype, LinearMap.ker_comp, Submodule.map_comap_eq_of_surjective H] show (LinearMap.ker π).FG have : LinearMap.ker π ≤ LinearMap.ker (l ∘ₗ π) := Submodule.comap_mono (f := π) (bot_le (a := LinearMap.ker l)) rw [← inf_eq_right.mpr this, ← Submodule.range_subtype (LinearMap.ker _), ← Submodule.map_comap_eq, ← LinearMap.ker_comp, e, LinearMap.ker_comp f, LinearMap.ker_eq_bot.mpr (Submodule.injective_subtype _), Submodule.comap_bot] exact (Module.FinitePresentation.fg_ker f hf).map (Submodule.subtype _) end Ring section CommRing variable {R M N N'} [CommRing R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] variable [AddCommGroup N'] [Module R N'] (S : Submonoid R) (f : N →ₗ[R] N') [IsLocalizedModule S f] lemma Module.FinitePresentation.exists_lift_of_isLocalizedModule [h : Module.FinitePresentation R M] (g : M →ₗ[R] N') : ∃ (h : M →ₗ[R] N) (s : S), f ∘ₗ h = s • g := by obtain ⟨σ, hσ, τ, hτ⟩ := h let π := Finsupp.total σ M R Subtype.val have hπ : Function.Surjective π := LinearMap.range_eq_top.mp (by rw [Finsupp.range_total, Subtype.range_val, ← hσ]; rfl) classical choose s hs using IsLocalizedModule.surj S f let i : σ → N := fun x ↦ (∏ j ∈ σ.erase x.1, (s (g j)).2) • (s (g x)).1 let s₀ := ∏ j ∈ σ, (s (g j)).2 have hi : f ∘ₗ Finsupp.total σ N R i = (s₀ • g) ∘ₗ π := by ext j simp only [LinearMap.coe_comp, Function.comp_apply, Finsupp.lsingle_apply, Finsupp.total_single, one_smul, LinearMap.map_smul_of_tower, ← hs, LinearMap.smul_apply, i, s₀, π] rw [← mul_smul, Finset.prod_erase_mul] exact j.prop have : ∀ x : τ, ∃ s : S, s • (Finsupp.total σ N R i x) = 0 := by intros x convert_to ∃ s : S, s • (Finsupp.total σ N R i x) = s • 0 · simp only [smul_zero] apply IsLocalizedModule.exists_of_eq (S := S) (f := f) rw [← LinearMap.comp_apply, map_zero, hi, LinearMap.comp_apply] convert map_zero (s₀ • g) rw [← LinearMap.mem_ker, ← hτ] exact Submodule.subset_span x.prop choose s' hs' using this let s₁ := ∏ i : τ, s' i have : LinearMap.ker π ≤ LinearMap.ker (s₁ • Finsupp.total σ N R i) := by rw [← hτ, Submodule.span_le] intro x hxσ simp only [s₁] rw [SetLike.mem_coe, LinearMap.mem_ker, LinearMap.smul_apply, ← Finset.prod_erase_mul _ _ (Finset.mem_univ ⟨x, hxσ⟩), mul_smul] convert smul_zero _ exact hs' ⟨x, hxσ⟩ refine ⟨Submodule.liftQ _ _ this ∘ₗ (LinearMap.quotKerEquivOfSurjective _ hπ).symm.toLinearMap, s₁ * s₀, ?_⟩ ext x obtain ⟨x, rfl⟩ := hπ x rw [← LinearMap.comp_apply, ← LinearMap.comp_apply, mul_smul, LinearMap.smul_comp, ← hi, ← LinearMap.comp_smul, LinearMap.comp_assoc, LinearMap.comp_assoc] congr 2 convert Submodule.liftQ_mkQ _ _ this using 2 ext x apply (LinearMap.quotKerEquivOfSurjective _ hπ).injective simp [LinearMap.quotKerEquivOfSurjective] lemma Module.Finite.exists_smul_of_comp_eq_of_isLocalizedModule [hM : Module.Finite R M] (g₁ g₂ : M →ₗ[R] N) (h : f.comp g₁ = f.comp g₂) : ∃ (s : S), s • g₁ = s • g₂ := by classical have : ∀ x, ∃ s : S, s • g₁ x = s • g₂ x := fun x ↦ IsLocalizedModule.exists_of_eq (S := S) (f := f) (LinearMap.congr_fun h x) choose s hs using this obtain ⟨σ, hσ⟩ := hM use σ.prod s rw [← sub_eq_zero, ← LinearMap.ker_eq_top, ← top_le_iff, ← hσ, Submodule.span_le] intro x hx simp only [SetLike.mem_coe, LinearMap.mem_ker, LinearMap.sub_apply, LinearMap.smul_apply, sub_eq_zero, ← Finset.prod_erase_mul σ s hx, mul_smul, hs] lemma Module.FinitePresentation.isLocalizedModule_map {M' : Type*} [AddCommGroup M'] [Module R M'] (f : M →ₗ[R] M') [IsLocalizedModule S f] {N' : Type*} [AddCommGroup N'] [Module R N'] (g : N →ₗ[R] N') [IsLocalizedModule S g] [Module.FinitePresentation R M] : IsLocalizedModule S (IsLocalizedModule.map S f g) := by constructor · intro s rw [Module.End_isUnit_iff] have := (Module.End_isUnit_iff _).mp (IsLocalizedModule.map_units (S := S) (f := g) s) constructor · exact fun _ _ e ↦ LinearMap.ext fun m ↦ this.left (LinearMap.congr_fun e m) · intro h use ((IsLocalizedModule.map_units (S := S) (f := g) s).unit⁻¹).1 ∘ₗ h ext x exact Module.End_isUnit_apply_inv_apply_of_isUnit (IsLocalizedModule.map_units (S := S) (f := g) s) (h x) · intro h obtain ⟨h', s, e⟩ := Module.FinitePresentation.exists_lift_of_isLocalizedModule S g (h ∘ₗ f) refine ⟨⟨h', s⟩, ?_⟩ apply IsLocalizedModule.ringHom_ext S f (IsLocalizedModule.map_units g) refine e.symm.trans (by ext; simp) · intro h₁ h₂ e apply Module.Finite.exists_smul_of_comp_eq_of_isLocalizedModule S g ext x simpa using LinearMap.congr_fun e (f x) end CommRing
Algebra\Module\GradedModule.lean
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang -/ import Mathlib.RingTheory.GradedAlgebra.Basic import Mathlib.Algebra.GradedMulAction import Mathlib.Algebra.DirectSum.Decomposition import Mathlib.Algebra.Module.BigOperators /-! # Graded Module Given an `R`-algebra `A` graded by `𝓐`, a graded `A`-module `M` is expressed as `DirectSum.Decomposition 𝓜` and `SetLike.GradedSMul 𝓐 𝓜`. Then `⨁ i, 𝓜 i` is an `A`-module and is isomorphic to `M`. ## Tags graded module -/ section open DirectSum variable {ιA ιB : Type*} (A : ιA → Type*) (M : ιB → Type*) namespace DirectSum open GradedMonoid /-- A graded version of `DistribMulAction`. -/ class GdistribMulAction [AddMonoid ιA] [VAdd ιA ιB] [GMonoid A] [∀ i, AddMonoid (M i)] extends GMulAction A M where smul_add {i j} (a : A i) (b c : M j) : smul a (b + c) = smul a b + smul a c smul_zero {i j} (a : A i) : smul a (0 : M j) = 0 /-- A graded version of `Module`. -/ class Gmodule [AddMonoid ιA] [VAdd ιA ιB] [∀ i, AddMonoid (A i)] [∀ i, AddMonoid (M i)] [GMonoid A] extends GdistribMulAction A M where add_smul {i j} (a a' : A i) (b : M j) : smul (a + a') b = smul a b + smul a' b zero_smul {i j} (b : M j) : smul (0 : A i) b = 0 /-- A graded version of `Semiring.toModule`. -/ instance GSemiring.toGmodule [AddMonoid ιA] [∀ i : ιA, AddCommMonoid (A i)] [h : GSemiring A] : Gmodule A A := { GMonoid.toGMulAction A with smul_add := fun _ _ _ => h.mul_add _ _ _ smul_zero := fun _ => h.mul_zero _ add_smul := fun _ _ => h.add_mul _ _ zero_smul := fun _ => h.zero_mul _ } variable [AddMonoid ιA] [VAdd ιA ιB] [∀ i : ιA, AddCommMonoid (A i)] [∀ i, AddCommMonoid (M i)] /-- The piecewise multiplication from the `Mul` instance, as a bundled homomorphism. -/ @[simps] def gsmulHom [GMonoid A] [Gmodule A M] {i j} : A i →+ M j →+ M (i +ᵥ j) where toFun a := { toFun := fun b => GSMul.smul a b map_zero' := GdistribMulAction.smul_zero _ map_add' := GdistribMulAction.smul_add _ } map_zero' := AddMonoidHom.ext fun a => Gmodule.zero_smul a map_add' _a₁ _a₂ := AddMonoidHom.ext fun _b => Gmodule.add_smul _ _ _ namespace Gmodule /-- For graded monoid `A` and a graded module `M` over `A`. `Gmodule.smulAddMonoidHom` is the `⨁ᵢ Aᵢ`-scalar multiplication on `⨁ᵢ Mᵢ` induced by `gsmul_hom`. -/ def smulAddMonoidHom [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] : (⨁ i, A i) →+ (⨁ i, M i) →+ ⨁ i, M i := toAddMonoid fun _i => AddMonoidHom.flip <| toAddMonoid fun _j => AddMonoidHom.flip <| (of M _).compHom.comp <| gsmulHom A M section open GradedMonoid DirectSum Gmodule instance [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] : SMul (⨁ i, A i) (⨁ i, M i) where smul x y := smulAddMonoidHom A M x y @[simp] theorem smul_def [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] (x : ⨁ i, A i) (y : ⨁ i, M i) : x • y = smulAddMonoidHom _ _ x y := rfl @[simp] theorem smulAddMonoidHom_apply_of_of [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] {i j} (x : A i) (y : M j) : smulAddMonoidHom A M (DirectSum.of A i x) (of M j y) = of M (i +ᵥ j) (GSMul.smul x y) := by simp [smulAddMonoidHom] -- @[simp] -- Porting note: simpNF lint theorem of_smul_of [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] {i j} (x : A i) (y : M j) : DirectSum.of A i x • of M j y = of M (i +ᵥ j) (GSMul.smul x y) := smulAddMonoidHom_apply_of_of _ _ _ _ open AddMonoidHom -- Porting note: renamed to one_smul' since DirectSum.Gmodule.one_smul already exists -- Almost identical to the proof of `direct_sum.one_mul` private theorem one_smul' [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodule A M] (x : ⨁ i, M i) : (1 : ⨁ i, A i) • x = x := by suffices smulAddMonoidHom A M 1 = AddMonoidHom.id (⨁ i, M i) from DFunLike.congr_fun this x apply DirectSum.addHom_ext; intro i xi rw [show (1 : DirectSum ιA fun i => A i) = (of A 0) GOne.one by rfl] rw [smulAddMonoidHom_apply_of_of] exact DirectSum.of_eq_of_gradedMonoid_eq (one_smul (GradedMonoid A) <| GradedMonoid.mk i xi) -- Porting note: renamed to mul_smul' since DirectSum.Gmodule.mul_smul already exists -- Almost identical to the proof of `direct_sum.mul_assoc` private theorem mul_smul' [DecidableEq ιA] [DecidableEq ιB] [GSemiring A] [Gmodule A M] (a b : ⨁ i, A i) (c : ⨁ i, M i) : (a * b) • c = a • b • c := by suffices (-- `fun a b c ↦ (a * b) • c` as a bundled hom smulAddMonoidHom A M).compHom.comp (DirectSum.mulHom A) = (AddMonoidHom.compHom AddMonoidHom.flipHom <| (smulAddMonoidHom A M).flip.compHom.comp <| smulAddMonoidHom A M).flip from-- `fun a b c ↦ a • (b • c)` as a bundled hom DFunLike.congr_fun (DFunLike.congr_fun (DFunLike.congr_fun this a) b) c ext ai ax bi bx ci cx : 6 dsimp only [coe_comp, Function.comp_apply, compHom_apply_apply, flip_apply, flipHom_apply] rw [smulAddMonoidHom_apply_of_of, smulAddMonoidHom_apply_of_of, DirectSum.mulHom_of_of, smulAddMonoidHom_apply_of_of] exact DirectSum.of_eq_of_gradedMonoid_eq (mul_smul (GradedMonoid.mk ai ax) (GradedMonoid.mk bi bx) (GradedMonoid.mk ci cx)) /-- The `Module` derived from `gmodule A M`. -/ instance module [DecidableEq ιA] [DecidableEq ιB] [GSemiring A] [Gmodule A M] : Module (⨁ i, A i) (⨁ i, M i) where smul := (· • ·) one_smul := one_smul' _ _ mul_smul := mul_smul' _ _ smul_add r := (smulAddMonoidHom A M r).map_add smul_zero r := (smulAddMonoidHom A M r).map_zero add_smul r s x := by simp only [smul_def, map_add, AddMonoidHom.add_apply] zero_smul x := by simp only [smul_def, map_zero, AddMonoidHom.zero_apply] end end Gmodule end DirectSum end open DirectSum variable {ιA ιM R A M σ σ' : Type*} variable [AddMonoid ιA] [AddAction ιA ιM] [CommSemiring R] [Semiring A] [Algebra R A] variable (𝓐 : ιA → σ') [SetLike σ' A] variable (𝓜 : ιM → σ) namespace SetLike instance gmulAction [AddMonoid M] [DistribMulAction A M] [SetLike σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSMul 𝓐 𝓜] : GradedMonoid.GMulAction (fun i => 𝓐 i) fun i => 𝓜 i := { SetLike.toGSMul 𝓐 𝓜 with one_smul := fun ⟨_i, _m⟩ => Sigma.subtype_ext (zero_vadd _ _) (one_smul _ _) mul_smul := fun ⟨_i, _a⟩ ⟨_j, _a'⟩ ⟨_k, _b⟩ => Sigma.subtype_ext (add_vadd _ _ _) (mul_smul _ _ _) } instance gdistribMulAction [AddMonoid M] [DistribMulAction A M] [SetLike σ M] [AddSubmonoidClass σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSMul 𝓐 𝓜] : DirectSum.GdistribMulAction (fun i => 𝓐 i) fun i => 𝓜 i := { SetLike.gmulAction 𝓐 𝓜 with smul_add := fun _a _b _c => Subtype.ext <| smul_add _ _ _ smul_zero := fun _a => Subtype.ext <| smul_zero _ } variable [AddCommMonoid M] [Module A M] [SetLike σ M] [AddSubmonoidClass σ' A] [AddSubmonoidClass σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSMul 𝓐 𝓜] /-- `[SetLike.GradedMonoid 𝓐] [SetLike.GradedSMul 𝓐 𝓜]` is the internal version of graded module, the internal version can be translated into the external version `gmodule`. -/ instance gmodule : DirectSum.Gmodule (fun i => 𝓐 i) fun i => 𝓜 i := { SetLike.gdistribMulAction 𝓐 𝓜 with smul := fun x y => ⟨(x : A) • (y : M), SetLike.GradedSMul.smul_mem x.2 y.2⟩ add_smul := fun _a _a' _b => Subtype.ext <| add_smul _ _ _ zero_smul := fun _b => Subtype.ext <| zero_smul _ _ } end SetLike namespace GradedModule variable [AddCommMonoid M] [Module A M] [SetLike σ M] [AddSubmonoidClass σ' A] [AddSubmonoidClass σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSMul 𝓐 𝓜] /-- The smul multiplication of `A` on `⨁ i, 𝓜 i` from `(⨁ i, 𝓐 i) →+ (⨁ i, 𝓜 i) →+ ⨁ i, 𝓜 i` turns `⨁ i, 𝓜 i` into an `A`-module -/ def isModule [DecidableEq ιA] [DecidableEq ιM] [GradedRing 𝓐] : Module A (⨁ i, 𝓜 i) := { Module.compHom _ (DirectSum.decomposeRingEquiv 𝓐 : A ≃+* ⨁ i, 𝓐 i).toRingHom with smul := fun a b => DirectSum.decompose 𝓐 a • b } /-- `⨁ i, 𝓜 i` and `M` are isomorphic as `A`-modules. "The internal version" and "the external version" are isomorphism as `A`-modules. -/ def linearEquiv [DecidableEq ιA] [DecidableEq ιM] [GradedRing 𝓐] [DirectSum.Decomposition 𝓜] : @LinearEquiv A A _ _ (RingHom.id A) (RingHom.id A) _ _ M (⨁ i, 𝓜 i) _ _ _ (by letI := isModule 𝓐 𝓜; infer_instance) := by letI h := isModule 𝓐 𝓜 refine ⟨⟨(DirectSum.decomposeAddEquiv 𝓜).toAddHom, ?_⟩, (DirectSum.decomposeAddEquiv 𝓜).symm.toFun, (DirectSum.decomposeAddEquiv 𝓜).left_inv, (DirectSum.decomposeAddEquiv 𝓜).right_inv⟩ intro x y classical rw [AddHom.toFun_eq_coe, ← DirectSum.sum_support_decompose 𝓐 x, map_sum, Finset.sum_smul, AddEquiv.coe_toAddHom, map_sum, Finset.sum_smul] refine Finset.sum_congr rfl (fun i _hi => ?_) rw [RingHom.id_apply, ← DirectSum.sum_support_decompose 𝓜 y, map_sum, Finset.smul_sum, map_sum, Finset.smul_sum] refine Finset.sum_congr rfl (fun j _hj => ?_) rw [show (decompose 𝓐 x i : A) • (decomposeAddEquiv 𝓜 ↑(decompose 𝓜 y j) : (⨁ i, 𝓜 i)) = DirectSum.Gmodule.smulAddMonoidHom _ _ (decompose 𝓐 ↑(decompose 𝓐 x i)) (decomposeAddEquiv 𝓜 ↑(decompose 𝓜 y j)) from DirectSum.Gmodule.smul_def _ _ _ _] simp only [decomposeAddEquiv_apply, Equiv.invFun_as_coe, Equiv.symm_symm, decompose_coe, Gmodule.smulAddMonoidHom_apply_of_of] convert DirectSum.decompose_coe 𝓜 _ rfl end GradedModule
Algebra\Module\Hom.lean
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Group.Hom.Instances import Mathlib.GroupTheory.GroupAction.DomAct.Basic /-! # Bundled Hom instances for module and multiplicative actions This file defines instances for `Module`, `MulAction` and related structures on bundled `Hom` types. These are analogous to the instances in `Algebra.Module.Pi`, but for bundled instead of unbundled functions. We also define bundled versions of `(c • ·)` and `(· • ·)` as `AddMonoidHom.smulLeft` and `AddMonoidHom.smul`, respectively. -/ variable {R S M A B : Type*} /-! ### Instances for `AddMonoidHom` -/ namespace AddMonoidHom section instance instDistribSMul [AddZeroClass A] [AddCommMonoid B] [DistribSMul M B] : DistribSMul M (A →+ B) where smul_add _ _ _ := ext fun _ => smul_add _ _ _ variable [Monoid R] [Monoid S] [AddMonoid A] [AddCommMonoid B] variable [DistribMulAction R B] [DistribMulAction S B] instance instDistribMulAction : DistribMulAction R (A →+ B) where smul_zero := smul_zero smul_add := smul_add one_smul _ := ext fun _ => one_smul _ _ mul_smul _ _ _ := ext fun _ => mul_smul _ _ _ @[simp] theorem coe_smul (r : R) (f : A →+ B) : ⇑(r • f) = r • ⇑f := rfl theorem smul_apply (r : R) (f : A →+ B) (x : A) : (r • f) x = r • f x := rfl instance smulCommClass [SMulCommClass R S B] : SMulCommClass R S (A →+ B) := ⟨fun _ _ _ => ext fun _ => smul_comm _ _ _⟩ instance isScalarTower [SMul R S] [IsScalarTower R S B] : IsScalarTower R S (A →+ B) := ⟨fun _ _ _ => ext fun _ => smul_assoc _ _ _⟩ instance isCentralScalar [DistribMulAction Rᵐᵒᵖ B] [IsCentralScalar R B] : IsCentralScalar R (A →+ B) := ⟨fun _ _ => ext fun _ => op_smul_eq_smul _ _⟩ end instance instModule [Semiring R] [AddMonoid A] [AddCommMonoid B] [Module R B] : Module R (A →+ B) := { add_smul := fun _ _ _=> ext fun _ => add_smul _ _ _ zero_smul := fun _ => ext fun _ => zero_smul _ _ } instance instDomMulActModule {S M M₂ : Type*} [Semiring S] [AddCommMonoid M] [AddCommMonoid M₂] [Module S M] : Module Sᵈᵐᵃ (M →+ M₂) where add_smul s s' f := AddMonoidHom.ext fun m ↦ by simp_rw [AddMonoidHom.add_apply, DomMulAct.smul_addMonoidHom_apply, ← map_add, ← add_smul]; rfl zero_smul _ := AddMonoidHom.ext fun _ ↦ by erw [DomMulAct.smul_addMonoidHom_apply, zero_smul, map_zero]; rfl end AddMonoidHom /-! ### Instances for `AddMonoid.End` These are direct copies of the instances above. -/ namespace AddMonoid.End section variable [Monoid R] [Monoid S] [AddCommMonoid A] instance instDistribSMul [DistribSMul M A] : DistribSMul M (AddMonoid.End A) := AddMonoidHom.instDistribSMul variable [DistribMulAction R A] [DistribMulAction S A] instance instDistribMulAction : DistribMulAction R (AddMonoid.End A) := AddMonoidHom.instDistribMulAction @[simp] theorem coe_smul (r : R) (f : AddMonoid.End A) : ⇑(r • f) = r • ⇑f := rfl theorem smul_apply (r : R) (f : AddMonoid.End A) (x : A) : (r • f) x = r • f x := rfl instance smulCommClass [SMulCommClass R S A] : SMulCommClass R S (AddMonoid.End A) := AddMonoidHom.smulCommClass instance isScalarTower [SMul R S] [IsScalarTower R S A] : IsScalarTower R S (AddMonoid.End A) := AddMonoidHom.isScalarTower instance isCentralScalar [DistribMulAction Rᵐᵒᵖ A] [IsCentralScalar R A] : IsCentralScalar R (AddMonoid.End A) := AddMonoidHom.isCentralScalar end instance instModule [Semiring R] [AddCommMonoid A] [Module R A] : Module R (AddMonoid.End A) := AddMonoidHom.instModule /-- The tautological action by `AddMonoid.End α` on `α`. This generalizes `AddMonoid.End.applyDistribMulAction`. -/ instance applyModule [AddCommMonoid A] : Module (AddMonoid.End A) A where add_smul _ _ _ := rfl zero_smul _ := rfl end AddMonoid.End /-! ### Miscelaneous morphisms -/ namespace AddMonoidHom /-- Scalar multiplication on the left as an additive monoid homomorphism. -/ @[simps! (config := .asFn)] protected def smulLeft [Monoid M] [AddMonoid A] [DistribMulAction M A] (c : M) : A →+ A := DistribMulAction.toAddMonoidHom _ c /-- Scalar multiplication as a biadditive monoid homomorphism. We need `M` to be commutative to have addition on `M →+ M`. -/ protected def smul [Semiring R] [AddCommMonoid M] [Module R M] : R →+ M →+ M := (Module.toAddMonoidEnd R M).toAddMonoidHom @[simp] theorem coe_smul' [Semiring R] [AddCommMonoid M] [Module R M] : ⇑(.smul : R →+ M →+ M) = AddMonoidHom.smulLeft := rfl end AddMonoidHom
Algebra\Module\Injective.lean
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jujian Zhang -/ import Mathlib.CategoryTheory.Preadditive.Injective import Mathlib.Algebra.Category.ModuleCat.EpiMono import Mathlib.RingTheory.Ideal.Basic import Mathlib.LinearAlgebra.LinearPMap import Mathlib.Logic.Equiv.TransferInstance /-! # Injective modules ## Main definitions * `Module.Injective`: an `R`-module `Q` is injective if and only if every injective `R`-linear map descends to a linear map to `Q`, i.e. in the following diagram, if `f` is injective then there is an `R`-linear map `h : Y ⟶ Q` such that `g = h ∘ f` ``` X --- f ---> Y | | g v Q ``` * `Module.Baer`: an `R`-module `Q` satisfies Baer's criterion if any `R`-linear map from an `Ideal R` extends to an `R`-linear map `R ⟶ Q` ## Main statements * `Module.Baer.injective`: an `R`-module is injective if it is Baer. -/ noncomputable section universe u v v' variable (R : Type u) [Ring R] (Q : Type v) [AddCommGroup Q] [Module R Q] /-- An `R`-module `Q` is injective if and only if every injective `R`-linear map descends to a linear map to `Q`, i.e. in the following diagram, if `f` is injective then there is an `R`-linear map `h : Y ⟶ Q` such that `g = h ∘ f` ``` X --- f ---> Y | | g v Q ``` -/ @[mk_iff] class Module.Injective : Prop where out : ∀ ⦃X Y : Type v⦄ [AddCommGroup X] [AddCommGroup Y] [Module R X] [Module R Y] (f : X →ₗ[R] Y) (_ : Function.Injective f) (g : X →ₗ[R] Q), ∃ h : Y →ₗ[R] Q, ∀ x, h (f x) = g x theorem Module.injective_object_of_injective_module [inj : Module.Injective R Q] : CategoryTheory.Injective (ModuleCat.of R Q) where factors g f m := have ⟨l, h⟩ := inj.out f ((ModuleCat.mono_iff_injective f).mp m) g ⟨l, LinearMap.ext h⟩ theorem Module.injective_module_of_injective_object [inj : CategoryTheory.Injective <| ModuleCat.of R Q] : Module.Injective R Q where out X Y _ _ _ _ f hf g := by have : CategoryTheory.Mono (ModuleCat.ofHom f) := (ModuleCat.mono_iff_injective _).mpr hf obtain ⟨l, rfl⟩ := inj.factors (ModuleCat.ofHom g) (ModuleCat.ofHom f) exact ⟨l, fun _ ↦ rfl⟩ theorem Module.injective_iff_injective_object : Module.Injective R Q ↔ CategoryTheory.Injective (ModuleCat.of R Q) := ⟨fun _ => injective_object_of_injective_module R Q, fun _ => injective_module_of_injective_object R Q⟩ /-- An `R`-module `Q` satisfies Baer's criterion if any `R`-linear map from an `Ideal R` extends to an `R`-linear map `R ⟶ Q`-/ def Module.Baer : Prop := ∀ (I : Ideal R) (g : I →ₗ[R] Q), ∃ g' : R →ₗ[R] Q, ∀ (x : R) (mem : x ∈ I), g' x = g ⟨x, mem⟩ namespace Module.Baer variable {R Q} {M N : Type*} [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] (i : M →ₗ[R] N) (f : M →ₗ[R] Q) /-- If we view `M` as a submodule of `N` via the injective linear map `i : M ↪ N`, then a submodule between `M` and `N` is a submodule `N'` of `N`. To prove Baer's criterion, we need to consider pairs of `(N', f')` such that `M ≤ N' ≤ N` and `f'` extends `f`. -/ structure ExtensionOf extends LinearPMap R N Q where le : LinearMap.range i ≤ domain is_extension : ∀ m : M, f m = toLinearPMap ⟨i m, le ⟨m, rfl⟩⟩ section Ext variable {i f} @[ext (iff := false)] theorem ExtensionOf.ext {a b : ExtensionOf i f} (domain_eq : a.domain = b.domain) (to_fun_eq : ∀ ⦃x : a.domain⦄ ⦃y : b.domain⦄, (x : N) = y → a.toLinearPMap x = b.toLinearPMap y) : a = b := by rcases a with ⟨a, a_le, e1⟩ rcases b with ⟨b, b_le, e2⟩ congr exact LinearPMap.ext domain_eq to_fun_eq theorem ExtensionOf.ext_iff {a b : ExtensionOf i f} : a = b ↔ ∃ _ : a.domain = b.domain, ∀ ⦃x : a.domain⦄ ⦃y : b.domain⦄, (x : N) = y → a.toLinearPMap x = b.toLinearPMap y := ⟨fun r => r ▸ ⟨rfl, fun _ _ h => congr_arg a.toFun <| mod_cast h⟩, fun ⟨h1, h2⟩ => ExtensionOf.ext h1 h2⟩ end Ext instance : Inf (ExtensionOf i f) where inf X1 X2 := { X1.toLinearPMap ⊓ X2.toLinearPMap with le := fun x hx => (by rcases hx with ⟨x, rfl⟩ refine ⟨X1.le (Set.mem_range_self _), X2.le (Set.mem_range_self _), ?_⟩ rw [← X1.is_extension x, ← X2.is_extension x] : x ∈ X1.toLinearPMap.eqLocus X2.toLinearPMap) is_extension := fun m => X1.is_extension _ } instance : SemilatticeInf (ExtensionOf i f) := Function.Injective.semilatticeInf ExtensionOf.toLinearPMap (fun X Y h => ExtensionOf.ext (by rw [h]) fun x y h' => by -- Porting note: induction didn't handle dependent rw like in Lean 3 have : {x y : N} → (h'' : x = y) → (hx : x ∈ X.toLinearPMap.domain) → (hy : y ∈ Y.toLinearPMap.domain) → X.toLinearPMap ⟨x,hx⟩ = Y.toLinearPMap ⟨y,hy⟩ := by rw [h] intro _ _ h _ _ congr apply this h' _ _) fun X Y => LinearPMap.ext rfl fun x y h => by congr exact mod_cast h variable {i f} theorem chain_linearPMap_of_chain_extensionOf {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c) : IsChain (· ≤ ·) <| (fun x : ExtensionOf i f => x.toLinearPMap) '' c := by rintro _ ⟨a, a_mem, rfl⟩ _ ⟨b, b_mem, rfl⟩ neq exact hchain a_mem b_mem (ne_of_apply_ne _ neq) /-- The maximal element of every nonempty chain of `extension_of i f`. -/ def ExtensionOf.max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c) (hnonempty : c.Nonempty) : ExtensionOf i f := { LinearPMap.sSup _ (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain) with le := by refine le_trans hnonempty.some.le <| (LinearPMap.le_sSup _ <| (Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩).1 is_extension := fun m => by refine Eq.trans (hnonempty.some.is_extension m) ?_ symm generalize_proofs _ h1 exact LinearPMap.sSup_apply (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain) ((Set.mem_image _ _ _).mpr ⟨hnonempty.some, hnonempty.choose_spec, rfl⟩) ⟨i m, h1⟩ } theorem ExtensionOf.le_max {c : Set (ExtensionOf i f)} (hchain : IsChain (· ≤ ·) c) (hnonempty : c.Nonempty) (a : ExtensionOf i f) (ha : a ∈ c) : a ≤ ExtensionOf.max hchain hnonempty := LinearPMap.le_sSup (IsChain.directedOn <| chain_linearPMap_of_chain_extensionOf hchain) <| (Set.mem_image _ _ _).mpr ⟨a, ha, rfl⟩ variable (i f) [Fact <| Function.Injective i] instance ExtensionOf.inhabited : Inhabited (ExtensionOf i f) where default := { domain := LinearMap.range i toFun := { toFun := fun x => f x.2.choose map_add' := fun x y => by have eq1 : _ + _ = (x + y).1 := congr_arg₂ (· + ·) x.2.choose_spec y.2.choose_spec rw [← map_add, ← (x + y).2.choose_spec] at eq1 dsimp rw [← Fact.out (p := Function.Injective i) eq1, map_add] map_smul' := fun r x => by have eq1 : r • _ = (r • x).1 := congr_arg (r • ·) x.2.choose_spec rw [← LinearMap.map_smul, ← (r • x).2.choose_spec] at eq1 dsimp rw [← Fact.out (p := Function.Injective i) eq1, LinearMap.map_smul] } le := le_refl _ is_extension := fun m => by simp only [LinearPMap.mk_apply, LinearMap.coe_mk] dsimp apply congrArg exact Fact.out (p := Function.Injective i) (⟨i m, ⟨_, rfl⟩⟩ : LinearMap.range i).2.choose_spec.symm } /-- Since every nonempty chain has a maximal element, by Zorn's lemma, there is a maximal `extension_of i f`. -/ def extensionOfMax : ExtensionOf i f := (@zorn_nonempty_partialOrder (ExtensionOf i f) _ ⟨Inhabited.default⟩ fun _ hchain hnonempty => ⟨ExtensionOf.max hchain hnonempty, ExtensionOf.le_max hchain hnonempty⟩).choose theorem extensionOfMax_is_max : ∀ a : ExtensionOf i f, extensionOfMax i f ≤ a → a = extensionOfMax i f := (@zorn_nonempty_partialOrder (ExtensionOf i f) _ ⟨Inhabited.default⟩ fun _ hchain hnonempty => ⟨ExtensionOf.max hchain hnonempty, ExtensionOf.le_max hchain hnonempty⟩).choose_spec -- Porting note: helper function. Lean looks for an instance of `Sup (Type u)` when the -- right hand side is substituted in directly abbrev supExtensionOfMaxSingleton (y : N) : Submodule R N := (extensionOfMax i f).domain ⊔ (Submodule.span R {y}) variable {f} private theorem extensionOfMax_adjoin.aux1 {y : N} (x : supExtensionOfMaxSingleton i f y) : ∃ (a : (extensionOfMax i f).domain) (b : R), x.1 = a.1 + b • y := by have mem1 : x.1 ∈ (_ : Set _) := x.2 rw [Submodule.coe_sup] at mem1 rcases mem1 with ⟨a, a_mem, b, b_mem : b ∈ (Submodule.span R _ : Submodule R N), eq1⟩ rw [Submodule.mem_span_singleton] at b_mem rcases b_mem with ⟨z, eq2⟩ exact ⟨⟨a, a_mem⟩, z, by rw [← eq1, ← eq2]⟩ /-- If `x ∈ M ⊔ ⟨y⟩`, then `x = m + r • y`, `fst` pick an arbitrary such `m`. -/ def ExtensionOfMaxAdjoin.fst {y : N} (x : supExtensionOfMaxSingleton i f y) : (extensionOfMax i f).domain := (extensionOfMax_adjoin.aux1 i x).choose /-- If `x ∈ M ⊔ ⟨y⟩`, then `x = m + r • y`, `snd` pick an arbitrary such `r`. -/ def ExtensionOfMaxAdjoin.snd {y : N} (x : supExtensionOfMaxSingleton i f y) : R := (extensionOfMax_adjoin.aux1 i x).choose_spec.choose theorem ExtensionOfMaxAdjoin.eqn {y : N} (x : supExtensionOfMaxSingleton i f y) : ↑x = ↑(ExtensionOfMaxAdjoin.fst i x) + ExtensionOfMaxAdjoin.snd i x • y := (extensionOfMax_adjoin.aux1 i x).choose_spec.choose_spec variable (f) -- TODO: refactor to use colon ideals? /-- The ideal `I = {r | r • y ∈ N}`-/ def ExtensionOfMaxAdjoin.ideal (y : N) : Ideal R := (extensionOfMax i f).domain.comap ((LinearMap.id : R →ₗ[R] R).smulRight y) /-- A linear map `I ⟶ Q` by `x ↦ f' (x • y)` where `f'` is the maximal extension-/ def ExtensionOfMaxAdjoin.idealTo (y : N) : ExtensionOfMaxAdjoin.ideal i f y →ₗ[R] Q where toFun (z : { x // x ∈ ideal i f y }) := (extensionOfMax i f).toLinearPMap ⟨(↑z : R) • y, z.prop⟩ map_add' (z1 z2 : { x // x ∈ ideal i f y }) := by -- Porting note: a single simp took care of the goal before reenableeta simp_rw [← (extensionOfMax i f).toLinearPMap.map_add] congr apply add_smul map_smul' z1 (z2 : {x // x ∈ ideal i f y}) := by -- Porting note: a single simp took care of the goal before reenableeta simp_rw [← (extensionOfMax i f).toLinearPMap.map_smul] congr 2 apply mul_smul /-- Since we assumed `Q` being Baer, the linear map `x ↦ f' (x • y) : I ⟶ Q` extends to `R ⟶ Q`, call this extended map `φ`-/ def ExtensionOfMaxAdjoin.extendIdealTo (h : Module.Baer R Q) (y : N) : R →ₗ[R] Q := (h (ExtensionOfMaxAdjoin.ideal i f y) (ExtensionOfMaxAdjoin.idealTo i f y)).choose theorem ExtensionOfMaxAdjoin.extendIdealTo_is_extension (h : Module.Baer R Q) (y : N) : ∀ (x : R) (mem : x ∈ ExtensionOfMaxAdjoin.ideal i f y), ExtensionOfMaxAdjoin.extendIdealTo i f h y x = ExtensionOfMaxAdjoin.idealTo i f y ⟨x, mem⟩ := (h (ExtensionOfMaxAdjoin.ideal i f y) (ExtensionOfMaxAdjoin.idealTo i f y)).choose_spec theorem ExtensionOfMaxAdjoin.extendIdealTo_wd' (h : Module.Baer R Q) {y : N} (r : R) (eq1 : r • y = 0) : ExtensionOfMaxAdjoin.extendIdealTo i f h y r = 0 := by have : r ∈ ideal i f y := by change (r • y) ∈ (extensionOfMax i f).toLinearPMap.domain rw [eq1] apply Submodule.zero_mem _ rw [ExtensionOfMaxAdjoin.extendIdealTo_is_extension i f h y r this] dsimp [ExtensionOfMaxAdjoin.idealTo] simp only [LinearMap.coe_mk, eq1, Subtype.coe_mk, ← ZeroMemClass.zero_def, (extensionOfMax i f).toLinearPMap.map_zero] theorem ExtensionOfMaxAdjoin.extendIdealTo_wd (h : Module.Baer R Q) {y : N} (r r' : R) (eq1 : r • y = r' • y) : ExtensionOfMaxAdjoin.extendIdealTo i f h y r = ExtensionOfMaxAdjoin.extendIdealTo i f h y r' := by rw [← sub_eq_zero, ← map_sub] convert ExtensionOfMaxAdjoin.extendIdealTo_wd' i f h (r - r') _ rw [sub_smul, sub_eq_zero, eq1] theorem ExtensionOfMaxAdjoin.extendIdealTo_eq (h : Module.Baer R Q) {y : N} (r : R) (hr : r • y ∈ (extensionOfMax i f).domain) : ExtensionOfMaxAdjoin.extendIdealTo i f h y r = (extensionOfMax i f).toLinearPMap ⟨r • y, hr⟩ := by -- Porting note: in mathlib3 `AddHom.coe_mk` was not needed simp only [ExtensionOfMaxAdjoin.extendIdealTo_is_extension i f h _ _ hr, ExtensionOfMaxAdjoin.idealTo, LinearMap.coe_mk, Subtype.coe_mk, AddHom.coe_mk] /-- We can finally define a linear map `M ⊔ ⟨y⟩ ⟶ Q` by `x + r • y ↦ f x + φ r` -/ def ExtensionOfMaxAdjoin.extensionToFun (h : Module.Baer R Q) {y : N} : supExtensionOfMaxSingleton i f y → Q := fun x => (extensionOfMax i f).toLinearPMap (ExtensionOfMaxAdjoin.fst i x) + ExtensionOfMaxAdjoin.extendIdealTo i f h y (ExtensionOfMaxAdjoin.snd i x) theorem ExtensionOfMaxAdjoin.extensionToFun_wd (h : Module.Baer R Q) {y : N} (x : supExtensionOfMaxSingleton i f y) (a : (extensionOfMax i f).domain) (r : R) (eq1 : ↑x = ↑a + r • y) : ExtensionOfMaxAdjoin.extensionToFun i f h x = (extensionOfMax i f).toLinearPMap a + ExtensionOfMaxAdjoin.extendIdealTo i f h y r := by cases' a with a ha have eq2 : (ExtensionOfMaxAdjoin.fst i x - a : N) = (r - ExtensionOfMaxAdjoin.snd i x) • y := by change x = a + r • y at eq1 rwa [ExtensionOfMaxAdjoin.eqn, ← sub_eq_zero, ← sub_sub_sub_eq, sub_eq_zero, ← sub_smul] at eq1 have eq3 := ExtensionOfMaxAdjoin.extendIdealTo_eq i f h (r - ExtensionOfMaxAdjoin.snd i x) (by rw [← eq2]; exact Submodule.sub_mem _ (ExtensionOfMaxAdjoin.fst i x).2 ha) simp only [map_sub, sub_smul, sub_eq_iff_eq_add] at eq3 unfold ExtensionOfMaxAdjoin.extensionToFun rw [eq3, ← add_assoc, ← (extensionOfMax i f).toLinearPMap.map_add, AddMemClass.mk_add_mk] congr ext dsimp rw [Subtype.coe_mk, add_sub, ← eq1] exact eq_sub_of_add_eq (ExtensionOfMaxAdjoin.eqn i x).symm /-- The linear map `M ⊔ ⟨y⟩ ⟶ Q` by `x + r • y ↦ f x + φ r` is an extension of `f`-/ def extensionOfMaxAdjoin (h : Module.Baer R Q) (y : N) : ExtensionOf i f where domain := supExtensionOfMaxSingleton i f y -- (extensionOfMax i f).domain ⊔ Submodule.span R {y} le := le_trans (extensionOfMax i f).le le_sup_left toFun := { toFun := ExtensionOfMaxAdjoin.extensionToFun i f h map_add' := fun a b => by have eq1 : ↑a + ↑b = ↑(ExtensionOfMaxAdjoin.fst i a + ExtensionOfMaxAdjoin.fst i b) + (ExtensionOfMaxAdjoin.snd i a + ExtensionOfMaxAdjoin.snd i b) • y := by rw [ExtensionOfMaxAdjoin.eqn, ExtensionOfMaxAdjoin.eqn, add_smul, Submodule.coe_add] ac_rfl rw [ExtensionOfMaxAdjoin.extensionToFun_wd (y := y) i f h (a + b) _ _ eq1, LinearPMap.map_add, map_add] unfold ExtensionOfMaxAdjoin.extensionToFun abel map_smul' := fun r a => by dsimp have eq1 : r • (a : N) = ↑(r • ExtensionOfMaxAdjoin.fst i a) + (r • ExtensionOfMaxAdjoin.snd i a) • y := by rw [ExtensionOfMaxAdjoin.eqn, smul_add, smul_eq_mul, mul_smul] rfl rw [ExtensionOfMaxAdjoin.extensionToFun_wd i f h (r • a :) _ _ eq1, LinearMap.map_smul, LinearPMap.map_smul, ← smul_add] congr } is_extension m := by dsimp rw [(extensionOfMax i f).is_extension, ExtensionOfMaxAdjoin.extensionToFun_wd i f h _ ⟨i m, _⟩ 0 _, map_zero, add_zero] simp theorem extensionOfMax_le (h : Module.Baer R Q) {y : N} : extensionOfMax i f ≤ extensionOfMaxAdjoin i f h y := ⟨le_sup_left, fun x x' EQ => by symm change ExtensionOfMaxAdjoin.extensionToFun i f h _ = _ rw [ExtensionOfMaxAdjoin.extensionToFun_wd i f h x' x 0 (by simp [EQ]), map_zero, add_zero]⟩ theorem extensionOfMax_to_submodule_eq_top (h : Module.Baer R Q) : (extensionOfMax i f).domain = ⊤ := by refine Submodule.eq_top_iff'.mpr fun y => ?_ dsimp rw [← extensionOfMax_is_max i f _ (extensionOfMax_le i f h), extensionOfMaxAdjoin, Submodule.mem_sup] exact ⟨0, Submodule.zero_mem _, y, Submodule.mem_span_singleton_self _, zero_add _⟩ protected theorem extension_property (h : Module.Baer R Q) (f : M →ₗ[R] N) (hf : Function.Injective f) (g : M →ₗ[R] Q) : ∃ h, h ∘ₗ f = g := haveI : Fact (Function.Injective f) := ⟨hf⟩ Exists.intro { toFun := ((extensionOfMax f g).toLinearPMap ⟨·, (extensionOfMax_to_submodule_eq_top f g h).symm ▸ ⟨⟩⟩) map_add' := fun x y ↦ by rw [← LinearPMap.map_add]; congr map_smul' := fun r x ↦ by rw [← LinearPMap.map_smul]; dsimp } <| LinearMap.ext fun x ↦ ((extensionOfMax f g).is_extension x).symm theorem extension_property_addMonoidHom (h : Module.Baer ℤ Q) (f : M →+ N) (hf : Function.Injective f) (g : M →+ Q) : ∃ h : N →+ Q, h.comp f = g := have ⟨g', hg'⟩ := h.extension_property f.toIntLinearMap hf g.toIntLinearMap ⟨g', congr(LinearMap.toAddMonoidHom $hg')⟩ /-- **Baer's criterion** for injective module : a Baer module is an injective module, i.e. if every linear map from an ideal can be extended, then the module is injective. -/ protected theorem injective (h : Module.Baer R Q) : Module.Injective R Q where out X Y _ _ _ _ i hi f := by obtain ⟨h, H⟩ := Module.Baer.extension_property h i hi f exact ⟨h, DFunLike.congr_fun H⟩ protected theorem of_injective [Small.{v} R] (inj : Module.Injective R Q) : Module.Baer R Q := by intro I g let eI := Shrink.linearEquiv I R let eR := Shrink.linearEquiv R R obtain ⟨g', hg'⟩ := Module.Injective.out (eR.symm.toLinearMap ∘ₗ I.subtype ∘ₗ eI.toLinearMap) (eR.symm.injective.comp <| Subtype.val_injective.comp eI.injective) (g ∘ₗ eI.toLinearMap) exact ⟨g' ∘ₗ eR.symm.toLinearMap, fun x mx ↦ by simpa [eI, eR] using hg' (equivShrink I ⟨x, mx⟩)⟩ protected theorem iff_injective [Small.{v} R] : Module.Baer R Q ↔ Module.Injective R Q := ⟨Module.Baer.injective, Module.Baer.of_injective⟩ end Module.Baer section ULift variable {M : Type v} [AddCommGroup M] [Module R M] lemma Module.ulift_injective_of_injective [Small.{v} R] (inj : Module.Injective R M) : Module.Injective R (ULift.{v'} M) := Module.Baer.injective fun I g ↦ have ⟨g', hg'⟩ := Module.Baer.iff_injective.mpr inj I (ULift.moduleEquiv.toLinearMap ∘ₗ g) ⟨ULift.moduleEquiv.symm.toLinearMap ∘ₗ g', fun r hr ↦ ULift.ext _ _ <| hg' r hr⟩ lemma Module.injective_of_ulift_injective (inj : Module.Injective R (ULift.{v'} M)) : Module.Injective R M where out X Y _ _ _ _ f hf g := let eX := ULift.moduleEquiv.{_,_,v'} (R := R) (M := X) have ⟨g', hg'⟩ := inj.out (ULift.moduleEquiv.{_,_,v'}.symm.toLinearMap ∘ₗ f ∘ₗ eX.toLinearMap) (by exact ULift.moduleEquiv.symm.injective.comp <| hf.comp eX.injective) (ULift.moduleEquiv.symm.toLinearMap ∘ₗ g ∘ₗ eX.toLinearMap) ⟨ULift.moduleEquiv.toLinearMap ∘ₗ g' ∘ₗ ULift.moduleEquiv.symm.toLinearMap, fun x ↦ by exact congr(ULift.down $(hg' ⟨x⟩))⟩ variable (M) [Small.{v} R] lemma Module.injective_iff_ulift_injective : Module.Injective R M ↔ Module.Injective R (ULift.{v'} M) := ⟨Module.ulift_injective_of_injective R, Module.injective_of_ulift_injective R⟩ instance ModuleCat.ulift_injective_of_injective [inj : CategoryTheory.Injective <| ModuleCat.of R M] : CategoryTheory.Injective <| ModuleCat.of R (ULift.{v'} M) := Module.injective_object_of_injective_module (inj := Module.ulift_injective_of_injective (inj := Module.injective_module_of_injective_object (inj := inj))) end ULift section lifting_property universe uR uM uP uP' variable (R : Type uR) [Ring R] [Small.{uM} R] variable (M : Type uM) [AddCommGroup M] [Module R M] [inj : Module.Injective R M] variable (P : Type uP) [AddCommGroup P] [Module R P] variable (P' : Type uP') [AddCommGroup P'] [Module R P'] lemma Module.Injective.extension_property (f : P →ₗ[R] P') (hf : Function.Injective f) (g : P →ₗ[R] M) : ∃ h : P' →ₗ[R] M, h ∘ₗ f = g := (Module.Baer.of_injective inj).extension_property f hf g end lifting_property
Algebra\Module\LocalizedModule.lean
/- Copyright (c) 2022 Jujian Zhang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang, Jujian Zhang -/ import Mathlib.Algebra.Algebra.Bilinear import Mathlib.RingTheory.Localization.Basic import Mathlib.Algebra.Exact /-! # Localized Module Given a commutative semiring `R`, a multiplicative subset `S ⊆ R` and an `R`-module `M`, we can localize `M` by `S`. This gives us a `Localization S`-module. ## Main definitions * `LocalizedModule.r`: the equivalence relation defining this localization, namely `(m, s) ≈ (m', s')` if and only if there is some `u : S` such that `u • s' • m = u • s • m'`. * `LocalizedModule M S`: the localized module by `S`. * `LocalizedModule.mk`: the canonical map sending `(m, s) : M × S ↦ m/s : LocalizedModule M S` * `LocalizedModule.liftOn`: any well defined function `f : M × S → α` respecting `r` descents to a function `LocalizedModule M S → α` * `LocalizedModule.liftOn₂`: any well defined function `f : M × S → M × S → α` respecting `r` descents to a function `LocalizedModule M S → LocalizedModule M S` * `LocalizedModule.mk_add_mk`: in the localized module `mk m s + mk m' s' = mk (s' • m + s • m') (s * s')` * `LocalizedModule.mk_smul_mk` : in the localized module, for any `r : R`, `s t : S`, `m : M`, we have `mk r s • mk m t = mk (r • m) (s * t)` where `mk r s : Localization S` is localized ring by `S`. * `LocalizedModule.isModule` : `LocalizedModule M S` is a `Localization S`-module. ## Future work * Redefine `Localization` for monoids and rings to coincide with `LocalizedModule`. -/ namespace LocalizedModule universe u v variable {R : Type u} [CommSemiring R] (S : Submonoid R) variable (M : Type v) [AddCommMonoid M] [Module R M] variable (T : Type*) [CommSemiring T] [Algebra R T] [IsLocalization S T] /-- The equivalence relation on `M × S` where `(m1, s1) ≈ (m2, s2)` if and only if for some (u : S), u * (s2 • m1 - s1 • m2) = 0-/ /- Porting note: We use small letter `r` since `R` is used for a ring. -/ def r (a b : M × S) : Prop := ∃ u : S, u • b.2 • a.1 = u • a.2 • b.1 theorem r.isEquiv : IsEquiv _ (r S M) := { refl := fun ⟨m, s⟩ => ⟨1, by rw [one_smul]⟩ trans := fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨m3, s3⟩ ⟨u1, hu1⟩ ⟨u2, hu2⟩ => by use u1 * u2 * s2 -- Put everything in the same shape, sorting the terms using `simp` have hu1' := congr_arg ((u2 * s3) • ·) hu1.symm have hu2' := congr_arg ((u1 * s1) • ·) hu2.symm simp only [← mul_smul, smul_assoc, mul_assoc, mul_comm, mul_left_comm] at hu1' hu2' ⊢ rw [hu2', hu1'] symm := fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨u, hu⟩ => ⟨u, hu.symm⟩ } instance r.setoid : Setoid (M × S) where r := r S M iseqv := ⟨(r.isEquiv S M).refl, (r.isEquiv S M).symm _ _, (r.isEquiv S M).trans _ _ _⟩ -- TODO: change `Localization` to use `r'` instead of `r` so that the two types are also defeq, -- `Localization S = LocalizedModule S R`. example {R} [CommSemiring R] (S : Submonoid R) : ⇑(Localization.r' S) = LocalizedModule.r S R := rfl /-- If `S` is a multiplicative subset of a ring `R` and `M` an `R`-module, then we can localize `M` by `S`. -/ -- Porting note(#5171): @[nolint has_nonempty_instance] def _root_.LocalizedModule : Type max u v := Quotient (r.setoid S M) section variable {M S} /-- The canonical map sending `(m, s) ↦ m/s`-/ def mk (m : M) (s : S) : LocalizedModule S M := Quotient.mk' ⟨m, s⟩ theorem mk_eq {m m' : M} {s s' : S} : mk m s = mk m' s' ↔ ∃ u : S, u • s' • m = u • s • m' := Quotient.eq' @[elab_as_elim, induction_eliminator, cases_eliminator] theorem induction_on {β : LocalizedModule S M → Prop} (h : ∀ (m : M) (s : S), β (mk m s)) : ∀ x : LocalizedModule S M, β x := by rintro ⟨⟨m, s⟩⟩ exact h m s @[elab_as_elim] theorem induction_on₂ {β : LocalizedModule S M → LocalizedModule S M → Prop} (h : ∀ (m m' : M) (s s' : S), β (mk m s) (mk m' s')) : ∀ x y, β x y := by rintro ⟨⟨m, s⟩⟩ ⟨⟨m', s'⟩⟩ exact h m m' s s' /-- If `f : M × S → α` respects the equivalence relation `LocalizedModule.r`, then `f` descents to a map `LocalizedModule M S → α`. -/ def liftOn {α : Type*} (x : LocalizedModule S M) (f : M × S → α) (wd : ∀ (p p' : M × S), p ≈ p' → f p = f p') : α := Quotient.liftOn x f wd theorem liftOn_mk {α : Type*} {f : M × S → α} (wd : ∀ (p p' : M × S), p ≈ p' → f p = f p') (m : M) (s : S) : liftOn (mk m s) f wd = f ⟨m, s⟩ := by convert Quotient.liftOn_mk f wd ⟨m, s⟩ /-- If `f : M × S → M × S → α` respects the equivalence relation `LocalizedModule.r`, then `f` descents to a map `LocalizedModule M S → LocalizedModule M S → α`. -/ def liftOn₂ {α : Type*} (x y : LocalizedModule S M) (f : M × S → M × S → α) (wd : ∀ (p q p' q' : M × S), p ≈ p' → q ≈ q' → f p q = f p' q') : α := Quotient.liftOn₂ x y f wd theorem liftOn₂_mk {α : Type*} (f : M × S → M × S → α) (wd : ∀ (p q p' q' : M × S), p ≈ p' → q ≈ q' → f p q = f p' q') (m m' : M) (s s' : S) : liftOn₂ (mk m s) (mk m' s') f wd = f ⟨m, s⟩ ⟨m', s'⟩ := by convert Quotient.liftOn₂_mk f wd _ _ instance : Zero (LocalizedModule S M) := ⟨mk 0 1⟩ /-- If `S` contains `0` then the localization at `S` is trivial. -/ theorem subsingleton (h : 0 ∈ S) : Subsingleton (LocalizedModule S M) := by refine ⟨fun a b ↦ ?_⟩ induction a,b using LocalizedModule.induction_on₂ exact mk_eq.mpr ⟨⟨0, h⟩, by simp only [Submonoid.mk_smul, zero_smul]⟩ @[simp] theorem zero_mk (s : S) : mk (0 : M) s = 0 := mk_eq.mpr ⟨1, by rw [one_smul, smul_zero, smul_zero, one_smul]⟩ instance : Add (LocalizedModule S M) where add p1 p2 := liftOn₂ p1 p2 (fun x y => mk (y.2 • x.1 + x.2 • y.1) (x.2 * y.2)) <| fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨m1', s1'⟩ ⟨m2', s2'⟩ ⟨u1, hu1⟩ ⟨u2, hu2⟩ => mk_eq.mpr ⟨u1 * u2, by -- Put everything in the same shape, sorting the terms using `simp` have hu1' := congr_arg ((u2 * s2 * s2') • ·) hu1 have hu2' := congr_arg ((u1 * s1 * s1') • ·) hu2 simp only [smul_add, ← mul_smul, smul_assoc, mul_assoc, mul_comm, mul_left_comm] at hu1' hu2' ⊢ rw [hu1', hu2']⟩ theorem mk_add_mk {m1 m2 : M} {s1 s2 : S} : mk m1 s1 + mk m2 s2 = mk (s2 • m1 + s1 • m2) (s1 * s2) := mk_eq.mpr <| ⟨1, rfl⟩ private theorem add_assoc' (x y z : LocalizedModule S M) : x + y + z = x + (y + z) := by induction' x with mx sx induction' y with my sy induction' z with mz sz simp only [mk_add_mk, smul_add] refine mk_eq.mpr ⟨1, ?_⟩ rw [one_smul, one_smul] congr 1 · rw [mul_assoc] · rw [eq_comm, mul_comm, add_assoc, mul_smul, mul_smul, ← mul_smul sx sz, mul_comm, mul_smul] private theorem add_comm' (x y : LocalizedModule S M) : x + y = y + x := LocalizedModule.induction_on₂ (fun m m' s s' => by rw [mk_add_mk, mk_add_mk, add_comm, mul_comm]) x y private theorem zero_add' (x : LocalizedModule S M) : 0 + x = x := induction_on (fun m s => by rw [← zero_mk s, mk_add_mk, smul_zero, zero_add, mk_eq] exact ⟨1, by rw [one_smul, mul_smul, one_smul]⟩) x private theorem add_zero' (x : LocalizedModule S M) : x + 0 = x := induction_on (fun m s => by rw [← zero_mk s, mk_add_mk, smul_zero, add_zero, mk_eq] exact ⟨1, by rw [one_smul, mul_smul, one_smul]⟩) x instance hasNatSMul : SMul ℕ (LocalizedModule S M) where smul n := nsmulRec n private theorem nsmul_zero' (x : LocalizedModule S M) : (0 : ℕ) • x = 0 := LocalizedModule.induction_on (fun _ _ => rfl) x private theorem nsmul_succ' (n : ℕ) (x : LocalizedModule S M) : n.succ • x = n • x + x := LocalizedModule.induction_on (fun _ _ => rfl) x instance : AddCommMonoid (LocalizedModule S M) where add := (· + ·) add_assoc := add_assoc' zero := 0 zero_add := zero_add' add_zero := add_zero' nsmul := (· • ·) nsmul_zero := nsmul_zero' nsmul_succ := nsmul_succ' add_comm := add_comm' instance {M : Type*} [AddCommGroup M] [Module R M] : Neg (LocalizedModule S M) where neg p := liftOn p (fun x => LocalizedModule.mk (-x.1) x.2) fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨u, hu⟩ => by rw [mk_eq] exact ⟨u, by simpa⟩ instance {M : Type*} [AddCommGroup M] [Module R M] : AddCommGroup (LocalizedModule S M) := { show AddCommMonoid (LocalizedModule S M) by infer_instance with add_left_neg := by rintro ⟨m, s⟩ change (liftOn (mk m s) (fun x => mk (-x.1) x.2) fun ⟨m1, s1⟩ ⟨m2, s2⟩ ⟨u, hu⟩ => by rw [mk_eq] exact ⟨u, by simpa⟩) + mk m s = 0 rw [liftOn_mk, mk_add_mk] simp -- TODO: fix the diamond zsmul := zsmulRec } theorem mk_neg {M : Type*} [AddCommGroup M] [Module R M] {m : M} {s : S} : mk (-m) s = -mk m s := rfl instance {A : Type*} [Semiring A] [Algebra R A] {S : Submonoid R} : Monoid (LocalizedModule S A) := { mul := fun m₁ m₂ => liftOn₂ m₁ m₂ (fun x₁ x₂ => LocalizedModule.mk (x₁.1 * x₂.1) (x₁.2 * x₂.2)) (by rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨b₁, t₁⟩ ⟨b₂, t₂⟩ ⟨u₁, e₁⟩ ⟨u₂, e₂⟩ rw [mk_eq] use u₁ * u₂ dsimp only at e₁ e₂ ⊢ rw [eq_comm] trans (u₁ • t₁ • a₁) • u₂ • t₂ • a₂ on_goal 1 => rw [e₁, e₂] on_goal 2 => rw [eq_comm] all_goals rw [smul_smul, mul_mul_mul_comm, ← smul_eq_mul, ← smul_eq_mul A, smul_smul_smul_comm, mul_smul, mul_smul]) one := mk 1 (1 : S) one_mul := by rintro ⟨a, s⟩ exact mk_eq.mpr ⟨1, by simp only [one_mul, one_smul]⟩ mul_one := by rintro ⟨a, s⟩ exact mk_eq.mpr ⟨1, by simp only [mul_one, one_smul]⟩ mul_assoc := by rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨a₃, s₃⟩ apply mk_eq.mpr _ use 1 simp only [one_mul, smul_smul, ← mul_assoc, mul_right_comm] } instance {A : Type*} [Semiring A] [Algebra R A] {S : Submonoid R} : Semiring (LocalizedModule S A) := { show (AddCommMonoid (LocalizedModule S A)) by infer_instance, show (Monoid (LocalizedModule S A)) by infer_instance with left_distrib := by rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨a₃, s₃⟩ apply mk_eq.mpr _ use 1 simp only [one_mul, smul_add, mul_add, mul_smul_comm, smul_smul, ← mul_assoc, mul_right_comm] right_distrib := by rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ ⟨a₃, s₃⟩ apply mk_eq.mpr _ use 1 simp only [one_mul, smul_add, add_mul, smul_smul, ← mul_assoc, smul_mul_assoc, mul_right_comm] zero_mul := by rintro ⟨a, s⟩ exact mk_eq.mpr ⟨1, by simp only [zero_mul, smul_zero]⟩ mul_zero := by rintro ⟨a, s⟩ exact mk_eq.mpr ⟨1, by simp only [mul_zero, smul_zero]⟩ } instance {A : Type*} [CommSemiring A] [Algebra R A] {S : Submonoid R} : CommSemiring (LocalizedModule S A) := { show Semiring (LocalizedModule S A) by infer_instance with mul_comm := by rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ exact mk_eq.mpr ⟨1, by simp only [one_smul, mul_comm]⟩ } instance {A : Type*} [Ring A] [Algebra R A] {S : Submonoid R} : Ring (LocalizedModule S A) := { inferInstanceAs (AddCommGroup (LocalizedModule S A)), inferInstanceAs (Semiring (LocalizedModule S A)) with } instance {A : Type*} [CommRing A] [Algebra R A] {S : Submonoid R} : CommRing (LocalizedModule S A) := { show (Ring (LocalizedModule S A)) by infer_instance with mul_comm := by rintro ⟨a₁, s₁⟩ ⟨a₂, s₂⟩ exact mk_eq.mpr ⟨1, by simp only [one_smul, mul_comm]⟩ } theorem mk_mul_mk {A : Type*} [Semiring A] [Algebra R A] {a₁ a₂ : A} {s₁ s₂ : S} : mk a₁ s₁ * mk a₂ s₂ = mk (a₁ * a₂) (s₁ * s₂) := rfl noncomputable instance : SMul T (LocalizedModule S M) where smul x p := let a := IsLocalization.sec S x liftOn p (fun p ↦ mk (a.1 • p.1) (a.2 * p.2)) (by rintro p p' ⟨s, h⟩ refine mk_eq.mpr ⟨s, ?_⟩ calc _ = a.2 • a.1 • s • p'.2 • p.1 := by simp_rw [Submonoid.smul_def, Submonoid.coe_mul, ← mul_smul]; ring_nf _ = a.2 • a.1 • s • p.2 • p'.1 := by rw [h] _ = s • (a.2 * p.2) • a.1 • p'.1 := by simp_rw [Submonoid.smul_def, ← mul_smul, Submonoid.coe_mul]; ring_nf ) theorem smul_def (x : T) (m : M) (s : S) : x • mk m s = mk ((IsLocalization.sec S x).1 • m) ((IsLocalization.sec S x).2 * s) := rfl theorem mk'_smul_mk (r : R) (m : M) (s s' : S) : IsLocalization.mk' T r s • mk m s' = mk (r • m) (s * s') := by rw [smul_def, mk_eq] obtain ⟨c, hc⟩ := IsLocalization.eq.mp <| IsLocalization.mk'_sec T (IsLocalization.mk' T r s) use c simp_rw [← mul_smul, Submonoid.smul_def, Submonoid.coe_mul, ← mul_smul, ← mul_assoc, mul_comm _ (s' : R), mul_assoc, hc] theorem mk_smul_mk (r : R) (m : M) (s t : S) : Localization.mk r s • mk m t = mk (r • m) (s * t) := by rw [Localization.mk_eq_mk'] exact mk'_smul_mk .. variable {T} private theorem one_smul_aux (p : LocalizedModule S M) : (1 : T) • p = p := by induction' p with m s rw [show (1 : T) = IsLocalization.mk' T (1 : R) (1 : S) by rw [IsLocalization.mk'_one, map_one]] rw [mk'_smul_mk, one_smul, one_mul] private theorem mul_smul_aux (x y : T) (p : LocalizedModule S M) : (x * y) • p = x • y • p := by induction' p with m s rw [← IsLocalization.mk'_sec (M := S) T x, ← IsLocalization.mk'_sec (M := S) T y] simp_rw [← IsLocalization.mk'_mul, mk'_smul_mk, ← mul_smul, mul_assoc] private theorem smul_add_aux (x : T) (p q : LocalizedModule S M) : x • (p + q) = x • p + x • q := by induction' p with m s induction' q with n t rw [smul_def, smul_def, mk_add_mk, mk_add_mk] rw [show x • _ = IsLocalization.mk' T _ _ • _ by rw [IsLocalization.mk'_sec (M := S) T]] rw [← IsLocalization.mk'_cancel _ _ (IsLocalization.sec S x).2, mk'_smul_mk] congr 1 · simp only [Submonoid.smul_def, smul_add, ← mul_smul, Submonoid.coe_mul]; ring_nf · rw [mul_mul_mul_comm] -- ring does not work here private theorem smul_zero_aux (x : T) : x • (0 : LocalizedModule S M) = 0 := by erw [smul_def, smul_zero, zero_mk] private theorem add_smul_aux (x y : T) (p : LocalizedModule S M) : (x + y) • p = x • p + y • p := by induction' p with m s rw [smul_def T x, smul_def T y, mk_add_mk, show (x + y) • _ = IsLocalization.mk' T _ _ • _ by rw [← IsLocalization.mk'_sec (M := S) T x, ← IsLocalization.mk'_sec (M := S) T y, ← IsLocalization.mk'_add, IsLocalization.mk'_cancel _ _ s], mk'_smul_mk, ← smul_assoc, ← smul_assoc, ← add_smul] congr 1 · simp only [Submonoid.smul_def, Submonoid.coe_mul, smul_eq_mul]; ring_nf · rw [mul_mul_mul_comm, mul_assoc] -- ring does not work here private theorem zero_smul_aux (p : LocalizedModule S M) : (0 : T) • p = 0 := by induction' p with m s rw [show (0 : T) = IsLocalization.mk' T (0 : R) (1 : S) by rw [IsLocalization.mk'_zero], mk'_smul_mk, zero_smul, zero_mk] noncomputable instance isModule : Module T (LocalizedModule S M) where smul := (· • ·) one_smul := one_smul_aux mul_smul := mul_smul_aux smul_add := smul_add_aux smul_zero := smul_zero_aux add_smul := add_smul_aux zero_smul := zero_smul_aux @[simp] theorem mk_cancel_common_left (s' s : S) (m : M) : mk (s' • m) (s' * s) = mk m s := mk_eq.mpr ⟨1, by simp only [mul_smul, one_smul] rw [smul_comm]⟩ @[simp] theorem mk_cancel (s : S) (m : M) : mk (s • m) s = mk m 1 := mk_eq.mpr ⟨1, by simp⟩ @[simp] theorem mk_cancel_common_right (s s' : S) (m : M) : mk (s' • m) (s * s') = mk m s := mk_eq.mpr ⟨1, by simp [mul_smul]⟩ noncomputable instance isModule' : Module R (LocalizedModule S M) := { Module.compHom (LocalizedModule S M) <| algebraMap R (Localization S) with } theorem smul'_mk (r : R) (s : S) (m : M) : r • mk m s = mk (r • m) s := by erw [mk_smul_mk r m 1 s, one_mul] theorem smul'_mul {A : Type*} [Semiring A] [Algebra R A] (x : T) (p₁ p₂ : LocalizedModule S A) : x • p₁ * p₂ = x • (p₁ * p₂) := by induction p₁, p₂ using induction_on₂ with | _ a₁ s₁ a₂ s₂ => _ rw [mk_mul_mk, smul_def, smul_def, mk_mul_mk, mul_assoc, smul_mul_assoc] theorem mul_smul' {A : Type*} [Semiring A] [Algebra R A] (x : T) (p₁ p₂ : LocalizedModule S A) : p₁ * x • p₂ = x • (p₁ * p₂) := by induction p₁, p₂ using induction_on₂ with | _ a₁ s₁ a₂ s₂ => _ rw [smul_def, mk_mul_mk, mk_mul_mk, smul_def, mul_left_comm, mul_smul_comm] variable (T) noncomputable instance {A : Type*} [Semiring A] [Algebra R A] : Algebra T (LocalizedModule S A) := Algebra.ofModule smul'_mul mul_smul' theorem algebraMap_mk' {A : Type*} [Semiring A] [Algebra R A] (a : R) (s : S) : algebraMap _ _ (IsLocalization.mk' T a s) = mk (algebraMap R A a) s := by rw [Algebra.algebraMap_eq_smul_one] change _ • mk _ _ = _ rw [mk'_smul_mk, Algebra.algebraMap_eq_smul_one, mul_one] theorem algebraMap_mk {A : Type*} [Semiring A] [Algebra R A] (a : R) (s : S) : algebraMap _ _ (Localization.mk a s) = mk (algebraMap R A a) s := by rw [Localization.mk_eq_mk'] exact algebraMap_mk' .. instance : IsScalarTower R T (LocalizedModule S M) where smul_assoc r x p := by induction' p with m s rw [← IsLocalization.mk'_sec (M := S) T x, IsLocalization.smul_mk', mk'_smul_mk, mk'_smul_mk, smul'_mk, mul_smul] noncomputable instance algebra' {A : Type*} [Semiring A] [Algebra R A] : Algebra R (LocalizedModule S A) := { (algebraMap (Localization S) (LocalizedModule S A)).comp (algebraMap R <| Localization S), show Module R (LocalizedModule S A) by infer_instance with commutes' := by intro r x induction x using induction_on with | _ a s => _ dsimp rw [← Localization.mk_one_eq_algebraMap, algebraMap_mk, mk_mul_mk, mk_mul_mk, mul_comm, Algebra.commutes] smul_def' := by intro r x induction x using induction_on with | _ a s => _ dsimp rw [← Localization.mk_one_eq_algebraMap, algebraMap_mk, mk_mul_mk, smul'_mk, Algebra.smul_def, one_mul] } section variable (S M) /-- The function `m ↦ m / 1` as an `R`-linear map. -/ @[simps] def mkLinearMap : M →ₗ[R] LocalizedModule S M where toFun m := mk m 1 map_add' x y := by simp [mk_add_mk] map_smul' r x := (smul'_mk _ _ _).symm end /-- For any `s : S`, there is an `R`-linear map given by `a/b ↦ a/(b*s)`. -/ @[simps] def divBy (s : S) : LocalizedModule S M →ₗ[R] LocalizedModule S M where toFun p := p.liftOn (fun p => mk p.1 (p.2 * s)) fun ⟨a, b⟩ ⟨a', b'⟩ ⟨c, eq1⟩ => mk_eq.mpr ⟨c, by rw [mul_smul, mul_smul, smul_comm _ s, smul_comm _ s, eq1, smul_comm _ s, smul_comm _ s]⟩ map_add' x y := by refine x.induction_on₂ ?_ y intro m₁ m₂ t₁ t₂ simp_rw [mk_add_mk, LocalizedModule.liftOn_mk, mk_add_mk, mul_smul, mul_comm _ s, mul_assoc, smul_comm _ s, ← smul_add, mul_left_comm s t₁ t₂, mk_cancel_common_left s] map_smul' r x := by refine x.induction_on (fun _ _ ↦ ?_) dsimp only change liftOn (mk _ _) _ _ = r • (liftOn (mk _ _) _ _) simp_rw [liftOn_mk, mul_assoc, ← smul_def] congr! theorem divBy_mul_by (s : S) (p : LocalizedModule S M) : divBy s (algebraMap R (Module.End R (LocalizedModule S M)) s p) = p := p.induction_on fun m t => by rw [Module.algebraMap_end_apply, divBy_apply] erw [smul_def] rw [LocalizedModule.liftOn_mk, mul_assoc, ← smul_def] erw [smul'_mk] rw [← Submonoid.smul_def, mk_cancel_common_right _ s] theorem mul_by_divBy (s : S) (p : LocalizedModule S M) : algebraMap R (Module.End R (LocalizedModule S M)) s (divBy s p) = p := p.induction_on fun m t => by rw [divBy_apply, Module.algebraMap_end_apply, LocalizedModule.liftOn_mk, smul'_mk, ← Submonoid.smul_def, mk_cancel_common_right _ s] end end LocalizedModule section IsLocalizedModule universe u v variable {R : Type*} [CommSemiring R] (S : Submonoid R) variable {M M' M'' : Type*} [AddCommMonoid M] [AddCommMonoid M'] [AddCommMonoid M''] variable {A : Type*} [CommSemiring A] [Algebra R A] [Module A M'] [IsLocalization S A] variable [Module R M] [Module R M'] [Module R M''] [IsScalarTower R A M'] variable (f : M →ₗ[R] M') (g : M →ₗ[R] M'') /-- The characteristic predicate for localized module. `IsLocalizedModule S f` describes that `f : M ⟶ M'` is the localization map identifying `M'` as `LocalizedModule S M`. -/ @[mk_iff] class IsLocalizedModule : Prop where map_units : ∀ x : S, IsUnit (algebraMap R (Module.End R M') x) surj' : ∀ y : M', ∃ x : M × S, x.2 • y = f x.1 exists_of_eq : ∀ {x₁ x₂}, f x₁ = f x₂ → ∃ c : S, c • x₁ = c • x₂ attribute [nolint docBlame] IsLocalizedModule.map_units IsLocalizedModule.surj' IsLocalizedModule.exists_of_eq -- Porting note: Manually added to make `S` and `f` explicit. lemma IsLocalizedModule.surj [IsLocalizedModule S f] (y : M') : ∃ x : M × S, x.2 • y = f x.1 := surj' y -- Porting note: Manually added to make `S` and `f` explicit. lemma IsLocalizedModule.eq_iff_exists [IsLocalizedModule S f] {x₁ x₂} : f x₁ = f x₂ ↔ ∃ c : S, c • x₁ = c • x₂ := Iff.intro exists_of_eq fun ⟨c, h⟩ ↦ by apply_fun f at h simp_rw [f.map_smul_of_tower, Submonoid.smul_def, ← Module.algebraMap_end_apply R R] at h exact ((Module.End_isUnit_iff _).mp <| map_units f c).1 h theorem IsLocalizedModule.of_linearEquiv (e : M' ≃ₗ[R] M'') [hf : IsLocalizedModule S f] : IsLocalizedModule S (e ∘ₗ f : M →ₗ[R] M'') where map_units s := by rw [show algebraMap R (Module.End R M'') s = e ∘ₗ (algebraMap R (Module.End R M') s) ∘ₗ e.symm by ext; simp, Module.End_isUnit_iff, LinearMap.coe_comp, LinearMap.coe_comp, LinearEquiv.coe_coe, LinearEquiv.coe_coe, EquivLike.comp_bijective, EquivLike.bijective_comp] exact (Module.End_isUnit_iff _).mp <| hf.map_units s surj' x := by obtain ⟨p, h⟩ := hf.surj' (e.symm x) exact ⟨p, by rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, ← e.congr_arg h, Submonoid.smul_def, Submonoid.smul_def, LinearEquiv.map_smul, LinearEquiv.apply_symm_apply]⟩ exists_of_eq h := by simp_rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, EmbeddingLike.apply_eq_iff_eq] at h exact hf.exists_of_eq h variable (M) in lemma isLocalizedModule_id (R') [CommSemiring R'] [Algebra R R'] [IsLocalization S R'] [Module R' M] [IsScalarTower R R' M] : IsLocalizedModule S (.id : M →ₗ[R] M) where map_units s := by rw [← (Algebra.lsmul R (A := R') R M).commutes]; exact (IsLocalization.map_units R' s).map _ surj' m := ⟨(m, 1), one_smul _ _⟩ exists_of_eq h := ⟨1, congr_arg _ h⟩ variable {S} in theorem isLocalizedModule_iff_isLocalization {A Aₛ} [CommSemiring A] [Algebra R A] [CommSemiring Aₛ] [Algebra A Aₛ] [Algebra R Aₛ] [IsScalarTower R A Aₛ] : IsLocalizedModule S (IsScalarTower.toAlgHom R A Aₛ).toLinearMap ↔ IsLocalization (Algebra.algebraMapSubmonoid A S) Aₛ := by rw [isLocalizedModule_iff, isLocalization_iff] refine and_congr ?_ (and_congr (forall_congr' fun _ ↦ ?_) (forall₂_congr fun _ _ ↦ ?_)) · simp_rw [← (Algebra.lmul R Aₛ).commutes, Algebra.lmul_isUnit_iff, Subtype.forall, Algebra.algebraMapSubmonoid, ← SetLike.mem_coe, Submonoid.coe_map, Set.forall_mem_image, ← IsScalarTower.algebraMap_apply] · simp_rw [Prod.exists, Subtype.exists, Algebra.algebraMapSubmonoid] simp [← IsScalarTower.algebraMap_apply, Submonoid.mk_smul, Algebra.smul_def, mul_comm] · congr!; simp_rw [Subtype.exists, Algebra.algebraMapSubmonoid]; simp [Algebra.smul_def] instance {A Aₛ} [CommSemiring A] [Algebra R A][CommSemiring Aₛ] [Algebra A Aₛ] [Algebra R Aₛ] [IsScalarTower R A Aₛ] [h : IsLocalization (Algebra.algebraMapSubmonoid A S) Aₛ] : IsLocalizedModule S (IsScalarTower.toAlgHom R A Aₛ).toLinearMap := isLocalizedModule_iff_isLocalization.mpr h lemma isLocalizedModule_iff_isLocalization' (R') [CommSemiring R'] [Algebra R R'] : IsLocalizedModule S (Algebra.ofId R R').toLinearMap ↔ IsLocalization S R' := by convert isLocalizedModule_iff_isLocalization (S := S) (A := R) (Aₛ := R') exact (Submonoid.map_id S).symm namespace LocalizedModule /-- If `g` is a linear map `M → M''` such that all scalar multiplication by `s : S` is invertible, then there is a linear map `LocalizedModule S M → M''`. -/ noncomputable def lift' (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit (algebraMap R (Module.End R M'') x)) : LocalizedModule S M → M'' := fun m => m.liftOn (fun p => (h p.2).unit⁻¹.val <| g p.1) fun ⟨m, s⟩ ⟨m', s'⟩ ⟨c, eq1⟩ => by -- Porting note: We remove `generalize_proofs h1 h2`. This does nothing here. dsimp only simp only [Submonoid.smul_def] at eq1 rw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← map_smul, eq_comm, Module.End_algebraMap_isUnit_inv_apply_eq_iff] have : c • s • g m' = c • s' • g m := by simp only [Submonoid.smul_def, ← g.map_smul, eq1] have : Function.Injective (h c).unit.inv := ((Module.End_isUnit_iff _).1 (by simp)).1 apply_fun (h c).unit.inv erw [Units.inv_eq_val_inv, Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← (h c).unit⁻¹.val.map_smul] symm rw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← g.map_smul, ← g.map_smul, ← g.map_smul, ← g.map_smul, eq1] theorem lift'_mk (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) (m : M) (s : S) : LocalizedModule.lift' S g h (LocalizedModule.mk m s) = (h s).unit⁻¹.val (g m) := rfl theorem lift'_add (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) (x y) : LocalizedModule.lift' S g h (x + y) = LocalizedModule.lift' S g h x + LocalizedModule.lift' S g h y := LocalizedModule.induction_on₂ (by intro a a' b b' erw [LocalizedModule.lift'_mk, LocalizedModule.lift'_mk, LocalizedModule.lift'_mk] -- Porting note: We remove `generalize_proofs h1 h2 h3`. This only generalize `h1`. erw [map_add, Module.End_algebraMap_isUnit_inv_apply_eq_iff, smul_add, ← map_smul, ← map_smul, ← map_smul] congr 1 <;> symm · erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, mul_smul, ← map_smul] rfl · dsimp erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, mul_comm, mul_smul, ← map_smul] rfl) x y theorem lift'_smul (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) (r : R) (m) : r • LocalizedModule.lift' S g h m = LocalizedModule.lift' S g h (r • m) := m.induction_on fun a b => by rw [LocalizedModule.lift'_mk, LocalizedModule.smul'_mk, LocalizedModule.lift'_mk] -- Porting note: We remove `generalize_proofs h1 h2`. This does nothing here. rw [← map_smul, ← g.map_smul] /-- If `g` is a linear map `M → M''` such that all scalar multiplication by `s : S` is invertible, then there is a linear map `LocalizedModule S M → M''`. -/ noncomputable def lift (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) : LocalizedModule S M →ₗ[R] M'' where toFun := LocalizedModule.lift' S g h map_add' := LocalizedModule.lift'_add S g h map_smul' r x := by rw [LocalizedModule.lift'_smul, RingHom.id_apply] /-- If `g` is a linear map `M → M''` such that all scalar multiplication by `s : S` is invertible, then `lift g m s = s⁻¹ • g m`. -/ theorem lift_mk (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit (algebraMap R (Module.End R M'') x)) (m : M) (s : S) : LocalizedModule.lift S g h (LocalizedModule.mk m s) = (h s).unit⁻¹.val (g m) := rfl /-- If `g` is a linear map `M → M''` such that all scalar multiplication by `s : S` is invertible, then there is a linear map `lift g ∘ mkLinearMap = g`. -/ theorem lift_comp (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) : (lift S g h).comp (mkLinearMap S M) = g := by ext x; dsimp; rw [LocalizedModule.lift_mk] erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, one_smul] /-- If `g` is a linear map `M → M''` such that all scalar multiplication by `s : S` is invertible and `l` is another linear map `LocalizedModule S M ⟶ M''` such that `l ∘ mkLinearMap = g` then `l = lift g` -/ theorem lift_unique (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) (l : LocalizedModule S M →ₗ[R] M'') (hl : l.comp (LocalizedModule.mkLinearMap S M) = g) : LocalizedModule.lift S g h = l := by ext x; induction' x with m s rw [LocalizedModule.lift_mk] rw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← hl, LinearMap.coe_comp, Function.comp_apply, LocalizedModule.mkLinearMap_apply, ← l.map_smul, LocalizedModule.smul'_mk] congr 1; rw [LocalizedModule.mk_eq] refine ⟨1, ?_⟩; simp only [one_smul, Submonoid.smul_def] end LocalizedModule instance localizedModuleIsLocalizedModule : IsLocalizedModule S (LocalizedModule.mkLinearMap S M) where map_units s := ⟨⟨algebraMap R (Module.End R (LocalizedModule S M)) s, LocalizedModule.divBy s, DFunLike.ext _ _ <| LocalizedModule.mul_by_divBy s, DFunLike.ext _ _ <| LocalizedModule.divBy_mul_by s⟩, DFunLike.ext _ _ fun p => p.induction_on <| by intros rfl⟩ surj' p := p.induction_on fun m t => by refine ⟨⟨m, t⟩, ?_⟩ erw [LocalizedModule.smul'_mk, LocalizedModule.mkLinearMap_apply, Submonoid.coe_subtype, LocalizedModule.mk_cancel t] exists_of_eq eq1 := by simpa only [eq_comm, one_smul] using LocalizedModule.mk_eq.mp eq1 namespace IsLocalizedModule variable [IsLocalizedModule S f] /-- If `(M', f : M ⟶ M')` satisfies universal property of localized module, there is a canonical map `LocalizedModule S M ⟶ M'`. -/ noncomputable def fromLocalizedModule' : LocalizedModule S M → M' := fun p => p.liftOn (fun x => (IsLocalizedModule.map_units f x.2).unit⁻¹.val (f x.1)) (by rintro ⟨a, b⟩ ⟨a', b'⟩ ⟨c, eq1⟩ dsimp -- Porting note: We remove `generalize_proofs h1 h2`. rw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← map_smul, ← map_smul, Module.End_algebraMap_isUnit_inv_apply_eq_iff', ← map_smul] exact (IsLocalizedModule.eq_iff_exists S f).mpr ⟨c, eq1.symm⟩) @[simp] theorem fromLocalizedModule'_mk (m : M) (s : S) : fromLocalizedModule' S f (LocalizedModule.mk m s) = (IsLocalizedModule.map_units f s).unit⁻¹.val (f m) := rfl theorem fromLocalizedModule'_add (x y : LocalizedModule S M) : fromLocalizedModule' S f (x + y) = fromLocalizedModule' S f x + fromLocalizedModule' S f y := LocalizedModule.induction_on₂ (by intro a a' b b' simp only [LocalizedModule.mk_add_mk, fromLocalizedModule'_mk] -- Porting note: We remove `generalize_proofs h1 h2 h3`. rw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, smul_add, ← map_smul, ← map_smul, ← map_smul, map_add] congr 1 all_goals rw [Module.End_algebraMap_isUnit_inv_apply_eq_iff'] · simp [mul_smul, Submonoid.smul_def] · rw [Submonoid.coe_mul, LinearMap.map_smul_of_tower, mul_comm, mul_smul, Submonoid.smul_def]) x y theorem fromLocalizedModule'_smul (r : R) (x : LocalizedModule S M) : r • fromLocalizedModule' S f x = fromLocalizedModule' S f (r • x) := LocalizedModule.induction_on (by intro a b rw [fromLocalizedModule'_mk, LocalizedModule.smul'_mk, fromLocalizedModule'_mk] -- Porting note: We remove `generalize_proofs h1`. rw [f.map_smul, map_smul]) x /-- If `(M', f : M ⟶ M')` satisfies universal property of localized module, there is a canonical map `LocalizedModule S M ⟶ M'`. -/ noncomputable def fromLocalizedModule : LocalizedModule S M →ₗ[R] M' where toFun := fromLocalizedModule' S f map_add' := fromLocalizedModule'_add S f map_smul' r x := by rw [fromLocalizedModule'_smul, RingHom.id_apply] theorem fromLocalizedModule_mk (m : M) (s : S) : fromLocalizedModule S f (LocalizedModule.mk m s) = (IsLocalizedModule.map_units f s).unit⁻¹.val (f m) := rfl theorem fromLocalizedModule.inj : Function.Injective <| fromLocalizedModule S f := fun x y eq1 => by induction' x with a b induction' y with a' b' simp only [fromLocalizedModule_mk] at eq1 -- Porting note: We remove `generalize_proofs h1 h2`. rw [Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← LinearMap.map_smul, Module.End_algebraMap_isUnit_inv_apply_eq_iff'] at eq1 rw [LocalizedModule.mk_eq, ← IsLocalizedModule.eq_iff_exists S f, Submonoid.smul_def, Submonoid.smul_def, f.map_smul, f.map_smul, eq1] theorem fromLocalizedModule.surj : Function.Surjective <| fromLocalizedModule S f := fun x => let ⟨⟨m, s⟩, eq1⟩ := IsLocalizedModule.surj S f x ⟨LocalizedModule.mk m s, by rw [fromLocalizedModule_mk, Module.End_algebraMap_isUnit_inv_apply_eq_iff, ← eq1, Submonoid.smul_def]⟩ theorem fromLocalizedModule.bij : Function.Bijective <| fromLocalizedModule S f := ⟨fromLocalizedModule.inj _ _, fromLocalizedModule.surj _ _⟩ /-- If `(M', f : M ⟶ M')` satisfies universal property of localized module, then `M'` is isomorphic to `LocalizedModule S M` as an `R`-module. -/ @[simps!] noncomputable def iso : LocalizedModule S M ≃ₗ[R] M' := { fromLocalizedModule S f, Equiv.ofBijective (fromLocalizedModule S f) <| fromLocalizedModule.bij _ _ with } theorem iso_apply_mk (m : M) (s : S) : iso S f (LocalizedModule.mk m s) = (IsLocalizedModule.map_units f s).unit⁻¹.val (f m) := rfl theorem iso_symm_apply_aux (m : M') : (iso S f).symm m = LocalizedModule.mk (IsLocalizedModule.surj S f m).choose.1 (IsLocalizedModule.surj S f m).choose.2 := by -- Porting note: We remove `generalize_proofs _ h2`. apply_fun iso S f using LinearEquiv.injective (iso S f) rw [LinearEquiv.apply_symm_apply] simp only [iso_apply, LinearMap.toFun_eq_coe, fromLocalizedModule_mk] erw [Module.End_algebraMap_isUnit_inv_apply_eq_iff', (surj' _).choose_spec] theorem iso_symm_apply' (m : M') (a : M) (b : S) (eq1 : b • m = f a) : (iso S f).symm m = LocalizedModule.mk a b := (iso_symm_apply_aux S f m).trans <| LocalizedModule.mk_eq.mpr <| by -- Porting note: We remove `generalize_proofs h1`. rw [← IsLocalizedModule.eq_iff_exists S f, Submonoid.smul_def, Submonoid.smul_def, f.map_smul, f.map_smul, ← (surj' _).choose_spec, ← Submonoid.smul_def, ← Submonoid.smul_def, ← mul_smul, mul_comm, mul_smul, eq1] theorem iso_symm_comp : (iso S f).symm.toLinearMap.comp f = LocalizedModule.mkLinearMap S M := by ext m rw [LinearMap.comp_apply, LocalizedModule.mkLinearMap_apply, LinearEquiv.coe_coe, iso_symm_apply'] exact one_smul _ _ /-- If `M'` is a localized module and `g` is a linear map `M → M''` such that all scalar multiplication by `s : S` is invertible, then there is a linear map `M' → M''`. -/ noncomputable def lift (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) : M' →ₗ[R] M'' := (LocalizedModule.lift S g h).comp (iso S f).symm.toLinearMap theorem lift_comp (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) : (lift S f g h).comp f = g := by dsimp only [IsLocalizedModule.lift] rw [LinearMap.comp_assoc, iso_symm_comp, LocalizedModule.lift_comp S g h] @[simp] theorem lift_apply (g : M →ₗ[R] M'') (h) (x) : lift S f g h (f x) = g x := LinearMap.congr_fun (lift_comp S f g h) x theorem lift_unique (g : M →ₗ[R] M'') (h : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) (l : M' →ₗ[R] M'') (hl : l.comp f = g) : lift S f g h = l := by dsimp only [IsLocalizedModule.lift] rw [LocalizedModule.lift_unique S g h (l.comp (iso S f).toLinearMap), LinearMap.comp_assoc, LinearEquiv.comp_coe, LinearEquiv.symm_trans_self, LinearEquiv.refl_toLinearMap, LinearMap.comp_id] rw [LinearMap.comp_assoc, ← hl] congr 1 ext x rw [LinearMap.comp_apply, LocalizedModule.mkLinearMap_apply, LinearEquiv.coe_coe, iso_apply, fromLocalizedModule'_mk, Module.End_algebraMap_isUnit_inv_apply_eq_iff, OneMemClass.coe_one, one_smul] /-- Universal property from localized module: If `(M', f : M ⟶ M')` is a localized module then it satisfies the following universal property: For every `R`-module `M''` which every `s : S`-scalar multiplication is invertible and for every `R`-linear map `g : M ⟶ M''`, there is a unique `R`-linear map `l : M' ⟶ M''` such that `l ∘ f = g`. ``` M -----f----> M' | / |g / | / l v / M'' ``` -/ theorem is_universal : ∀ (g : M →ₗ[R] M'') (_ : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)), ∃! l : M' →ₗ[R] M'', l.comp f = g := fun g h => ⟨lift S f g h, lift_comp S f g h, fun l hl => (lift_unique S f g h l hl).symm⟩ theorem ringHom_ext (map_unit : ∀ x : S, IsUnit ((algebraMap R (Module.End R M'')) x)) ⦃j k : M' →ₗ[R] M''⦄ (h : j.comp f = k.comp f) : j = k := by rw [← lift_unique S f (k.comp f) map_unit j h, lift_unique] rfl /-- If `(M', f)` and `(M'', g)` both satisfy universal property of localized module, then `M', M''` are isomorphic as `R`-module -/ noncomputable def linearEquiv [IsLocalizedModule S g] : M' ≃ₗ[R] M'' := (iso S f).symm.trans (iso S g) variable {S} theorem smul_injective (s : S) : Function.Injective fun m : M' => s • m := ((Module.End_isUnit_iff _).mp (IsLocalizedModule.map_units f s)).injective theorem smul_inj (s : S) (m₁ m₂ : M') : s • m₁ = s • m₂ ↔ m₁ = m₂ := (smul_injective f s).eq_iff /-- `mk' f m s` is the fraction `m/s` with respect to the localization map `f`. -/ noncomputable def mk' (m : M) (s : S) : M' := fromLocalizedModule S f (LocalizedModule.mk m s) theorem mk'_smul (r : R) (m : M) (s : S) : mk' f (r • m) s = r • mk' f m s := by delta mk' rw [← LocalizedModule.smul'_mk, LinearMap.map_smul] theorem mk'_add_mk' (m₁ m₂ : M) (s₁ s₂ : S) : mk' f m₁ s₁ + mk' f m₂ s₂ = mk' f (s₂ • m₁ + s₁ • m₂) (s₁ * s₂) := by delta mk' rw [← map_add, LocalizedModule.mk_add_mk] @[simp] theorem mk'_zero (s : S) : mk' f 0 s = 0 := by rw [← zero_smul R (0 : M), mk'_smul, zero_smul] variable (S) @[simp] theorem mk'_one (m : M) : mk' f m (1 : S) = f m := by delta mk' rw [fromLocalizedModule_mk, Module.End_algebraMap_isUnit_inv_apply_eq_iff, Submonoid.coe_one, one_smul] variable {S} @[simp] theorem mk'_cancel (m : M) (s : S) : mk' f (s • m) s = f m := by delta mk' rw [LocalizedModule.mk_cancel, ← mk'_one S f, fromLocalizedModule_mk, Module.End_algebraMap_isUnit_inv_apply_eq_iff, OneMemClass.coe_one, mk'_one, one_smul] @[simp] theorem mk'_cancel' (m : M) (s : S) : s • mk' f m s = f m := by rw [Submonoid.smul_def, ← mk'_smul, ← Submonoid.smul_def, mk'_cancel] @[simp] theorem mk'_cancel_left (m : M) (s₁ s₂ : S) : mk' f (s₁ • m) (s₁ * s₂) = mk' f m s₂ := by delta mk' rw [LocalizedModule.mk_cancel_common_left] @[simp] theorem mk'_cancel_right (m : M) (s₁ s₂ : S) : mk' f (s₂ • m) (s₁ * s₂) = mk' f m s₁ := by delta mk' rw [LocalizedModule.mk_cancel_common_right] theorem mk'_add (m₁ m₂ : M) (s : S) : mk' f (m₁ + m₂) s = mk' f m₁ s + mk' f m₂ s := by rw [mk'_add_mk', ← smul_add, mk'_cancel_left] theorem mk'_eq_mk'_iff (m₁ m₂ : M) (s₁ s₂ : S) : mk' f m₁ s₁ = mk' f m₂ s₂ ↔ ∃ s : S, s • s₁ • m₂ = s • s₂ • m₁ := by delta mk' rw [(fromLocalizedModule.inj S f).eq_iff, LocalizedModule.mk_eq] simp_rw [eq_comm] theorem mk'_neg {M M' : Type*} [AddCommGroup M] [AddCommGroup M'] [Module R M] [Module R M'] (f : M →ₗ[R] M') [IsLocalizedModule S f] (m : M) (s : S) : mk' f (-m) s = -mk' f m s := by delta mk' rw [LocalizedModule.mk_neg, map_neg] theorem mk'_sub {M M' : Type*} [AddCommGroup M] [AddCommGroup M'] [Module R M] [Module R M'] (f : M →ₗ[R] M') [IsLocalizedModule S f] (m₁ m₂ : M) (s : S) : mk' f (m₁ - m₂) s = mk' f m₁ s - mk' f m₂ s := by rw [sub_eq_add_neg, sub_eq_add_neg, mk'_add, mk'_neg] theorem mk'_sub_mk' {M M' : Type*} [AddCommGroup M] [AddCommGroup M'] [Module R M] [Module R M'] (f : M →ₗ[R] M') [IsLocalizedModule S f] (m₁ m₂ : M) (s₁ s₂ : S) : mk' f m₁ s₁ - mk' f m₂ s₂ = mk' f (s₂ • m₁ - s₁ • m₂) (s₁ * s₂) := by rw [sub_eq_add_neg, ← mk'_neg, mk'_add_mk', smul_neg, ← sub_eq_add_neg] theorem mk'_mul_mk'_of_map_mul {M M' : Type*} [Semiring M] [Semiring M'] [Module R M] [Algebra R M'] (f : M →ₗ[R] M') (hf : ∀ m₁ m₂, f (m₁ * m₂) = f m₁ * f m₂) [IsLocalizedModule S f] (m₁ m₂ : M) (s₁ s₂ : S) : mk' f m₁ s₁ * mk' f m₂ s₂ = mk' f (m₁ * m₂) (s₁ * s₂) := by symm apply (Module.End_algebraMap_isUnit_inv_apply_eq_iff _ _ _ _).mpr simp_rw [Submonoid.coe_mul, ← smul_eq_mul] rw [smul_smul_smul_comm, ← mk'_smul, ← mk'_smul] simp_rw [← Submonoid.smul_def, mk'_cancel, smul_eq_mul, hf] theorem mk'_mul_mk' {M M' : Type*} [Semiring M] [Semiring M'] [Algebra R M] [Algebra R M'] (f : M →ₐ[R] M') [IsLocalizedModule S f.toLinearMap] (m₁ m₂ : M) (s₁ s₂ : S) : mk' f.toLinearMap m₁ s₁ * mk' f.toLinearMap m₂ s₂ = mk' f.toLinearMap (m₁ * m₂) (s₁ * s₂) := mk'_mul_mk'_of_map_mul f.toLinearMap (map_mul f) m₁ m₂ s₁ s₂ variable {f} /-- Porting note (#10618): simp can prove this @[simp] -/ theorem mk'_eq_iff {m : M} {s : S} {m' : M'} : mk' f m s = m' ↔ f m = s • m' := by rw [← smul_inj f s, Submonoid.smul_def, ← mk'_smul, ← Submonoid.smul_def, mk'_cancel] @[simp] theorem mk'_eq_zero {m : M} (s : S) : mk' f m s = 0 ↔ f m = 0 := by rw [mk'_eq_iff, smul_zero] variable (f) theorem mk'_eq_zero' {m : M} (s : S) : mk' f m s = 0 ↔ ∃ s' : S, s' • m = 0 := by simp_rw [← mk'_zero f (1 : S), mk'_eq_mk'_iff, smul_zero, one_smul, eq_comm] theorem mk_eq_mk' (s : S) (m : M) : LocalizedModule.mk m s = mk' (LocalizedModule.mkLinearMap S M) m s := by rw [eq_comm, mk'_eq_iff, Submonoid.smul_def, LocalizedModule.smul'_mk, ← Submonoid.smul_def, LocalizedModule.mk_cancel, LocalizedModule.mkLinearMap_apply] variable (A) in lemma mk'_smul_mk' (x : R) (m : M) (s t : S) : IsLocalization.mk' A x s • mk' f m t = mk' f (x • m) (s * t) := by apply smul_injective f (s * t) conv_lhs => simp only [smul_assoc, mul_smul, smul_comm t] simp only [mk'_cancel', map_smul, Submonoid.smul_def s] rw [← smul_assoc, IsLocalization.smul_mk'_self, algebraMap_smul] variable (S) theorem eq_zero_iff {m : M} : f m = 0 ↔ ∃ s' : S, s' • m = 0 := (mk'_eq_zero (1 : S)).symm.trans (mk'_eq_zero' f _) theorem mk'_surjective : Function.Surjective (Function.uncurry <| mk' f : M × S → M') := by intro x obtain ⟨⟨m, s⟩, e : s • x = f m⟩ := IsLocalizedModule.surj S f x exact ⟨⟨m, s⟩, mk'_eq_iff.mpr e.symm⟩ variable {N N'} [AddCommGroup N] [AddCommGroup N'] [Module R N] [Module R N'] variable (g : N →ₗ[R] N') [IsLocalizedModule S g] /-- A linear map `M →ₗ[R] N` gives a map between localized modules `Mₛ →ₗ[R] Nₛ`. -/ noncomputable def map : (M →ₗ[R] N) →ₗ[R] (M' →ₗ[R] N') where toFun h := lift S f (g ∘ₗ h) (IsLocalizedModule.map_units g) map_add' h₁ h₂ := by apply IsLocalizedModule.ringHom_ext S f (IsLocalizedModule.map_units g) simp only [lift_comp, LinearMap.add_comp, LinearMap.comp_add] map_smul' r h := by apply IsLocalizedModule.ringHom_ext S f (IsLocalizedModule.map_units g) simp only [lift_comp, LinearMap.add_comp, LinearMap.comp_add, LinearMap.smul_comp, LinearMap.comp_smul, RingHom.id_apply] lemma map_comp (h : M →ₗ[R] N) : (map S f g h) ∘ₗ f = g ∘ₗ h := lift_comp S f (g ∘ₗ h) (IsLocalizedModule.map_units g) @[simp] lemma map_apply (h : M →ₗ[R] N) (x) : map S f g h (f x) = g (h x) := lift_apply S f (g ∘ₗ h) (IsLocalizedModule.map_units g) x @[simp] lemma map_mk' (h : M →ₗ[R] N) (x) (s : S) : map S f g h (IsLocalizedModule.mk' f x s) = (IsLocalizedModule.mk' g (h x) s) := by simp only [map, lift, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply] rw [iso_symm_apply' S f (mk' f x s) x s (mk'_cancel' f x s), LocalizedModule.lift_mk] rfl open LocalizedModule LinearEquiv LinearMap Submonoid variable (M) /-- The linear map `(LocalizedModule S M) → (LocalizedModule S M)` from `iso` is the identity. -/ lemma iso_localizedModule_eq_refl : iso S (mkLinearMap S M) = refl R (LocalizedModule S M) := by let f := mkLinearMap S M obtain ⟨e, _, univ⟩ := is_universal S f f (map_units f) rw [← toLinearMap_inj, univ (iso S f) ((eq_toLinearMap_symm_comp f f).1 (iso_symm_comp S f).symm)] exact Eq.symm <| univ (refl R (LocalizedModule S M)) (by simp) variable {M₀ M₀'} [AddCommGroup M₀] [AddCommGroup M₀'] [Module R M₀] [Module R M₀'] variable (f₀ : M₀ →ₗ[R] M₀') [IsLocalizedModule S f₀] variable {M₁ M₁'} [AddCommGroup M₁] [AddCommGroup M₁'] [Module R M₁] [Module R M₁'] variable (f₁ : M₁ →ₗ[R] M₁') [IsLocalizedModule S f₁] /-- Formula for `IsLocalizedModule.map` when each localized module is a `LocalizedModule`.-/ lemma map_LocalizedModules (g : M₀ →ₗ[R] M₁) (m : M₀) (s : S) : ((map S (mkLinearMap S M₀) (mkLinearMap S M₁)) g) (LocalizedModule.mk m s) = LocalizedModule.mk (g m) s := by have := (iso_apply_mk S (mkLinearMap S M₁) (g m) s).symm rw [iso_localizedModule_eq_refl, refl_apply] at this simpa [map, lift, iso_localizedModule_eq_refl S M₀] lemma map_iso_commute (g : M₀ →ₗ[R] M₁) : (map S f₀ f₁) g ∘ₗ (iso S f₀) = (iso S f₁) ∘ₗ (map S (mkLinearMap S M₀) (mkLinearMap S M₁)) g := by ext x refine induction_on (fun m s ↦ ((Module.End_isUnit_iff _).1 (map_units f₁ s)).1 ?_) x repeat rw [Module.algebraMap_end_apply, ← CompatibleSMul.map_smul, smul'_mk, ← mk_smul, mk_cancel] simp -- Can't be combined with next simp. This uses map_apply, which would be preempted by map. simp [map, lift, iso_localizedModule_eq_refl, lift_mk] end IsLocalizedModule namespace LocalizedModule open IsLocalizedModule LocalizedModule Function Submonoid variable {M₀ M₀'} [AddCommGroup M₀] [Module R M₀] variable {M₁ M₁'} [AddCommGroup M₁] [Module R M₁] variable {M₂ M₂'} [AddCommGroup M₂] [Module R M₂] /-- Localization of modules is an exact functor, proven here for `LocalizedModule`. See `IsLocalizedModule.map_exact` for the more general version. -/ lemma map_exact (g : M₀ →ₗ[R] M₁) (h : M₁ →ₗ[R] M₂) (ex : Exact g h) : Exact (map S (mkLinearMap S M₀) (mkLinearMap S M₁) g) (map S (mkLinearMap S M₁) (mkLinearMap S M₂) h) := fun y ↦ Iff.intro (induction_on (fun m s hy ↦ by rw [map_LocalizedModules, ← zero_mk 1, mk_eq, one_smul, smul_zero] at hy obtain ⟨a, aS, ha⟩ := Subtype.exists.1 hy rw [smul_zero, mk_smul, ← LinearMap.map_smul, ex (a • m)] at ha rcases ha with ⟨x, hx⟩ use mk x (⟨a, aS⟩ * s) rw [map_LocalizedModules, hx, ← mk_cancel_common_left ⟨a, aS⟩ s m, mk_smul]) y) fun ⟨x, hx⟩ ↦ by revert hx refine induction_on (fun m s hx ↦ ?_) x rw [← hx, map_LocalizedModules, map_LocalizedModules, (ex (g m)).2 ⟨m, rfl⟩, zero_mk] end LocalizedModule namespace IsLocalizedModule variable {M₀ M₀'} [AddCommGroup M₀] [AddCommGroup M₀'] [Module R M₀] [Module R M₀'] variable (f₀ : M₀ →ₗ[R] M₀') [IsLocalizedModule S f₀] variable {M₁ M₁'} [AddCommGroup M₁] [AddCommGroup M₁'] [Module R M₁] [Module R M₁'] variable (f₁ : M₁ →ₗ[R] M₁') [IsLocalizedModule S f₁] variable {M₂ M₂'} [AddCommGroup M₂] [AddCommGroup M₂'] [Module R M₂] [Module R M₂'] variable (f₂ : M₂ →ₗ[R] M₂') [IsLocalizedModule S f₂] /-- Localization of modules is an exact functor. -/ theorem map_exact (g : M₀ →ₗ[R] M₁) (h : M₁ →ₗ[R] M₂) (ex : Function.Exact g h) : Function.Exact (map S f₀ f₁ g) (map S f₁ f₂ h) := Function.Exact.of_ladder_linearEquiv_of_exact (map_iso_commute S f₀ f₁ g) (map_iso_commute S f₁ f₂ h) (LocalizedModule.map_exact S g h ex) section Algebra theorem mkOfAlgebra {R S S' : Type*} [CommRing R] [CommRing S] [CommRing S'] [Algebra R S] [Algebra R S'] (M : Submonoid R) (f : S →ₐ[R] S') (h₁ : ∀ x ∈ M, IsUnit (algebraMap R S' x)) (h₂ : ∀ y, ∃ x : S × M, x.2 • y = f x.1) (h₃ : ∀ x, f x = 0 → ∃ m : M, m • x = 0) : IsLocalizedModule M f.toLinearMap := by replace h₃ := fun x => Iff.intro (h₃ x) fun ⟨⟨m, hm⟩, e⟩ => (h₁ m hm).mul_left_cancel <| by rw [← Algebra.smul_def] simpa [Submonoid.smul_def] using f.congr_arg e constructor · intro x rw [Module.End_isUnit_iff] constructor · rintro a b (e : x • a = x • b) simp_rw [Submonoid.smul_def, Algebra.smul_def] at e exact (h₁ x x.2).mul_left_cancel e · intro a refine ⟨((h₁ x x.2).unit⁻¹ : _) * a, ?_⟩ rw [Module.algebraMap_end_apply, Algebra.smul_def, ← mul_assoc, IsUnit.mul_val_inv, one_mul] · exact h₂ · intros x y dsimp only [AlgHom.toLinearMap_apply] rw [← sub_eq_zero, ← map_sub, h₃] simp_rw [smul_sub, sub_eq_zero] exact id end Algebra end IsLocalizedModule end IsLocalizedModule section Subsingleton variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] lemma LocalizedModule.mem_ker_mkLinearMap_iff {S : Submonoid R} {m} : m ∈ LinearMap.ker (LocalizedModule.mkLinearMap S M) ↔ ∃ r ∈ S, r • m = 0 := by constructor · intro H obtain ⟨r, hr⟩ := (@LocalizedModule.mk_eq _ _ S M _ _ m 0 1 1).mp (by simpa using H) exact ⟨r, r.2, by simpa using hr⟩ · rintro ⟨r, hr, e⟩ apply ((Module.End_isUnit_iff _).mp (IsLocalizedModule.map_units (LocalizedModule.mkLinearMap S M) ⟨r, hr⟩)).injective simp [← IsLocalizedModule.mk_eq_mk', LocalizedModule.smul'_mk, e] lemma LocalizedModule.subsingleton_iff_ker_eq_top {S : Submonoid R} : Subsingleton (LocalizedModule S M) ↔ LinearMap.ker (LocalizedModule.mkLinearMap S M) = ⊤ := by rw [← top_le_iff] refine ⟨fun H m _ ↦ Subsingleton.elim _ _, fun H ↦ (subsingleton_iff_forall_eq 0).mpr fun x ↦ ?_⟩ obtain ⟨⟨x, s⟩, rfl⟩ := IsLocalizedModule.mk'_surjective S (LocalizedModule.mkLinearMap S M) x simpa using @H x trivial lemma LocalizedModule.subsingleton_iff {S : Submonoid R} : Subsingleton (LocalizedModule S M) ↔ ∀ m : M, ∃ r ∈ S, r • m = 0 := by simp_rw [subsingleton_iff_ker_eq_top, ← top_le_iff, SetLike.le_def, mem_ker_mkLinearMap_iff, Submodule.mem_top, true_implies] end Subsingleton
Algebra\Module\LocalizedModuleIntegers.lean
/- Copyright (c) 2024 Christian Merten. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Christian Merten -/ import Mathlib.Algebra.Module.LocalizedModule import Mathlib.Algebra.Module.Submodule.Pointwise /-! # Integer elements of a localized module This is a mirror of the corresponding notion for localizations of rings. ## Main definitions * `IsLocalizedModule.IsInteger` is a predicate stating that `m : M'` is in the image of `M` ## Implementation details After `IsLocalizedModule` and `IsLocalization` are unified, the two `IsInteger` predicates can be unified. -/ variable {R : Type*} [CommSemiring R] {S : Submonoid R} {M : Type*} [AddCommMonoid M] [Module R M] {M' : Type*} [AddCommMonoid M'] [Module R M'] (f : M →ₗ[R] M') open Function namespace IsLocalizedModule /-- Given `x : M'`, `M'` a localization of `M` via `f`, `IsInteger f x` iff `x` is in the image of the localization map `f`. -/ def IsInteger (x : M') : Prop := x ∈ LinearMap.range f lemma isInteger_zero : IsInteger f (0 : M') := Submodule.zero_mem _ theorem isInteger_add {x y : M'} (hx : IsInteger f x) (hy : IsInteger f y) : IsInteger f (x + y) := Submodule.add_mem _ hx hy theorem isInteger_smul {a : R} {x : M'} (hx : IsInteger f x) : IsInteger f (a • x) := by rcases hx with ⟨x', hx⟩ use a • x' rw [← hx, LinearMapClass.map_smul] variable (S) variable [IsLocalizedModule S f] /-- Each element `x : M'` has an `S`-multiple which is an integer. -/ theorem exists_integer_multiple (x : M') : ∃ a : S, IsInteger f (a.val • x) := let ⟨⟨Num, denom⟩, h⟩ := IsLocalizedModule.surj S f x ⟨denom, Set.mem_range.mpr ⟨Num, h.symm⟩⟩ /-- We can clear the denominators of a `Finset`-indexed family of fractions. -/ theorem exist_integer_multiples {ι : Type*} (s : Finset ι) (g : ι → M') : ∃ b : S, ∀ i ∈ s, IsInteger f (b.val • g i) := by classical choose sec hsec using (fun i ↦ IsLocalizedModule.surj S f (g i)) refine ⟨∏ i ∈ s, (sec i).2, fun i hi => ⟨?_, ?_⟩⟩ · exact (∏ j ∈ s.erase i, (sec j).2) • (sec i).1 · simp only [LinearMap.map_smul_of_tower, Submonoid.coe_finset_prod] rw [← hsec, ← mul_smul, Submonoid.smul_def] congr simp only [Submonoid.coe_mul, Submonoid.coe_finset_prod, mul_comm] rw [← Finset.prod_insert (f := fun i ↦ ((sec i).snd).val) (s.not_mem_erase i), Finset.insert_erase hi] /-- We can clear the denominators of a finite indexed family of fractions. -/ theorem exist_integer_multiples_of_finite {ι : Type*} [Finite ι] (g : ι → M') : ∃ b : S, ∀ i, IsInteger f ((b : R) • g i) := by cases nonempty_fintype ι obtain ⟨b, hb⟩ := exist_integer_multiples S f Finset.univ g exact ⟨b, fun i => hb i (Finset.mem_univ _)⟩ /-- We can clear the denominators of a finite set of fractions. -/ theorem exist_integer_multiples_of_finset (s : Finset M') : ∃ b : S, ∀ a ∈ s, IsInteger f ((b : R) • a) := exist_integer_multiples S f s id /-- A choice of a common multiple of the denominators of a `Finset`-indexed family of fractions. -/ noncomputable def commonDenom {ι : Type*} (s : Finset ι) (g : ι → M') : S := (exist_integer_multiples S f s g).choose /-- The numerator of a fraction after clearing the denominators of a `Finset`-indexed family of fractions. -/ noncomputable def integerMultiple {ι : Type*} (s : Finset ι) (g : ι → M') (i : s) : M := ((exist_integer_multiples S f s g).choose_spec i i.prop).choose @[simp] theorem map_integerMultiple {ι : Type*} (s : Finset ι) (g : ι → M') (i : s) : f (integerMultiple S f s g i) = commonDenom S f s g • g i := ((exist_integer_multiples S f s g).choose_spec _ i.prop).choose_spec /-- A choice of a common multiple of the denominators of a finite set of fractions. -/ noncomputable def commonDenomOfFinset (s : Finset M') : S := commonDenom S f s id /-- The finset of numerators after clearing the denominators of a finite set of fractions. -/ noncomputable def finsetIntegerMultiple [DecidableEq M] (s : Finset M') : Finset M := s.attach.image fun t => integerMultiple S f s id t open Pointwise theorem finsetIntegerMultiple_image [DecidableEq M] (s : Finset M') : f '' finsetIntegerMultiple S f s = commonDenomOfFinset S f s • (s : Set M') := by delta finsetIntegerMultiple commonDenom rw [Finset.coe_image] ext constructor · rintro ⟨_, ⟨x, -, rfl⟩, rfl⟩ rw [map_integerMultiple] exact Set.mem_image_of_mem _ x.prop · rintro ⟨x, hx, rfl⟩ exact ⟨_, ⟨⟨x, hx⟩, s.mem_attach _, rfl⟩, map_integerMultiple S f s id _⟩ theorem smul_mem_finsetIntegerMultiple_span [DecidableEq M] (x : M) (s : Finset M') (hx : f x ∈ Submodule.span R s) : ∃ (m : S), m • x ∈ Submodule.span R (IsLocalizedModule.finsetIntegerMultiple S f s) := by let y : S := IsLocalizedModule.commonDenomOfFinset S f s have hx₁ : (y : R) • (s : Set M') = f '' _ := (IsLocalizedModule.finsetIntegerMultiple_image S f s).symm apply congrArg (Submodule.span R) at hx₁ rw [Submodule.span_smul] at hx₁ replace hx : _ ∈ y • Submodule.span R (s : Set M') := Set.smul_mem_smul_set hx erw [hx₁, ← f.map_smul, ← Submodule.map_span f] at hx obtain ⟨x', hx', hx''⟩ := hx obtain ⟨a, ha⟩ := (IsLocalizedModule.eq_iff_exists S f).mp hx'' use a * y convert (Submodule.span R (IsLocalizedModule.finsetIntegerMultiple S f s : Set M)).smul_mem a hx' using 1 convert ha.symm using 1 simp only [Submonoid.coe_subtype, Submonoid.smul_def] erw [← smul_smul] end IsLocalizedModule
Algebra\Module\MinimalAxioms.lean
/- Copyright (c) 2015 Nathaniel Thomas. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Martin C. Martin -/ import Mathlib.Algebra.Module.Defs /-! # Minimal Axioms for a Module This file defines a constructor to define a `Module` structure on a Type with an `AddCommGroup`, while proving a minimum number of equalities. ## Main Definitions * `Module.ofMinimalAxioms`: Define a `Module` structure on a Type with an AddCommGroup by proving a minimized set of axioms -/ universe u v /-- Define a `Module` structure on a Type by proving a minimized set of axioms. -/ abbrev Module.ofMinimalAxioms {R : Type u} {M : Type v} [Semiring R] [AddCommGroup M] [SMul R M] -- Scalar multiplication distributes over addition from the left. (smul_add : ∀ (r : R) (x y : M), r • (x + y) = r • x + r • y) -- Scalar multiplication distributes over addition from the right. (add_smul : ∀ (r s : R) (x : M), (r + s) • x = r • x + s • x) -- Scalar multiplication distributes over multiplication from the right. (mul_smul : ∀ (r s : R) (x : M), (r * s) • x = r • s • x) -- Scalar multiplication by one is the identity. (one_smul : ∀ x : M, (1 : R) • x = x) : Module R M := { smul_add := smul_add, add_smul := add_smul, mul_smul := mul_smul, one_smul := one_smul, zero_smul := fun x => (AddMonoidHom.mk' (· • x) fun r s => add_smul r s x).map_zero smul_zero := fun r => (AddMonoidHom.mk' (r • ·) (smul_add r)).map_zero }
Algebra\Module\Opposites.lean
/- Copyright (c) 2020 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.GroupWithZero.Action.Opposite import Mathlib.Algebra.Module.Equiv.Defs /-! # Module operations on `Mᵐᵒᵖ` This file contains definitions that build on top of the group action definitions in `Mathlib.Algebra.GroupWithZero.Action.Opposite`. -/ namespace MulOpposite universe u v variable (R : Type u) {M : Type v} [Semiring R] [AddCommMonoid M] [Module R M] /-- `MulOpposite.distribMulAction` extends to a `Module` -/ instance instModule : Module R Mᵐᵒᵖ where add_smul _ _ _ := unop_injective <| add_smul _ _ _ zero_smul _ := unop_injective <| zero_smul _ _ /-- The function `op` is a linear equivalence. -/ def opLinearEquiv : M ≃ₗ[R] Mᵐᵒᵖ := { opAddEquiv with map_smul' := MulOpposite.op_smul } @[simp] theorem coe_opLinearEquiv : (opLinearEquiv R : M → Mᵐᵒᵖ) = op := rfl @[simp] theorem coe_opLinearEquiv_symm : ((opLinearEquiv R).symm : Mᵐᵒᵖ → M) = unop := rfl @[simp] theorem coe_opLinearEquiv_toLinearMap : ((opLinearEquiv R).toLinearMap : M → Mᵐᵒᵖ) = op := rfl @[simp] theorem coe_opLinearEquiv_symm_toLinearMap : ((opLinearEquiv R).symm.toLinearMap : Mᵐᵒᵖ → M) = unop := rfl -- Porting note: LHS simplifies; added new simp lemma below @[simp] theorem opLinearEquiv_toAddEquiv : (opLinearEquiv R : M ≃ₗ[R] Mᵐᵒᵖ).toAddEquiv = opAddEquiv := rfl @[simp] theorem coe_opLinearEquiv_addEquiv : ((opLinearEquiv R : M ≃ₗ[R] Mᵐᵒᵖ) : M ≃+ Mᵐᵒᵖ) = opAddEquiv := rfl -- Porting note: LHS simplifies; added new simp lemma below @[simp] theorem opLinearEquiv_symm_toAddEquiv : (opLinearEquiv R : M ≃ₗ[R] Mᵐᵒᵖ).symm.toAddEquiv = opAddEquiv.symm := rfl @[simp] theorem coe_opLinearEquiv_symm_addEquiv : ((opLinearEquiv R : M ≃ₗ[R] Mᵐᵒᵖ).symm : Mᵐᵒᵖ ≃+ M) = opAddEquiv.symm := rfl end MulOpposite
Algebra\Module\Pi.lean
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon, Patrick Massot -/ import Mathlib.Algebra.GroupWithZero.Action.Pi import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Regular.SMul import Mathlib.Algebra.Ring.Pi /-! # Pi instances for modules This file defines instances for module and related structures on Pi Types -/ universe u v w variable {I : Type u} -- The indexing type variable {f : I → Type v} -- The family of types already equipped with instances variable (x y : ∀ i, f i) (i : I) namespace Pi theorem _root_.IsSMulRegular.pi {α : Type*} [∀ i, SMul α <| f i] {k : α} (hk : ∀ i, IsSMulRegular (f i) k) : IsSMulRegular (∀ i, f i) k := fun _ _ h => funext fun i => hk i (congr_fun h i : _) instance smulWithZero (α) [Zero α] [∀ i, Zero (f i)] [∀ i, SMulWithZero α (f i)] : SMulWithZero α (∀ i, f i) := { Pi.instSMul with smul_zero := fun _ => funext fun _ => smul_zero _ zero_smul := fun _ => funext fun _ => zero_smul _ _ } instance smulWithZero' {g : I → Type*} [∀ i, Zero (g i)] [∀ i, Zero (f i)] [∀ i, SMulWithZero (g i) (f i)] : SMulWithZero (∀ i, g i) (∀ i, f i) := { Pi.smul' with smul_zero := fun _ => funext fun _ => smul_zero _ zero_smul := fun _ => funext fun _ => zero_smul _ _ } instance mulActionWithZero (α) [MonoidWithZero α] [∀ i, Zero (f i)] [∀ i, MulActionWithZero α (f i)] : MulActionWithZero α (∀ i, f i) := { Pi.mulAction _, Pi.smulWithZero _ with } instance mulActionWithZero' {g : I → Type*} [∀ i, MonoidWithZero (g i)] [∀ i, Zero (f i)] [∀ i, MulActionWithZero (g i) (f i)] : MulActionWithZero (∀ i, g i) (∀ i, f i) := { Pi.mulAction', Pi.smulWithZero' with } variable (I f) instance module (α) {r : Semiring α} {m : ∀ i, AddCommMonoid <| f i} [∀ i, Module α <| f i] : @Module α (∀ i : I, f i) r (@Pi.addCommMonoid I f m) := { Pi.distribMulAction _ with add_smul := fun _ _ _ => funext fun _ => add_smul _ _ _ zero_smul := fun _ => funext fun _ => zero_smul α _ } /- Extra instance to short-circuit type class resolution. For unknown reasons, this is necessary for certain inference problems. E.g., for this to succeed: ```lean example (β X : Type*) [NormedAddCommGroup β] [NormedSpace ℝ β] : Module ℝ (X → β) := inferInstance ``` See: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Typeclass.20resolution.20under.20binders/near/281296989 -/ /-- A special case of `Pi.module` for non-dependent types. Lean struggles to elaborate definitions elsewhere in the library without this. -/ instance Function.module (α β : Type*) [Semiring α] [AddCommMonoid β] [Module α β] : Module α (I → β) := Pi.module _ _ _ variable {I f} instance module' {g : I → Type*} {r : ∀ i, Semiring (f i)} {m : ∀ i, AddCommMonoid (g i)} [∀ i, Module (f i) (g i)] : Module (∀ i, f i) (∀ i, g i) where add_smul := by intros ext1 apply add_smul zero_smul := by intros ext1 -- Porting note: not sure why `apply zero_smul` fails here. rw [zero_smul] instance noZeroSMulDivisors (α) [Semiring α] [∀ i, AddCommMonoid <| f i] [∀ i, Module α <| f i] [∀ i, NoZeroSMulDivisors α <| f i] : NoZeroSMulDivisors α (∀ i : I, f i) := ⟨fun {_ _} h => or_iff_not_imp_left.mpr fun hc => funext fun i => (smul_eq_zero.mp (congr_fun h i)).resolve_left hc⟩ /-- A special case of `Pi.noZeroSMulDivisors` for non-dependent types. Lean struggles to synthesize this instance by itself elsewhere in the library. -/ instance _root_.Function.noZeroSMulDivisors {ι α β : Type*} [Semiring α] [AddCommMonoid β] [Module α β] [NoZeroSMulDivisors α β] : NoZeroSMulDivisors α (ι → β) := Pi.noZeroSMulDivisors _ end Pi
Algebra\Module\PID.lean
/- Copyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Pierre-Alexandre Bazin -/ import Mathlib.Algebra.Module.DedekindDomain import Mathlib.LinearAlgebra.FreeModule.PID import Mathlib.Algebra.Module.Projective import Mathlib.Algebra.Category.ModuleCat.Biproducts import Mathlib.RingTheory.SimpleModule /-! # Structure of finitely generated modules over a PID ## Main statements * `Module.equiv_directSum_of_isTorsion` : A finitely generated torsion module over a PID is isomorphic to a direct sum of some `R ⧸ R ∙ (p i ^ e i)` where the `p i ^ e i` are prime powers. * `Module.equiv_free_prod_directSum` : A finitely generated module over a PID is isomorphic to the product of a free module (its torsion free part) and a direct sum of the form above (its torsion submodule). ## Notation * `R` is a PID and `M` is a (finitely generated for main statements) `R`-module, with additional torsion hypotheses in the intermediate lemmas. * `N` is an `R`-module lying over a higher type universe than `R`. This assumption is needed on the final statement for technical reasons. * `p` is an irreducible element of `R` or a tuple of these. ## Implementation details We first prove (`Submodule.isInternal_prime_power_torsion_of_pid`) that a finitely generated torsion module is the internal direct sum of its `p i ^ e i`-torsion submodules for some (finitely many) prime powers `p i ^ e i`. This is proved in more generality for a Dedekind domain at `Submodule.isInternal_prime_power_torsion`. Then we treat the case of a `p ^ ∞`-torsion module (that is, a module where all elements are cancelled by scalar multiplication by some power of `p`) and apply it to the `p i ^ e i`-torsion submodules (that are `p i ^ ∞`-torsion) to get the result for torsion modules. Then we get the general result using that a torsion free module is free (which has been proved at `Module.free_of_finite_type_torsion_free'` at `LinearAlgebra.FreeModule.PID`.) ## Tags Finitely generated module, principal ideal domain, classification, structure theorem -/ -- We shouldn't need to know about topology to prove -- the structure theorem for finitely generated modules over a PID. assert_not_exists TopologicalSpace universe u v variable {R : Type u} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R] variable {M : Type v} [AddCommGroup M] [Module R M] variable {N : Type max u v} [AddCommGroup N] [Module R N] open scoped DirectSum open Submodule open UniqueFactorizationMonoid theorem Submodule.isSemisimple_torsionBy_of_irreducible {a : R} (h : Irreducible a) : IsSemisimpleModule R (torsionBy R M a) := haveI := PrincipalIdealRing.isMaximal_of_irreducible h letI := Ideal.Quotient.field (R ∙ a) (submodule_torsionBy_orderIso a).complementedLattice /-- A finitely generated torsion module over a PID is an internal direct sum of its `p i ^ e i`-torsion submodules for some primes `p i` and numbers `e i`. -/ theorem Submodule.isInternal_prime_power_torsion_of_pid [DecidableEq (Ideal R)] [Module.Finite R M] (hM : Module.IsTorsion R M) : DirectSum.IsInternal fun p : (factors (⊤ : Submodule R M).annihilator).toFinset => torsionBy R M (IsPrincipal.generator (p : Ideal R) ^ (factors (⊤ : Submodule R M).annihilator).count ↑p) := by convert isInternal_prime_power_torsion hM ext p : 1 rw [← torsionBySet_span_singleton_eq, Ideal.submodule_span_eq, ← Ideal.span_singleton_pow, Ideal.span_singleton_generator] /-- A finitely generated torsion module over a PID is an internal direct sum of its `p i ^ e i`-torsion submodules for some primes `p i` and numbers `e i`. -/ theorem Submodule.exists_isInternal_prime_power_torsion_of_pid [Module.Finite R M] (hM : Module.IsTorsion R M) : ∃ (ι : Type u) (_ : Fintype ι) (_ : DecidableEq ι) (p : ι → R) (_ : ∀ i, Irreducible <| p i) (e : ι → ℕ), DirectSum.IsInternal fun i => torsionBy R M <| p i ^ e i := by classical refine ⟨_, ?_, _, _, ?_, _, Submodule.isInternal_prime_power_torsion_of_pid hM⟩ · exact Finset.fintypeCoeSort _ · rintro ⟨p, hp⟩ have hP := prime_of_factor p (Multiset.mem_toFinset.mp hp) haveI := Ideal.isPrime_of_prime hP exact (IsPrincipal.prime_generator_of_isPrime p hP.ne_zero).irreducible namespace Module section PTorsion variable {p : R} (hp : Irreducible p) (hM : Module.IsTorsion' M (Submonoid.powers p)) variable [dec : ∀ x : M, Decidable (x = 0)] open Ideal Submodule.IsPrincipal theorem _root_.Ideal.torsionOf_eq_span_pow_pOrder (x : M) : torsionOf R M x = span {p ^ pOrder hM x} := by classical dsimp only [pOrder] rw [← (torsionOf R M x).span_singleton_generator, Ideal.span_singleton_eq_span_singleton, ← Associates.mk_eq_mk_iff_associated, Associates.mk_pow] have prop : (fun n : ℕ => p ^ n • x = 0) = fun n : ℕ => (Associates.mk <| generator <| torsionOf R M x) ∣ Associates.mk p ^ n := by ext n; rw [← Associates.mk_pow, Associates.mk_dvd_mk, ← mem_iff_generator_dvd]; rfl have := (isTorsion'_powers_iff p).mp hM x; rw [prop] at this convert Associates.eq_pow_find_of_dvd_irreducible_pow (Associates.irreducible_mk.mpr hp) this.choose_spec theorem p_pow_smul_lift {x y : M} {k : ℕ} (hM' : Module.IsTorsionBy R M (p ^ pOrder hM y)) (h : p ^ k • x ∈ R ∙ y) : ∃ a : R, p ^ k • x = p ^ k • a • y := by -- Porting note: needed to make `smul_smul` work below. letI : MulAction R M := MulActionWithZero.toMulAction by_cases hk : k ≤ pOrder hM y · let f := ((R ∙ p ^ (pOrder hM y - k) * p ^ k).quotEquivOfEq _ ?_).trans (quotTorsionOfEquivSpanSingleton R M y) · have : f.symm ⟨p ^ k • x, h⟩ ∈ R ∙ Ideal.Quotient.mk (R ∙ p ^ (pOrder hM y - k) * p ^ k) (p ^ k) := by rw [← Quotient.torsionBy_eq_span_singleton, mem_torsionBy_iff, ← f.symm.map_smul] · convert f.symm.map_zero; ext rw [coe_smul_of_tower, coe_mk, coe_zero, smul_smul, ← pow_add, Nat.sub_add_cancel hk, @hM' x] · exact mem_nonZeroDivisors_of_ne_zero (pow_ne_zero _ hp.ne_zero) rw [Submodule.mem_span_singleton] at this; obtain ⟨a, ha⟩ := this; use a rw [f.eq_symm_apply, ← Ideal.Quotient.mk_eq_mk, ← Quotient.mk_smul] at ha dsimp only [smul_eq_mul, LinearEquiv.trans_apply, Submodule.quotEquivOfEq_mk, quotTorsionOfEquivSpanSingleton_apply_mk] at ha rw [smul_smul, mul_comm]; exact congr_arg ((↑) : _ → M) ha.symm · symm; convert Ideal.torsionOf_eq_span_pow_pOrder hp hM y rw [← pow_add, Nat.sub_add_cancel hk] · use 0 rw [zero_smul, smul_zero, ← Nat.sub_add_cancel (le_of_not_le hk), pow_add, mul_smul, hM', smul_zero] open Submodule.Quotient theorem exists_smul_eq_zero_and_mk_eq {z : M} (hz : Module.IsTorsionBy R M (p ^ pOrder hM z)) {k : ℕ} (f : (R ⧸ R ∙ p ^ k) →ₗ[R] M ⧸ R ∙ z) : ∃ x : M, p ^ k • x = 0 ∧ Submodule.Quotient.mk (p := span R {z}) x = f 1 := by have f1 := mk_surjective (R ∙ z) (f 1) have : p ^ k • f1.choose ∈ R ∙ z := by rw [← Quotient.mk_eq_zero, mk_smul, f1.choose_spec, ← f.map_smul] convert f.map_zero; change _ • Submodule.Quotient.mk _ = _ rw [← mk_smul, Quotient.mk_eq_zero, Algebra.id.smul_eq_mul, mul_one] exact Submodule.mem_span_singleton_self _ obtain ⟨a, ha⟩ := p_pow_smul_lift hp hM hz this refine ⟨f1.choose - a • z, by rw [smul_sub, sub_eq_zero, ha], ?_⟩ rw [mk_sub, mk_smul, (Quotient.mk_eq_zero _).mpr <| Submodule.mem_span_singleton_self _, smul_zero, sub_zero, f1.choose_spec] open Finset Multiset /-- A finitely generated `p ^ ∞`-torsion module over a PID is isomorphic to a direct sum of some `R ⧸ R ∙ (p ^ e i)` for some `e i`. -/ theorem torsion_by_prime_power_decomposition (hN : Module.IsTorsion' N (Submonoid.powers p)) [h' : Module.Finite R N] : ∃ (d : ℕ) (k : Fin d → ℕ), Nonempty <| N ≃ₗ[R] ⨁ i : Fin d, R ⧸ R ∙ p ^ (k i : ℕ) := by obtain ⟨d, s, hs⟩ := @Module.Finite.exists_fin _ _ _ _ _ h'; use d; clear h' induction' d with d IH generalizing N · -- Porting note: was `use fun i => finZeroElim i` use finZeroElim rw [Set.range_eq_empty, Submodule.span_empty] at hs haveI : Unique N := ⟨⟨0⟩, fun x => by dsimp; rw [← Submodule.mem_bot R, hs]; exact Submodule.mem_top⟩ haveI : IsEmpty (Fin Nat.zero) := inferInstanceAs (IsEmpty (Fin 0)) exact ⟨0⟩ · have : ∀ x : N, Decidable (x = 0) := fun _ => by classical infer_instance obtain ⟨j, hj⟩ := exists_isTorsionBy hN d.succ d.succ_ne_zero s hs let s' : Fin d → N ⧸ R ∙ s j := Submodule.Quotient.mk ∘ s ∘ j.succAbove -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5732): -- `obtain` doesn't work with placeholders. have := IH ?_ s' ?_ · obtain ⟨k, ⟨f⟩⟩ := this clear IH have : ∀ i : Fin d, ∃ x : N, p ^ k i • x = 0 ∧ f (Submodule.Quotient.mk x) = DirectSum.lof R _ _ i 1 := by intro i let fi := f.symm.toLinearMap.comp (DirectSum.lof _ _ _ i) obtain ⟨x, h0, h1⟩ := exists_smul_eq_zero_and_mk_eq hp hN hj fi; refine ⟨x, h0, ?_⟩; rw [h1] simp only [fi, LinearMap.coe_comp, f.symm.coe_toLinearMap, f.apply_symm_apply, Function.comp_apply] refine ⟨?_, ⟨?_⟩⟩ · exact fun a => (fun i => (Option.rec (pOrder hN (s j)) k i : ℕ)) (finSuccEquiv d a) · refine (((lequivProdOfRightSplitExact (g := (f.trans ULift.moduleEquiv.{u, u, v}.symm).toLinearMap.comp <| mkQ _) (f := (DirectSum.toModule _ _ _ fun i => (liftQSpanSingleton (p ^ k i) (LinearMap.toSpanSingleton _ _ _) (this i).choose_spec.left : R ⧸ _ →ₗ[R] _)).comp ULift.moduleEquiv.toLinearMap) (R ∙ s j).injective_subtype ?_ ?_).symm.trans (((quotTorsionOfEquivSpanSingleton R N (s j)).symm.trans (quotEquivOfEq (torsionOf R N (s j)) _ (Ideal.torsionOf_eq_span_pow_pOrder hp hN (s j)))).prod (ULift.moduleEquiv))).trans (@DirectSum.lequivProdDirectSum R _ _ (fun i => R ⧸ R ∙ p ^ @Option.rec _ (fun _ => ℕ) (pOrder hN <| s j) k i) _ _).symm).trans (DirectSum.lequivCongrLeft R (finSuccEquiv d).symm) · rw [range_subtype, LinearEquiv.ker_comp, ker_mkQ] · rw [← f.comp_coe, LinearMap.comp_assoc, LinearMap.comp_assoc, LinearEquiv.toLinearMap_symm_comp_eq, LinearMap.comp_id, ← LinearMap.comp_assoc, ← LinearMap.comp_assoc] suffices (f.toLinearMap.comp (R ∙ s j).mkQ).comp _ = LinearMap.id by rw [this, LinearMap.id_comp] ext i : 3 simp only [LinearMap.coe_comp, Function.comp_apply, mkQ_apply] rw [LinearEquiv.coe_toLinearMap, LinearMap.id_apply, DirectSum.toModule_lof, liftQSpanSingleton_apply, LinearMap.toSpanSingleton_one, Ideal.Quotient.mk_eq_mk, map_one (Ideal.Quotient.mk _), (this i).choose_spec.right] · exact (mk_surjective _).forall.mpr fun x => ⟨(@hN x).choose, by rw [← Quotient.mk_smul, (@hN x).choose_spec, Quotient.mk_zero]⟩ · have hs' := congr_arg (Submodule.map <| mkQ <| R ∙ s j) hs rw [Submodule.map_span, Submodule.map_top, range_mkQ] at hs'; simp only [mkQ_apply] at hs' simp only [s']; rw [← Function.comp.assoc, Set.range_comp (_ ∘ s), Fin.range_succAbove] rw [← Set.range_comp, ← Set.insert_image_compl_eq_range _ j, Function.comp_apply, (Quotient.mk_eq_zero _).mpr (Submodule.mem_span_singleton_self _), span_insert_zero] at hs' exact hs' end PTorsion /-- A finitely generated torsion module over a PID is isomorphic to a direct sum of some `R ⧸ R ∙ (p i ^ e i)` where the `p i ^ e i` are prime powers. -/ theorem equiv_directSum_of_isTorsion [h' : Module.Finite R N] (hN : Module.IsTorsion R N) : ∃ (ι : Type u) (_ : Fintype ι) (p : ι → R) (_ : ∀ i, Irreducible <| p i) (e : ι → ℕ), Nonempty <| N ≃ₗ[R] ⨁ i : ι, R ⧸ R ∙ p i ^ e i := by obtain ⟨I, fI, _, p, hp, e, h⟩ := Submodule.exists_isInternal_prime_power_torsion_of_pid hN haveI := fI have : ∀ i, ∃ (d : ℕ) (k : Fin d → ℕ), Nonempty <| torsionBy R N (p i ^ e i) ≃ₗ[R] ⨁ j, R ⧸ R ∙ p i ^ k j := by haveI := fun i => isNoetherian_submodule' (torsionBy R N <| p i ^ e i) exact fun i => torsion_by_prime_power_decomposition.{u, v} (hp i) ((isTorsion'_powers_iff <| p i).mpr fun x => ⟨e i, smul_torsionBy _ _⟩) classical refine ⟨Σ i, Fin (this i).choose, inferInstance, fun ⟨i, _⟩ => p i, fun ⟨i, _⟩ => hp i, fun ⟨i, j⟩ => (this i).choose_spec.choose j, ⟨(LinearEquiv.ofBijective (DirectSum.coeLinearMap _) h).symm.trans <| (DFinsupp.mapRange.linearEquiv fun i => (this i).choose_spec.choose_spec.some).trans <| (DirectSum.sigmaLcurryEquiv R).symm.trans (DFinsupp.mapRange.linearEquiv fun i => quotEquivOfEq _ _ ?_)⟩⟩ cases' i with i j simp only /-- **Structure theorem of finitely generated modules over a PID** : A finitely generated module over a PID is isomorphic to the product of a free module and a direct sum of some `R ⧸ R ∙ (p i ^ e i)` where the `p i ^ e i` are prime powers. -/ theorem equiv_free_prod_directSum [h' : Module.Finite R N] : ∃ (n : ℕ) (ι : Type u) (_ : Fintype ι) (p : ι → R) (_ : ∀ i, Irreducible <| p i) (e : ι → ℕ), Nonempty <| N ≃ₗ[R] (Fin n →₀ R) × ⨁ i : ι, R ⧸ R ∙ p i ^ e i := by haveI := isNoetherian_submodule' (torsion R N) haveI := Module.Finite.of_surjective _ (torsion R N).mkQ_surjective obtain ⟨I, fI, p, hp, e, ⟨h⟩⟩ := equiv_directSum_of_isTorsion.{u, v} (@torsion_isTorsion R N _ _ _) obtain ⟨n, ⟨g⟩⟩ := @Module.basisOfFiniteTypeTorsionFree' R _ (N ⧸ torsion R N) _ _ _ _ _ _ haveI : Module.Projective R (N ⧸ torsion R N) := Module.Projective.of_basis ⟨g⟩ obtain ⟨f, hf⟩ := Module.projective_lifting_property _ LinearMap.id (torsion R N).mkQ_surjective refine ⟨n, I, fI, p, hp, e, ⟨(lequivProdOfRightSplitExact (torsion R N).injective_subtype ?_ hf).symm.trans <| (h.prod g).trans <| LinearEquiv.prodComm.{u, u} R _ (Fin n →₀ R) ⟩⟩ rw [range_subtype, ker_mkQ] end Module
Algebra\Module\PointwisePi.lean
/- Copyright (c) 2021 Alex J. Best. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alex J. Best -/ import Mathlib.Algebra.Group.Action.Pi import Mathlib.Data.Set.Pointwise.SMul /-! # Pointwise actions on sets in Pi types This file contains lemmas about pointwise actions on sets in Pi types. ## Tags set multiplication, set addition, pointwise addition, pointwise multiplication, pi -/ open Pointwise open Set variable {K ι : Type*} {R : ι → Type*} @[to_additive] theorem smul_pi_subset [∀ i, SMul K (R i)] (r : K) (s : Set ι) (t : ∀ i, Set (R i)) : r • pi s t ⊆ pi s (r • t) := by rintro x ⟨y, h, rfl⟩ i hi exact smul_mem_smul_set (h i hi) -- Porting note: Lean 4 can't synthesize `Set.mem_univ i`? @[to_additive] theorem smul_univ_pi [∀ i, SMul K (R i)] (r : K) (t : ∀ i, Set (R i)) : r • pi (univ : Set ι) t = pi (univ : Set ι) (r • t) := (Subset.antisymm (smul_pi_subset _ _ _)) fun x h ↦ by refine ⟨fun i ↦ Classical.choose (h i <| Set.mem_univ _), fun i _ ↦ ?_, funext fun i ↦ ?_⟩ · exact (Classical.choose_spec (h i <| Set.mem_univ i)).left · exact (Classical.choose_spec (h i <| Set.mem_univ i)).right @[to_additive] theorem smul_pi [Group K] [∀ i, MulAction K (R i)] (r : K) (S : Set ι) (t : ∀ i, Set (R i)) : r • S.pi t = S.pi (r • t) := (Subset.antisymm (smul_pi_subset _ _ _)) fun x h ↦ ⟨r⁻¹ • x, fun i hiS ↦ mem_smul_set_iff_inv_smul_mem.mp (h i hiS), smul_inv_smul _ _⟩ theorem smul_pi₀ [GroupWithZero K] [∀ i, MulAction K (R i)] {r : K} (S : Set ι) (t : ∀ i, Set (R i)) (hr : r ≠ 0) : r • S.pi t = S.pi (r • t) := smul_pi (Units.mk0 r hr) S t
Algebra\Module\Prod.lean
/- Copyright (c) 2018 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon, Patrick Massot, Eric Wieser -/ import Mathlib.Algebra.GroupWithZero.Action.Prod import Mathlib.Algebra.Module.Defs /-! # Prod instances for module and multiplicative actions This file defines instances for binary product of modules -/ variable {R : Type*} {S : Type*} {M : Type*} {N : Type*} namespace Prod instance smulWithZero [Zero R] [Zero M] [Zero N] [SMulWithZero R M] [SMulWithZero R N] : SMulWithZero R (M × N) := { Prod.smul with smul_zero := fun _ => Prod.ext (smul_zero _) (smul_zero _) zero_smul := fun _ => Prod.ext (zero_smul _ _) (zero_smul _ _) } instance mulActionWithZero [MonoidWithZero R] [Zero M] [Zero N] [MulActionWithZero R M] [MulActionWithZero R N] : MulActionWithZero R (M × N) := { Prod.mulAction with smul_zero := fun _ => Prod.ext (smul_zero _) (smul_zero _) zero_smul := fun _ => Prod.ext (zero_smul _ _) (zero_smul _ _) } instance instModule [Semiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N] : Module R (M × N) := { Prod.distribMulAction with add_smul := fun _ _ _ => mk.inj_iff.mpr ⟨add_smul _ _ _, add_smul _ _ _⟩ zero_smul := fun _ => mk.inj_iff.mpr ⟨zero_smul _ _, zero_smul _ _⟩ } instance noZeroSMulDivisors {r : Semiring R} [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N] [NoZeroSMulDivisors R M] [NoZeroSMulDivisors R N] : NoZeroSMulDivisors R (M × N) := { eq_zero_or_eq_zero_of_smul_eq_zero := by -- Porting note: in mathlib3 there is no need for `by`/ -- `intro`/`exact`, i.e. the following works: -- ⟨fun c ⟨x, y⟩ h => -- or_iff_not_imp_left.mpr fun hc => intro c ⟨x, y⟩ h exact or_iff_not_imp_left.mpr fun hc => mk.inj_iff.mpr ⟨(smul_eq_zero.mp (congr_arg fst h)).resolve_left hc, (smul_eq_zero.mp (congr_arg snd h)).resolve_left hc⟩ } end Prod
Algebra\Module\Projective.lean
/- Copyright (c) 2021 Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Buzzard, Antoine Labelle -/ import Mathlib.Algebra.Module.Defs import Mathlib.LinearAlgebra.Finsupp import Mathlib.LinearAlgebra.FreeModule.Basic import Mathlib.LinearAlgebra.TensorProduct.Tower /-! # Projective modules This file contains a definition of a projective module, the proof that our definition is equivalent to a lifting property, and the proof that all free modules are projective. ## Main definitions Let `R` be a ring (or a semiring) and let `M` be an `R`-module. * `Module.Projective R M` : the proposition saying that `M` is a projective `R`-module. ## Main theorems * `Module.projective_lifting_property` : a map from a projective module can be lifted along a surjection. * `Module.Projective.of_lifting_property` : If for all R-module surjections `A →ₗ B`, all maps `M →ₗ B` lift to `M →ₗ A`, then `M` is projective. * `Module.Projective.of_free` : Free modules are projective ## Implementation notes The actual definition of projective we use is that the natural R-module map from the free R-module on the type M down to M splits. This is more convenient than certain other definitions which involve quantifying over universes, and also universe-polymorphic (the ring and module can be in different universes). We require that the module sits in at least as high a universe as the ring: without this, free modules don't even exist, and it's unclear if projective modules are even a useful notion. ## References https://en.wikipedia.org/wiki/Projective_module ## TODO - Direct sum of two projective modules is projective. - Arbitrary sum of projective modules is projective. All of these should be relatively straightforward. ## Tags projective module -/ universe u v open LinearMap hiding id open Finsupp /- The actual implementation we choose: `P` is projective if the natural surjection from the free `R`-module on `P` to `P` splits. -/ /-- An R-module is projective if it is a direct summand of a free module, or equivalently if maps from the module lift along surjections. There are several other equivalent definitions. -/ class Module.Projective (R : Type*) [Semiring R] (P : Type*) [AddCommMonoid P] [Module R P] : Prop where out : ∃ s : P →ₗ[R] P →₀ R, Function.LeftInverse (Finsupp.total P P R id) s namespace Module section Semiring variable {R : Type*} [Semiring R] {P : Type*} [AddCommMonoid P] [Module R P] {M : Type*} [AddCommMonoid M] [Module R M] {N : Type*} [AddCommMonoid N] [Module R N] theorem projective_def : Projective R P ↔ ∃ s : P →ₗ[R] P →₀ R, Function.LeftInverse (Finsupp.total P P R id) s := ⟨fun h => h.1, fun h => ⟨h⟩⟩ theorem projective_def' : Projective R P ↔ ∃ s : P →ₗ[R] P →₀ R, Finsupp.total P P R id ∘ₗ s = .id := by simp_rw [projective_def, DFunLike.ext_iff, Function.LeftInverse, comp_apply, id_apply] /-- A projective R-module has the property that maps from it lift along surjections. -/ theorem projective_lifting_property [h : Projective R P] (f : M →ₗ[R] N) (g : P →ₗ[R] N) (hf : Function.Surjective f) : ∃ h : P →ₗ[R] M, f.comp h = g := by /- Here's the first step of the proof. Recall that `X →₀ R` is Lean's way of talking about the free `R`-module on a type `X`. The universal property `Finsupp.total` says that to a map `X → N` from a type to an `R`-module, we get an associated R-module map `(X →₀ R) →ₗ N`. Apply this to a (noncomputable) map `P → M` coming from the map `P →ₗ N` and a random splitting of the surjection `M →ₗ N`, and we get a map `φ : (P →₀ R) →ₗ M`. -/ let φ : (P →₀ R) →ₗ[R] M := Finsupp.total _ _ _ fun p => Function.surjInv hf (g p) -- By projectivity we have a map `P →ₗ (P →₀ R)`; cases' h.out with s hs -- Compose to get `P →ₗ M`. This works. use φ.comp s ext p conv_rhs => rw [← hs p] simp [φ, Finsupp.total_apply, Function.surjInv_eq hf, map_finsupp_sum] /-- A module which satisfies the universal property is projective: If all surjections of `R`-modules `(P →₀ R) →ₗ[R] P` have `R`-linear left inverse maps, then `P` is projective. -/ theorem Projective.of_lifting_property'' {R : Type u} [Semiring R] {P : Type v} [AddCommMonoid P] [Module R P] (huniv : ∀ (f : (P →₀ R) →ₗ[R] P), Function.Surjective f → ∃ h : P →ₗ[R] (P →₀ R), f.comp h = .id) : Projective R P := projective_def'.2 <| huniv (Finsupp.total P P R (id : P → P)) (total_surjective _ Function.surjective_id) variable {Q : Type*} [AddCommMonoid Q] [Module R Q] instance [Projective R P] [Projective R Q] : Projective R (P × Q) := by refine .of_lifting_property'' fun f hf ↦ ?_ rcases projective_lifting_property f (.inl _ _ _) hf with ⟨g₁, hg₁⟩ rcases projective_lifting_property f (.inr _ _ _) hf with ⟨g₂, hg₂⟩ refine ⟨coprod g₁ g₂, ?_⟩ rw [LinearMap.comp_coprod, hg₁, hg₂, LinearMap.coprod_inl_inr] variable {ι : Type*} (A : ι → Type*) [∀ i : ι, AddCommMonoid (A i)] [∀ i : ι, Module R (A i)] instance [h : ∀ i : ι, Projective R (A i)] : Projective R (Π₀ i, A i) := .of_lifting_property'' fun f hf ↦ by classical choose g hg using fun i ↦ projective_lifting_property f (DFinsupp.lsingle i) hf replace hg : ∀ i x, f (g i x) = DFinsupp.single i x := fun i ↦ DFunLike.congr_fun (hg i) refine ⟨DFinsupp.coprodMap g, ?_⟩ ext i x j simp only [comp_apply, id_apply, DFinsupp.lsingle_apply, DFinsupp.coprodMap_apply_single, hg] end Semiring section Ring variable {R : Type u} [Ring R] {P : Type v} [AddCommGroup P] [Module R P] /-- Free modules are projective. -/ theorem Projective.of_basis {ι : Type*} (b : Basis ι R P) : Projective R P := by -- need P →ₗ (P →₀ R) for definition of projective. -- get it from `ι → (P →₀ R)` coming from `b`. use b.constr ℕ fun i => Finsupp.single (b i) (1 : R) intro m simp only [b.constr_apply, mul_one, id, Finsupp.smul_single', Finsupp.total_single, map_finsupp_sum] exact b.total_repr m instance (priority := 100) Projective.of_free [Module.Free R P] : Module.Projective R P := .of_basis <| Module.Free.chooseBasis R P variable {R₀ M N} [CommRing R₀] [Algebra R₀ R] [AddCommGroup M] [Module R₀ M] [Module R M] variable [IsScalarTower R₀ R M] [AddCommGroup N] [Module R₀ N] theorem Projective.of_split [Module.Projective R M] (i : P →ₗ[R] M) (s : M →ₗ[R] P) (H : s.comp i = LinearMap.id) : Module.Projective R P := by obtain ⟨g, hg⟩ := projective_lifting_property (Finsupp.total P P R id) s (fun x ↦ ⟨Finsupp.single x 1, by simp⟩) refine ⟨g.comp i, fun x ↦ ?_⟩ rw [LinearMap.comp_apply, ← LinearMap.comp_apply, hg, ← LinearMap.comp_apply, H, LinearMap.id_apply] theorem Projective.of_equiv [Module.Projective R M] (e : M ≃ₗ[R] P) : Module.Projective R P := Projective.of_split e.symm e.toLinearMap (by ext; simp) /-- A module is projective iff it is the direct summand of a free module. -/ theorem Projective.iff_split : Module.Projective R P ↔ ∃ (M : Type max u v) (_ : AddCommGroup M) (_ : Module R M) (_ : Module.Free R M) (i : P →ₗ[R] M) (s : M →ₗ[R] P), s.comp i = LinearMap.id := ⟨fun ⟨i, hi⟩ ↦ ⟨P →₀ R, _, _, inferInstance, i, Finsupp.total P P R id, LinearMap.ext hi⟩, fun ⟨_, _, _, _, i, s, H⟩ ↦ Projective.of_split i s H⟩ /-- A quotient of a projective module is projective iff it is a direct summand. -/ theorem Projective.iff_split_of_projective [Module.Projective R M] (s : M →ₗ[R] P) (hs : Function.Surjective s) : Module.Projective R P ↔ ∃ i, s ∘ₗ i = LinearMap.id := ⟨fun _ ↦ projective_lifting_property _ _ hs, fun ⟨i, H⟩ ↦ Projective.of_split i s H⟩ set_option maxSynthPendingDepth 2 in open TensorProduct in instance Projective.tensorProduct [hM : Module.Projective R M] [hN : Module.Projective R₀ N] : Module.Projective R (M ⊗[R₀] N) := by obtain ⟨sM, hsM⟩ := hM obtain ⟨sN, hsN⟩ := hN have : Module.Projective R (M ⊗[R₀] (N →₀ R₀)) := by fapply Projective.of_split (R := R) (M := ((M →₀ R) ⊗[R₀] (N →₀ R₀))) · exact (AlgebraTensorModule.map sM (LinearMap.id (R := R₀) (M := N →₀ R₀))) · exact (AlgebraTensorModule.map (Finsupp.total M M R id) (LinearMap.id (R := R₀) (M := N →₀ R₀))) · ext; simp [hsM _] fapply Projective.of_split (R := R) (M := (M ⊗[R₀] (N →₀ R₀))) · exact (AlgebraTensorModule.map (LinearMap.id (R := R) (M := M)) sN) · exact (AlgebraTensorModule.map (LinearMap.id (R := R) (M := M)) (Finsupp.total N N R₀ id)) · ext; simp [hsN _] end Ring --This is in a different section because special universe restrictions are required. section OfLiftingProperty -- Porting note (#11215): TODO: generalize to `P : Type v`? /-- A module which satisfies the universal property is projective. Note that the universe variables in `huniv` are somewhat restricted. -/ theorem Projective.of_lifting_property' {R : Type u} [Semiring R] {P : Type max u v} [AddCommMonoid P] [Module R P] -- If for all surjections of `R`-modules `M →ₗ N`, all maps `P →ₗ N` lift to `P →ₗ M`, (huniv : ∀ {M : Type max v u} {N : Type max u v} [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N] (f : M →ₗ[R] N) (g : P →ₗ[R] N), Function.Surjective f → ∃ h : P →ₗ[R] M, f.comp h = g) : -- then `P` is projective. Projective R P := .of_lifting_property'' (huniv · _) -- Porting note (#11215): TODO: generalize to `P : Type v`? /-- A variant of `of_lifting_property'` when we're working over a `[Ring R]`, which only requires quantifying over modules with an `AddCommGroup` instance. -/ theorem Projective.of_lifting_property {R : Type u} [Ring R] {P : Type max u v} [AddCommGroup P] [Module R P] -- If for all surjections of `R`-modules `M →ₗ N`, all maps `P →ₗ N` lift to `P →ₗ M`, (huniv : ∀ {M : Type max v u} {N : Type max u v} [AddCommGroup M] [AddCommGroup N] [Module R M] [Module R N] (f : M →ₗ[R] N) (g : P →ₗ[R] N), Function.Surjective f → ∃ h : P →ₗ[R] M, f.comp h = g) : -- then `P` is projective. Projective R P := .of_lifting_property'' (huniv · _) end OfLiftingProperty end Module
Algebra\Module\Rat.lean
/- Copyright (c) 2015 Nathaniel Thomas. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Module.Basic import Mathlib.Algebra.Field.Rat /-! # Basic results about modules over the rationals. -/ universe u v variable {M M₂ : Type*} theorem map_ratCast_smul [AddCommGroup M] [AddCommGroup M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (R S : Type*) [DivisionRing R] [DivisionRing S] [Module R M] [Module S M₂] (c : ℚ) (x : M) : f ((c : R) • x) = (c : S) • f x := by rw [Rat.cast_def, Rat.cast_def, div_eq_mul_inv, div_eq_mul_inv, mul_smul, mul_smul, map_intCast_smul f R S, map_inv_natCast_smul f R S] @[deprecated (since := "2024-04-17")] alias map_rat_cast_smul := map_ratCast_smul theorem map_rat_smul [AddCommGroup M] [AddCommGroup M₂] [_instM : Module ℚ M] [_instM₂ : Module ℚ M₂] {F : Type*} [FunLike F M M₂] [AddMonoidHomClass F M M₂] (f : F) (c : ℚ) (x : M) : f (c • x) = c • f x := map_ratCast_smul f ℚ ℚ c x /-- There can be at most one `Module ℚ E` structure on an additive commutative group. -/ instance subsingleton_rat_module (E : Type*) [AddCommGroup E] : Subsingleton (Module ℚ E) := ⟨fun P Q => (Module.ext' P Q) fun r x => map_rat_smul (_instM := P) (_instM₂ := Q) (AddMonoidHom.id E) r x⟩ /-- If `E` is a vector space over two division rings `R` and `S`, then scalar multiplications agree on rational numbers in `R` and `S`. -/ theorem ratCast_smul_eq {E : Type*} (R S : Type*) [AddCommGroup E] [DivisionRing R] [DivisionRing S] [Module R E] [Module S E] (r : ℚ) (x : E) : (r : R) • x = (r : S) • x := map_ratCast_smul (AddMonoidHom.id E) R S r x @[deprecated (since := "2024-04-17")] alias rat_cast_smul_eq := ratCast_smul_eq instance IsScalarTower.rat {R : Type u} {M : Type v} [Ring R] [AddCommGroup M] [Module R M] [Module ℚ R] [Module ℚ M] : IsScalarTower ℚ R M where smul_assoc r x y := map_rat_smul ((smulAddHom R M).flip y) r x instance SMulCommClass.rat {R : Type u} {M : Type v} [Semiring R] [AddCommGroup M] [Module R M] [Module ℚ M] : SMulCommClass ℚ R M where smul_comm r x y := (map_rat_smul (smulAddHom R M x) r y).symm instance SMulCommClass.rat' {R : Type u} {M : Type v} [Semiring R] [AddCommGroup M] [Module R M] [Module ℚ M] : SMulCommClass R ℚ M := SMulCommClass.symm _ _ _ -- see note [lower instance priority] instance (priority := 100) RatModule.noZeroSMulDivisors [AddCommGroup M] [Module ℚ M] : NoZeroSMulDivisors ℤ M := ⟨fun {k} {x : M} h => by simpa only [← Int.cast_smul_eq_zsmul ℚ k x, smul_eq_zero, Rat.zero_iff_num_zero] using h⟩ -- Porting note: old proof was: --⟨fun {k x} h => by simpa [zsmul_eq_smul_cast ℚ k x] using h⟩
Algebra\Module\Torsion.lean
/- Copyright (c) 2022 Pierre-Alexandre Bazin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Pierre-Alexandre Bazin -/ import Mathlib.Algebra.DirectSum.Module import Mathlib.Algebra.Module.BigOperators import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.GroupTheory.Torsion import Mathlib.RingTheory.Coprime.Ideal import Mathlib.RingTheory.Finiteness import Mathlib.Data.Set.Lattice /-! # Torsion submodules ## Main definitions * `torsionOf R M x` : the torsion ideal of `x`, containing all `a` such that `a • x = 0`. * `Submodule.torsionBy R M a` : the `a`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0`. * `Submodule.torsionBySet R M s` : the submodule containing all elements `x` of `M` such that `a • x = 0` for all `a` in `s`. * `Submodule.torsion' R M S` : the `S`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some `a` in `S`. * `Submodule.torsion R M` : the torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some non-zero-divisor `a` in `R`. * `Module.IsTorsionBy R M a` : the property that defines an `a`-torsion module. Similarly, `IsTorsionBySet`, `IsTorsion'` and `IsTorsion`. * `Module.IsTorsionBySet.module` : Creates an `R ⧸ I`-module from an `R`-module that `IsTorsionBySet R _ I`. ## Main statements * `quot_torsionOf_equiv_span_singleton` : isomorphism between the span of an element of `M` and the quotient by its torsion ideal. * `torsion' R M S` and `torsion R M` are submodules. * `torsionBySet_eq_torsionBySet_span` : torsion by a set is torsion by the ideal generated by it. * `Submodule.torsionBy_is_torsionBy` : the `a`-torsion submodule is an `a`-torsion module. Similar lemmas for `torsion'` and `torsion`. * `Submodule.torsionBy_isInternal` : a `∏ i, p i`-torsion module is the internal direct sum of its `p i`-torsion submodules when the `p i` are pairwise coprime. A more general version with coprime ideals is `Submodule.torsionBySet_is_internal`. * `Submodule.noZeroSMulDivisors_iff_torsion_bot` : a module over a domain has `NoZeroSMulDivisors` (that is, there is no non-zero `a`, `x` such that `a • x = 0`) iff its torsion submodule is trivial. * `Submodule.QuotientTorsion.torsion_eq_bot` : quotienting by the torsion submodule makes the torsion submodule of the new module trivial. If `R` is a domain, we can derive an instance `Submodule.QuotientTorsion.noZeroSMulDivisors : NoZeroSMulDivisors R (M ⧸ torsion R M)`. ## Notation * The notions are defined for a `CommSemiring R` and a `Module R M`. Some additional hypotheses on `R` and `M` are required by some lemmas. * The letters `a`, `b`, ... are used for scalars (in `R`), while `x`, `y`, ... are used for vectors (in `M`). ## Tags Torsion, submodule, module, quotient -/ namespace Ideal section TorsionOf variable (R M : Type*) [Semiring R] [AddCommMonoid M] [Module R M] /-- The torsion ideal of `x`, containing all `a` such that `a • x = 0`. -/ @[simps!] def torsionOf (x : M) : Ideal R := -- Porting note (#11036): broken dot notation on LinearMap.ker Lean4#1910 LinearMap.ker (LinearMap.toSpanSingleton R M x) @[simp] theorem torsionOf_zero : torsionOf R M (0 : M) = ⊤ := by simp [torsionOf] variable {R M} @[simp] theorem mem_torsionOf_iff (x : M) (a : R) : a ∈ torsionOf R M x ↔ a • x = 0 := Iff.rfl variable (R) @[simp] theorem torsionOf_eq_top_iff (m : M) : torsionOf R M m = ⊤ ↔ m = 0 := by refine ⟨fun h => ?_, fun h => by simp [h]⟩ rw [← one_smul R m, ← mem_torsionOf_iff m (1 : R), h] exact Submodule.mem_top @[simp] theorem torsionOf_eq_bot_iff_of_noZeroSMulDivisors [Nontrivial R] [NoZeroSMulDivisors R M] (m : M) : torsionOf R M m = ⊥ ↔ m ≠ 0 := by refine ⟨fun h contra => ?_, fun h => (Submodule.eq_bot_iff _).mpr fun r hr => ?_⟩ · rw [contra, torsionOf_zero] at h exact bot_ne_top.symm h · rw [mem_torsionOf_iff, smul_eq_zero] at hr tauto /-- See also `CompleteLattice.Independent.linearIndependent` which provides the same conclusion but requires the stronger hypothesis `NoZeroSMulDivisors R M`. -/ theorem CompleteLattice.Independent.linear_independent' {ι R M : Type*} {v : ι → M} [Ring R] [AddCommGroup M] [Module R M] (hv : CompleteLattice.Independent fun i => R ∙ v i) (h_ne_zero : ∀ i, Ideal.torsionOf R M (v i) = ⊥) : LinearIndependent R v := by refine linearIndependent_iff_not_smul_mem_span.mpr fun i r hi => ?_ replace hv := CompleteLattice.independent_def.mp hv i simp only [iSup_subtype', ← Submodule.span_range_eq_iSup (ι := Subtype _), disjoint_iff] at hv have : r • v i ∈ (⊥ : Submodule R M) := by rw [← hv, Submodule.mem_inf] refine ⟨Submodule.mem_span_singleton.mpr ⟨r, rfl⟩, ?_⟩ convert hi ext simp rw [← Submodule.mem_bot R, ← h_ne_zero i] simpa using this end TorsionOf section variable (R M : Type*) [Ring R] [AddCommGroup M] [Module R M] /-- The span of `x` in `M` is isomorphic to `R` quotiented by the torsion ideal of `x`. -/ noncomputable def quotTorsionOfEquivSpanSingleton (x : M) : (R ⧸ torsionOf R M x) ≃ₗ[R] R ∙ x := (LinearMap.toSpanSingleton R M x).quotKerEquivRange.trans <| LinearEquiv.ofEq _ _ (LinearMap.span_singleton_eq_range R M x).symm variable {R M} @[simp] theorem quotTorsionOfEquivSpanSingleton_apply_mk (x : M) (a : R) : quotTorsionOfEquivSpanSingleton R M x (Submodule.Quotient.mk a) = a • ⟨x, Submodule.mem_span_singleton_self x⟩ := rfl end end Ideal open nonZeroDivisors section Defs variable (R M : Type*) [CommSemiring R] [AddCommMonoid M] [Module R M] namespace Submodule /-- The `a`-torsion submodule for `a` in `R`, containing all elements `x` of `M` such that `a • x = 0`. -/ @[simps!] def torsionBy (a : R) : Submodule R M := -- Porting note (#11036): broken dot notation on LinearMap.ker Lean4#1910 LinearMap.ker (DistribMulAction.toLinearMap R M a) /-- The submodule containing all elements `x` of `M` such that `a • x = 0` for all `a` in `s`. -/ @[simps!] def torsionBySet (s : Set R) : Submodule R M := sInf (torsionBy R M '' s) -- Porting note: torsion' had metavariables and factoring out this fixed it -- perhaps there is a better fix /-- The additive submonoid of all elements `x` of `M` such that `a • x = 0` for some `a` in `S`. -/ @[simps!] def torsion'AddSubMonoid (S : Type*) [CommMonoid S] [DistribMulAction S M] : AddSubmonoid M where carrier := { x | ∃ a : S, a • x = 0 } add_mem' := by intro x y ⟨a,hx⟩ ⟨b,hy⟩ use b * a rw [smul_add, mul_smul, mul_comm, mul_smul, hx, hy, smul_zero, smul_zero, add_zero] zero_mem' := ⟨1, smul_zero 1⟩ /-- The `S`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some `a` in `S`. -/ @[simps!] def torsion' (S : Type*) [CommMonoid S] [DistribMulAction S M] [SMulCommClass S R M] : Submodule R M := { torsion'AddSubMonoid M S with smul_mem' := fun a x ⟨b, h⟩ => ⟨b, by rw [smul_comm, h, smul_zero]⟩} /-- The torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some non-zero-divisor `a` in `R`. -/ abbrev torsion := torsion' R M R⁰ end Submodule namespace Module /-- An `a`-torsion module is a module where every element is `a`-torsion. -/ abbrev IsTorsionBy (a : R) := ∀ ⦃x : M⦄, a • x = 0 /-- A module where every element is `a`-torsion for all `a` in `s`. -/ abbrev IsTorsionBySet (s : Set R) := ∀ ⦃x : M⦄ ⦃a : s⦄, (a : R) • x = 0 /-- An `S`-torsion module is a module where every element is `a`-torsion for some `a` in `S`. -/ abbrev IsTorsion' (S : Type*) [SMul S M] := ∀ ⦃x : M⦄, ∃ a : S, a • x = 0 /-- A torsion module is a module where every element is `a`-torsion for some non-zero-divisor `a`. -/ abbrev IsTorsion := ∀ ⦃x : M⦄, ∃ a : R⁰, a • x = 0 theorem isTorsionBySet_annihilator : IsTorsionBySet R M (Module.annihilator R M) := fun _ r ↦ Module.mem_annihilator.mp r.2 _ end Module end Defs lemma isSMulRegular_iff_torsionBy_eq_bot {R} (M : Type*) [CommRing R] [AddCommGroup M] [Module R M] (r : R) : IsSMulRegular M r ↔ Submodule.torsionBy R M r = ⊥ := Iff.symm (DistribMulAction.toLinearMap R M r).ker_eq_bot variable {R M : Type*} section variable [CommSemiring R] [AddCommMonoid M] [Module R M] (s : Set R) (a : R) namespace Submodule @[simp] theorem smul_torsionBy (x : torsionBy R M a) : a • x = 0 := Subtype.ext x.prop @[simp] theorem smul_coe_torsionBy (x : torsionBy R M a) : a • (x : M) = 0 := x.prop @[simp] theorem mem_torsionBy_iff (x : M) : x ∈ torsionBy R M a ↔ a • x = 0 := Iff.rfl @[simp] theorem mem_torsionBySet_iff (x : M) : x ∈ torsionBySet R M s ↔ ∀ a : s, (a : R) • x = 0 := by refine ⟨fun h ⟨a, ha⟩ => mem_sInf.mp h _ (Set.mem_image_of_mem _ ha), fun h => mem_sInf.mpr ?_⟩ rintro _ ⟨a, ha, rfl⟩; exact h ⟨a, ha⟩ @[simp] theorem torsionBySet_singleton_eq : torsionBySet R M {a} = torsionBy R M a := by ext x simp only [mem_torsionBySet_iff, SetCoe.forall, Subtype.coe_mk, Set.mem_singleton_iff, forall_eq, mem_torsionBy_iff] theorem torsionBySet_le_torsionBySet_of_subset {s t : Set R} (st : s ⊆ t) : torsionBySet R M t ≤ torsionBySet R M s := sInf_le_sInf fun _ ⟨a, ha, h⟩ => ⟨a, st ha, h⟩ /-- Torsion by a set is torsion by the ideal generated by it. -/ theorem torsionBySet_eq_torsionBySet_span : torsionBySet R M s = torsionBySet R M (Ideal.span s) := by refine le_antisymm (fun x hx => ?_) (torsionBySet_le_torsionBySet_of_subset subset_span) rw [mem_torsionBySet_iff] at hx ⊢ suffices Ideal.span s ≤ Ideal.torsionOf R M x by rintro ⟨a, ha⟩ exact this ha rw [Ideal.span_le] exact fun a ha => hx ⟨a, ha⟩ theorem torsionBySet_span_singleton_eq : torsionBySet R M (R ∙ a) = torsionBy R M a := (torsionBySet_eq_torsionBySet_span _).symm.trans <| torsionBySet_singleton_eq _ theorem torsionBy_le_torsionBy_of_dvd (a b : R) (dvd : a ∣ b) : torsionBy R M a ≤ torsionBy R M b := by rw [← torsionBySet_span_singleton_eq, ← torsionBySet_singleton_eq] apply torsionBySet_le_torsionBySet_of_subset rintro c (rfl : c = b); exact Ideal.mem_span_singleton.mpr dvd @[simp] theorem torsionBy_one : torsionBy R M 1 = ⊥ := eq_bot_iff.mpr fun _ h => by rw [mem_torsionBy_iff, one_smul] at h exact h @[simp] theorem torsionBySet_univ : torsionBySet R M Set.univ = ⊥ := by rw [eq_bot_iff, ← torsionBy_one, ← torsionBySet_singleton_eq] exact torsionBySet_le_torsionBySet_of_subset fun _ _ => trivial end Submodule open Submodule namespace Module @[simp] theorem isTorsionBySet_singleton_iff : IsTorsionBySet R M {a} ↔ IsTorsionBy R M a := by refine ⟨fun h x => @h _ ⟨_, Set.mem_singleton _⟩, fun h x => ?_⟩ rintro ⟨b, rfl : b = a⟩; exact @h _ theorem isTorsionBySet_iff_torsionBySet_eq_top : IsTorsionBySet R M s ↔ Submodule.torsionBySet R M s = ⊤ := ⟨fun h => eq_top_iff.mpr fun _ _ => (mem_torsionBySet_iff _ _).mpr <| @h _, fun h x => by rw [← mem_torsionBySet_iff, h] trivial⟩ /-- An `a`-torsion module is a module whose `a`-torsion submodule is the full space. -/ theorem isTorsionBy_iff_torsionBy_eq_top : IsTorsionBy R M a ↔ torsionBy R M a = ⊤ := by rw [← torsionBySet_singleton_eq, ← isTorsionBySet_singleton_iff, isTorsionBySet_iff_torsionBySet_eq_top] theorem isTorsionBySet_iff_is_torsion_by_span : IsTorsionBySet R M s ↔ IsTorsionBySet R M (Ideal.span s) := by rw [isTorsionBySet_iff_torsionBySet_eq_top, isTorsionBySet_iff_torsionBySet_eq_top, torsionBySet_eq_torsionBySet_span] theorem isTorsionBySet_span_singleton_iff : IsTorsionBySet R M (R ∙ a) ↔ IsTorsionBy R M a := (isTorsionBySet_iff_is_torsion_by_span _).symm.trans <| isTorsionBySet_singleton_iff _ theorem isTorsionBySet_iff_subseteq_ker_lsmul : IsTorsionBySet R M s ↔ s ⊆ LinearMap.ker (LinearMap.lsmul R M) where mp h r hr := LinearMap.mem_ker.mpr <| LinearMap.ext fun x => @h x ⟨r, hr⟩ mpr | h, x, ⟨_, hr⟩ => DFunLike.congr_fun (LinearMap.mem_ker.mp (h hr)) x theorem isTorsionBy_iff_mem_ker_lsmul : IsTorsionBy R M a ↔ a ∈ LinearMap.ker (LinearMap.lsmul R M) := Iff.symm LinearMap.ext_iff end Module namespace Submodule open Module theorem torsionBySet_isTorsionBySet : IsTorsionBySet R (torsionBySet R M s) s := fun ⟨_, hx⟩ a => Subtype.ext <| (mem_torsionBySet_iff _ _).mp hx a /-- The `a`-torsion submodule is an `a`-torsion module. -/ theorem torsionBy_isTorsionBy : IsTorsionBy R (torsionBy R M a) a := smul_torsionBy a @[simp] theorem torsionBy_torsionBy_eq_top : torsionBy R (torsionBy R M a) a = ⊤ := (isTorsionBy_iff_torsionBy_eq_top a).mp <| torsionBy_isTorsionBy a @[simp] theorem torsionBySet_torsionBySet_eq_top : torsionBySet R (torsionBySet R M s) s = ⊤ := (isTorsionBySet_iff_torsionBySet_eq_top s).mp <| torsionBySet_isTorsionBySet s variable (R M) theorem torsion_gc : @GaloisConnection (Submodule R M) (Ideal R)ᵒᵈ _ _ annihilator fun I => torsionBySet R M ↑(OrderDual.ofDual I) := fun _ _ => ⟨fun h x hx => (mem_torsionBySet_iff _ _).mpr fun ⟨_, ha⟩ => mem_annihilator.mp (h ha) x hx, fun h a ha => mem_annihilator.mpr fun _ hx => (mem_torsionBySet_iff _ _).mp (h hx) ⟨a, ha⟩⟩ variable {R M} section Coprime variable {ι : Type*} {p : ι → Ideal R} {S : Finset ι} -- Porting note: mem_iSup_finset_iff_exists_sum now requires DecidableEq ι theorem iSup_torsionBySet_ideal_eq_torsionBySet_iInf (hp : (S : Set ι).Pairwise fun i j => p i ⊔ p j = ⊤) : ⨆ i ∈ S, torsionBySet R M (p i) = torsionBySet R M ↑(⨅ i ∈ S, p i) := by rcases S.eq_empty_or_nonempty with h | h · simp only [h] -- Porting note: converts were not cooperating convert iSup_emptyset (f := fun i => torsionBySet R M (p i)) <;> simp apply le_antisymm · apply iSup_le _ intro i apply iSup_le _ intro is apply torsionBySet_le_torsionBySet_of_subset exact (iInf_le (fun i => ⨅ _ : i ∈ S, p i) i).trans (iInf_le _ is) · intro x hx rw [mem_iSup_finset_iff_exists_sum] obtain ⟨μ, hμ⟩ := (mem_iSup_finset_iff_exists_sum _ _).mp ((Ideal.eq_top_iff_one _).mp <| (Ideal.iSup_iInf_eq_top_iff_pairwise h _).mpr hp) refine ⟨fun i => ⟨(μ i : R) • x, ?_⟩, ?_⟩ · rw [mem_torsionBySet_iff] at hx ⊢ rintro ⟨a, ha⟩ rw [smul_smul] suffices a * μ i ∈ ⨅ i ∈ S, p i from hx ⟨_, this⟩ rw [mem_iInf] intro j rw [mem_iInf] intro hj by_cases ij : j = i · rw [ij] exact Ideal.mul_mem_right _ _ ha · have := coe_mem (μ i) simp only [mem_iInf] at this exact Ideal.mul_mem_left _ _ (this j hj ij) · rw [← Finset.sum_smul, hμ, one_smul] -- Porting note: iSup_torsionBySet_ideal_eq_torsionBySet_iInf now requires DecidableEq ι theorem supIndep_torsionBySet_ideal (hp : (S : Set ι).Pairwise fun i j => p i ⊔ p j = ⊤) : S.SupIndep fun i => torsionBySet R M <| p i := fun T hT i hi hiT => by rw [disjoint_iff, Finset.sup_eq_iSup, iSup_torsionBySet_ideal_eq_torsionBySet_iInf fun i hi j hj ij => hp (hT hi) (hT hj) ij] have := GaloisConnection.u_inf (b₁ := OrderDual.toDual (p i)) (b₂ := OrderDual.toDual (⨅ i ∈ T, p i)) (torsion_gc R M) dsimp at this ⊢ rw [← this, Ideal.sup_iInf_eq_top, top_coe, torsionBySet_univ] intro j hj; apply hp hi (hT hj); rintro rfl; exact hiT hj variable {q : ι → R} theorem iSup_torsionBy_eq_torsionBy_prod (hq : (S : Set ι).Pairwise <| (IsCoprime on q)) : ⨆ i ∈ S, torsionBy R M (q i) = torsionBy R M (∏ i ∈ S, q i) := by rw [← torsionBySet_span_singleton_eq, Ideal.submodule_span_eq, ← Ideal.finset_inf_span_singleton _ _ hq, Finset.inf_eq_iInf, ← iSup_torsionBySet_ideal_eq_torsionBySet_iInf] · congr ext : 1 congr ext : 1 exact (torsionBySet_span_singleton_eq _).symm exact fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime _ _).mpr (hq hi hj ij) theorem supIndep_torsionBy (hq : (S : Set ι).Pairwise <| (IsCoprime on q)) : S.SupIndep fun i => torsionBy R M <| q i := by convert supIndep_torsionBySet_ideal (M := M) fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime (q i) _).mpr <| hq hi hj ij exact (torsionBySet_span_singleton_eq (R := R) (M := M) _).symm end Coprime end Submodule end section NeedsGroup variable [CommRing R] [AddCommGroup M] [Module R M] namespace Submodule variable {ι : Type*} [DecidableEq ι] {S : Finset ι} /-- If the `p i` are pairwise coprime, a `⨅ i, p i`-torsion module is the internal direct sum of its `p i`-torsion submodules. -/ theorem torsionBySet_isInternal {p : ι → Ideal R} (hp : (S : Set ι).Pairwise fun i j => p i ⊔ p j = ⊤) (hM : Module.IsTorsionBySet R M (⨅ i ∈ S, p i : Ideal R)) : DirectSum.IsInternal fun i : S => torsionBySet R M <| p i := DirectSum.isInternal_submodule_of_independent_of_iSup_eq_top (CompleteLattice.independent_iff_supIndep.mpr <| supIndep_torsionBySet_ideal hp) (by apply (iSup_subtype'' ↑S fun i => torsionBySet R M <| p i).trans -- Porting note: times out if we change apply below to <| apply (iSup_torsionBySet_ideal_eq_torsionBySet_iInf hp).trans <| (Module.isTorsionBySet_iff_torsionBySet_eq_top _).mp hM) /-- If the `q i` are pairwise coprime, a `∏ i, q i`-torsion module is the internal direct sum of its `q i`-torsion submodules. -/ theorem torsionBy_isInternal {q : ι → R} (hq : (S : Set ι).Pairwise <| (IsCoprime on q)) (hM : Module.IsTorsionBy R M <| ∏ i ∈ S, q i) : DirectSum.IsInternal fun i : S => torsionBy R M <| q i := by rw [← Module.isTorsionBySet_span_singleton_iff, Ideal.submodule_span_eq, ← Ideal.finset_inf_span_singleton _ _ hq, Finset.inf_eq_iInf] at hM convert torsionBySet_isInternal (fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime (q i) _).mpr <| hq hi hj ij) hM exact (torsionBySet_span_singleton_eq _ (R := R) (M := M)).symm end Submodule namespace Module variable {I : Ideal R} {r : R} /-- can't be an instance because `hM` can't be inferred -/ def IsTorsionBySet.hasSMul (hM : IsTorsionBySet R M I) : SMul (R ⧸ I) M where smul b x := I.liftQ (LinearMap.lsmul R M) ((isTorsionBySet_iff_subseteq_ker_lsmul _).mp hM) b x /-- can't be an instance because `hM` can't be inferred -/ abbrev IsTorsionBy.hasSMul (hM : IsTorsionBy R M r) : SMul (R ⧸ Ideal.span {r}) M := ((isTorsionBySet_span_singleton_iff r).mpr hM).hasSMul @[simp] theorem IsTorsionBySet.mk_smul (hM : IsTorsionBySet R M I) (b : R) (x : M) : haveI := hM.hasSMul Ideal.Quotient.mk I b • x = b • x := rfl @[simp] theorem IsTorsionBy.mk_smul (hM : IsTorsionBy R M r) (b : R) (x : M) : haveI := hM.hasSMul Ideal.Quotient.mk (Ideal.span {r}) b • x = b • x := rfl /-- An `(R ⧸ I)`-module is an `R`-module which `IsTorsionBySet R M I`. -/ def IsTorsionBySet.module (hM : IsTorsionBySet R M I) : Module (R ⧸ I) M := letI := hM.hasSMul; I.mkQ_surjective.moduleLeft _ (IsTorsionBySet.mk_smul hM) instance IsTorsionBySet.isScalarTower (hM : IsTorsionBySet R M I) {S : Type*} [SMul S R] [SMul S M] [IsScalarTower S R M] [IsScalarTower S R R] : @IsScalarTower S (R ⧸ I) M _ (IsTorsionBySet.module hM).toSMul _ := -- Porting note: still needed to be fed the Module R / I M instance @IsScalarTower.mk S (R ⧸ I) M _ (IsTorsionBySet.module hM).toSMul _ (fun b d x => Quotient.inductionOn' d fun c => (smul_assoc b c x : _)) /-- An `(R ⧸ Ideal.span {r})`-module is an `R`-module for which `IsTorsionBy R M r`. -/ abbrev IsTorsionBy.module (hM : IsTorsionBy R M r) : Module (R ⧸ Ideal.span {r}) M := ((isTorsionBySet_span_singleton_iff r).mpr hM).module /-- Any module is also a module over the quotient of the ring by the annihilator. Not an instance because it causes synthesis failures / timeouts. -/ def quotientAnnihilator : Module (R ⧸ Module.annihilator R M) M := (isTorsionBySet_annihilator R M).module theorem isTorsionBy_quotient_iff (N : Submodule R M) (r : R) : IsTorsionBy R (M⧸N) r ↔ ∀ x, r • x ∈ N := Iff.trans N.mkQ_surjective.forall <| forall_congr' fun _ => Submodule.Quotient.mk_eq_zero N theorem IsTorsionBy.quotient (N : Submodule R M) {r : R} (h : IsTorsionBy R M r) : IsTorsionBy R (M⧸N) r := (isTorsionBy_quotient_iff N r).mpr fun x => @h x ▸ N.zero_mem theorem isTorsionBySet_quotient_iff (N : Submodule R M) (s : Set R) : IsTorsionBySet R (M⧸N) s ↔ ∀ x, ∀ r ∈ s, r • x ∈ N := Iff.trans N.mkQ_surjective.forall <| forall_congr' fun _ => Iff.trans Subtype.forall <| forall₂_congr fun _ _ => Submodule.Quotient.mk_eq_zero N theorem IsTorsionBySet.quotient (N : Submodule R M) {s} (h : IsTorsionBySet R M s) : IsTorsionBySet R (M⧸N) s := (isTorsionBySet_quotient_iff N s).mpr fun x r h' => @h x ⟨r, h'⟩ ▸ N.zero_mem variable (M I) (s : Set R) (r : R) open Pointwise Submodule lemma isTorsionBySet_quotient_set_smul : IsTorsionBySet R (M⧸s • (⊤ : Submodule R M)) s := (isTorsionBySet_quotient_iff _ _).mpr fun _ _ h => mem_set_smul_of_mem_mem h mem_top lemma isTorsionBy_quotient_element_smul : IsTorsionBy R (M⧸r • (⊤ : Submodule R M)) r := (isTorsionBy_quotient_iff _ _).mpr (smul_mem_pointwise_smul · r ⊤ ⟨⟩) lemma isTorsionBySet_quotient_ideal_smul : IsTorsionBySet R (M⧸I • (⊤ : Submodule R M)) I := (isTorsionBySet_quotient_iff _ _).mpr fun _ _ h => smul_mem_smul h ⟨⟩ instance : Module (R ⧸ Ideal.span s) (M ⧸ s • (⊤ : Submodule R M)) := ((isTorsionBySet_iff_is_torsion_by_span s).mp (isTorsionBySet_quotient_set_smul M s)).module instance : Module (R ⧸ I) (M ⧸ I • (⊤ : Submodule R M)) := (isTorsionBySet_quotient_ideal_smul M I).module instance : Module (R ⧸ Ideal.span {r}) (M ⧸ r • (⊤ : Submodule R M)) := (isTorsionBy_quotient_element_smul M r).module lemma Quotient.mk_smul_mk (r : R) (m : M) : Ideal.Quotient.mk I r • Submodule.Quotient.mk (p := (I • ⊤ : Submodule R M)) m = Submodule.Quotient.mk (p := (I • ⊤ : Submodule R M)) (r • m) := rfl end Module namespace Submodule instance (I : Ideal R) : Module (R ⧸ I) (torsionBySet R M I) := -- Porting note: times out without the (R := R) Module.IsTorsionBySet.module <| torsionBySet_isTorsionBySet (R := R) I @[simp] theorem torsionBySet.mk_smul (I : Ideal R) (b : R) (x : torsionBySet R M I) : Ideal.Quotient.mk I b • x = b • x := rfl instance (I : Ideal R) {S : Type*} [SMul S R] [SMul S M] [IsScalarTower S R M] [IsScalarTower S R R] : IsScalarTower S (R ⧸ I) (torsionBySet R M I) := inferInstance /-- The `a`-torsion submodule as an `(R ⧸ R∙a)`-module. -/ instance instModuleQuotientTorsionBy (a : R) : Module (R ⧸ R ∙ a) (torsionBy R M a) := Module.IsTorsionBySet.module <| (Module.isTorsionBySet_span_singleton_iff a).mpr <| torsionBy_isTorsionBy a -- Porting note: added for torsionBy.mk_ideal_smul instance (a : R) : Module (R ⧸ Ideal.span {a}) (torsionBy R M a) := inferInstanceAs <| Module (R ⧸ R ∙ a) (torsionBy R M a) -- Porting note: added because torsionBy.mk_smul simplifies @[simp] theorem torsionBy.mk_ideal_smul (a b : R) (x : torsionBy R M a) : (Ideal.Quotient.mk (Ideal.span {a})) b • x = b • x := rfl theorem torsionBy.mk_smul (a b : R) (x : torsionBy R M a) : Ideal.Quotient.mk (R ∙ a) b • x = b • x := rfl instance (a : R) {S : Type*} [SMul S R] [SMul S M] [IsScalarTower S R M] [IsScalarTower S R R] : IsScalarTower S (R ⧸ R ∙ a) (torsionBy R M a) := inferInstance /-- Given an `R`-module `M` and an element `a` in `R`, submodules of the `a`-torsion submodule of `M` do not depend on whether we take scalars to be `R` or `R ⧸ R ∙ a`. -/ def submodule_torsionBy_orderIso (a : R) : Submodule (R ⧸ R ∙ a) (torsionBy R M a) ≃o Submodule R (torsionBy R M a) := { restrictScalarsEmbedding R (R ⧸ R ∙ a) (torsionBy R M a) with invFun := fun p ↦ { carrier := p add_mem' := add_mem zero_mem' := p.zero_mem smul_mem' := by rintro ⟨b⟩; exact p.smul_mem b } left_inv := by intro; ext; simp [restrictScalarsEmbedding] right_inv := by intro; ext; simp [restrictScalarsEmbedding] } end Submodule end NeedsGroup namespace Submodule section Torsion' open Module variable [CommSemiring R] [AddCommMonoid M] [Module R M] variable (S : Type*) [CommMonoid S] [DistribMulAction S M] [SMulCommClass S R M] @[simp] theorem mem_torsion'_iff (x : M) : x ∈ torsion' R M S ↔ ∃ a : S, a • x = 0 := Iff.rfl -- @[simp] Porting note (#10618): simp can prove this theorem mem_torsion_iff (x : M) : x ∈ torsion R M ↔ ∃ a : R⁰, a • x = 0 := Iff.rfl @[simps] instance : SMul S (torsion' R M S) := ⟨fun s x => ⟨s • (x : M), by obtain ⟨x, a, h⟩ := x use a dsimp rw [smul_comm, h, smul_zero]⟩⟩ instance : DistribMulAction S (torsion' R M S) := Subtype.coe_injective.distribMulAction (torsion' R M S).subtype.toAddMonoidHom fun (_ : S) _ => rfl instance : SMulCommClass S R (torsion' R M S) := ⟨fun _ _ _ => Subtype.ext <| smul_comm _ _ _⟩ /-- An `S`-torsion module is a module whose `S`-torsion submodule is the full space. -/ theorem isTorsion'_iff_torsion'_eq_top : IsTorsion' M S ↔ torsion' R M S = ⊤ := ⟨fun h => eq_top_iff.mpr fun _ _ => @h _, fun h x => by rw [← @mem_torsion'_iff R, h] trivial⟩ /-- The `S`-torsion submodule is an `S`-torsion module. -/ theorem torsion'_isTorsion' : IsTorsion' (torsion' R M S) S := fun ⟨_, ⟨a, h⟩⟩ => ⟨a, Subtype.ext h⟩ @[simp] theorem torsion'_torsion'_eq_top : torsion' R (torsion' R M S) S = ⊤ := (isTorsion'_iff_torsion'_eq_top S).mp <| torsion'_isTorsion' S /-- The torsion submodule of the torsion submodule (viewed as a module) is the full torsion module. -/ -- @[simp] Porting note (#10618): simp can prove this theorem torsion_torsion_eq_top : torsion R (torsion R M) = ⊤ := torsion'_torsion'_eq_top R⁰ /-- The torsion submodule is always a torsion module. -/ theorem torsion_isTorsion : Module.IsTorsion R (torsion R M) := torsion'_isTorsion' R⁰ end Torsion' section Torsion variable [CommSemiring R] [AddCommMonoid M] [Module R M] variable (R M) theorem _root_.Module.isTorsionBySet_annihilator_top : Module.IsTorsionBySet R M (⊤ : Submodule R M).annihilator := fun x ha => mem_annihilator.mp ha.prop x mem_top variable {R M} theorem _root_.Submodule.annihilator_top_inter_nonZeroDivisors [Module.Finite R M] (hM : Module.IsTorsion R M) : ((⊤ : Submodule R M).annihilator : Set R) ∩ R⁰ ≠ ∅ := by obtain ⟨S, hS⟩ := ‹Module.Finite R M›.out refine Set.Nonempty.ne_empty ⟨_, ?_, (∏ x ∈ S, (@hM x).choose : R⁰).prop⟩ rw [Submonoid.coe_finset_prod, SetLike.mem_coe, ← hS, mem_annihilator_span] intro n letI := Classical.decEq M rw [← Finset.prod_erase_mul _ _ n.prop, mul_smul, ← Submonoid.smul_def, (@hM n).choose_spec, smul_zero] variable [NoZeroDivisors R] [Nontrivial R] theorem coe_torsion_eq_annihilator_ne_bot : (torsion R M : Set M) = { x : M | (R ∙ x).annihilator ≠ ⊥ } := by ext x; simp_rw [Submodule.ne_bot_iff, mem_annihilator, mem_span_singleton] exact ⟨fun ⟨a, hax⟩ => ⟨a, fun _ ⟨b, hb⟩ => by rw [← hb, smul_comm, ← Submonoid.smul_def, hax, smul_zero], nonZeroDivisors.coe_ne_zero _⟩, fun ⟨a, hax, ha⟩ => ⟨⟨_, mem_nonZeroDivisors_of_ne_zero ha⟩, hax x ⟨1, one_smul _ _⟩⟩⟩ /-- A module over a domain has `NoZeroSMulDivisors` iff its torsion submodule is trivial. -/ theorem noZeroSMulDivisors_iff_torsion_eq_bot : NoZeroSMulDivisors R M ↔ torsion R M = ⊥ := by constructor <;> intro h · haveI : NoZeroSMulDivisors R M := h rw [eq_bot_iff] rintro x ⟨a, hax⟩ change (a : R) • x = 0 at hax cases' eq_zero_or_eq_zero_of_smul_eq_zero hax with h0 h0 · exfalso exact nonZeroDivisors.coe_ne_zero a h0 · exact h0 · exact { eq_zero_or_eq_zero_of_smul_eq_zero := fun {a} {x} hax => by by_cases ha : a = 0 · left exact ha · right rw [← mem_bot R, ← h] exact ⟨⟨a, mem_nonZeroDivisors_of_ne_zero ha⟩, hax⟩ } lemma torsion_int {G} [AddCommGroup G] : (torsion ℤ G).toAddSubgroup = AddCommGroup.torsion G := by ext x refine ((isOfFinAddOrder_iff_zsmul_eq_zero (x := x)).trans ?_).symm simp [mem_nonZeroDivisors_iff_ne_zero] end Torsion namespace QuotientTorsion variable [CommRing R] [AddCommGroup M] [Module R M] /-- Quotienting by the torsion submodule gives a torsion-free module. -/ @[simp] theorem torsion_eq_bot : torsion R (M ⧸ torsion R M) = ⊥ := eq_bot_iff.mpr fun z => Quotient.inductionOn' z fun x ⟨a, hax⟩ => by rw [Quotient.mk''_eq_mk, ← Quotient.mk_smul, Quotient.mk_eq_zero] at hax rw [mem_bot, Quotient.mk''_eq_mk, Quotient.mk_eq_zero] cases' hax with b h exact ⟨b * a, (mul_smul _ _ _).trans h⟩ instance noZeroSMulDivisors [IsDomain R] : NoZeroSMulDivisors R (M ⧸ torsion R M) := noZeroSMulDivisors_iff_torsion_eq_bot.mpr torsion_eq_bot end QuotientTorsion section PTorsion open Module section variable [Monoid R] [AddCommMonoid M] [DistribMulAction R M] theorem isTorsion'_powers_iff (p : R) : IsTorsion' M (Submonoid.powers p) ↔ ∀ x : M, ∃ n : ℕ, p ^ n • x = 0 := by -- Porting note: previous term proof was having trouble elaborating constructor · intro h x let ⟨⟨a, ⟨n, hn⟩⟩, hx⟩ := @h x dsimp at hn use n rw [hn] apply hx · intro h x let ⟨n, hn⟩ := h x exact ⟨⟨_, ⟨n, rfl⟩⟩, hn⟩ /-- In a `p ^ ∞`-torsion module (that is, a module where all elements are cancelled by scalar multiplication by some power of `p`), the smallest `n` such that `p ^ n • x = 0`. -/ def pOrder {p : R} (hM : IsTorsion' M <| Submonoid.powers p) (x : M) [∀ n : ℕ, Decidable (p ^ n • x = 0)] := Nat.find <| (isTorsion'_powers_iff p).mp hM x @[simp] theorem pow_pOrder_smul {p : R} (hM : IsTorsion' M <| Submonoid.powers p) (x : M) [∀ n : ℕ, Decidable (p ^ n • x = 0)] : p ^ pOrder hM x • x = 0 := Nat.find_spec <| (isTorsion'_powers_iff p).mp hM x end variable [CommSemiring R] [AddCommMonoid M] [Module R M] [∀ x : M, Decidable (x = 0)] theorem exists_isTorsionBy {p : R} (hM : IsTorsion' M <| Submonoid.powers p) (d : ℕ) (hd : d ≠ 0) (s : Fin d → M) (hs : span R (Set.range s) = ⊤) : ∃ j : Fin d, Module.IsTorsionBy R M (p ^ pOrder hM (s j)) := by let oj := List.argmax (fun i => pOrder hM <| s i) (List.finRange d) have hoj : oj.isSome := Option.ne_none_iff_isSome.mp fun eq_none => hd <| List.finRange_eq_nil.mp <| List.argmax_eq_none.mp eq_none use Option.get _ hoj rw [isTorsionBy_iff_torsionBy_eq_top, eq_top_iff, ← hs, Submodule.span_le, Set.range_subset_iff] intro i; change (p ^ pOrder hM (s (Option.get oj hoj))) • s i = 0 have : pOrder hM (s i) ≤ pOrder hM (s <| Option.get _ hoj) := List.le_of_mem_argmax (List.mem_finRange i) (Option.get_mem hoj) rw [← Nat.sub_add_cancel this, pow_add, mul_smul, pow_pOrder_smul, smul_zero] end PTorsion end Submodule namespace Ideal.Quotient open Submodule universe w theorem torsionBy_eq_span_singleton {R : Type w} [CommRing R] (a b : R) (ha : a ∈ R⁰) : torsionBy R (R ⧸ R ∙ a * b) a = R ∙ mk (R ∙ a * b) b := by ext x; rw [mem_torsionBy_iff, Submodule.mem_span_singleton] obtain ⟨x, rfl⟩ := mk_surjective x; constructor <;> intro h · rw [← mk_eq_mk, ← Quotient.mk_smul, Quotient.mk_eq_zero, Submodule.mem_span_singleton] at h obtain ⟨c, h⟩ := h rw [smul_eq_mul, smul_eq_mul, mul_comm, mul_assoc, mul_cancel_left_mem_nonZeroDivisors ha, mul_comm] at h use c rw [← h, ← mk_eq_mk, ← Quotient.mk_smul, smul_eq_mul, mk_eq_mk] · obtain ⟨c, h⟩ := h rw [← h, smul_comm, ← mk_eq_mk, ← Quotient.mk_smul, (Quotient.mk_eq_zero _).mpr <| mem_span_singleton_self _, smul_zero] end Ideal.Quotient namespace AddMonoid theorem isTorsion_iff_isTorsion_nat [AddCommMonoid M] : AddMonoid.IsTorsion M ↔ Module.IsTorsion ℕ M := by refine ⟨fun h x => ?_, fun h x => ?_⟩ · obtain ⟨n, h0, hn⟩ := (h x).exists_nsmul_eq_zero exact ⟨⟨n, mem_nonZeroDivisors_of_ne_zero <| ne_of_gt h0⟩, hn⟩ · rw [isOfFinAddOrder_iff_nsmul_eq_zero] obtain ⟨n, hn⟩ := @h x exact ⟨n, Nat.pos_of_ne_zero (nonZeroDivisors.coe_ne_zero _), hn⟩ theorem isTorsion_iff_isTorsion_int [AddCommGroup M] : AddMonoid.IsTorsion M ↔ Module.IsTorsion ℤ M := by refine ⟨fun h x => ?_, fun h x => ?_⟩ · obtain ⟨n, h0, hn⟩ := (h x).exists_nsmul_eq_zero exact ⟨⟨n, mem_nonZeroDivisors_of_ne_zero <| ne_of_gt <| Int.natCast_pos.mpr h0⟩, (natCast_zsmul _ _).trans hn⟩ · rw [isOfFinAddOrder_iff_nsmul_eq_zero] obtain ⟨n, hn⟩ := @h x exact ⟨_, Int.natAbs_pos.2 (nonZeroDivisors.coe_ne_zero n), natAbs_nsmul_eq_zero.2 hn⟩ end AddMonoid
Algebra\Module\ULift.lean
/- Copyright (c) 2020 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.Algebra.GroupWithZero.ULift import Mathlib.Algebra.Ring.ULift import Mathlib.Algebra.Module.Equiv.Defs import Mathlib.Data.ULift /-! # `ULift` instances for module and multiplicative actions This file defines instances for module, mul_action and related structures on `ULift` types. (Recall `ULift α` is just a "copy" of a type `α` in a higher universe.) We also provide `ULift.moduleEquiv : ULift M ≃ₗ[R] M`. -/ namespace ULift universe u v w variable {R : Type u} {M : Type v} {N : Type w} @[to_additive] instance smulLeft [SMul R M] : SMul (ULift R) M := ⟨fun s x => s.down • x⟩ @[to_additive (attr := simp)] theorem smul_def [SMul R M] (s : ULift R) (x : M) : s • x = s.down • x := rfl instance isScalarTower [SMul R M] [SMul M N] [SMul R N] [IsScalarTower R M N] : IsScalarTower (ULift R) M N := ⟨fun x y z => show (x.down • y) • z = x.down • y • z from smul_assoc _ _ _⟩ instance isScalarTower' [SMul R M] [SMul M N] [SMul R N] [IsScalarTower R M N] : IsScalarTower R (ULift M) N := ⟨fun x y z => show (x • y.down) • z = x • y.down • z from smul_assoc _ _ _⟩ instance isScalarTower'' [SMul R M] [SMul M N] [SMul R N] [IsScalarTower R M N] : IsScalarTower R M (ULift N) := ⟨fun x y z => show up ((x • y) • z.down) = ⟨x • y • z.down⟩ by rw [smul_assoc]⟩ instance [SMul R M] [SMul Rᵐᵒᵖ M] [IsCentralScalar R M] : IsCentralScalar R (ULift M) := ⟨fun r m => congr_arg up <| op_smul_eq_smul r m.down⟩ -- Porting note (#11215): TODO this takes way longer to elaborate than it should @[to_additive] instance mulAction [Monoid R] [MulAction R M] : MulAction (ULift R) M where smul := (· • ·) mul_smul _ _ := mul_smul _ _ one_smul := one_smul _ @[to_additive] instance mulAction' [Monoid R] [MulAction R M] : MulAction R (ULift M) where smul := (· • ·) mul_smul := fun _ _ _ => congr_arg ULift.up <| mul_smul _ _ _ one_smul := fun _ => congr_arg ULift.up <| one_smul _ _ instance smulZeroClass [Zero M] [SMulZeroClass R M] : SMulZeroClass (ULift R) M := { ULift.smulLeft with smul_zero := fun _ => smul_zero _ } instance smulZeroClass' [Zero M] [SMulZeroClass R M] : SMulZeroClass R (ULift M) where smul_zero c := by { ext; simp [smul_zero] } instance distribSMul [AddZeroClass M] [DistribSMul R M] : DistribSMul (ULift R) M where smul_add _ := smul_add _ instance distribSMul' [AddZeroClass M] [DistribSMul R M] : DistribSMul R (ULift M) where smul_add c f g := by ext simp [smul_add] instance distribMulAction [Monoid R] [AddMonoid M] [DistribMulAction R M] : DistribMulAction (ULift R) M := { ULift.mulAction, ULift.distribSMul with } instance distribMulAction' [Monoid R] [AddMonoid M] [DistribMulAction R M] : DistribMulAction R (ULift M) := { ULift.mulAction', ULift.distribSMul' with } instance mulDistribMulAction [Monoid R] [Monoid M] [MulDistribMulAction R M] : MulDistribMulAction (ULift R) M where smul_one _ := smul_one _ smul_mul _ := smul_mul' _ instance mulDistribMulAction' [Monoid R] [Monoid M] [MulDistribMulAction R M] : MulDistribMulAction R (ULift M) := { ULift.mulAction' with smul_one := fun _ => by ext simp [smul_one] smul_mul := fun _ _ _ => by ext simp [smul_mul'] } instance smulWithZero [Zero R] [Zero M] [SMulWithZero R M] : SMulWithZero (ULift R) M := { ULift.smulLeft with smul_zero := fun _ => smul_zero _ zero_smul := zero_smul _ } instance smulWithZero' [Zero R] [Zero M] [SMulWithZero R M] : SMulWithZero R (ULift M) where smul_zero _ := ULift.ext _ _ <| smul_zero _ zero_smul _ := ULift.ext _ _ <| zero_smul _ _ instance mulActionWithZero [MonoidWithZero R] [Zero M] [MulActionWithZero R M] : MulActionWithZero (ULift R) M := { ULift.smulWithZero with -- Porting note (#11215): TODO there seems to be a mismatch in whether -- the carrier is explicit here one_smul := one_smul _ mul_smul := mul_smul } instance mulActionWithZero' [MonoidWithZero R] [Zero M] [MulActionWithZero R M] : MulActionWithZero R (ULift M) := { ULift.smulWithZero' with one_smul := one_smul _ mul_smul := mul_smul } instance module [Semiring R] [AddCommMonoid M] [Module R M] : Module (ULift R) M := { ULift.smulWithZero with add_smul := fun _ _ => add_smul _ _ smul_add := smul_add one_smul := one_smul _ mul_smul := mul_smul } instance module' [Semiring R] [AddCommMonoid M] [Module R M] : Module R (ULift M) := { ULift.smulWithZero' with add_smul := fun _ _ _ => ULift.ext _ _ <| add_smul _ _ _ one_smul := one_smul _ mul_smul := mul_smul smul_add := smul_add } /-- The `R`-linear equivalence between `ULift M` and `M`. This is a linear version of `AddEquiv.ulift`. -/ @[simps apply symm_apply] def moduleEquiv [Semiring R] [AddCommMonoid M] [Module R M] : ULift.{w} M ≃ₗ[R] M where toFun := ULift.down invFun := ULift.up map_smul' _ _ := rfl __ := AddEquiv.ulift end ULift
Algebra\Module\Equiv\Basic.lean
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.Equiv.Defs import Mathlib.Algebra.Field.Defs import Mathlib.Algebra.Module.Hom import Mathlib.Algebra.Module.LinearMap.End import Mathlib.Algebra.Module.Pi import Mathlib.GroupTheory.GroupAction.Group /-! # Further results on (semi)linear equivalences. -/ open Function universe u u' v w x y z variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {k : Type*} {K : Type*} {S : Type*} {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} variable {N₁ : Type*} {N₂ : Type*} {N₃ : Type*} {N₄ : Type*} {ι : Type*} section AddCommMonoid namespace LinearEquiv variable [Semiring R] [Semiring S] [Semiring R₂] [AddCommMonoid M] [AddCommMonoid M₂] section RestrictScalars variable (R) variable [Module R M] [Module R M₂] [Module S M] [Module S M₂] [LinearMap.CompatibleSMul M M₂ R S] /-- If `M` and `M₂` are both `R`-semimodules and `S`-semimodules and `R`-semimodule structures are defined by an action of `R` on `S` (formally, we have two scalar towers), then any `S`-linear equivalence from `M` to `M₂` is also an `R`-linear equivalence. See also `LinearMap.restrictScalars`. -/ @[simps] def restrictScalars (f : M ≃ₗ[S] M₂) : M ≃ₗ[R] M₂ := { f.toLinearMap.restrictScalars R with toFun := f invFun := f.symm left_inv := f.left_inv right_inv := f.right_inv } theorem restrictScalars_injective : Function.Injective (restrictScalars R : (M ≃ₗ[S] M₂) → M ≃ₗ[R] M₂) := fun _ _ h ↦ ext (LinearEquiv.congr_fun h : _) @[simp] theorem restrictScalars_inj (f g : M ≃ₗ[S] M₂) : f.restrictScalars R = g.restrictScalars R ↔ f = g := (restrictScalars_injective R).eq_iff end RestrictScalars theorem _root_.Module.End_isUnit_iff [Module R M] (f : Module.End R M) : IsUnit f ↔ Function.Bijective f := ⟨fun h ↦ Function.bijective_iff_has_inverse.mpr <| ⟨h.unit.inv, ⟨Module.End_isUnit_inv_apply_apply_of_isUnit h, Module.End_isUnit_apply_inv_apply_of_isUnit h⟩⟩, fun H ↦ let e : M ≃ₗ[R] M := { f, Equiv.ofBijective f H with } ⟨⟨_, e.symm, LinearMap.ext e.right_inv, LinearMap.ext e.left_inv⟩, rfl⟩⟩ section Automorphisms variable [Module R M] instance automorphismGroup : Group (M ≃ₗ[R] M) where mul f g := g.trans f one := LinearEquiv.refl R M inv f := f.symm mul_assoc f g h := rfl mul_one f := ext fun x ↦ rfl one_mul f := ext fun x ↦ rfl mul_left_inv f := ext <| f.left_inv @[simp] lemma coe_one : ↑(1 : M ≃ₗ[R] M) = id := rfl @[simp] lemma coe_toLinearMap_one : (↑(1 : M ≃ₗ[R] M) : M →ₗ[R] M) = LinearMap.id := rfl @[simp] lemma coe_toLinearMap_mul {e₁ e₂ : M ≃ₗ[R] M} : (↑(e₁ * e₂) : M →ₗ[R] M) = (e₁ : M →ₗ[R] M) * (e₂ : M →ₗ[R] M) := rfl theorem coe_pow (e : M ≃ₗ[R] M) (n : ℕ) : ⇑(e ^ n) = e^[n] := hom_coe_pow _ rfl (fun _ _ ↦ rfl) _ _ theorem pow_apply (e : M ≃ₗ[R] M) (n : ℕ) (m : M) : (e ^ n) m = e^[n] m := congr_fun (coe_pow e n) m /-- Restriction from `R`-linear automorphisms of `M` to `R`-linear endomorphisms of `M`, promoted to a monoid hom. -/ @[simps] def automorphismGroup.toLinearMapMonoidHom : (M ≃ₗ[R] M) →* M →ₗ[R] M where toFun e := e.toLinearMap map_one' := rfl map_mul' _ _ := rfl /-- The tautological action by `M ≃ₗ[R] M` on `M`. This generalizes `Function.End.applyMulAction`. -/ instance applyDistribMulAction : DistribMulAction (M ≃ₗ[R] M) M where smul := (· <| ·) smul_zero := LinearEquiv.map_zero smul_add := LinearEquiv.map_add one_smul _ := rfl mul_smul _ _ _ := rfl @[simp] protected theorem smul_def (f : M ≃ₗ[R] M) (a : M) : f • a = f a := rfl /-- `LinearEquiv.applyDistribMulAction` is faithful. -/ instance apply_faithfulSMul : FaithfulSMul (M ≃ₗ[R] M) M := ⟨@fun _ _ ↦ LinearEquiv.ext⟩ instance apply_smulCommClass [SMul S R] [SMul S M] [IsScalarTower S R M] : SMulCommClass S (M ≃ₗ[R] M) M where smul_comm r e m := (e.map_smul_of_tower r m).symm instance apply_smulCommClass' [SMul S R] [SMul S M] [IsScalarTower S R M] : SMulCommClass (M ≃ₗ[R] M) S M := SMulCommClass.symm _ _ _ end Automorphisms section OfSubsingleton variable (M M₂) variable [Module R M] [Module R M₂] [Subsingleton M] [Subsingleton M₂] /-- Any two modules that are subsingletons are isomorphic. -/ @[simps] def ofSubsingleton : M ≃ₗ[R] M₂ := { (0 : M →ₗ[R] M₂) with toFun := fun _ ↦ 0 invFun := fun _ ↦ 0 left_inv := fun _ ↦ Subsingleton.elim _ _ right_inv := fun _ ↦ Subsingleton.elim _ _ } @[simp] theorem ofSubsingleton_self : ofSubsingleton M M = refl R M := by ext simp [eq_iff_true_of_subsingleton] end OfSubsingleton end LinearEquiv namespace Module /-- `g : R ≃+* S` is `R`-linear when the module structure on `S` is `Module.compHom S g` . -/ @[simps] def compHom.toLinearEquiv {R S : Type*} [Semiring R] [Semiring S] (g : R ≃+* S) : haveI := compHom S (↑g : R →+* S) R ≃ₗ[R] S := letI := compHom S (↑g : R →+* S) { g with toFun := (g : R → S) invFun := (g.symm : S → R) map_smul' := g.map_mul } end Module namespace DistribMulAction variable (R M) [Semiring R] [AddCommMonoid M] [Module R M] variable [Group S] [DistribMulAction S M] [SMulCommClass S R M] /-- Each element of the group defines a linear equivalence. This is a stronger version of `DistribMulAction.toAddEquiv`. -/ @[simps!] def toLinearEquiv (s : S) : M ≃ₗ[R] M := { toAddEquiv M s, toLinearMap R M s with } /-- Each element of the group defines a module automorphism. This is a stronger version of `DistribMulAction.toAddAut`. -/ @[simps] def toModuleAut : S →* M ≃ₗ[R] M where toFun := toLinearEquiv R M map_one' := LinearEquiv.ext <| one_smul _ map_mul' _ _ := LinearEquiv.ext <| mul_smul _ _ end DistribMulAction namespace AddEquiv section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R M₂] variable (e : M ≃+ M₂) /-- An additive equivalence whose underlying function preserves `smul` is a linear equivalence. -/ def toLinearEquiv (h : ∀ (c : R) (x), e (c • x) = c • e x) : M ≃ₗ[R] M₂ := { e with map_smul' := h } @[simp] theorem coe_toLinearEquiv (h : ∀ (c : R) (x), e (c • x) = c • e x) : ⇑(e.toLinearEquiv h) = e := rfl @[simp] theorem coe_toLinearEquiv_symm (h : ∀ (c : R) (x), e (c • x) = c • e x) : ⇑(e.toLinearEquiv h).symm = e.symm := rfl /-- An additive equivalence between commutative additive monoids is a linear equivalence between ℕ-modules -/ def toNatLinearEquiv : M ≃ₗ[ℕ] M₂ := e.toLinearEquiv fun c a ↦ by rw [map_nsmul] @[simp] theorem coe_toNatLinearEquiv : ⇑e.toNatLinearEquiv = e := rfl @[simp] theorem toNatLinearEquiv_toAddEquiv : ↑e.toNatLinearEquiv = e := rfl @[simp] theorem _root_.LinearEquiv.toAddEquiv_toNatLinearEquiv (e : M ≃ₗ[ℕ] M₂) : AddEquiv.toNatLinearEquiv ↑e = e := DFunLike.coe_injective rfl @[simp] theorem toNatLinearEquiv_symm : e.toNatLinearEquiv.symm = e.symm.toNatLinearEquiv := rfl @[simp] theorem toNatLinearEquiv_refl : (AddEquiv.refl M).toNatLinearEquiv = LinearEquiv.refl ℕ M := rfl @[simp] theorem toNatLinearEquiv_trans (e₂ : M₂ ≃+ M₃) : e.toNatLinearEquiv.trans e₂.toNatLinearEquiv = (e.trans e₂).toNatLinearEquiv := rfl end AddCommMonoid section AddCommGroup variable [AddCommGroup M] [AddCommGroup M₂] [AddCommGroup M₃] variable (e : M ≃+ M₂) /-- An additive equivalence between commutative additive groups is a linear equivalence between ℤ-modules -/ def toIntLinearEquiv : M ≃ₗ[ℤ] M₂ := e.toLinearEquiv fun c a ↦ e.toAddMonoidHom.map_zsmul a c @[simp] theorem coe_toIntLinearEquiv : ⇑e.toIntLinearEquiv = e := rfl @[simp] theorem toIntLinearEquiv_toAddEquiv : ↑e.toIntLinearEquiv = e := by ext rfl @[simp] theorem _root_.LinearEquiv.toAddEquiv_toIntLinearEquiv (e : M ≃ₗ[ℤ] M₂) : AddEquiv.toIntLinearEquiv (e : M ≃+ M₂) = e := DFunLike.coe_injective rfl @[simp] theorem toIntLinearEquiv_symm : e.toIntLinearEquiv.symm = e.symm.toIntLinearEquiv := rfl @[simp] theorem toIntLinearEquiv_refl : (AddEquiv.refl M).toIntLinearEquiv = LinearEquiv.refl ℤ M := rfl @[simp] theorem toIntLinearEquiv_trans (e₂ : M₂ ≃+ M₃) : e.toIntLinearEquiv.trans e₂.toIntLinearEquiv = (e.trans e₂).toIntLinearEquiv := rfl end AddCommGroup end AddEquiv namespace LinearMap variable (R S M) variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M] /-- The equivalence between R-linear maps from `R` to `M`, and points of `M` itself. This says that the forgetful functor from `R`-modules to types is representable, by `R`. This is an `S`-linear equivalence, under the assumption that `S` acts on `M` commuting with `R`. When `R` is commutative, we can take this to be the usual action with `S = R`. Otherwise, `S = ℕ` shows that the equivalence is additive. See note [bundled maps over different rings]. -/ @[simps] def ringLmapEquivSelf [Module S M] [SMulCommClass R S M] : (R →ₗ[R] M) ≃ₗ[S] M := { applyₗ' S (1 : R) with toFun := fun f ↦ f 1 invFun := smulRight (1 : R →ₗ[R] R) left_inv := fun f ↦ by ext simp only [coe_smulRight, one_apply, smul_eq_mul, ← map_smul f, mul_one] right_inv := fun x ↦ by simp } end LinearMap /-- The `R`-linear equivalence between additive morphisms `A →+ B` and `ℕ`-linear morphisms `A →ₗ[ℕ] B`. -/ @[simps] def addMonoidHomLequivNat {A B : Type*} (R : Type*) [Semiring R] [AddCommMonoid A] [AddCommMonoid B] [Module R B] : (A →+ B) ≃ₗ[R] A →ₗ[ℕ] B where toFun := AddMonoidHom.toNatLinearMap invFun := LinearMap.toAddMonoidHom map_add' _ _ := rfl map_smul' _ _ := rfl left_inv _ := rfl right_inv _ := rfl /-- The `R`-linear equivalence between additive morphisms `A →+ B` and `ℤ`-linear morphisms `A →ₗ[ℤ] B`. -/ @[simps] def addMonoidHomLequivInt {A B : Type*} (R : Type*) [Semiring R] [AddCommGroup A] [AddCommGroup B] [Module R B] : (A →+ B) ≃ₗ[R] A →ₗ[ℤ] B where toFun := AddMonoidHom.toIntLinearMap invFun := LinearMap.toAddMonoidHom map_add' _ _ := rfl map_smul' _ _ := rfl left_inv _ := rfl right_inv _ := rfl /-- Ring equivalence between additive group endomorphisms of an `AddCommGroup` `A` and `ℤ`-module endomorphisms of `A.` -/ @[simps] def addMonoidEndRingEquivInt (A : Type*) [AddCommGroup A] : AddMonoid.End A ≃+* Module.End ℤ A := { addMonoidHomLequivInt (B := A) ℤ with map_mul' := fun _ _ ↦ rfl } namespace LinearEquiv section AddCommMonoid section Subsingleton variable [Semiring R] [Semiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] variable [Module R M] [Module R₂ M₂] variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} variable [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] section Module variable [Subsingleton M] [Subsingleton M₂] /-- Between two zero modules, the zero map is an equivalence. -/ instance : Zero (M ≃ₛₗ[σ₁₂] M₂) := ⟨{ (0 : M →ₛₗ[σ₁₂] M₂) with toFun := 0 invFun := 0 right_inv := Subsingleton.elim _ left_inv := Subsingleton.elim _ }⟩ -- Even though these are implied by `Subsingleton.elim` via the `Unique` instance below, they're -- nice to have as `rfl`-lemmas for `dsimp`. @[simp] theorem zero_symm : (0 : M ≃ₛₗ[σ₁₂] M₂).symm = 0 := rfl @[simp] theorem coe_zero : ⇑(0 : M ≃ₛₗ[σ₁₂] M₂) = 0 := rfl theorem zero_apply (x : M) : (0 : M ≃ₛₗ[σ₁₂] M₂) x = 0 := rfl /-- Between two zero modules, the zero map is the only equivalence. -/ instance : Unique (M ≃ₛₗ[σ₁₂] M₂) where uniq _ := toLinearMap_injective (Subsingleton.elim _ _) default := 0 end Module instance uniqueOfSubsingleton [Subsingleton R] [Subsingleton R₂] : Unique (M ≃ₛₗ[σ₁₂] M₂) := by haveI := Module.subsingleton R M haveI := Module.subsingleton R₂ M₂ infer_instance end Subsingleton section Uncurry variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable (V V₂ R) /-- Linear equivalence between a curried and uncurried function. Differs from `TensorProduct.curry`. -/ protected def curry : (V × V₂ → R) ≃ₗ[R] V → V₂ → R := { Equiv.curry _ _ _ with map_add' := fun _ _ ↦ rfl map_smul' := fun _ _ ↦ rfl } @[simp] theorem coe_curry : ⇑(LinearEquiv.curry R V V₂) = curry := rfl @[simp] theorem coe_curry_symm : ⇑(LinearEquiv.curry R V V₂).symm = uncurry := rfl end Uncurry section variable [Semiring R] [Semiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] variable {module_M : Module R M} {module_M₂ : Module R₂ M₂} variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} variable {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₁ : RingHomInvPair σ₂₁ σ₁₂} variable (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₁] M) /-- If a linear map has an inverse, it is a linear equivalence. -/ def ofLinear (h₁ : f.comp g = LinearMap.id) (h₂ : g.comp f = LinearMap.id) : M ≃ₛₗ[σ₁₂] M₂ := { f with invFun := g left_inv := LinearMap.ext_iff.1 h₂ right_inv := LinearMap.ext_iff.1 h₁ } @[simp] theorem ofLinear_apply {h₁ h₂} (x : M) : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂) x = f x := rfl @[simp] theorem ofLinear_symm_apply {h₁ h₂} (x : M₂) : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂).symm x = g x := rfl @[simp] theorem ofLinear_toLinearMap {h₁ h₂} : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂) = f := rfl @[simp] theorem ofLinear_symm_toLinearMap {h₁ h₂} : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂).symm = g := rfl end end AddCommMonoid section Neg variable (R) [Semiring R] [AddCommGroup M] [Module R M] /-- `x ↦ -x` as a `LinearEquiv` -/ def neg : M ≃ₗ[R] M := { Equiv.neg M, (-LinearMap.id : M →ₗ[R] M) with } variable {R} @[simp] theorem coe_neg : ⇑(neg R : M ≃ₗ[R] M) = -id := rfl theorem neg_apply (x : M) : neg R x = -x := by simp @[simp] theorem symm_neg : (neg R : M ≃ₗ[R] M).symm = neg R := rfl end Neg section CommSemiring variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R M₂] [Module R M₃] open LinearMap /-- Multiplying by a unit `a` of the ring `R` is a linear equivalence. -/ def smulOfUnit (a : Rˣ) : M ≃ₗ[R] M := DistribMulAction.toLinearEquiv R M a /-- A linear isomorphism between the domains and codomains of two spaces of linear maps gives a linear isomorphism between the two function spaces. -/ def arrowCongr {R M₁ M₂ M₂₁ M₂₂ : Sort _} [CommSemiring R] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂] [Module R M₂₁] [Module R M₂₂] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) : (M₁ →ₗ[R] M₂₁) ≃ₗ[R] M₂ →ₗ[R] M₂₂ where toFun := fun f : M₁ →ₗ[R] M₂₁ ↦ (e₂ : M₂₁ →ₗ[R] M₂₂).comp <| f.comp (e₁.symm : M₂ →ₗ[R] M₁) invFun f := (e₂.symm : M₂₂ →ₗ[R] M₂₁).comp <| f.comp (e₁ : M₁ →ₗ[R] M₂) left_inv f := by ext x simp only [symm_apply_apply, Function.comp_apply, coe_comp, coe_coe] right_inv f := by ext x simp only [Function.comp_apply, apply_symm_apply, coe_comp, coe_coe] map_add' f g := by ext x simp only [map_add, add_apply, Function.comp_apply, coe_comp, coe_coe] map_smul' c f := by ext x simp only [smul_apply, Function.comp_apply, coe_comp, map_smulₛₗ e₂, coe_coe] @[simp] theorem arrowCongr_apply {R M₁ M₂ M₂₁ M₂₂ : Sort _} [CommSemiring R] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂] [Module R M₂₁] [Module R M₂₂] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) (f : M₁ →ₗ[R] M₂₁) (x : M₂) : arrowCongr e₁ e₂ f x = e₂ (f (e₁.symm x)) := rfl @[simp] theorem arrowCongr_symm_apply {R M₁ M₂ M₂₁ M₂₂ : Sort _} [CommSemiring R] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂] [Module R M₂₁] [Module R M₂₂] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) (f : M₂ →ₗ[R] M₂₂) (x : M₁) : (arrowCongr e₁ e₂).symm f x = e₂.symm (f (e₁ x)) := rfl theorem arrowCongr_comp {N N₂ N₃ : Sort _} [AddCommMonoid N] [AddCommMonoid N₂] [AddCommMonoid N₃] [Module R N] [Module R N₂] [Module R N₃] (e₁ : M ≃ₗ[R] N) (e₂ : M₂ ≃ₗ[R] N₂) (e₃ : M₃ ≃ₗ[R] N₃) (f : M →ₗ[R] M₂) (g : M₂ →ₗ[R] M₃) : arrowCongr e₁ e₃ (g.comp f) = (arrowCongr e₂ e₃ g).comp (arrowCongr e₁ e₂ f) := by ext simp only [symm_apply_apply, arrowCongr_apply, LinearMap.comp_apply] theorem arrowCongr_trans {M₁ M₂ M₃ N₁ N₂ N₃ : Sort _} [AddCommMonoid M₁] [Module R M₁] [AddCommMonoid M₂] [Module R M₂] [AddCommMonoid M₃] [Module R M₃] [AddCommMonoid N₁] [Module R N₁] [AddCommMonoid N₂] [Module R N₂] [AddCommMonoid N₃] [Module R N₃] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : N₁ ≃ₗ[R] N₂) (e₃ : M₂ ≃ₗ[R] M₃) (e₄ : N₂ ≃ₗ[R] N₃) : (arrowCongr e₁ e₂).trans (arrowCongr e₃ e₄) = arrowCongr (e₁.trans e₃) (e₂.trans e₄) := rfl /-- If `M₂` and `M₃` are linearly isomorphic then the two spaces of linear maps from `M` into `M₂` and `M` into `M₃` are linearly isomorphic. -/ def congrRight (f : M₂ ≃ₗ[R] M₃) : (M →ₗ[R] M₂) ≃ₗ[R] M →ₗ[R] M₃ := arrowCongr (LinearEquiv.refl R M) f /-- If `M` and `M₂` are linearly isomorphic then the two spaces of linear maps from `M` and `M₂` to themselves are linearly isomorphic. -/ def conj (e : M ≃ₗ[R] M₂) : Module.End R M ≃ₗ[R] Module.End R M₂ := arrowCongr e e theorem conj_apply (e : M ≃ₗ[R] M₂) (f : Module.End R M) : e.conj f = ((↑e : M →ₗ[R] M₂).comp f).comp (e.symm : M₂ →ₗ[R] M) := rfl theorem conj_apply_apply (e : M ≃ₗ[R] M₂) (f : Module.End R M) (x : M₂) : e.conj f x = e (f (e.symm x)) := rfl theorem symm_conj_apply (e : M ≃ₗ[R] M₂) (f : Module.End R M₂) : e.symm.conj f = ((↑e.symm : M₂ →ₗ[R] M).comp f).comp (e : M →ₗ[R] M₂) := rfl theorem conj_comp (e : M ≃ₗ[R] M₂) (f g : Module.End R M) : e.conj (g.comp f) = (e.conj g).comp (e.conj f) := arrowCongr_comp e e e f g theorem conj_trans (e₁ : M ≃ₗ[R] M₂) (e₂ : M₂ ≃ₗ[R] M₃) : e₁.conj.trans e₂.conj = (e₁.trans e₂).conj := rfl @[simp] theorem conj_id (e : M ≃ₗ[R] M₂) : e.conj LinearMap.id = LinearMap.id := by ext simp [conj_apply] variable (M) in /-- An `R`-linear isomorphism between two `R`-modules `M₂` and `M₃` induces an `S`-linear isomorphism between `M₂ →ₗ[R] M` and `M₃ →ₗ[R] M`, if `M` is both an `R`-module and an `S`-module and their actions commute. -/ def congrLeft {R} (S) [Semiring R] [Semiring S] [Module R M₂] [Module R M₃] [Module R M] [Module S M] [SMulCommClass R S M] (e : M₂ ≃ₗ[R] M₃) : (M₂ →ₗ[R] M) ≃ₗ[S] (M₃ →ₗ[R] M) where toFun f := f.comp e.symm.toLinearMap invFun f := f.comp e.toLinearMap map_add' _ _ := rfl map_smul' _ _ := rfl left_inv f := by dsimp only; apply DFunLike.ext; exact (congr_arg f <| e.left_inv ·) right_inv f := by dsimp only; apply DFunLike.ext; exact (congr_arg f <| e.right_inv ·) end CommSemiring section Field variable [Field K] [AddCommGroup M] [AddCommGroup M₂] [AddCommGroup M₃] variable [Module K M] [Module K M₂] [Module K M₃] variable (K) (M) open LinearMap /-- Multiplying by a nonzero element `a` of the field `K` is a linear equivalence. -/ @[simps!] def smulOfNeZero (a : K) (ha : a ≠ 0) : M ≃ₗ[K] M := smulOfUnit <| Units.mk0 a ha end Field end LinearEquiv namespace Equiv variable [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid M₂] [Module R M₂] /-- An equivalence whose underlying function is linear is a linear equivalence. -/ def toLinearEquiv (e : M ≃ M₂) (h : IsLinearMap R (e : M → M₂)) : M ≃ₗ[R] M₂ := { e, h.mk' e with } end Equiv section FunLeft variable (R M) [Semiring R] [AddCommMonoid M] [Module R M] variable {m n p : Type*} namespace LinearMap /-- Given an `R`-module `M` and a function `m → n` between arbitrary types, construct a linear map `(n → M) →ₗ[R] (m → M)` -/ def funLeft (f : m → n) : (n → M) →ₗ[R] m → M where toFun := (· ∘ f) map_add' _ _ := rfl map_smul' _ _ := rfl @[simp] theorem funLeft_apply (f : m → n) (g : n → M) (i : m) : funLeft R M f g i = g (f i) := rfl @[simp] theorem funLeft_id (g : n → M) : funLeft R M _root_.id g = g := rfl theorem funLeft_comp (f₁ : n → p) (f₂ : m → n) : funLeft R M (f₁ ∘ f₂) = (funLeft R M f₂).comp (funLeft R M f₁) := rfl theorem funLeft_surjective_of_injective (f : m → n) (hf : Injective f) : Surjective (funLeft R M f) := by classical intro g refine ⟨fun x ↦ if h : ∃ y, f y = x then g h.choose else 0, ?_⟩ ext dsimp only [funLeft_apply] split_ifs with w · congr exact hf w.choose_spec · simp only [not_true, exists_apply_eq_apply] at w theorem funLeft_injective_of_surjective (f : m → n) (hf : Surjective f) : Injective (funLeft R M f) := by obtain ⟨g, hg⟩ := hf.hasRightInverse suffices LeftInverse (funLeft R M g) (funLeft R M f) by exact this.injective intro x rw [← LinearMap.comp_apply, ← funLeft_comp, hg.id, funLeft_id] end LinearMap namespace LinearEquiv open LinearMap /-- Given an `R`-module `M` and an equivalence `m ≃ n` between arbitrary types, construct a linear equivalence `(n → M) ≃ₗ[R] (m → M)` -/ def funCongrLeft (e : m ≃ n) : (n → M) ≃ₗ[R] m → M := LinearEquiv.ofLinear (funLeft R M e) (funLeft R M e.symm) (LinearMap.ext fun x ↦ funext fun i ↦ by rw [id_apply, ← funLeft_comp, Equiv.symm_comp_self, LinearMap.funLeft_id]) (LinearMap.ext fun x ↦ funext fun i ↦ by rw [id_apply, ← funLeft_comp, Equiv.self_comp_symm, LinearMap.funLeft_id]) @[simp] theorem funCongrLeft_apply (e : m ≃ n) (x : n → M) : funCongrLeft R M e x = funLeft R M e x := rfl @[simp] theorem funCongrLeft_id : funCongrLeft R M (Equiv.refl n) = LinearEquiv.refl R (n → M) := rfl @[simp] theorem funCongrLeft_comp (e₁ : m ≃ n) (e₂ : n ≃ p) : funCongrLeft R M (Equiv.trans e₁ e₂) = LinearEquiv.trans (funCongrLeft R M e₂) (funCongrLeft R M e₁) := rfl @[simp] theorem funCongrLeft_symm (e : m ≃ n) : (funCongrLeft R M e).symm = funCongrLeft R M e.symm := rfl end LinearEquiv end FunLeft end AddCommMonoid
Algebra\Module\Equiv\Defs.lean
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.LinearMap.Defs /-! # (Semi)linear equivalences In this file we define * `LinearEquiv σ M M₂`, `M ≃ₛₗ[σ] M₂`: an invertible semilinear map. Here, `σ` is a `RingHom` from `R` to `R₂` and an `e : M ≃ₛₗ[σ] M₂` satisfies `e (c • x) = (σ c) • (e x)`. The plain linear version, with `σ` being `RingHom.id R`, is denoted by `M ≃ₗ[R] M₂`, and the star-linear version (with `σ` being `starRingEnd`) is denoted by `M ≃ₗ⋆[R] M₂`. ## Implementation notes To ensure that composition works smoothly for semilinear equivalences, we use the typeclasses `RingHomCompTriple`, `RingHomInvPair` and `RingHomSurjective` from `Algebra/Ring/CompTypeclasses`. The group structure on automorphisms, `LinearEquiv.automorphismGroup`, is provided elsewhere. ## TODO * Parts of this file have not yet been generalized to semilinear maps ## Tags linear equiv, linear equivalences, linear isomorphism, linear isomorphic -/ assert_not_exists Field assert_not_exists Pi.module open Function universe u u' v w x y z variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {k : Type*} {K : Type*} {S : Type*} {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} variable {N₁ : Type*} {N₂ : Type*} {N₃ : Type*} {N₄ : Type*} {ι : Type*} section /-- A linear equivalence is an invertible linear map. -/ -- Porting note (#11215): TODO @[nolint has_nonempty_instance] structure LinearEquiv {R : Type*} {S : Type*} [Semiring R] [Semiring S] (σ : R →+* S) {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] (M : Type*) (M₂ : Type*) [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] extends LinearMap σ M M₂, M ≃+ M₂ attribute [coe] LinearEquiv.toLinearMap /-- The linear map underlying a linear equivalence. -/ add_decl_doc LinearEquiv.toLinearMap /-- The additive equivalence of types underlying a linear equivalence. -/ add_decl_doc LinearEquiv.toAddEquiv /-- The backwards directed function underlying a linear equivalence. -/ add_decl_doc LinearEquiv.invFun /-- `LinearEquiv.invFun` is a right inverse to the linear equivalence's underlying function. -/ add_decl_doc LinearEquiv.right_inv /-- `LinearEquiv.invFun` is a left inverse to the linear equivalence's underlying function. -/ add_decl_doc LinearEquiv.left_inv /-- The notation `M ≃ₛₗ[σ] M₂` denotes the type of linear equivalences between `M` and `M₂` over a ring homomorphism `σ`. -/ notation:50 M " ≃ₛₗ[" σ "] " M₂ => LinearEquiv σ M M₂ /-- The notation `M ≃ₗ [R] M₂` denotes the type of linear equivalences between `M` and `M₂` over a plain linear map `M →ₗ M₂`. -/ notation:50 M " ≃ₗ[" R "] " M₂ => LinearEquiv (RingHom.id R) M M₂ /-- `SemilinearEquivClass F σ M M₂` asserts `F` is a type of bundled `σ`-semilinear equivs `M → M₂`. See also `LinearEquivClass F R M M₂` for the case where `σ` is the identity map on `R`. A map `f` between an `R`-module and an `S`-module over a ring homomorphism `σ : R →+* S` is semilinear if it satisfies the two properties `f (x + y) = f x + f y` and `f (c • x) = (σ c) • f x`. -/ class SemilinearEquivClass (F : Type*) {R S : outParam Type*} [Semiring R] [Semiring S] (σ : outParam <| R →+* S) {σ' : outParam <| S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] (M M₂ : outParam Type*) [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] [EquivLike F M M₂] extends AddEquivClass F M M₂ : Prop where /-- Applying a semilinear equivalence `f` over `σ` to `r • x` equals `σ r • f x`. -/ map_smulₛₗ : ∀ (f : F) (r : R) (x : M), f (r • x) = σ r • f x -- `R, S, σ, σ'` become metavars, but it's OK since they are outparams. /-- `LinearEquivClass F R M M₂` asserts `F` is a type of bundled `R`-linear equivs `M → M₂`. This is an abbreviation for `SemilinearEquivClass F (RingHom.id R) M M₂`. -/ abbrev LinearEquivClass (F : Type*) (R M M₂ : outParam Type*) [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R M₂] [EquivLike F M M₂] := SemilinearEquivClass F (RingHom.id R) M M₂ end namespace SemilinearEquivClass variable (F : Type*) [Semiring R] [Semiring S] variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] variable [Module R M] [Module S M₂] {σ : R →+* S} {σ' : S →+* R} instance (priority := 100) [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] [EquivLike F M M₂] [s : SemilinearEquivClass F σ M M₂] : SemilinearMapClass F σ M M₂ := { s with } variable {F} /-- Reinterpret an element of a type of semilinear equivalences as a semilinear equivalence. -/ @[coe] def semilinearEquiv [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] [EquivLike F M M₂] [SemilinearEquivClass F σ M M₂] (f : F) : M ≃ₛₗ[σ] M₂ := { (f : M ≃+ M₂), (f : M →ₛₗ[σ] M₂) with } /-- Reinterpret an element of a type of semilinear equivalences as a semilinear equivalence. -/ instance instCoeToSemilinearEquiv [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] [EquivLike F M M₂] [SemilinearEquivClass F σ M M₂] : CoeHead F (M ≃ₛₗ[σ] M₂) where coe f := semilinearEquiv f end SemilinearEquivClass namespace LinearEquiv section AddCommMonoid variable {M₄ : Type*} variable [Semiring R] [Semiring S] section variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] variable [Module R M] [Module S M₂] {σ : R →+* S} {σ' : S →+* R} variable [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] instance : Coe (M ≃ₛₗ[σ] M₂) (M →ₛₗ[σ] M₂) := ⟨toLinearMap⟩ -- This exists for compatibility, previously `≃ₗ[R]` extended `≃` instead of `≃+`. /-- The equivalence of types underlying a linear equivalence. -/ def toEquiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂ := fun f ↦ f.toAddEquiv.toEquiv theorem toEquiv_injective : Function.Injective (toEquiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂) := fun ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ h ↦ (LinearEquiv.mk.injEq _ _ _ _ _ _ _ _).mpr ⟨LinearMap.ext (congr_fun (Equiv.mk.inj h).1), (Equiv.mk.inj h).2⟩ @[simp] theorem toEquiv_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} : e₁.toEquiv = e₂.toEquiv ↔ e₁ = e₂ := toEquiv_injective.eq_iff theorem toLinearMap_injective : Injective (toLinearMap : (M ≃ₛₗ[σ] M₂) → M →ₛₗ[σ] M₂) := fun _ _ H ↦ toEquiv_injective <| Equiv.ext <| LinearMap.congr_fun H @[simp, norm_cast] theorem toLinearMap_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} : (↑e₁ : M →ₛₗ[σ] M₂) = e₂ ↔ e₁ = e₂ := toLinearMap_injective.eq_iff instance : EquivLike (M ≃ₛₗ[σ] M₂) M M₂ where inv := LinearEquiv.invFun coe_injective' _ _ h _ := toLinearMap_injective (DFunLike.coe_injective h) left_inv := LinearEquiv.left_inv right_inv := LinearEquiv.right_inv /-- Helper instance for when inference gets stuck on following the normal chain `EquivLike → FunLike`. TODO: this instance doesn't appear to be necessary: remove it (after benchmarking?) -/ instance : FunLike (M ≃ₛₗ[σ] M₂) M M₂ where coe := DFunLike.coe coe_injective' := DFunLike.coe_injective instance : SemilinearEquivClass (M ≃ₛₗ[σ] M₂) σ M M₂ where map_add := (·.map_add') --map_add' Porting note (#11215): TODO why did I need to change this? map_smulₛₗ := (·.map_smul') --map_smul' Porting note (#11215): TODO why did I need to change this? -- Porting note: moved to a lower line since there is no shortcut `CoeFun` instance any more @[simp] theorem coe_mk {to_fun inv_fun map_add map_smul left_inv right_inv} : (⟨⟨⟨to_fun, map_add⟩, map_smul⟩, inv_fun, left_inv, right_inv⟩ : M ≃ₛₗ[σ] M₂) = to_fun := rfl theorem coe_injective : @Injective (M ≃ₛₗ[σ] M₂) (M → M₂) CoeFun.coe := DFunLike.coe_injective end section variable [Semiring R₁] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] variable [AddCommMonoid M₃] [AddCommMonoid M₄] variable [AddCommMonoid N₁] [AddCommMonoid N₂] variable {module_M : Module R M} {module_S_M₂ : Module S M₂} {σ : R →+* S} {σ' : S →+* R} variable {re₁ : RingHomInvPair σ σ'} {re₂ : RingHomInvPair σ' σ} variable (e e' : M ≃ₛₗ[σ] M₂) @[simp, norm_cast] theorem coe_coe : ⇑(e : M →ₛₗ[σ] M₂) = e := rfl @[simp] theorem coe_toEquiv : ⇑(e.toEquiv) = e := rfl @[simp] theorem coe_toLinearMap : ⇑e.toLinearMap = e := rfl -- Porting note: no longer a `simp` theorem toFun_eq_coe : e.toFun = e := rfl section variable {e e'} @[ext] theorem ext (h : ∀ x, e x = e' x) : e = e' := DFunLike.ext _ _ h protected theorem congr_arg {x x'} : x = x' → e x = e x' := DFunLike.congr_arg e protected theorem congr_fun (h : e = e') (x : M) : e x = e' x := DFunLike.congr_fun h x end section variable (M R) /-- The identity map is a linear equivalence. -/ @[refl] def refl [Module R M] : M ≃ₗ[R] M := { LinearMap.id, Equiv.refl M with } end @[simp] theorem refl_apply [Module R M] (x : M) : refl R M x = x := rfl /-- Linear equivalences are symmetric. -/ @[symm] def symm (e : M ≃ₛₗ[σ] M₂) : M₂ ≃ₛₗ[σ'] M := { e.toLinearMap.inverse e.invFun e.left_inv e.right_inv, e.toEquiv.symm with toFun := e.toLinearMap.inverse e.invFun e.left_inv e.right_inv invFun := e.toEquiv.symm.invFun map_smul' := fun r x ↦ by dsimp only; rw [map_smulₛₗ] } -- Porting note: this is new /-- See Note [custom simps projection] -/ def Simps.apply {R : Type*} {S : Type*} [Semiring R] [Semiring S] {σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] {M : Type*} {M₂ : Type*} [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] (e : M ≃ₛₗ[σ] M₂) : M → M₂ := e /-- See Note [custom simps projection] -/ def Simps.symm_apply {R : Type*} {S : Type*} [Semiring R] [Semiring S] {σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] {M : Type*} {M₂ : Type*} [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] (e : M ≃ₛₗ[σ] M₂) : M₂ → M := e.symm initialize_simps_projections LinearEquiv (toFun → apply, invFun → symm_apply) @[simp] theorem invFun_eq_symm : e.invFun = e.symm := rfl @[simp] theorem coe_toEquiv_symm : e.toEquiv.symm = e.symm := rfl variable {module_M₁ : Module R₁ M₁} {module_M₂ : Module R₂ M₂} {module_M₃ : Module R₃ M₃} variable {module_N₁ : Module R₁ N₁} {module_N₂ : Module R₁ N₂} variable {σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R₁ →+* R₃} variable {σ₂₁ : R₂ →+* R₁} {σ₃₂ : R₃ →+* R₂} {σ₃₁ : R₃ →+* R₁} variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable [RingHomCompTriple σ₃₂ σ₂₁ σ₃₁] variable {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₃ : RingHomInvPair σ₂₃ σ₃₂} variable [RingHomInvPair σ₁₃ σ₃₁] {re₂₁ : RingHomInvPair σ₂₁ σ₁₂} variable {re₃₂ : RingHomInvPair σ₃₂ σ₂₃} [RingHomInvPair σ₃₁ σ₁₃] variable (e₁₂ : M₁ ≃ₛₗ[σ₁₂] M₂) (e₂₃ : M₂ ≃ₛₗ[σ₂₃] M₃) -- Porting note: Lean 4 aggressively removes unused variables declared using `variable`, so -- we have to list all the variables explicitly here in order to match the Lean 3 signature. set_option linter.unusedVariables false in /-- Linear equivalences are transitive. -/ -- Note: the `RingHomCompTriple σ₃₂ σ₂₁ σ₃₁` is unused, but is convenient to carry around -- implicitly for lemmas like `LinearEquiv.self_trans_symm`. @[trans, nolint unusedArguments] def trans [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] [RingHomCompTriple σ₃₂ σ₂₁ σ₃₁] {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₃ : RingHomInvPair σ₂₃ σ₃₂} [RingHomInvPair σ₁₃ σ₃₁] {re₂₁ : RingHomInvPair σ₂₁ σ₁₂} {re₃₂ : RingHomInvPair σ₃₂ σ₂₃} [RingHomInvPair σ₃₁ σ₁₃] (e₁₂ : M₁ ≃ₛₗ[σ₁₂] M₂) (e₂₃ : M₂ ≃ₛₗ[σ₂₃] M₃) : M₁ ≃ₛₗ[σ₁₃] M₃ := { e₂₃.toLinearMap.comp e₁₂.toLinearMap, e₁₂.toEquiv.trans e₂₃.toEquiv with } /-- The notation `e₁ ≪≫ₗ e₂` denotes the composition of the linear equivalences `e₁` and `e₂`. -/ notation3:80 (name := transNotation) e₁:80 " ≪≫ₗ " e₂:81 => @LinearEquiv.trans _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ (RingHom.id _) (RingHom.id _) (RingHom.id _) (RingHom.id _) (RingHom.id _) (RingHom.id _) RingHomCompTriple.ids RingHomCompTriple.ids RingHomInvPair.ids RingHomInvPair.ids RingHomInvPair.ids RingHomInvPair.ids RingHomInvPair.ids RingHomInvPair.ids e₁ e₂ variable {e₁₂} {e₂₃} @[simp] theorem coe_toAddEquiv : e.toAddEquiv = e := rfl /-- The two paths coercion can take to an `AddMonoidHom` are equivalent -/ theorem toAddMonoidHom_commutes : e.toLinearMap.toAddMonoidHom = e.toAddEquiv.toAddMonoidHom := rfl @[simp] theorem trans_apply (c : M₁) : (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃) c = e₂₃ (e₁₂ c) := rfl theorem coe_trans : (e₁₂.trans e₂₃ : M₁ →ₛₗ[σ₁₃] M₃) = (e₂₃ : M₂ →ₛₗ[σ₂₃] M₃).comp (e₁₂ : M₁ →ₛₗ[σ₁₂] M₂) := rfl @[simp] theorem apply_symm_apply (c : M₂) : e (e.symm c) = c := e.right_inv c @[simp] theorem symm_apply_apply (b : M) : e.symm (e b) = b := e.left_inv b @[simp] theorem trans_symm : (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃).symm = e₂₃.symm.trans e₁₂.symm := rfl theorem symm_trans_apply (c : M₃) : (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃).symm c = e₁₂.symm (e₂₃.symm c) := rfl @[simp] theorem trans_refl : e.trans (refl S M₂) = e := toEquiv_injective e.toEquiv.trans_refl @[simp] theorem refl_trans : (refl R M).trans e = e := toEquiv_injective e.toEquiv.refl_trans theorem symm_apply_eq {x y} : e.symm x = y ↔ x = e y := e.toEquiv.symm_apply_eq theorem eq_symm_apply {x y} : y = e.symm x ↔ e y = x := e.toEquiv.eq_symm_apply theorem eq_comp_symm {α : Type*} (f : M₂ → α) (g : M₁ → α) : f = g ∘ e₁₂.symm ↔ f ∘ e₁₂ = g := e₁₂.toEquiv.eq_comp_symm f g theorem comp_symm_eq {α : Type*} (f : M₂ → α) (g : M₁ → α) : g ∘ e₁₂.symm = f ↔ g = f ∘ e₁₂ := e₁₂.toEquiv.comp_symm_eq f g theorem eq_symm_comp {α : Type*} (f : α → M₁) (g : α → M₂) : f = e₁₂.symm ∘ g ↔ e₁₂ ∘ f = g := e₁₂.toEquiv.eq_symm_comp f g theorem symm_comp_eq {α : Type*} (f : α → M₁) (g : α → M₂) : e₁₂.symm ∘ g = f ↔ g = e₁₂ ∘ f := e₁₂.toEquiv.symm_comp_eq f g variable [RingHomCompTriple σ₂₁ σ₁₃ σ₂₃] [RingHomCompTriple σ₃₁ σ₁₂ σ₃₂] theorem eq_comp_toLinearMap_symm (f : M₂ →ₛₗ[σ₂₃] M₃) (g : M₁ →ₛₗ[σ₁₃] M₃) : f = g.comp e₁₂.symm.toLinearMap ↔ f.comp e₁₂.toLinearMap = g := by constructor <;> intro H <;> ext · simp [H, e₁₂.toEquiv.eq_comp_symm f g] · simp [← H, ← e₁₂.toEquiv.eq_comp_symm f g] theorem comp_toLinearMap_symm_eq (f : M₂ →ₛₗ[σ₂₃] M₃) (g : M₁ →ₛₗ[σ₁₃] M₃) : g.comp e₁₂.symm.toLinearMap = f ↔ g = f.comp e₁₂.toLinearMap := by constructor <;> intro H <;> ext · simp [← H, ← e₁₂.toEquiv.comp_symm_eq f g] · simp [H, e₁₂.toEquiv.comp_symm_eq f g] theorem eq_toLinearMap_symm_comp (f : M₃ →ₛₗ[σ₃₁] M₁) (g : M₃ →ₛₗ[σ₃₂] M₂) : f = e₁₂.symm.toLinearMap.comp g ↔ e₁₂.toLinearMap.comp f = g := by constructor <;> intro H <;> ext · simp [H, e₁₂.toEquiv.eq_symm_comp f g] · simp [← H, ← e₁₂.toEquiv.eq_symm_comp f g] theorem toLinearMap_symm_comp_eq (f : M₃ →ₛₗ[σ₃₁] M₁) (g : M₃ →ₛₗ[σ₃₂] M₂) : e₁₂.symm.toLinearMap.comp g = f ↔ g = e₁₂.toLinearMap.comp f := by constructor <;> intro H <;> ext · simp [← H, ← e₁₂.toEquiv.symm_comp_eq f g] · simp [H, e₁₂.toEquiv.symm_comp_eq f g] @[simp] theorem refl_symm [Module R M] : (refl R M).symm = LinearEquiv.refl R M := rfl @[simp] theorem self_trans_symm (f : M₁ ≃ₛₗ[σ₁₂] M₂) : f.trans f.symm = LinearEquiv.refl R₁ M₁ := by ext x simp @[simp] theorem symm_trans_self (f : M₁ ≃ₛₗ[σ₁₂] M₂) : f.symm.trans f = LinearEquiv.refl R₂ M₂ := by ext x simp @[simp] -- Porting note: norm_cast theorem refl_toLinearMap [Module R M] : (LinearEquiv.refl R M : M →ₗ[R] M) = LinearMap.id := rfl @[simp] -- Porting note: norm_cast theorem comp_coe [Module R M] [Module R M₂] [Module R M₃] (f : M ≃ₗ[R] M₂) (f' : M₂ ≃ₗ[R] M₃) : (f' : M₂ →ₗ[R] M₃).comp (f : M →ₗ[R] M₂) = (f.trans f' : M ≃ₗ[R] M₃) := rfl @[simp] theorem mk_coe (f h₁ h₂) : (LinearEquiv.mk e f h₁ h₂ : M ≃ₛₗ[σ] M₂) = e := ext fun _ ↦ rfl protected theorem map_add (a b : M) : e (a + b) = e a + e b := map_add e a b protected theorem map_zero : e 0 = 0 := map_zero e protected theorem map_smulₛₗ (c : R) (x : M) : e (c • x) = (σ : R → S) c • e x := e.map_smul' c x theorem map_smul (e : N₁ ≃ₗ[R₁] N₂) (c : R₁) (x : N₁) : e (c • x) = c • e x := map_smulₛₗ e c x theorem map_eq_zero_iff {x : M} : e x = 0 ↔ x = 0 := e.toAddEquiv.map_eq_zero_iff theorem map_ne_zero_iff {x : M} : e x ≠ 0 ↔ x ≠ 0 := e.toAddEquiv.map_ne_zero_iff @[simp] theorem symm_symm (e : M ≃ₛₗ[σ] M₂) : e.symm.symm = e := by cases e rfl theorem symm_bijective [Module R M] [Module S M₂] [RingHomInvPair σ' σ] [RingHomInvPair σ σ'] : Function.Bijective (symm : (M ≃ₛₗ[σ] M₂) → M₂ ≃ₛₗ[σ'] M) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ @[simp] theorem mk_coe' (f h₁ h₂ h₃ h₄) : (LinearEquiv.mk ⟨⟨f, h₁⟩, h₂⟩ (⇑e) h₃ h₄ : M₂ ≃ₛₗ[σ'] M) = e.symm := symm_bijective.injective <| ext fun _ ↦ rfl /-- Auxilliary definition to avoid looping in `dsimp` with `LinearEquiv.symm_mk`. -/ protected def symm_mk.aux (f h₁ h₂ h₃ h₄) := (⟨⟨⟨e, h₁⟩, h₂⟩, f, h₃, h₄⟩ : M ≃ₛₗ[σ] M₂).symm @[simp] theorem symm_mk (f h₁ h₂ h₃ h₄) : (⟨⟨⟨e, h₁⟩, h₂⟩, f, h₃, h₄⟩ : M ≃ₛₗ[σ] M₂).symm = { symm_mk.aux e f h₁ h₂ h₃ h₄ with toFun := f invFun := e } := rfl @[simp] theorem coe_symm_mk [Module R M] [Module R M₂] {to_fun inv_fun map_add map_smul left_inv right_inv} : ⇑(⟨⟨⟨to_fun, map_add⟩, map_smul⟩, inv_fun, left_inv, right_inv⟩ : M ≃ₗ[R] M₂).symm = inv_fun := rfl protected theorem bijective : Function.Bijective e := e.toEquiv.bijective protected theorem injective : Function.Injective e := e.toEquiv.injective protected theorem surjective : Function.Surjective e := e.toEquiv.surjective protected theorem image_eq_preimage (s : Set M) : e '' s = e.symm ⁻¹' s := e.toEquiv.image_eq_preimage s protected theorem image_symm_eq_preimage (s : Set M₂) : e.symm '' s = e ⁻¹' s := e.toEquiv.symm.image_eq_preimage s end /-- Interpret a `RingEquiv` `f` as an `f`-semilinear equiv. -/ @[simps] def _root_.RingEquiv.toSemilinearEquiv (f : R ≃+* S) : haveI := RingHomInvPair.of_ringEquiv f haveI := RingHomInvPair.symm (↑f : R →+* S) (f.symm : S →+* R) R ≃ₛₗ[(↑f : R →+* S)] S := haveI := RingHomInvPair.of_ringEquiv f haveI := RingHomInvPair.symm (↑f : R →+* S) (f.symm : S →+* R) { f with toFun := f map_smul' := f.map_mul } variable [Semiring R₁] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] /-- An involutive linear map is a linear equivalence. -/ def ofInvolutive {σ σ' : R →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] {_ : Module R M} (f : M →ₛₗ[σ] M) (hf : Involutive f) : M ≃ₛₗ[σ] M := { f, hf.toPerm f with } @[simp] theorem coe_ofInvolutive {σ σ' : R →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] {_ : Module R M} (f : M →ₛₗ[σ] M) (hf : Involutive f) : ⇑(ofInvolutive f hf) = f := rfl end AddCommMonoid end LinearEquiv
Algebra\Module\LinearMap\Basic.lean
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.LinearMap.Defs import Mathlib.Algebra.Module.Pi import Mathlib.GroupTheory.GroupAction.DomAct.Basic /-! # Further results on (semi)linear maps -/ assert_not_exists Submonoid assert_not_exists Finset assert_not_exists Star open Function universe u u' v w x y z variable {R R₁ R₂ R₃ k S S₃ T M M₁ M₂ M₃ N₁ N₂ N₃ ι : Type*} namespace LinearMap section SMul variable [Semiring R] [Semiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] variable [Module R M] [Module R₂ M₂] variable {σ₁₂ : R →+* R₂} variable {S' T' : Type*} variable [Monoid S'] [DistribMulAction S' M] [SMulCommClass R S' M] variable [Monoid T'] [DistribMulAction T' M] [SMulCommClass R T' M] instance : SMul S'ᵈᵐᵃ (M →ₛₗ[σ₁₂] M₂) where smul a f := { toFun := a • (f : M → M₂) map_add' := fun x y ↦ by simp only [DomMulAct.smul_apply, f.map_add, smul_add] map_smul' := fun c x ↦ by simp_rw [DomMulAct.smul_apply, ← smul_comm, f.map_smulₛₗ] } theorem _root_.DomMulAct.smul_linearMap_apply (a : S'ᵈᵐᵃ) (f : M →ₛₗ[σ₁₂] M₂) (x : M) : (a • f) x = f (DomMulAct.mk.symm a • x) := rfl @[simp] theorem _root_.DomMulAct.mk_smul_linearMap_apply (a : S') (f : M →ₛₗ[σ₁₂] M₂) (x : M) : (DomMulAct.mk a • f) x = f (a • x) := rfl theorem _root_.DomMulAct.coe_smul_linearMap (a : S'ᵈᵐᵃ) (f : M →ₛₗ[σ₁₂] M₂) : (a • f : M →ₛₗ[σ₁₂] M₂) = a • (f : M → M₂) := rfl instance [SMulCommClass S' T' M] : SMulCommClass S'ᵈᵐᵃ T'ᵈᵐᵃ (M →ₛₗ[σ₁₂] M₂) := ⟨fun s t f ↦ ext fun m ↦ by simp_rw [DomMulAct.smul_linearMap_apply, smul_comm]⟩ end SMul section Actions variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] section SMul variable [Monoid S] [DistribMulAction S M₂] [SMulCommClass R₂ S M₂] variable [Monoid S₃] [DistribMulAction S₃ M₃] [SMulCommClass R₃ S₃ M₃] variable [Monoid T] [DistribMulAction T M₂] [SMulCommClass R₂ T M₂] instance {S'} [Monoid S'] [DistribMulAction S' M] [SMulCommClass R S' M] : DistribMulAction S'ᵈᵐᵃ (M →ₛₗ[σ₁₂] M₂) where one_smul _ := ext fun _ ↦ congr_arg _ (one_smul _ _) mul_smul _ _ _ := ext fun _ ↦ congr_arg _ (mul_smul _ _ _) smul_add _ _ _ := ext fun _ ↦ rfl smul_zero _ := ext fun _ ↦ rfl end SMul section Module variable [Semiring S] [Module S M] [Module S M₂] [SMulCommClass R₂ S M₂] instance [NoZeroSMulDivisors S M₂] : NoZeroSMulDivisors S (M →ₛₗ[σ₁₂] M₂) := coe_injective.noZeroSMulDivisors _ rfl coe_smul instance [SMulCommClass R S M] : Module Sᵈᵐᵃ (M →ₛₗ[σ₁₂] M₂) where add_smul _ _ _ := ext fun _ ↦ by simp_rw [add_apply, DomMulAct.smul_linearMap_apply, ← map_add, ← add_smul]; rfl zero_smul _ := ext fun _ ↦ by erw [DomMulAct.smul_linearMap_apply, zero_smul, map_zero]; rfl end Module end Actions end LinearMap
Algebra\Module\LinearMap\Defs.lean
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Ring.CompTypeclasses import Mathlib.GroupTheory.GroupAction.Hom /-! # (Semi)linear maps In this file we define * `LinearMap σ M M₂`, `M →ₛₗ[σ] M₂` : a semilinear map between two `Module`s. Here, `σ` is a `RingHom` from `R` to `R₂` and an `f : M →ₛₗ[σ] M₂` satisfies `f (c • x) = (σ c) • (f x)`. We recover plain linear maps by choosing `σ` to be `RingHom.id R`. This is denoted by `M →ₗ[R] M₂`. We also add the notation `M →ₗ⋆[R] M₂` for star-linear maps. * `IsLinearMap R f` : predicate saying that `f : M → M₂` is a linear map. (Note that this was not generalized to semilinear maps.) We then provide `LinearMap` with the following instances: * `LinearMap.addCommMonoid` and `LinearMap.addCommGroup`: the elementwise addition structures corresponding to addition in the codomain * `LinearMap.distribMulAction` and `LinearMap.module`: the elementwise scalar action structures corresponding to applying the action in the codomain. ## Implementation notes To ensure that composition works smoothly for semilinear maps, we use the typeclasses `RingHomCompTriple`, `RingHomInvPair` and `RingHomSurjective` from `Mathlib.Algebra.Ring.CompTypeclasses`. ## Notation * Throughout the file, we denote regular linear maps by `fₗ`, `gₗ`, etc, and semilinear maps by `f`, `g`, etc. ## TODO * Parts of this file have not yet been generalized to semilinear maps (i.e. `CompatibleSMul`) ## Tags linear map -/ assert_not_exists Star assert_not_exists DomMulAct assert_not_exists Pi.module assert_not_exists WCovBy assert_not_exists Field open Function universe u u' v w x y z variable {R R₁ R₂ R₃ k S S₃ T M M₁ M₂ M₃ N₁ N₂ N₃ ι : Type*} /-- A map `f` between modules over a semiring is linear if it satisfies the two properties `f (x + y) = f x + f y` and `f (c • x) = c • f x`. The predicate `IsLinearMap R f` asserts this property. A bundled version is available with `LinearMap`, and should be favored over `IsLinearMap` most of the time. -/ structure IsLinearMap (R : Type u) {M : Type v} {M₂ : Type w} [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R M₂] (f : M → M₂) : Prop where /-- A linear map preserves addition. -/ map_add : ∀ x y, f (x + y) = f x + f y /-- A linear map preserves scalar multiplication. -/ map_smul : ∀ (c : R) (x), f (c • x) = c • f x section /-- A map `f` between an `R`-module and an `S`-module over a ring homomorphism `σ : R →+* S` is semilinear if it satisfies the two properties `f (x + y) = f x + f y` and `f (c • x) = (σ c) • f x`. Elements of `LinearMap σ M M₂` (available under the notation `M →ₛₗ[σ] M₂`) are bundled versions of such maps. For plain linear maps (i.e. for which `σ = RingHom.id R`), the notation `M →ₗ[R] M₂` is available. An unbundled version of plain linear maps is available with the predicate `IsLinearMap`, but it should be avoided most of the time. -/ structure LinearMap {R S : Type*} [Semiring R] [Semiring S] (σ : R →+* S) (M : Type*) (M₂ : Type*) [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] extends AddHom M M₂, MulActionHom σ M M₂ /-- The `MulActionHom` underlying a `LinearMap`. -/ add_decl_doc LinearMap.toMulActionHom /-- The `AddHom` underlying a `LinearMap`. -/ add_decl_doc LinearMap.toAddHom /-- `M →ₛₗ[σ] N` is the type of `σ`-semilinear maps from `M` to `N`. -/ notation:25 M " →ₛₗ[" σ:25 "] " M₂:0 => LinearMap σ M M₂ /-- `M →ₗ[R] N` is the type of `R`-linear maps from `M` to `N`. -/ notation:25 M " →ₗ[" R:25 "] " M₂:0 => LinearMap (RingHom.id R) M M₂ /-- `SemilinearMapClass F σ M M₂` asserts `F` is a type of bundled `σ`-semilinear maps `M → M₂`. See also `LinearMapClass F R M M₂` for the case where `σ` is the identity map on `R`. A map `f` between an `R`-module and an `S`-module over a ring homomorphism `σ : R →+* S` is semilinear if it satisfies the two properties `f (x + y) = f x + f y` and `f (c • x) = (σ c) • f x`. -/ class SemilinearMapClass (F : Type*) {R S : outParam Type*} [Semiring R] [Semiring S] (σ : outParam (R →+* S)) (M M₂ : outParam Type*) [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] [FunLike F M M₂] extends AddHomClass F M M₂, MulActionSemiHomClass F σ M M₂ : Prop end -- Porting note: `dangerousInstance` linter has become smarter about `outParam`s -- `σ` becomes a metavariable but that's fine because it's an `outParam` -- attribute [nolint dangerousInstance] SemilinearMapClass.toAddHomClass -- `map_smulₛₗ` should be `@[simp]` but doesn't fire due to `lean4#3701`. -- attribute [simp] map_smulₛₗ /-- `LinearMapClass F R M M₂` asserts `F` is a type of bundled `R`-linear maps `M → M₂`. This is an abbreviation for `SemilinearMapClass F (RingHom.id R) M M₂`. -/ abbrev LinearMapClass (F : Type*) (R : outParam Type*) (M M₂ : Type*) [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R M₂] [FunLike F M M₂] := SemilinearMapClass F (RingHom.id R) M M₂ @[simp high] protected lemma LinearMapClass.map_smul {R M M₂ : outParam Type*} [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R M₂] {F : Type*} [FunLike F M M₂] [LinearMapClass F R M M₂] (f : F) (r : R) (x : M) : f (r • x) = r • f x := by rw [_root_.map_smul] namespace SemilinearMapClass variable (F : Type*) variable [Semiring R] [Semiring S] variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R M₂] [Module S M₃] variable {σ : R →+* S} -- Porting note: the `dangerousInstance` linter has become smarter about `outParam`s instance (priority := 100) instAddMonoidHomClass [FunLike F M M₃] [SemilinearMapClass F σ M M₃] : AddMonoidHomClass F M M₃ := { SemilinearMapClass.toAddHomClass with map_zero := fun f ↦ show f 0 = 0 by rw [← zero_smul R (0 : M), map_smulₛₗ] simp } instance (priority := 100) distribMulActionSemiHomClass [FunLike F M M₃] [SemilinearMapClass F σ M M₃] : DistribMulActionSemiHomClass F σ M M₃ := { SemilinearMapClass.toAddHomClass with map_smulₛₗ := fun f c x ↦ by rw [map_smulₛₗ] } variable {F} (f : F) [FunLike F M M₃] [SemilinearMapClass F σ M M₃] theorem map_smul_inv {σ' : S →+* R} [RingHomInvPair σ σ'] (c : S) (x : M) : c • f x = f (σ' c • x) := by simp [map_smulₛₗ _] /-- Reinterpret an element of a type of semilinear maps as a semilinear map. -/ @[coe] def semilinearMap : M →ₛₗ[σ] M₃ where toFun := f map_add' := map_add f map_smul' := map_smulₛₗ f /-- Reinterpret an element of a type of semilinear maps as a semilinear map. -/ instance instCoeToSemilinearMap : CoeHead F (M →ₛₗ[σ] M₃) where coe f := semilinearMap f end SemilinearMapClass namespace LinearMapClass variable {F : Type*} [Semiring R] [AddCommMonoid M₁] [AddCommMonoid M₂] [Module R M₁] [Module R M₂] (f : F) [FunLike F M₁ M₂] [LinearMapClass F R M₁ M₂] /-- Reinterpret an element of a type of linear maps as a linear map. -/ abbrev linearMap : M₁ →ₗ[R] M₂ := SemilinearMapClass.semilinearMap f /-- Reinterpret an element of a type of linear maps as a linear map. -/ instance instCoeToLinearMap : CoeHead F (M₁ →ₗ[R] M₂) where coe f := SemilinearMapClass.semilinearMap f end LinearMapClass namespace LinearMap section AddCommMonoid variable [Semiring R] [Semiring S] section variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [AddCommMonoid N₁] [AddCommMonoid N₂] [AddCommMonoid N₃] variable [Module R M] [Module R M₂] [Module S M₃] variable {σ : R →+* S} instance instFunLike : FunLike (M →ₛₗ[σ] M₃) M M₃ where coe f := f.toFun coe_injective' f g h := by cases f cases g congr apply DFunLike.coe_injective' exact h instance semilinearMapClass : SemilinearMapClass (M →ₛₗ[σ] M₃) σ M M₃ where map_add f := f.map_add' map_smulₛₗ := LinearMap.map_smul' @[simp, norm_cast] lemma coe_coe {F : Type*} [FunLike F M M₃] [SemilinearMapClass F σ M M₃] {f : F} : ⇑(f : M →ₛₗ[σ] M₃) = f := rfl -- Porting note: we don't port specialized `CoeFun` instances if there is `DFunLike` instead /-- The `DistribMulActionHom` underlying a `LinearMap`. -/ def toDistribMulActionHom (f : M →ₛₗ[σ] M₃) : DistribMulActionHom σ.toMonoidHom M M₃ := { f with map_zero' := show f 0 = 0 from map_zero f } @[simp] theorem coe_toAddHom (f : M →ₛₗ[σ] M₃) : ⇑f.toAddHom = f := rfl -- Porting note: no longer a `simp` theorem toFun_eq_coe {f : M →ₛₗ[σ] M₃} : f.toFun = (f : M → M₃) := rfl @[ext] theorem ext {f g : M →ₛₗ[σ] M₃} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h /-- Copy of a `LinearMap` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (f : M →ₛₗ[σ] M₃) (f' : M → M₃) (h : f' = ⇑f) : M →ₛₗ[σ] M₃ where toFun := f' map_add' := h.symm ▸ f.map_add' map_smul' := h.symm ▸ f.map_smul' @[simp] theorem coe_copy (f : M →ₛₗ[σ] M₃) (f' : M → M₃) (h : f' = ⇑f) : ⇑(f.copy f' h) = f' := rfl theorem copy_eq (f : M →ₛₗ[σ] M₃) (f' : M → M₃) (h : f' = ⇑f) : f.copy f' h = f := DFunLike.ext' h initialize_simps_projections LinearMap (toFun → apply) @[simp] theorem coe_mk {σ : R →+* S} (f : AddHom M M₃) (h) : ((LinearMap.mk f h : M →ₛₗ[σ] M₃) : M → M₃) = f := rfl -- Porting note: This theorem is new. @[simp] theorem coe_addHom_mk {σ : R →+* S} (f : AddHom M M₃) (h) : ((LinearMap.mk f h : M →ₛₗ[σ] M₃) : AddHom M M₃) = f := rfl theorem coe_semilinearMap {F : Type*} [FunLike F M M₃] [SemilinearMapClass F σ M M₃] (f : F) : ((f : M →ₛₗ[σ] M₃) : M → M₃) = f := rfl theorem toLinearMap_injective {F : Type*} [FunLike F M M₃] [SemilinearMapClass F σ M M₃] {f g : F} (h : (f : M →ₛₗ[σ] M₃) = (g : M →ₛₗ[σ] M₃)) : f = g := by apply DFunLike.ext intro m exact DFunLike.congr_fun h m /-- Identity map as a `LinearMap` -/ def id : M →ₗ[R] M := { DistribMulActionHom.id R with toFun := _root_.id } theorem id_apply (x : M) : @id R M _ _ _ x = x := rfl @[simp, norm_cast] theorem id_coe : ((LinearMap.id : M →ₗ[R] M) : M → M) = _root_.id := rfl /-- A generalisation of `LinearMap.id` that constructs the identity function as a `σ`-semilinear map for any ring homomorphism `σ` which we know is the identity. -/ @[simps] def id' {σ : R →+* R} [RingHomId σ] : M →ₛₗ[σ] M where toFun x := x map_add' x y := rfl map_smul' r x := by have := (RingHomId.eq_id : σ = _) subst this rfl @[simp, norm_cast] theorem id'_coe {σ : R →+* R} [RingHomId σ] : ((id' : M →ₛₗ[σ] M) : M → M) = _root_.id := rfl end section variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [AddCommMonoid N₁] [AddCommMonoid N₂] [AddCommMonoid N₃] variable [Module R M] [Module R M₂] [Module S M₃] variable (σ : R →+* S) variable (fₗ gₗ : M →ₗ[R] M₂) (f g : M →ₛₗ[σ] M₃) theorem isLinear : IsLinearMap R fₗ := ⟨fₗ.map_add', fₗ.map_smul'⟩ variable {fₗ gₗ f g σ} theorem coe_injective : Injective (DFunLike.coe : (M →ₛₗ[σ] M₃) → _) := DFunLike.coe_injective protected theorem congr_arg {x x' : M} : x = x' → f x = f x' := DFunLike.congr_arg f /-- If two linear maps are equal, they are equal at each point. -/ protected theorem congr_fun (h : f = g) (x : M) : f x = g x := DFunLike.congr_fun h x @[simp] theorem mk_coe (f : M →ₛₗ[σ] M₃) (h) : (LinearMap.mk f h : M →ₛₗ[σ] M₃) = f := ext fun _ ↦ rfl variable (fₗ gₗ f g) protected theorem map_add (x y : M) : f (x + y) = f x + f y := map_add f x y protected theorem map_zero : f 0 = 0 := map_zero f -- Porting note: `simp` wasn't picking up `map_smulₛₗ` for `LinearMap`s without specifying -- `map_smulₛₗ f`, so we marked this as `@[simp]` in Mathlib3. -- For Mathlib4, let's try without the `@[simp]` attribute and hope it won't need to be re-enabled. -- This has to be re-tagged as `@[simp]` in #8386 (see also leanprover/lean4#3107). @[simp] protected theorem map_smulₛₗ (c : R) (x : M) : f (c • x) = σ c • f x := map_smulₛₗ f c x protected theorem map_smul (c : R) (x : M) : fₗ (c • x) = c • fₗ x := map_smul fₗ c x protected theorem map_smul_inv {σ' : S →+* R} [RingHomInvPair σ σ'] (c : S) (x : M) : c • f x = f (σ' c • x) := by simp @[simp] theorem map_eq_zero_iff (h : Function.Injective f) {x : M} : f x = 0 ↔ x = 0 := _root_.map_eq_zero_iff f h variable (M M₂) /-- A typeclass for `SMul` structures which can be moved through a `LinearMap`. This typeclass is generated automatically from an `IsScalarTower` instance, but exists so that we can also add an instance for `AddCommGroup.toIntModule`, allowing `z •` to be moved even if `S` does not support negation. -/ class CompatibleSMul (R S : Type*) [Semiring S] [SMul R M] [Module S M] [SMul R M₂] [Module S M₂] : Prop where /-- Scalar multiplication by `R` of `M` can be moved through linear maps. -/ map_smul : ∀ (fₗ : M →ₗ[S] M₂) (c : R) (x : M), fₗ (c • x) = c • fₗ x variable {M M₂} section variable {R S : Type*} [Semiring S] [SMul R M] [Module S M] [SMul R M₂] [Module S M₂] instance (priority := 100) IsScalarTower.compatibleSMul [SMul R S] [IsScalarTower R S M] [IsScalarTower R S M₂] : CompatibleSMul M M₂ R S := ⟨fun fₗ c x ↦ by rw [← smul_one_smul S c x, ← smul_one_smul S c (fₗ x), map_smul]⟩ instance IsScalarTower.compatibleSMul' [SMul R S] [IsScalarTower R S M] : CompatibleSMul S M R S where map_smul := (IsScalarTower.smulHomClass R S M (S →ₗ[S] M)).map_smulₛₗ @[simp] theorem map_smul_of_tower [CompatibleSMul M M₂ R S] (fₗ : M →ₗ[S] M₂) (c : R) (x : M) : fₗ (c • x) = c • fₗ x := CompatibleSMul.map_smul fₗ c x variable (R R) in theorem isScalarTower_of_injective [SMul R S] [CompatibleSMul M M₂ R S] [IsScalarTower R S M₂] (f : M →ₗ[S] M₂) (hf : Function.Injective f) : IsScalarTower R S M where smul_assoc r s _ := hf <| by rw [f.map_smul_of_tower r, map_smul, map_smul, smul_assoc] end variable (R) in theorem isLinearMap_of_compatibleSMul [Module S M] [Module S M₂] [CompatibleSMul M M₂ R S] (f : M →ₗ[S] M₂) : IsLinearMap R f where map_add := map_add f map_smul := map_smul_of_tower f /-- convert a linear map to an additive map -/ def toAddMonoidHom : M →+ M₃ where toFun := f map_zero' := f.map_zero map_add' := f.map_add @[simp] theorem toAddMonoidHom_coe : ⇑f.toAddMonoidHom = f := rfl section RestrictScalars variable (R) variable [Module S M] [Module S M₂] [CompatibleSMul M M₂ R S] /-- If `M` and `M₂` are both `R`-modules and `S`-modules and `R`-module structures are defined by an action of `R` on `S` (formally, we have two scalar towers), then any `S`-linear map from `M` to `M₂` is `R`-linear. See also `LinearMap.map_smul_of_tower`. -/ @[coe] def restrictScalars (fₗ : M →ₗ[S] M₂) : M →ₗ[R] M₂ where toFun := fₗ map_add' := fₗ.map_add map_smul' := fₗ.map_smul_of_tower -- Porting note: generalized from `Algebra` to `CompatibleSMul` instance coeIsScalarTower : CoeHTCT (M →ₗ[S] M₂) (M →ₗ[R] M₂) := ⟨restrictScalars R⟩ @[simp, norm_cast] theorem coe_restrictScalars (f : M →ₗ[S] M₂) : ((f : M →ₗ[R] M₂) : M → M₂) = f := rfl theorem restrictScalars_apply (fₗ : M →ₗ[S] M₂) (x) : restrictScalars R fₗ x = fₗ x := rfl theorem restrictScalars_injective : Function.Injective (restrictScalars R : (M →ₗ[S] M₂) → M →ₗ[R] M₂) := fun _ _ h ↦ ext (LinearMap.congr_fun h : _) @[simp] theorem restrictScalars_inj (fₗ gₗ : M →ₗ[S] M₂) : fₗ.restrictScalars R = gₗ.restrictScalars R ↔ fₗ = gₗ := (restrictScalars_injective R).eq_iff end RestrictScalars theorem toAddMonoidHom_injective : Function.Injective (toAddMonoidHom : (M →ₛₗ[σ] M₃) → M →+ M₃) := fun fₗ gₗ h ↦ ext <| (DFunLike.congr_fun h : ∀ x, fₗ.toAddMonoidHom x = gₗ.toAddMonoidHom x) /-- If two `σ`-linear maps from `R` are equal on `1`, then they are equal. -/ @[ext high] theorem ext_ring {f g : R →ₛₗ[σ] M₃} (h : f 1 = g 1) : f = g := ext fun x ↦ by rw [← mul_one x, ← smul_eq_mul, f.map_smulₛₗ, g.map_smulₛₗ, h] @[ext high] theorem ext_ring_op {σ : Rᵐᵒᵖ →+* S} {f g : R →ₛₗ[σ] M₃} (h : f (1 : R) = g (1 : R)) : f = g := ext fun x ↦ by -- Porting note: replaced the oneliner `rw` proof with a partially term-mode proof -- because `rw` was giving "motive is type incorrect" errors rw [← one_mul x, ← op_smul_eq_mul] refine (f.map_smulₛₗ (MulOpposite.op x) 1).trans ?_ rw [h] exact (g.map_smulₛₗ (MulOpposite.op x) 1).symm end /-- Interpret a `RingHom` `f` as an `f`-semilinear map. -/ @[simps] def _root_.RingHom.toSemilinearMap (f : R →+* S) : R →ₛₗ[f] S := { f with map_smul' := f.map_mul } section variable [Semiring R₁] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃] variable {module_M₁ : Module R₁ M₁} {module_M₂ : Module R₂ M₂} {module_M₃ : Module R₃ M₃} variable {σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R₁ →+* R₃} /-- Composition of two linear maps is a linear map -/ def comp [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] (f : M₂ →ₛₗ[σ₂₃] M₃) (g : M₁ →ₛₗ[σ₁₂] M₂) : M₁ →ₛₗ[σ₁₃] M₃ where toFun := f ∘ g map_add' := by simp only [map_add, forall_const, Function.comp_apply] -- Note that #8386 changed `map_smulₛₗ` to `map_smulₛₗ _` map_smul' r x := by simp only [Function.comp_apply, map_smulₛₗ _, RingHomCompTriple.comp_apply] variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable (f : M₂ →ₛₗ[σ₂₃] M₃) (g : M₁ →ₛₗ[σ₁₂] M₂) /-- `∘ₗ` is notation for composition of two linear (not semilinear!) maps into a linear map. This is useful when Lean is struggling to infer the `RingHomCompTriple` instance. -/ notation3:80 (name := compNotation) f:81 " ∘ₗ " g:80 => LinearMap.comp (σ₁₂ := RingHom.id _) (σ₂₃ := RingHom.id _) (σ₁₃ := RingHom.id _) f g theorem comp_apply (x : M₁) : f.comp g x = f (g x) := rfl @[simp, norm_cast] theorem coe_comp : (f.comp g : M₁ → M₃) = f ∘ g := rfl @[simp] theorem comp_id : f.comp id = f := LinearMap.ext fun _ ↦ rfl @[simp] theorem id_comp : id.comp f = f := LinearMap.ext fun _ ↦ rfl theorem comp_assoc {R₄ M₄ : Type*} [Semiring R₄] [AddCommMonoid M₄] [Module R₄ M₄] {σ₃₄ : R₃ →+* R₄} {σ₂₄ : R₂ →+* R₄} {σ₁₄ : R₁ →+* R₄} [RingHomCompTriple σ₂₃ σ₃₄ σ₂₄] [RingHomCompTriple σ₁₃ σ₃₄ σ₁₄] [RingHomCompTriple σ₁₂ σ₂₄ σ₁₄] (f : M₁ →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] M₃) (h : M₃ →ₛₗ[σ₃₄] M₄) : ((h.comp g : M₂ →ₛₗ[σ₂₄] M₄).comp f : M₁ →ₛₗ[σ₁₄] M₄) = h.comp (g.comp f : M₁ →ₛₗ[σ₁₃] M₃) := rfl variable {f g} {f' : M₂ →ₛₗ[σ₂₃] M₃} {g' : M₁ →ₛₗ[σ₁₂] M₂} /-- The linear map version of `Function.Surjective.injective_comp_right` -/ lemma _root_.Function.Surjective.injective_linearMapComp_right (hg : Surjective g) : Injective fun f : M₂ →ₛₗ[σ₂₃] M₃ ↦ f.comp g := fun _ _ h ↦ ext <| hg.forall.2 (LinearMap.ext_iff.1 h) @[simp] theorem cancel_right (hg : Surjective g) : f.comp g = f'.comp g ↔ f = f' := hg.injective_linearMapComp_right.eq_iff /-- The linear map version of `Function.Injective.comp_left` -/ lemma _root_.Function.Injective.injective_linearMapComp_left (hf : Injective f) : Injective fun g : M₁ →ₛₗ[σ₁₂] M₂ ↦ f.comp g := fun g₁ g₂ (h : f.comp g₁ = f.comp g₂) ↦ ext fun x ↦ hf <| by rw [← comp_apply, h, comp_apply] @[simp] theorem cancel_left (hf : Injective f) : f.comp g = f.comp g' ↔ g = g' := hf.injective_linearMapComp_left.eq_iff end variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃] /-- If a function `g` is a left and right inverse of a linear map `f`, then `g` is linear itself. -/ def inverse [Module R M] [Module S M₂] {σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] (f : M →ₛₗ[σ] M₂) (g : M₂ → M) (h₁ : LeftInverse g f) (h₂ : RightInverse g f) : M₂ →ₛₗ[σ'] M := by dsimp [LeftInverse, Function.RightInverse] at h₁ h₂ exact { toFun := g map_add' := fun x y ↦ by rw [← h₁ (g (x + y)), ← h₁ (g x + g y)]; simp [h₂] map_smul' := fun a b ↦ by dsimp only rw [← h₁ (g (a • b)), ← h₁ (σ' a • g b)] simp [h₂] } end AddCommMonoid section AddCommGroup variable [Semiring R] [Semiring S] [AddCommGroup M] [AddCommGroup M₂] variable {module_M : Module R M} {module_M₂ : Module S M₂} {σ : R →+* S} variable (f : M →ₛₗ[σ] M₂) protected theorem map_neg (x : M) : f (-x) = -f x := map_neg f x protected theorem map_sub (x y : M) : f (x - y) = f x - f y := map_sub f x y instance CompatibleSMul.intModule {S : Type*} [Semiring S] [Module S M] [Module S M₂] : CompatibleSMul M M₂ ℤ S := ⟨fun fₗ c x ↦ by induction c using Int.induction_on with | hz => simp | hp n ih => simp [add_smul, ih] | hn n ih => simp [sub_smul, ih]⟩ instance CompatibleSMul.units {R S : Type*} [Monoid R] [MulAction R M] [MulAction R M₂] [Semiring S] [Module S M] [Module S M₂] [CompatibleSMul M M₂ R S] : CompatibleSMul M M₂ Rˣ S := ⟨fun fₗ c x ↦ (CompatibleSMul.map_smul fₗ (c : R) x : _)⟩ end AddCommGroup end LinearMap namespace Module /-- `g : R →+* S` is `R`-linear when the module structure on `S` is `Module.compHom S g` . -/ @[simps] def compHom.toLinearMap {R S : Type*} [Semiring R] [Semiring S] (g : R →+* S) : letI := compHom S g; R →ₗ[R] S := letI := compHom S g { toFun := (g : R → S) map_add' := g.map_add map_smul' := g.map_mul } end Module namespace DistribMulActionHom variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Semiring R] [Module R M] [Semiring S] [Module S M₂] [Module R M₃] variable {σ : R →+* S} /-- A `DistribMulActionHom` between two modules is a linear map. -/ @[coe] def toSemilinearMap (fₗ : M →ₑ+[σ.toMonoidHom] M₂) : M →ₛₗ[σ] M₂ := { fₗ with } instance : SemilinearMapClass (M →ₑ+[σ.toMonoidHom] M₂) σ M M₂ where instance instCoeTCSemilinearMap : CoeTC (M →ₑ+[σ.toMonoidHom] M₂) (M →ₛₗ[σ] M₂) := ⟨toSemilinearMap⟩ /-- A `DistribMulActionHom` between two modules is a linear map. -/ def toLinearMap (fₗ : M →+[R] M₃) : M →ₗ[R] M₃ := { fₗ with } instance instCoeTCLinearMap : CoeTC (M →+[R] M₃) (M →ₗ[R] M₃) := ⟨toLinearMap⟩ /-- A `DistribMulActionHom` between two modules is a linear map. -/ instance : LinearMapClass (M →+[R] M₃) R M M₃ where -- Porting note: because coercions get unfolded, there is no need for this rewrite -- Porting note: removed @[norm_cast] attribute due to error: -- norm_cast: badly shaped lemma, rhs can't start with coe @[simp] theorem coe_toLinearMap (f : M →ₑ+[σ.toMonoidHom] M₂) : ((f : M →ₛₗ[σ] M₂) : M → M₂) = f := rfl theorem toLinearMap_injective {f g : M →ₑ+[σ.toMonoidHom] M₂} (h : (f : M →ₛₗ[σ] M₂) = (g : M →ₛₗ[σ] M₂)) : f = g := by ext m exact LinearMap.congr_fun h m end DistribMulActionHom namespace IsLinearMap section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] variable [Module R M] [Module R M₂] /-- Convert an `IsLinearMap` predicate to a `LinearMap` -/ def mk' (f : M → M₂) (lin : IsLinearMap R f) : M →ₗ[R] M₂ where toFun := f map_add' := lin.1 map_smul' := lin.2 @[simp] theorem mk'_apply {f : M → M₂} (lin : IsLinearMap R f) (x : M) : mk' f lin x = f x := rfl theorem isLinearMap_smul {R M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] (c : R) : IsLinearMap R fun z : M ↦ c • z := by refine IsLinearMap.mk (smul_add c) ?_ intro _ _ simp only [smul_smul, mul_comm] theorem isLinearMap_smul' {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] (a : M) : IsLinearMap R fun c : R ↦ c • a := IsLinearMap.mk (fun x y ↦ add_smul x y a) fun x y ↦ mul_smul x y a theorem map_zero {f : M → M₂} (lin : IsLinearMap R f) : f (0 : M) = (0 : M₂) := (lin.mk' f).map_zero end AddCommMonoid section AddCommGroup variable [Semiring R] [AddCommGroup M] [AddCommGroup M₂] variable [Module R M] [Module R M₂] theorem isLinearMap_neg : IsLinearMap R fun z : M ↦ -z := IsLinearMap.mk neg_add fun x y ↦ (smul_neg x y).symm theorem map_neg {f : M → M₂} (lin : IsLinearMap R f) (x : M) : f (-x) = -f x := (lin.mk' f).map_neg x theorem map_sub {f : M → M₂} (lin : IsLinearMap R f) (x y : M) : f (x - y) = f x - f y := (lin.mk' f).map_sub x y end AddCommGroup end IsLinearMap /-- Reinterpret an additive homomorphism as an `ℕ`-linear map. -/ def AddMonoidHom.toNatLinearMap [AddCommMonoid M] [AddCommMonoid M₂] (f : M →+ M₂) : M →ₗ[ℕ] M₂ where toFun := f map_add' := f.map_add map_smul' := map_nsmul f theorem AddMonoidHom.toNatLinearMap_injective [AddCommMonoid M] [AddCommMonoid M₂] : Function.Injective (@AddMonoidHom.toNatLinearMap M M₂ _ _) := by intro f g h ext x exact LinearMap.congr_fun h x /-- Reinterpret an additive homomorphism as a `ℤ`-linear map. -/ def AddMonoidHom.toIntLinearMap [AddCommGroup M] [AddCommGroup M₂] (f : M →+ M₂) : M →ₗ[ℤ] M₂ where toFun := f map_add' := f.map_add map_smul' := map_zsmul f theorem AddMonoidHom.toIntLinearMap_injective [AddCommGroup M] [AddCommGroup M₂] : Function.Injective (@AddMonoidHom.toIntLinearMap M M₂ _ _) := by intro f g h ext x exact LinearMap.congr_fun h x @[simp] theorem AddMonoidHom.coe_toIntLinearMap [AddCommGroup M] [AddCommGroup M₂] (f : M →+ M₂) : ⇑f.toIntLinearMap = f := rfl namespace LinearMap section SMul variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable [Monoid S] [DistribMulAction S M₂] [SMulCommClass R₂ S M₂] variable [Monoid S₃] [DistribMulAction S₃ M₃] [SMulCommClass R₃ S₃ M₃] variable [Monoid T] [DistribMulAction T M₂] [SMulCommClass R₂ T M₂] instance : SMul S (M →ₛₗ[σ₁₂] M₂) := ⟨fun a f ↦ { toFun := a • (f : M → M₂) map_add' := fun x y ↦ by simp only [Pi.smul_apply, f.map_add, smul_add] map_smul' := fun c x ↦ by simp [Pi.smul_apply, smul_comm] }⟩ @[simp] theorem smul_apply (a : S) (f : M →ₛₗ[σ₁₂] M₂) (x : M) : (a • f) x = a • f x := rfl theorem coe_smul (a : S) (f : M →ₛₗ[σ₁₂] M₂) : (a • f : M →ₛₗ[σ₁₂] M₂) = a • (f : M → M₂) := rfl instance [SMulCommClass S T M₂] : SMulCommClass S T (M →ₛₗ[σ₁₂] M₂) := ⟨fun _ _ _ ↦ ext fun _ ↦ smul_comm _ _ _⟩ -- example application of this instance: if S -> T -> R are homomorphisms of commutative rings and -- M and M₂ are R-modules then the S-module and T-module structures on Hom_R(M,M₂) are compatible. instance [SMul S T] [IsScalarTower S T M₂] : IsScalarTower S T (M →ₛₗ[σ₁₂] M₂) where smul_assoc _ _ _ := ext fun _ ↦ smul_assoc _ _ _ instance [DistribMulAction Sᵐᵒᵖ M₂] [SMulCommClass R₂ Sᵐᵒᵖ M₂] [IsCentralScalar S M₂] : IsCentralScalar S (M →ₛₗ[σ₁₂] M₂) where op_smul_eq_smul _ _ := ext fun _ ↦ op_smul_eq_smul _ _ end SMul /-! ### Arithmetic on the codomain -/ section Arithmetic variable [Semiring R₁] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [AddCommGroup N₁] [AddCommGroup N₂] [AddCommGroup N₃] variable [Module R₁ M] [Module R₂ M₂] [Module R₃ M₃] variable [Module R₁ N₁] [Module R₂ N₂] [Module R₃ N₃] variable {σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R₁ →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] /-- The constant 0 map is linear. -/ instance : Zero (M →ₛₗ[σ₁₂] M₂) := ⟨{ toFun := 0 map_add' := by simp map_smul' := by simp }⟩ @[simp] theorem zero_apply (x : M) : (0 : M →ₛₗ[σ₁₂] M₂) x = 0 := rfl @[simp] theorem comp_zero (g : M₂ →ₛₗ[σ₂₃] M₃) : (g.comp (0 : M →ₛₗ[σ₁₂] M₂) : M →ₛₗ[σ₁₃] M₃) = 0 := ext fun c ↦ by rw [comp_apply, zero_apply, zero_apply, g.map_zero] @[simp] theorem zero_comp (f : M →ₛₗ[σ₁₂] M₂) : ((0 : M₂ →ₛₗ[σ₂₃] M₃).comp f : M →ₛₗ[σ₁₃] M₃) = 0 := rfl instance : Inhabited (M →ₛₗ[σ₁₂] M₂) := ⟨0⟩ @[simp] theorem default_def : (default : M →ₛₗ[σ₁₂] M₂) = 0 := rfl instance uniqueOfLeft [Subsingleton M] : Unique (M →ₛₗ[σ₁₂] M₂) := { inferInstanceAs (Inhabited (M →ₛₗ[σ₁₂] M₂)) with uniq := fun f => ext fun x => by rw [Subsingleton.elim x 0, map_zero, map_zero] } instance uniqueOfRight [Subsingleton M₂] : Unique (M →ₛₗ[σ₁₂] M₂) := coe_injective.unique /-- The sum of two linear maps is linear. -/ instance : Add (M →ₛₗ[σ₁₂] M₂) := ⟨fun f g ↦ { toFun := f + g map_add' := by simp [add_comm, add_left_comm] map_smul' := by simp [smul_add] }⟩ @[simp] theorem add_apply (f g : M →ₛₗ[σ₁₂] M₂) (x : M) : (f + g) x = f x + g x := rfl theorem add_comp (f : M →ₛₗ[σ₁₂] M₂) (g h : M₂ →ₛₗ[σ₂₃] M₃) : ((h + g).comp f : M →ₛₗ[σ₁₃] M₃) = h.comp f + g.comp f := rfl theorem comp_add (f g : M →ₛₗ[σ₁₂] M₂) (h : M₂ →ₛₗ[σ₂₃] M₃) : (h.comp (f + g) : M →ₛₗ[σ₁₃] M₃) = h.comp f + h.comp g := ext fun _ ↦ h.map_add _ _ /-- The type of linear maps is an additive monoid. -/ instance addCommMonoid : AddCommMonoid (M →ₛₗ[σ₁₂] M₂) := DFunLike.coe_injective.addCommMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl /-- The negation of a linear map is linear. -/ instance : Neg (M →ₛₗ[σ₁₂] N₂) := ⟨fun f ↦ { toFun := -f map_add' := by simp [add_comm] map_smul' := by simp }⟩ @[simp] theorem neg_apply (f : M →ₛₗ[σ₁₂] N₂) (x : M) : (-f) x = -f x := rfl @[simp] theorem neg_comp (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] N₃) : (-g).comp f = -g.comp f := rfl @[simp] theorem comp_neg (f : M →ₛₗ[σ₁₂] N₂) (g : N₂ →ₛₗ[σ₂₃] N₃) : g.comp (-f) = -g.comp f := ext fun _ ↦ g.map_neg _ /-- The subtraction of two linear maps is linear. -/ instance : Sub (M →ₛₗ[σ₁₂] N₂) := ⟨fun f g ↦ { toFun := f - g map_add' := fun x y ↦ by simp only [Pi.sub_apply, map_add, add_sub_add_comm] map_smul' := fun r x ↦ by simp [Pi.sub_apply, map_smul, smul_sub] }⟩ @[simp] theorem sub_apply (f g : M →ₛₗ[σ₁₂] N₂) (x : M) : (f - g) x = f x - g x := rfl theorem sub_comp (f : M →ₛₗ[σ₁₂] M₂) (g h : M₂ →ₛₗ[σ₂₃] N₃) : (g - h).comp f = g.comp f - h.comp f := rfl theorem comp_sub (f g : M →ₛₗ[σ₁₂] N₂) (h : N₂ →ₛₗ[σ₂₃] N₃) : h.comp (g - f) = h.comp g - h.comp f := ext fun _ ↦ h.map_sub _ _ /-- The type of linear maps is an additive group. -/ instance addCommGroup : AddCommGroup (M →ₛₗ[σ₁₂] N₂) := DFunLike.coe_injective.addCommGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ _ ↦ rfl /-- Evaluation of a `σ₁₂`-linear map at a fixed `a`, as an `AddMonoidHom`. -/ @[simps] def evalAddMonoidHom (a : M) : (M →ₛₗ[σ₁₂] M₂) →+ M₂ where toFun f := f a map_add' f g := LinearMap.add_apply f g a map_zero' := rfl /-- `LinearMap.toAddMonoidHom` promoted to an `AddMonoidHom`. -/ @[simps] def toAddMonoidHom' : (M →ₛₗ[σ₁₂] M₂) →+ M →+ M₂ where toFun := toAddMonoidHom map_zero' := by ext; rfl map_add' := by intros; ext; rfl /-- If `M` is the zero module, then the identity map of `M` is the zero map. -/ @[simp] theorem identityMapOfZeroModuleIsZero [Subsingleton M] : id (R := R₁) (M := M) = 0 := Subsingleton.eq_zero id end Arithmetic section Actions variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] section SMul variable [Monoid S] [DistribMulAction S M₂] [SMulCommClass R₂ S M₂] variable [Monoid S₃] [DistribMulAction S₃ M₃] [SMulCommClass R₃ S₃ M₃] variable [Monoid T] [DistribMulAction T M₂] [SMulCommClass R₂ T M₂] instance : DistribMulAction S (M →ₛₗ[σ₁₂] M₂) where one_smul _ := ext fun _ ↦ one_smul _ _ mul_smul _ _ _ := ext fun _ ↦ mul_smul _ _ _ smul_add _ _ _ := ext fun _ ↦ smul_add _ _ _ smul_zero _ := ext fun _ ↦ smul_zero _ theorem smul_comp (a : S₃) (g : M₂ →ₛₗ[σ₂₃] M₃) (f : M →ₛₗ[σ₁₂] M₂) : (a • g).comp f = a • g.comp f := rfl -- TODO: generalize this to semilinear maps theorem comp_smul [Module R M₂] [Module R M₃] [SMulCommClass R S M₂] [DistribMulAction S M₃] [SMulCommClass R S M₃] [CompatibleSMul M₃ M₂ S R] (g : M₃ →ₗ[R] M₂) (a : S) (f : M →ₗ[R] M₃) : g.comp (a • f) = a • g.comp f := ext fun _ ↦ g.map_smul_of_tower _ _ end SMul section Module variable [Semiring S] [Module S M] [Module S M₂] [SMulCommClass R₂ S M₂] instance module : Module S (M →ₛₗ[σ₁₂] M₂) where add_smul _ _ _ := ext fun _ ↦ add_smul _ _ _ zero_smul _ := ext fun _ ↦ zero_smul _ _ end Module end Actions section RestrictScalarsAsLinearMap variable {R S M N : Type*} [Semiring R] [Semiring S] [AddCommGroup M] [AddCommGroup N] [Module R M] [Module R N] [Module S M] [Module S N] [LinearMap.CompatibleSMul M N R S] variable (R S M N) in @[simp] lemma restrictScalars_zero : (0 : M →ₗ[S] N).restrictScalars R = 0 := rfl @[simp] theorem restrictScalars_add (f g : M →ₗ[S] N) : (f + g).restrictScalars R = f.restrictScalars R + g.restrictScalars R := rfl @[simp] theorem restrictScalars_neg (f : M →ₗ[S] N) : (-f).restrictScalars R = -f.restrictScalars R := rfl variable {R₁ : Type*} [Semiring R₁] [Module R₁ N] [SMulCommClass S R₁ N] [SMulCommClass R R₁ N] @[simp] theorem restrictScalars_smul (c : R₁) (f : M →ₗ[S] N) : (c • f).restrictScalars R = c • f.restrictScalars R := rfl variable (S M N R R₁) /-- `LinearMap.restrictScalars` as a `LinearMap`. -/ @[simps apply] def restrictScalarsₗ : (M →ₗ[S] N) →ₗ[R₁] M →ₗ[R] N where toFun := restrictScalars R map_add' := restrictScalars_add map_smul' := restrictScalars_smul end RestrictScalarsAsLinearMap end LinearMap
Algebra\Module\LinearMap\End.lean
/- Copyright (c) 2024 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.Module.LinearMap.Defs /-! # Endomorphisms of a module In this file we define the type of linear endomorphisms of a module over a ring (`Module.End`). We set up the basic theory, including the action of `Module.End` on the module we are considering endomorphisms of. ## Main results * `Module.End.semiring` and `Module.End.ring`: the (semi)ring of endomorphisms formed by taking the additive structure above with composition as multiplication. -/ universe u v /-- Linear endomorphisms of a module, with associated ring structure `Module.End.semiring` and algebra structure `Module.End.algebra`. -/ abbrev Module.End (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] [Module R M] := M →ₗ[R] M variable {R R₁ R₂ S M M₁ M₂ M₃ N N₁ N₂ : Type*} namespace LinearMap open Function /-! ## Monoid structure of endomorphisms -/ section Endomorphisms variable [Semiring R] [AddCommMonoid M] [AddCommGroup N₁] [Module R M] [Module R N₁] instance : One (Module.End R M) := ⟨LinearMap.id⟩ instance : Mul (Module.End R M) := ⟨fun f g => LinearMap.comp f g⟩ theorem one_eq_id : (1 : Module.End R M) = id := rfl theorem mul_eq_comp (f g : Module.End R M) : f * g = f.comp g := rfl @[simp] theorem one_apply (x : M) : (1 : Module.End R M) x = x := rfl @[simp] theorem mul_apply (f g : Module.End R M) (x : M) : (f * g) x = f (g x) := rfl theorem coe_one : ⇑(1 : Module.End R M) = _root_.id := rfl theorem coe_mul (f g : Module.End R M) : ⇑(f * g) = f ∘ g := rfl instance _root_.Module.End.instNontrivial [Nontrivial M] : Nontrivial (Module.End R M) := by obtain ⟨m, ne⟩ := exists_ne (0 : M) exact nontrivial_of_ne 1 0 fun p => ne (LinearMap.congr_fun p m) instance _root_.Module.End.monoid : Monoid (Module.End R M) where mul := (· * ·) one := (1 : M →ₗ[R] M) mul_assoc f g h := LinearMap.ext fun x ↦ rfl mul_one := comp_id one_mul := id_comp instance _root_.Module.End.semiring : Semiring (Module.End R M) := { AddMonoidWithOne.unary, Module.End.monoid, LinearMap.addCommMonoid with mul_zero := comp_zero zero_mul := zero_comp left_distrib := fun _ _ _ ↦ comp_add _ _ _ right_distrib := fun _ _ _ ↦ add_comp _ _ _ natCast := fun n ↦ n • (1 : M →ₗ[R] M) natCast_zero := zero_smul ℕ (1 : M →ₗ[R] M) natCast_succ := fun n ↦ AddMonoid.nsmul_succ n (1 : M →ₗ[R] M) } /-- See also `Module.End.natCast_def`. -/ @[simp] theorem _root_.Module.End.natCast_apply (n : ℕ) (m : M) : (↑n : Module.End R M) m = n • m := rfl @[simp] theorem _root_.Module.End.ofNat_apply (n : ℕ) [n.AtLeastTwo] (m : M) : (no_index (OfNat.ofNat n) : Module.End R M) m = OfNat.ofNat n • m := rfl instance _root_.Module.End.ring : Ring (Module.End R N₁) := { Module.End.semiring, LinearMap.addCommGroup with intCast := fun z ↦ z • (1 : N₁ →ₗ[R] N₁) intCast_ofNat := natCast_zsmul _ intCast_negSucc := negSucc_zsmul _ } /-- See also `Module.End.intCast_def`. -/ @[simp] theorem _root_.Module.End.intCast_apply (z : ℤ) (m : N₁) : (z : Module.End R N₁) m = z • m := rfl section variable [Monoid S] [DistribMulAction S M] [SMulCommClass R S M] instance _root_.Module.End.isScalarTower : IsScalarTower S (Module.End R M) (Module.End R M) := ⟨smul_comp⟩ instance _root_.Module.End.smulCommClass [SMul S R] [IsScalarTower S R M] : SMulCommClass S (Module.End R M) (Module.End R M) := ⟨fun s _ _ ↦ (comp_smul _ s _).symm⟩ instance _root_.Module.End.smulCommClass' [SMul S R] [IsScalarTower S R M] : SMulCommClass (Module.End R M) S (Module.End R M) := SMulCommClass.symm _ _ _ theorem _root_.Module.End_isUnit_apply_inv_apply_of_isUnit {f : Module.End R M} (h : IsUnit f) (x : M) : f (h.unit.inv x) = x := show (f * h.unit.inv) x = x by simp theorem _root_.Module.End_isUnit_inv_apply_apply_of_isUnit {f : Module.End R M} (h : IsUnit f) (x : M) : h.unit.inv (f x) = x := (by simp : (h.unit.inv * f) x = x) theorem coe_pow (f : M →ₗ[R] M) (n : ℕ) : ⇑(f ^ n) = f^[n] := hom_coe_pow _ rfl (fun _ _ ↦ rfl) _ _ theorem pow_apply (f : M →ₗ[R] M) (n : ℕ) (m : M) : (f ^ n) m = f^[n] m := congr_fun (coe_pow f n) m theorem pow_map_zero_of_le {f : Module.End R M} {m : M} {k l : ℕ} (hk : k ≤ l) (hm : (f ^ k) m = 0) : (f ^ l) m = 0 := by rw [← Nat.sub_add_cancel hk, pow_add, mul_apply, hm, map_zero] theorem commute_pow_left_of_commute [Semiring R₂] [AddCommMonoid M₂] [Module R₂ M₂] {σ₁₂ : R →+* R₂} {f : M →ₛₗ[σ₁₂] M₂} {g : Module.End R M} {g₂ : Module.End R₂ M₂} (h : g₂.comp f = f.comp g) (k : ℕ) : (g₂ ^ k).comp f = f.comp (g ^ k) := by induction' k with k ih · simp only [Nat.zero_eq, pow_zero, one_eq_id, id_comp, comp_id] · rw [pow_succ', pow_succ', LinearMap.mul_eq_comp, LinearMap.comp_assoc, ih, ← LinearMap.comp_assoc, h, LinearMap.comp_assoc, LinearMap.mul_eq_comp] @[simp] theorem id_pow (n : ℕ) : (id : M →ₗ[R] M) ^ n = id := one_pow n variable {f' : M →ₗ[R] M} theorem iterate_succ (n : ℕ) : f' ^ (n + 1) = comp (f' ^ n) f' := by rw [pow_succ, mul_eq_comp] theorem iterate_surjective (h : Surjective f') : ∀ n : ℕ, Surjective (f' ^ n) | 0 => surjective_id | n + 1 => by rw [iterate_succ] exact (iterate_surjective h n).comp h theorem iterate_injective (h : Injective f') : ∀ n : ℕ, Injective (f' ^ n) | 0 => injective_id | n + 1 => by rw [iterate_succ] exact (iterate_injective h n).comp h theorem iterate_bijective (h : Bijective f') : ∀ n : ℕ, Bijective (f' ^ n) | 0 => bijective_id | n + 1 => by rw [iterate_succ] exact (iterate_bijective h n).comp h theorem injective_of_iterate_injective {n : ℕ} (hn : n ≠ 0) (h : Injective (f' ^ n)) : Injective f' := by rw [← Nat.succ_pred_eq_of_pos (show 0 < n by omega), iterate_succ, coe_comp] at h exact h.of_comp theorem surjective_of_iterate_surjective {n : ℕ} (hn : n ≠ 0) (h : Surjective (f' ^ n)) : Surjective f' := by rw [← Nat.succ_pred_eq_of_pos (Nat.pos_iff_ne_zero.mpr hn), pow_succ', coe_mul] at h exact Surjective.of_comp h end /-! ## Action by a module endomorphism. -/ /-- The tautological action by `Module.End R M` (aka `M →ₗ[R] M`) on `M`. This generalizes `Function.End.applyMulAction`. -/ instance applyModule : Module (Module.End R M) M where smul := (· <| ·) smul_zero := LinearMap.map_zero smul_add := LinearMap.map_add add_smul := LinearMap.add_apply zero_smul := (LinearMap.zero_apply : ∀ m, (0 : M →ₗ[R] M) m = 0) one_smul _ := rfl mul_smul _ _ _ := rfl @[simp] protected theorem smul_def (f : Module.End R M) (a : M) : f • a = f a := rfl /-- `LinearMap.applyModule` is faithful. -/ instance apply_faithfulSMul : FaithfulSMul (Module.End R M) M := ⟨LinearMap.ext⟩ instance apply_smulCommClass [SMul S R] [SMul S M] [IsScalarTower S R M] : SMulCommClass S (Module.End R M) M where smul_comm r e m := (e.map_smul_of_tower r m).symm instance apply_smulCommClass' [SMul S R] [SMul S M] [IsScalarTower S R M] : SMulCommClass (Module.End R M) S M := SMulCommClass.symm _ _ _ instance apply_isScalarTower [Monoid S] [DistribMulAction S M] [SMulCommClass R S M] : IsScalarTower S (Module.End R M) M := ⟨fun _ _ _ ↦ rfl⟩ end Endomorphisms end LinearMap /-! ## Actions as module endomorphisms -/ namespace DistribMulAction variable (R M) [Semiring R] [AddCommMonoid M] [Module R M] variable [Monoid S] [DistribMulAction S M] [SMulCommClass S R M] /-- Each element of the monoid defines a linear map. This is a stronger version of `DistribMulAction.toAddMonoidHom`. -/ @[simps] def toLinearMap (s : S) : M →ₗ[R] M where toFun := HSMul.hSMul s map_add' := smul_add s map_smul' _ _ := smul_comm _ _ _ /-- Each element of the monoid defines a module endomorphism. This is a stronger version of `DistribMulAction.toAddMonoidEnd`. -/ @[simps] def toModuleEnd : S →* Module.End R M where toFun := toLinearMap R M map_one' := LinearMap.ext <| one_smul _ map_mul' _ _ := LinearMap.ext <| mul_smul _ _ end DistribMulAction namespace Module variable (R M) [Semiring R] [AddCommMonoid M] [Module R M] variable [Semiring S] [Module S M] [SMulCommClass S R M] /-- Each element of the semiring defines a module endomorphism. This is a stronger version of `DistribMulAction.toModuleEnd`. -/ @[simps] def toModuleEnd : S →+* Module.End R M := { DistribMulAction.toModuleEnd R M with toFun := DistribMulAction.toLinearMap R M map_zero' := LinearMap.ext <| zero_smul S map_add' := fun _ _ ↦ LinearMap.ext <| add_smul _ _ } /-- The canonical (semi)ring isomorphism from `Rᵐᵒᵖ` to `Module.End R R` induced by the right multiplication. -/ @[simps] def moduleEndSelf : Rᵐᵒᵖ ≃+* Module.End R R := { Module.toModuleEnd R R with toFun := DistribMulAction.toLinearMap R R invFun := fun f ↦ MulOpposite.op (f 1) left_inv := mul_one right_inv := fun _ ↦ LinearMap.ext_ring <| one_mul _ } /-- The canonical (semi)ring isomorphism from `R` to `Module.End Rᵐᵒᵖ R` induced by the left multiplication. -/ @[simps] def moduleEndSelfOp : R ≃+* Module.End Rᵐᵒᵖ R := { Module.toModuleEnd _ _ with toFun := DistribMulAction.toLinearMap _ _ invFun := fun f ↦ f 1 left_inv := mul_one right_inv := fun _ ↦ LinearMap.ext_ring_op <| mul_one _ } theorem End.natCast_def (n : ℕ) [AddCommMonoid N₁] [Module R N₁] : (↑n : Module.End R N₁) = Module.toModuleEnd R N₁ n := rfl theorem End.intCast_def (z : ℤ) [AddCommGroup N₁] [Module R N₁] : (z : Module.End R N₁) = Module.toModuleEnd R N₁ z := rfl end Module namespace LinearMap section AddCommMonoid section SMulRight variable [Semiring R] [Semiring R₂] [AddCommMonoid M] [AddCommMonoid M₁] [Module R M] [Module R M₁] variable [Semiring S] [Module R S] [Module S M] [IsScalarTower R S M] /-- When `f` is an `R`-linear map taking values in `S`, then `fun b ↦ f b • x` is an `R`-linear map. -/ def smulRight (f : M₁ →ₗ[R] S) (x : M) : M₁ →ₗ[R] M where toFun b := f b • x map_add' x y := by dsimp only; rw [f.map_add, add_smul] map_smul' b y := by dsimp; rw [map_smul, smul_assoc] @[simp] theorem coe_smulRight (f : M₁ →ₗ[R] S) (x : M) : (smulRight f x : M₁ → M) = fun c => f c • x := rfl theorem smulRight_apply (f : M₁ →ₗ[R] S) (x : M) (c : M₁) : smulRight f x c = f c • x := rfl @[simp] lemma smulRight_zero (f : M₁ →ₗ[R] S) : f.smulRight (0 : M) = 0 := by ext; simp @[simp] lemma zero_smulRight (x : M) : (0 : M₁ →ₗ[R] S).smulRight x = 0 := by ext; simp @[simp] lemma smulRight_apply_eq_zero_iff {f : M₁ →ₗ[R] S} {x : M} [NoZeroSMulDivisors S M] : f.smulRight x = 0 ↔ f = 0 ∨ x = 0 := by rcases eq_or_ne x 0 with rfl | hx · simp refine ⟨fun h ↦ Or.inl ?_, fun h ↦ by simp [h.resolve_right hx]⟩ ext v replace h : f v • x = 0 := by simpa only [LinearMap.zero_apply] using LinearMap.congr_fun h v rw [smul_eq_zero] at h tauto end SMulRight end AddCommMonoid section Module variable [Semiring R] [Semiring S] [AddCommMonoid M] [AddCommMonoid M₂] variable [Module R M] [Module R M₂] [Module S M₂] [SMulCommClass R S M₂] variable (S) /-- Applying a linear map at `v : M`, seen as `S`-linear map from `M →ₗ[R] M₂` to `M₂`. See `LinearMap.applyₗ` for a version where `S = R`. -/ @[simps] def applyₗ' : M →+ (M →ₗ[R] M₂) →ₗ[S] M₂ where toFun v := { toFun := fun f => f v map_add' := fun f g => f.add_apply g v map_smul' := fun x f => f.smul_apply x v } map_zero' := LinearMap.ext fun f => f.map_zero map_add' _ _ := LinearMap.ext fun f => f.map_add _ _ end Module section CommSemiring variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R M₂] [Module R M₃] variable (f g : M →ₗ[R] M₂) /-- Composition by `f : M₂ → M₃` is a linear map from the space of linear maps `M → M₂` to the space of linear maps `M → M₃`. -/ def compRight (f : M₂ →ₗ[R] M₃) : (M →ₗ[R] M₂) →ₗ[R] M →ₗ[R] M₃ where toFun g := f.comp g map_add' _ _ := LinearMap.ext fun _ => map_add f _ _ map_smul' _ _ := LinearMap.ext fun _ => map_smul f _ _ @[simp] theorem compRight_apply (f : M₂ →ₗ[R] M₃) (g : M →ₗ[R] M₂) : compRight f g = f.comp g := rfl /-- Applying a linear map at `v : M`, seen as a linear map from `M →ₗ[R] M₂` to `M₂`. See also `LinearMap.applyₗ'` for a version that works with two different semirings. This is the `LinearMap` version of `toAddMonoidHom.eval`. -/ @[simps] def applyₗ : M →ₗ[R] (M →ₗ[R] M₂) →ₗ[R] M₂ := { applyₗ' R with toFun := fun v => { applyₗ' R v with toFun := fun f => f v } map_smul' := fun _ _ => LinearMap.ext fun f => map_smul f _ _ } /-- The family of linear maps `M₂ → M` parameterised by `f ∈ M₂ → R`, `x ∈ M`, is linear in `f`, `x`. -/ def smulRightₗ : (M₂ →ₗ[R] R) →ₗ[R] M →ₗ[R] M₂ →ₗ[R] M where toFun f := { toFun := LinearMap.smulRight f map_add' := fun m m' => by ext apply smul_add map_smul' := fun c m => by ext apply smul_comm } map_add' f f' := by ext apply add_smul map_smul' c f := by ext apply mul_smul @[simp] theorem smulRightₗ_apply (f : M₂ →ₗ[R] R) (x : M) (c : M₂) : (smulRightₗ : (M₂ →ₗ[R] R) →ₗ[R] M →ₗ[R] M₂ →ₗ[R] M) f x c = f c • x := rfl end CommSemiring end LinearMap
Algebra\Module\LinearMap\Polynomial.lean
/- Copyright (c) 2024 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin -/ import Mathlib.Algebra.MvPolynomial.Monad import Mathlib.LinearAlgebra.Charpoly.ToMatrix import Mathlib.LinearAlgebra.Dimension.Finrank import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition import Mathlib.LinearAlgebra.Matrix.Charpoly.Univ /-! # Characteristic polynomials of linear families of endomorphisms The coefficients of the characteristic polynomials of a linear family of endomorphisms are homogeneous polynomials in the parameters. This result is used in Lie theory to establish the existence of regular elements and Cartan subalgebras, and ultimately a well-defined notion of rank for Lie algebras. In this file we prove this result about characteristic polynomials. Let `L` and `M` be modules over a nontrivial commutative ring `R`, and let `φ : L →ₗ[R] Module.End R M` be a linear map. Let `b` be a basis of `L`, indexed by `ι`. Then we define a multivariate polynomial with variables indexed by `ι` that evaluates on elements `x` of `L` to the characteristic polynomial of `φ x`. ## Main declarations * `Matrix.toMvPolynomial M i`: the family of multivariate polynomials that evaluates on `c : n → R` to the dot product of the `i`-th row of `M` with `c`. `Matrix.toMvPolynomial M i` is the sum of the monomials `C (M i j) * X j`. * `LinearMap.toMvPolynomial b₁ b₂ f`: a version of `Matrix.toMvPolynomial` for linear maps `f` with respect to bases `b₁` and `b₂` of the domain and codomain. * `LinearMap.polyCharpoly`: the multivariate polynomial that evaluates on elements `x` of `L` to the characteristic polynomial of `φ x`. * `LinearMap.polyCharpoly_map_eq_charpoly`: the evaluation of `polyCharpoly` on elements `x` of `L` is the characteristic polynomial of `φ x`. * `LinearMap.polyCharpoly_coeff_isHomogeneous`: the coefficients of `polyCharpoly` are homogeneous polynomials in the parameters. * `LinearMap.nilRank`: the smallest index at which `polyCharpoly` has a non-zero coefficient, which is independent of the choice of basis for `L`. * `LinearMap.IsNilRegular`: an element `x` of `L` is *nil-regular* with respect to `φ` if the `n`-th coefficient of the characteristic polynomial of `φ x` is non-zero, where `n` denotes the nil-rank of `φ`. ## Implementation details We show that `LinearMap.polyCharpoly` does not depend on the choice of basis of the target module. This is done via `LinearMap.polyCharpoly_eq_polyCharpolyAux` and `LinearMap.polyCharpolyAux_basisIndep`. The latter is proven by considering the base change of the `R`-linear map `φ : L →ₗ[R] End R M` to the multivariate polynomial ring `MvPolynomial ι R`, and showing that `polyCharpolyAux φ` is equal to the characteristic polynomial of this base change. The proof concludes because characteristic polynomials are independent of the chosen basis. ## References * [barnes1967]: "On Cartan subalgebras of Lie algebras" by D.W. Barnes. -/ open scoped Matrix namespace Matrix variable {m n o R S : Type*} variable [Fintype n] [Fintype o] [CommSemiring R] [CommSemiring S] open MvPolynomial /-- Let `M` be an `(m × n)`-matrix over `R`. Then `Matrix.toMvPolynomial M` is the family (indexed by `i : m`) of multivariate polynomials in `n` variables over `R` that evaluates on `c : n → R` to the dot product of the `i`-th row of `M` with `c`: `Matrix.toMvPolynomial M i` is the sum of the monomials `C (M i j) * X j`. -/ noncomputable def toMvPolynomial (M : Matrix m n R) (i : m) : MvPolynomial n R := ∑ j, monomial (.single j 1) (M i j) lemma toMvPolynomial_eval_eq_apply (M : Matrix m n R) (i : m) (c : n → R) : eval c (M.toMvPolynomial i) = (M *ᵥ c) i := by simp only [toMvPolynomial, map_sum, eval_monomial, pow_zero, Finsupp.prod_single_index, pow_one, mulVec, dotProduct] lemma toMvPolynomial_map (f : R →+* S) (M : Matrix m n R) (i : m) : (M.map f).toMvPolynomial i = MvPolynomial.map f (M.toMvPolynomial i) := by simp only [toMvPolynomial, map_apply, map_sum, map_monomial] lemma toMvPolynomial_isHomogeneous (M : Matrix m n R) (i : m) : (M.toMvPolynomial i).IsHomogeneous 1 := by apply MvPolynomial.IsHomogeneous.sum rintro j - apply MvPolynomial.isHomogeneous_monomial _ _ simp [Finsupp.degree, Finsupp.support_single_ne_zero _ one_ne_zero, Finset.sum_singleton, Finsupp.single_eq_same] lemma toMvPolynomial_totalDegree_le (M : Matrix m n R) (i : m) : (M.toMvPolynomial i).totalDegree ≤ 1 := by apply (toMvPolynomial_isHomogeneous _ _).totalDegree_le @[simp] lemma toMvPolynomial_constantCoeff (M : Matrix m n R) (i : m) : constantCoeff (M.toMvPolynomial i) = 0 := by simp only [toMvPolynomial, ← C_mul_X_eq_monomial, map_sum, _root_.map_mul, constantCoeff_X, mul_zero, Finset.sum_const_zero] @[simp] lemma toMvPolynomial_zero : (0 : Matrix m n R).toMvPolynomial = 0 := by ext; simp only [toMvPolynomial, zero_apply, map_zero, Finset.sum_const_zero, Pi.zero_apply] @[simp] lemma toMvPolynomial_one [DecidableEq n] : (1 : Matrix n n R).toMvPolynomial = X := by ext i : 1 rw [toMvPolynomial, Finset.sum_eq_single i] · simp only [one_apply_eq, ← C_mul_X_eq_monomial, C_1, one_mul] · rintro j - hj simp only [one_apply_ne hj.symm, map_zero] · intro h exact (h (Finset.mem_univ _)).elim lemma toMvPolynomial_add (M N : Matrix m n R) : (M + N).toMvPolynomial = M.toMvPolynomial + N.toMvPolynomial := by ext i : 1 simp only [toMvPolynomial, add_apply, map_add, Finset.sum_add_distrib, Pi.add_apply] lemma toMvPolynomial_mul (M : Matrix m n R) (N : Matrix n o R) (i : m) : (M * N).toMvPolynomial i = bind₁ N.toMvPolynomial (M.toMvPolynomial i) := by simp only [toMvPolynomial, mul_apply, map_sum, Finset.sum_comm (γ := o), bind₁, aeval, AlgHom.coe_mk, coe_eval₂Hom, eval₂_monomial, algebraMap_apply, Algebra.id.map_eq_id, RingHom.id_apply, C_apply, pow_zero, Finsupp.prod_single_index, pow_one, Finset.mul_sum, monomial_mul, zero_add] end Matrix namespace LinearMap open MvPolynomial section variable {R M₁ M₂ ι₁ ι₂ : Type*} variable [CommRing R] [AddCommGroup M₁] [AddCommGroup M₂] variable [Module R M₁] [Module R M₂] variable [Fintype ι₁] [Finite ι₂] variable [DecidableEq ι₁] variable (b₁ : Basis ι₁ R M₁) (b₂ : Basis ι₂ R M₂) /-- Let `f : M₁ →ₗ[R] M₂` be an `R`-linear map between modules `M₁` and `M₂` with bases `b₁` and `b₂` respectively. Then `LinearMap.toMvPolynomial b₁ b₂ f` is the family of multivariate polynomials over `R` that evaluates on an element `x` of `M₁` (represented on the basis `b₁`) to the element `f x` of `M₂` (represented on the basis `b₂`). -/ noncomputable def toMvPolynomial (f : M₁ →ₗ[R] M₂) (i : ι₂) : MvPolynomial ι₁ R := (toMatrix b₁ b₂ f).toMvPolynomial i lemma toMvPolynomial_eval_eq_apply (f : M₁ →ₗ[R] M₂) (i : ι₂) (c : ι₁ →₀ R) : eval c (f.toMvPolynomial b₁ b₂ i) = b₂.repr (f (b₁.repr.symm c)) i := by rw [toMvPolynomial, Matrix.toMvPolynomial_eval_eq_apply, ← LinearMap.toMatrix_mulVec_repr b₁ b₂, LinearEquiv.apply_symm_apply] open Algebra.TensorProduct in lemma toMvPolynomial_baseChange (f : M₁ →ₗ[R] M₂) (i : ι₂) (A : Type*) [CommRing A] [Algebra R A] : (f.baseChange A).toMvPolynomial (basis A b₁) (basis A b₂) i = MvPolynomial.map (algebraMap R A) (f.toMvPolynomial b₁ b₂ i) := by simp only [toMvPolynomial, toMatrix_baseChange, Matrix.toMvPolynomial_map] lemma toMvPolynomial_isHomogeneous (f : M₁ →ₗ[R] M₂) (i : ι₂) : (f.toMvPolynomial b₁ b₂ i).IsHomogeneous 1 := Matrix.toMvPolynomial_isHomogeneous _ _ lemma toMvPolynomial_totalDegree_le (f : M₁ →ₗ[R] M₂) (i : ι₂) : (f.toMvPolynomial b₁ b₂ i).totalDegree ≤ 1 := Matrix.toMvPolynomial_totalDegree_le _ _ @[simp] lemma toMvPolynomial_constantCoeff (f : M₁ →ₗ[R] M₂) (i : ι₂) : constantCoeff (f.toMvPolynomial b₁ b₂ i) = 0 := Matrix.toMvPolynomial_constantCoeff _ _ @[simp] lemma toMvPolynomial_zero : (0 : M₁ →ₗ[R] M₂).toMvPolynomial b₁ b₂ = 0 := by unfold toMvPolynomial; simp only [map_zero, Matrix.toMvPolynomial_zero] @[simp] lemma toMvPolynomial_id : (id : M₁ →ₗ[R] M₁).toMvPolynomial b₁ b₁ = X := by unfold toMvPolynomial; simp only [toMatrix_id, Matrix.toMvPolynomial_one] lemma toMvPolynomial_add (f g : M₁ →ₗ[R] M₂) : (f + g).toMvPolynomial b₁ b₂ = f.toMvPolynomial b₁ b₂ + g.toMvPolynomial b₁ b₂ := by unfold toMvPolynomial; simp only [map_add, Matrix.toMvPolynomial_add] end variable {R M₁ M₂ M₃ ι₁ ι₂ ι₃ : Type*} variable [CommRing R] [AddCommGroup M₁] [AddCommGroup M₂] [AddCommGroup M₃] variable [Module R M₁] [Module R M₂] [Module R M₃] variable [Fintype ι₁] [Fintype ι₂] [Finite ι₃] variable [DecidableEq ι₁] [DecidableEq ι₂] variable (b₁ : Basis ι₁ R M₁) (b₂ : Basis ι₂ R M₂) (b₃ : Basis ι₃ R M₃) lemma toMvPolynomial_comp (g : M₂ →ₗ[R] M₃) (f : M₁ →ₗ[R] M₂) (i : ι₃) : (g ∘ₗ f).toMvPolynomial b₁ b₃ i = bind₁ (f.toMvPolynomial b₁ b₂) (g.toMvPolynomial b₂ b₃ i) := by simp only [toMvPolynomial, toMatrix_comp b₁ b₂ b₃, Matrix.toMvPolynomial_mul] rfl end LinearMap variable {R L M n ι ι' ιM : Type*} variable [CommRing R] [AddCommGroup L] [Module R L] [AddCommGroup M] [Module R M] variable (φ : L →ₗ[R] Module.End R M) variable [Fintype ι] [Fintype ι'] [Fintype ιM] [DecidableEq ι] [DecidableEq ι'] namespace LinearMap section aux variable [DecidableEq ιM] (b : Basis ι R L) (bₘ : Basis ιM R M) open Matrix /-- (Implementation detail, see `LinearMap.polyCharpoly`.) Let `L` and `M` be finite free modules over `R`, and let `φ : L →ₗ[R] Module.End R M` be a linear map. Let `b` be a basis of `L` and `bₘ` a basis of `M`. Then `LinearMap.polyCharpolyAux φ b bₘ` is the polynomial that evaluates on elements `x` of `L` to the characteristic polynomial of `φ x` acting on `M`. This definition does not depend on the choice of `bₘ` (see `LinearMap.polyCharpolyAux_basisIndep`). -/ noncomputable def polyCharpolyAux : Polynomial (MvPolynomial ι R) := (charpoly.univ R ιM).map <| MvPolynomial.bind₁ (φ.toMvPolynomial b bₘ.end) open Algebra.TensorProduct MvPolynomial in lemma polyCharpolyAux_baseChange (A : Type*) [CommRing A] [Algebra R A] : polyCharpolyAux (tensorProduct _ _ _ _ ∘ₗ φ.baseChange A) (basis A b) (basis A bₘ) = (polyCharpolyAux φ b bₘ).map (MvPolynomial.map (algebraMap R A)) := by simp only [polyCharpolyAux] rw [← charpoly.univ_map_map _ (algebraMap R A)] simp only [Polynomial.map_map] congr 1 apply ringHom_ext · intro r simp only [RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, map_C, bind₁_C_right] · rintro ij simp only [RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, map_X, bind₁_X_right] classical rw [toMvPolynomial_comp _ (basis A (Basis.end bₘ)), ← toMvPolynomial_baseChange] #adaptation_note /-- After https://github.com/leanprover/lean4/pull/4119 we either need to specify the `M₂` argument, or use `set_option maxSynthPendingDepth 2 in`. -/ suffices toMvPolynomial (M₂ := (Module.End A (TensorProduct R A M))) (basis A bₘ.end) (basis A bₘ).end (tensorProduct R A M M) ij = X ij by rw [this, bind₁_X_right] simp only [toMvPolynomial, Matrix.toMvPolynomial] suffices ∀ kl, (toMatrix (basis A bₘ.end) (basis A bₘ).end) (tensorProduct R A M M) ij kl = if kl = ij then 1 else 0 by rw [Finset.sum_eq_single ij] · rw [this, if_pos rfl, X] · rintro kl - H rw [this, if_neg H, map_zero] · intro h exact (h (Finset.mem_univ _)).elim intro kl rw [toMatrix_apply, tensorProduct, TensorProduct.AlgebraTensorModule.lift_apply, basis_apply, TensorProduct.lift.tmul, coe_restrictScalars] dsimp only [coe_mk, AddHom.coe_mk, smul_apply, baseChangeHom_apply] rw [one_smul, Basis.baseChange_end, Basis.repr_self_apply] open LinearMap in lemma polyCharpolyAux_map_eq_toMatrix_charpoly (x : L) : (polyCharpolyAux φ b bₘ).map (MvPolynomial.eval (b.repr x)) = (toMatrix bₘ bₘ (φ x)).charpoly := by rw [polyCharpolyAux, Polynomial.map_map, ← MvPolynomial.eval₂Hom_C_eq_bind₁, MvPolynomial.comp_eval₂Hom, charpoly.univ_map_eval₂Hom] congr ext rw [of_apply, Function.curry_apply, toMvPolynomial_eval_eq_apply, LinearEquiv.symm_apply_apply] rfl open LinearMap in lemma polyCharpolyAux_eval_eq_toMatrix_charpoly_coeff (x : L) (i : ℕ) : MvPolynomial.eval (b.repr x) ((polyCharpolyAux φ b bₘ).coeff i) = (toMatrix bₘ bₘ (φ x)).charpoly.coeff i := by simp [← polyCharpolyAux_map_eq_toMatrix_charpoly φ b bₘ x] @[simp] lemma polyCharpolyAux_map_eq_charpoly [Module.Finite R M] [Module.Free R M] (x : L) : (polyCharpolyAux φ b bₘ).map (MvPolynomial.eval (b.repr x)) = (φ x).charpoly := by nontriviality R rw [polyCharpolyAux_map_eq_toMatrix_charpoly, LinearMap.charpoly_toMatrix] @[simp] lemma polyCharpolyAux_coeff_eval [Module.Finite R M] [Module.Free R M] (x : L) (i : ℕ) : MvPolynomial.eval (b.repr x) ((polyCharpolyAux φ b bₘ).coeff i) = (φ x).charpoly.coeff i := by nontriviality R rw [← polyCharpolyAux_map_eq_charpoly φ b bₘ x, Polynomial.coeff_map] lemma polyCharpolyAux_map_eval [Module.Finite R M] [Module.Free R M] (x : ι → R) : (polyCharpolyAux φ b bₘ).map (MvPolynomial.eval x) = (φ (b.repr.symm (Finsupp.equivFunOnFinite.symm x))).charpoly := by simp only [← polyCharpolyAux_map_eq_charpoly φ b bₘ, LinearEquiv.apply_symm_apply, Finsupp.equivFunOnFinite, Equiv.coe_fn_symm_mk, Finsupp.coe_mk] open Algebra.TensorProduct TensorProduct in lemma polyCharpolyAux_map_aeval (A : Type*) [CommRing A] [Algebra R A] [Module.Finite A (A ⊗[R] M)] [Module.Free A (A ⊗[R] M)] (x : ι → A) : (polyCharpolyAux φ b bₘ).map (MvPolynomial.aeval x).toRingHom = LinearMap.charpoly ((tensorProduct R A M M).comp (baseChange A φ) ((basis A b).repr.symm (Finsupp.equivFunOnFinite.symm x))) := by rw [← polyCharpolyAux_map_eval (tensorProduct R A M M ∘ₗ baseChange A φ) _ (basis A bₘ), polyCharpolyAux_baseChange, Polynomial.map_map] congr exact DFunLike.ext _ _ fun f ↦ (MvPolynomial.eval_map (algebraMap R A) x f).symm open Algebra.TensorProduct MvPolynomial in /-- `LinearMap.polyCharpolyAux` is independent of the choice of basis of the target module. Proof strategy: 1. Rewrite `polyCharpolyAux` as the (honest, ordinary) characteristic polynomial of the basechange of `φ` to the multivariate polynomial ring `MvPolynomial ι R`. 2. Use that the characteristic polynomial of a linear map is independent of the choice of basis. This independence result is used transitively via `LinearMap.polyCharpolyAux_map_aeval` and `LinearMap.polyCharpolyAux_map_eq_charpoly`. -/ lemma polyCharpolyAux_basisIndep {ιM' : Type*} [Fintype ιM'] [DecidableEq ιM'] (bₘ' : Basis ιM' R M) : polyCharpolyAux φ b bₘ = polyCharpolyAux φ b bₘ' := by let f : Polynomial (MvPolynomial ι R) → Polynomial (MvPolynomial ι R) := Polynomial.map (MvPolynomial.aeval X).toRingHom have hf : Function.Injective f := by simp only [f, aeval_X_left, AlgHom.toRingHom_eq_coe, AlgHom.id_toRingHom, Polynomial.map_id] exact Polynomial.map_injective (RingHom.id _) Function.injective_id apply hf let _h1 : Module.Finite (MvPolynomial ι R) (TensorProduct R (MvPolynomial ι R) M) := Module.Finite.of_basis (basis (MvPolynomial ι R) bₘ) let _h2 : Module.Free (MvPolynomial ι R) (TensorProduct R (MvPolynomial ι R) M) := Module.Free.of_basis (basis (MvPolynomial ι R) bₘ) simp only [f, polyCharpolyAux_map_aeval, polyCharpolyAux_map_aeval] end aux open FiniteDimensional Matrix variable [Module.Free R M] [Module.Finite R M] (b : Basis ι R L) /-- Let `L` and `M` be finite free modules over `R`, and let `φ : L →ₗ[R] Module.End R M` be a linear family of endomorphisms. Let `b` be a basis of `L` and `bₘ` a basis of `M`. Then `LinearMap.polyCharpoly φ b` is the polynomial that evaluates on elements `x` of `L` to the characteristic polynomial of `φ x` acting on `M`. -/ noncomputable def polyCharpoly : Polynomial (MvPolynomial ι R) := φ.polyCharpolyAux b (Module.Free.chooseBasis R M) lemma polyCharpoly_eq_of_basis [DecidableEq ιM] (bₘ : Basis ιM R M) : polyCharpoly φ b = (charpoly.univ R ιM).map (MvPolynomial.bind₁ (φ.toMvPolynomial b bₘ.end)) := by rw [polyCharpoly, φ.polyCharpolyAux_basisIndep b (Module.Free.chooseBasis R M) bₘ, polyCharpolyAux] lemma polyCharpoly_monic : (polyCharpoly φ b).Monic := (charpoly.univ_monic R _).map _ lemma polyCharpoly_ne_zero [Nontrivial R] : (polyCharpoly φ b) ≠ 0 := (polyCharpoly_monic _ _).ne_zero @[simp] lemma polyCharpoly_natDegree [Nontrivial R] : (polyCharpoly φ b).natDegree = finrank R M := by rw [polyCharpoly, polyCharpolyAux, (charpoly.univ_monic _ _).natDegree_map, charpoly.univ_natDegree, finrank_eq_card_chooseBasisIndex] lemma polyCharpoly_coeff_isHomogeneous (i j : ℕ) (hij : i + j = finrank R M) [Nontrivial R] : ((polyCharpoly φ b).coeff i).IsHomogeneous j := by rw [finrank_eq_card_chooseBasisIndex] at hij rw [polyCharpoly, polyCharpolyAux, Polynomial.coeff_map, ← one_mul j] apply (charpoly.univ_coeff_isHomogeneous _ _ _ _ hij).eval₂ · exact fun r ↦ MvPolynomial.isHomogeneous_C _ _ · exact LinearMap.toMvPolynomial_isHomogeneous _ _ _ open Algebra.TensorProduct MvPolynomial in lemma polyCharpoly_baseChange (A : Type*) [CommRing A] [Algebra R A] : polyCharpoly (tensorProduct _ _ _ _ ∘ₗ φ.baseChange A) (basis A b) = (polyCharpoly φ b).map (MvPolynomial.map (algebraMap R A)) := by unfold polyCharpoly rw [← φ.polyCharpolyAux_baseChange] apply polyCharpolyAux_basisIndep @[simp] lemma polyCharpoly_map_eq_charpoly (x : L) : (polyCharpoly φ b).map (MvPolynomial.eval (b.repr x)) = (φ x).charpoly := by rw [polyCharpoly, polyCharpolyAux_map_eq_charpoly] @[simp] lemma polyCharpoly_coeff_eval (x : L) (i : ℕ) : MvPolynomial.eval (b.repr x) ((polyCharpoly φ b).coeff i) = (φ x).charpoly.coeff i := by rw [polyCharpoly, polyCharpolyAux_coeff_eval] lemma polyCharpoly_coeff_eq_zero_of_basis (b : Basis ι R L) (b' : Basis ι' R L) (k : ℕ) (H : (polyCharpoly φ b).coeff k = 0) : (polyCharpoly φ b').coeff k = 0 := by rw [polyCharpoly, polyCharpolyAux, Polynomial.coeff_map] at H ⊢ set B := (Module.Free.chooseBasis R M).end set g := toMvPolynomial b' b LinearMap.id apply_fun (MvPolynomial.bind₁ g) at H have : toMvPolynomial b' B φ = fun i ↦ (MvPolynomial.bind₁ g) (toMvPolynomial b B φ i) := funext <| toMvPolynomial_comp b' b B φ LinearMap.id rwa [map_zero, RingHom.coe_coe, MvPolynomial.bind₁_bind₁, ← this] at H lemma polyCharpoly_coeff_eq_zero_iff_of_basis (b : Basis ι R L) (b' : Basis ι' R L) (k : ℕ) : (polyCharpoly φ b).coeff k = 0 ↔ (polyCharpoly φ b').coeff k = 0 := by constructor <;> apply polyCharpoly_coeff_eq_zero_of_basis section aux /-- (Implementation detail, see `LinearMap.nilRank`.) Let `L` and `M` be finite free modules over `R`, and let `φ : L →ₗ[R] Module.End R M` be a linear family of endomorphisms. Then `LinearMap.nilRankAux φ b` is the smallest index at which `LinearMap.polyCharpoly φ b` has a non-zero coefficient. This number does not depend on the choice of `b`, see `nilRankAux_basis_indep`. -/ noncomputable def nilRankAux (φ : L →ₗ[R] Module.End R M) (b : Basis ι R L) : ℕ := (polyCharpoly φ b).natTrailingDegree lemma polyCharpoly_coeff_nilRankAux_ne_zero [Nontrivial R] : (polyCharpoly φ b).coeff (nilRankAux φ b) ≠ 0 := by apply Polynomial.trailingCoeff_nonzero_iff_nonzero.mpr apply polyCharpoly_ne_zero lemma nilRankAux_le [Nontrivial R] (b : Basis ι R L) (b' : Basis ι' R L) : nilRankAux φ b ≤ nilRankAux φ b' := by apply Polynomial.natTrailingDegree_le_of_ne_zero rw [Ne, (polyCharpoly_coeff_eq_zero_iff_of_basis φ b b' _).not] apply polyCharpoly_coeff_nilRankAux_ne_zero lemma nilRankAux_basis_indep [Nontrivial R] (b : Basis ι R L) (b' : Basis ι' R L) : nilRankAux φ b = (polyCharpoly φ b').natTrailingDegree := by apply le_antisymm <;> apply nilRankAux_le end aux variable [Module.Finite R L] [Module.Free R L] /-- Let `L` and `M` be finite free modules over `R`, and let `φ : L →ₗ[R] Module.End R M` be a linear family of endomorphisms. Then `LinearMap.nilRank φ b` is the smallest index at which `LinearMap.polyCharpoly φ b` has a non-zero coefficient. This number does not depend on the choice of `b`, see `LinearMap.nilRank_eq_polyCharpoly_natTrailingDegree`. -/ noncomputable def nilRank (φ : L →ₗ[R] Module.End R M) : ℕ := nilRankAux φ (Module.Free.chooseBasis R L) variable [Nontrivial R] lemma nilRank_eq_polyCharpoly_natTrailingDegree (b : Basis ι R L) : nilRank φ = (polyCharpoly φ b).natTrailingDegree := by apply nilRankAux_basis_indep lemma polyCharpoly_coeff_nilRank_ne_zero : (polyCharpoly φ b).coeff (nilRank φ) ≠ 0 := by rw [nilRank_eq_polyCharpoly_natTrailingDegree _ b] apply polyCharpoly_coeff_nilRankAux_ne_zero open FiniteDimensional Module.Free lemma nilRank_le_card (b : Basis ι R M) : nilRank φ ≤ Fintype.card ι := by apply Polynomial.natTrailingDegree_le_of_ne_zero rw [← FiniteDimensional.finrank_eq_card_basis b, ← polyCharpoly_natDegree φ (chooseBasis R L), Polynomial.coeff_natDegree, (polyCharpoly_monic _ _).leadingCoeff] apply one_ne_zero lemma nilRank_le_finrank : nilRank φ ≤ finrank R M := by simpa only [finrank_eq_card_chooseBasisIndex R M] using nilRank_le_card φ (chooseBasis R M) lemma nilRank_le_natTrailingDegree_charpoly (x : L) : nilRank φ ≤ (φ x).charpoly.natTrailingDegree := by apply Polynomial.natTrailingDegree_le_of_ne_zero intro h apply_fun (MvPolynomial.eval ((chooseBasis R L).repr x)) at h rw [polyCharpoly_coeff_eval, map_zero] at h apply Polynomial.trailingCoeff_nonzero_iff_nonzero.mpr _ h apply (LinearMap.charpoly_monic _).ne_zero /-- Let `L` and `M` be finite free modules over `R`, and let `φ : L →ₗ[R] Module.End R M` be a linear family of endomorphisms, and denote `n := nilRank φ`. An element `x : L` is *nil-regular* with respect to `φ` if the `n`-th coefficient of the characteristic polynomial of `φ x` is non-zero. -/ def IsNilRegular (x : L) : Prop := Polynomial.coeff (φ x).charpoly (nilRank φ) ≠ 0 variable (x : L) lemma isNilRegular_def : IsNilRegular φ x ↔ (Polynomial.coeff (φ x).charpoly (nilRank φ) ≠ 0) := Iff.rfl lemma isNilRegular_iff_coeff_polyCharpoly_nilRank_ne_zero : IsNilRegular φ x ↔ MvPolynomial.eval (b.repr x) ((polyCharpoly φ b).coeff (nilRank φ)) ≠ 0 := by rw [IsNilRegular, polyCharpoly_coeff_eval] lemma isNilRegular_iff_natTrailingDegree_charpoly_eq_nilRank : IsNilRegular φ x ↔ (φ x).charpoly.natTrailingDegree = nilRank φ := by rw [isNilRegular_def] constructor · intro h exact le_antisymm (Polynomial.natTrailingDegree_le_of_ne_zero h) (nilRank_le_natTrailingDegree_charpoly φ x) · intro h rw [← h] apply Polynomial.trailingCoeff_nonzero_iff_nonzero.mpr apply (LinearMap.charpoly_monic _).ne_zero section IsDomain variable [IsDomain R] open Cardinal FiniteDimensional MvPolynomial in lemma exists_isNilRegular_of_finrank_le_card (h : finrank R M ≤ #R) : ∃ x : L, IsNilRegular φ x := by let b := chooseBasis R L let bₘ := chooseBasis R M let n := Fintype.card (ChooseBasisIndex R M) have aux : ((polyCharpoly φ b).coeff (nilRank φ)).IsHomogeneous (n - nilRank φ) := polyCharpoly_coeff_isHomogeneous _ b (nilRank φ) (n - nilRank φ) (by simp [nilRank_le_card φ bₘ, finrank_eq_card_chooseBasisIndex]) obtain ⟨x, hx⟩ : ∃ r, eval r ((polyCharpoly _ b).coeff (nilRank φ)) ≠ 0 := by by_contra! h₀ apply polyCharpoly_coeff_nilRank_ne_zero φ b apply aux.eq_zero_of_forall_eval_eq_zero_of_le_card h₀ (le_trans _ h) simp only [finrank_eq_card_chooseBasisIndex, Nat.cast_le, Nat.sub_le] let c := Finsupp.equivFunOnFinite.symm x use b.repr.symm c rwa [isNilRegular_iff_coeff_polyCharpoly_nilRank_ne_zero _ b, LinearEquiv.apply_symm_apply] lemma exists_isNilRegular [Infinite R] : ∃ x : L, IsNilRegular φ x := by apply exists_isNilRegular_of_finrank_le_card exact (Cardinal.nat_lt_aleph0 _).le.trans <| Cardinal.infinite_iff.mp ‹Infinite R› end IsDomain end LinearMap
Algebra\Module\LinearMap\Prod.lean
/- Copyright (c) 2019 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import Mathlib.Algebra.Module.Prod import Mathlib.Tactic.Abel import Mathlib.Algebra.Module.LinearMap.Defs /-! # Addition and subtraction are linear maps from the product space Note that these results use `IsLinearMap`, which is mostly discouraged. ## Tags linear algebra, vector space, module -/ variable {R : Type*} {M : Type*} [Semiring R] namespace IsLinearMap theorem isLinearMap_add [AddCommMonoid M] [Module R M] : IsLinearMap R fun x : M × M => x.1 + x.2 := by apply IsLinearMap.mk · intro x y simp only [Prod.fst_add, Prod.snd_add] abel · intro x y simp [smul_add] theorem isLinearMap_sub [AddCommGroup M] [Module R M] : IsLinearMap R fun x : M × M => x.1 - x.2 := by apply IsLinearMap.mk · intro x y -- porting note (#10745): was `simp [add_comm, add_left_comm, sub_eq_add_neg]` rw [Prod.fst_add, Prod.snd_add] abel · intro x y simp [smul_sub] end IsLinearMap
Algebra\Module\LinearMap\Rat.lean
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.Rat import Mathlib.Algebra.Module.LinearMap.Defs /-! # Reinterpret an additive homomorphism as a `ℚ`-linear map. -/ open Function variable {M M₂ : Type*} /-- Reinterpret an additive homomorphism as a `ℚ`-linear map. -/ def AddMonoidHom.toRatLinearMap [AddCommGroup M] [Module ℚ M] [AddCommGroup M₂] [Module ℚ M₂] (f : M →+ M₂) : M →ₗ[ℚ] M₂ := { f with map_smul' := map_rat_smul f } theorem AddMonoidHom.toRatLinearMap_injective [AddCommGroup M] [Module ℚ M] [AddCommGroup M₂] [Module ℚ M₂] : Function.Injective (@AddMonoidHom.toRatLinearMap M M₂ _ _ _ _) := by intro f g h ext x exact LinearMap.congr_fun h x @[simp] theorem AddMonoidHom.coe_toRatLinearMap [AddCommGroup M] [Module ℚ M] [AddCommGroup M₂] [Module ℚ M₂] (f : M →+ M₂) : ⇑f.toRatLinearMap = f := rfl
Algebra\Module\LinearMap\Star.lean
/- Copyright (c) 2021 Frédéric Dupuis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Frédéric Dupuis -/ import Mathlib.Algebra.Module.Equiv.Defs import Mathlib.Algebra.Star.Basic /-! # Notation for star-linear maps This is in a separate file as a it is not needed until much later, and avoids importing the theory of star operations unnecessarily early. -/ /-- `M →ₗ⋆[R] N` is the type of `R`-conjugate-linear maps from `M` to `N`. -/ notation:25 M " →ₗ⋆[" R:25 "] " M₂:0 => LinearMap (starRingEnd R) M M₂ /-- The notation `M ≃ₗ⋆[R] M₂` denotes the type of star-linear equivalences between `M` and `M₂` over the `⋆` endomorphism of the underlying starred ring `R`. -/ notation:50 M " ≃ₗ⋆[" R "] " M₂ => LinearEquiv (starRingEnd R) M M₂
Algebra\Module\Submodule\Basic.lean
/- Copyright (c) 2015 Nathaniel Thomas. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Field.Defs import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.GroupTheory.GroupAction.SubMulAction /-! # Submodules of a module In this file we define * `Submodule R M` : a subset of a `Module` `M` that contains zero and is closed with respect to addition and scalar multiplication. * `Subspace k M` : an abbreviation for `Submodule` assuming that `k` is a `Field`. ## Tags submodule, subspace, linear map -/ open Function universe u'' u' u v w variable {G : Type u''} {S : Type u'} {R : Type u} {M : Type v} {ι : Type w} /-- A submodule of a module is one which is closed under vector operations. This is a sufficient condition for the subset of vectors in the submodule to themselves form a module. -/ structure Submodule (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] [Module R M] extends AddSubmonoid M, SubMulAction R M : Type v /-- Reinterpret a `Submodule` as an `AddSubmonoid`. -/ add_decl_doc Submodule.toAddSubmonoid /-- Reinterpret a `Submodule` as a `SubMulAction`. -/ add_decl_doc Submodule.toSubMulAction namespace Submodule variable [Semiring R] [AddCommMonoid M] [Module R M] instance setLike : SetLike (Submodule R M) M where coe s := s.carrier coe_injective' p q h := by cases p; cases q; congr; exact SetLike.coe_injective' h instance addSubmonoidClass : AddSubmonoidClass (Submodule R M) M where zero_mem _ := AddSubmonoid.zero_mem' _ add_mem := AddSubsemigroup.add_mem' _ instance smulMemClass : SMulMemClass (Submodule R M) R M where smul_mem {s} c _ h := SubMulAction.smul_mem' s.toSubMulAction c h @[simp] theorem mem_toAddSubmonoid (p : Submodule R M) (x : M) : x ∈ p.toAddSubmonoid ↔ x ∈ p := Iff.rfl variable {p q : Submodule R M} @[simp] theorem mem_mk {S : AddSubmonoid M} {x : M} (h) : x ∈ (⟨S, h⟩ : Submodule R M) ↔ x ∈ S := Iff.rfl @[simp] theorem coe_set_mk (S : AddSubmonoid M) (h) : ((⟨S, h⟩ : Submodule R M) : Set M) = S := rfl @[simp] theorem eta (h) : ({p with smul_mem' := h} : Submodule R M) = p := rfl -- Porting note: replaced `S ⊆ S' : Set` with `S ≤ S'` @[simp] theorem mk_le_mk {S S' : AddSubmonoid M} (h h') : (⟨S, h⟩ : Submodule R M) ≤ (⟨S', h'⟩ : Submodule R M) ↔ S ≤ S' := Iff.rfl @[ext] theorem ext (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q := SetLike.ext h -- Porting note: adding this as the `simp`-normal form of `toSubMulAction_eq` @[simp] theorem carrier_inj : p.carrier = q.carrier ↔ p = q := (SetLike.coe_injective (A := Submodule R M)).eq_iff /-- Copy of a submodule with a new `carrier` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (p : Submodule R M) (s : Set M) (hs : s = ↑p) : Submodule R M where carrier := s zero_mem' := by simpa [hs] using p.zero_mem' add_mem' := hs.symm ▸ p.add_mem' smul_mem' := by simpa [hs] using p.smul_mem' @[simp] theorem coe_copy (S : Submodule R M) (s : Set M) (hs : s = ↑S) : (S.copy s hs : Set M) = s := rfl theorem copy_eq (S : Submodule R M) (s : Set M) (hs : s = ↑S) : S.copy s hs = S := SetLike.coe_injective hs theorem toAddSubmonoid_injective : Injective (toAddSubmonoid : Submodule R M → AddSubmonoid M) := fun p q h => SetLike.ext'_iff.2 (show (p.toAddSubmonoid : Set M) = q from SetLike.ext'_iff.1 h) @[simp] theorem toAddSubmonoid_eq : p.toAddSubmonoid = q.toAddSubmonoid ↔ p = q := toAddSubmonoid_injective.eq_iff @[mono] theorem toAddSubmonoid_strictMono : StrictMono (toAddSubmonoid : Submodule R M → AddSubmonoid M) := fun _ _ => id theorem toAddSubmonoid_le : p.toAddSubmonoid ≤ q.toAddSubmonoid ↔ p ≤ q := Iff.rfl @[mono] theorem toAddSubmonoid_mono : Monotone (toAddSubmonoid : Submodule R M → AddSubmonoid M) := toAddSubmonoid_strictMono.monotone @[simp] theorem coe_toAddSubmonoid (p : Submodule R M) : (p.toAddSubmonoid : Set M) = p := rfl theorem toSubMulAction_injective : Injective (toSubMulAction : Submodule R M → SubMulAction R M) := fun p q h => SetLike.ext'_iff.2 (show (p.toSubMulAction : Set M) = q from SetLike.ext'_iff.1 h) theorem toSubMulAction_eq : p.toSubMulAction = q.toSubMulAction ↔ p = q := toSubMulAction_injective.eq_iff @[mono] theorem toSubMulAction_strictMono : StrictMono (toSubMulAction : Submodule R M → SubMulAction R M) := fun _ _ => id @[mono] theorem toSubMulAction_mono : Monotone (toSubMulAction : Submodule R M → SubMulAction R M) := toSubMulAction_strictMono.monotone @[simp] theorem coe_toSubMulAction (p : Submodule R M) : (p.toSubMulAction : Set M) = p := rfl end Submodule namespace SMulMemClass variable [Semiring R] [AddCommMonoid M] [Module R M] {A : Type*} [SetLike A M] [AddSubmonoidClass A M] [SMulMemClass A R M] (S' : A) -- Prefer subclasses of `Module` over `SMulMemClass`. /-- A submodule of a `Module` is a `Module`. -/ instance (priority := 75) toModule : Module R S' := Subtype.coe_injective.module R (AddSubmonoidClass.subtype S') (SetLike.val_smul S') /-- This can't be an instance because Lean wouldn't know how to find `R`, but we can still use this to manually derive `Module` on specific types. -/ def toModule' (S R' R A : Type*) [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A] [Semiring R'] [SMul R' R] [Module R' A] [IsScalarTower R' R A] [SetLike S A] [AddSubmonoidClass S A] [SMulMemClass S R A] (s : S) : Module R' s := haveI : SMulMemClass S R' A := SMulMemClass.ofIsScalarTower S R' R A SMulMemClass.toModule s end SMulMemClass namespace Submodule section AddCommMonoid variable [Semiring R] [AddCommMonoid M] -- We can infer the module structure implicitly from the bundled submodule, -- rather than via typeclass resolution. variable {module_M : Module R M} variable {p q : Submodule R M} variable {r : R} {x y : M} variable (p) -- Porting note: removing `@[simp]` since it can already be proven theorem mem_carrier : x ∈ p.carrier ↔ x ∈ (p : Set M) := Iff.rfl @[simp] protected theorem zero_mem : (0 : M) ∈ p := zero_mem _ protected theorem add_mem (h₁ : x ∈ p) (h₂ : y ∈ p) : x + y ∈ p := add_mem h₁ h₂ theorem smul_mem (r : R) (h : x ∈ p) : r • x ∈ p := p.smul_mem' r h theorem smul_of_tower_mem [SMul S R] [SMul S M] [IsScalarTower S R M] (r : S) (h : x ∈ p) : r • x ∈ p := p.toSubMulAction.smul_of_tower_mem r h protected theorem sum_mem {t : Finset ι} {f : ι → M} : (∀ c ∈ t, f c ∈ p) → (∑ i ∈ t, f i) ∈ p := sum_mem theorem sum_smul_mem {t : Finset ι} {f : ι → M} (r : ι → R) (hyp : ∀ c ∈ t, f c ∈ p) : (∑ i ∈ t, r i • f i) ∈ p := sum_mem fun i hi => smul_mem _ _ (hyp i hi) @[simp] theorem smul_mem_iff' [Group G] [MulAction G M] [SMul G R] [IsScalarTower G R M] (g : G) : g • x ∈ p ↔ x ∈ p := p.toSubMulAction.smul_mem_iff' g instance add : Add p := ⟨fun x y => ⟨x.1 + y.1, add_mem x.2 y.2⟩⟩ instance zero : Zero p := ⟨⟨0, zero_mem _⟩⟩ instance inhabited : Inhabited p := ⟨0⟩ instance smul [SMul S R] [SMul S M] [IsScalarTower S R M] : SMul S p := ⟨fun c x => ⟨c • x.1, smul_of_tower_mem _ c x.2⟩⟩ instance isScalarTower [SMul S R] [SMul S M] [IsScalarTower S R M] : IsScalarTower S R p := p.toSubMulAction.isScalarTower instance isScalarTower' {S' : Type*} [SMul S R] [SMul S M] [SMul S' R] [SMul S' M] [SMul S S'] [IsScalarTower S' R M] [IsScalarTower S S' M] [IsScalarTower S R M] : IsScalarTower S S' p := p.toSubMulAction.isScalarTower' instance isCentralScalar [SMul S R] [SMul S M] [IsScalarTower S R M] [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ M] [IsScalarTower Sᵐᵒᵖ R M] [IsCentralScalar S M] : IsCentralScalar S p := p.toSubMulAction.isCentralScalar protected theorem nonempty : (p : Set M).Nonempty := ⟨0, p.zero_mem⟩ theorem mk_eq_zero {x} (h : x ∈ p) : (⟨x, h⟩ : p) = 0 ↔ x = 0 := Subtype.ext_iff_val variable {p} @[norm_cast] -- Porting note: removed `@[simp]` because this follows from `ZeroMemClass.coe_zero` theorem coe_eq_zero {x : p} : (x : M) = 0 ↔ x = 0 := (SetLike.coe_eq_coe : (x : M) = (0 : p) ↔ x = 0) @[simp, norm_cast] theorem coe_add (x y : p) : (↑(x + y) : M) = ↑x + ↑y := rfl @[simp, norm_cast] theorem coe_zero : ((0 : p) : M) = 0 := rfl @[norm_cast] theorem coe_smul (r : R) (x : p) : ((r • x : p) : M) = r • (x : M) := rfl @[simp, norm_cast] theorem coe_smul_of_tower [SMul S R] [SMul S M] [IsScalarTower S R M] (r : S) (x : p) : ((r • x : p) : M) = r • (x : M) := rfl @[norm_cast] -- Porting note: removed `@[simp]` because this is now structure eta theorem coe_mk (x : M) (hx : x ∈ p) : ((⟨x, hx⟩ : p) : M) = x := rfl -- Porting note: removed `@[simp]` because this is exactly `SetLike.coe_mem` theorem coe_mem (x : p) : (x : M) ∈ p := x.2 variable (p) instance addCommMonoid : AddCommMonoid p := { p.toAddSubmonoid.toAddCommMonoid with } instance module' [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : Module S p := { (show MulAction S p from p.toSubMulAction.mulAction') with smul_zero := fun a => by ext; simp zero_smul := fun a => by ext; simp add_smul := fun a b x => by ext; simp [add_smul] smul_add := fun a x y => by ext; simp [smul_add] } instance module : Module R p := p.module' instance noZeroSMulDivisors [NoZeroSMulDivisors R M] : NoZeroSMulDivisors R p := ⟨fun {c} {x : p} h => have : c = 0 ∨ (x : M) = 0 := eq_zero_or_eq_zero_of_smul_eq_zero (congr_arg Subtype.val h) this.imp_right (@Subtype.ext_iff _ _ x 0).mpr⟩ section AddAction /-! ### Additive actions by `Submodule`s These instances transfer the action by an element `m : M` of an `R`-module `M` written as `m +ᵥ a` onto the action by an element `s : S` of a submodule `S : Submodule R M` such that `s +ᵥ a = (s : M) +ᵥ a`. These instances work particularly well in conjunction with `AddGroup.toAddAction`, enabling `s +ᵥ m` as an alias for `↑s + m`. -/ variable {α β : Type*} instance [VAdd M α] : VAdd p α := p.toAddSubmonoid.vadd instance vaddCommClass [VAdd M β] [VAdd α β] [VAddCommClass M α β] : VAddCommClass p α β := ⟨fun a => (vadd_comm (a : M) : _)⟩ instance [VAdd M α] [FaithfulVAdd M α] : FaithfulVAdd p α := ⟨fun h => Subtype.ext <| eq_of_vadd_eq_vadd h⟩ variable {p} theorem vadd_def [VAdd M α] (g : p) (m : α) : g +ᵥ m = (g : M) +ᵥ m := rfl end AddAction end AddCommMonoid section AddCommGroup variable [Ring R] [AddCommGroup M] variable {module_M : Module R M} variable (p p' : Submodule R M) variable {r : R} {x y : M} instance addSubgroupClass [Module R M] : AddSubgroupClass (Submodule R M) M := { Submodule.addSubmonoidClass with neg_mem := fun p {_} => p.toSubMulAction.neg_mem } protected theorem neg_mem (hx : x ∈ p) : -x ∈ p := neg_mem hx /-- Reinterpret a submodule as an additive subgroup. -/ def toAddSubgroup : AddSubgroup M := { p.toAddSubmonoid with neg_mem' := fun {_} => p.neg_mem } @[simp] theorem coe_toAddSubgroup : (p.toAddSubgroup : Set M) = p := rfl @[simp] theorem mem_toAddSubgroup : x ∈ p.toAddSubgroup ↔ x ∈ p := Iff.rfl theorem toAddSubgroup_injective : Injective (toAddSubgroup : Submodule R M → AddSubgroup M) | _, _, h => SetLike.ext (SetLike.ext_iff.1 h : _) @[simp] theorem toAddSubgroup_eq : p.toAddSubgroup = p'.toAddSubgroup ↔ p = p' := toAddSubgroup_injective.eq_iff @[mono] theorem toAddSubgroup_strictMono : StrictMono (toAddSubgroup : Submodule R M → AddSubgroup M) := fun _ _ => id theorem toAddSubgroup_le : p.toAddSubgroup ≤ p'.toAddSubgroup ↔ p ≤ p' := Iff.rfl @[mono] theorem toAddSubgroup_mono : Monotone (toAddSubgroup : Submodule R M → AddSubgroup M) := toAddSubgroup_strictMono.monotone protected theorem sub_mem : x ∈ p → y ∈ p → x - y ∈ p := sub_mem protected theorem neg_mem_iff : -x ∈ p ↔ x ∈ p := neg_mem_iff protected theorem add_mem_iff_left : y ∈ p → (x + y ∈ p ↔ x ∈ p) := add_mem_cancel_right protected theorem add_mem_iff_right : x ∈ p → (x + y ∈ p ↔ y ∈ p) := add_mem_cancel_left protected theorem coe_neg (x : p) : ((-x : p) : M) = -x := NegMemClass.coe_neg _ protected theorem coe_sub (x y : p) : (↑(x - y) : M) = ↑x - ↑y := AddSubgroupClass.coe_sub _ _ theorem sub_mem_iff_left (hy : y ∈ p) : x - y ∈ p ↔ x ∈ p := by rw [sub_eq_add_neg, p.add_mem_iff_left (p.neg_mem hy)] theorem sub_mem_iff_right (hx : x ∈ p) : x - y ∈ p ↔ y ∈ p := by rw [sub_eq_add_neg, p.add_mem_iff_right hx, p.neg_mem_iff] instance addCommGroup : AddCommGroup p := { p.toAddSubgroup.toAddCommGroup with } -- See `neg_coe_set` theorem neg_coe : -(p : Set M) = p := Set.ext fun _ => p.neg_mem_iff end AddCommGroup section IsDomain variable [Ring R] [IsDomain R] variable [AddCommGroup M] [Module R M] {b : ι → M} theorem not_mem_of_ortho {x : M} {N : Submodule R M} (ortho : ∀ (c : R), ∀ y ∈ N, c • x + y = (0 : M) → c = 0) : x ∉ N := by intro hx simpa using ortho (-1) x hx theorem ne_zero_of_ortho {x : M} {N : Submodule R M} (ortho : ∀ (c : R), ∀ y ∈ N, c • x + y = (0 : M) → c = 0) : x ≠ 0 := mt (fun h => show x ∈ N from h.symm ▸ N.zero_mem) (not_mem_of_ortho ortho) end IsDomain end Submodule namespace SubmoduleClass instance (priority := 75) module' {T : Type*} [Semiring R] [AddCommMonoid M] [Semiring S] [Module R M] [SMul S R] [Module S M] [IsScalarTower S R M] [SetLike T M] [AddSubmonoidClass T M] [SMulMemClass T R M] (t : T) : Module S t where one_smul _ := by ext; simp mul_smul _ _ _ := by ext; simp [mul_smul] smul_zero _ := by ext; simp zero_smul _ := by ext; simp add_smul _ _ _ := by ext; simp [add_smul] smul_add _ _ _ := by ext; simp [smul_add] instance (priority := 75) module [Semiring R] [AddCommMonoid M] [Module R M] [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) : Module R s := module' s end SubmoduleClass namespace Submodule variable [DivisionSemiring S] [Semiring R] [AddCommMonoid M] [Module R M] variable [SMul S R] [Module S M] [IsScalarTower S R M] variable (p : Submodule R M) {s : S} {x y : M} theorem smul_mem_iff (s0 : s ≠ 0) : s • x ∈ p ↔ x ∈ p := p.toSubMulAction.smul_mem_iff s0 end Submodule /-- Subspace of a vector space. Defined to equal `Submodule`. -/ abbrev Subspace (R : Type u) (M : Type v) [DivisionRing R] [AddCommGroup M] [Module R M] := Submodule R M
Algebra\Module\Submodule\Bilinear.lean
/- Copyright (c) 2019 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Eric Wieser -/ import Mathlib.LinearAlgebra.Span import Mathlib.LinearAlgebra.BilinearMap /-! # Images of pairs of submodules under bilinear maps This file provides `Submodule.map₂`, which is later used to implement `Submodule.mul`. ## Main results * `Submodule.map₂_eq_span_image2`: the image of two submodules under a bilinear map is the span of their `Set.image2`. ## Notes This file is quite similar to the n-ary section of `Data.Set.Basic` and to `Order.Filter.NAry`. Please keep them in sync. -/ universe uι u v open Set open Pointwise namespace Submodule variable {ι : Sort uι} {R M N P : Type*} variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] variable [Module R M] [Module R N] [Module R P] /-- Map a pair of submodules under a bilinear map. This is the submodule version of `Set.image2`. -/ def map₂ (f : M →ₗ[R] N →ₗ[R] P) (p : Submodule R M) (q : Submodule R N) : Submodule R P := ⨆ s : p, q.map (f s) theorem apply_mem_map₂ (f : M →ₗ[R] N →ₗ[R] P) {m : M} {n : N} {p : Submodule R M} {q : Submodule R N} (hm : m ∈ p) (hn : n ∈ q) : f m n ∈ map₂ f p q := (le_iSup _ ⟨m, hm⟩ : _ ≤ map₂ f p q) ⟨n, hn, by rfl⟩ theorem map₂_le {f : M →ₗ[R] N →ₗ[R] P} {p : Submodule R M} {q : Submodule R N} {r : Submodule R P} : map₂ f p q ≤ r ↔ ∀ m ∈ p, ∀ n ∈ q, f m n ∈ r := ⟨fun H _m hm _n hn => H <| apply_mem_map₂ _ hm hn, fun H => iSup_le fun ⟨m, hm⟩ => map_le_iff_le_comap.2 fun n hn => H m hm n hn⟩ variable (R) theorem map₂_span_span (f : M →ₗ[R] N →ₗ[R] P) (s : Set M) (t : Set N) : map₂ f (span R s) (span R t) = span R (Set.image2 (fun m n => f m n) s t) := by apply le_antisymm · rw [map₂_le] apply @span_induction' R M _ _ _ s intro a ha apply @span_induction' R N _ _ _ t intro b hb exact subset_span ⟨_, ‹_›, _, ‹_›, rfl⟩ all_goals intros; simp only [*, add_mem, smul_mem, zero_mem, _root_.map_zero, map_add, LinearMap.zero_apply, LinearMap.add_apply, LinearMap.smul_apply, map_smul] · rw [span_le, image2_subset_iff] intro a ha b hb exact apply_mem_map₂ _ (subset_span ha) (subset_span hb) variable {R} @[simp] theorem map₂_bot_right (f : M →ₗ[R] N →ₗ[R] P) (p : Submodule R M) : map₂ f p ⊥ = ⊥ := eq_bot_iff.2 <| map₂_le.2 fun m _hm n hn => by rw [Submodule.mem_bot] at hn rw [hn, LinearMap.map_zero]; simp only [mem_bot] @[simp] theorem map₂_bot_left (f : M →ₗ[R] N →ₗ[R] P) (q : Submodule R N) : map₂ f ⊥ q = ⊥ := eq_bot_iff.2 <| map₂_le.2 fun m hm n hn => by rw [Submodule.mem_bot] at hm ⊢ rw [hm, LinearMap.map_zero₂] @[mono] theorem map₂_le_map₂ {f : M →ₗ[R] N →ₗ[R] P} {p₁ p₂ : Submodule R M} {q₁ q₂ : Submodule R N} (hp : p₁ ≤ p₂) (hq : q₁ ≤ q₂) : map₂ f p₁ q₁ ≤ map₂ f p₂ q₂ := map₂_le.2 fun _m hm _n hn => apply_mem_map₂ _ (hp hm) (hq hn) theorem map₂_le_map₂_left {f : M →ₗ[R] N →ₗ[R] P} {p₁ p₂ : Submodule R M} {q : Submodule R N} (h : p₁ ≤ p₂) : map₂ f p₁ q ≤ map₂ f p₂ q := map₂_le_map₂ h (le_refl q) theorem map₂_le_map₂_right {f : M →ₗ[R] N →ₗ[R] P} {p : Submodule R M} {q₁ q₂ : Submodule R N} (h : q₁ ≤ q₂) : map₂ f p q₁ ≤ map₂ f p q₂ := map₂_le_map₂ (le_refl p) h theorem map₂_sup_right (f : M →ₗ[R] N →ₗ[R] P) (p : Submodule R M) (q₁ q₂ : Submodule R N) : map₂ f p (q₁ ⊔ q₂) = map₂ f p q₁ ⊔ map₂ f p q₂ := le_antisymm (map₂_le.2 fun _m hm _np hnp => let ⟨_n, hn, _p, hp, hnp⟩ := mem_sup.1 hnp mem_sup.2 ⟨_, apply_mem_map₂ _ hm hn, _, apply_mem_map₂ _ hm hp, hnp ▸ (map_add _ _ _).symm⟩) (sup_le (map₂_le_map₂_right le_sup_left) (map₂_le_map₂_right le_sup_right)) theorem map₂_sup_left (f : M →ₗ[R] N →ₗ[R] P) (p₁ p₂ : Submodule R M) (q : Submodule R N) : map₂ f (p₁ ⊔ p₂) q = map₂ f p₁ q ⊔ map₂ f p₂ q := le_antisymm (map₂_le.2 fun _mn hmn _p hp => let ⟨_m, hm, _n, hn, hmn⟩ := mem_sup.1 hmn mem_sup.2 ⟨_, apply_mem_map₂ _ hm hp, _, apply_mem_map₂ _ hn hp, hmn ▸ (LinearMap.map_add₂ _ _ _ _).symm⟩) (sup_le (map₂_le_map₂_left le_sup_left) (map₂_le_map₂_left le_sup_right)) theorem image2_subset_map₂ (f : M →ₗ[R] N →ₗ[R] P) (p : Submodule R M) (q : Submodule R N) : Set.image2 (fun m n => f m n) (↑p : Set M) (↑q : Set N) ⊆ (↑(map₂ f p q) : Set P) := by rintro _ ⟨i, hi, j, hj, rfl⟩ exact apply_mem_map₂ _ hi hj theorem map₂_eq_span_image2 (f : M →ₗ[R] N →ₗ[R] P) (p : Submodule R M) (q : Submodule R N) : map₂ f p q = span R (Set.image2 (fun m n => f m n) (p : Set M) (q : Set N)) := by rw [← map₂_span_span, span_eq, span_eq] theorem map₂_flip (f : M →ₗ[R] N →ₗ[R] P) (p : Submodule R M) (q : Submodule R N) : map₂ f.flip q p = map₂ f p q := by rw [map₂_eq_span_image2, map₂_eq_span_image2, Set.image2_swap] rfl theorem map₂_iSup_left (f : M →ₗ[R] N →ₗ[R] P) (s : ι → Submodule R M) (t : Submodule R N) : map₂ f (⨆ i, s i) t = ⨆ i, map₂ f (s i) t := by suffices map₂ f (⨆ i, span R (s i : Set M)) (span R t) = ⨆ i, map₂ f (span R (s i)) (span R t) by simpa only [span_eq] using this simp_rw [map₂_span_span, ← span_iUnion, map₂_span_span, Set.image2_iUnion_left] theorem map₂_iSup_right (f : M →ₗ[R] N →ₗ[R] P) (s : Submodule R M) (t : ι → Submodule R N) : map₂ f s (⨆ i, t i) = ⨆ i, map₂ f s (t i) := by suffices map₂ f (span R s) (⨆ i, span R (t i : Set N)) = ⨆ i, map₂ f (span R s) (span R (t i)) by simpa only [span_eq] using this simp_rw [map₂_span_span, ← span_iUnion, map₂_span_span, Set.image2_iUnion_right] theorem map₂_span_singleton_eq_map (f : M →ₗ[R] N →ₗ[R] P) (m : M) : map₂ f (span R {m}) = map (f m) := by funext s rw [← span_eq s, map₂_span_span, image2_singleton_left, map_span] theorem map₂_span_singleton_eq_map_flip (f : M →ₗ[R] N →ₗ[R] P) (s : Submodule R M) (n : N) : map₂ f s (span R {n}) = map (f.flip n) s := by rw [← map₂_span_singleton_eq_map, map₂_flip] end Submodule
Algebra\Module\Submodule\EqLocus.lean
/- Copyright (c) 2022 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ import Mathlib.Algebra.Module.Submodule.Ker /-! # The submodule of elements `x : M` such that `f x = g x` ## Main declarations * `LinearMap.eqLocus`: the submodule of elements `x : M` such that `f x = g x` ## Tags linear algebra, vector space, module -/ variable {R : Type*} {R₂ : Type*} variable {M : Type*} {M₂ : Type*} /-! ### Properties of linear maps -/ namespace LinearMap section AddCommMonoid variable [Semiring R] [Semiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] variable [Module R M] [Module R₂ M₂] open Submodule variable {τ₁₂ : R →+* R₂} section variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂] /-- A linear map version of `AddMonoidHom.eqLocusM` -/ def eqLocus (f g : F) : Submodule R M := { (f : M →+ M₂).eqLocusM g with carrier := { x | f x = g x } smul_mem' := fun {r} {x} (hx : _ = _) => show _ = _ by -- Note: #8386 changed `map_smulₛₗ` into `map_smulₛₗ _` simpa only [map_smulₛₗ _] using congr_arg (τ₁₂ r • ·) hx } @[simp] theorem mem_eqLocus {x : M} {f g : F} : x ∈ eqLocus f g ↔ f x = g x := Iff.rfl theorem eqLocus_toAddSubmonoid (f g : F) : (eqLocus f g).toAddSubmonoid = (f : M →+ M₂).eqLocusM g := rfl @[simp] theorem eqLocus_eq_top {f g : F} : eqLocus f g = ⊤ ↔ f = g := by simp [SetLike.ext_iff, DFunLike.ext_iff] @[simp] theorem eqLocus_same (f : F) : eqLocus f f = ⊤ := eqLocus_eq_top.2 rfl theorem le_eqLocus {f g : F} {S : Submodule R M} : S ≤ eqLocus f g ↔ Set.EqOn f g S := Iff.rfl theorem eqOn_sup {f g : F} {S T : Submodule R M} (hS : Set.EqOn f g S) (hT : Set.EqOn f g T) : Set.EqOn f g ↑(S ⊔ T) := by rw [← le_eqLocus] at hS hT ⊢ exact sup_le hS hT theorem ext_on_codisjoint {f g : F} {S T : Submodule R M} (hST : Codisjoint S T) (hS : Set.EqOn f g S) (hT : Set.EqOn f g T) : f = g := DFunLike.ext _ _ fun _ ↦ eqOn_sup hS hT <| hST.eq_top.symm ▸ trivial end end AddCommMonoid section Ring variable [Ring R] [Ring R₂] variable [AddCommGroup M] [AddCommGroup M₂] variable [Module R M] [Module R₂ M₂] variable {τ₁₂ : R →+* R₂} open Submodule theorem eqLocus_eq_ker_sub (f g : M →ₛₗ[τ₁₂] M₂) : eqLocus f g = ker (f - g) := SetLike.ext fun _ => sub_eq_zero.symm end Ring end LinearMap
Algebra\Module\Submodule\Equiv.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.Submodule.Range /-! ### Linear equivalences involving submodules -/ open Function variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} variable {N : Type*} namespace LinearEquiv section AddCommMonoid section variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable {module_M : Module R M} {module_M₂ : Module R₂ M₂} {module_M₃ : Module R₃ M₃} variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} variable {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable {σ₃₂ : R₃ →+* R₂} variable {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₁ : RingHomInvPair σ₂₁ σ₁₂} variable {re₂₃ : RingHomInvPair σ₂₃ σ₃₂} {re₃₂ : RingHomInvPair σ₃₂ σ₂₃} variable (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₁] M) (e : M ≃ₛₗ[σ₁₂] M₂) (h : M₂ →ₛₗ[σ₂₃] M₃) variable (p q : Submodule R M) /-- Linear equivalence between two equal submodules. -/ def ofEq (h : p = q) : p ≃ₗ[R] q := { Equiv.Set.ofEq (congr_arg _ h) with map_smul' := fun _ _ => rfl map_add' := fun _ _ => rfl } variable {p q} @[simp] theorem coe_ofEq_apply (h : p = q) (x : p) : (ofEq p q h x : M) = x := rfl @[simp] theorem ofEq_symm (h : p = q) : (ofEq p q h).symm = ofEq q p h.symm := rfl @[simp] theorem ofEq_rfl : ofEq p p rfl = LinearEquiv.refl R p := by ext; rfl /-- A linear equivalence which maps a submodule of one module onto another, restricts to a linear equivalence of the two submodules. -/ def ofSubmodules (p : Submodule R M) (q : Submodule R₂ M₂) (h : p.map (e : M →ₛₗ[σ₁₂] M₂) = q) : p ≃ₛₗ[σ₁₂] q := (e.submoduleMap p).trans (LinearEquiv.ofEq _ _ h) @[simp] theorem ofSubmodules_apply {p : Submodule R M} {q : Submodule R₂ M₂} (h : p.map ↑e = q) (x : p) : ↑(e.ofSubmodules p q h x) = e x := rfl @[simp] theorem ofSubmodules_symm_apply {p : Submodule R M} {q : Submodule R₂ M₂} (h : p.map ↑e = q) (x : q) : ↑((e.ofSubmodules p q h).symm x) = e.symm x := rfl /-- A linear equivalence of two modules restricts to a linear equivalence from the preimage of any submodule to that submodule. This is `LinearEquiv.ofSubmodule` but with `comap` on the left instead of `map` on the right. -/ def ofSubmodule' [Module R M] [Module R₂ M₂] (f : M ≃ₛₗ[σ₁₂] M₂) (U : Submodule R₂ M₂) : U.comap (f : M →ₛₗ[σ₁₂] M₂) ≃ₛₗ[σ₁₂] U := (f.symm.ofSubmodules _ _ f.symm.map_eq_comap).symm theorem ofSubmodule'_toLinearMap [Module R M] [Module R₂ M₂] (f : M ≃ₛₗ[σ₁₂] M₂) (U : Submodule R₂ M₂) : (f.ofSubmodule' U).toLinearMap = (f.toLinearMap.domRestrict _).codRestrict _ Subtype.prop := by ext rfl @[simp] theorem ofSubmodule'_apply [Module R M] [Module R₂ M₂] (f : M ≃ₛₗ[σ₁₂] M₂) (U : Submodule R₂ M₂) (x : U.comap (f : M →ₛₗ[σ₁₂] M₂)) : (f.ofSubmodule' U x : M₂) = f (x : M) := rfl @[simp] theorem ofSubmodule'_symm_apply [Module R M] [Module R₂ M₂] (f : M ≃ₛₗ[σ₁₂] M₂) (U : Submodule R₂ M₂) (x : U) : ((f.ofSubmodule' U).symm x : M) = f.symm (x : M₂) := rfl variable (p) /-- The top submodule of `M` is linearly equivalent to `M`. -/ def ofTop (h : p = ⊤) : p ≃ₗ[R] M := { p.subtype with invFun := fun x => ⟨x, h.symm ▸ trivial⟩ left_inv := fun _ => rfl right_inv := fun _ => rfl } @[simp] theorem ofTop_apply {h} (x : p) : ofTop p h x = x := rfl @[simp] theorem coe_ofTop_symm_apply {h} (x : M) : ((ofTop p h).symm x : M) = x := rfl theorem ofTop_symm_apply {h} (x : M) : (ofTop p h).symm x = ⟨x, h.symm ▸ trivial⟩ := rfl @[simp] protected theorem range : LinearMap.range (e : M →ₛₗ[σ₁₂] M₂) = ⊤ := LinearMap.range_eq_top.2 e.toEquiv.surjective @[simp] protected theorem _root_.LinearEquivClass.range [Module R M] [Module R₂ M₂] {F : Type*} [EquivLike F M M₂] [SemilinearEquivClass F σ₁₂ M M₂] (e : F) : LinearMap.range e = ⊤ := LinearMap.range_eq_top.2 (EquivLike.surjective e) theorem eq_bot_of_equiv [Module R₂ M₂] (e : p ≃ₛₗ[σ₁₂] (⊥ : Submodule R₂ M₂)) : p = ⊥ := by refine bot_unique (SetLike.le_def.2 fun b hb => (Submodule.mem_bot R).2 ?_) rw [← p.mk_eq_zero hb, ← e.map_eq_zero_iff] apply Submodule.eq_zero_of_bot_submodule -- Porting note: `RingHomSurjective σ₁₂` is an unused argument. @[simp] theorem range_comp [RingHomSurjective σ₂₃] [RingHomSurjective σ₁₃] : LinearMap.range (h.comp (e : M →ₛₗ[σ₁₂] M₂) : M →ₛₗ[σ₁₃] M₃) = LinearMap.range h := LinearMap.range_comp_of_range_eq_top _ e.range variable {f g} /-- A linear map `f : M →ₗ[R] M₂` with a left-inverse `g : M₂ →ₗ[R] M` defines a linear equivalence between `M` and `f.range`. This is a computable alternative to `LinearEquiv.ofInjective`, and a bidirectional version of `LinearMap.rangeRestrict`. -/ def ofLeftInverse [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] {g : M₂ → M} (h : Function.LeftInverse g f) : M ≃ₛₗ[σ₁₂] (LinearMap.range f) := { LinearMap.rangeRestrict f with toFun := LinearMap.rangeRestrict f invFun := g ∘ (LinearMap.range f).subtype left_inv := h right_inv := fun x => Subtype.ext <| let ⟨x', hx'⟩ := LinearMap.mem_range.mp x.prop show f (g x) = x by rw [← hx', h x'] } @[simp] theorem ofLeftInverse_apply [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] (h : Function.LeftInverse g f) (x : M) : ↑(ofLeftInverse h x) = f x := rfl @[simp] theorem ofLeftInverse_symm_apply [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] (h : Function.LeftInverse g f) (x : LinearMap.range f) : (ofLeftInverse h).symm x = g x := rfl variable (f) /-- An `Injective` linear map `f : M →ₗ[R] M₂` defines a linear equivalence between `M` and `f.range`. See also `LinearMap.ofLeftInverse`. -/ noncomputable def ofInjective [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] (h : Injective f) : M ≃ₛₗ[σ₁₂] LinearMap.range f := ofLeftInverse <| Classical.choose_spec h.hasLeftInverse @[simp] theorem ofInjective_apply [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] {h : Injective f} (x : M) : ↑(ofInjective f h x) = f x := rfl /-- A bijective linear map is a linear equivalence. -/ noncomputable def ofBijective [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] (hf : Bijective f) : M ≃ₛₗ[σ₁₂] M₂ := (ofInjective f hf.injective).trans (ofTop _ <| LinearMap.range_eq_top.2 hf.surjective) @[simp] theorem ofBijective_apply [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] {hf} (x : M) : ofBijective f hf x = f x := rfl @[simp] theorem ofBijective_symm_apply_apply [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] {h} (x : M) : (ofBijective f h).symm (f x) = x := by simp [LinearEquiv.symm_apply_eq] end end AddCommMonoid end LinearEquiv namespace Submodule section Module variable [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] /-- Given `p` a submodule of the module `M` and `q` a submodule of `p`, `p.equivSubtypeMap q` is the natural `LinearEquiv` between `q` and `q.map p.subtype`. -/ def equivSubtypeMap (p : Submodule R M) (q : Submodule R p) : q ≃ₗ[R] q.map p.subtype := { (p.subtype.domRestrict q).codRestrict _ (by rintro ⟨x, hx⟩; exact ⟨x, hx, rfl⟩) with invFun := by rintro ⟨x, hx⟩ refine ⟨⟨x, ?_⟩, ?_⟩ <;> rcases hx with ⟨⟨_, h⟩, _, rfl⟩ <;> assumption left_inv := fun ⟨⟨_, _⟩, _⟩ => rfl right_inv := fun ⟨x, ⟨_, h⟩, _, rfl⟩ => by ext; rfl } @[simp] theorem equivSubtypeMap_apply {p : Submodule R M} {q : Submodule R p} (x : q) : (p.equivSubtypeMap q x : M) = p.subtype.domRestrict q x := rfl @[simp] theorem equivSubtypeMap_symm_apply {p : Submodule R M} {q : Submodule R p} (x : q.map p.subtype) : ((p.equivSubtypeMap q).symm x : M) = x := by cases x rfl /-- A linear injection `M ↪ N` restricts to an equivalence `f⁻¹ p ≃ p` for any submodule `p` contained in its range. -/ @[simps! apply] noncomputable def comap_equiv_self_of_inj_of_le {f : M →ₗ[R] N} {p : Submodule R N} (hf : Injective f) (h : p ≤ LinearMap.range f) : p.comap f ≃ₗ[R] p := LinearEquiv.ofBijective ((f ∘ₗ (p.comap f).subtype).codRestrict p <| fun ⟨x, hx⟩ ↦ mem_comap.mp hx) (⟨fun x y hxy ↦ by simpa using hf (Subtype.ext_iff.mp hxy), fun ⟨x, hx⟩ ↦ by obtain ⟨y, rfl⟩ := h hx; exact ⟨⟨y, hx⟩, by simp [Subtype.ext_iff]⟩⟩) end Module end Submodule
Algebra\Module\Submodule\IterateMapComap.lean
/- Copyright (c) 2024 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.Algebra.Module.Submodule.Ker /-! # Iterate maps and comaps of submodules Some preliminary work for establishing the strong rank condition for noetherian rings. Given two linear maps `f i : N →ₗ[R] M` and a submodule `K : Submodule R N`, we can define `LinearMap.iterateMapComap f i n K : Submodule R N` to be `f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times). If `f(K) ≤ i(K)`, then this sequence is non-decreasing (`LinearMap.iterateMapComap_le_succ`). On the other hand, if `f` is surjective, `i` is injective, and there exists some `m` such that `LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`, then for any `n`, `LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`. In particular, by taking `n = 0`, the kernel of `f` is contained in `K` (`LinearMap.ker_le_of_iterateMapComap_eq_succ`), which is a consequence of `LinearMap.ker_le_comap`. As a special case, if one can take `K` to be zero, then `f` is injective. This is the key result for establishing the strong rank condition for noetherian rings. The construction here is adapted from the proof in Djoković's paper *Epimorphisms of modules which must be isomorphisms* [djokovic1973]. -/ open Function Submodule namespace LinearMap variable {R N M : Type*} [Semiring R] [AddCommMonoid N] [Module R N] [AddCommMonoid M] [Module R M] (f i : N →ₗ[R] M) /-- The `LinearMap.iterateMapComap f i n K : Submodule R N` is `f⁻¹(i(⋯(f⁻¹(i(K)))))` (`n` times). -/ def iterateMapComap (n : ℕ) := (fun K : Submodule R N ↦ (K.map i).comap f)^[n] /-- If `f(K) ≤ i(K)`, then `LinearMap.iterateMapComap` is not decreasing. -/ theorem iterateMapComap_le_succ (K : Submodule R N) (h : K.map f ≤ K.map i) (n : ℕ) : f.iterateMapComap i n K ≤ f.iterateMapComap i (n + 1) K := by nth_rw 2 [iterateMapComap] rw [iterate_succ', Function.comp_apply, ← iterateMapComap, ← map_le_iff_le_comap] induction n with | zero => exact h | succ n ih => simp_rw [iterateMapComap, iterate_succ', Function.comp_apply] calc _ ≤ (f.iterateMapComap i n K).map i := map_comap_le _ _ _ ≤ (((f.iterateMapComap i n K).map f).comap f).map i := map_mono (le_comap_map _ _) _ ≤ _ := map_mono (comap_mono ih) /-- If `f` is surjective, `i` is injective, and there exists some `m` such that `LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`, then for any `n`, `LinearMap.iterateMapComap f i n K = LinearMap.iterateMapComap f i (n + 1) K`. In particular, by taking `n = 0`, the kernel of `f` is contained in `K` (`LinearMap.ker_le_of_iterateMapComap_eq_succ`), which is a consequence of `LinearMap.ker_le_comap`. -/ theorem iterateMapComap_eq_succ (K : Submodule R N) (m : ℕ) (heq : f.iterateMapComap i m K = f.iterateMapComap i (m + 1) K) (hf : Surjective f) (hi : Injective i) (n : ℕ) : f.iterateMapComap i n K = f.iterateMapComap i (n + 1) K := by induction n with | zero => contrapose! heq induction m with | zero => exact heq | succ m ih => rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ'] exact fun H ↦ ih (map_injective_of_injective hi (comap_injective_of_surjective hf H)) | succ n ih => rw [iterateMapComap, iterateMapComap, iterate_succ', iterate_succ', Function.comp_apply, Function.comp_apply, ← iterateMapComap, ← iterateMapComap, ih] /-- If `f` is surjective, `i` is injective, and there exists some `m` such that `LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`, then the kernel of `f` is contained in `K`. This is a corollary of `LinearMap.iterateMapComap_eq_succ` and `LinearMap.ker_le_comap`. As a special case, if one can take `K` to be zero, then `f` is injective. This is the key result for establishing the strong rank condition for noetherian rings. -/ theorem ker_le_of_iterateMapComap_eq_succ (K : Submodule R N) (m : ℕ) (heq : f.iterateMapComap i m K = f.iterateMapComap i (m + 1) K) (hf : Surjective f) (hi : Injective i) : LinearMap.ker f ≤ K := by rw [show K = _ from f.iterateMapComap_eq_succ i K m heq hf hi 0] exact f.ker_le_comap end LinearMap
Algebra\Module\Submodule\Ker.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.Submodule.Map /-! # Kernel of a linear map This file defines the kernel of a linear map. ## Main definitions * `LinearMap.ker`: the kernel of a linear map as a submodule of the domain ## Notations * We continue to use the notations `M →ₛₗ[σ] M₂` and `M →ₗ[R] M₂` for the type of semilinear (resp. linear) maps from `M` to `M₂` over the ring homomorphism `σ` (resp. over the ring `R`). ## Tags linear algebra, vector space, module -/ open Function open Pointwise variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {K : Type*} variable {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} variable {V : Type*} {V₂ : Type*} /-! ### Properties of linear maps -/ namespace LinearMap section AddCommMonoid variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] open Submodule variable {σ₂₁ : R₂ →+* R} {τ₁₂ : R →+* R₂} {τ₂₃ : R₂ →+* R₃} {τ₁₃ : R →+* R₃} variable [RingHomCompTriple τ₁₂ τ₂₃ τ₁₃] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂] /-- The kernel of a linear map `f : M → M₂` is defined to be `comap f ⊥`. This is equivalent to the set of `x : M` such that `f x = 0`. The kernel is a submodule of `M`. -/ def ker (f : F) : Submodule R M := comap f ⊥ @[simp] theorem mem_ker {f : F} {y} : y ∈ ker f ↔ f y = 0 := mem_bot R₂ @[simp] theorem ker_id : ker (LinearMap.id : M →ₗ[R] M) = ⊥ := rfl @[simp] theorem map_coe_ker (f : F) (x : ker f) : f x = 0 := mem_ker.1 x.2 theorem ker_toAddSubmonoid (f : M →ₛₗ[τ₁₂] M₂) : f.ker.toAddSubmonoid = (AddMonoidHom.mker f) := rfl theorem comp_ker_subtype (f : M →ₛₗ[τ₁₂] M₂) : f.comp f.ker.subtype = 0 := LinearMap.ext fun x => mem_ker.1 x.2 theorem ker_comp (f : M →ₛₗ[τ₁₂] M₂) (g : M₂ →ₛₗ[τ₂₃] M₃) : ker (g.comp f : M →ₛₗ[τ₁₃] M₃) = comap f (ker g) := rfl theorem ker_le_ker_comp (f : M →ₛₗ[τ₁₂] M₂) (g : M₂ →ₛₗ[τ₂₃] M₃) : ker f ≤ ker (g.comp f : M →ₛₗ[τ₁₃] M₃) := by rw [ker_comp]; exact comap_mono bot_le theorem ker_sup_ker_le_ker_comp_of_commute {f g : M →ₗ[R] M} (h : Commute f g) : ker f ⊔ ker g ≤ ker (f ∘ₗ g) := by refine sup_le_iff.mpr ⟨?_, ker_le_ker_comp g f⟩ rw [← mul_eq_comp, h.eq, mul_eq_comp] exact ker_le_ker_comp f g @[simp] theorem ker_le_comap {p : Submodule R₂ M₂} (f : M →ₛₗ[τ₁₂] M₂) : ker f ≤ p.comap f := fun x hx ↦ by simp [mem_ker.mp hx] theorem disjoint_ker {f : F} {p : Submodule R M} : Disjoint p (ker f) ↔ ∀ x ∈ p, f x = 0 → x = 0 := by simp [disjoint_def] theorem ker_eq_bot' {f : F} : ker f = ⊥ ↔ ∀ m, f m = 0 → m = 0 := by simpa [disjoint_iff_inf_le] using disjoint_ker (f := f) (p := ⊤) theorem ker_eq_bot_of_inverse {τ₂₁ : R₂ →+* R} [RingHomInvPair τ₁₂ τ₂₁] {f : M →ₛₗ[τ₁₂] M₂} {g : M₂ →ₛₗ[τ₂₁] M} (h : (g.comp f : M →ₗ[R] M) = id) : ker f = ⊥ := ker_eq_bot'.2 fun m hm => by rw [← id_apply (R := R) m, ← h, comp_apply, hm, g.map_zero] theorem le_ker_iff_map [RingHomSurjective τ₁₂] {f : F} {p : Submodule R M} : p ≤ ker f ↔ map f p = ⊥ := by rw [ker, eq_bot_iff, map_le_iff_le_comap] theorem ker_codRestrict {τ₂₁ : R₂ →+* R} (p : Submodule R M) (f : M₂ →ₛₗ[τ₂₁] M) (hf) : ker (codRestrict p f hf) = ker f := by rw [ker, comap_codRestrict, Submodule.map_bot]; rfl theorem ker_restrict [AddCommMonoid M₁] [Module R M₁] {p : Submodule R M} {q : Submodule R M₁} {f : M →ₗ[R] M₁} (hf : ∀ x : M, x ∈ p → f x ∈ q) : ker (f.restrict hf) = LinearMap.ker (f.domRestrict p) := by rw [restrict_eq_codRestrict_domRestrict, ker_codRestrict] @[simp] theorem ker_zero : ker (0 : M →ₛₗ[τ₁₂] M₂) = ⊤ := eq_top_iff'.2 fun x => by simp theorem ker_eq_top {f : M →ₛₗ[τ₁₂] M₂} : ker f = ⊤ ↔ f = 0 := ⟨fun h => ext fun _ => mem_ker.1 <| h.symm ▸ trivial, fun h => h.symm ▸ ker_zero⟩ @[simp] theorem _root_.AddMonoidHom.coe_toIntLinearMap_ker {M M₂ : Type*} [AddCommGroup M] [AddCommGroup M₂] (f : M →+ M₂) : LinearMap.ker f.toIntLinearMap = AddSubgroup.toIntSubmodule f.ker := rfl theorem ker_eq_bot_of_injective {f : F} (hf : Injective f) : ker f = ⊥ := by have : Disjoint ⊤ (ker f) := by -- Porting note: `← map_zero f` should work here, but it needs to be directly applied to H. rw [disjoint_ker] intros _ _ H rw [← map_zero f] at H exact hf H simpa [disjoint_iff_inf_le] /-- The increasing sequence of submodules consisting of the kernels of the iterates of a linear map. -/ @[simps] def iterateKer (f : M →ₗ[R] M) : ℕ →o Submodule R M where toFun n := ker (f ^ n) monotone' n m w x h := by obtain ⟨c, rfl⟩ := Nat.exists_eq_add_of_le w rw [LinearMap.mem_ker] at h rw [LinearMap.mem_ker, add_comm, pow_add, LinearMap.mul_apply, h, LinearMap.map_zero] end AddCommMonoid section Ring variable [Ring R] [Ring R₂] [Ring R₃] variable [AddCommGroup M] [AddCommGroup M₂] [AddCommGroup M₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] variable {τ₁₂ : R →+* R₂} {τ₂₃ : R₂ →+* R₃} {τ₁₃ : R →+* R₃} variable [RingHomCompTriple τ₁₂ τ₂₃ τ₁₃] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂] variable {f : F} open Submodule theorem ker_toAddSubgroup (f : M →ₛₗ[τ₁₂] M₂) : (ker f).toAddSubgroup = f.toAddMonoidHom.ker := rfl theorem sub_mem_ker_iff {x y} : x - y ∈ ker f ↔ f x = f y := by rw [mem_ker, map_sub, sub_eq_zero] theorem disjoint_ker' {p : Submodule R M} : Disjoint p (ker f) ↔ ∀ x ∈ p, ∀ y ∈ p, f x = f y → x = y := disjoint_ker.trans ⟨fun H x hx y hy h => eq_of_sub_eq_zero <| H _ (sub_mem hx hy) (by simp [h]), fun H x h₁ h₂ => H x h₁ 0 (zero_mem _) (by simpa using h₂)⟩ theorem injOn_of_disjoint_ker {p : Submodule R M} {s : Set M} (h : s ⊆ p) (hd : Disjoint p (ker f)) : Set.InjOn f s := fun _ hx _ hy => disjoint_ker'.1 hd _ (h hx) _ (h hy) variable (F) theorem _root_.LinearMapClass.ker_eq_bot : ker f = ⊥ ↔ Injective f := by simpa [disjoint_iff_inf_le] using disjoint_ker' (f := f) (p := ⊤) variable {F} theorem ker_eq_bot {f : M →ₛₗ[τ₁₂] M₂} : ker f = ⊥ ↔ Injective f := LinearMapClass.ker_eq_bot _ @[simp] lemma injective_domRestrict_iff {f : M →ₛₗ[τ₁₂] M₂} {S : Submodule R M} : Injective (f.domRestrict S) ↔ S ⊓ LinearMap.ker f = ⊥ := by rw [← LinearMap.ker_eq_bot] refine ⟨fun h ↦ le_bot_iff.1 ?_, fun h ↦ le_bot_iff.1 ?_⟩ · intro x ⟨hx, h'x⟩ have : ⟨x, hx⟩ ∈ LinearMap.ker (LinearMap.domRestrict f S) := by simpa using h'x rw [h] at this simpa using this · rintro ⟨x, hx⟩ h'x have : x ∈ S ⊓ LinearMap.ker f := ⟨hx, h'x⟩ rw [h] at this simpa using this @[simp] theorem injective_restrict_iff_disjoint {p : Submodule R M} {f : M →ₗ[R] M} (hf : ∀ x ∈ p, f x ∈ p) : Injective (f.restrict hf) ↔ Disjoint p (ker f) := by rw [← ker_eq_bot, ker_restrict hf, ker_eq_bot, injective_domRestrict_iff, disjoint_iff] end Ring section Semifield variable [Semifield K] variable [AddCommMonoid V] [Module K V] variable [AddCommMonoid V₂] [Module K V₂] theorem ker_smul (f : V →ₗ[K] V₂) (a : K) (h : a ≠ 0) : ker (a • f) = ker f := Submodule.comap_smul f _ a h theorem ker_smul' (f : V →ₗ[K] V₂) (a : K) : ker (a • f) = ⨅ _ : a ≠ 0, ker f := Submodule.comap_smul' f _ a end Semifield end LinearMap namespace Submodule section AddCommMonoid variable [Semiring R] [Semiring R₂] [AddCommMonoid M] [AddCommMonoid M₂] variable [Module R M] [Module R₂ M₂] variable (p p' : Submodule R M) (q : Submodule R₂ M₂) variable {τ₁₂ : R →+* R₂} variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂] open LinearMap @[simp] theorem comap_bot (f : F) : comap f ⊥ = ker f := rfl @[simp] theorem ker_subtype : ker p.subtype = ⊥ := ker_eq_bot_of_injective fun _ _ => Subtype.ext_val @[simp] theorem ker_inclusion (p p' : Submodule R M) (h : p ≤ p') : ker (inclusion h) = ⊥ := by rw [inclusion, ker_codRestrict, ker_subtype] end AddCommMonoid end Submodule namespace LinearMap section Semiring variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] variable {τ₁₂ : R →+* R₂} {τ₂₃ : R₂ →+* R₃} {τ₁₃ : R →+* R₃} variable [RingHomCompTriple τ₁₂ τ₂₃ τ₁₃] theorem ker_comp_of_ker_eq_bot (f : M →ₛₗ[τ₁₂] M₂) {g : M₂ →ₛₗ[τ₂₃] M₃} (hg : ker g = ⊥) : ker (g.comp f : M →ₛₗ[τ₁₃] M₃) = ker f := by rw [ker_comp, hg, Submodule.comap_bot] end Semiring end LinearMap /-! ### Linear equivalences -/ namespace LinearEquiv section AddCommMonoid section variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable {module_M : Module R M} {module_M₂ : Module R₂ M₂} {module_M₃ : Module R₃ M₃} variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} variable {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable {σ₃₂ : R₃ →+* R₂} variable {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₁ : RingHomInvPair σ₂₁ σ₁₂} variable {re₂₃ : RingHomInvPair σ₂₃ σ₃₂} {re₃₂ : RingHomInvPair σ₃₂ σ₂₃} variable (e : M ≃ₛₗ[σ₁₂] M₂) (e'' : M₂ ≃ₛₗ[σ₂₃] M₃) @[simp] protected theorem ker : LinearMap.ker (e : M →ₛₗ[σ₁₂] M₂) = ⊥ := LinearMap.ker_eq_bot_of_injective e.toEquiv.injective @[simp] theorem ker_comp (l : M →ₛₗ[σ₁₂] M₂) : LinearMap.ker (((e'' : M₂ →ₛₗ[σ₂₃] M₃).comp l : M →ₛₗ[σ₁₃] M₃) : M →ₛₗ[σ₁₃] M₃) = LinearMap.ker l := LinearMap.ker_comp_of_ker_eq_bot _ e''.ker end end AddCommMonoid end LinearEquiv
Algebra\Module\Submodule\Lattice.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov -/ import Mathlib.Algebra.Module.Equiv.Defs import Mathlib.Algebra.Module.Submodule.Basic import Mathlib.Algebra.PUnitInstances.Module import Mathlib.Data.Set.Subsingleton import Mathlib.Order.ConditionallyCompleteLattice.Basic /-! # The lattice structure on `Submodule`s This file defines the lattice structure on submodules, `Submodule.CompleteLattice`, with `⊥` defined as `{0}` and `⊓` defined as intersection of the underlying carrier. If `p` and `q` are submodules of a module, `p ≤ q` means that `p ⊆ q`. Many results about operations on this lattice structure are defined in `LinearAlgebra/Basic.lean`, most notably those which use `span`. ## Implementation notes This structure should match the `AddSubmonoid.CompleteLattice` structure, and we should try to unify the APIs where possible. -/ universe v variable {R S M : Type*} section AddCommMonoid variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M] [Module S M] variable [SMul S R] [IsScalarTower S R M] variable {p q : Submodule R M} namespace Submodule /-! ## Bottom element of a submodule -/ /-- The set `{0}` is the bottom element of the lattice of submodules. -/ instance : Bot (Submodule R M) := ⟨{ (⊥ : AddSubmonoid M) with carrier := {0} smul_mem' := by simp }⟩ instance inhabited' : Inhabited (Submodule R M) := ⟨⊥⟩ @[simp] theorem bot_coe : ((⊥ : Submodule R M) : Set M) = {0} := rfl @[simp] theorem bot_toAddSubmonoid : (⊥ : Submodule R M).toAddSubmonoid = ⊥ := rfl @[simp] lemma bot_toAddSubgroup {R M} [Ring R] [AddCommGroup M] [Module R M] : (⊥ : Submodule R M).toAddSubgroup = ⊥ := rfl variable (R) in @[simp] theorem mem_bot {x : M} : x ∈ (⊥ : Submodule R M) ↔ x = 0 := Set.mem_singleton_iff instance uniqueBot : Unique (⊥ : Submodule R M) := ⟨inferInstance, fun x ↦ Subtype.ext <| (mem_bot R).1 x.mem⟩ instance : OrderBot (Submodule R M) where bot := ⊥ bot_le p x := by simp (config := { contextual := true }) [zero_mem] protected theorem eq_bot_iff (p : Submodule R M) : p = ⊥ ↔ ∀ x ∈ p, x = (0 : M) := ⟨fun h ↦ h.symm ▸ fun _ hx ↦ (mem_bot R).mp hx, fun h ↦ eq_bot_iff.mpr fun x hx ↦ (mem_bot R).mpr (h x hx)⟩ @[ext high] protected theorem bot_ext (x y : (⊥ : Submodule R M)) : x = y := by rcases x with ⟨x, xm⟩; rcases y with ⟨y, ym⟩; congr rw [(Submodule.eq_bot_iff _).mp rfl x xm] rw [(Submodule.eq_bot_iff _).mp rfl y ym] protected theorem ne_bot_iff (p : Submodule R M) : p ≠ ⊥ ↔ ∃ x ∈ p, x ≠ (0 : M) := by simp only [ne_eq, p.eq_bot_iff, not_forall, exists_prop] theorem nonzero_mem_of_bot_lt {p : Submodule R M} (bot_lt : ⊥ < p) : ∃ a : p, a ≠ 0 := let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp bot_lt.ne' ⟨⟨b, hb₁⟩, hb₂ ∘ congr_arg Subtype.val⟩ theorem exists_mem_ne_zero_of_ne_bot {p : Submodule R M} (h : p ≠ ⊥) : ∃ b : M, b ∈ p ∧ b ≠ 0 := let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp h ⟨b, hb₁, hb₂⟩ -- FIXME: we default PUnit to PUnit.{1} here without the explicit universe annotation /-- The bottom submodule is linearly equivalent to punit as an `R`-module. -/ @[simps] def botEquivPUnit : (⊥ : Submodule R M) ≃ₗ[R] PUnit.{v+1} where toFun _ := PUnit.unit invFun _ := 0 map_add' _ _ := rfl map_smul' _ _ := rfl left_inv _ := Subsingleton.elim _ _ right_inv _ := rfl theorem subsingleton_iff_eq_bot : Subsingleton p ↔ p = ⊥ := by rw [subsingleton_iff, Submodule.eq_bot_iff] refine ⟨fun h x hx ↦ by simpa using h ⟨x, hx⟩ ⟨0, p.zero_mem⟩, fun h ⟨x, hx⟩ ⟨y, hy⟩ ↦ by simp [h x hx, h y hy]⟩ theorem eq_bot_of_subsingleton [Subsingleton p] : p = ⊥ := subsingleton_iff_eq_bot.mp inferInstance theorem nontrivial_iff_ne_bot : Nontrivial p ↔ p ≠ ⊥ := by rw [iff_not_comm, not_nontrivial_iff_subsingleton, subsingleton_iff_eq_bot] /-! ## Top element of a submodule -/ /-- The universal set is the top element of the lattice of submodules. -/ instance : Top (Submodule R M) := ⟨{ (⊤ : AddSubmonoid M) with carrier := Set.univ smul_mem' := fun _ _ _ ↦ trivial }⟩ @[simp] theorem top_coe : ((⊤ : Submodule R M) : Set M) = Set.univ := rfl @[simp] theorem top_toAddSubmonoid : (⊤ : Submodule R M).toAddSubmonoid = ⊤ := rfl @[simp] lemma top_toAddSubgroup {R M} [Ring R] [AddCommGroup M] [Module R M] : (⊤ : Submodule R M).toAddSubgroup = ⊤ := rfl @[simp] theorem mem_top {x : M} : x ∈ (⊤ : Submodule R M) := trivial instance : OrderTop (Submodule R M) where top := ⊤ le_top _ _ _ := trivial theorem eq_top_iff' {p : Submodule R M} : p = ⊤ ↔ ∀ x, x ∈ p := eq_top_iff.trans ⟨fun h _ ↦ h trivial, fun h x _ ↦ h x⟩ /-- The top submodule is linearly equivalent to the module. This is the module version of `AddSubmonoid.topEquiv`. -/ @[simps] def topEquiv : (⊤ : Submodule R M) ≃ₗ[R] M where toFun x := x invFun x := ⟨x, mem_top⟩ map_add' _ _ := rfl map_smul' _ _ := rfl left_inv _ := rfl right_inv _ := rfl /-! ## Infima & suprema in a submodule -/ instance : InfSet (Submodule R M) := ⟨fun S ↦ { carrier := ⋂ s ∈ S, (s : Set M) zero_mem' := by simp [zero_mem] add_mem' := by simp (config := { contextual := true }) [add_mem] smul_mem' := by simp (config := { contextual := true }) [smul_mem] }⟩ private theorem sInf_le' {S : Set (Submodule R M)} {p} : p ∈ S → sInf S ≤ p := Set.biInter_subset_of_mem private theorem le_sInf' {S : Set (Submodule R M)} {p} : (∀ q ∈ S, p ≤ q) → p ≤ sInf S := Set.subset_iInter₂ instance : Inf (Submodule R M) := ⟨fun p q ↦ { carrier := p ∩ q zero_mem' := by simp [zero_mem] add_mem' := by simp (config := { contextual := true }) [add_mem] smul_mem' := by simp (config := { contextual := true }) [smul_mem] }⟩ instance completeLattice : CompleteLattice (Submodule R M) := { (inferInstance : OrderTop (Submodule R M)), (inferInstance : OrderBot (Submodule R M)) with sup := fun a b ↦ sInf { x | a ≤ x ∧ b ≤ x } le_sup_left := fun _ _ ↦ le_sInf' fun _ ⟨h, _⟩ ↦ h le_sup_right := fun _ _ ↦ le_sInf' fun _ ⟨_, h⟩ ↦ h sup_le := fun _ _ _ h₁ h₂ ↦ sInf_le' ⟨h₁, h₂⟩ inf := (· ⊓ ·) le_inf := fun _ _ _ ↦ Set.subset_inter inf_le_left := fun _ _ ↦ Set.inter_subset_left inf_le_right := fun _ _ ↦ Set.inter_subset_right le_sSup := fun _ _ hs ↦ le_sInf' fun _ hq ↦ by exact hq _ hs sSup_le := fun _ _ hs ↦ sInf_le' hs le_sInf := fun _ _ ↦ le_sInf' sInf_le := fun _ _ ↦ sInf_le' } @[simp] theorem inf_coe : ↑(p ⊓ q) = (p ∩ q : Set M) := rfl @[simp] theorem mem_inf {p q : Submodule R M} {x : M} : x ∈ p ⊓ q ↔ x ∈ p ∧ x ∈ q := Iff.rfl @[simp] theorem sInf_coe (P : Set (Submodule R M)) : (↑(sInf P) : Set M) = ⋂ p ∈ P, ↑p := rfl @[simp] theorem finset_inf_coe {ι} (s : Finset ι) (p : ι → Submodule R M) : (↑(s.inf p) : Set M) = ⋂ i ∈ s, ↑(p i) := by letI := Classical.decEq ι refine s.induction_on ?_ fun i s _ ih ↦ ?_ · simp · rw [Finset.inf_insert, inf_coe, ih] simp @[simp] theorem iInf_coe {ι} (p : ι → Submodule R M) : (↑(⨅ i, p i) : Set M) = ⋂ i, ↑(p i) := by rw [iInf, sInf_coe]; simp only [Set.mem_range, Set.iInter_exists, Set.iInter_iInter_eq'] @[simp] theorem mem_sInf {S : Set (Submodule R M)} {x : M} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p := Set.mem_iInter₂ @[simp] theorem mem_iInf {ι} (p : ι → Submodule R M) {x} : (x ∈ ⨅ i, p i) ↔ ∀ i, x ∈ p i := by rw [← SetLike.mem_coe, iInf_coe, Set.mem_iInter]; rfl @[simp] theorem mem_finset_inf {ι} {s : Finset ι} {p : ι → Submodule R M} {x : M} : x ∈ s.inf p ↔ ∀ i ∈ s, x ∈ p i := by simp only [← SetLike.mem_coe, finset_inf_coe, Set.mem_iInter] theorem mem_sup_left {S T : Submodule R M} : ∀ {x : M}, x ∈ S → x ∈ S ⊔ T := by have : S ≤ S ⊔ T := le_sup_left rw [LE.le] at this exact this theorem mem_sup_right {S T : Submodule R M} : ∀ {x : M}, x ∈ T → x ∈ S ⊔ T := by have : T ≤ S ⊔ T := le_sup_right rw [LE.le] at this exact this theorem add_mem_sup {S T : Submodule R M} {s t : M} (hs : s ∈ S) (ht : t ∈ T) : s + t ∈ S ⊔ T := add_mem (mem_sup_left hs) (mem_sup_right ht) theorem sub_mem_sup {R' M' : Type*} [Ring R'] [AddCommGroup M'] [Module R' M'] {S T : Submodule R' M'} {s t : M'} (hs : s ∈ S) (ht : t ∈ T) : s - t ∈ S ⊔ T := by rw [sub_eq_add_neg] exact add_mem_sup hs (neg_mem ht) theorem mem_iSup_of_mem {ι : Sort*} {b : M} {p : ι → Submodule R M} (i : ι) (h : b ∈ p i) : b ∈ ⨆ i, p i := (le_iSup p i) h theorem sum_mem_iSup {ι : Type*} [Fintype ι] {f : ι → M} {p : ι → Submodule R M} (h : ∀ i, f i ∈ p i) : (∑ i, f i) ∈ ⨆ i, p i := sum_mem fun i _ ↦ mem_iSup_of_mem i (h i) theorem sum_mem_biSup {ι : Type*} {s : Finset ι} {f : ι → M} {p : ι → Submodule R M} (h : ∀ i ∈ s, f i ∈ p i) : (∑ i ∈ s, f i) ∈ ⨆ i ∈ s, p i := sum_mem fun i hi ↦ mem_iSup_of_mem i <| mem_iSup_of_mem hi (h i hi) /-! Note that `Submodule.mem_iSup` is provided in `Mathlib/LinearAlgebra/Span.lean`. -/ theorem mem_sSup_of_mem {S : Set (Submodule R M)} {s : Submodule R M} (hs : s ∈ S) : ∀ {x : M}, x ∈ s → x ∈ sSup S := by have := le_sSup hs rw [LE.le] at this exact this @[simp] theorem toAddSubmonoid_sSup (s : Set (Submodule R M)) : (sSup s).toAddSubmonoid = sSup (toAddSubmonoid '' s) := by let p : Submodule R M := { toAddSubmonoid := sSup (toAddSubmonoid '' s) smul_mem' := fun t {m} h ↦ by simp_rw [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, sSup_eq_iSup'] at h ⊢ refine AddSubmonoid.iSup_induction' (C := fun x _ ↦ t • x ∈ ⨆ p : toAddSubmonoid '' s, (p : AddSubmonoid M)) ?_ ?_ (fun x y _ _ ↦ ?_) h · rintro ⟨-, ⟨p : Submodule R M, hp : p ∈ s, rfl⟩⟩ x (hx : x ∈ p) suffices p.toAddSubmonoid ≤ ⨆ q : toAddSubmonoid '' s, (q : AddSubmonoid M) by exact this (smul_mem p t hx) apply le_sSup rw [Subtype.range_coe_subtype] exact ⟨p, hp, rfl⟩ · simpa only [smul_zero] using zero_mem _ · simp_rw [smul_add]; exact add_mem } refine le_antisymm (?_ : sSup s ≤ p) ?_ · exact sSup_le fun q hq ↦ le_sSup <| Set.mem_image_of_mem toAddSubmonoid hq · exact sSup_le fun _ ⟨q, hq, hq'⟩ ↦ hq'.symm ▸ le_sSup hq variable (R) @[simp] theorem subsingleton_iff : Subsingleton (Submodule R M) ↔ Subsingleton M := have h : Subsingleton (Submodule R M) ↔ Subsingleton (AddSubmonoid M) := by rw [← subsingleton_iff_bot_eq_top, ← subsingleton_iff_bot_eq_top, ← toAddSubmonoid_eq, bot_toAddSubmonoid, top_toAddSubmonoid] h.trans AddSubmonoid.subsingleton_iff @[simp] theorem nontrivial_iff : Nontrivial (Submodule R M) ↔ Nontrivial M := not_iff_not.mp ((not_nontrivial_iff_subsingleton.trans <| subsingleton_iff R).trans not_nontrivial_iff_subsingleton.symm) variable {R} instance [Subsingleton M] : Unique (Submodule R M) := ⟨⟨⊥⟩, fun a => @Subsingleton.elim _ ((subsingleton_iff R).mpr ‹_›) a _⟩ instance unique' [Subsingleton R] : Unique (Submodule R M) := by haveI := Module.subsingleton R M; infer_instance instance [Nontrivial M] : Nontrivial (Submodule R M) := (nontrivial_iff R).mpr ‹_› /-! ## Disjointness of submodules -/ theorem disjoint_def {p p' : Submodule R M} : Disjoint p p' ↔ ∀ x ∈ p, x ∈ p' → x = (0 : M) := disjoint_iff_inf_le.trans <| show (∀ x, x ∈ p ∧ x ∈ p' → x ∈ ({0} : Set M)) ↔ _ by simp theorem disjoint_def' {p p' : Submodule R M} : Disjoint p p' ↔ ∀ x ∈ p, ∀ y ∈ p', x = y → x = (0 : M) := disjoint_def.trans ⟨fun h x hx _ hy hxy ↦ h x hx <| hxy.symm ▸ hy, fun h x hx hx' ↦ h _ hx x hx' rfl⟩ theorem eq_zero_of_coe_mem_of_disjoint (hpq : Disjoint p q) {a : p} (ha : (a : M) ∈ q) : a = 0 := mod_cast disjoint_def.mp hpq a (coe_mem a) ha theorem mem_right_iff_eq_zero_of_disjoint {p p' : Submodule R M} (h : Disjoint p p') {x : p} : (x : M) ∈ p' ↔ x = 0 := ⟨fun hx => coe_eq_zero.1 <| disjoint_def.1 h x x.2 hx, fun h => h.symm ▸ p'.zero_mem⟩ theorem mem_left_iff_eq_zero_of_disjoint {p p' : Submodule R M} (h : Disjoint p p') {x : p'} : (x : M) ∈ p ↔ x = 0 := ⟨fun hx => coe_eq_zero.1 <| disjoint_def.1 h x hx x.2, fun h => h.symm ▸ p.zero_mem⟩ end Submodule section NatSubmodule /-! ## ℕ-submodules -/ -- Porting note: `S.toNatSubmodule` doesn't work. I used `AddSubmonoid.toNatSubmodule S` instead. /-- An additive submonoid is equivalent to a ℕ-submodule. -/ def AddSubmonoid.toNatSubmodule : AddSubmonoid M ≃o Submodule ℕ M where toFun S := { S with smul_mem' := fun r s hs ↦ show r • s ∈ S from nsmul_mem hs _ } invFun := Submodule.toAddSubmonoid left_inv _ := rfl right_inv _ := rfl map_rel_iff' := Iff.rfl @[simp] theorem AddSubmonoid.toNatSubmodule_symm : ⇑(AddSubmonoid.toNatSubmodule.symm : _ ≃o AddSubmonoid M) = Submodule.toAddSubmonoid := rfl @[simp] theorem AddSubmonoid.coe_toNatSubmodule (S : AddSubmonoid M) : (AddSubmonoid.toNatSubmodule S : Set M) = S := rfl @[simp] theorem AddSubmonoid.toNatSubmodule_toAddSubmonoid (S : AddSubmonoid M) : S.toNatSubmodule.toAddSubmonoid = S := AddSubmonoid.toNatSubmodule.symm_apply_apply S @[simp] theorem Submodule.toAddSubmonoid_toNatSubmodule (S : Submodule ℕ M) : AddSubmonoid.toNatSubmodule S.toAddSubmonoid = S := AddSubmonoid.toNatSubmodule.apply_symm_apply S end NatSubmodule end AddCommMonoid section IntSubmodule /-! ## ℤ-submodules -/ variable [AddCommGroup M] -- Porting note: `S.toIntSubmodule` doesn't work. I used `AddSubgroup.toIntSubmodule S` instead. /-- An additive subgroup is equivalent to a ℤ-submodule. -/ def AddSubgroup.toIntSubmodule : AddSubgroup M ≃o Submodule ℤ M where toFun S := { S with smul_mem' := fun _ _ hs ↦ S.zsmul_mem hs _ } invFun := Submodule.toAddSubgroup left_inv _ := rfl right_inv _ := rfl map_rel_iff' := Iff.rfl @[simp] theorem AddSubgroup.toIntSubmodule_symm : ⇑(AddSubgroup.toIntSubmodule.symm : _ ≃o AddSubgroup M) = Submodule.toAddSubgroup := rfl @[simp] theorem AddSubgroup.coe_toIntSubmodule (S : AddSubgroup M) : (AddSubgroup.toIntSubmodule S : Set M) = S := rfl @[simp] theorem AddSubgroup.toIntSubmodule_toAddSubgroup (S : AddSubgroup M) : S.toIntSubmodule.toAddSubgroup = S := AddSubgroup.toIntSubmodule.symm_apply_apply S @[simp] theorem Submodule.toAddSubgroup_toIntSubmodule (S : Submodule ℤ M) : AddSubgroup.toIntSubmodule S.toAddSubgroup = S := AddSubgroup.toIntSubmodule.apply_symm_apply S end IntSubmodule
Algebra\Module\Submodule\LinearMap.lean
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.Module.LinearMap.End import Mathlib.Algebra.Module.Submodule.Basic /-! # Linear maps involving submodules of a module In this file we define a number of linear maps involving submodules of a module. ## Main declarations * `Submodule.subtype`: Embedding of a submodule `p` to the ambient space `M` as a `Submodule`. * `LinearMap.domRestrict`: The restriction of a semilinear map `f : M → M₂` to a submodule `p ⊆ M` as a semilinear map `p → M₂`. * `LinearMap.restrict`: The restriction of a linear map `f : M → M₁` to a submodule `p ⊆ M` and `q ⊆ M₁` (if `q` contains the codomain). * `Submodule.inclusion`: the inclusion `p ⊆ p'` of submodules `p` and `p'` as a linear map. ## Tags submodule, subspace, linear map -/ open Function Set universe u'' u' u v w section variable {G : Type u''} {S : Type u'} {R : Type u} {M : Type v} {ι : Type w} namespace SMulMemClass variable [Semiring R] [AddCommMonoid M] [Module R M] {A : Type*} [SetLike A M] [AddSubmonoidClass A M] [SMulMemClass A R M] (S' : A) /-- The natural `R`-linear map from a submodule of an `R`-module `M` to `M`. -/ protected def subtype : S' →ₗ[R] M where toFun := Subtype.val map_add' _ _ := rfl map_smul' _ _ := rfl @[simp] protected theorem coeSubtype : (SMulMemClass.subtype S' : S' → M) = Subtype.val := rfl end SMulMemClass namespace Submodule section AddCommMonoid variable [Semiring R] [AddCommMonoid M] -- We can infer the module structure implicitly from the bundled submodule, -- rather than via typeclass resolution. variable {module_M : Module R M} variable {p q : Submodule R M} variable {r : R} {x y : M} variable (p) /-- Embedding of a submodule `p` to the ambient space `M`. -/ protected def subtype : p →ₗ[R] M where toFun := Subtype.val map_add' := by simp [coe_smul] map_smul' := by simp [coe_smul] theorem subtype_apply (x : p) : p.subtype x = x := rfl @[simp] theorem coeSubtype : (Submodule.subtype p : p → M) = Subtype.val := rfl theorem injective_subtype : Injective p.subtype := Subtype.coe_injective /-- Note the `AddSubmonoid` version of this lemma is called `AddSubmonoid.coe_finset_sum`. -/ -- Porting note: removing the `@[simp]` attribute since it's literally `AddSubmonoid.coe_finset_sum` theorem coe_sum (x : ι → p) (s : Finset ι) : ↑(∑ i ∈ s, x i) = ∑ i ∈ s, (x i : M) := map_sum p.subtype _ _ section AddAction variable {α β : Type*} /-- The action by a submodule is the action by the underlying module. -/ instance [AddAction M α] : AddAction p α := AddAction.compHom _ p.subtype.toAddMonoidHom end AddAction end AddCommMonoid end Submodule end section variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} variable {ι : Type*} namespace LinearMap section AddCommMonoid variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R M₁] [Module R₂ M₂] [Module R₃ M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] M₃) /-- The restriction of a linear map `f : M → M₂` to a submodule `p ⊆ M` gives a linear map `p → M₂`. -/ def domRestrict (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) : p →ₛₗ[σ₁₂] M₂ := f.comp p.subtype @[simp] theorem domRestrict_apply (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) (x : p) : f.domRestrict p x = f x := rfl /-- A linear map `f : M₂ → M` whose values lie in a submodule `p ⊆ M` can be restricted to a linear map M₂ → p. -/ def codRestrict (p : Submodule R₂ M₂) (f : M →ₛₗ[σ₁₂] M₂) (h : ∀ c, f c ∈ p) : M →ₛₗ[σ₁₂] p where toFun c := ⟨f c, h c⟩ map_add' _ _ := by simp map_smul' _ _ := by simp @[simp] theorem codRestrict_apply (p : Submodule R₂ M₂) (f : M →ₛₗ[σ₁₂] M₂) {h} (x : M) : (codRestrict p f h x : M₂) = f x := rfl @[simp] theorem comp_codRestrict (p : Submodule R₃ M₃) (h : ∀ b, g b ∈ p) : ((codRestrict p g h).comp f : M →ₛₗ[σ₁₃] p) = codRestrict p (g.comp f) fun _ => h _ := ext fun _ => rfl @[simp] theorem subtype_comp_codRestrict (p : Submodule R₂ M₂) (h : ∀ b, f b ∈ p) : p.subtype.comp (codRestrict p f h) = f := ext fun _ => rfl /-- Restrict domain and codomain of a linear map. -/ def restrict (f : M →ₗ[R] M₁) {p : Submodule R M} {q : Submodule R M₁} (hf : ∀ x ∈ p, f x ∈ q) : p →ₗ[R] q := (f.domRestrict p).codRestrict q <| SetLike.forall.2 hf @[simp] theorem restrict_coe_apply (f : M →ₗ[R] M₁) {p : Submodule R M} {q : Submodule R M₁} (hf : ∀ x ∈ p, f x ∈ q) (x : p) : ↑(f.restrict hf x) = f x := rfl theorem restrict_apply {f : M →ₗ[R] M₁} {p : Submodule R M} {q : Submodule R M₁} (hf : ∀ x ∈ p, f x ∈ q) (x : p) : f.restrict hf x = ⟨f x, hf x.1 x.2⟩ := rfl lemma restrict_sub {R M M₁ : Type*} [Ring R] [AddCommGroup M] [AddCommGroup M₁] [Module R M] [Module R M₁] {p : Submodule R M} {q : Submodule R M₁} {f g : M →ₗ[R] M₁} (hf : MapsTo f p q) (hg : MapsTo g p q) (hfg : MapsTo (f - g) p q := fun _ hx ↦ q.sub_mem (hf hx) (hg hx)) : f.restrict hf - g.restrict hg = (f - g).restrict hfg := by ext; simp lemma restrict_comp {M₂ M₃ : Type*} [AddCommMonoid M₂] [AddCommMonoid M₃] [Module R M₂] [Module R M₃] {p : Submodule R M} {p₂ : Submodule R M₂} {p₃ : Submodule R M₃} {f : M →ₗ[R] M₂} {g : M₂ →ₗ[R] M₃} (hf : MapsTo f p p₂) (hg : MapsTo g p₂ p₃) (hfg : MapsTo (g ∘ₗ f) p p₃ := hg.comp hf) : (g ∘ₗ f).restrict hfg = (g.restrict hg) ∘ₗ (f.restrict hf) := rfl lemma restrict_commute {f g : M →ₗ[R] M} (h : Commute f g) {p : Submodule R M} (hf : MapsTo f p p) (hg : MapsTo g p p) : Commute (f.restrict hf) (g.restrict hg) := by change _ * _ = _ * _ conv_lhs => rw [mul_eq_comp, ← restrict_comp]; congr; rw [← mul_eq_comp, h.eq] rfl theorem subtype_comp_restrict {f : M →ₗ[R] M₁} {p : Submodule R M} {q : Submodule R M₁} (hf : ∀ x ∈ p, f x ∈ q) : q.subtype.comp (f.restrict hf) = f.domRestrict p := rfl theorem restrict_eq_codRestrict_domRestrict {f : M →ₗ[R] M₁} {p : Submodule R M} {q : Submodule R M₁} (hf : ∀ x ∈ p, f x ∈ q) : f.restrict hf = (f.domRestrict p).codRestrict q fun x => hf x.1 x.2 := rfl theorem restrict_eq_domRestrict_codRestrict {f : M →ₗ[R] M₁} {p : Submodule R M} {q : Submodule R M₁} (hf : ∀ x, f x ∈ q) : (f.restrict fun x _ => hf x) = (f.codRestrict q hf).domRestrict p := rfl theorem sum_apply (t : Finset ι) (f : ι → M →ₛₗ[σ₁₂] M₂) (b : M) : (∑ d ∈ t, f d) b = ∑ d ∈ t, f d b := _root_.map_sum ((AddMonoidHom.eval b).comp toAddMonoidHom') f _ @[simp, norm_cast] theorem coeFn_sum {ι : Type*} (t : Finset ι) (f : ι → M →ₛₗ[σ₁₂] M₂) : ⇑(∑ i ∈ t, f i) = ∑ i ∈ t, (f i : M → M₂) := _root_.map_sum (show AddMonoidHom (M →ₛₗ[σ₁₂] M₂) (M → M₂) from { toFun := DFunLike.coe, map_zero' := rfl map_add' := fun _ _ => rfl }) _ _ theorem submodule_pow_eq_zero_of_pow_eq_zero {N : Submodule R M} {g : Module.End R N} {G : Module.End R M} (h : G.comp N.subtype = N.subtype.comp g) {k : ℕ} (hG : G ^ k = 0) : g ^ k = 0 := by ext m have hg : N.subtype.comp (g ^ k) m = 0 := by rw [← commute_pow_left_of_commute h, hG, zero_comp, zero_apply] simpa using hg section variable {f' : M →ₗ[R] M} theorem pow_apply_mem_of_forall_mem {p : Submodule R M} (n : ℕ) (h : ∀ x ∈ p, f' x ∈ p) (x : M) (hx : x ∈ p) : (f' ^ n) x ∈ p := by induction' n with n ih generalizing x · simpa · simpa only [iterate_succ, coe_comp, Function.comp_apply, restrict_apply] using ih _ (h _ hx) theorem pow_restrict {p : Submodule R M} (n : ℕ) (h : ∀ x ∈ p, f' x ∈ p) (h' := pow_apply_mem_of_forall_mem n h) : (f'.restrict h) ^ n = (f' ^ n).restrict h' := by ext x have : Semiconj (↑) (f'.restrict h) f' := fun _ ↦ restrict_coe_apply _ _ _ simp [coe_pow, this.iterate_right _ _] end end AddCommMonoid section CommSemiring variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid M₂] variable [Module R M] [Module R M₂] variable (f g : M →ₗ[R] M₂) /-- Alternative version of `domRestrict` as a linear map. -/ def domRestrict' (p : Submodule R M) : (M →ₗ[R] M₂) →ₗ[R] p →ₗ[R] M₂ where toFun φ := φ.domRestrict p map_add' := by simp [LinearMap.ext_iff] map_smul' := by simp [LinearMap.ext_iff] @[simp] theorem domRestrict'_apply (f : M →ₗ[R] M₂) (p : Submodule R M) (x : p) : domRestrict' p f x = f x := rfl end CommSemiring end LinearMap end namespace Submodule section AddCommMonoid variable {R : Type*} {M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] {p p' : Submodule R M} /-- If two submodules `p` and `p'` satisfy `p ⊆ p'`, then `inclusion p p'` is the linear map version of this inclusion. -/ def inclusion (h : p ≤ p') : p →ₗ[R] p' := p.subtype.codRestrict p' fun ⟨_, hx⟩ => h hx @[simp] theorem coe_inclusion (h : p ≤ p') (x : p) : (inclusion h x : M) = x := rfl theorem inclusion_apply (h : p ≤ p') (x : p) : inclusion h x = ⟨x, h x.2⟩ := rfl theorem inclusion_injective (h : p ≤ p') : Function.Injective (inclusion h) := fun _ _ h => Subtype.val_injective (Subtype.mk.inj h) variable (p p') theorem subtype_comp_inclusion (p q : Submodule R M) (h : p ≤ q) : q.subtype.comp (inclusion h) = p.subtype := by ext ⟨b, hb⟩ rfl end AddCommMonoid end Submodule
Algebra\Module\Submodule\Localization.lean
/- Copyright (c) 2024 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Algebra.Module.LocalizedModule import Mathlib.LinearAlgebra.Quotient import Mathlib.RingTheory.Localization.Module /-! # Localization of Submodules Results about localizations of submodules and quotient modules are provided in this file. ## Main result - `Submodule.localized`: The localization of an `R`-submodule of `M` at `p` viewed as an `Rₚ`-submodule of `Mₚ`. - `Submodule.toLocalized`: The localization map of a submodule `M' →ₗ[R] M'.localized p`. - `Submodule.toLocalizedQuotient`: The localization map of a quotient module `M ⧸ M' →ₗ[R] LocalizedModule p M ⧸ M'.localized p`. ## TODO - Statements regarding the exactness of localization. - Connection with flatness. -/ open nonZeroDivisors universe u u' v v' w w' variable {R : Type u} (S : Type u') {M : Type v} {N : Type v'} variable [CommRing R] [CommRing S] [AddCommGroup M] [AddCommGroup N] variable [Module R M] [Module R N] [Algebra R S] [Module S N] [IsScalarTower R S N] variable (p : Submonoid R) [IsLocalization p S] (f : M →ₗ[R] N) [IsLocalizedModule p f] variable (hp : p ≤ R⁰) variable (M' : Submodule R M) /-- Let `S` be the localization of `R` at `p` and `N` be the localization of `M` at `p`. This is the localization of an `R`-submodule of `M` viewed as an `S`-submodule of `N`. -/ def Submodule.localized' : Submodule S N where carrier := { x | ∃ m ∈ M', ∃ s : p, IsLocalizedModule.mk' f m s = x } add_mem' := fun {x} {y} ⟨m, hm, s, hx⟩ ⟨n, hn, t, hy⟩ ↦ ⟨t • m + s • n, add_mem (M'.smul_mem t hm) (M'.smul_mem s hn), s * t, by rw [← hx, ← hy, IsLocalizedModule.mk'_add_mk']⟩ zero_mem' := ⟨0, zero_mem _, 1, by simp⟩ smul_mem' := fun r x h ↦ by have ⟨m, hm, s, hx⟩ := h have ⟨y, t, hyt⟩ := IsLocalization.mk'_surjective p r exact ⟨y • m, M'.smul_mem y hm, t * s, by simp [← hyt, ← hx, IsLocalizedModule.mk'_smul_mk']⟩ lemma Submodule.mem_localized' (x : N) : x ∈ Submodule.localized' S p f M' ↔ ∃ m ∈ M', ∃ s : p, IsLocalizedModule.mk' f m s = x := Iff.rfl /-- The localization of an `R`-submodule of `M` at `p` viewed as an `Rₚ`-submodule of `Mₚ`. -/ abbrev Submodule.localized : Submodule (Localization p) (LocalizedModule p M) := M'.localized' (Localization p) p (LocalizedModule.mkLinearMap p M) /-- The localization map of a submodule. -/ @[simps!] def Submodule.toLocalized' : M' →ₗ[R] M'.localized' S p f := f.restrict (q := (M'.localized' S p f).restrictScalars R) (fun x hx ↦ ⟨x, hx, 1, by simp⟩) /-- The localization map of a submodule. -/ abbrev Submodule.toLocalized : M' →ₗ[R] M'.localized p := M'.toLocalized' (Localization p) p (LocalizedModule.mkLinearMap p M) instance Submodule.isLocalizedModule : IsLocalizedModule p (M'.toLocalized' S p f) where map_units x := by simp_rw [Module.End_isUnit_iff] constructor · exact fun _ _ e ↦ Subtype.ext (IsLocalizedModule.smul_injective f x (congr_arg Subtype.val e)) · rintro m use (IsLocalization.mk' S 1 x) • m rw [Module.algebraMap_end_apply, ← smul_assoc, IsLocalization.smul_mk'_one, IsLocalization.mk'_self', one_smul] surj' := by rintro ⟨y, x, hx, s, rfl⟩ exact ⟨⟨⟨x, hx⟩, s⟩, by ext; simp⟩ exists_of_eq e := by simpa [Subtype.ext_iff] using IsLocalizedModule.exists_of_eq (S := p) (f := f) (congr_arg Subtype.val e) /-- The localization map of a quotient module. -/ def Submodule.toLocalizedQuotient' : M ⧸ M' →ₗ[R] N ⧸ M'.localized' S p f := Submodule.mapQ M' ((M'.localized' S p f).restrictScalars R) f (fun x hx ↦ ⟨x, hx, 1, by simp⟩) /-- The localization map of a quotient module. -/ abbrev Submodule.toLocalizedQuotient : M ⧸ M' →ₗ[R] LocalizedModule p M ⧸ M'.localized p := M'.toLocalizedQuotient' (Localization p) p (LocalizedModule.mkLinearMap p M) @[simp] lemma Submodule.toLocalizedQuotient'_mk (x : M) : M'.toLocalizedQuotient' S p f (Submodule.Quotient.mk x) = Submodule.Quotient.mk (f x) := rfl open Submodule Submodule.Quotient IsLocalization in instance IsLocalizedModule.toLocalizedQuotient' (M' : Submodule R M) : IsLocalizedModule p (M'.toLocalizedQuotient' S p f) where map_units x := by refine (Module.End_isUnit_iff _).mpr ⟨fun m n e ↦ ?_, fun m ↦ ⟨(IsLocalization.mk' S 1 x) • m, by rw [Module.algebraMap_end_apply, ← smul_assoc, smul_mk'_one, mk'_self', one_smul]⟩⟩ obtain ⟨⟨m, rfl⟩, n, rfl⟩ := PProd.mk (mk_surjective _ m) (mk_surjective _ n) simp only [Module.algebraMap_end_apply, ← mk_smul, Submodule.Quotient.eq, ← smul_sub] at e replace e := Submodule.smul_mem _ (IsLocalization.mk' S 1 x) e rwa [smul_comm, ← smul_assoc, smul_mk'_one, mk'_self', one_smul, ← Submodule.Quotient.eq] at e surj' y := by obtain ⟨y, rfl⟩ := mk_surjective _ y obtain ⟨⟨y, s⟩, rfl⟩ := IsLocalizedModule.mk'_surjective p f y exact ⟨⟨Submodule.Quotient.mk y, s⟩, by simp only [Function.uncurry_apply_pair, toLocalizedQuotient'_mk, ← mk_smul, mk'_cancel']⟩ exists_of_eq {m n} e := by obtain ⟨⟨m, rfl⟩, n, rfl⟩ := PProd.mk (mk_surjective _ m) (mk_surjective _ n) obtain ⟨x, hx, s, hs⟩ : f (m - n) ∈ _ := by simpa [Submodule.Quotient.eq] using e obtain ⟨c, hc⟩ := exists_of_eq (S := p) (show f (s • (m - n)) = f x by simp [-map_sub, ← hs]) exact ⟨c * s, by simpa only [← Quotient.mk_smul, Submodule.Quotient.eq, ← smul_sub, mul_smul, hc] using M'.smul_mem c hx⟩ instance (M' : Submodule R M) : IsLocalizedModule p (M'.toLocalizedQuotient p) := IsLocalizedModule.toLocalizedQuotient' _ _ _ _ section LinearMap variable {P : Type w} [AddCommGroup P] [Module R P] variable {Q : Type w'} [AddCommGroup Q] [Module R Q] [Module S Q] [IsScalarTower R S Q] variable (f' : P →ₗ[R] Q) [IsLocalizedModule p f'] lemma LinearMap.localized'_ker_eq_ker_localizedMap (g : M →ₗ[R] P) : Submodule.localized' S p f (LinearMap.ker g) = LinearMap.ker ((IsLocalizedModule.map p f f' g).extendScalarsOfIsLocalization p S) := by ext x simp only [Submodule.mem_localized', mem_ker, extendScalarsOfIsLocalization_apply'] constructor · rintro ⟨m, hm, a, ha, rfl⟩ rw [IsLocalizedModule.map_mk', hm] simp · intro h obtain ⟨⟨a, b⟩, rfl⟩ := IsLocalizedModule.mk'_surjective p f x simp only [Function.uncurry_apply_pair, IsLocalizedModule.map_mk', IsLocalizedModule.mk'_eq_zero, IsLocalizedModule.eq_zero_iff p f'] at h obtain ⟨c, hc⟩ := h refine ⟨c • a, by simpa, c * b, by simp⟩ lemma LinearMap.ker_localizedMap_eq_localized'_ker (g : M →ₗ[R] P) : LinearMap.ker (IsLocalizedModule.map p f f' g) = ((LinearMap.ker g).localized' S p f).restrictScalars _ := by ext simp [localized'_ker_eq_ker_localizedMap S p f f'] /-- The canonical map from the kernel of `g` to the kernel of `g` localized at a submonoid. This is a localization map by `LinearMap.toKerLocalized_isLocalizedModule`. -/ @[simps!] noncomputable def LinearMap.toKerIsLocalized (g : M →ₗ[R] P) : ker g →ₗ[R] ker (IsLocalizedModule.map p f f' g) := f.restrict (fun x hx ↦ by simp [LinearMap.mem_ker, LinearMap.mem_ker.mp hx]) /-- The canonical map to the kernel of the localization of `g` is localizing. In other words, localization commutes with kernels. -/ lemma LinearMap.toKerLocalized_isLocalizedModule (g : M →ₗ[R] P) : IsLocalizedModule p (toKerIsLocalized p f f' g) := let e : Submodule.localized' S p f (ker g) ≃ₗ[S] ker ((IsLocalizedModule.map p f f' g).extendScalarsOfIsLocalization p S) := LinearEquiv.ofEq _ _ (localized'_ker_eq_ker_localizedMap S p f f' g) IsLocalizedModule.of_linearEquiv p (Submodule.toLocalized' S p f (ker g)) (e.restrictScalars R) end LinearMap
Algebra\Module\Submodule\Map.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Algebra.Module.Submodule.Lattice import Mathlib.Algebra.Module.Submodule.LinearMap /-! # `map` and `comap` for `Submodule`s ## Main declarations * `Submodule.map`: The pushforward of a submodule `p ⊆ M` by `f : M → M₂` * `Submodule.comap`: The pullback of a submodule `p ⊆ M₂` along `f : M → M₂` * `Submodule.giMapComap`: `map f` and `comap f` form a `GaloisInsertion` when `f` is surjective. * `Submodule.gciMapComap`: `map f` and `comap f` form a `GaloisCoinsertion` when `f` is injective. ## Tags submodule, subspace, linear map, pushforward, pullback -/ open Function Pointwise Set variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*} variable {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*} namespace Submodule section AddCommMonoid variable [Semiring R] [Semiring R₂] [Semiring R₃] variable [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃] variable [Module R M] [Module R₂ M₂] [Module R₃ M₃] variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃} variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] variable (p p' : Submodule R M) (q q' : Submodule R₂ M₂) variable {x : M} section variable [RingHomSurjective σ₁₂] {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] /-- The pushforward of a submodule `p ⊆ M` by `f : M → M₂` -/ def map (f : F) (p : Submodule R M) : Submodule R₂ M₂ := { p.toAddSubmonoid.map f with carrier := f '' p smul_mem' := by rintro c x ⟨y, hy, rfl⟩ obtain ⟨a, rfl⟩ := σ₁₂.surjective c exact ⟨_, p.smul_mem a hy, map_smulₛₗ f _ _⟩ } @[simp] theorem map_coe (f : F) (p : Submodule R M) : (map f p : Set M₂) = f '' p := rfl theorem map_toAddSubmonoid (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) : (p.map f).toAddSubmonoid = p.toAddSubmonoid.map (f : M →+ M₂) := SetLike.coe_injective rfl theorem map_toAddSubmonoid' (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) : (p.map f).toAddSubmonoid = p.toAddSubmonoid.map f := SetLike.coe_injective rfl @[simp] theorem _root_.AddMonoidHom.coe_toIntLinearMap_map {A A₂ : Type*} [AddCommGroup A] [AddCommGroup A₂] (f : A →+ A₂) (s : AddSubgroup A) : (AddSubgroup.toIntSubmodule s).map f.toIntLinearMap = AddSubgroup.toIntSubmodule (s.map f) := rfl @[simp] theorem _root_.MonoidHom.coe_toAdditive_map {G G₂ : Type*} [Group G] [Group G₂] (f : G →* G₂) (s : Subgroup G) : s.toAddSubgroup.map (MonoidHom.toAdditive f) = Subgroup.toAddSubgroup (s.map f) := rfl @[simp] theorem _root_.AddMonoidHom.coe_toMultiplicative_map {G G₂ : Type*} [AddGroup G] [AddGroup G₂] (f : G →+ G₂) (s : AddSubgroup G) : s.toSubgroup.map (AddMonoidHom.toMultiplicative f) = AddSubgroup.toSubgroup (s.map f) := rfl @[simp] theorem mem_map {f : F} {p : Submodule R M} {x : M₂} : x ∈ map f p ↔ ∃ y, y ∈ p ∧ f y = x := Iff.rfl theorem mem_map_of_mem {f : F} {p : Submodule R M} {r} (h : r ∈ p) : f r ∈ map f p := Set.mem_image_of_mem _ h theorem apply_coe_mem_map (f : F) {p : Submodule R M} (r : p) : f r ∈ map f p := mem_map_of_mem r.prop @[simp] theorem map_id : map (LinearMap.id : M →ₗ[R] M) p = p := Submodule.ext fun a => by simp theorem map_comp [RingHomSurjective σ₂₃] [RingHomSurjective σ₁₃] (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] M₃) (p : Submodule R M) : map (g.comp f : M →ₛₗ[σ₁₃] M₃) p = map g (map f p) := SetLike.coe_injective <| by simp only [← image_comp, map_coe, LinearMap.coe_comp, comp_apply] theorem map_mono {f : F} {p p' : Submodule R M} : p ≤ p' → map f p ≤ map f p' := image_subset _ @[simp] theorem map_zero : map (0 : M →ₛₗ[σ₁₂] M₂) p = ⊥ := have : ∃ x : M, x ∈ p := ⟨0, p.zero_mem⟩ ext <| by simp [this, eq_comm] theorem map_add_le (f g : M →ₛₗ[σ₁₂] M₂) : map (f + g) p ≤ map f p ⊔ map g p := by rintro x ⟨m, hm, rfl⟩ exact add_mem_sup (mem_map_of_mem hm) (mem_map_of_mem hm) theorem map_inf_le (f : F) {p q : Submodule R M} : (p ⊓ q).map f ≤ p.map f ⊓ q.map f := image_inter_subset f p q theorem map_inf (f : F) {p q : Submodule R M} (hf : Injective f) : (p ⊓ q).map f = p.map f ⊓ q.map f := SetLike.coe_injective <| Set.image_inter hf theorem range_map_nonempty (N : Submodule R M) : (Set.range (fun ϕ => Submodule.map ϕ N : (M →ₛₗ[σ₁₂] M₂) → Submodule R₂ M₂)).Nonempty := ⟨_, Set.mem_range.mpr ⟨0, rfl⟩⟩ end section SemilinearMap variable {σ₂₁ : R₂ →+* R} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] /-- The pushforward of a submodule by an injective linear map is linearly equivalent to the original submodule. See also `LinearEquiv.submoduleMap` for a computable version when `f` has an explicit inverse. -/ noncomputable def equivMapOfInjective (f : F) (i : Injective f) (p : Submodule R M) : p ≃ₛₗ[σ₁₂] p.map f := { Equiv.Set.image f p i with map_add' := by intros simp only [coe_add, map_add, Equiv.toFun_as_coe, Equiv.Set.image_apply] rfl map_smul' := by intros -- Note: #8386 changed `map_smulₛₗ` into `map_smulₛₗ _` simp only [coe_smul_of_tower, map_smulₛₗ _, Equiv.toFun_as_coe, Equiv.Set.image_apply] rfl } @[simp] theorem coe_equivMapOfInjective_apply (f : F) (i : Injective f) (p : Submodule R M) (x : p) : (equivMapOfInjective f i p x : M₂) = f x := rfl @[simp] theorem map_equivMapOfInjective_symm_apply (f : F) (i : Injective f) (p : Submodule R M) (x : p.map f) : f ((equivMapOfInjective f i p).symm x) = x := by rw [← LinearEquiv.apply_symm_apply (equivMapOfInjective f i p) x, coe_equivMapOfInjective_apply, i.eq_iff, LinearEquiv.apply_symm_apply] /-- The pullback of a submodule `p ⊆ M₂` along `f : M → M₂` -/ def comap [SemilinearMapClass F σ₁₂ M M₂] (f : F) (p : Submodule R₂ M₂) : Submodule R M := { p.toAddSubmonoid.comap f with carrier := f ⁻¹' p -- Note: #8386 added `map_smulₛₗ _` smul_mem' := fun a x h => by simp [p.smul_mem (σ₁₂ a) h, map_smulₛₗ _] } @[simp] theorem comap_coe (f : F) (p : Submodule R₂ M₂) : (comap f p : Set M) = f ⁻¹' p := rfl @[simp] theorem AddMonoidHom.coe_toIntLinearMap_comap {A A₂ : Type*} [AddCommGroup A] [AddCommGroup A₂] (f : A →+ A₂) (s : AddSubgroup A₂) : (AddSubgroup.toIntSubmodule s).comap f.toIntLinearMap = AddSubgroup.toIntSubmodule (s.comap f) := rfl @[simp] theorem mem_comap {f : F} {p : Submodule R₂ M₂} : x ∈ comap f p ↔ f x ∈ p := Iff.rfl @[simp] theorem comap_id : comap (LinearMap.id : M →ₗ[R] M) p = p := SetLike.coe_injective rfl theorem comap_comp (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₃] M₃) (p : Submodule R₃ M₃) : comap (g.comp f : M →ₛₗ[σ₁₃] M₃) p = comap f (comap g p) := rfl theorem comap_mono {f : F} {q q' : Submodule R₂ M₂} : q ≤ q' → comap f q ≤ comap f q' := preimage_mono theorem le_comap_pow_of_le_comap (p : Submodule R M) {f : M →ₗ[R] M} (h : p ≤ p.comap f) (k : ℕ) : p ≤ p.comap (f ^ k) := by induction' k with k ih · simp [LinearMap.one_eq_id] · simp [LinearMap.iterate_succ, comap_comp, h.trans (comap_mono ih)] section variable [RingHomSurjective σ₁₂] theorem map_le_iff_le_comap {f : F} {p : Submodule R M} {q : Submodule R₂ M₂} : map f p ≤ q ↔ p ≤ comap f q := image_subset_iff theorem gc_map_comap (f : F) : GaloisConnection (map f) (comap f) | _, _ => map_le_iff_le_comap @[simp] theorem map_bot (f : F) : map f ⊥ = ⊥ := (gc_map_comap f).l_bot @[simp] theorem map_sup (f : F) : map f (p ⊔ p') = map f p ⊔ map f p' := (gc_map_comap f : GaloisConnection (map f) (comap f)).l_sup @[simp] theorem map_iSup {ι : Sort*} (f : F) (p : ι → Submodule R M) : map f (⨆ i, p i) = ⨆ i, map f (p i) := (gc_map_comap f : GaloisConnection (map f) (comap f)).l_iSup end @[simp] theorem comap_top (f : F) : comap f ⊤ = ⊤ := rfl @[simp] theorem comap_inf (f : F) : comap f (q ⊓ q') = comap f q ⊓ comap f q' := rfl @[simp] theorem comap_iInf [RingHomSurjective σ₁₂] {ι : Sort*} (f : F) (p : ι → Submodule R₂ M₂) : comap f (⨅ i, p i) = ⨅ i, comap f (p i) := (gc_map_comap f : GaloisConnection (map f) (comap f)).u_iInf @[simp] theorem comap_zero : comap (0 : M →ₛₗ[σ₁₂] M₂) q = ⊤ := ext <| by simp theorem map_comap_le [RingHomSurjective σ₁₂] (f : F) (q : Submodule R₂ M₂) : map f (comap f q) ≤ q := (gc_map_comap f).l_u_le _ theorem le_comap_map [RingHomSurjective σ₁₂] (f : F) (p : Submodule R M) : p ≤ comap f (map f p) := (gc_map_comap f).le_u_l _ section GaloisInsertion variable [RingHomSurjective σ₁₂] {f : F} /-- `map f` and `comap f` form a `GaloisInsertion` when `f` is surjective. -/ def giMapComap (hf : Surjective f) : GaloisInsertion (map f) (comap f) := (gc_map_comap f).toGaloisInsertion fun S x hx => by rcases hf x with ⟨y, rfl⟩ simp only [mem_map, mem_comap] exact ⟨y, hx, rfl⟩ variable (hf : Surjective f) theorem map_comap_eq_of_surjective (p : Submodule R₂ M₂) : (p.comap f).map f = p := (giMapComap hf).l_u_eq _ theorem map_surjective_of_surjective : Function.Surjective (map f) := (giMapComap hf).l_surjective theorem comap_injective_of_surjective : Function.Injective (comap f) := (giMapComap hf).u_injective theorem map_sup_comap_of_surjective (p q : Submodule R₂ M₂) : (p.comap f ⊔ q.comap f).map f = p ⊔ q := (giMapComap hf).l_sup_u _ _ theorem map_iSup_comap_of_sujective {ι : Sort*} (S : ι → Submodule R₂ M₂) : (⨆ i, (S i).comap f).map f = iSup S := (giMapComap hf).l_iSup_u _ theorem map_inf_comap_of_surjective (p q : Submodule R₂ M₂) : (p.comap f ⊓ q.comap f).map f = p ⊓ q := (giMapComap hf).l_inf_u _ _ theorem map_iInf_comap_of_surjective {ι : Sort*} (S : ι → Submodule R₂ M₂) : (⨅ i, (S i).comap f).map f = iInf S := (giMapComap hf).l_iInf_u _ theorem comap_le_comap_iff_of_surjective (p q : Submodule R₂ M₂) : p.comap f ≤ q.comap f ↔ p ≤ q := (giMapComap hf).u_le_u_iff theorem comap_strictMono_of_surjective : StrictMono (comap f) := (giMapComap hf).strictMono_u end GaloisInsertion section GaloisCoinsertion variable [RingHomSurjective σ₁₂] {f : F} /-- `map f` and `comap f` form a `GaloisCoinsertion` when `f` is injective. -/ def gciMapComap (hf : Injective f) : GaloisCoinsertion (map f) (comap f) := (gc_map_comap f).toGaloisCoinsertion fun S x => by simp [mem_comap, mem_map, forall_exists_index, and_imp] intro y hy hxy rw [hf.eq_iff] at hxy rwa [← hxy] variable (hf : Injective f) theorem comap_map_eq_of_injective (p : Submodule R M) : (p.map f).comap f = p := (gciMapComap hf).u_l_eq _ theorem comap_surjective_of_injective : Function.Surjective (comap f) := (gciMapComap hf).u_surjective theorem map_injective_of_injective : Function.Injective (map f) := (gciMapComap hf).l_injective theorem comap_inf_map_of_injective (p q : Submodule R M) : (p.map f ⊓ q.map f).comap f = p ⊓ q := (gciMapComap hf).u_inf_l _ _ theorem comap_iInf_map_of_injective {ι : Sort*} (S : ι → Submodule R M) : (⨅ i, (S i).map f).comap f = iInf S := (gciMapComap hf).u_iInf_l _ theorem comap_sup_map_of_injective (p q : Submodule R M) : (p.map f ⊔ q.map f).comap f = p ⊔ q := (gciMapComap hf).u_sup_l _ _ theorem comap_iSup_map_of_injective {ι : Sort*} (S : ι → Submodule R M) : (⨆ i, (S i).map f).comap f = iSup S := (gciMapComap hf).u_iSup_l _ theorem map_le_map_iff_of_injective (p q : Submodule R M) : p.map f ≤ q.map f ↔ p ≤ q := (gciMapComap hf).l_le_l_iff theorem map_strictMono_of_injective : StrictMono (map f) := (gciMapComap hf).strictMono_l end GaloisCoinsertion end SemilinearMap section OrderIso variable [RingHomSurjective σ₁₂] {F : Type*} /-- A linear isomorphism induces an order isomorphism of submodules. -/ @[simps symm_apply apply] def orderIsoMapComapOfBijective [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] (f : F) (hf : Bijective f) : Submodule R M ≃o Submodule R₂ M₂ where toFun := map f invFun := comap f left_inv := comap_map_eq_of_injective hf.injective right_inv := map_comap_eq_of_surjective hf.surjective map_rel_iff' := map_le_map_iff_of_injective hf.injective _ _ /-- A linear isomorphism induces an order isomorphism of submodules. -/ @[simps! symm_apply apply] def orderIsoMapComap [EquivLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] (f : F) : Submodule R M ≃o Submodule R₂ M₂ := orderIsoMapComapOfBijective f (EquivLike.bijective f) end OrderIso variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] --TODO(Mario): is there a way to prove this from order properties? theorem map_inf_eq_map_inf_comap [RingHomSurjective σ₁₂] {f : F} {p : Submodule R M} {p' : Submodule R₂ M₂} : map f p ⊓ p' = map f (p ⊓ comap f p') := le_antisymm (by rintro _ ⟨⟨x, h₁, rfl⟩, h₂⟩; exact ⟨_, ⟨h₁, h₂⟩, rfl⟩) (le_inf (map_mono inf_le_left) (map_le_iff_le_comap.2 inf_le_right)) @[simp] theorem map_comap_subtype : map p.subtype (comap p.subtype p') = p ⊓ p' := ext fun x => ⟨by rintro ⟨⟨_, h₁⟩, h₂, rfl⟩; exact ⟨h₁, h₂⟩, fun ⟨h₁, h₂⟩ => ⟨⟨_, h₁⟩, h₂, rfl⟩⟩ theorem eq_zero_of_bot_submodule : ∀ b : (⊥ : Submodule R M), b = 0 | ⟨b', hb⟩ => Subtype.eq <| show b' = 0 from (mem_bot R).1 hb /-- The infimum of a family of invariant submodule of an endomorphism is also an invariant submodule. -/ theorem _root_.LinearMap.iInf_invariant {σ : R →+* R} [RingHomSurjective σ] {ι : Sort*} (f : M →ₛₗ[σ] M) {p : ι → Submodule R M} (hf : ∀ i, ∀ v ∈ p i, f v ∈ p i) : ∀ v ∈ iInf p, f v ∈ iInf p := by have : ∀ i, (p i).map f ≤ p i := by rintro i - ⟨v, hv, rfl⟩ exact hf i v hv suffices (iInf p).map f ≤ iInf p by exact fun v hv => this ⟨v, hv, rfl⟩ exact le_iInf fun i => (Submodule.map_mono (iInf_le p i)).trans (this i) theorem disjoint_iff_comap_eq_bot {p q : Submodule R M} : Disjoint p q ↔ comap p.subtype q = ⊥ := by rw [← (map_injective_of_injective (show Injective p.subtype from Subtype.coe_injective)).eq_iff, map_comap_subtype, map_bot, disjoint_iff] end AddCommMonoid section AddCommGroup variable [Ring R] [AddCommGroup M] [Module R M] (p : Submodule R M) variable [AddCommGroup M₂] [Module R M₂] @[simp] protected theorem map_neg (f : M →ₗ[R] M₂) : map (-f) p = map f p := ext fun _ => ⟨fun ⟨x, hx, hy⟩ => hy ▸ ⟨-x, show -x ∈ p from neg_mem hx, map_neg f x⟩, fun ⟨x, hx, hy⟩ => hy ▸ ⟨-x, show -x ∈ p from neg_mem hx, (map_neg (-f) _).trans (neg_neg (f x))⟩⟩ @[simp] lemma comap_neg {f : M →ₗ[R] M₂} {p : Submodule R M₂} : p.comap (-f) = p.comap f := by ext; simp end AddCommGroup end Submodule namespace Submodule variable {K : Type*} {V : Type*} {V₂ : Type*} variable [Semifield K] variable [AddCommMonoid V] [Module K V] variable [AddCommMonoid V₂] [Module K V₂] theorem comap_smul (f : V →ₗ[K] V₂) (p : Submodule K V₂) (a : K) (h : a ≠ 0) : p.comap (a • f) = p.comap f := by ext b; simp only [Submodule.mem_comap, p.smul_mem_iff h, LinearMap.smul_apply] protected theorem map_smul (f : V →ₗ[K] V₂) (p : Submodule K V) (a : K) (h : a ≠ 0) : p.map (a • f) = p.map f := le_antisymm (by rw [map_le_iff_le_comap, comap_smul f _ a h, ← map_le_iff_le_comap]) (by rw [map_le_iff_le_comap, ← comap_smul f _ a h, ← map_le_iff_le_comap]) theorem comap_smul' (f : V →ₗ[K] V₂) (p : Submodule K V₂) (a : K) : p.comap (a • f) = ⨅ _ : a ≠ 0, p.comap f := by classical by_cases h : a = 0 <;> simp [h, comap_smul] theorem map_smul' (f : V →ₗ[K] V₂) (p : Submodule K V) (a : K) : p.map (a • f) = ⨆ _ : a ≠ 0, map f p := by classical by_cases h : a = 0 <;> simp [h, Submodule.map_smul] end Submodule namespace Submodule section Module variable [Semiring R] [AddCommMonoid M] [Module R M] /-- If `s ≤ t`, then we can view `s` as a submodule of `t` by taking the comap of `t.subtype`. -/ @[simps symm_apply] def comapSubtypeEquivOfLe {p q : Submodule R M} (hpq : p ≤ q) : comap q.subtype p ≃ₗ[R] p where toFun x := ⟨x, x.2⟩ invFun x := ⟨⟨x, hpq x.2⟩, x.2⟩ left_inv x := by simp only [coe_mk, SetLike.eta, LinearEquiv.coe_coe] right_inv x := by simp only [Subtype.coe_mk, SetLike.eta, LinearEquiv.coe_coe] map_add' x y := rfl map_smul' c x := rfl -- Porting note: The original theorem generated by `simps` was using `LinearEquiv.toLinearMap`, -- different from the theorem on Lean 3, and not simp-normal form. @[simp] theorem comapSubtypeEquivOfLe_apply_coe {p q : Submodule R M} (hpq : p ≤ q) (x : comap q.subtype p) : (comapSubtypeEquivOfLe hpq x : M) = (x : M) := rfl end Module end Submodule namespace Submodule variable [Semiring R] [Semiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R₂ M₂] variable {τ₁₂ : R →+* R₂} {τ₂₁ : R₂ →+* R} variable [RingHomInvPair τ₁₂ τ₂₁] [RingHomInvPair τ₂₁ τ₁₂] variable (p : Submodule R M) (q : Submodule R₂ M₂) -- Porting note: Was `@[simp]`. @[simp high] theorem mem_map_equiv {e : M ≃ₛₗ[τ₁₂] M₂} {x : M₂} : x ∈ p.map (e : M →ₛₗ[τ₁₂] M₂) ↔ e.symm x ∈ p := by rw [Submodule.mem_map]; constructor · rintro ⟨y, hy, hx⟩ simp [← hx, hy] · intro hx exact ⟨e.symm x, hx, by simp⟩ theorem map_equiv_eq_comap_symm (e : M ≃ₛₗ[τ₁₂] M₂) (K : Submodule R M) : K.map (e : M →ₛₗ[τ₁₂] M₂) = K.comap (e.symm : M₂ →ₛₗ[τ₂₁] M) := Submodule.ext fun _ => by rw [mem_map_equiv, mem_comap, LinearEquiv.coe_coe] theorem comap_equiv_eq_map_symm (e : M ≃ₛₗ[τ₁₂] M₂) (K : Submodule R₂ M₂) : K.comap (e : M →ₛₗ[τ₁₂] M₂) = K.map (e.symm : M₂ →ₛₗ[τ₂₁] M) := (map_equiv_eq_comap_symm e.symm K).symm variable {p} theorem map_symm_eq_iff (e : M ≃ₛₗ[τ₁₂] M₂) {K : Submodule R₂ M₂} : K.map e.symm = p ↔ p.map e = K := by constructor <;> rintro rfl · calc map e (map e.symm K) = comap e.symm (map e.symm K) := map_equiv_eq_comap_symm _ _ _ = K := comap_map_eq_of_injective e.symm.injective _ · calc map e.symm (map e p) = comap e (map e p) := (comap_equiv_eq_map_symm _ _).symm _ = p := comap_map_eq_of_injective e.injective _ theorem orderIsoMapComap_apply' (e : M ≃ₛₗ[τ₁₂] M₂) (p : Submodule R M) : orderIsoMapComap e p = comap e.symm p := p.map_equiv_eq_comap_symm _ theorem orderIsoMapComap_symm_apply' (e : M ≃ₛₗ[τ₁₂] M₂) (p : Submodule R₂ M₂) : (orderIsoMapComap e).symm p = map e.symm p := p.comap_equiv_eq_map_symm _ theorem inf_comap_le_comap_add (f₁ f₂ : M →ₛₗ[τ₁₂] M₂) : comap f₁ q ⊓ comap f₂ q ≤ comap (f₁ + f₂) q := by rw [SetLike.le_def] intro m h change f₁ m + f₂ m ∈ q change f₁ m ∈ q ∧ f₂ m ∈ q at h apply q.add_mem h.1 h.2 end Submodule namespace Submodule variable {N N₂ : Type*} variable [CommSemiring R] [CommSemiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R₂ M₂] variable [AddCommMonoid N] [AddCommMonoid N₂] [Module R N] [Module R N₂] variable {τ₁₂ : R →+* R₂} {τ₂₁ : R₂ →+* R} variable [RingHomInvPair τ₁₂ τ₂₁] [RingHomInvPair τ₂₁ τ₁₂] variable (p : Submodule R M) (q : Submodule R₂ M₂) variable (pₗ : Submodule R N) (qₗ : Submodule R N₂) theorem comap_le_comap_smul (fₗ : N →ₗ[R] N₂) (c : R) : comap fₗ qₗ ≤ comap (c • fₗ) qₗ := by rw [SetLike.le_def] intro m h change c • fₗ m ∈ qₗ change fₗ m ∈ qₗ at h apply qₗ.smul_mem _ h /-- Given modules `M`, `M₂` over a commutative ring, together with submodules `p ⊆ M`, `q ⊆ M₂`, the set of maps $\{f ∈ Hom(M, M₂) | f(p) ⊆ q \}$ is a submodule of `Hom(M, M₂)`. -/ def compatibleMaps : Submodule R (N →ₗ[R] N₂) where carrier := { fₗ | pₗ ≤ comap fₗ qₗ } zero_mem' := by change pₗ ≤ comap (0 : N →ₗ[R] N₂) qₗ rw [comap_zero] exact le_top add_mem' {f₁ f₂} h₁ h₂ := by apply le_trans _ (inf_comap_le_comap_add qₗ f₁ f₂) rw [le_inf_iff] exact ⟨h₁, h₂⟩ smul_mem' c fₗ h := by dsimp at h exact le_trans h (comap_le_comap_smul qₗ fₗ c) end Submodule namespace LinearMap variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₁] [Module R M] [Module R M₁] /-- A linear map between two modules restricts to a linear map from any submodule p of the domain onto the image of that submodule. This is the linear version of `AddMonoidHom.addSubmonoidMap` and `AddMonoidHom.addSubgroupMap`. -/ def submoduleMap (f : M →ₗ[R] M₁) (p : Submodule R M) : p →ₗ[R] p.map f := f.restrict fun x hx ↦ Submodule.mem_map.mpr ⟨x, hx, rfl⟩ @[simp] theorem submoduleMap_coe_apply (f : M →ₗ[R] M₁) {p : Submodule R M} (x : p) : ↑(f.submoduleMap p x) = f x := rfl theorem submoduleMap_surjective (f : M →ₗ[R] M₁) (p : Submodule R M) : Function.Surjective (f.submoduleMap p) := f.toAddMonoidHom.addSubmonoidMap_surjective _ variable [Semiring R₂] [AddCommMonoid M₂] [Module R₂ M₂] {σ₂₁ : R₂ →+* R} open Submodule theorem map_codRestrict [RingHomSurjective σ₂₁] (p : Submodule R M) (f : M₂ →ₛₗ[σ₂₁] M) (h p') : Submodule.map (codRestrict p f h) p' = comap p.subtype (p'.map f) := Submodule.ext fun ⟨x, hx⟩ => by simp [Subtype.ext_iff_val] theorem comap_codRestrict (p : Submodule R M) (f : M₂ →ₛₗ[σ₂₁] M) (hf p') : Submodule.comap (codRestrict p f hf) p' = Submodule.comap f (map p.subtype p') := Submodule.ext fun x => ⟨fun h => ⟨⟨_, hf x⟩, h, rfl⟩, by rintro ⟨⟨_, _⟩, h, ⟨⟩⟩; exact h⟩ end LinearMap /-! ### Linear equivalences -/ namespace LinearEquiv section AddCommMonoid section variable [Semiring R] [Semiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] variable {module_M : Module R M} {module_M₂ : Module R₂ M₂} variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} variable {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₁ : RingHomInvPair σ₂₁ σ₁₂} variable (e : M ≃ₛₗ[σ₁₂] M₂) theorem map_eq_comap {p : Submodule R M} : (p.map (e : M →ₛₗ[σ₁₂] M₂) : Submodule R₂ M₂) = p.comap (e.symm : M₂ →ₛₗ[σ₂₁] M) := SetLike.coe_injective <| by simp [e.image_eq_preimage] /-- A linear equivalence of two modules restricts to a linear equivalence from any submodule `p` of the domain onto the image of that submodule. This is the linear version of `AddEquiv.submonoidMap` and `AddEquiv.subgroupMap`. This is `LinearEquiv.ofSubmodule'` but with `map` on the right instead of `comap` on the left. -/ def submoduleMap (p : Submodule R M) : p ≃ₛₗ[σ₁₂] ↥(p.map (e : M →ₛₗ[σ₁₂] M₂) : Submodule R₂ M₂) := { ((e : M →ₛₗ[σ₁₂] M₂).domRestrict p).codRestrict (p.map (e : M →ₛₗ[σ₁₂] M₂)) fun x => ⟨x, by simp only [LinearMap.domRestrict_apply, eq_self_iff_true, and_true_iff, SetLike.coe_mem, SetLike.mem_coe]⟩ with invFun := fun y => ⟨(e.symm : M₂ →ₛₗ[σ₂₁] M) y, by rcases y with ⟨y', hy⟩ rw [Submodule.mem_map] at hy rcases hy with ⟨x, hx, hxy⟩ subst hxy simp only [symm_apply_apply, Submodule.coe_mk, coe_coe, hx]⟩ left_inv := fun x => by simp only [LinearMap.domRestrict_apply, LinearMap.codRestrict_apply, LinearMap.toFun_eq_coe, LinearEquiv.coe_coe, LinearEquiv.symm_apply_apply, SetLike.eta] right_inv := fun y => by apply SetCoe.ext simp only [LinearMap.domRestrict_apply, LinearMap.codRestrict_apply, LinearMap.toFun_eq_coe, LinearEquiv.coe_coe, LinearEquiv.apply_symm_apply] } @[simp] theorem submoduleMap_apply (p : Submodule R M) (x : p) : ↑(e.submoduleMap p x) = e x := rfl @[simp] theorem submoduleMap_symm_apply (p : Submodule R M) (x : (p.map (e : M →ₛₗ[σ₁₂] M₂) : Submodule R₂ M₂)) : ↑((e.submoduleMap p).symm x) = e.symm x := rfl end end AddCommMonoid end LinearEquiv
Algebra\Module\Submodule\Order.lean
/- Copyright (c) 2021 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ import Mathlib.Algebra.Module.Submodule.Basic import Mathlib.Algebra.Order.Group.InjSurj /-! # Ordered instances on submodules -/ namespace Submodule variable {R M : Type*} section OrderedMonoid variable [Semiring R] /-- A submodule of an `OrderedAddCommMonoid` is an `OrderedAddCommMonoid`. -/ instance toOrderedAddCommMonoid [OrderedAddCommMonoid M] [Module R M] (S : Submodule R M) : OrderedAddCommMonoid S := Subtype.coe_injective.orderedAddCommMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl /-- A submodule of a `LinearOrderedAddCommMonoid` is a `LinearOrderedAddCommMonoid`. -/ instance toLinearOrderedAddCommMonoid [LinearOrderedAddCommMonoid M] [Module R M] (S : Submodule R M) : LinearOrderedAddCommMonoid S := Subtype.coe_injective.linearOrderedAddCommMonoid Subtype.val rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl /-- A submodule of an `OrderedCancelAddCommMonoid` is an `OrderedCancelAddCommMonoid`. -/ instance toOrderedCancelAddCommMonoid [OrderedCancelAddCommMonoid M] [Module R M] (S : Submodule R M) : OrderedCancelAddCommMonoid S := Subtype.coe_injective.orderedCancelAddCommMonoid Subtype.val rfl (fun _ _ => rfl) fun _ _ => rfl /-- A submodule of a `LinearOrderedCancelAddCommMonoid` is a `LinearOrderedCancelAddCommMonoid`. -/ instance toLinearOrderedCancelAddCommMonoid [LinearOrderedCancelAddCommMonoid M] [Module R M] (S : Submodule R M) : LinearOrderedCancelAddCommMonoid S := Subtype.coe_injective.linearOrderedCancelAddCommMonoid Subtype.val rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl end OrderedMonoid section OrderedGroup variable [Ring R] /-- A submodule of an `OrderedAddCommGroup` is an `OrderedAddCommGroup`. -/ instance toOrderedAddCommGroup [OrderedAddCommGroup M] [Module R M] (S : Submodule R M) : OrderedAddCommGroup S := Subtype.coe_injective.orderedAddCommGroup Subtype.val rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl /-- A submodule of a `LinearOrderedAddCommGroup` is a `LinearOrderedAddCommGroup`. -/ instance toLinearOrderedAddCommGroup [LinearOrderedAddCommGroup M] [Module R M] (S : Submodule R M) : LinearOrderedAddCommGroup S := Subtype.coe_injective.linearOrderedAddCommGroup Subtype.val rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl end OrderedGroup end Submodule
Algebra\Module\Submodule\Pointwise.lean
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser, Jujian Zhang -/ import Mathlib.Algebra.Module.BigOperators import Mathlib.Algebra.Group.Subgroup.Pointwise import Mathlib.Algebra.Order.Group.Action import Mathlib.RingTheory.Ideal.Basic /-! # Pointwise instances on `Submodule`s This file provides: * `Submodule.pointwiseNeg` and the actions * `Submodule.pointwiseDistribMulAction` * `Submodule.pointwiseMulActionWithZero` which matches the action of `Set.mulActionSet`. This file also provides: * `Submodule.pointwiseSetSMulSubmodule`: for `R`-module `M`, a `s : Set R` can act on `N : Submodule R M` by defining `s • N` to be the smallest submodule containing all `a • n` where `a ∈ s` and `n ∈ N`. These actions are available in the `Pointwise` locale. ## Implementation notes For an `R`-module `M`, The action of a subset of `R` acting on a submodule of `M` introduced in section `set_acting_on_submodules` does not have a counterpart in the file `Mathlib.Algebra.Group.Submonoid.Pointwise`. Other than section `set_acting_on_submodules`, most of the lemmas in this file are direct copies of lemmas from the file `Mathlib.Algebra.Group.Submonoid.Pointwise`. -/ variable {α : Type*} {R : Type*} {M : Type*} open Pointwise namespace Submodule section Neg section Semiring variable [Semiring R] [AddCommGroup M] [Module R M] /-- The submodule with every element negated. Note if `R` is a ring and not just a semiring, this is a no-op, as shown by `Submodule.neg_eq_self`. Recall that When `R` is the semiring corresponding to the nonnegative elements of `R'`, `Submodule R' M` is the type of cones of `M`. This instance reflects such cones about `0`. This is available as an instance in the `Pointwise` locale. -/ protected def pointwiseNeg : Neg (Submodule R M) where neg p := { -p.toAddSubmonoid with smul_mem' := fun r m hm => Set.mem_neg.2 <| smul_neg r m ▸ p.smul_mem r <| Set.mem_neg.1 hm } scoped[Pointwise] attribute [instance] Submodule.pointwiseNeg open Pointwise @[simp] theorem coe_set_neg (S : Submodule R M) : ↑(-S) = -(S : Set M) := rfl @[simp] theorem neg_toAddSubmonoid (S : Submodule R M) : (-S).toAddSubmonoid = -S.toAddSubmonoid := rfl @[simp] theorem mem_neg {g : M} {S : Submodule R M} : g ∈ -S ↔ -g ∈ S := Iff.rfl /-- `Submodule.pointwiseNeg` is involutive. This is available as an instance in the `Pointwise` locale. -/ protected def involutivePointwiseNeg : InvolutiveNeg (Submodule R M) where neg := Neg.neg neg_neg _S := SetLike.coe_injective <| neg_neg _ scoped[Pointwise] attribute [instance] Submodule.involutivePointwiseNeg @[simp] theorem neg_le_neg (S T : Submodule R M) : -S ≤ -T ↔ S ≤ T := SetLike.coe_subset_coe.symm.trans Set.neg_subset_neg theorem neg_le (S T : Submodule R M) : -S ≤ T ↔ S ≤ -T := SetLike.coe_subset_coe.symm.trans Set.neg_subset /-- `Submodule.pointwiseNeg` as an order isomorphism. -/ def negOrderIso : Submodule R M ≃o Submodule R M where toEquiv := Equiv.neg _ map_rel_iff' := @neg_le_neg _ _ _ _ _ theorem closure_neg (s : Set M) : span R (-s) = -span R s := by apply le_antisymm · rw [span_le, coe_set_neg, ← Set.neg_subset, neg_neg] exact subset_span · rw [neg_le, span_le, coe_set_neg, ← Set.neg_subset] exact subset_span @[simp] theorem neg_inf (S T : Submodule R M) : -(S ⊓ T) = -S ⊓ -T := SetLike.coe_injective Set.inter_neg @[simp] theorem neg_sup (S T : Submodule R M) : -(S ⊔ T) = -S ⊔ -T := (negOrderIso : Submodule R M ≃o Submodule R M).map_sup S T @[simp] theorem neg_bot : -(⊥ : Submodule R M) = ⊥ := SetLike.coe_injective <| (Set.neg_singleton 0).trans <| congr_arg _ neg_zero @[simp] theorem neg_top : -(⊤ : Submodule R M) = ⊤ := SetLike.coe_injective <| Set.neg_univ @[simp] theorem neg_iInf {ι : Sort*} (S : ι → Submodule R M) : (-⨅ i, S i) = ⨅ i, -S i := (negOrderIso : Submodule R M ≃o Submodule R M).map_iInf _ @[simp] theorem neg_iSup {ι : Sort*} (S : ι → Submodule R M) : (-⨆ i, S i) = ⨆ i, -S i := (negOrderIso : Submodule R M ≃o Submodule R M).map_iSup _ end Semiring open Pointwise @[simp] theorem neg_eq_self [Ring R] [AddCommGroup M] [Module R M] (p : Submodule R M) : -p = p := ext fun _ => p.neg_mem_iff end Neg variable [Semiring R] [AddCommMonoid M] [Module R M] instance pointwiseZero : Zero (Submodule R M) where zero := ⊥ instance pointwiseAdd : Add (Submodule R M) where add := (· ⊔ ·) instance pointwiseAddCommMonoid : AddCommMonoid (Submodule R M) where add_assoc := sup_assoc zero_add := bot_sup_eq add_zero := sup_bot_eq add_comm := sup_comm nsmul := nsmulRec @[simp] theorem add_eq_sup (p q : Submodule R M) : p + q = p ⊔ q := rfl -- dsimp loops when applying this lemma to its LHS, -- probably https://github.com/leanprover/lean4/pull/2867 @[simp, nolint simpNF] theorem zero_eq_bot : (0 : Submodule R M) = ⊥ := rfl instance : CanonicallyOrderedAddCommMonoid (Submodule R M) := { Submodule.pointwiseAddCommMonoid, Submodule.completeLattice with add_le_add_left := fun _a _b => sup_le_sup_left exists_add_of_le := @fun _a b h => ⟨b, (sup_eq_right.2 h).symm⟩ le_self_add := fun _a _b => le_sup_left } section variable [Monoid α] [DistribMulAction α M] [SMulCommClass α R M] /-- The action on a submodule corresponding to applying the action to every element. This is available as an instance in the `Pointwise` locale. -/ protected def pointwiseDistribMulAction : DistribMulAction α (Submodule R M) where smul a S := S.map (DistribMulAction.toLinearMap R M a : M →ₗ[R] M) one_smul S := (congr_arg (fun f : Module.End R M => S.map f) (LinearMap.ext <| one_smul α)).trans S.map_id mul_smul _a₁ _a₂ S := (congr_arg (fun f : Module.End R M => S.map f) (LinearMap.ext <| mul_smul _ _)).trans (S.map_comp _ _) smul_zero _a := map_bot _ smul_add _a _S₁ _S₂ := map_sup _ _ _ scoped[Pointwise] attribute [instance] Submodule.pointwiseDistribMulAction open Pointwise @[simp] theorem coe_pointwise_smul (a : α) (S : Submodule R M) : ↑(a • S) = a • (S : Set M) := rfl @[simp] theorem pointwise_smul_toAddSubmonoid (a : α) (S : Submodule R M) : (a • S).toAddSubmonoid = a • S.toAddSubmonoid := rfl @[simp] theorem pointwise_smul_toAddSubgroup {R M : Type*} [Ring R] [AddCommGroup M] [DistribMulAction α M] [Module R M] [SMulCommClass α R M] (a : α) (S : Submodule R M) : (a • S).toAddSubgroup = a • S.toAddSubgroup := rfl theorem smul_mem_pointwise_smul (m : M) (a : α) (S : Submodule R M) : m ∈ S → a • m ∈ a • S := (Set.smul_mem_smul_set : _ → _ ∈ a • (S : Set M)) instance : CovariantClass α (Submodule R M) HSMul.hSMul LE.le := ⟨fun _ _ => map_mono⟩ /-- See also `Submodule.smul_bot`. -/ @[simp] theorem smul_bot' (a : α) : a • (⊥ : Submodule R M) = ⊥ := map_bot _ /-- See also `Submodule.smul_sup`. -/ theorem smul_sup' (a : α) (S T : Submodule R M) : a • (S ⊔ T) = a • S ⊔ a • T := map_sup _ _ _ theorem smul_span (a : α) (s : Set M) : a • span R s = span R (a • s) := map_span _ _ theorem span_smul (a : α) (s : Set M) : span R (a • s) = a • span R s := Eq.symm (span_image _).symm instance pointwiseCentralScalar [DistribMulAction αᵐᵒᵖ M] [SMulCommClass αᵐᵒᵖ R M] [IsCentralScalar α M] : IsCentralScalar α (Submodule R M) := ⟨fun _a S => (congr_arg fun f : Module.End R M => S.map f) <| LinearMap.ext <| op_smul_eq_smul _⟩ @[simp] theorem smul_le_self_of_tower {α : Type*} [Semiring α] [Module α R] [Module α M] [SMulCommClass α R M] [IsScalarTower α R M] (a : α) (S : Submodule R M) : a • S ≤ S := by rintro y ⟨x, hx, rfl⟩ exact smul_of_tower_mem _ a hx end section variable [Semiring α] [Module α M] [SMulCommClass α R M] /-- The action on a submodule corresponding to applying the action to every element. This is available as an instance in the `Pointwise` locale. This is a stronger version of `Submodule.pointwiseDistribMulAction`. Note that `add_smul` does not hold so this cannot be stated as a `Module`. -/ protected def pointwiseMulActionWithZero : MulActionWithZero α (Submodule R M) := { Submodule.pointwiseDistribMulAction with zero_smul := fun S => (congr_arg (fun f : M →ₗ[R] M => S.map f) (LinearMap.ext <| zero_smul α)).trans S.map_zero } scoped[Pointwise] attribute [instance] Submodule.pointwiseMulActionWithZero end /-! ### Sets acting on Submodules Let `R` be a (semi)ring and `M` an `R`-module. Let `S` be a monoid which acts on `M` distributively, then subsets of `S` can act on submodules of `M`. For subset `s ⊆ S` and submodule `N ≤ M`, we define `s • N` to be the smallest submodule containing all `r • n` where `r ∈ s` and `n ∈ N`. #### Results For arbitrary monoids `S` acting distributively on `M`, there is an induction principle for `s • N`: To prove `P` holds for all `s • N`, it is enough to prove: - for all `r ∈ s` and `n ∈ N`, `P (r • n)`; - for all `r` and `m ∈ s • N`, `P (r • n)`; - for all `m₁, m₂`, `P m₁` and `P m₂` implies `P (m₁ + m₂)`; - `P 0`. To invoke this induction principle, use `induction x, hx using Submodule.set_smul_inductionOn` where `x : M` and `hx : x ∈ s • N` When we consider subset of `R` acting on `M` - `Submodule.pointwiseSetDistribMulAction` : the action described above is distributive. - `Submodule.mem_set_smul` : `x ∈ s • N` iff `x` can be written as `r₀ n₀ + ... + rₖ nₖ` where `rᵢ ∈ s` and `nᵢ ∈ N`. - `Submodule.coe_span_smul`: `s • N` is the same as `⟨s⟩ • N` where `⟨s⟩` is the ideal spanned by `s`. #### Notes - If we assume the addition on subsets of `R` is the `⊔` and subtraction `⊓` i.e. use `SetSemiring`, then this action actually gives a module structure on submodules of `M` over subsets of `R`. - If we generalize so that `r • N` makes sense for all `r : S`, then `Submodule.singleton_set_smul` and `Submodule.singleton_set_smul` can be generalized as well. -/ section set_acting_on_submodules variable {S : Type*} [Monoid S] variable [DistribMulAction S M] /-- Let `s ⊆ R` be a set and `N ≤ M` be a submodule, then `s • N` is the smallest submodule containing all `r • n` where `r ∈ s` and `n ∈ N`. -/ protected def pointwiseSetSMul : SMul (Set S) (Submodule R M) where smul s N := sInf { p | ∀ ⦃r : S⦄ ⦃n : M⦄, r ∈ s → n ∈ N → r • n ∈ p } scoped[Pointwise] attribute [instance] Submodule.pointwiseSetSMul variable (sR : Set R) (s : Set S) (N : Submodule R M) lemma mem_set_smul_def (x : M) : x ∈ s • N ↔ x ∈ sInf { p : Submodule R M | ∀ ⦃r : S⦄ {n : M}, r ∈ s → n ∈ N → r • n ∈ p } := Iff.rfl variable {s N} in @[aesop safe] lemma mem_set_smul_of_mem_mem {r : S} {m : M} (mem1 : r ∈ s) (mem2 : m ∈ N) : r • m ∈ s • N := by rw [mem_set_smul_def, mem_sInf] exact fun _ h => h mem1 mem2 lemma set_smul_le (p : Submodule R M) (closed_under_smul : ∀ ⦃r : S⦄ ⦃n : M⦄, r ∈ s → n ∈ N → r • n ∈ p) : s • N ≤ p := sInf_le closed_under_smul lemma set_smul_le_iff (p : Submodule R M) : s • N ≤ p ↔ ∀ ⦃r : S⦄ ⦃n : M⦄, r ∈ s → n ∈ N → r • n ∈ p := by fconstructor · intro h r n hr hn exact h <| mem_set_smul_of_mem_mem hr hn · apply set_smul_le lemma set_smul_eq_of_le (p : Submodule R M) (closed_under_smul : ∀ ⦃r : S⦄ ⦃n : M⦄, r ∈ s → n ∈ N → r • n ∈ p) (le : p ≤ s • N) : s • N = p := le_antisymm (set_smul_le s N p closed_under_smul) le instance : CovariantClass (Set S) (Submodule R M) HSMul.hSMul LE.le := ⟨fun _ _ _ le => set_smul_le _ _ _ fun _ _ hr hm => mem_set_smul_of_mem_mem (mem1 := hr) (mem2 := le hm)⟩ @[deprecated smul_mono_right (since := "2024-03-31")] theorem set_smul_mono_right {p q : Submodule R M} (le : p ≤ q) : s • p ≤ s • q := smul_mono_right s le lemma set_smul_mono_left {s t : Set S} (le : s ≤ t) : s • N ≤ t • N := set_smul_le _ _ _ fun _ _ hr hm => mem_set_smul_of_mem_mem (mem1 := le hr) (mem2 := hm) lemma set_smul_le_of_le_le {s t : Set S} {p q : Submodule R M} (le_set : s ≤ t) (le_submodule : p ≤ q) : s • p ≤ t • q := le_trans (set_smul_mono_left _ le_set) <| smul_mono_right _ le_submodule lemma set_smul_eq_iSup [SMulCommClass S R M] (s : Set S) (N : Submodule R M) : s • N = ⨆ (a ∈ s), a • N := by refine Eq.trans (congrArg sInf ?_) csInf_Ici simp_rw [← Set.Ici_def, iSup_le_iff, @forall_comm M] exact Set.ext fun _ => forall₂_congr (fun _ _ => Iff.symm map_le_iff_le_comap) theorem set_smul_span [SMulCommClass S R M] (s : Set S) (t : Set M) : s • span R t = span R (s • t) := by simp_rw [set_smul_eq_iSup, smul_span, iSup_span, Set.iUnion_smul_set] theorem span_set_smul [SMulCommClass S R M] (s : Set S) (t : Set M) : span R (s • t) = s • span R t := (set_smul_span s t).symm variable {s N} in /-- Induction principle for set acting on submodules. To prove `P` holds for all `s • N`, it is enough to prove: - for all `r ∈ s` and `n ∈ N`, `P (r • n)`; - for all `r` and `m ∈ s • N`, `P (r • n)`; - for all `m₁, m₂`, `P m₁` and `P m₂` implies `P (m₁ + m₂)`; - `P 0`. To invoke this induction principle, use `induction x, hx using Submodule.set_smul_inductionOn` where `x : M` and `hx : x ∈ s • N` -/ @[elab_as_elim] lemma set_smul_inductionOn {motive : (x : M) → (_ : x ∈ s • N) → Prop} (x : M) (hx : x ∈ s • N) (smul₀ : ∀ ⦃r : S⦄ ⦃n : M⦄ (mem₁ : r ∈ s) (mem₂ : n ∈ N), motive (r • n) (mem_set_smul_of_mem_mem mem₁ mem₂)) (smul₁ : ∀ (r : R) ⦃m : M⦄ (mem : m ∈ s • N) , motive m mem → motive (r • m) (Submodule.smul_mem _ r mem)) -- (add : ∀ ⦃m₁ m₂ : M⦄ (mem₁ : m₁ ∈ s • N) (mem₂ : m₂ ∈ s • N), motive m₁ mem₁ → motive m₂ mem₂ → motive (m₁ + m₂) (Submodule.add_mem _ mem₁ mem₂)) (zero : motive 0 (Submodule.zero_mem _)) : motive x hx := let ⟨_, h⟩ := set_smul_le s N { carrier := { m | ∃ (mem : m ∈ s • N), motive m mem }, zero_mem' := ⟨Submodule.zero_mem _, zero⟩ add_mem' := fun ⟨mem, h⟩ ⟨mem', h'⟩ ↦ ⟨_, add mem mem' h h'⟩ smul_mem' := fun r _ ⟨mem, h⟩ ↦ ⟨_, smul₁ r mem h⟩ } (fun _ _ mem mem' ↦ ⟨mem_set_smul_of_mem_mem mem mem', smul₀ mem mem'⟩) hx h -- Implementation note: if `N` is both an `R`-submodule and `S`-submodule and `SMulCommClass R S M`, -- this lemma is also true for any `s : Set S`. lemma set_smul_eq_map [SMulCommClass R R N] : sR • N = Submodule.map (N.subtype.comp (Finsupp.lsum R <| DistribMulAction.toLinearMap _ _)) (Finsupp.supported N R sR) := by classical apply set_smul_eq_of_le · intro r n hr hn exact ⟨Finsupp.single r ⟨n, hn⟩, Finsupp.single_mem_supported _ _ hr, by simp⟩ · intro x hx obtain ⟨c, hc, rfl⟩ := hx simp only [LinearMap.coe_comp, coeSubtype, Finsupp.coe_lsum, Finsupp.sum, LinearMap.coe_mk, AddHom.coe_mk, Function.comp_apply, AddSubmonoid.coe_finset_sum, coe_toAddSubmonoid, SetLike.val_smul] refine Submodule.sum_mem (p := sR • N) (t := c.support) ?_ _ ⟨sR • N, ?_⟩ · rintro r hr rw [mem_set_smul_def, Submodule.mem_sInf] rintro p hp exact hp (hc hr) (c r).2 · ext x : 1 simp only [Set.mem_iInter, SetLike.mem_coe] fconstructor · refine fun h ↦ h fun r n hr hn ↦ ?_ rw [mem_set_smul_def, mem_sInf] exact fun p hp ↦ hp hr hn · aesop lemma mem_set_smul (x : M) [SMulCommClass R R N] : x ∈ sR • N ↔ ∃ (c : R →₀ N), (c.support : Set R) ⊆ sR ∧ x = c.sum fun r m ↦ r • m := by fconstructor · intros h rw [set_smul_eq_map] at h obtain ⟨c, hc, rfl⟩ := h exact ⟨c, hc, rfl⟩ · rw [mem_set_smul_def, Submodule.mem_sInf] rintro ⟨c, hc1, rfl⟩ p hp simp only [Finsupp.sum, AddSubmonoid.coe_finset_sum, coe_toAddSubmonoid, SetLike.val_smul] exact Submodule.sum_mem _ fun r hr ↦ hp (hc1 hr) (c _).2 @[simp] lemma empty_set_smul : (∅ : Set S) • N = ⊥ := by ext fconstructor · intro hx rw [mem_set_smul_def, Submodule.mem_sInf] at hx exact hx ⊥ (fun r _ hr ↦ hr.elim) · rintro rfl; exact Submodule.zero_mem _ @[simp] lemma set_smul_bot : s • (⊥ : Submodule R M) = ⊥ := eq_bot_iff.mpr fun x hx ↦ by induction x, hx using set_smul_inductionOn <;> aesop lemma singleton_set_smul [SMulCommClass S R M] (r : S) : ({r} : Set S) • N = r • N := by apply set_smul_eq_of_le · rintro _ m rfl hm; exact ⟨m, hm, rfl⟩ · rintro _ ⟨m, hm, rfl⟩ rw [mem_set_smul_def, Submodule.mem_sInf] intro _ hp; exact hp rfl hm lemma mem_singleton_set_smul [SMulCommClass R S M] (r : S) (x : M) : x ∈ ({r} : Set S) • N ↔ ∃ (m : M), m ∈ N ∧ x = r • m := by fconstructor · intro hx induction' x, hx using Submodule.set_smul_inductionOn with t n memₜ memₙ t n mem h m₁ m₂ mem₁ mem₂ h₁ h₂ · aesop · rcases h with ⟨n, hn, rfl⟩ exact ⟨t • n, by aesop, smul_comm _ _ _⟩ · rcases h₁ with ⟨m₁, h₁, rfl⟩ rcases h₂ with ⟨m₂, h₂, rfl⟩ exact ⟨m₁ + m₂, Submodule.add_mem _ h₁ h₂, by aesop⟩ · exact ⟨0, Submodule.zero_mem _, by aesop⟩ · aesop -- Note that this can't be generalized to `Set S`, because even though `SMulCommClass R R M` implies -- `SMulComm R R N` for all `R`-submodules `N`, `SMulCommClass R S N` for all `R`-submodules `N` -- does not make sense. If we just focus on `R`-submodules that are also `S`-submodule, then this -- should be true. /-- A subset of a ring `R` has a multiplicative action on submodules of a module over `R`. -/ protected def pointwiseSetMulAction [SMulCommClass R R M] : MulAction (Set R) (Submodule R M) where one_smul x := show {(1 : R)} • x = x from SetLike.ext fun m => (mem_singleton_set_smul _ _ _).trans ⟨by rintro ⟨_, h, rfl⟩; rwa [one_smul], fun h => ⟨m, h, (one_smul _ _).symm⟩⟩ mul_smul s t x := le_antisymm (set_smul_le _ _ _ <| by rintro _ _ ⟨_, _, _, _, rfl⟩ _; rw [mul_smul]; aesop) (set_smul_le _ _ _ fun r m hr hm ↦ by have : SMulCommClass R R x := ⟨fun r s m => Subtype.ext <| smul_comm _ _ _⟩ obtain ⟨c, hc1, rfl⟩ := mem_set_smul _ _ _ |>.mp hm simp only [Finsupp.sum, AddSubmonoid.coe_finset_sum, coe_toAddSubmonoid, SetLike.val_smul, Finset.smul_sum, smul_smul] exact Submodule.sum_mem _ fun r' hr' ↦ mem_set_smul_of_mem_mem (Set.mul_mem_mul hr (hc1 hr')) (c _).2) scoped[Pointwise] attribute [instance] Submodule.pointwiseSetMulAction -- This cannot be generalized to `Set S` because `MulAction` can't be generalized already. /-- In a ring, sets acts on submodules. -/ protected def pointwiseSetDistribMulAction [SMulCommClass R R M] : DistribMulAction (Set R) (Submodule R M) where smul_zero s := set_smul_bot s smul_add s x y := le_antisymm (set_smul_le _ _ _ <| by rintro r m hr hm rw [add_eq_sup, Submodule.mem_sup] at hm obtain ⟨a, ha, b, hb, rfl⟩ := hm rw [smul_add, add_eq_sup, Submodule.mem_sup] exact ⟨r • a, mem_set_smul_of_mem_mem (mem1 := hr) (mem2 := ha), r • b, mem_set_smul_of_mem_mem (mem1 := hr) (mem2 := hb), rfl⟩) (sup_le_iff.mpr ⟨smul_mono_right _ le_sup_left, smul_mono_right _ le_sup_right⟩) scoped[Pointwise] attribute [instance] Submodule.pointwiseSetDistribMulAction lemma sup_set_smul (s t : Set S) : (s ⊔ t) • N = s • N ⊔ t • N := set_smul_eq_of_le _ _ _ (by rintro _ _ (hr|hr) hn · exact Submodule.mem_sup_left (mem_set_smul_of_mem_mem hr hn) · exact Submodule.mem_sup_right (mem_set_smul_of_mem_mem hr hn)) (sup_le (set_smul_mono_left _ le_sup_left) (set_smul_mono_left _ le_sup_right)) lemma coe_span_smul {R' M' : Type*} [CommSemiring R'] [AddCommMonoid M'] [Module R' M'] (s : Set R') (N : Submodule R' M') : (Ideal.span s : Set R') • N = s • N := set_smul_eq_of_le _ _ _ (by rintro r n hr hn induction' hr using Submodule.span_induction' with r h _ _ _ _ ihr ihs r r' hr hr' · exact mem_set_smul_of_mem_mem h hn · rw [zero_smul]; exact Submodule.zero_mem _ · rw [add_smul]; exact Submodule.add_mem _ ihr ihs · rw [mem_span_set] at hr obtain ⟨c, hc, rfl⟩ := hr rw [Finsupp.sum, Finset.smul_sum, Finset.sum_smul] refine Submodule.sum_mem _ fun i hi => ?_ rw [← mul_smul, smul_eq_mul, mul_comm, mul_smul] exact mem_set_smul_of_mem_mem (hc hi) <| Submodule.smul_mem _ _ hn) <| set_smul_mono_left _ Submodule.subset_span end set_acting_on_submodules end Submodule