Hodge conjecture: the CM case in Lean, read and discussed
OpenAI's Lean proof of the Hodge conjecture for CM abelian varieties: rerun it, read its statement, and keep the open questions with their sources. The conjecture is open

| 1 | import Mathlib |
| 2 | |
| 3 | /-! # Elementary Divisors Existence Linear -/ |
| 4 | |
| 5 | namespace OAI.Algebra.Modules.ElementaryDivisorsExistenceLinear.Construction |
| 6 | |
| 7 | section |
| 8 | |
| 9 | open scoped BigOperators |
| 10 | |
| 11 | variable {R K : Type*} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R] |
| 12 | [Field K] [Algebra R K] [IsFractionRing R K] |
| 13 | |
| 14 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 15 | lemma uniformizer_map_ne_zero {π : R} (hπ : Irreducible π) : |
| 16 | algebraMap R K π ≠ 0 := by |
| 17 | exact (map_ne_zero_iff (algebraMap R K) (IsFractionRing.injective R K)).2 hπ.ne_zero |
| 18 | |
| 19 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 20 | lemma integral_zpow_iff {π : R} (hπ : Irreducible π) (a : ℤ) : |
| 21 | (∃ r : R, algebraMap R K r = (algebraMap R K π) ^ a) ↔ 0 ≤ a := by |
| 22 | constructor |
| 23 | · rintro ⟨r, hr⟩ |
| 24 | by_contra hn |
| 25 | have hn' : a < 0 := lt_of_not_ge hn |
| 26 | obtain ⟨m, hm⟩ := Int.eq_negSucc_of_lt_zero hn' |
| 27 | subst a |
| 28 | have he : r * π ^ (m + 1) = 1 := by |
| 29 | apply IsFractionRing.injective R K |
| 30 | simp only [map_mul, map_pow, map_one, hr, zpow_negSucc] |
| 31 | exact inv_mul_cancel₀ (pow_ne_zero _ (uniformizer_map_ne_zero hπ)) |
| 32 | have hu : IsUnit (π ^ (m + 1)) := IsUnit.of_mul_eq_one_right r he |
| 33 | rw [pow_succ] at hu |
| 34 | exact hπ.not_isUnit (IsUnit.mul_iff.mp hu).2 |
| 35 | · intro ha |
| 36 | refine ⟨π ^ a.toNat, ?_⟩ |
| 37 | rw [map_pow, ← zpow_natCast, Int.toNat_of_nonneg ha] |
| 38 | |
| 39 | omit [IsDomain R] [IsDiscreteValuationRing R] [IsFractionRing R K] in |
| 40 | lemma gl3_determinant_unit_adjustment |
| 41 | (g : Matrix.GeneralLinearGroup (Fin 3) K) |
| 42 | (hdet : ∃ u : Rˣ, g.val.det = algebraMap R K (u : R)) : |
| 43 | ∃ U : Matrix.GeneralLinearGroup (Fin 3) R, |
| 44 | (g.val * U.val.map (algebraMap R K)).det = 1 := by |
| 45 | obtain ⟨u, hu⟩ := hdet |
| 46 | obtain ⟨U, hU⟩ := Matrix.GeneralLinearGroup.det_surjective (n := Fin 3) u⁻¹ |
| 47 | refine ⟨U, ?_⟩ |
| 48 | rw [Matrix.det_mul, hu] |
| 49 | change algebraMap R K (u : R) * |
| 50 | ((algebraMap R K).mapMatrix U.val).det = 1 |
| 51 | rw [← RingHom.map_det] |
| 52 | have hU' : U.val.det = (↑u⁻¹ : R) := congrArg Units.val hU |
| 53 | rw [hU', ← map_mul] |
| 54 | simp |
| 55 | |
| 56 | lemma exists_unit_permutation {n : ℕ} (A : Matrix (Fin n) (Fin n) R) |
| 57 | (hA : IsUnit A.det) : |
| 58 | ∃ σ : Equiv.Perm (Fin n), ∀ i, IsUnit (A (σ i) i) := by |
| 59 | classical |
| 60 | rw [Matrix.det_apply] at hA |
| 61 | obtain ⟨σ, _, hσ⟩ := IsLocalRing.exists_of_isUnit_sum hA |
| 62 | refine ⟨σ, ?_⟩ |
| 63 | have hσ' : IsUnit ((↑(Equiv.Perm.sign σ) : R) * ∏ i, A (σ i) i) := by |
| 64 | simpa only [Units.smul_def, zsmul_eq_mul] using hσ |
| 65 | have hp : IsUnit (∏ i, A (σ i) i) := (IsUnit.mul_iff.mp hσ').2 |
| 66 | simpa using (IsUnit.prod_univ_iff.mp hp) |
| 67 | |
| 68 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 69 | lemma exponent_le_of_unit_coefficient {π : R} (hπ : Irreducible π) |
| 70 | {a b : ℤ} {u r : R} (hu : IsUnit u) |
| 71 | (h : algebraMap R K u * (algebraMap R K π) ^ b = |
| 72 | algebraMap R K r * (algebraMap R K π) ^ a) : a ≤ b := by |
| 73 | obtain ⟨u, rfl⟩ := hu |
| 74 | have hp := uniformizer_map_ne_zero (K := K) hπ |
| 75 | have hi : ∃ s : R, algebraMap R K s = (algebraMap R K π) ^ (b - a) := by |
| 76 | refine ⟨(↑u⁻¹ : R) * r, ?_⟩ |
| 77 | rw [map_mul, zpow_sub₀ hp] |
| 78 | apply (eq_div_iff (zpow_ne_zero _ hp)).2 |
| 79 | calc |
| 80 | _ = algebraMap R K (↑u⁻¹ : R) * |
| 81 | (algebraMap R K r * (algebraMap R K π) ^ a) := by ring |
| 82 | _ = algebraMap R K (↑u⁻¹ : R) * |
| 83 | (algebraMap R K (u : R) * (algebraMap R K π) ^ b) := by rw [← h] |
| 84 | _ = _ := by rw [← mul_assoc, ← map_mul]; simp |
| 85 | have := (integral_zpow_iff (K := K) hπ (b - a)).mp hi |
| 86 | omega |
| 87 | |
| 88 | lemma monotone_eq_of_permutation_bounds {n : ℕ} {a b : Fin n → ℤ} |
| 89 | (ha : Monotone a) (hb : Monotone b) |
| 90 | (h₁ : ∃ σ : Equiv.Perm (Fin n), ∀ i, a (σ i) ≤ b i) |
| 91 | (h₂ : ∃ τ : Equiv.Perm (Fin n), ∀ i, b (τ i) ≤ a i) : a = b := by |
| 92 | classical |
| 93 | obtain ⟨σ, hσ⟩ := h₁ |
| 94 | obtain ⟨τ, hτ⟩ := h₂ |
| 95 | have hs₁ : (∑ i, a i) ≤ ∑ i, b i := by |
| 96 | simpa only [Equiv.sum_comp] using Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hσ i) |
| 97 | have hs₂ : (∑ i, b i) ≤ ∑ i, a i := by |
| 98 | simpa only [Equiv.sum_comp] using Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hτ i) |
| 99 | have hs : (∑ i, a (σ i)) = ∑ i, b i := by |
| 100 | simpa only [Equiv.sum_comp] using le_antisymm hs₁ hs₂ |
| 101 | have he : a ∘ σ = b := funext fun i => |
| 102 | (Finset.sum_eq_sum_iff_of_le (fun j (_ : j ∈ Finset.univ) => hσ j)).mp hs i (Finset.mem_univ i) |
| 103 | have hm : Monotone (a ∘ σ) := he.symm ▸ hb |
| 104 | have hu := Tuple.unique_monotone (σ := Equiv.refl (Fin n)) (τ := σ) ha hm |
| 105 | exact hu.trans he |
| 106 | |
| 107 | end |
| 108 | |
| 109 | section |
| 110 | |
| 111 | open _root_.Module |
| 112 | open scoped BigOperators |
| 113 | |
| 114 | variable {R K : Type*} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R] |
| 115 | [Field K] [Algebra R K] [IsFractionRing R K] |
| 116 | variable {n : ℕ} |
| 117 | |
| 118 | noncomputable def powerBasis (π : R) (hπ : Irreducible π) |
| 119 | (e : Basis (Fin n) K (Fin n → K)) (a : Fin n → ℤ) : |
| 120 | Basis (Fin n) K (Fin n → K) := |
| 121 | e.unitsSMul fun i => Units.mk0 ((algebraMap R K π) ^ a i) |
| 122 | (zpow_ne_zero _ (uniformizer_map_ne_zero hπ)) |
| 123 | |
| 124 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 125 | @[simp] lemma powerBasis_apply (π : R) (hπ : Irreducible π) |
| 126 | (e : Basis (Fin n) K (Fin n → K)) (a : Fin n → ℤ) (i : Fin n) : |
| 127 | powerBasis π hπ e a i = (algebraMap R K π) ^ a i • e i := by |
| 128 | simp [powerBasis, Basis.unitsSMul_apply, Units.smul_def] |
| 129 | |
| 130 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 131 | @[simp] lemma powerBasis_repr (π : R) (hπ : Irreducible π) |
| 132 | (e : Basis (Fin n) K (Fin n → K)) (a : Fin n → ℤ) |
| 133 | (x : Fin n → K) (i : Fin n) : |
| 134 | (powerBasis π hπ e a).repr x i = |
| 135 | ((algebraMap R K π) ^ a i)⁻¹ * e.repr x i := by |
| 136 | simp [powerBasis, Basis.repr_unitsSMul, Units.smul_def] |
| 137 | |
| 138 | lemma lattice_basis_permutation_bound (π : R) (hπ : Irreducible π) |
| 139 | (e f : Basis (Fin n) K (Fin n → K)) (a b : Fin n → ℤ) |
| 140 | (h₀ : Submodule.span R (Set.range e) = Submodule.span R (Set.range f)) |
| 141 | (h₁ : Submodule.span R (Set.range (powerBasis π hπ e a)) = |
| 142 | Submodule.span R (Set.range (powerBasis π hπ f b))) : |
| 143 | ∃ σ : Equiv.Perm (Fin n), ∀ i, a (σ i) ≤ b i := by |
| 144 | classical |
| 145 | let eb := e.restrictScalars R |
| 146 | let fb := (f.restrictScalars R).map (LinearEquiv.ofEq _ _ h₀.symm) |
| 147 | let A := eb.toMatrix fb |
| 148 | let := eb.invertibleToMatrix fb |
| 149 | have hu : IsUnit A.det := Matrix.isUnit_det_of_invertible A |
| 150 | obtain ⟨σ, hσ⟩ := exists_unit_permutation A hu |
| 151 | refine ⟨σ, fun i => ?_⟩ |
| 152 | have hc : algebraMap R K (A (σ i) i) = e.repr (f i) (σ i) := by |
| 153 | simpa only [A, eb, Basis.toMatrix_apply, fb, Basis.map_apply, |
| 154 | LinearEquiv.coe_ofEq_apply, Basis.restrictScalars_apply] using |
| 155 | e.restrictScalars_repr_apply R (fb i) (σ i) |
| 156 | have hm : powerBasis π hπ f b i ∈ |
| 157 | Submodule.span R (Set.range (powerBasis π hπ e a)) := by |
| 158 | rw [h₁] |
| 159 | exact Submodule.subset_span (Set.mem_range_self i) |
| 160 | obtain ⟨r, hr⟩ := ((powerBasis π hπ e a).mem_span_iff_repr_mem R _).mp hm (σ i) |
| 161 | apply exponent_le_of_unit_coefficient (K := K) hπ (hσ i) (r := r) |
| 162 | rw [hc, hr] |
| 163 | simp only [powerBasis_repr, powerBasis_apply, map_smul, Finsupp.smul_apply, |
| 164 | smul_eq_mul] |
| 165 | field_simp [uniformizer_map_ne_zero (K := K) hπ] |
| 166 | |
| 167 | lemma lattice_exponents_unique (π : R) (hπ : Irreducible π) |
| 168 | (e f : Basis (Fin n) K (Fin n → K)) (a b : Fin n → ℤ) |
| 169 | (ha : Monotone a) (hb : Monotone b) |
| 170 | (h₀ : Submodule.span R (Set.range e) = Submodule.span R (Set.range f)) |
| 171 | (h₁ : Submodule.span R (Set.range fun i => (algebraMap R K π) ^ a i • e i) = |
| 172 | Submodule.span R (Set.range fun i => (algebraMap R K π) ^ b i • f i)) : |
| 173 | a = b := by |
| 174 | have h₁' : Submodule.span R (Set.range (powerBasis π hπ e a)) = |
| 175 | Submodule.span R (Set.range (powerBasis π hπ f b)) := by |
| 176 | change Submodule.span R (Set.range fun i => powerBasis π hπ e a i) = |
| 177 | Submodule.span R (Set.range fun i => powerBasis π hπ f b i) |
| 178 | simpa only [powerBasis_apply] using h₁ |
| 179 | exact monotone_eq_of_permutation_bounds ha hb |
| 180 | (lattice_basis_permutation_bound π hπ e f a b h₀ h₁') |
| 181 | (lattice_basis_permutation_bound π hπ f e b a h₀.symm h₁'.symm) |
| 182 | |
| 183 | end |
| 184 | |
| 185 | section |
| 186 | |
| 187 | open _root_.Module |
| 188 | open scoped BigOperators Pointwise |
| 189 | |
| 190 | variable {R K : Type*} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R] |
| 191 | [Field K] [Algebra R K] [IsFractionRing R K] |
| 192 | variable {n : ℕ} |
| 193 | |
| 194 | omit [IsDomain R] [IsDiscreteValuationRing R] [IsFractionRing R K] in |
| 195 | lemma basis_span_coe {L : Submodule R (Fin n → K)} (b : Basis (Fin n) R L) : |
| 196 | Submodule.span R (Set.range fun i => (b i : Fin n → K)) = L := by |
| 197 | have h := congrArg (Submodule.map L.subtype) b.span_eq |
| 198 | simpa only [Submodule.map_span, ← Set.range_comp, Submodule.map_top, |
| 199 | Submodule.range_subtype, Function.comp_def, Submodule.coe_subtype] using h |
| 200 | |
| 201 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 202 | lemma extended_basis_span {L : Submodule R (Fin n → K)} [Submodule.IsLattice K L] |
| 203 | (b : Basis (Fin n) R L) : |
| 204 | Submodule.span R (Set.range (b.extendOfIsLattice K)) = L := by |
| 205 | change Submodule.span R (Set.range fun i => b.extendOfIsLattice K i) = L |
| 206 | simpa only [Basis.extendOfIsLattice_apply] using basis_span_coe b |
| 207 | |
| 208 | lemma lattice_exists_scale_le (L M : Submodule R (Fin n → K)) |
| 209 | [Submodule.IsLattice K L] [Submodule.IsLattice K M] : |
| 210 | ∃ q : Kˣ, q • M ≤ L := by |
| 211 | classical |
| 212 | have hnL : Module.finrank R L = n := by simpa using Submodule.IsLattice.finrank_of_pi K L |
| 213 | have hnM : Module.finrank R M = n := by simpa using Submodule.IsLattice.finrank_of_pi K M |
| 214 | let bl : Basis (Fin n) R L := Module.finBasisOfFinrankEq R L hnL |
| 215 | let bm : Basis (Fin n) R M := Module.finBasisOfFinrankEq R M hnM |
| 216 | let e := bl.extendOfIsLattice K |
| 217 | let f := bm.extendOfIsLattice K |
| 218 | have he : Submodule.span R (Set.range e) = L := extended_basis_span (K := K) (L := L) bl |
| 219 | have hf : Submodule.span R (Set.range f) = M := extended_basis_span (K := K) (L := M) bm |
| 220 | obtain ⟨c, hc⟩ := IsLocalization.exist_integer_multiples_of_finite |
| 221 | (nonZeroDivisors R) (fun ij : Fin n × Fin n => e.repr (f ij.2) ij.1) |
| 222 | have hc0 : algebraMap R K (c : R) ≠ 0 := by |
| 223 | exact (map_ne_zero_iff (algebraMap R K) (IsFractionRing.injective R K)).2 |
| 224 | (mem_nonZeroDivisors_iff_ne_zero.mp c.property) |
| 225 | let q : Kˣ := Units.mk0 (algebraMap R K (c : R)) hc0 |
| 226 | refine ⟨q, ?_⟩ |
| 227 | intro x hx |
| 228 | obtain ⟨y, hy, rfl⟩ := (Submodule.mem_smul_pointwise_iff_exists x q M).mp hx |
| 229 | clear hx |
| 230 | rw [← hf] at hy |
| 231 | induction hy using Submodule.span_induction with |
| 232 | | mem y hy => |
| 233 | obtain ⟨i, rfl⟩ := hy |
| 234 | rw [← he, e.mem_span_iff_repr_mem R] |
| 235 | intro j |
| 236 | change ∃ r : R, algebraMap R K r = |
| 237 | e.repr ((algebraMap R K (c : R)) • f i) j |
| 238 | rw [map_smul, Finsupp.smul_apply, smul_eq_mul] |
| 239 | obtain ⟨r, hr⟩ := hc (j, i) |
| 240 | exact ⟨r, by simpa only [Algebra.smul_def] using hr⟩ |
| 241 | | zero => simp |
| 242 | | add x y _ _ hx hy => simpa only [smul_add] using L.add_mem hx hy |
| 243 | | smul r x _ hx => simpa only [smul_comm q r x] using L.smul_mem r hx |
| 244 | |
| 245 | end |
| 246 | |
| 247 | section |
| 248 | |
| 249 | open _root_.Module |
| 250 | open scoped BigOperators Pointwise |
| 251 | |
| 252 | variable {R K : Type*} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R] |
| 253 | [Field K] [Algebra R K] [IsFractionRing R K] |
| 254 | variable {n : ℕ} |
| 255 | |
| 256 | lemma lattice_diagonal_exists (π : R) (hπ : Irreducible π) |
| 257 | (L M : Submodule R (Fin n → K)) |
| 258 | [Submodule.IsLattice K L] [Submodule.IsLattice K M] : |
| 259 | ∃ (a : Fin n → ℤ) (e : Basis (Fin n) K (Fin n → K)), |
| 260 | L = Submodule.span R (Set.range e) ∧ |
| 261 | M = Submodule.span R (Set.range fun i => (algebraMap R K π) ^ a i • e i) := by |
| 262 | classical |
| 263 | obtain ⟨q, hq⟩ := lattice_exists_scale_le L M |
| 264 | let N : Submodule R (Fin n → K) := q • M |
| 265 | let J : Submodule R L := N.comap L.subtype |
| 266 | let E : J ≃ₗ[R] N := Submodule.comapSubtypeEquivOfLe hq |
| 267 | have hnL : Module.finrank R L = n := by simpa using Submodule.IsLattice.finrank_of_pi K L |
| 268 | have hnN : Module.finrank R N = n := by simpa using Submodule.IsLattice.finrank_of_pi K N |
| 269 | have hj : Module.finrank R J = Module.finrank R L := E.finrank_eq.trans (hnN.trans hnL.symm) |
| 270 | let bl : Basis (Fin n) R L := Module.finBasisOfFinrankEq R L hnL |
| 271 | obtain ⟨b, d, c, hc⟩ := J.exists_smith_normal_form_of_rank_eq bl hj |
| 272 | have hd : ∀ i, d i ≠ 0 := by |
| 273 | intro i hi |
| 274 | apply c.ne_zero i |
| 275 | apply Subtype.ext |
| 276 | change (c i : L) = 0 |
| 277 | simpa only [hi, zero_smul] using hc i |
| 278 | have hx : ∀ i, (↑q⁻¹ : K) * algebraMap R K (d i) ≠ 0 := by |
| 279 | intro i |
| 280 | exact mul_ne_zero (Units.ne_zero _) ((map_ne_zero_iff _ (IsFractionRing.injective R K)).2 (hd i)) |
| 281 | choose a u hu using fun i => |
| 282 | IsDiscreteValuationRing.exists_units_eq_smul_zpow_of_irreducible hπ (hx i) |
| 283 | let e := (b.unitsSMul u).extendOfIsLattice K |
| 284 | have he : Submodule.span R (Set.range e) = L := |
| 285 | extended_basis_span (K := K) (L := L) (b.unitsSMul u) |
| 286 | let f : Fin n → (Fin n → K) := fun i => ((c i : L) : Fin n → K) |
| 287 | have hf : Submodule.span R (Set.range f) = N := by |
| 288 | simpa [f, E, Basis.map_apply, Submodule.comapSubtypeEquivOfLe] |
| 289 | using basis_span_coe (c.map E) |
| 290 | have hv : ∀ i, (algebraMap R K π) ^ a i • e i = q⁻¹ • f i := by |
| 291 | intro i |
| 292 | have hi : (↑q⁻¹ : K) * algebraMap R K (d i) = |
| 293 | algebraMap R K (u i : R) * (algebraMap R K π) ^ a i := by |
| 294 | simpa only [Units.smul_def, Algebra.smul_def] using hu i |
| 295 | have hci : f i = algebraMap R K (d i) • (b i : Fin n → K) := by |
| 296 | change ((c i : L) : Fin n → K) = _ |
| 297 | rw [hc i] |
| 298 | simp only [Submodule.coe_smul, algebraMap_smul] |
| 299 | have hei : e i = algebraMap R K (u i : R) • (b i : Fin n → K) := by |
| 300 | simp only [e, Basis.extendOfIsLattice_apply, Basis.unitsSMul_apply, |
| 301 | Units.smul_def, Submodule.coe_smul, algebraMap_smul] |
| 302 | rw [hei, hci, Units.smul_def, smul_smul, smul_smul, hi, mul_comm] |
| 303 | refine ⟨a, e, he.symm, ?_⟩ |
| 304 | simp_rw [hv] |
| 305 | rw [Set.range_smul, ← Submodule.smul_span, hf] |
| 306 | exact (inv_smul_smul q M).symm |
| 307 | |
| 308 | lemma lattices_elementary_divisors |
| 309 | (π : R) (hπ : Irreducible π) |
| 310 | (L M : Submodule R (Fin n → K)) |
| 311 | [Submodule.IsLattice K L] [Submodule.IsLattice K M] : |
| 312 | ∃! a : Fin n → ℤ, |
| 313 | Monotone a ∧ |
| 314 | ∃ e : Basis (Fin n) K (Fin n → K), |
| 315 | L = Submodule.span R (Set.range fun i => e i) ∧ |
| 316 | M = Submodule.span R |
| 317 | (Set.range fun i => (algebraMap R K π) ^ a i • e i) := by |
| 318 | classical |
| 319 | obtain ⟨a, e, he, ha⟩ := lattice_diagonal_exists π hπ L M |
| 320 | let σ := Tuple.sort a |
| 321 | let f := e.reindex σ.symm |
| 322 | have hfL : L = Submodule.span R (Set.range f) := by |
| 323 | simpa only [f, Basis.coe_reindex, Equiv.symm_symm, σ.surjective.range_comp] using he |
| 324 | have hfM : M = Submodule.span R |
| 325 | (Set.range fun i => (algebraMap R K π) ^ (a ∘ σ) i • f i) := by |
| 326 | simp only [f, Basis.reindex_apply, Equiv.symm_symm, Function.comp_apply] |
| 327 | change M = Submodule.span R |
| 328 | (Set.range ((fun i => (algebraMap R K π) ^ a i • e i) ∘ σ)) |
| 329 | rw [σ.surjective.range_comp] |
| 330 | exact ha |
| 331 | refine ⟨a ∘ σ, ⟨Tuple.monotone_sort a, f, hfL, hfM⟩, ?_⟩ |
| 332 | rintro b ⟨hb, g, hg, hbg⟩ |
| 333 | exact lattice_exponents_unique π hπ g f b (a ∘ σ) hb (Tuple.monotone_sort a) |
| 334 | (hg.symm.trans hfL) (hbg.symm.trans hfM) |
| 335 | |
| 336 | end |
| 337 | |
| 338 | section |
| 339 | |
| 340 | open _root_.Module _root_.Matrix |
| 341 | open scoped BigOperators |
| 342 | |
| 343 | variable {R K : Type*} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R] |
| 344 | [Field K] [Algebra R K] [IsFractionRing R K] |
| 345 | variable {n : ℕ} |
| 346 | |
| 347 | noncomputable def matrixBasis (g : Matrix.GeneralLinearGroup (Fin n) K) : |
| 348 | Basis (Fin n) K (Fin n → K) := by |
| 349 | classical |
| 350 | exact basisOfPiSpaceOfLinearIndependent (Matrix.linearIndependent_cols_of_det_ne_zero g.det_ne_zero) |
| 351 | |
| 352 | @[simp] lemma matrixBasis_apply (g : Matrix.GeneralLinearGroup (Fin n) K) (i j : Fin n) : |
| 353 | matrixBasis g i j = g.val j i := by |
| 354 | classical |
| 355 | have he : (matrixBasis g : Fin n → Fin n → K) = g.val.col := by |
| 356 | simpa only [matrixBasis] using |
| 357 | coe_basisOfPiSpaceOfLinearIndependent |
| 358 | (Matrix.linearIndependent_cols_of_det_ne_zero g.det_ne_zero) |
| 359 | exact congrFun (congrFun he i) j |
| 360 | |
| 361 | @[simp] lemma standard_toMatrix_matrixBasis (g : Matrix.GeneralLinearGroup (Fin n) K) : |
| 362 | (Pi.basisFun K (Fin n)).toMatrix (matrixBasis g) = g.val := by |
| 363 | ext i j |
| 364 | simp [Basis.toMatrix_apply] |
| 365 | |
| 366 | omit [IsDomain R] [IsDiscreteValuationRing R] [IsFractionRing R K] in |
| 367 | lemma basis_span_isLattice (e : Basis (Fin n) K (Fin n → K)) : |
| 368 | Submodule.IsLattice K (Submodule.span R (Set.range e)) where |
| 369 | fg := Submodule.fg_span (Set.finite_range _) |
| 370 | span_eq_top := by rw [Submodule.span_span_of_tower, e.span_eq] |
| 371 | |
| 372 | lemma integral_basis_change (e f : Basis (Fin n) K (Fin n → K)) |
| 373 | (h : Submodule.span R (Set.range e) = Submodule.span R (Set.range f)) : |
| 374 | ∃ U : Matrix.GeneralLinearGroup (Fin n) R, |
| 375 | e.toMatrix f = U.val.map (algebraMap R K) := by |
| 376 | classical |
| 377 | let eb := e.restrictScalars R |
| 378 | let fb := (f.restrictScalars R).map (LinearEquiv.ofEq _ _ h.symm) |
| 379 | let U : Matrix.GeneralLinearGroup (Fin n) R := |
| 380 | ⟨eb.toMatrix fb, fb.toMatrix eb, eb.toMatrix_mul_toMatrix_flip fb, |
| 381 | fb.toMatrix_mul_toMatrix_flip eb⟩ |
| 382 | refine ⟨U, ?_⟩ |
| 383 | ext i j |
| 384 | symm |
| 385 | simpa only [U, Matrix.map_apply, Basis.toMatrix_apply, eb, fb, Basis.map_apply, |
| 386 | LinearEquiv.coe_ofEq_apply, Basis.restrictScalars_apply] using |
| 387 | e.restrictScalars_repr_apply R (fb j) i |
| 388 | |
| 389 | lemma basis_span_le_of_toMatrix_map (e f : Basis (Fin n) K (Fin n → K)) |
| 390 | (A : Matrix (Fin n) (Fin n) R) |
| 391 | (h : e.toMatrix f = A.map (algebraMap R K)) : |
| 392 | Submodule.span R (Set.range f) ≤ Submodule.span R (Set.range e) := by |
| 393 | apply Submodule.span_le.mpr |
| 394 | rintro _ ⟨j, rfl⟩ |
| 395 | apply (e.mem_span_iff_repr_mem R _).mpr |
| 396 | intro i |
| 397 | exact ⟨A i j, (congrFun (congrFun h i) j).symm⟩ |
| 398 | |
| 399 | lemma basis_span_eq_of_toMatrix_map (e f : Basis (Fin n) K (Fin n → K)) |
| 400 | (U : Matrix.GeneralLinearGroup (Fin n) R) |
| 401 | (h : e.toMatrix f = U.val.map (algebraMap R K)) : |
| 402 | Submodule.span R (Set.range e) = Submodule.span R (Set.range f) := by |
| 403 | have hU : f.toMatrix e = (U⁻¹).val.map (algebraMap R K) := by |
| 404 | have hprod := f.toMatrix_mul_toMatrix_flip e |
| 405 | rw [h] at hprod |
| 406 | calc |
| 407 | _ = f.toMatrix e * |
| 408 | (U.val.map (algebraMap R K) * (U⁻¹).val.map (algebraMap R K)) := by |
| 409 | rw [Matrix.GeneralLinearGroup.coe_inv, Matrix.GeneralLinearGroup.coe_map_mul_map_inv] |
| 410 | simp |
| 411 | _ = _ := by rw [← mul_assoc, hprod, one_mul] |
| 412 | exact le_antisymm (basis_span_le_of_toMatrix_map f e _ hU) |
| 413 | (basis_span_le_of_toMatrix_map e f _ h) |
| 414 | |
| 415 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 416 | lemma toMatrix_powerBasis (π : R) (hπ : Irreducible π) |
| 417 | (e : Basis (Fin n) K (Fin n → K)) (a : Fin n → ℤ) : |
| 418 | e.toMatrix (powerBasis π hπ e a) = |
| 419 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) := by |
| 420 | classical |
| 421 | simp [powerBasis, Basis.toMatrix_unitsSMul] |
| 422 | |
| 423 | end |
| 424 | |
| 425 | section |
| 426 | |
| 427 | open _root_.Module _root_.Matrix |
| 428 | open scoped BigOperators |
| 429 | |
| 430 | variable {R K : Type*} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R] |
| 431 | [Field K] [Algebra R K] [IsFractionRing R K] |
| 432 | variable {n : ℕ} |
| 433 | |
| 434 | lemma matrix_factorization_lattices (π : R) (hπ : Irreducible π) |
| 435 | (g : Matrix.GeneralLinearGroup (Fin n) K) (a : Fin n → ℤ) |
| 436 | (U V : Matrix.GeneralLinearGroup (Fin n) R) |
| 437 | (h : g.val = U.val.map (algebraMap R K) * |
| 438 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 439 | V.val.map (algebraMap R K)) : |
| 440 | ∃ e : Basis (Fin n) K (Fin n → K), |
| 441 | Submodule.span R (Set.range (Pi.basisFun K (Fin n))) = Submodule.span R (Set.range e) ∧ |
| 442 | Submodule.span R (Set.range (matrixBasis g)) = |
| 443 | Submodule.span R (Set.range fun i => (algebraMap R K π) ^ a i • e i) := by |
| 444 | classical |
| 445 | let s := Pi.basisFun K (Fin n) |
| 446 | let e := matrixBasis (Matrix.GeneralLinearGroup.map (algebraMap R K) U) |
| 447 | let f := matrixBasis g |
| 448 | let p := powerBasis π hπ e a |
| 449 | have he : s.toMatrix e = U.val.map (algebraMap R K) := |
| 450 | standard_toMatrix_matrixBasis _ |
| 451 | have hp : s.toMatrix p = U.val.map (algebraMap R K) * |
| 452 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) := by |
| 453 | rw [← s.toMatrix_mul_toMatrix e p, he, toMatrix_powerBasis] |
| 454 | have hg : s.toMatrix f = s.toMatrix p * V.val.map (algebraMap R K) := by |
| 455 | rw [hp, standard_toMatrix_matrixBasis] |
| 456 | exact h |
| 457 | have hV : p.toMatrix f = V.val.map (algebraMap R K) := by |
| 458 | calc |
| 459 | _ = p.toMatrix s * s.toMatrix f := (p.toMatrix_mul_toMatrix s f).symm |
| 460 | _ = _ := by rw [hg, ← mul_assoc, p.toMatrix_mul_toMatrix_flip s, one_mul] |
| 461 | refine ⟨e, basis_span_eq_of_toMatrix_map s e U he, ?_⟩ |
| 462 | have hm := (basis_span_eq_of_toMatrix_map p f V hV).symm |
| 463 | change Submodule.span R (Set.range f) = |
| 464 | Submodule.span R (Set.range fun i => (algebraMap R K π) ^ a i • e i) |
| 465 | simpa only [p, ← powerBasis_apply π hπ e a] using hm |
| 466 | |
| 467 | theorem gl_smith_normal_form (π : R) (hπ : Irreducible π) |
| 468 | (g : Matrix.GeneralLinearGroup (Fin n) K) : |
| 469 | ∃! a : Fin n → ℤ, |
| 470 | Monotone a ∧ |
| 471 | ∃ U V : Matrix.GeneralLinearGroup (Fin n) R, |
| 472 | g.val = U.val.map (algebraMap R K) * |
| 473 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 474 | V.val.map (algebraMap R K) := by |
| 475 | classical |
| 476 | let s := Pi.basisFun K (Fin n) |
| 477 | let f := matrixBasis g |
| 478 | let L := Submodule.span R (Set.range s) |
| 479 | let M := Submodule.span R (Set.range f) |
| 480 | have : Submodule.IsLattice K L := basis_span_isLattice s |
| 481 | have : Submodule.IsLattice K M := basis_span_isLattice f |
| 482 | obtain ⟨a, ⟨ha, e, he, hf⟩, huniq⟩ := lattices_elementary_divisors π hπ L M |
| 483 | let p := powerBasis π hπ e a |
| 484 | obtain ⟨U, hU⟩ := integral_basis_change s e he |
| 485 | have hp : Submodule.span R (Set.range p) = Submodule.span R (Set.range f) := by |
| 486 | change Submodule.span R (Set.range fun i => powerBasis π hπ e a i) = M |
| 487 | simpa only [powerBasis_apply] using hf.symm |
| 488 | obtain ⟨V, hV⟩ := integral_basis_change p f hp |
| 489 | have hm : g.val = U.val.map (algebraMap R K) * |
| 490 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 491 | V.val.map (algebraMap R K) := by |
| 492 | calc |
| 493 | g.val = s.toMatrix f := (standard_toMatrix_matrixBasis g).symm |
| 494 | _ = s.toMatrix e * e.toMatrix p * p.toMatrix f := by |
| 495 | rw [s.toMatrix_mul_toMatrix, s.toMatrix_mul_toMatrix] |
| 496 | _ = _ := by rw [hU, hV, toMatrix_powerBasis] |
| 497 | refine ⟨a, ⟨ha, U, V, hm⟩, ?_⟩ |
| 498 | rintro b ⟨hb, U', V', hg⟩ |
| 499 | obtain ⟨e', hL, hM⟩ := matrix_factorization_lattices π hπ g b U' V' hg |
| 500 | exact huniq b ⟨hb, e', hL, hM⟩ |
| 501 | |
| 502 | theorem gl3_smith_normal_form |
| 503 | (π : R) (hπ : Irreducible π) |
| 504 | (g : Matrix.GeneralLinearGroup (Fin 3) K) : |
| 505 | ∃! a : Fin 3 → ℤ, |
| 506 | Monotone a ∧ |
| 507 | ∃ U V : Matrix.GeneralLinearGroup (Fin 3) R, |
| 508 | g.val = U.val.map (algebraMap R K) * |
| 509 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 510 | V.val.map (algebraMap R K) := |
| 511 | gl_smith_normal_form π hπ g |
| 512 | |
| 513 | end |
| 514 | |
| 515 | open _root_.Module _root_.Matrix |
| 516 | open scoped BigOperators |
| 517 | |
| 518 | variable {R K : Type*} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R] |
| 519 | [Field K] [Algebra R K] [IsFractionRing R K] |
| 520 | |
| 521 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 522 | lemma exponent_zero_of_unit (π : R) (hπ : Irreducible π) (a : ℤ) (u : Rˣ) |
| 523 | (h : (algebraMap R K π) ^ a = algebraMap R K (u : R)) : a = 0 := by |
| 524 | have hp := (integral_zpow_iff (K := K) hπ a).mp ⟨u, h.symm⟩ |
| 525 | have hm := (integral_zpow_iff (K := K) hπ (-a)).mp |
| 526 | ⟨↑u⁻¹, by rw [map_units_inv, _root_.zpow_neg, h]⟩ |
| 527 | omega |
| 528 | |
| 529 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 530 | lemma determinant_exponent_zero (π : R) (hπ : Irreducible π) |
| 531 | (g : Matrix.SpecialLinearGroup (Fin 3) K) (a : Fin 3 → ℤ) |
| 532 | (U V : Matrix.GeneralLinearGroup (Fin 3) R) |
| 533 | (h : (g : Matrix (Fin 3) (Fin 3) K) = U.val.map (algebraMap R K) * |
| 534 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 535 | V.val.map (algebraMap R K)) : |
| 536 | (∑ i, a i) = 0 ∧ U.val.det * V.val.det = 1 := by |
| 537 | have hp := uniformizer_map_ne_zero (K := K) hπ |
| 538 | have hd := congrArg Matrix.det h |
| 539 | have hmap (B : Matrix (Fin 3) (Fin 3) R) : |
| 540 | (B.map (algebraMap R K)).det = algebraMap R K B.det := |
| 541 | ((algebraMap R K).map_det B).symm |
| 542 | have hprod : (∏ i, (algebraMap R K π) ^ a i) = (algebraMap R K π) ^ (∑ i, a i) := by |
| 543 | simp [Fin.prod_univ_succ, Fin.sum_univ_succ, zpow_add₀ hp] |
| 544 | rw [g.property, Matrix.det_mul, Matrix.det_mul, hmap, hmap, |
| 545 | Matrix.det_diagonal, hprod] at hd |
| 546 | let u : Rˣ := U.det * V.det |
| 547 | have he : (algebraMap R K π) ^ (∑ i, a i) = algebraMap R K (↑u⁻¹ : R) := by |
| 548 | rw [map_units_inv, inv_eq_one_div] |
| 549 | apply (eq_div_iff ((u.isUnit.map (algebraMap R K)).ne_zero)).mpr |
| 550 | change (algebraMap R K π) ^ (∑ i, a i) * algebraMap R K (U.val.det * V.val.det) = 1 |
| 551 | rw [map_mul] |
| 552 | calc |
| 553 | _ = algebraMap R K U.val.det * (algebraMap R K π) ^ (∑ i, a i) * |
| 554 | algebraMap R K V.val.det := by ring |
| 555 | _ = 1 := hd.symm |
| 556 | have hs := exponent_zero_of_unit π hπ (∑ i, a i) u⁻¹ he |
| 557 | refine ⟨hs, ?_⟩ |
| 558 | apply IsFractionRing.injective R K |
| 559 | rw [map_mul, map_one] |
| 560 | simpa only [hs, zpow_zero, mul_one] using hd.symm |
| 561 | |
| 562 | def determinantDiagonal (u : Rˣ) : Matrix (Fin 3) (Fin 3) R := |
| 563 | Matrix.diagonal ![(u : R), 1, 1] |
| 564 | |
| 565 | omit [IsDomain R] [IsDiscreteValuationRing R] in |
| 566 | @[simp] lemma determinantDiagonal_det (u : Rˣ) : (determinantDiagonal u).det = (u : R) := by |
| 567 | simp [determinantDiagonal, Matrix.det_diagonal, Fin.prod_univ_succ] |
| 568 | |
| 569 | lemma determinantDiagonal_cancel (u : Rˣ) (d : Fin 3 → K) : |
| 570 | (determinantDiagonal u⁻¹).map (algebraMap R K) * Matrix.diagonal d * |
| 571 | (determinantDiagonal u).map (algebraMap R K) = Matrix.diagonal d := by |
| 572 | classical |
| 573 | simp only [determinantDiagonal, Matrix.diagonal_map (map_zero (algebraMap R K)), |
| 574 | Matrix.diagonal_mul_diagonal] |
| 575 | congr 1 |
| 576 | funext i |
| 577 | fin_cases i <;> simp [map_units_inv, mul_comm] |
| 578 | |
| 579 | theorem sl3_smith_normal_form |
| 580 | (π : R) (hπ : Irreducible π) |
| 581 | (g : Matrix.SpecialLinearGroup (Fin 3) K) : |
| 582 | ∃! a : Fin 3 → ℤ, |
| 583 | Monotone a ∧ (∑ i, a i) = 0 ∧ |
| 584 | ∃ U V : Matrix.SpecialLinearGroup (Fin 3) R, |
| 585 | (g : Matrix (Fin 3) (Fin 3) K) = |
| 586 | (U : Matrix (Fin 3) (Fin 3) R).map (algebraMap R K) * |
| 587 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 588 | (V : Matrix (Fin 3) (Fin 3) R).map (algebraMap R K) := by |
| 589 | classical |
| 590 | obtain ⟨a, ⟨ha, U, V, h⟩, huniq⟩ := |
| 591 | gl3_smith_normal_form π hπ (Matrix.SpecialLinearGroup.toGL g) |
| 592 | obtain ⟨hs, hd⟩ := determinant_exponent_zero π hπ g a U V h |
| 593 | let U' : Matrix.SpecialLinearGroup (Fin 3) R := |
| 594 | ⟨U.val * determinantDiagonal U.det⁻¹, by |
| 595 | rw [Matrix.det_mul, determinantDiagonal_det] |
| 596 | exact Units.mul_inv U.det⟩ |
| 597 | let V' : Matrix.SpecialLinearGroup (Fin 3) R := |
| 598 | ⟨determinantDiagonal U.det * V.val, by |
| 599 | rw [Matrix.det_mul, determinantDiagonal_det] |
| 600 | exact hd⟩ |
| 601 | refine ⟨a, ⟨ha, hs, U', V', ?_⟩, ?_⟩ |
| 602 | · change (g : Matrix (Fin 3) (Fin 3) K) = |
| 603 | (U.val * determinantDiagonal U.det⁻¹).map (algebraMap R K) * |
| 604 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 605 | (determinantDiagonal U.det * V.val).map (algebraMap R K) |
| 606 | rw [Matrix.map_mul, Matrix.map_mul] |
| 607 | calc |
| 608 | _ = U.val.map (algebraMap R K) * |
| 609 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 610 | V.val.map (algebraMap R K) := h |
| 611 | _ = U.val.map (algebraMap R K) * |
| 612 | ((determinantDiagonal U.det⁻¹).map (algebraMap R K) * |
| 613 | Matrix.diagonal (fun i => (algebraMap R K π) ^ a i) * |
| 614 | (determinantDiagonal U.det).map (algebraMap R K)) * |
| 615 | V.val.map (algebraMap R K) := by rw [determinantDiagonal_cancel] |
| 616 | _ = _ := by simp only [mul_assoc] |
| 617 | · rintro b ⟨hb, _, U'', V'', hb'⟩ |
| 618 | exact huniq b ⟨hb, Matrix.SpecialLinearGroup.toGL U'', |
| 619 | Matrix.SpecialLinearGroup.toGL V'', hb'⟩ |
| 620 | |
| 621 | end OAI.Algebra.Modules.ElementaryDivisorsExistenceLinear.Construction |