Stafford38/Paper/Section5/SmoothLocus.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 
3 public import Stafford38.Paper.Section5
4 public import Stafford38.Paper.Section5.Definitions
5 public import Stafford38.Paper.Section5.JacobianConverse
6 public import Stafford38.Geometry.GenericPointKaehlerConormal
7 public import Stafford38.Geometry.ExactDivisorialVisibleFrameExistence
8 
9 @[expose] public section
10 
11 /-!
12 # Definitions 5.1–5.5 of the paper and the printed Theorem 5.7
13 
14 The paper defines the smooth locus `Y_sm` of an irreducible closed `Y = V(𝔭)` by
15 the Jacobian (Definition 5.4(b)): `y ∈ Y_sm` iff the Jacobian matrix of
16 generators of `𝔭` has rank `n - dim Y` at `y`, with `dim Y` the Krull dimension
17 of `R = K[x]/𝔭`.  Theorems 5.7 and 5.8 are stated in Lean with
18 `SmoothAffinePoint`, Mathlib's smooth locus of `R`.  `definition_5_4_b_iff`
19 proves that the two loci coincide (the Jacobian criterion).
20 
21 * `y` smooth ⇒ Jacobian rank `n - dim Y` (`definition_5_4_b`): the stalk
22   `(Ω_{R/K})_𝔪` is free; its dual basis gives derivations `R → L` for every field
23   `L` over `R_𝔪`, whose coordinate vectors are a basis of the Zariski tangent space
24   over `L`.  Taking `L = K` (the point `y`) and `L = F = Frac R` (the generic point,
25   Lemma 5.12(a)) gives `dim T_y Y = trdeg_K F = dim Y`.
26 * Jacobian rank `n - dim Y` ⇒ `y` smooth (`smoothAffinePoint_of_jacobian` in
27   `Stafford38.Paper.Section5.JacobianConverse`): equations `f_1, …, f_c ∈ 𝔭` with
28   independent differentials generate `𝔭` near `y`, and Mathlib's local Jacobian
29   criterion applies.
30 * `dim Y = trdeg_K F` is `Stafford38.Paper.Support.ringKrullDim_eq_trdeg`.
31 
32 Hence the printed conormal cone `N(Y)` is the Lean one (`conormalCone_paper_eq`),
33 the printed `Dir(Y)` is the Lean direction closure (`definition_5_5`), and
34 `theorem_5_7_i_printed`, `theorem_5_7_ii_printed` are Theorem 5.7 for a nonempty
35 irreducible closed `Y ⊆ K^n` (Definition 5.4(a)), derived from the prime-ideal forms
36 `theorem_5_7_i_prime`, `theorem_5_7_ii_prime` with `𝔭 = I(Y)`.
37 
38 The last section binds the printed Definitions 5.1–5.3 to the Mathlib notions
39 where the wording differs.
40 -/
41 
42 namespace Stafford38.Paper.Section5
43 
44 open MvPolynomial
45 open Stafford38.Geometry.AffineConormalSpan
46 open Stafford38.Geometry.CoisotropicTranslation
47 open Stafford38.Geometry
48 open Stafford38.Geometry.GenericPointKaehlerConormal (quotientDerivation quotientDerivation_mk
49   mkDerivation_eq_sum_pderiv)
50 
51 noncomputable section
52 
53 universe u
54 
55 section Tangent
56 
57 variable {k : Type u} [Field k] {n : ℕ} {I : Ideal (MvPolynomial (Fin n) k)}
58   {L : Type*} [Field L] [Algebra k L] [Algebra (MvPolynomial (Fin n) k ⧸ I) L]
59   [IsScalarTower k (MvPolynomial (Fin n) k ⧸ I) L]
60 
61 /-- Chain rule: a derivation `D : K[x]/I → L` satisfies
62 `D(f̄) = Σ_i ∂_i f(x̄) · D(x̄_i)`. -/
63 theorem derivation_quotient_mk_eq_sum
64     (D : Derivation k (MvPolynomial (Fin n) k ⧸ I) L) (f : MvPolynomial (Fin n) k) :
65     D (Ideal.Quotient.mk I f) = ∑ i, MvPolynomial.eval₂ (algebraMap k L) (GenericPointKaehlerConormal.genericPoint I L)
66       (MvPolynomial.pderiv i f) * D (Ideal.Quotient.mk I (X i)) := by
67   classical
68   induction f using MvPolynomial.induction_on with
69   | C a =>
70     have : Ideal.Quotient.mk I (C a) = algebraMap k (MvPolynomial (Fin n) k ⧸ I) a := rfl
71     rw [this, Derivation.map_algebraMap]
72     simp
73   | add p q hp hq =>
74     simp only [map_add, hp, hq, MvPolynomial.eval₂_add, add_mul, Finset.sum_add_distrib]
75   | mul_X p j hp =>
76     rw [map_mul, Derivation.leibniz, hp, Algebra.smul_def, Algebra.smul_def,
77       algebraMap_quotient_mk_eq_eval₂, algebraMap_quotient_mk_eq_eval₂]
78     have h2 : ∀ i, MvPolynomial.eval₂ (algebraMap k L) (GenericPointKaehlerConormal.genericPoint I L)
79         (MvPolynomial.pderiv i (p * X j)) * D (Ideal.Quotient.mk I (X i)) =
80         (if j = i then MvPolynomial.eval₂ (algebraMap k L) (GenericPointKaehlerConormal.genericPoint I L) p *
81           D (Ideal.Quotient.mk I (X i)) else 0) +
82         MvPolynomial.eval₂ (algebraMap k L) (GenericPointKaehlerConormal.genericPoint I L) (X j) *
83           (MvPolynomial.eval₂ (algebraMap k L) (GenericPointKaehlerConormal.genericPoint I L) (MvPolynomial.pderiv i p) *
84             D (Ideal.Quotient.mk I (X i))) := by
85       intro i
86       simp only [MvPolynomial.pderiv_mul, MvPolynomial.pderiv_X, MvPolynomial.eval₂_add,
87         MvPolynomial.eval₂_mul, Pi.single_apply]
88       split_ifs with h
89       · subst h; simp; ring
90       · simp; ring
91     simp only [h2, Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_ite_eq,
92       Finset.mem_univ, ite_true]
93 
94 /-- The coordinates `(D x̄_i)_i` of a derivation `D : K[x]/I → L` form a tangent
95 vector at the point `x̄ ∈ L^n`. -/
96 theorem derivation_coordinates_mem_zariskiTangentSpace
97     (D : Derivation k (MvPolynomial (Fin n) k ⧸ I) L) :
98     (fun i ↦ D (Ideal.Quotient.mk I (X i))) ∈
99       zariskiTangentSpace (GenericPointKaehlerConormal.genericPoint I L) (I.map (MvPolynomial.map (algebraMap k L))) := by
100   apply mem_zariskiTangentSpace_map_of_forall_mem
101   · intro g hg
102     exact eval₂_genericPoint_eq_zero hg
103   · intro g hg
104     have h := derivation_quotient_mk_eq_sum D g
105     rw [(Ideal.Quotient.eq_zero_iff_mem).2 hg, map_zero] at h
106     exact h.symm
107 
108 /-- Conversely every tangent vector at `x̄ ∈ L^n` is `(D x̄_i)_i` for a derivation
109 `D : K[x]/I → L`. -/
110 theorem exists_derivation_of_mem_zariskiTangentSpace (w : Fin n → L)
111     (hw : w ∈ zariskiTangentSpace (GenericPointKaehlerConormal.genericPoint I L)
112       (I.map (MvPolynomial.map (algebraMap k L)))) :
113     ∃ D : Derivation k (MvPolynomial (Fin n) k ⧸ I) L,
114       ∀ i, D (Ideal.Quotient.mk I (X i)) = w i := by
115   classical
116   set A := MvPolynomial (Fin n) k ⧸ I
117   set y := GenericPointKaehlerConormal.genericPoint I L
118   rw [zariskiTangentSpace, Submodule.mem_dualCoannihilator] at hw
119   have htan : ∀ f ∈ I.map (MvPolynomial.map (algebraMap k L)),
120       ∑ i, differentialAt y f i * w i = 0 := by
121     intro f hf
122     simpa using hw (differentialCovector y f) (Submodule.subset_span ⟨⟨f, hf⟩, rfl⟩)
123   let _ : Algebra (MvPolynomial (Fin n) k) L :=
124     ((algebraMap A L).comp (algebraMap (MvPolynomial (Fin n) k) A)).toAlgebra
125   have : IsScalarTower (MvPolynomial (Fin n) k) A L := by
126     refine ⟨fun p a x ↦ ?_⟩
127     obtain ⟨q, rfl⟩ := Ideal.Quotient.mk_surjective a
128     rw [← Ideal.Quotient.mk_eq_mk, ← Submodule.Quotient.mk_smul, Ideal.Quotient.mk_eq_mk,
129       smul_eq_mul, Algebra.smul_def, Algebra.smul_def, Algebra.smul_def, map_mul, map_mul,
130       mul_assoc]
131     rfl
132   have : IsScalarTower k (MvPolynomial (Fin n) k) L :=
133     IsScalarTower.of_algebraMap_eq fun a ↦ by
134       change algebraMap k L a =
135         algebraMap A L (algebraMap (MvPolynomial (Fin n) k) A (algebraMap k _ a))
136       rw [← IsScalarTower.algebraMap_apply k (MvPolynomial (Fin n) k) A,
137         ← IsScalarTower.algebraMap_apply k A L]
138   have halg : ∀ p : MvPolynomial (Fin n) k,
139       algebraMap (MvPolynomial (Fin n) k) L p = aeval y p := by
140     intro p
141     have : (IsScalarTower.toAlgHom k (MvPolynomial (Fin n) k) L) = aeval y := by
142       apply MvPolynomial.algHom_ext
143       intro i
144       rw [IsScalarTower.coe_toAlgHom', aeval_X]
145       rfl
146     exact AlgHom.congr_fun this p
147   let DP : Derivation k (MvPolynomial (Fin n) k) L := mkDerivation k w
148   have hDP : ∀ f, DP f = ∑ i, aeval y (pderiv i f) * w i :=
149     mkDerivation_eq_sum_pderiv y w halg
150   have hDPI : ∀ f ∈ I, DP f = 0 := by
151     intro f hf
152     rw [hDP]
153     have := htan _ (Ideal.mem_map_of_mem _ hf)
154     convert this using 2 with i
155     rw [differentialAt, pderiv_map, eval_map, aeval_def]
156   refine ⟨quotientDerivation DP hDPI, fun i ↦ ?_⟩
157   rw [quotientDerivation_mk]
158   exact mkDerivation_X k w i
159 
160 end Tangent
161 
162 section Stalk
163 
164 variable {k : Type u} [Field k] {n : ℕ} {I : Ideal (MvPolynomial (Fin n) k)}
165   (𝔪 : Ideal (MvPolynomial (Fin n) k ⧸ I)) [𝔪.IsPrime]
166   {L : Type*} [Field L] [Algebra k L] [Algebra (MvPolynomial (Fin n) k ⧸ I) L]
167   [IsScalarTower k (MvPolynomial (Fin n) k ⧸ I) L]
168   [Algebra (Localization.AtPrime 𝔪) L]
169   [IsScalarTower (MvPolynomial (Fin n) k ⧸ I) (Localization.AtPrime 𝔪) L]
170 
171 /-- If `(Ω_{R/K})_𝔪` is free over `R_𝔪`, then for every field `L` over `R_𝔪` the
172 Zariski tangent space at the `L`-point `x̄` has dimension `rank (Ω_{R/K})_𝔪`.
173 A basis of the dual of `(Ω_{R/K})_𝔪` gives derivations `D_j : R → L`; their
174 coordinate vectors `(D_j x̄_i)_i` are a basis of the tangent space. -/
175 theorem finrank_zariskiTangentSpace_eq_finrank_localizedKaehler
176     [Module.Free (Localization.AtPrime 𝔪)
177       (LocalizedModule 𝔪.primeCompl Ω[(MvPolynomial (Fin n) k ⧸ I)⁄k])]
178     [Module.Finite (Localization.AtPrime 𝔪)
179       (LocalizedModule 𝔪.primeCompl Ω[(MvPolynomial (Fin n) k ⧸ I)⁄k])] :
180     Module.finrank L (zariskiTangentSpace (GenericPointKaehlerConormal.genericPoint I L)
181         (I.map (MvPolynomial.map (algebraMap k L)))) =
182       Module.finrank (Localization.AtPrime 𝔪)
183         (LocalizedModule 𝔪.primeCompl Ω[(MvPolynomial (Fin n) k ⧸ I)⁄k]) := by
184   classical
185   set A := MvPolynomial (Fin n) k ⧸ I
186   set R := Localization.AtPrime 𝔪
187   set M := LocalizedModule 𝔪.primeCompl Ω[A⁄k]
188   set T := zariskiTangentSpace (GenericPointKaehlerConormal.genericPoint I L) (I.map (MvPolynomial.map (algebraMap k L)))
189   let b := Module.Free.chooseBasis R M
190   let lam : Module.Free.ChooseBasisIndex R M → (M →ₗ[R] L) :=
191     fun j ↦ (Algebra.linearMap R L).comp (b.coord j)
192   let mkM : Ω[A⁄k] →ₗ[A] M := LocalizedModule.mkLinearMap 𝔪.primeCompl Ω[A⁄k]
193   let Dj : Module.Free.ChooseBasisIndex R M → Derivation k A L :=
194     fun j ↦ (((lam j).restrictScalars A).comp mkM).compDer (KaehlerDifferential.D k A)
195   let v : Module.Free.ChooseBasisIndex R M → Fin n → L :=
196     fun j i ↦ Dj j (Ideal.Quotient.mk I (X i))
197   have hv : ∀ j i, v j i = algebraMap R L (b.coord j (mkM (KaehlerDifferential.D k A
198       (Ideal.Quotient.mk I (X i))))) := fun _ _ ↦ rfl
199   -- Elements of `𝔪ᶜ` act invertibly on `L`.
200   have hunit : ∀ s : 𝔪.primeCompl, IsUnit (algebraMap A (Module.End A L) s) := by
201     intro s
202     rw [Module.End.isUnit_iff]
203     have hu : IsUnit (algebraMap A L s) := by
204       rw [IsScalarTower.algebraMap_apply A R L]
205       exact (IsLocalization.map_units R s).map _
206     have hfun : ⇑(algebraMap A (Module.End A L) s) = fun x ↦ algebraMap A L s * x :=
207       funext fun x ↦ Algebra.smul_def (s : A) x
208     rw [hfun]
209     exact ⟨hu.mul_right_injective, fun x ↦ ⟨(algebraMap A L s)⁻¹ * x, by
210       simp only; rw [← mul_assoc, mul_inv_cancel₀ hu.ne_zero, one_mul]⟩⟩
211   have hvT : ∀ j, v j ∈ T := fun j ↦ derivation_coordinates_mem_zariskiTangentSpace (Dj j)
212   have hli : LinearIndependent L v := by
213     rw [Fintype.linearIndependent_iff]
214     intro t ht j
215     let lt : M →ₗ[R] L := ∑ j', (LinearMap.mulLeft R (t j')).comp (lam j')
216     have hlt : ∀ x, lt x = ∑ j', t j' * algebraMap R L (b.coord j' x) := by
217       intro x
218       simp [lt, lam]
219     let Dt : Derivation k A L :=
220       ((lt.restrictScalars A).comp mkM).compDer (KaehlerDifferential.D k A)
221     have hDtX : ∀ i, Dt (Ideal.Quotient.mk I (X i)) = 0 := by
222       intro i
223       have h := congrFun ht i
224       simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul, Pi.zero_apply, hv] at h
225       change lt (mkM (KaehlerDifferential.D k A (Ideal.Quotient.mk I (X i)))) = 0
226       rw [hlt]
227       exact h
228     have hDt0 : Dt = 0 := by
229       ext a
230       obtain ⟨f, rfl⟩ := Ideal.Quotient.mk_surjective a
231       rw [derivation_quotient_mk_eq_sum Dt f]
232       simp [hDtX]
233     have hcomp : (lt.restrictScalars A).comp mkM = 0 := by
234       apply Derivation.liftKaehlerDifferential_unique
235       ext a
236       change Dt a = 0
237       rw [hDt0, Derivation.zero_apply]
238     have hlt0 : lt.restrictScalars A = 0 :=
239       IsLocalizedModule.ext 𝔪.primeCompl mkM hunit (by rw [hcomp, LinearMap.zero_comp])
240     have h := LinearMap.congr_fun hlt0 (b j)
241     rw [LinearMap.restrictScalars_apply, LinearMap.zero_apply, hlt] at h
242     simpa [Module.Basis.coord_apply, Module.Basis.repr_self, Finsupp.single_apply] using h
243   have hspan : T ≤ Submodule.span L (Set.range v) := by
244     intro w hw
245     obtain ⟨Dw, hDw⟩ := exists_derivation_of_mem_zariskiTangentSpace w hw
246     let ψ : Ω[A⁄k] →ₗ[A] L := Dw.liftKaehlerDifferential
247     let φ : M →ₗ[A] L := IsLocalizedModule.lift 𝔪.primeCompl mkM ψ hunit
248     let Φ : M →ₗ[R] L := LinearMap.extendScalarsOfIsLocalization 𝔪.primeCompl R φ
249     have hΦ : ∀ x, Φ x = ∑ j, Φ (b j) * algebraMap R L (b.coord j x) := by
250       intro x
251       conv_lhs => rw [← b.sum_repr x]
252       rw [map_sum]
253       refine Finset.sum_congr rfl fun j _ ↦ ?_
254       rw [map_smul, Algebra.smul_def, mul_comm, Module.Basis.coord_apply]
255     have hw' : w = ∑ j, Φ (b j) • v j := by
256       funext i
257       have h1 : Φ (mkM (KaehlerDifferential.D k A (Ideal.Quotient.mk I (X i)))) = w i := by
258         change φ (mkM _) = w i
259         rw [IsLocalizedModule.lift_apply]
260         change Dw.liftKaehlerDifferential (KaehlerDifferential.D k A _) = _
261         rw [Derivation.liftKaehlerDifferential_comp_D, hDw]
262       rw [← h1, hΦ]
263       simp [Finset.sum_apply, hv]
264     rw [hw']
265     exact Submodule.sum_mem _ fun j _ ↦ Submodule.smul_mem _ _ (Submodule.subset_span ⟨j, rfl⟩)
266   have heq : T = Submodule.span L (Set.range v) :=
267     le_antisymm hspan (Submodule.span_le.2 (Set.range_subset_iff.2 hvT))
268   have : StrongRankCondition R := commRing_strongRankCondition R
269   rw [heq, finrank_span_eq_card hli, Module.finrank_eq_card_chooseBasisIndex]
270 
271 end Stalk
272 
273 section JacobianRank
274 
275 variable {k : Type u} [Field k] {n : ℕ}
276 
277 /-- `rank (df_y)_{f ∈ I} + dim T_y = n`: the Jacobian rank and the dimension of the
278 Zariski tangent space at `y` add up to `n`. -/
279 theorem finrank_differentialSpan_add_finrank_zariskiTangentSpace
280     (I : Ideal (MvPolynomial (Fin n) k)) (y : Fin n → k) :
281     Module.finrank k (Submodule.span k (Set.range fun f : I ↦ differentialAt y f.1)) +
282       Module.finrank k (zariskiTangentSpace y I) = n := by
283   have hspan : equationCovectorSpan y I =
284       (Submodule.span k (Set.range fun f : I ↦ differentialAt y f.1)).map
285         (coordinateCovectorLinear (k := k) (n := n)) := by
286     rw [Submodule.map_span, ← Set.range_comp]
287     rfl
288   have hinj : Function.Injective (coordinateCovectorLinear (k := k) (n := n)) :=
289     coordinateCovector_injective
290   have h1 : Module.finrank k (equationCovectorSpan y I) =
291       Module.finrank k (Submodule.span k (Set.range fun f : I ↦ differentialAt y f.1)) := by
292     rw [hspan]
293     exact (Submodule.equivMapOfInjective _ hinj _).finrank_eq.symm
294   have h := Subspace.finrank_add_finrank_dualCoannihilator_eq (equationCovectorSpan y I)
295   have hn : Module.finrank k (AffineTangentVector k n) = n := Module.finrank_fin_fun k
296   rw [h1, hn] at h
297   exact h
298 
299 /-- The rank of the Jacobian matrix `(∂_i g_j(y))_{j,i}` of a family of generators
300 `g_1, …, g_s` of `I` at a point `y ∈ V(I)` is `dim span {df_y : f ∈ I}`; in particular it
301 does not depend on the generators. -/
302 theorem jacobian_rank_eq_finrank_differentialSpan
303     (I : Ideal (MvPolynomial (Fin n) k)) {s : ℕ} (g : Fin s → MvPolynomial (Fin n) k)
304     (hg : Ideal.span (Set.range g) = I) {y : Fin n → k}
305     (hy : y ∈ MvPolynomial.zeroLocus k I) :
306     (Matrix.of fun j i ↦ differentialAt y (g j) i).rank =
307       Module.finrank k (Submodule.span k (Set.range fun f : I ↦ differentialAt y f.1)) := by
308   rw [Matrix.rank_eq_finrank_span_row]
309   have hrows : Set.range (Matrix.of fun j i ↦ differentialAt y (g j) i).row =
310       Set.range fun j ↦ differentialAt y (g j) := rfl
311   suffices hs : Submodule.span k (Set.range fun j ↦ differentialAt y (g j)) =
312       Submodule.span k (Set.range fun f : I ↦ differentialAt y f.1) by
313     rw [hrows, hs]
314   apply le_antisymm
315   · rw [Submodule.span_le]
316     rintro _ ⟨j, rfl⟩
317     have hj : g j ∈ I := hg ▸ Ideal.subset_span ⟨j, rfl⟩
318     exact Submodule.subset_span ⟨⟨g j, hj⟩, rfl⟩
319   · have key : ∀ f ∈ Ideal.span (Set.range g),
320         differentialAt y f ∈ Submodule.span k (Set.range fun j ↦ differentialAt y (g j)) := by
321       intro f hf
322       induction hf using Submodule.span_induction with
323       | mem f hf =>
324         obtain ⟨j, rfl⟩ := hf
325         exact Submodule.subset_span ⟨j, rfl⟩
326       | zero =>
327         have : differentialAt y (0 : MvPolynomial (Fin n) k) = 0 := by
328           funext i; simp [differentialAt]
329         rw [this]
330         exact Submodule.zero_mem _
331       | add f₁ f₂ _ _ ih₁ ih₂ =>
332         have : differentialAt y (f₁ + f₂) = differentialAt y f₁ + differentialAt y f₂ := by
333           funext i; simp [differentialAt]
334         rw [this]
335         exact Submodule.add_mem _ ih₁ ih₂
336       | smul a f hfs ih =>
337         have hfy : MvPolynomial.eval y f = 0 := by
338           simpa using (MvPolynomial.mem_zeroLocus_iff.1 hy) f (hg ▸ hfs)
339         have : differentialAt y (a • f) = MvPolynomial.eval y a • differentialAt y f := by
340           funext i
341           simp [differentialAt, smul_eq_mul, hfy]
342         rw [this]
343         exact Submodule.smul_mem _ _ ih
344     rw [Submodule.span_le]
345     rintro _ ⟨⟨f, hf⟩, rfl⟩
346     exact key f (hg ▸ hf)
347 
348 end JacobianRank
349 
350 section SmoothPoint
351 
352 variable {k : Type u} [Field k] {n : ℕ}
353 
354 /-- `dim Y` for `Y = V(𝔭)`: the transcendence degree over `K` of the function field
355 `F = Frac(K[x]/𝔭)`. -/
356 def componentDimension (P : PrimeSpectrum (MvPolynomial (Fin n) k)) : ℕ :=
357   (Algebra.trdeg k (FractionRing (MvPolynomial (Fin n) k ⧸ P.asIdeal))).toNat
358 
359 /-- **Definition 5.4(b), the Jacobian smooth locus.** `y ∈ Y_sm` iff `y ∈ Y = V(𝔭)` and
360 the Jacobian matrix `(∂_i g_j(y))` of generators `g_1, …, g_s` of `I(Y) = 𝔭` has rank
361 `n - dim Y`, written `rank + dim Y = n` with `dim Y` the Krull dimension of `K[x]/𝔭`.
362 The rank does not depend on the generators
363 (`jacobian_rank_eq_finrank_differentialSpan`, `jacobianSmoothPoint_iff_span`). -/
364 def JacobianSmoothPoint (P : PrimeSpectrum (MvPolynomial (Fin n) k)) (y : Fin n → k) : Prop :=
365   y ∈ MvPolynomial.zeroLocus k P.asIdeal ∧
366     ∃ (s : ℕ) (g : Fin s → MvPolynomial (Fin n) k), Ideal.span (Set.range g) = P.asIdeal ∧
367       ((Matrix.of fun j i ↦ differentialAt y (g j) i).rank : WithBot ℕ∞) +
368         ringKrullDim (MvPolynomial (Fin n) k ⧸ P.asIdeal) = n
369 
370 /-- The Jacobian rank is `dim span {df_y : f ∈ 𝔭}`, for any finite generating family
371 (one exists, `K[x]` being Noetherian). -/
372 theorem jacobianSmoothPoint_iff_span (P : PrimeSpectrum (MvPolynomial (Fin n) k))
373     (y : Fin n → k) :
374     JacobianSmoothPoint P y ↔ y ∈ MvPolynomial.zeroLocus k P.asIdeal ∧
375       (Module.finrank k (Submodule.span k (Set.range fun f : P.asIdeal ↦ differentialAt y f.1)) :
376         WithBot ℕ∞) + ringKrullDim (MvPolynomial (Fin n) k ⧸ P.asIdeal) = n := by
377   constructor
378   · rintro ⟨hy, s, g, hg, h⟩
379     exact ⟨hy, by rwa [jacobian_rank_eq_finrank_differentialSpan P.asIdeal g hg hy] at h⟩
380   · rintro ⟨hy, h⟩
381     obtain ⟨s, g, hg⟩ :=
382       Submodule.fg_iff_exists_fin_generating_family.mp (IsNoetherian.noetherian P.asIdeal)
383     exact ⟨hy, s, g, hg, by rwa [jacobian_rank_eq_finrank_differentialSpan P.asIdeal g hg hy]⟩
384 
385 /-- `dim Y` is both the Krull dimension of `K[x]/𝔭` and `trdeg_K Frac(K[x]/𝔭)`. -/
386 theorem componentDimension_eq_ringKrullDim (P : PrimeSpectrum (MvPolynomial (Fin n) k)) :
387     ringKrullDim (MvPolynomial (Fin n) k ⧸ P.asIdeal) = componentDimension P := by
388   rw [Stafford38.Paper.Support.ringKrullDim_eq_trdeg (K := k), componentDimension,
389     Stafford38.Paper.Support.trdeg_fractionRing]
390 
391 theorem componentDimension_le (P : PrimeSpectrum (MvPolynomial (Fin n) k)) :
392     componentDimension P ≤ n := by
393   rw [componentDimension, Stafford38.Paper.Support.trdeg_fractionRing]
394   have h := Stafford38.Paper.Support.trdeg_quotient_le (K := k) P.asIdeal
395   rw [MvPolynomial.trdeg_of_isDomain, Cardinal.mk_fintype, Fintype.card_fin,
396     Cardinal.lift_natCast] at h
397   have := Cardinal.toNat_le_toNat h Cardinal.natCast_lt_aleph0
398   simpa using this
399 
400 /-- **Definition 5.4(b), transcendence-degree form.** -/
401 theorem jacobianSmoothPoint_iff_trdeg (P : PrimeSpectrum (MvPolynomial (Fin n) k))
402     (y : Fin n → k) :
403     JacobianSmoothPoint P y ↔ y ∈ MvPolynomial.zeroLocus k P.asIdeal ∧
404       Module.finrank k (Submodule.span k (Set.range fun f : P.asIdeal ↦ differentialAt y f.1)) =
405         n - componentDimension P := by
406   have hle := componentDimension_le P
407   rw [jacobianSmoothPoint_iff_span, componentDimension_eq_ringKrullDim]
408   apply and_congr_right
409   intro _
410   constructor
411   · intro h
412     have h' : Module.finrank k (Submodule.span k (Set.range fun f : P.asIdeal ↦
413         differentialAt y f.1)) + componentDimension P = n := by exact_mod_cast h
414     omega
415   · intro h
416     have h' : Module.finrank k (Submodule.span k (Set.range fun f : P.asIdeal ↦
417         differentialAt y f.1)) + componentDimension P = n := by omega
418     exact_mod_cast h'
419 
420 variable [IsAlgClosed k]
421 
422 omit [IsAlgClosed k] in
423 open Stafford38.Geometry.SmoothAffineConormal in
424 /-- At a Mathlib smooth point `y` the Zariski tangent space has dimension
425 `dim_F Ω_{F/K}`.  The stalk `(Ω_{R/K})_𝔪` is free; its rank is read off once at `y`
426 (`L = K`) and once at the generic point (`L = F`), where Lemma 5.12(a) gives
427 `dim_F Ω_{F/K}`. -/
428 theorem finrank_zariskiTangentSpace_of_smoothAffinePoint
429     (P : PrimeSpectrum (MvPolynomial (Fin n) k)) {y : Fin n → k}
430     (hy : SmoothAffinePoint P.asIdeal y) :
431     Module.finrank k (zariskiTangentSpace y P.asIdeal) =
432       Module.finrank (FractionRing (MvPolynomial (Fin n) k ⧸ P.asIdeal))
433         Ω[FractionRing (MvPolynomial (Fin n) k ⧸ P.asIdeal)⁄k] := by
434   classical
435   set A := MvPolynomial (Fin n) k ⧸ P.asIdeal
436   set F := FractionRing A
437   obtain ⟨e, heval, hsm⟩ := hy
438   set 𝔪 : Ideal A := RingHom.ker e.toRingHom
439   have : 𝔪.IsPrime := RingHom.ker_isPrime e
440   rw [Algebra.smoothLocus_eq_compl_support_inter] at hsm
441   have : Module.Free (Localization.AtPrime 𝔪) (LocalizedModule 𝔪.primeCompl Ω[A⁄k]) :=
442     Module.mem_freeLocus.1 hsm.2
443   -- The point `y`: `L = K` through `e : R → K`.
444   have hK : Module.finrank k (zariskiTangentSpace y P.asIdeal) =
445       Module.finrank (Localization.AtPrime 𝔪) (LocalizedModule 𝔪.primeCompl Ω[A⁄k]) := by
446     let : Algebra A k := e.toRingHom.toAlgebra
447     have : IsScalarTower k A k := ⟨fun c a x ↦ by
448       change e (c • a) * x = c * (e a * x)
449       rw [map_smul, smul_eq_mul, mul_assoc]⟩
450     have hunitK : ∀ s : 𝔪.primeCompl, IsUnit (e.toRingHom (s : A)) :=
451       fun s ↦ isUnit_iff_ne_zero.2 fun h ↦ s.2 h
452     let : Algebra (Localization.AtPrime 𝔪) k :=
453       (IsLocalization.lift (M := 𝔪.primeCompl) (S := Localization.AtPrime 𝔪) hunitK).toAlgebra
454     have : IsScalarTower A (Localization.AtPrime 𝔪) k :=
455       IsScalarTower.of_algebraMap_eq fun a ↦ (IsLocalization.lift_eq hunitK a).symm
456     have h := finrank_zariskiTangentSpace_eq_finrank_localizedKaehler (L := k) 𝔪
457     have hpt : GenericPointKaehlerConormal.genericPoint P.asIdeal k = y := by
458       funext i
459       change e (Ideal.Quotient.mk _ (X i)) = y i
460       rw [heval]
461       simp
462     have hmap : MvPolynomial.map (algebraMap k k) =
463         RingHom.id (MvPolynomial (Fin n) k) := by
464       rw [Algebra.algebraMap_self]
465       exact RingHom.ext MvPolynomial.map_id
466     rwa [hpt, hmap, Ideal.map_id] at h
467   -- The generic point: `L = F`.
468   have hF : Module.finrank F (zariskiTangentSpace (GenericPointKaehlerConormal.genericPoint P.asIdeal F)
469         (P.asIdeal.map (MvPolynomial.map (algebraMap k F)))) =
470       Module.finrank (Localization.AtPrime 𝔪) (LocalizedModule 𝔪.primeCompl Ω[A⁄k]) := by
471     let : Algebra (Localization.AtPrime 𝔪) F :=
472       IsLocalization.localizationAlgebraOfSubmonoidLe _ _ 𝔪.primeCompl (nonZeroDivisors A)
473         (Ideal.primeCompl_le_nonZeroDivisors 𝔪)
474     have : IsScalarTower A (Localization.AtPrime 𝔪) F :=
475       IsLocalization.localization_isScalarTower_of_submonoid_le (R := A)
476         (Localization.AtPrime 𝔪) F 𝔪.primeCompl (nonZeroDivisors A)
477         (Ideal.primeCompl_le_nonZeroDivisors 𝔪)
478     exact finrank_zariskiTangentSpace_eq_finrank_localizedKaehler (L := F) 𝔪
479   have h512 := generic_tangent_finrank_eq_component_kaehler_finrank (F := F) (E := F)
480     (I := P.asIdeal)
481   simp only [Algebra.algebraMap_self, RingHom.id_apply] at h512
482   rw [hK, ← hF, ← h512]
483 
484 open Stafford38.Geometry.SmoothAffineConormal in
485 /-- **Definition 5.4(b), Lean smooth points are Jacobian smooth.** A point of Mathlib's
486 smooth locus of `K[x]/𝔭` (`SmoothAffinePoint`) lies in the paper's `Y_sm`: the Jacobian
487 of `𝔭` has rank `n - dim Y` there.  The converse is `definition_5_4_b_iff`. -/
488 theorem definition_5_4_b [CharZero k]
489     (P : PrimeSpectrum (MvPolynomial (Fin n) k)) {y : Fin n → k}
490     (hy : SmoothAffinePoint P.asIdeal y) : JacobianSmoothPoint P y := by
491   rw [jacobianSmoothPoint_iff_trdeg]
492   refine ⟨smoothAffinePoint_mem_zeroLocus P.asIdeal hy, ?_⟩
493   have h1 := finrank_differentialSpan_add_finrank_zariskiTangentSpace P.asIdeal y
494   have h2 := finrank_zariskiTangentSpace_of_smoothAffinePoint P hy
495   have h3 := (component_kaehler_finrank_eq_trdeg (k := k)
496     (AffineComponentCoordinateSplit.componentCoordinate P)
497     (ExactDivisorialVisibleFrameExistence.componentCoordinate_adjoin_eq_top P)).2
498   rw [componentDimension]
499   omega
500 
501 open Stafford38.Geometry.SmoothAffineConormal in
502 /-- **Definition 5.4(b), the Jacobian criterion.** `y` lies in Mathlib's smooth locus of
503 `K[x]/𝔭` iff the Jacobian of `𝔭` has rank `n - dim Y` at `y ∈ Y`.  The converse direction
504 picks equations `f_1, …, f_c ∈ 𝔭` with independent differentials at `y` and applies
505 `smoothAffinePoint_of_jacobian`. -/
506 theorem definition_5_4_b_iff [CharZero k]
507     (P : PrimeSpectrum (MvPolynomial (Fin n) k)) (y : Fin n → k) :
508     SmoothAffinePoint P.asIdeal y ↔ JacobianSmoothPoint P y := by
509   classical
510   refine ⟨definition_5_4_b P, fun h ↦ ?_⟩
511   have hle := componentDimension_le P
512   rw [jacobianSmoothPoint_iff_trdeg] at h
513   obtain ⟨hy, hr⟩ := h
514   obtain ⟨s, hsub, hspan, hli⟩ :=
515     exists_linearIndependent k (Set.range fun f : P.asIdeal ↦ differentialAt y f.1)
516   have : Fintype s := (hli.setFinite).fintype
517   have hcard : Fintype.card s = Module.finrank k
518       (Submodule.span k (Set.range fun f : P.asIdeal ↦ differentialAt y f.1)) := by
519     rw [← hspan, ← finrank_span_eq_card hli, Subtype.range_coe]
520   have hg : ∀ v : s, ∃ g : MvPolynomial (Fin n) k, g ∈ P.asIdeal ∧ differentialAt y g = v :=
521     fun v ↦ by
522       obtain ⟨g, hg⟩ := hsub v.2
523       exact ⟨g.1, g.2, hg⟩
524   choose g hgP hgd using hg
525   have hli' : LinearIndependent k fun v : s ↦ differentialAt y (g v) := by
526     convert hli using 1
527     funext v
528     exact hgd v
529   exact smoothAffinePoint_of_jacobian P hy g hgP hli' (by
530     change Fintype.card s + componentDimension P = n
531     omega)
532 
533 end SmoothPoint
534 
535 section ConormalCone
536 
537 open Stafford38.Geometry.SmoothAffineConormal
538 open Stafford38.Geometry.ProjectiveConormalDirections
539 open Stafford38.Geometry.AffineConormalClosure
540 open Stafford38.Geometry.ConormalPrincipalOpenDensity
541 
542 variable {k : Type u} [Field k] [IsAlgClosed k] {n : ℕ}
543 
544 /-- **Definition 5.4(d), as printed.** The conormal cone
545 `N(Y) = ⋃_{y ∈ Y_sm} N*_y Y` over the Jacobian smooth locus, with
546 `N*_y Y = span_K {df_y : f ∈ I(Y)}`. -/
547 def conormalCone (P : PrimeSpectrum (MvPolynomial (Fin n) k)) : Set (Fin n → k) :=
548   {ξ | ∃ y, JacobianSmoothPoint P y ∧
549     ξ ∈ Submodule.span k (Set.range fun f : P.asIdeal ↦ differentialAt y f.1)}
550 
551 /-- **`N(Y)` as printed is the Lean conormal cone**: the Jacobian smooth locus is Mathlib's
552 smooth locus (`definition_5_4_b_iff`). -/
553 theorem conormalCone_paper_eq [CharZero k] (P : PrimeSpectrum (MvPolynomial (Fin n) k)) :
554     conormalCone P = smoothConormalFibreProjection P.asIdeal := by
555   ext ξ
556   rw [definition_5_4_d]
557   simp only [conormalCone, Set.mem_ofPred_eq, definition_5_4_b_iff]
558 
559 omit [IsAlgClosed k] in
560 theorem projectivizedDirectionSet_smoothConormalDirectionSet
561     (I : Ideal (MvPolynomial (Fin n) k)) :
562     projectivizedDirectionSet (smoothConormalDirectionSet I) =
563       projectivizedDirectionSet (smoothConormalFibreProjection I) := by
564   ext z
565   constructor
566   · rintro ⟨v, ⟨y, hy, _, hc⟩, hv, rfl⟩
567     exact ⟨v, ⟨y, hy, hc⟩, hv, rfl⟩
568   · rintro ⟨v, ⟨y, hy, hc⟩, hv, rfl⟩
569     exact ⟨v, ⟨y, hy, hv, hc⟩, hv, rfl⟩
570 
571 /-- **Definition 5.5, as printed.** `Dir(Y)` is the Zariski closure in `ℙ((K^n)^*)` of
572 `{[ξ] : 0 ≠ ξ ∈ N(Y)}`; projective Zariski closed sets are the common zero sets of
573 homogeneous polynomials. -/
574 def conormalDirections (P : PrimeSpectrum (MvPolynomial (Fin n) k)) :
575     Set (Projectivization k (Fin n → k)) :=
576   projectiveHomogeneousClosure (projectivizedDirectionSet (conormalCone P))
577 
578 /-- **Definition 5.5.** The printed `Dir(Y)` is the Lean direction closure used in
579 Theorem 5.7(ii). -/
580 theorem definition_5_5 [CharZero k] (P : PrimeSpectrum (MvPolynomial (Fin n) k)) :
581     conormalDirections P = projectiveHomogeneousClosure
582       (projectivizedDirectionSet (smoothConormalDirectionSet P.asIdeal)) := by
583   rw [projectivizedDirectionSet_smoothConormalDirectionSet, conormalDirections,
584     conormalCone_paper_eq]
585 
586 end ConormalCone
587 
588 section Theorem57
589 
590 open Stafford38.Geometry.ProjectiveConormalDirections
591 
592 /-- Theorem 5.7(i) for `Y = V(𝔭)` with `𝔭 = I(Y)` prime: every polynomial
593 `P ∈ K[ξ_1, …, ξ_n]` vanishing on the conormal cone `N(Y)` over the Jacobian smooth
594 locus satisfies `P(1, 0, …, 0) = 0`.  `theorem_5_7_i_printed` is the printed form. -/
595 theorem theorem_5_7_i_prime
596     {k : Type u} [Field k] [IsAlgClosed k] [CharZero k]
597     {m : ℕ} (hm : 0 < m)
598     (I : PrimeSpectrum (MvPolynomial (Fin m) k))
599     (havoid : ∀ y ∈ MvPolynomial.zeroLocus k I.asIdeal, y ⟨0, hm⟩ ≠ 0)
600     (Q : MvPolynomial (Fin m) k) (hQ : ∀ ξ ∈ conormalCone I, MvPolynomial.eval ξ Q = 0) :
601     MvPolynomial.eval (fun i : Fin m => if i = ⟨0, hm⟩ then (1 : k) else 0) Q = 0 := by
602   have hQ' : Q ∈ MvPolynomial.vanishingIdeal k (smoothConormalFibreProjection I.asIdeal) := by
603     rw [MvPolynomial.mem_vanishingIdeal_iff, ← conormalCone_paper_eq I]
604     simpa using hQ
605   simpa using (MvPolynomial.mem_zeroLocus_iff.1 (theorem_5_7_i hm I havoid)) Q hQ'
606 
607 /-- Theorem 5.7(ii) for `Y = V(𝔭)` with `𝔭` prime: `[dx_1] ∈ Dir(Y)`.
608 `theorem_5_7_ii_printed` is the printed form. -/
609 theorem theorem_5_7_ii_prime
610     {k : Type u} [Field k] [IsAlgClosed k] [CharZero k]
611     {m : ℕ} (hm : 0 < m)
612     (I : PrimeSpectrum (MvPolynomial (Fin m) k))
613     (havoid : ∀ y ∈ MvPolynomial.zeroLocus k I.asIdeal, y ⟨0, hm⟩ ≠ 0) :
614     Projectivization.mk k
615         (fun i : Fin m => if i = ⟨0, hm⟩ then (1 : k) else 0)
616         (by intro h; have := congrFun h ⟨0, hm⟩; simp at this) ∈
617       conormalDirections I := by
618   rw [definition_5_5]
619   exact theorem_5_7_ii hm I havoid
620 
621 /-- For a prime `𝔭`, `Y = V_K(𝔭)` is nonempty, closed and irreducible
622 (Definition 5.4(a)), with `I(Y) = 𝔭` (Nullstellensatz). -/
623 theorem irreducibleClosed_zeroLocus_of_isPrime
624     {k : Type u} [Field k] [IsAlgClosed k] {m : ℕ}
625     (𝔭 : Ideal (MvPolynomial (Fin m) k)) [h𝔭 : 𝔭.IsPrime] :
626     ∃ (hne : (MvPolynomial.zeroLocus k 𝔭).Nonempty)
627       (hY : IsIrreducibleClosed (MvPolynomial.zeroLocus k 𝔭)),
628       idealPoint (MvPolynomial.zeroLocus k 𝔭) hne hY = ⟨𝔭, h𝔭⟩ := by
629   have hI : MvPolynomial.vanishingIdeal k (MvPolynomial.zeroLocus k 𝔭) = 𝔭 :=
630     MvPolynomial.IsPrime.vanishingIdeal_zeroLocus 𝔭
631   have hne : (MvPolynomial.zeroLocus k 𝔭).Nonempty := by
632     rw [Set.nonempty_iff_ne_empty]
633     intro h0
634     rw [h0, MvPolynomial.vanishingIdeal_empty] at hI
635     exact h𝔭.ne_top hI.symm
636   have hY : IsIrreducibleClosed (MvPolynomial.zeroLocus k 𝔭) :=
637     (definition_5_4_a hne ⟨𝔭, rfl⟩).2 (by rw [hI]; exact h𝔭)
638   exact ⟨hne, hY, PrimeSpectrum.ext hI⟩
639 
640 /-- **Theorem 5.7(i).** Let `Y ⊆ X = K^n` be nonempty, closed and irreducible
641 (Definition 5.4(a)) with `Y ∩ H = ∅`, `H = {x_1 = 0}`, and let
642 `N(Y) = ⋃_{y ∈ Y_sm} N*_y Y` be the conormal cone over the smooth locus.  Every
643 polynomial `P ∈ K[ξ_1, …, ξ_n]` vanishing on `N(Y)` satisfies `P(1, 0, …, 0) = 0`.
644 Derived from `theorem_5_7_i_prime` with `𝔭 = I(Y)`. -/
645 theorem theorem_5_7_i_printed
646     {k : Type u} [Field k] [IsAlgClosed k] [CharZero k]
647     {m : ℕ} (hm : 0 < m)
648     (Y : Set (Fin m → k)) (hne : Y.Nonempty) (hY : IsIrreducibleClosed Y)
649     (hH : Y ∩ {y | y ⟨0, hm⟩ = 0} = ∅)
650     (P : MvPolynomial (Fin m) k)
651     (hP : ∀ ξ ∈ conormalCone (idealPoint Y hne hY), MvPolynomial.eval ξ P = 0) :
652     MvPolynomial.eval (fun i : Fin m => if i = ⟨0, hm⟩ then (1 : k) else 0) P = 0 := by
653   refine theorem_5_7_i_prime hm (idealPoint Y hne hY) (fun y hy h0 => ?_) P hP
654   change y ∈ MvPolynomial.zeroLocus k (MvPolynomial.vanishingIdeal k Y) at hy
655   rw [zeroLocus_vanishingIdeal_of_isZariskiClosed hY.1] at hy
656   exact (Set.eq_empty_iff_forall_notMem.mp hH) y ⟨hy, h0⟩
657 
658 /-- **Theorem 5.7(ii).** For `Y` as in (i), `[dx_1] ∈ Dir(Y)`.  Derived from
659 `theorem_5_7_ii_prime` with `𝔭 = I(Y)`. -/
660 theorem theorem_5_7_ii_printed
661     {k : Type u} [Field k] [IsAlgClosed k] [CharZero k]
662     {m : ℕ} (hm : 0 < m)
663     (Y : Set (Fin m → k)) (hne : Y.Nonempty) (hY : IsIrreducibleClosed Y)
664     (hH : Y ∩ {y | y ⟨0, hm⟩ = 0} = ∅) :
665     Projectivization.mk k
666         (fun i : Fin m => if i = ⟨0, hm⟩ then (1 : k) else 0)
667         (by intro h; have := congrFun h ⟨0, hm⟩; simp at this) ∈
668       conormalDirections (idealPoint Y hne hY) := by
669   refine theorem_5_7_ii_prime hm (idealPoint Y hne hY) (fun y hy h0 => ?_)
670   change y ∈ MvPolynomial.zeroLocus k (MvPolynomial.vanishingIdeal k Y) at hy
671   rw [zeroLocus_vanishingIdeal_of_isZariskiClosed hY.1] at hy
672   exact (Set.eq_empty_iff_forall_notMem.mp hH) y ⟨hy, h0⟩
673 
674 end Theorem57
675 
676 end
677 
678 #print axioms derivation_quotient_mk_eq_sum
679 #print axioms derivation_coordinates_mem_zariskiTangentSpace
680 #print axioms exists_derivation_of_mem_zariskiTangentSpace
681 #print axioms finrank_zariskiTangentSpace_eq_finrank_localizedKaehler
682 #print axioms finrank_differentialSpan_add_finrank_zariskiTangentSpace
683 #print axioms jacobian_rank_eq_finrank_differentialSpan
684 #print axioms componentDimension_eq_ringKrullDim
685 #print axioms componentDimension_le
686 #print axioms jacobianSmoothPoint_iff_trdeg
687 #print axioms finrank_zariskiTangentSpace_of_smoothAffinePoint
688 #print axioms definition_5_4_b
689 #print axioms definition_5_4_b_iff
690 #print axioms conormalCone_paper_eq
691 #print axioms projectivizedDirectionSet_smoothConormalDirectionSet
692 #print axioms definition_5_5
693 #print axioms theorem_5_7_i_prime
694 #print axioms theorem_5_7_ii_prime
695 #print axioms irreducibleClosed_zeroLocus_of_isPrime
696 #print axioms theorem_5_7_i_printed
697 #print axioms theorem_5_7_ii_printed
698 
699 end Stafford38.Paper.Section5
700