Stafford38/Geometry/CompletedDVRPowerSeriesEquiv.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 public import Stafford38.Geometry.CompletedDVRCoefficientSection
3 public import Mathlib.RingTheory.PowerSeries.Trunc
4 public import Mathlib.RingTheory.DiscreteValuationRing.Basic
5 
6 @[expose] public section
7 
8 /-!
9 # A chosen-coordinate power-series map to a completed DVR
10 
11 For a discrete valuation ring `V`, choose an actual uniformizer `pi`, not an
12 arbitrary nonzero nonunit.  A residue-field section in the maximal-ideal adic
13 completion then gives a map depending on those choices
14 
15 `(ResidueField V)[[X]] -> AdicCompletion (maximalIdeal V) V`
16 
17 by evaluating the `n`-th truncation modulo the `n`-th power of the maximal
18 ideal.  This file constructs that map directly from the inverse-limit
19 coordinates and proves its coefficient and uniformizer formulas.
20 
21 No Cohen structure theorem is invoked.  In particular, an equivalence is
22 constructed only from a separately proved surjectivity statement.
23 -/
24 
25 namespace Stafford38.Geometry.CompletedDVRPowerSeries
26 
27 open IsLocalRing
28 open Stafford38.Geometry.AsymptoticDivisorExistence
29 open Stafford38.Geometry.CompletedDVRCoefficientSection
30 open Stafford38.Geometry.RelativeCoefficientDVR
31 open Stafford38.Geometry.RetainedDVR
32 
33 noncomputable section
34 
35 set_option maxHeartbeats 1200000
36 set_option synthInstance.maxHeartbeats 150000
37 
38 universe u
39 
40 section NilpotentEvaluation
41 
42 variable {K S : Type u} [CommRing K] [CommRing S]
43 
44 /-- Polynomials agreeing below degree `n` have the same value at an element
45 whose `n`-th power vanishes. -/
46 private theorem eval₂_eq_of_coeff_eq_of_pow_eq_zero
47     (c : K →+* S) (x : S) (n : ℕ) (hx : x ^ n = 0)
48     {p q : Polynomial K}
49     (hcoeff : ∀ d < n, p.coeff d = q.coeff d) :
50     Polynomial.eval₂ c x p = Polynomial.eval₂ c x q := by
51   have hdvd : (Polynomial.X : Polynomial K) ^ n ∣ p - q := by
52     rw [Polynomial.X_pow_dvd_iff]
53     intro d hd
54     simp [hcoeff d hd]
55   obtain ⟨r, hr⟩ := hdvd
56   have hzero : Polynomial.eval₂ c x (p - q) = 0 := by
57     rw [hr, Polynomial.eval₂_mul, Polynomial.eval₂_pow,
58       Polynomial.eval₂_X, hx, zero_mul]
59   rw [Polynomial.eval₂_sub, sub_eq_zero] at hzero
60   exact hzero
61 
62 /-- Evaluation of a power series at an `n`-nilpotent element, using its
63 degree-`< n` truncation. -/
64 def nilpotentPowerSeriesEval
65     (c : K →+* S) (x : S) (n : ℕ) (hx : x ^ n = 0) :
66     PowerSeries K →+* S where
67   toFun f := Polynomial.eval₂ c x (PowerSeries.trunc n f)
68   map_zero' := by simp
69   map_add' f g := by simp
70   map_one' := by
71     cases n with
72     | zero =>
73         have hsub : Subsingleton S := by
74           apply subsingleton_iff_zero_eq_one.mp
75           simpa using hx.symm
76         exact Subsingleton.elim _ _
77     | succ n => simp
78   map_mul' f g := by
79     rw [← Polynomial.eval₂_mul]
80     apply eval₂_eq_of_coeff_eq_of_pow_eq_zero c x n hx
81     intro d hd
82     rw [PowerSeries.coeff_trunc, if_pos hd]
83     calc
84       (PowerSeries.coeff d) (f * g) =
85           (PowerSeries.coeff d)
86             ((PowerSeries.trunc n f : PowerSeries K) *
87               (PowerSeries.trunc n g : PowerSeries K)) :=
88         PowerSeries.coeff_mul_eq_coeff_trunc_mul_trunc f g hd
89       _ = (PowerSeries.trunc n f * PowerSeries.trunc n g).coeff d := by
90         rw [← Polynomial.coe_mul]
91         exact Polynomial.coeff_coe
92           (PowerSeries.trunc n f * PowerSeries.trunc n g) d
93 
94 @[simp]
95 theorem nilpotentPowerSeriesEval_C
96     (c : K →+* S) (x : S) (n : ℕ) (hx : x ^ n = 0) (a : K) :
97     nilpotentPowerSeriesEval c x n hx (PowerSeries.C a) = c a := by
98   cases n with
99   | zero =>
100       have hone : (1 : S) = 0 := by simpa using hx
101       have hsub : Subsingleton S :=
102         subsingleton_iff_zero_eq_one.mp hone.symm
103       exact Subsingleton.elim _ _
104   | succ n => simp [nilpotentPowerSeriesEval]
105 
106 @[simp]
107 theorem nilpotentPowerSeriesEval_X
108     (c : K →+* S) (x : S) (n : ℕ) (hx : x ^ n = 0) :
109     nilpotentPowerSeriesEval c x n hx PowerSeries.X = x := by
110   cases n with
111   | zero =>
112       have hone : (1 : S) = 0 := by simpa using hx
113       have hsub : Subsingleton S :=
114         subsingleton_iff_zero_eq_one.mp hone.symm
115       exact Subsingleton.elim _ _
116   | succ n =>
117       cases n with
118       | zero =>
119           have hx0 : x = 0 := by simpa using hx
120           simp [nilpotentPowerSeriesEval, PowerSeries.trunc_one_X, hx0]
121       | succ n =>
122           simp [nilpotentPowerSeriesEval, PowerSeries.trunc_X_of]
123 
124 /-- Truncated evaluation is independent of a larger truncation once the
125 smaller nilpotence exponent has been reached. -/
126 private theorem nilpotentPowerSeriesEval_truncation_independent
127     (c : K →+* S) (x : S) {m n : ℕ} (hmn : m ≤ n)
128     (hx : x ^ m = 0) (f : PowerSeries K) :
129     Polynomial.eval₂ c x (PowerSeries.trunc n f) =
130       Polynomial.eval₂ c x (PowerSeries.trunc m f) := by
131   apply eval₂_eq_of_coeff_eq_of_pow_eq_zero c x m hx
132   intro d hd
133   rw [PowerSeries.coeff_trunc, if_pos (lt_of_lt_of_le hd hmn),
134     PowerSeries.coeff_trunc, if_pos hd]
135 
136 end NilpotentEvaluation
137 
138 section CompleteDVR
139 
140 variable (E V : Type u)
141 variable [Field E] [CommRing V] [IsDomain V] [IsLocalRing V]
142 variable [IsDiscreteValuationRing V] [Algebra E V]
143 
144 private abbrev K := ResidueField V
145 private abbrev m : Ideal V := maximalIdeal V
146 
147 /-- A fixed genuine uniformizer of the DVR. -/
148 def chosenUniformizer : V :=
149   Classical.choose (IsDiscreteValuationRing.exists_irreducible V)
150 
151 /-- The chosen element is irreducible. -/
152 theorem chosenUniformizer_irreducible :
153     Irreducible (chosenUniformizer V) :=
154   Classical.choose_spec (IsDiscreteValuationRing.exists_irreducible V)
155 
156 /-- Consequently the chosen element generates the maximal ideal. -/
157 theorem maximalIdeal_eq_span_chosenUniformizer :
158     maximalIdeal V = Ideal.span {chosenUniformizer V} :=
159   (chosenUniformizer_irreducible V).maximalIdeal_eq
160 
161 /-- The chosen uniformizer in the `n`-th raw completion coordinate. -/
162 def uniformizerCoordinate (n : ℕ) :
163     V ⧸ ((m V) ^ n • ⊤ : Ideal V) :=
164   Ideal.Quotient.mk _ (chosenUniformizer V)
165 
166 /-- Its `n`-th power vanishes in the `n`-th coordinate. -/
167 theorem uniformizerCoordinate_pow_eq_zero (n : ℕ) :
168     uniformizerCoordinate V n ^ n = 0 := by
169   rw [uniformizerCoordinate, ← map_pow, Ideal.Quotient.eq_zero_iff_mem]
170   simpa using Ideal.pow_mem_pow
171     (show chosenUniformizer V ∈ m V by
172       change chosenUniformizer V ∈ maximalIdeal V
173       rw [maximalIdeal_eq_span_chosenUniformizer V]
174       exact Ideal.mem_span_singleton_self _) n
175 
176 /-- Evaluation of a power series in one coordinate of the completed DVR. -/
177 def powerSeriesCoordinateMap
178     (hsep : Algebra.IsSeparable E (K V)) (n : ℕ) :
179     PowerSeries (K V) →+* V ⧸ ((m V) ^ n • ⊤ : Ideal V) :=
180   nilpotentPowerSeriesEval
181     (completionCoordinateSection E V hsep n).toRingHom
182     (uniformizerCoordinate V n) n
183     (uniformizerCoordinate_pow_eq_zero V n)
184 
185 /-- Coordinate maps commute with every inverse-limit transition. -/
186 theorem powerSeriesCoordinateMap_compatible
187     (hsep : Algebra.IsSeparable E (K V)) {a b : ℕ} (hab : a ≤ b)
188     (f : PowerSeries (K V)) :
189     AdicCompletion.transitionMap (m V) V hab
190         (powerSeriesCoordinateMap E V hsep b f) =
191       powerSeriesCoordinateMap E V hsep a f := by
192   let T := (AdicCompletion.transitionMapₐ (m V) hab).toRingHom
193   change T (Polynomial.eval₂
194       (completionCoordinateSection E V hsep b).toRingHom
195       (uniformizerCoordinate V b) (PowerSeries.trunc b f)) =
196     Polynomial.eval₂
197       (completionCoordinateSection E V hsep a).toRingHom
198       (uniformizerCoordinate V a) (PowerSeries.trunc a f)
199   rw [Polynomial.hom_eval₂]
200   have hc :
201       T.comp (completionCoordinateSection E V hsep b).toRingHom =
202         (completionCoordinateSection E V hsep a).toRingHom := by
203     ext z
204     exact completionCoordinateSection_compatible E V hsep hab z
205   have hx : T (uniformizerCoordinate V b) = uniformizerCoordinate V a := by
206     rfl
207   rw [hc, hx]
208   exact nilpotentPowerSeriesEval_truncation_independent
209     (completionCoordinateSection E V hsep a).toRingHom
210     (uniformizerCoordinate V a) hab
211     (uniformizerCoordinate_pow_eq_zero V a) f
212 
213 /-- The actual chosen-coordinate power-series map to the maximal-ideal adic
214 completion. -/
215 def completedDVRPowerSeriesMap
216     (hsep : Algebra.IsSeparable E (K V)) :
217     PowerSeries (K V) →+* AdicCompletion (m V) V where
218   toFun f :=
219     ⟨fun n ↦ powerSeriesCoordinateMap E V hsep n f,
220       fun hab ↦ powerSeriesCoordinateMap_compatible E V hsep hab f⟩
221   map_zero' := AdicCompletion.ext fun n ↦
222     (powerSeriesCoordinateMap E V hsep n).map_zero
223   map_one' := AdicCompletion.ext fun n ↦
224     (powerSeriesCoordinateMap E V hsep n).map_one
225   map_add' f g := AdicCompletion.ext fun n ↦
226     (powerSeriesCoordinateMap E V hsep n).map_add f g
227   map_mul' f g := AdicCompletion.ext fun n ↦
228     (powerSeriesCoordinateMap E V hsep n).map_mul f g
229 
230 /-- Evaluation of the completed map at coordinate `n` is its truncated
231 polynomial evaluation there. -/
232 theorem eval_completedDVRPowerSeriesMap
233     (hsep : Algebra.IsSeparable E (K V)) (n : ℕ)
234     (f : PowerSeries (K V)) :
235     (completedDVRPowerSeriesMap E V hsep f).val n =
236       powerSeriesCoordinateMap E V hsep n f :=
237   rfl
238 
239 /-- Constant series map to the completed residue-field section. -/
240 @[simp]
241 theorem completedDVRPowerSeriesMap_C
242     (hsep : Algebra.IsSeparable E (K V)) (a : K V) :
243     completedDVRPowerSeriesMap E V hsep (PowerSeries.C a) =
244       completedCoefficientSection E V hsep a := by
245   apply AdicCompletion.ext
246   intro n
247   exact nilpotentPowerSeriesEval_C
248     (completionCoordinateSection E V hsep n).toRingHom
249     (uniformizerCoordinate V n) n
250     (uniformizerCoordinate_pow_eq_zero V n) a
251 
252 /-- The series variable maps to the chosen uniformizer in every completion
253 coordinate. -/
254 @[simp]
255 theorem completedDVRPowerSeriesMap_X
256     (hsep : Algebra.IsSeparable E (K V)) :
257     completedDVRPowerSeriesMap E V hsep PowerSeries.X =
258       ⟨fun n ↦ uniformizerCoordinate V n,
259         fun hab ↦ by rfl⟩ := by
260   apply AdicCompletion.ext
261   intro n
262   exact nilpotentPowerSeriesEval_X
263     (completionCoordinateSection E V hsep n).toRingHom
264     (uniformizerCoordinate V n) n
265     (uniformizerCoordinate_pow_eq_zero V n)
266 
267 /-- A coefficient-section value cannot be killed by the matching power of
268 the uniformizer one level too early. -/
269 private theorem coefficient_eq_zero_of_mul_uniformizer_pow_eq_zero
270     (hsep : Algebra.IsSeparable E (K V)) (n : ℕ) (a : K V)
271     (hzero :
272       completionCoordinateSection E V hsep (n + 1) a *
273           uniformizerCoordinate V (n + 1) ^ n = 0) :
274     a = 0 := by
275   obtain ⟨v, hv⟩ := Ideal.Quotient.mk_surjective
276     (completionCoordinateSection E V hsep (n + 1) a)
277   have hmem : v * chosenUniformizer V ^ n ∈ (m V) ^ (n + 1) := by
278     have hraw :
279         Ideal.Quotient.mk ((m V) ^ (n + 1) • ⊤ : Ideal V)
280             (v * chosenUniformizer V ^ n) = 0 := by
281       rw [map_mul, map_pow, hv]
282       change completionCoordinateSection E V hsep (n + 1) a *
283           uniformizerCoordinate V (n + 1) ^ n = 0
284       exact hzero
285     rw [Ideal.Quotient.eq_zero_iff_mem] at hraw
286     simpa using hraw
287   have hpowspan :
288       (m V) ^ (n + 1) =
289         Ideal.span {chosenUniformizer V ^ (n + 1)} := by
290     change (maximalIdeal V) ^ (n + 1) = _
291     rw [maximalIdeal_eq_span_chosenUniformizer V,
292       Ideal.span_singleton_pow]
293   rw [hpowspan, Ideal.mem_span_singleton'] at hmem
294   obtain ⟨b, hb⟩ := hmem
295   have hvfactor : v = b * chosenUniformizer V := by
296     apply mul_right_cancel₀ (pow_ne_zero n
297       (chosenUniformizer_irreducible V).ne_zero)
298     calc
299       v * chosenUniformizer V ^ n =
300           b * chosenUniformizer V ^ (n + 1) := hb.symm
301       _ = (b * chosenUniformizer V) * chosenUniformizer V ^ n := by
302         rw [pow_succ']
303         ring
304   have hvmax : v ∈ maximalIdeal V := by
305     rw [maximalIdeal_eq_span_chosenUniformizer V,
306       Ideal.mem_span_singleton']
307     exact ⟨b, hvfactor.symm⟩
308   have hvres : residue V v = a := by
309     have hab : 1 ≤ n + 1 := Nat.succ_le_succ (Nat.zero_le n)
310     have hv1 := congrArg
311       (AdicCompletion.transitionMap (m V) V hab) hv
312     rw [AdicCompletion.transitionMap_ideal_mk,
313       completionCoordinateSection_compatible E V hsep hab a] at hv1
314     let rawResidue :
315         (V ⧸ ((m V) ^ 1 • ⊤ : Ideal V)) →+* K V :=
316       Ideal.Quotient.lift _ (residue V) (by
317         intro z hz
318         rw [residue_eq_zero_iff]
319         simpa using hz)
320     have hres := congrArg rawResidue hv1
321     change residue V v = rawResidue
322       (completionCoordinateSection E V hsep 1 a) at hres
323     rw [hres]
324     have ha := DFunLike.congr_fun
325       (adicJetResidue_comp_adicJetCoefficientSection E V hsep 0) a
326     change adicJetResidue E V 0
327         (adicJetCoefficientSection E V hsep 0 a) = a at ha
328     calc
329       rawResidue (completionCoordinateSection E V hsep 1 a) =
330           adicJetResidue E V 0
331             (adicJetCoefficientSection E V hsep 0 a) := by
332         simp only [rawResidue, completionCoordinateSection, adicJetResidue,
333           AlgHom.comp_apply, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk]
334         generalize hz : adicJetCoefficientSection E V hsep 0 a = z
335         obtain ⟨w, rfl⟩ := Ideal.Quotient.mk_surjective z
336         rfl
337       _ = a := ha
338   have hvzero : residue V v = 0 :=
339     (IsLocalRing.residue_eq_zero_iff v).mpr hvmax
340   rw [hvzero] at hvres
341   exact hvres.symm
342 
343 /-- If all earlier coefficients vanish, vanishing of coordinate `n+1`
344 forces the `n`-th coefficient to vanish. -/
345 private theorem coeff_eq_zero_of_coordinate_eq_zero
346     (hsep : Algebra.IsSeparable E (K V)) (f : PowerSeries (K V)) (n : ℕ)
347     (hprev : ∀ i < n, PowerSeries.coeff i f = 0)
348     (hcoord : powerSeriesCoordinateMap E V hsep (n + 1) f = 0) :
349     PowerSeries.coeff n f = 0 := by
350   have hsum :
351       ∑ i ∈ Finset.range (n + 1),
352           completionCoordinateSection E V hsep (n + 1)
353               (PowerSeries.coeff i f) *
354             uniformizerCoordinate V (n + 1) ^ i = 0 := by
355     simpa [powerSeriesCoordinateMap, nilpotentPowerSeriesEval,
356       PowerSeries.eval₂_trunc_eq_sum_range] using hcoord
357   have hsingle :
358       completionCoordinateSection E V hsep (n + 1)
359             (PowerSeries.coeff n f) *
360           uniformizerCoordinate V (n + 1) ^ n = 0 := by
361     rw [Finset.sum_eq_single n] at hsum
362     · exact hsum
363     · intro i hi hin
364       rw [Finset.mem_range] at hi
365       have hil : i < n := Nat.lt_of_le_of_ne
366         (Nat.le_of_lt_succ hi) hin
367       rw [hprev i hil, map_zero, zero_mul]
368     · simp
369   exact coefficient_eq_zero_of_mul_uniformizer_pow_eq_zero
370     E V hsep n _ hsingle
371 
372 /-- The chosen-coordinate map is injective.  The proof detects the first nonzero
373 coefficient in the quotient modulo the next uniformizer power. -/
374 theorem completedDVRPowerSeriesMap_injective
375     (hsep : Algebra.IsSeparable E (K V)) :
376     Function.Injective (completedDVRPowerSeriesMap E V hsep) := by
377   intro f g hfg
378   rw [← sub_eq_zero]
379   apply PowerSeries.ext
380   intro n
381   have hmap : completedDVRPowerSeriesMap E V hsep (f - g) = 0 := by
382     rw [map_sub, hfg, sub_self]
383   have hcoeff : ∀ r : ℕ,
384       PowerSeries.coeff r (f - g) = 0 := by
385     intro r
386     induction r using Nat.strong_induction_on with
387     | h r ih =>
388         apply coeff_eq_zero_of_coordinate_eq_zero E V hsep (f - g) r ih
389         have := congrArg (fun z ↦ z.val (r + 1)) hmap
390         change powerSeriesCoordinateMap E V hsep (r + 1) (f - g) = 0 at this
391         exact this
392   exact hcoeff n
393 
394 /-- The kernel of the transition from level `n + 1` to level `n` consists of
395 one residue-field coefficient times the `n`-th uniformizer power. -/
396 private theorem exists_coefficient_mul_uniformizer_pow_eq
397     (hsep : Algebra.IsSeparable E (K V)) (n : ℕ)
398     (y : V ⧸ ((m V) ^ (n + 1) • ⊤ : Ideal V))
399     (hy : AdicCompletion.transitionMap (m V) V (Nat.le_succ n) y = 0) :
400     ∃ a : K V,
401       y = completionCoordinateSection E V hsep (n + 1) a *
402         uniformizerCoordinate V (n + 1) ^ n := by
403   obtain ⟨v, rfl⟩ := Ideal.Quotient.mk_surjective y
404   have hvpow : v ∈ (m V) ^ n := by
405     rw [AdicCompletion.transitionMap_ideal_mk,
406       Ideal.Quotient.eq_zero_iff_mem] at hy
407     simpa using hy
408   have hpowspan :
409       (m V) ^ n = Ideal.span {chosenUniformizer V ^ n} := by
410     change (maximalIdeal V) ^ n = _
411     rw [maximalIdeal_eq_span_chosenUniformizer V,
412       Ideal.span_singleton_pow]
413   rw [hpowspan, Ideal.mem_span_singleton'] at hvpow
414   obtain ⟨c, rfl⟩ := hvpow
415   let a : K V := residue V c
416   obtain ⟨s, hs⟩ := Ideal.Quotient.mk_surjective
417     (completionCoordinateSection E V hsep (n + 1) a)
418   have hsres : residue V s = a := by
419     have hlevel : 1 ≤ n + 1 := Nat.succ_le_succ (Nat.zero_le n)
420     have hs1 := congrArg
421       (AdicCompletion.transitionMap (m V) V hlevel) hs
422     rw [AdicCompletion.transitionMap_ideal_mk,
423       completionCoordinateSection_compatible E V hsep hlevel a] at hs1
424     let rawResidue :
425         (V ⧸ ((m V) ^ 1 • ⊤ : Ideal V)) →+* K V :=
426       Ideal.Quotient.lift _ (residue V) (by
427         intro z hz
428         rw [residue_eq_zero_iff]
429         simpa using hz)
430     have hres := congrArg rawResidue hs1
431     change residue V s = rawResidue
432       (completionCoordinateSection E V hsep 1 a) at hres
433     rw [hres]
434     have ha := DFunLike.congr_fun
435       (adicJetResidue_comp_adicJetCoefficientSection E V hsep 0) a
436     change adicJetResidue E V 0
437         (adicJetCoefficientSection E V hsep 0 a) = a at ha
438     calc
439       rawResidue (completionCoordinateSection E V hsep 1 a) =
440           adicJetResidue E V 0
441             (adicJetCoefficientSection E V hsep 0 a) := by
442         simp only [rawResidue, completionCoordinateSection, adicJetResidue,
443           AlgHom.comp_apply, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk]
444         generalize hz : adicJetCoefficientSection E V hsep 0 a = z
445         obtain ⟨w, rfl⟩ := Ideal.Quotient.mk_surjective z
446         rfl
447       _ = a := ha
448   have hdiff : c - s ∈ m V := by
449     change c - s ∈ maximalIdeal V
450     rw [← residue_eq_zero_iff, map_sub, hsres]
451     exact sub_self a
452   refine ⟨a, ?_⟩
453   rw [← hs, map_mul, map_pow]
454   apply Ideal.Quotient.eq.mpr
455   change c * chosenUniformizer V ^ n -
456       s * chosenUniformizer V ^ n ∈ (m V) ^ (n + 1) • ⊤
457   have hpow : chosenUniformizer V ^ n ∈ (m V) ^ n :=
458     Ideal.pow_mem_pow
459       (show chosenUniformizer V ∈ m V by
460         change chosenUniformizer V ∈ maximalIdeal V
461         rw [maximalIdeal_eq_span_chosenUniformizer V]
462         exact Ideal.mem_span_singleton_self _) n
463   have hmul := Ideal.mul_mem_mul hdiff hpow
464   simpa [sub_mul, pow_succ, mul_comm] using hmul
465 
466 /-- Successive approximants matching one more adic coordinate at each step. -/
467 private noncomputable def powerSeriesApproximant
468     (hsep : Algebra.IsSeparable E (K V))
469     (z : AdicCompletion (m V) V) :
470     (n : ℕ) → { f : PowerSeries (K V) //
471       powerSeriesCoordinateMap E V hsep n f = z.val n }
472   | 0 => by
473       have htop : ((m V) ^ 0 • ⊤ : Ideal V) = ⊤ := by simp
474       letI : Subsingleton (V ⧸ ((m V) ^ 0 • ⊤ : Ideal V)) := by
475         rw [htop]
476         infer_instance
477       exact ⟨0, Subsingleton.elim _ _⟩
478   | n + 1 => by
479       let f := powerSeriesApproximant hsep z n
480       let y := z.val (n + 1) - powerSeriesCoordinateMap E V hsep (n + 1) f
481       have hy :
482           AdicCompletion.transitionMap (m V) V (Nat.le_succ n) y = 0 := by
483         change AdicCompletion.transitionMap (m V) V (Nat.le_succ n)
484             (z.val (n + 1) - powerSeriesCoordinateMap E V hsep (n + 1) f) = 0
485         rw [map_sub, z.property (Nat.le_succ n),
486           powerSeriesCoordinateMap_compatible E V hsep (Nat.le_succ n) f,
487           f.property, sub_self]
488       let a := Classical.choose
489         (exists_coefficient_mul_uniformizer_pow_eq E V hsep n y hy)
490       have ha := Classical.choose_spec
491         (exists_coefficient_mul_uniformizer_pow_eq E V hsep n y hy)
492       refine ⟨f.1 + PowerSeries.C a * PowerSeries.X ^ n, ?_⟩
493       change powerSeriesCoordinateMap E V hsep (n + 1)
494           (f.1 + PowerSeries.C a * PowerSeries.X ^ n) = z.val (n + 1)
495       rw [map_add, map_mul, map_pow]
496       have hC : powerSeriesCoordinateMap E V hsep (n + 1)
497           (PowerSeries.C a) =
498           completionCoordinateSection E V hsep (n + 1) a :=
499         nilpotentPowerSeriesEval_C
500           (completionCoordinateSection E V hsep (n + 1)).toRingHom
501           (uniformizerCoordinate V (n + 1)) (n + 1)
502           (uniformizerCoordinate_pow_eq_zero V (n + 1)) a
503       have hX : powerSeriesCoordinateMap E V hsep (n + 1) PowerSeries.X =
504           uniformizerCoordinate V (n + 1) :=
505         nilpotentPowerSeriesEval_X
506           (completionCoordinateSection E V hsep (n + 1)).toRingHom
507           (uniformizerCoordinate V (n + 1)) (n + 1)
508           (uniformizerCoordinate_pow_eq_zero V (n + 1))
509       rw [hC, hX]
510       rw [← ha]
511       change powerSeriesCoordinateMap E V hsep (n + 1) f +
512           (z.val (n + 1) - powerSeriesCoordinateMap E V hsep (n + 1) f) =
513         z.val (n + 1)
514       abel
515 
516 /-- Passing to the next approximant does not change any earlier coefficient. -/
517 private theorem powerSeriesApproximant_succ_coeff
518     (hsep : Algebra.IsSeparable E (K V))
519     (z : AdicCompletion (m V) V) (n i : ℕ) (hi : i < n) :
520     PowerSeries.coeff i (powerSeriesApproximant E V hsep z (n + 1)).1 =
521       PowerSeries.coeff i (powerSeriesApproximant E V hsep z n).1 := by
522   change PowerSeries.coeff i
523       ((powerSeriesApproximant E V hsep z n).1 +
524         PowerSeries.C _ * PowerSeries.X ^ n) = _
525   rw [map_add, PowerSeries.coeff_C_mul, PowerSeries.coeff_X_pow,
526     if_neg hi.ne, mul_zero, add_zero]
527 
528 /-- All coefficients below level `a` are stable in every later approximant. -/
529 private theorem powerSeriesApproximant_coeff_stable
530     (hsep : Algebra.IsSeparable E (K V))
531     (z : AdicCompletion (m V) V) {a b i : ℕ} (hab : a ≤ b) (hi : i < a) :
532     PowerSeries.coeff i (powerSeriesApproximant E V hsep z b).1 =
533       PowerSeries.coeff i (powerSeriesApproximant E V hsep z a).1 := by
534   induction b with
535   | zero =>
536       have ha : a = 0 := Nat.eq_zero_of_le_zero hab
537       subst a
538       omega
539   | succ b ih =>
540       by_cases hab' : a = b + 1
541       · subst a
542         rfl
543       · have hab0 : a ≤ b := Nat.le_of_lt_succ (lt_of_le_of_ne hab hab')
544         calc
545           PowerSeries.coeff i
546               (powerSeriesApproximant E V hsep z (b + 1)).1 =
547               PowerSeries.coeff i
548                 (powerSeriesApproximant E V hsep z b).1 :=
549             powerSeriesApproximant_succ_coeff E V hsep z b i
550               (lt_of_lt_of_le hi hab0)
551           _ = PowerSeries.coeff i
552                 (powerSeriesApproximant E V hsep z a).1 := ih hab0
553 
554 /-- The power series obtained by taking the stable coefficient at every
555 stage of the successive approximation. -/
556 private noncomputable def powerSeriesExpansion
557     (hsep : Algebra.IsSeparable E (K V))
558     (z : AdicCompletion (m V) V) : PowerSeries (K V) :=
559   PowerSeries.mk fun n ↦
560     PowerSeries.coeff n (powerSeriesApproximant E V hsep z (n + 1))
561 
562 /-- The assembled expansion has the same first `n` coefficients as the
563 `n`-th approximant. -/
564 private theorem powerSeriesExpansion_coeff_eq_approximant
565     (hsep : Algebra.IsSeparable E (K V))
566     (z : AdicCompletion (m V) V) {n i : ℕ} (hi : i < n) :
567     PowerSeries.coeff i (powerSeriesExpansion E V hsep z) =
568       PowerSeries.coeff i (powerSeriesApproximant E V hsep z n).1 := by
569   rw [powerSeriesExpansion, PowerSeries.coeff_mk]
570   exact (powerSeriesApproximant_coeff_stable E V hsep z
571     (a := i + 1) (b := n) (i := i)
572     (Nat.succ_le_iff.mpr hi) (Nat.lt_succ_self i)).symm
573 
574 /-- Every compatible adic family admits an expansion in the chosen
575 uniformizer with coefficients in the completed residue-field section. -/
576 def CompletedDVRPowerSeriesSurjectivity
577     (hsep : Algebra.IsSeparable E (K V)) : Prop :=
578   Function.Surjective (completedDVRPowerSeriesMap E V hsep)
579 
580 /-- Successive approximation supplies the expansion theorem. -/
581 theorem completedDVRPowerSeriesMap_surjective
582     (hsep : Algebra.IsSeparable E (K V)) :
583     CompletedDVRPowerSeriesSurjectivity E V hsep := by
584   intro z
585   refine ⟨powerSeriesExpansion E V hsep z, ?_⟩
586   apply AdicCompletion.ext
587   intro n
588   rw [eval_completedDVRPowerSeriesMap]
589   change Polynomial.eval₂
590       (completionCoordinateSection E V hsep n).toRingHom
591       (uniformizerCoordinate V n)
592       (PowerSeries.trunc n (powerSeriesExpansion E V hsep z)) = z.val n
593   calc
594     Polynomial.eval₂
595         (completionCoordinateSection E V hsep n).toRingHom
596         (uniformizerCoordinate V n)
597         (PowerSeries.trunc n (powerSeriesExpansion E V hsep z)) =
598       Polynomial.eval₂
599         (completionCoordinateSection E V hsep n).toRingHom
600         (uniformizerCoordinate V n)
601         (PowerSeries.trunc n (powerSeriesApproximant E V hsep z n)) := by
602           apply eval₂_eq_of_coeff_eq_of_pow_eq_zero
603             (completionCoordinateSection E V hsep n).toRingHom
604             (uniformizerCoordinate V n) n
605             (uniformizerCoordinate_pow_eq_zero V n)
606           intro d hd
607           rw [PowerSeries.coeff_trunc, if_pos hd,
608             PowerSeries.coeff_trunc, if_pos hd]
609           exact powerSeriesExpansion_coeff_eq_approximant E V hsep z hd
610     _ = powerSeriesCoordinateMap E V hsep n
611           (powerSeriesApproximant E V hsep z n) := rfl
612     _ = z.val n := (powerSeriesApproximant E V hsep z n).property
613 
614 /-- A supplied surjectivity proof turns the constructed map into the literal
615 power-series equivalence. -/
616 def completedDVRPowerSeriesEquivOfSurjective
617     (hsep : Algebra.IsSeparable E (K V))
618     (hsurj : CompletedDVRPowerSeriesSurjectivity E V hsep) :
619     PowerSeries (K V) ≃+* AdicCompletion (m V) V :=
620   RingEquiv.ofBijective (completedDVRPowerSeriesMap E V hsep)
621     ⟨completedDVRPowerSeriesMap_injective E V hsep, hsurj⟩
622 
623 end CompleteDVR
624 
625 section RetainedDVR
626 
627 private abbrev SourceDVR (E : Type u) [Field E] :=
628   CoordinateZeroLocalRing E
629 
630 /-- The chosen-coordinate power-series map for the retained DVR place. -/
631 def retainedCompletedDVRPowerSeriesMap
632     (E : Type u) [Field E] [CharZero E]
633     {L : Type u} [Field L] [Algebra (SourceDVR E) L]
634     {a : SourceDVR E}
635     (D : RetainedDVRPlace (SourceDVR E) (L := L) a) :
636     letI : IsDiscreteValuationRing D.valuation.toSubring := D.isDiscrete
637     letI : Algebra E D.valuation.toSubring :=
638       (relativeCoefficientMap E D).toAlgebra
639     PowerSeries (ResidueField D.valuation.toSubring) →+*
640       AdicCompletion (maximalIdeal D.valuation.toSubring)
641         D.valuation.toSubring := by
642   letI : IsDiscreteValuationRing D.valuation.toSubring := D.isDiscrete
643   letI : Algebra E D.valuation.toSubring :=
644     (relativeCoefficientMap E D).toAlgebra
645   exact completedDVRPowerSeriesMap E D.valuation.toSubring
646     (relativeResidue_isSeparable E D)
647 
648 /-- The retained completed-DVR power-series map is injective. -/
649 theorem retainedCompletedDVRPowerSeriesMap_injective
650     (E : Type u) [Field E] [CharZero E]
651     {L : Type u} [Field L] [Algebra (SourceDVR E) L]
652     {a : SourceDVR E}
653     (D : RetainedDVRPlace (SourceDVR E) (L := L) a) :
654     letI : IsDiscreteValuationRing D.valuation.toSubring := D.isDiscrete
655     letI : Algebra E D.valuation.toSubring :=
656       (relativeCoefficientMap E D).toAlgebra
657     Function.Injective (retainedCompletedDVRPowerSeriesMap E D) := by
658   letI : IsDiscreteValuationRing D.valuation.toSubring := D.isDiscrete
659   letI : Algebra E D.valuation.toSubring :=
660     (relativeCoefficientMap E D).toAlgebra
661   exact completedDVRPowerSeriesMap_injective E D.valuation.toSubring
662     (relativeResidue_isSeparable E D)
663 
664 end RetainedDVR
665 
666 #print axioms chosenUniformizer
667 #print axioms chosenUniformizer_irreducible
668 #print axioms maximalIdeal_eq_span_chosenUniformizer
669 #print axioms powerSeriesCoordinateMap
670 #print axioms powerSeriesCoordinateMap_compatible
671 #print axioms completedDVRPowerSeriesMap
672 #print axioms completedDVRPowerSeriesMap_C
673 #print axioms completedDVRPowerSeriesMap_X
674 #print axioms completedDVRPowerSeriesMap_injective
675 #print axioms CompletedDVRPowerSeriesSurjectivity
676 #print axioms completedDVRPowerSeriesMap_surjective
677 #print axioms completedDVRPowerSeriesEquivOfSurjective
678 #print axioms retainedCompletedDVRPowerSeriesMap
679 #print axioms retainedCompletedDVRPowerSeriesMap_injective
680 
681 end
682 
683 end Stafford38.Geometry.CompletedDVRPowerSeries
684