|
| 1 | +import Mathlib |
| 2 | +import LeanCamCombi.Mathlib.Data.Prod.Lex |
| 3 | + |
| 4 | +variable {R M A} [CommRing R] [AddCommGroup M] [Module R M] [CommRing A] [Algebra R A] |
| 5 | + |
| 6 | +open Polynomial TensorProduct PrimeSpectrum |
| 7 | + |
| 8 | +abbrev Ideal.ResidueField (I : Ideal R) [I.IsPrime] : Type _ := |
| 9 | + LocalRing.ResidueField (Localization.AtPrime I) |
| 10 | + |
| 11 | +lemma LocalRing.residue_surjective {R} [CommRing R] [LocalRing R] : |
| 12 | + Function.Surjective (LocalRing.residue R) := |
| 13 | + Ideal.Quotient.mk_surjective |
| 14 | + |
| 15 | +instance {R S} [CommRing R] [CommRing S] [LocalRing S] [Algebra R S] : |
| 16 | + Algebra R (LocalRing.ResidueField S) := by delta LocalRing.ResidueField; infer_instance |
| 17 | + |
| 18 | +@[simp] |
| 19 | +lemma LocalRing.algebraMap_residueField {R} [CommRing R] [LocalRing R] : |
| 20 | + algebraMap R (LocalRing.ResidueField R) = LocalRing.residue R := rfl |
| 21 | + |
| 22 | +instance {R₁ R₂ S} [CommRing R₁] [CommRing R₂] [CommRing S] [LocalRing S] |
| 23 | + [Algebra R₁ R₂] [Algebra R₁ S] [Algebra R₂ S] [IsScalarTower R₁ R₂ S] : |
| 24 | + IsScalarTower R₁ R₂ (LocalRing.ResidueField S) := by |
| 25 | + delta LocalRing.ResidueField; infer_instance |
| 26 | + |
| 27 | +noncomputable |
| 28 | +abbrev Ideal.residueFieldMap (I : Ideal R) [I.IsPrime] (J : Ideal A) [J.IsPrime] |
| 29 | + (f : R →+* A) (hf : I = J.comap f) : I.ResidueField →+* J.ResidueField := |
| 30 | + LocalRing.ResidueField.map (Localization.localRingHom I J f hf) |
| 31 | + |
| 32 | +noncomputable |
| 33 | +def Ideal.residueFieldMapₐ (I : Ideal R) [I.IsPrime] (J : Ideal A) [J.IsPrime] |
| 34 | + (hf : I = J.comap (algebraMap R A)) : I.ResidueField →ₐ[R] J.ResidueField where |
| 35 | + __ := Ideal.residueFieldMap I J (algebraMap R A) hf |
| 36 | + commutes' r := by |
| 37 | + rw [IsScalarTower.algebraMap_apply R (Localization.AtPrime I), |
| 38 | + LocalRing.algebraMap_residueField] |
| 39 | + simp only [RingHom.toMonoidHom_eq_coe, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, |
| 40 | + MonoidHom.coe_coe, LocalRing.ResidueField.map_residue, Localization.localRingHom_to_map] |
| 41 | + rfl |
| 42 | + |
| 43 | +@[simp] |
| 44 | +lemma Ideal.algebraMap_residueField_eq_zero {I : Ideal R} [I.IsPrime] {x} : |
| 45 | + algebraMap R I.ResidueField x = 0 ↔ x ∈ I := by |
| 46 | + rw [IsScalarTower.algebraMap_apply R (Localization.AtPrime I), |
| 47 | + LocalRing.algebraMap_residueField, LocalRing.residue_eq_zero_iff] |
| 48 | + exact IsLocalization.AtPrime.to_map_mem_maximal_iff _ _ _ |
| 49 | + |
| 50 | +lemma Ideal.ker_algebraMap_residueField (I : Ideal R) [I.IsPrime] : |
| 51 | + RingHom.ker (algebraMap R I.ResidueField) = I := by |
| 52 | + ext x |
| 53 | + exact Ideal.algebraMap_residueField_eq_zero |
| 54 | + |
| 55 | + |
| 56 | +-- set_option |
| 57 | +-- set_option synthInstance.maxHeartbeats 400000 in |
| 58 | +-- noncomputable |
| 59 | +-- instance (g : R[X]) (x : Ideal R) [x.IsPrime] : |
| 60 | +-- Algebra R[X] (Module.End R[X] ((R[X] ⧸ Ideal.span {g}) ⊗[R] x.ResidueField)) := |
| 61 | +-- inferInstance |
| 62 | + |
| 63 | +noncomputable |
| 64 | +def fooBarMap (s : Set A) (I : Ideal A) (hg : s ⊆ I) [I.IsPrime] : |
| 65 | + (A ⧸ Ideal.span s) ⊗[R] (I.comap (algebraMap R A)).ResidueField →ₐ[A] I.ResidueField := by |
| 66 | + fapply Algebra.TensorProduct.lift |
| 67 | + · refine Ideal.Quotient.liftₐ (Ideal.span s) (Algebra.ofId A I.ResidueField) ?_ |
| 68 | + show Ideal.span s ≤ RingHom.ker (algebraMap A I.ResidueField) |
| 69 | + rwa [Ideal.span_le, Ideal.ker_algebraMap_residueField] |
| 70 | + · exact Ideal.residueFieldMapₐ _ _ rfl |
| 71 | + · exact fun _ _ ↦ .all _ _ |
| 72 | + |
| 73 | +-- set_option synthInstance.maxHeartbeats 400000 in |
| 74 | +-- -- set_option maxHeartbeats 0 in |
| 75 | +lemma mem_image_comap_zeroLocus_sdiff (f : A) (s : Set A) (x) : |
| 76 | + x ∈ comap (algebraMap R A) '' (zeroLocus s \ zeroLocus {f}) ↔ |
| 77 | + ¬ IsNilpotent (algebraMap A ((A ⧸ Ideal.span s) ⊗[R] x.asIdeal.ResidueField) f) := by |
| 78 | + constructor |
| 79 | + · rintro ⟨q, ⟨hqg, hqf⟩, rfl⟩ H |
| 80 | + simp only [mem_zeroLocus, Set.singleton_subset_iff, SetLike.mem_coe] at hqg hqf |
| 81 | + have := H.map (fooBarMap s q.asIdeal hqg) |
| 82 | + rw [AlgHom.commutes, isNilpotent_iff_eq_zero, ← RingHom.mem_ker, |
| 83 | + Ideal.ker_algebraMap_residueField] at this |
| 84 | + exact hqf this |
| 85 | + · intro H |
| 86 | + rw [← mem_nilradical, nilradical_eq_sInf, Ideal.mem_sInf] at H |
| 87 | + simp only [Set.mem_setOf_eq, Algebra.TensorProduct.algebraMap_apply, |
| 88 | + Ideal.Quotient.algebraMap_eq, not_forall, Classical.not_imp] at H |
| 89 | + obtain ⟨q, hq, hfq⟩ := H |
| 90 | + have : ∀ a ∈ s, Ideal.Quotient.mk (Ideal.span s) a ⊗ₜ[R] 1 ∈ q := fun a ha ↦ by |
| 91 | + simp [Ideal.Quotient.eq_zero_iff_mem.mpr (Ideal.subset_span ha)] |
| 92 | + refine ⟨comap (algebraMap A _) ⟨q, hq⟩, ⟨by simpa [Set.subset_def], by simpa⟩, ?_⟩ |
| 93 | + rw [← comap_comp_apply, ← IsScalarTower.algebraMap_eq, |
| 94 | + ← Algebra.TensorProduct.includeRight.comp_algebraMap, comap_comp_apply, |
| 95 | + Subsingleton.elim (α := PrimeSpectrum x.asIdeal.ResidueField) (comap _ _) ⊥] |
| 96 | + ext a |
| 97 | + exact congr(a ∈ $(Ideal.ker_algebraMap_residueField _)) |
| 98 | + |
| 99 | +lemma mem_image_comap_basicOpen (f : A) (x) : |
| 100 | + x ∈ comap (algebraMap R A) '' (basicOpen f) ↔ |
| 101 | + ¬ IsNilpotent (algebraMap A (A ⊗[R] x.asIdeal.ResidueField) f) := by |
| 102 | + have e : A ⊗[R] x.asIdeal.ResidueField ≃ₐ[A] |
| 103 | + (A ⧸ (Ideal.span ∅ : Ideal A)) ⊗[R] x.asIdeal.ResidueField := by |
| 104 | + refine Algebra.TensorProduct.congr ?f AlgEquiv.refl |
| 105 | + rw [Ideal.span_empty] |
| 106 | + exact { __ := (RingEquiv.quotientBot A).symm, __ := Algebra.ofId _ _ } |
| 107 | + rw [← IsNilpotent.map_iff e.injective, AlgEquiv.commutes, |
| 108 | + ← mem_image_comap_zeroLocus_sdiff f ∅ x, zeroLocus_empty, ← Set.compl_eq_univ_diff, |
| 109 | + basicOpen_eq_zeroLocus_compl] |
| 110 | + |
| 111 | +lemma mem_image_comap_basicOpen_iff_map_ne_zero (f : R[X]) (x : PrimeSpectrum R) : |
| 112 | + x ∈ comap C '' (basicOpen f) ↔ f.map (algebraMap R x.asIdeal.ResidueField) ≠ 0 := by |
| 113 | + refine (mem_image_comap_basicOpen _ _).trans (not_iff_not.mpr ?_) |
| 114 | + let e : R[X] ⊗[R] x.asIdeal.ResidueField ≃ₐ[R] x.asIdeal.ResidueField[X] := |
| 115 | + (Algebra.TensorProduct.comm R _ _).trans (polyEquivTensor R x.asIdeal.ResidueField).symm |
| 116 | + rw [← IsNilpotent.map_iff e.injective, isNilpotent_iff_eq_zero] |
| 117 | + show (e.toAlgHom.toRingHom).comp (algebraMap _ _) f = 0 ↔ Polynomial.mapRingHom _ f = 0 |
| 118 | + congr! |
| 119 | + ext1 |
| 120 | + · ext; simp [e] |
| 121 | + · simp [e, monomial_one_one_eq_X] |
| 122 | + |
| 123 | + |
| 124 | +lemma image_comap_C_basicOpen (f : R[X]) : |
| 125 | + comap C '' basicOpen f = (zeroLocus (Set.range f.coeff))ᶜ := by |
| 126 | + ext p |
| 127 | + rw [mem_image_comap_basicOpen_iff_map_ne_zero, ← not_iff_not] |
| 128 | + simp [Polynomial.ext_iff, Set.range_subset_iff] |
| 129 | + |
| 130 | + |
| 131 | +open Module in |
| 132 | +lemma LinearMap.nilpotent_iff_charpoly {R M} [CommRing R] [IsDomain R] [AddCommGroup M] |
| 133 | + [Module R M] [Free R M] [IsNoetherian R M] (φ : End R M) : |
| 134 | + IsNilpotent φ ↔ charpoly φ = X ^ finrank R M := |
| 135 | + (LinearMap.charpoly_nilpotent_tfae φ).out 0 1 |
| 136 | + |
| 137 | +lemma LinearMap.charpoly_baseChange {R M} [CommRing R] [AddCommGroup M] [Module R M] |
| 138 | + [Module.Free R M] [Module.Finite R M] |
| 139 | + {A} [CommRing A] [Algebra R A] (f : M →ₗ[R] M) : |
| 140 | + (f.baseChange A).charpoly = f.charpoly.map (algebraMap R A) := by |
| 141 | + nontriviality A |
| 142 | + have := (algebraMap R A).domain_nontrivial |
| 143 | + let I := Module.Free.ChooseBasisIndex R M |
| 144 | + let b : Basis I R M := Module.Free.chooseBasis R M |
| 145 | + rw [← f.charpoly_toMatrix b, ← (f.baseChange A).charpoly_toMatrix (b.baseChange A), |
| 146 | + ← Matrix.charpoly_map] |
| 147 | + congr 1 |
| 148 | + ext i j |
| 149 | + simp [Matrix.map_apply, LinearMap.toMatrix_apply, ← Algebra.algebraMap_eq_smul_one] |
| 150 | + |
| 151 | +lemma Algebra.baseChange_lmul {R B} [CommRing R] [CommRing B] [Algebra R B] |
| 152 | + {A} [CommRing A] [Algebra R A] (f : B) : |
| 153 | + (Algebra.lmul R B f).baseChange A = Algebra.lmul A (A ⊗[R] B) (1 ⊗ₜ f) := by |
| 154 | + ext i |
| 155 | + simp |
| 156 | + |
| 157 | +lemma isNilpotent_tensor_residueField_iff |
| 158 | + [Module.Free R A] [Module.Finite R A] (f : A) (I : Ideal R) [I.IsPrime] : |
| 159 | + IsNilpotent (algebraMap A (A ⊗[R] I.ResidueField) f) ↔ |
| 160 | + ∀ i < Module.finrank R A, (Algebra.lmul R A f).charpoly.coeff i ∈ I := by |
| 161 | + cases subsingleton_or_nontrivial R |
| 162 | + · have := (algebraMap R (A ⊗[R] I.ResidueField)).codomain_trivial |
| 163 | + simp [Subsingleton.elim I ⊤, Subsingleton.elim (f ⊗ₜ[R] (1 : I.ResidueField)) 0] |
| 164 | + have : Module.finrank I.ResidueField (I.ResidueField ⊗[R] A) = Module.finrank R A := by |
| 165 | + rw [Module.finrank_tensorProduct, Module.finrank_self, one_mul] |
| 166 | + rw [← IsNilpotent.map_iff (Algebra.TensorProduct.comm R A I.ResidueField).injective] |
| 167 | + simp only [Algebra.TensorProduct.algebraMap_apply, Algebra.id.map_eq_id, RingHom.id_apply, |
| 168 | + Algebra.coe_lmul_eq_mul, Algebra.TensorProduct.comm_tmul] |
| 169 | + rw [← IsNilpotent.map_iff (Algebra.lmul_injective (R := I.ResidueField)), |
| 170 | + LinearMap.nilpotent_iff_charpoly, ← Algebra.baseChange_lmul, LinearMap.charpoly_baseChange] |
| 171 | + simp_rw [this, ← ((LinearMap.mul R A) f).charpoly_natDegree] |
| 172 | + constructor |
| 173 | + · intro e i hi |
| 174 | + replace e := congr(($e).coeff i) |
| 175 | + simpa only [Algebra.coe_lmul_eq_mul, coeff_map, coeff_X_pow, hi.ne, ↓reduceIte, |
| 176 | + ← RingHom.mem_ker, Ideal.ker_algebraMap_residueField] using e |
| 177 | + · intro H |
| 178 | + ext i |
| 179 | + obtain (hi | hi) := eq_or_ne i ((LinearMap.mul R A) f).charpoly.natDegree |
| 180 | + · simp only [Algebra.coe_lmul_eq_mul, hi, coeff_map, coeff_X_pow, ↓reduceIte] |
| 181 | + rw [← Polynomial.leadingCoeff, ((LinearMap.mul R A) f).charpoly_monic, map_one] |
| 182 | + obtain (hi | hi) := lt_or_gt_of_ne hi |
| 183 | + · simpa [hi.ne, ← RingHom.mem_ker, Ideal.ker_algebraMap_residueField] using H i hi |
| 184 | + · simp [hi.ne', coeff_eq_zero_of_natDegree_lt hi] |
| 185 | + |
| 186 | +lemma exists_image_comap (f : A) (s : Set A) [Module.Free R (A ⧸ Ideal.span s)] |
| 187 | + [Module.Finite R (A ⧸ Ideal.span s)] : |
| 188 | + ∃ t : Finset R, |
| 189 | + comap (algebraMap R A) '' (zeroLocus s \ zeroLocus {f}) = (zeroLocus t)ᶜ := by |
| 190 | + classical |
| 191 | + use (Finset.range (Module.finrank R (A ⧸ Ideal.span s))).image |
| 192 | + (Algebra.lmul R (A ⧸ Ideal.span s) (Ideal.Quotient.mk _ f)).charpoly.coeff |
| 193 | + ext x |
| 194 | + rw [mem_image_comap_zeroLocus_sdiff, IsScalarTower.algebraMap_apply A (A ⧸ Ideal.span s), |
| 195 | + isNilpotent_tensor_residueField_iff] |
| 196 | + simp [Set.subset_def] |
| 197 | + |
| 198 | +lemma exists_image_comap_of_monic (f g : R[X]) (hg : g.Monic) : |
| 199 | + ∃ t : Finset R, |
| 200 | + comap C '' (zeroLocus {g} \ zeroLocus {f}) = (zeroLocus t)ᶜ := by |
| 201 | + apply (config := { allowSynthFailures := true }) exists_image_comap |
| 202 | + · exact .of_basis (AdjoinRoot.powerBasis' hg).basis |
| 203 | + · exact .of_basis (AdjoinRoot.powerBasis' hg).basis |
| 204 | + |
| 205 | +universe u |
| 206 | + |
| 207 | +example {R} (n : ℕ) (f : Fin n → R) (a : R) : Fin (n + 1) → R := Fin.cons a f |
| 208 | + |
| 209 | +@[simp] |
| 210 | +lemma Ideal.span_singleton_zero : Ideal.span {0} = (⊥ : Ideal R) := by simp |
| 211 | +-- Fin n → ℕ × Prop |
| 212 | + |
| 213 | +lemma foo_induction |
| 214 | + (P : ∀ (R : Type u) [CommRing R], Ideal R[X] → Prop) |
| 215 | + (hP : ∀ (R) [CommRing R] (c : R) (I : Ideal R[X]), |
| 216 | + P (Localization.Away c) (I.map (mapRingHom (algebraMap _ _))) → |
| 217 | + P (R ⧸ Ideal.span {c}) (I.map (mapRingHom (algebraMap _ _))) → P R I) |
| 218 | + (hP₀ : ∀ (R) [CommRing R] (g : R[X]), g.Monic → P R (Ideal.span {g})) |
| 219 | + (hP₁ : ∀ (R) [CommRing R], P R ⊥) |
| 220 | + {R} [CommRing R] (I : Ideal R[X]) (hI : I.FG) : P R I := by |
| 221 | + classical |
| 222 | + obtain ⟨n, e, rfl⟩ : ∃ (n : ℕ) (e : Fin (n + 1) → R[X]), I = Ideal.span (Set.range e) := by |
| 223 | + obtain ⟨s, rfl⟩ := hI |
| 224 | + exact ⟨s.card, Fin.cons 0 (Subtype.val ∘ s.equivFin.symm), |
| 225 | + by simp [← Set.union_singleton, Ideal.span_union]⟩ |
| 226 | + clear hI |
| 227 | + set v : Lex ((Fin (n + 1) → ℕ) × ℕ) := toLex |
| 228 | + (natDegree ∘ e, (Finset.univ.filter (fun i ↦ IsUnit (e i).leadingCoeff)).card) with hv |
| 229 | + clear_value v |
| 230 | + have : WellFoundedLT (Lex ((Fin (n + 1) → ℕ) × ℕ)) := inferInstance |
| 231 | + induction v using wellFounded_lt (α := Lex ((Fin (n + 1) → ℕ) × ℕ)).induction generalizing R with |
| 232 | + | h v H_IH => |
| 233 | + by_cases he0 : e = 0 |
| 234 | + · rw [he0, Set.range_zero, Ideal.span_singleton_zero]; exact hP₁ R |
| 235 | + simp only [funext_iff, Pi.zero_apply, not_forall] at he0 |
| 236 | + obtain ⟨i, hi, H⟩ : ∃ i, e i ≠ 0 ∧ ∀ j, e j ≠ 0 → (e i).natDegree ≤ (e j).natDegree := by |
| 237 | + have : ∃ n : ℕ, ∃ i, (e i).natDegree = n ∧ (e i) ≠ 0 := by rw [exists_comm]; simpa |
| 238 | + let m := Nat.find this |
| 239 | + obtain ⟨i, hi, hi'⟩ : ∃ i, (e i).natDegree = m ∧ (e i) ≠ 0 := Nat.find_spec this |
| 240 | + exact ⟨i, hi', fun j hj ↦ hi.trans_le (Nat.find_min' _ ⟨j, rfl, hj⟩)⟩ |
| 241 | + by_cases hi' : (e i).Monic; swap |
| 242 | + · apply hP _ (e i).leadingCoeff |
| 243 | + · rw [Ideal.map_span, ← Set.range_comp] |
| 244 | + refine H_IH _ ?_ _ rfl |
| 245 | + sorry |
| 246 | + · sorry |
| 247 | + by_cases h' : ∃ j ≠ i, (e j) ≠ 0 |
| 248 | + · sorry |
| 249 | + · sorry |
0 commit comments