|
| 1 | +/- |
| 2 | +Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Dagur Asgeirsson |
| 5 | +-/ |
| 6 | +import Mathlib.Algebra.Category.ModuleCat.Abelian |
| 7 | +import Mathlib.Algebra.Category.ModuleCat.Adjunctions |
| 8 | +import Mathlib.Algebra.Homology.ShortExact.Preadditive |
| 9 | +import Mathlib.LinearAlgebra.FreeModule.Basic |
| 10 | +import Mathlib.LinearAlgebra.FreeModule.Finite.Rank |
| 11 | +import Mathlib.LinearAlgebra.Dimension |
| 12 | +import Mathlib.LinearAlgebra.Finrank |
| 13 | + |
| 14 | +/-! |
| 15 | +# Exact sequences with free modules |
| 16 | +
|
| 17 | +This file proves results about linear independence and span in exact sequences of modules. |
| 18 | +
|
| 19 | +## Main theorems |
| 20 | +
|
| 21 | +* `linearIndependent_shortExact`: Given a short exact sequence `0 ⟶ N ⟶ M ⟶ P ⟶ 0` of |
| 22 | + `R`-modules and linearly independent families `v : ι → N` and `w : ι' → M`, we get a linearly |
| 23 | + independent family `ι ⊕ ι' → M` |
| 24 | +* `span_rightExact`: Given an exact sequence `N ⟶ M ⟶ P ⟶ 0` of `R`-modules and spanning |
| 25 | + families `v : ι → N` and `w : ι' → M`, we get a spanning family `ι ⊕ ι' → M` |
| 26 | +* Using `linearIndependent_shortExact` and `span_rightExact`, we prove `free_shortExact`: In a |
| 27 | + short exact sequence `0 ⟶ N ⟶ M ⟶ P ⟶ 0` where `N` and `P` are free, `M` is free as well. |
| 28 | +
|
| 29 | +## Tags |
| 30 | +linear algebra, module, free |
| 31 | +
|
| 32 | +-/ |
| 33 | + |
| 34 | +namespace ModuleCat |
| 35 | + |
| 36 | +variable {ι ι' R : Type _}[Ring R] {N P : ModuleCat R} {v : ι → N} |
| 37 | + |
| 38 | +open CategoryTheory |
| 39 | + |
| 40 | +section LinearIndependent |
| 41 | + |
| 42 | +variable (hv : LinearIndependent R v) {M : ModuleCat R} |
| 43 | + {u : ι ⊕ ι' → M} {f : N ⟶ M} {g : M ⟶ P} |
| 44 | + (hw : LinearIndependent R (g ∘ u ∘ Sum.inr)) (hu : Function.Injective u) |
| 45 | + (hm : Mono f) (he : Exact f g) (huv : u ∘ Sum.inl = f ∘ v) |
| 46 | + |
| 47 | +theorem disjoint_span_sum : Disjoint (Submodule.span R (Set.range (u ∘ Sum.inl))) |
| 48 | + (Submodule.span R (Set.range (u ∘ Sum.inr))) := by |
| 49 | + rw [huv] |
| 50 | + refine' Disjoint.mono_left (Submodule.span_mono (Set.range_comp_subset_range _ _)) _ |
| 51 | + rw [← LinearMap.range_coe, (Submodule.span_eq (LinearMap.range f)), (exact_iff _ _).mp he] |
| 52 | + exact Submodule.ker_range_disjoint (Function.Injective.comp hu Sum.inr_injective) hw |
| 53 | + |
| 54 | +/-- In the commutative diagram |
| 55 | + f g |
| 56 | + 0 --→ N --→ M --→ P |
| 57 | + ↑ ↑ ↑ |
| 58 | + v| u| w| |
| 59 | + ι → ι ⊕ ι' ← ι' |
| 60 | +
|
| 61 | +where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and |
| 62 | +`Sum.inr`. If `u` is injective and `v` and `w` are linearly independent, then `u` is linearly |
| 63 | +independent. -/ |
| 64 | +theorem linearIndependent_leftExact : LinearIndependent R u := |
| 65 | + linearIndependent_sum.mpr |
| 66 | + ⟨(congr_arg (fun f ↦ LinearIndependent R f) huv).mpr |
| 67 | + ((LinearMap.linearIndependent_iff (f : N →ₗ[R] M) |
| 68 | + (LinearMap.ker_eq_bot.mpr ((mono_iff_injective _).mp hm))).mpr hv), |
| 69 | + LinearIndependent.of_comp g hw, disjoint_span_sum hw hu he huv⟩ |
| 70 | + |
| 71 | +/-- Given a short exact sequence of modules and injective families `v : ι → N` and `w : ι' → P` |
| 72 | + f g |
| 73 | + 0 --→ N --→ M --→ P --→ 0 |
| 74 | + ↑ ↑ ↑ |
| 75 | + v| | w| |
| 76 | + ι ι ⊕ ι' ι' |
| 77 | +
|
| 78 | +such that `w` does not hit `0`, the family `Sum.elim (f ∘ v) (g.toFun.invFun ∘ w) : ι ⊕ ι' → M` |
| 79 | +is injective. -/ |
| 80 | +theorem family_injective_shortExact {w : ι' → P} (hse : ShortExact f g) |
| 81 | + (hv : v.Injective) (hw : w.Injective) (hw' : ∀ x, w x ≠ 0) : |
| 82 | + Function.Injective (Sum.elim (f ∘ v) (g.toFun.invFun ∘ w)) := |
| 83 | + Function.Injective.sum_elim |
| 84 | + (Function.Injective.comp ((mono_iff_injective _).mp hse.mono) hv) |
| 85 | + (Function.Injective.comp (Function.rightInverse_invFun |
| 86 | + ((epi_iff_surjective _).mp hse.epi)).injective hw) (fun a b h ↦ by |
| 87 | + apply_fun g at h |
| 88 | + dsimp at h |
| 89 | + rw [Function.rightInverse_invFun ((epi_iff_surjective _).mp hse.epi)] at h |
| 90 | + change (f ≫ g) (v a) = _ at h |
| 91 | + rw [hse.exact.w] at h |
| 92 | + change 0 = _ at h |
| 93 | + exact hw' _ h.symm ) |
| 94 | + |
| 95 | +/-- Given a short exact sequence `0 ⟶ N ⟶ M ⟶ P ⟶ 0` of `R`-modules and linearly independent |
| 96 | + families `v : ι → N` and `w : ι' → P`, we get a linearly independent family `ι ⊕ ι' → M` -/ |
| 97 | +theorem linearIndependent_shortExact {w : ι' → P} |
| 98 | + (hw : LinearIndependent R w) (hse : ShortExact f g) : |
| 99 | + LinearIndependent R (Sum.elim (f ∘ v) (g.toFun.invFun ∘ w)) := by |
| 100 | + cases subsingleton_or_nontrivial R |
| 101 | + · exact linearIndependent_of_subsingleton |
| 102 | + · refine' linearIndependent_leftExact hv _ (family_injective_shortExact hse hv.injective |
| 103 | + hw.injective (fun x ↦ hw.ne_zero x)) hse.mono hse.exact _ |
| 104 | + · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inr] |
| 105 | + rwa [← Function.comp.assoc, Function.RightInverse.comp_eq_id (Function.rightInverse_invFun |
| 106 | + ((epi_iff_surjective _).mp hse.epi)), |
| 107 | + Function.comp.left_id] |
| 108 | + · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inl] |
| 109 | + |
| 110 | +end LinearIndependent |
| 111 | + |
| 112 | +section Span |
| 113 | + |
| 114 | +variable {M : ModuleCat R} {u : ι⊕ ι' → M} {f : N ⟶ M} {g : M ⟶ P} |
| 115 | + |
| 116 | +/-- In the commutative diagram |
| 117 | + f g |
| 118 | + N --→ M --→ P |
| 119 | + ↑ ↑ ↑ |
| 120 | +v| u| w| |
| 121 | + ι → ι ⊕ ι' ← ι' |
| 122 | +
|
| 123 | +where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and |
| 124 | +`Sum.inr`. If `v` spans `N` and `w` spans `P`, then `u` spans `M`. -/ |
| 125 | +theorem span_exact (he : Exact f g) (huv : u ∘ Sum.inl = f ∘ v) |
| 126 | + (hv : ⊤ ≤ Submodule.span R (Set.range v)) |
| 127 | + (hw : ⊤ ≤ Submodule.span R (Set.range (g ∘ u ∘ Sum.inr))) : |
| 128 | + ⊤ ≤ Submodule.span R (Set.range u) := by |
| 129 | + intro m _ |
| 130 | + have hgm : g m ∈ Submodule.span R (Set.range (g ∘ u ∘ Sum.inr)) := hw Submodule.mem_top |
| 131 | + rw [Finsupp.mem_span_range_iff_exists_finsupp] at hgm |
| 132 | + obtain ⟨cm, hm⟩ := hgm |
| 133 | + let m' : M := Finsupp.sum cm fun j a ↦ a • (u (Sum.inr j)) |
| 134 | + have hsub : m - m' ∈ LinearMap.range f |
| 135 | + · rw [(exact_iff _ _).mp he] |
| 136 | + simp only [LinearMap.mem_ker, map_sub, sub_eq_zero] |
| 137 | + rw [← hm, map_finsupp_sum] |
| 138 | + simp only [Function.comp_apply, map_smul] |
| 139 | + obtain ⟨n, hnm⟩ := hsub |
| 140 | + have hn : n ∈ Submodule.span R (Set.range v) := hv Submodule.mem_top |
| 141 | + rw [Finsupp.mem_span_range_iff_exists_finsupp] at hn |
| 142 | + obtain ⟨cn, hn⟩ := hn |
| 143 | + rw [← hn, map_finsupp_sum] at hnm |
| 144 | + rw [← sub_add_cancel m m', ← hnm,] |
| 145 | + simp only [map_smul] |
| 146 | + have hn' : (Finsupp.sum cn fun a b ↦ b • f (v a)) = |
| 147 | + (Finsupp.sum cn fun a b ↦ b • u (Sum.inl a)) := |
| 148 | + by congr; ext a b; change b • (f ∘ v) a = _; rw [← huv]; rfl |
| 149 | + rw [hn'] |
| 150 | + apply Submodule.add_mem |
| 151 | + · rw [Finsupp.mem_span_range_iff_exists_finsupp] |
| 152 | + use cn.mapDomain (Sum.inl) |
| 153 | + rw [Finsupp.sum_mapDomain_index_inj Sum.inl_injective] |
| 154 | + · rw [Finsupp.mem_span_range_iff_exists_finsupp] |
| 155 | + use cm.mapDomain (Sum.inr) |
| 156 | + rw [Finsupp.sum_mapDomain_index_inj Sum.inr_injective] |
| 157 | + |
| 158 | +/-- Given an exact sequence `N ⟶ M ⟶ P ⟶ 0` of `R`-modules and spanning |
| 159 | + families `v : ι → N` and `w : ι' → P`, we get a spanning family `ι ⊕ ι' → M` -/ |
| 160 | +theorem span_rightExact {w : ι' → P} (hv : ⊤ ≤ Submodule.span R (Set.range v)) |
| 161 | + (hw : ⊤ ≤ Submodule.span R (Set.range w)) (hE : Epi g) (he : Exact f g) : |
| 162 | + ⊤ ≤ Submodule.span R (Set.range (Sum.elim (f ∘ v) (g.toFun.invFun ∘ w))) := by |
| 163 | + refine' span_exact he _ hv _ |
| 164 | + · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inl] |
| 165 | + · convert hw |
| 166 | + simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inr] |
| 167 | + rw [ModuleCat.epi_iff_surjective] at hE |
| 168 | + rw [← Function.comp.assoc, Function.RightInverse.comp_eq_id (Function.rightInverse_invFun hE), |
| 169 | + Function.comp.left_id] |
| 170 | + |
| 171 | +end Span |
| 172 | + |
| 173 | +/-- In a short exact sequence `0 ⟶ N ⟶ M ⟶ P ⟶ 0`, if `N` and `P` are free, then `M` is free.-/ |
| 174 | +theorem free_shortExact {M : ModuleCat R} {f : N ⟶ M} |
| 175 | + {g : M ⟶ P} (h : ShortExact f g) [Module.Free R N] [Module.Free R P] : |
| 176 | + Module.Free R M := |
| 177 | + Module.Free.of_basis (Basis.mk |
| 178 | + (linearIndependent_shortExact |
| 179 | + (Module.Free.chooseBasis R N).linearIndependent |
| 180 | + (Module.Free.chooseBasis R P).linearIndependent h) |
| 181 | + (span_rightExact |
| 182 | + (le_of_eq ((Module.Free.chooseBasis R N)).span_eq.symm) |
| 183 | + (le_of_eq (Module.Free.chooseBasis R P).span_eq.symm) h.epi h.exact)) |
| 184 | + |
| 185 | +theorem free_shortExact_rank_add {M : ModuleCat R} {f : N ⟶ M} |
| 186 | + {g : M ⟶ P} (h : ShortExact f g) [Module.Free R N] [Module.Free R P] [StrongRankCondition R] : |
| 187 | + Module.rank R M = Module.rank R N + Module.rank R P := by |
| 188 | + haveI := free_shortExact h |
| 189 | + rw [Module.Free.rank_eq_card_chooseBasisIndex, Module.Free.rank_eq_card_chooseBasisIndex R N, |
| 190 | + Module.Free.rank_eq_card_chooseBasisIndex R P, Cardinal.add_def, Cardinal.eq] |
| 191 | + exact ⟨Basis.indexEquiv (Module.Free.chooseBasis R M) (Basis.mk |
| 192 | + (linearIndependent_shortExact |
| 193 | + (Module.Free.chooseBasis R N).linearIndependent |
| 194 | + (Module.Free.chooseBasis R P).linearIndependent h) |
| 195 | + (span_rightExact |
| 196 | + (le_of_eq ((Module.Free.chooseBasis R N)).span_eq.symm) |
| 197 | + (le_of_eq (Module.Free.chooseBasis R P).span_eq.symm) h.epi h.exact))⟩ |
| 198 | + |
| 199 | +theorem free_shortExact_finrank_add {M : ModuleCat R} {f : N ⟶ M} |
| 200 | + {g : M ⟶ P} (h : ShortExact f g) [Module.Free R N] [Module.Finite R N] |
| 201 | + [Module.Free R P] [Module.Finite R P] |
| 202 | + (hN : FiniteDimensional.finrank R N = n) |
| 203 | + (hP : FiniteDimensional.finrank R P = p) |
| 204 | + [StrongRankCondition R]: |
| 205 | + FiniteDimensional.finrank R M = n + p := by |
| 206 | + apply FiniteDimensional.finrank_eq_of_rank_eq |
| 207 | + rw [free_shortExact_rank_add h, ← hN, ← hP] |
| 208 | + simp only [Nat.cast_add, FiniteDimensional.finrank_eq_rank] |
| 209 | + |
| 210 | +end ModuleCat |
0 commit comments