Lean sources / SurfaceBlowup / Blowup / DivisorPoints.lean

Exceptional divisor points of two-chart curve data

1461 lines · 10 public declarations · raw file · declaration index

1/-2Copyright (c) 2026 Asvin G, Claude (Anthropic), GPT-6-Astra (OpenAI). All rights reserved.3Released under Apache 2.0 license as described in the file LICENSE.4Authors: Asvin G, Claude (Anthropic), GPT-6-Astra (OpenAI)5-/6import SurfaceBlowup.Blowup.CurveSections7import SurfaceBlowup.Surfaces.ConcreteAtlas8 9/-!10# Exceptional divisor points of two-chart curve data11 12For the blow-up of a regular local surface at its closed point, this file relates two-chart curve13data (finitely many points of the two charts with local curve generators) to divisors on the14exceptional line `ℙ¹_k`. It computes level-one kernels as products of powers of irreducible15polynomials, shows that a curve datum matching a divisor `Dv` has degree `deg Dv`, constructs curve16data realizing prescribed child ideals, and proves that the glued global function lies in the fixed17tangent cell.18 19## Main results20 21* `SurfaceBlowup.level_one_kernel_polynomial`: the level-one kernel on a blow-up chart maps to the22  ideal of `k[X]` generated by a product of powers of distinct monic irreducibles;23  `SurfaceBlowup.two_chart_left_level_one_kernel_polynomial` specialises it to the left chart.24* `SurfaceBlowup.child_ideals_curve_datum`: prescribed child ideals are realized by a curve datum.25* `SurfaceBlowup.fixed_tangent_cell_curve_datum`: every ideal of the fixed tangent cell comes from26  a curve datum matching `Dv`.27* `SurfaceBlowup.matches_divisor_degree`: a curve datum matching `Dv` has degree `deg Dv`.28* `SurfaceBlowup.matches_divisor_level_one_polynomial`: its level-one left kernel is generated by29  the affine polynomial of `Dv`.30* `SurfaceBlowup.global_function_has_tangent_divisor`, `SurfaceBlowup.global_function_mem_cell`:31  the glued global function has tangent divisor `Dv` and lies in the fixed tangent cell.32 33## Implementation notes34 35Statements about the concrete surfaces `ConcreteSurface O pi u a b` are written with the local36notations `tChart`, `tExc`, ... for the blow-up charts and their data; see the notation section.37 38Provenance: `Thm_SurfaceBlowupV2_{boundary_contact_of_twisted_generator,39contracted_level_one_ideal_is_irreducible_power, two_chart_common_multiplicity_eq,40child_ideals_curve_datum, curve_datum_common_and_zero_clauses, curve_datum_matches_divisor,41matches_divisor_degree, fixed_tangent_cell_curve_datum, two_chart_left_level_one_kernel_polynomial,42matches_divisor_level_one_polynomial, global_function_has_tangent_divisor,43global_function_mem_cell}`.44-/45 46namespace SurfaceBlowup47 48open scoped BigOperators ENNReal49 50/-! ### Notation for the concrete surfaces51 52Local notations for the charts of the blow-up of `R = ConcreteSurface O pi u a b` at its53closed point `(t, x)`, taking the surface data as explicit arguments. -/54 55/-- The `t`-chart `R[x/t]` of the blow-up of the concrete surface at `(t, x)`. -/56local notation:max "tChart" O:max pi:max u:max a:max b:max =>57  BlowupChart (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)58 59/-- The structure map `R → R[x/t]`. -/60local notation:max "tBase" O:max pi:max u:max a:max b:max =>61  chartBase (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)62 63/-- The slope `x/t` in the `t`-chart. -/64local notation:max "tSlope" O:max pi:max u:max a:max b:max =>65  chartSlope (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)66 67/-- The exceptional ideal `(t)` of the `t`-chart. -/68local notation:max "tExc" O:max pi:max u:max a:max b:max =>69  chartExceptional (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)70 71/-- The overlap of the two charts. -/72local notation:max "tOverlap" O:max pi:max u:max a:max b:max =>73  BlowupOverlap (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)74 75/-- The `x`-chart `R[t/x]` of the blow-up of the concrete surface at `(t, x)`. -/76local notation:max "xChart" O:max pi:max u:max a:max b:max =>77  BlowupChart (ConcreteSurface O pi u a b) (surfaceX O pi u a b) (surfaceT O pi u a b)78 79/-- The structure map `R → R[t/x]`. -/80local notation:max "xBase" O:max pi:max u:max a:max b:max =>81  chartBase (ConcreteSurface O pi u a b) (surfaceX O pi u a b) (surfaceT O pi u a b)82 83/-- The slope `t/x` in the `x`-chart. -/84local notation:max "xSlope" O:max pi:max u:max a:max b:max =>85  chartSlope (ConcreteSurface O pi u a b) (surfaceX O pi u a b) (surfaceT O pi u a b)86 87/-- The exceptional ideal `(x)` of the `x`-chart. -/88local notation:max "xExc" O:max pi:max u:max a:max b:max =>89  chartExceptional (ConcreteSurface O pi u a b) (surfaceX O pi u a b) (surfaceT O pi u a b)90 91/-- If `f ≡ g` modulo the ideal `I`, then `(f) + I = I + (g)`. -/92private theorem span_sup_eq_sup_span {A : Type} [CommRing A] {I : Ideal A} {f g : A}93    (h : f - g ∈ I) : Ideal.span {f} ⊔ I = I ⊔ Ideal.span {g} := by94  refine le_antisymm (sup_le ?_ le_sup_left) (sup_le le_sup_right ?_) <;>95    rw [Ideal.span_singleton_le_iff_mem]96  · rw [← sub_add_cancel f g]97    exact add_mem (Ideal.mem_sup_left h) (Ideal.mem_sup_right (Ideal.mem_span_singleton_self g))98  · rw [← sub_sub_cancel f g]99    exact sub_mem (Ideal.mem_sup_left (Ideal.mem_span_singleton_self f)) (Ideal.mem_sup_right h)100 101/-- If `f = ∑ cᵢ t^(d-i) xⁱ`, then in the chart `R[t/x]` the function `f` factors as102`x^d · ∑ cᵢ (t/x)^(d-i)`, and the boundary contact of `f` with `t = 0` is `d` plus the contact103of the strict transform with the slope divisor. -/104theorem boundary_contact_of_twisted_generator (R : Type) [CommRing R] (t x : R)105    [(Ideal.span ({t,x} : Set R)).IsMaximal] (hreg : RegularParameterPair R t x) (d : ℕ) (f : R)106    (c : Fin (d + 1) → R) (hc : f = ∑ i : Fin (d + 1), c i * t ^ (d - i.val) * x ^ i.val) :107    algebraMap R (BlowupChart R x t) f = (chartBase R x t x)^d *108        ∑ i : Fin (d+1), algebraMap R (BlowupChart R x t) (c i) * (chartSlope R x t)^(d - i.val) ∧109      Module.length R (R ⧸ (Ideal.span {f} ⊔ Ideal.span {t})) = (d : ℕ∞) +110        Module.length (BlowupChart R x t) (BlowupChart R x t ⧸111          (Ideal.span {∑ i : Fin (d+1), algebraMap R (BlowupChart R x t) (c i) *112            (chartSlope R x t)^(d - i.val)} ⊔ Ideal.span {chartSlope R x t})) := by113  have hal : ∀ r : R, algebraMap R (BlowupChart R x t) r = chartBase R x t r := fun _ ↦ rfl114  set B := BlowupChart R x t115  set W := chartSlope R x t116  set g : B := ∑ i : Fin (d+1), algebraMap R B (c i) * W^(d - i.val) with hg117  refine ⟨?_, ?_⟩118  · rw [hc, map_sum, Finset.mul_sum]119    refine Finset.sum_congr rfl fun i _ ↦ ?_120    simp only [map_mul, map_pow, hal, ← blowup_chart_relation R x t]121    rw [← pow_mul_pow_sub _ (Nat.le_of_lt_succ i.isLt), hal]122    ring123  set I : Ideal R := Ideal.span {t}124  have hfI : f - c (Fin.last d) * x ^ d ∈ I := by125    rw [hc, Fin.sum_univ_castSucc]126    simp only [Fin.val_last, Nat.sub_self, pow_zero, mul_one, add_sub_cancel_right]127    exact Ideal.sum_mem _ fun i _ ↦ Ideal.mul_mem_right _ _ (Ideal.mul_mem_left _ _128      (Ideal.pow_mem_of_mem _ (Ideal.mem_span_singleton_self t) _ (Nat.sub_pos_of_lt i.isLt)))129  have hx (y) (hy : x * y ∈ I) : y ∈ I := by130    rw [← Ideal.Quotient.eq_zero_iff_mem] at hy ⊢131    apply hreg.2132    simpa using hy133  have hxd (n : ℕ) : ∀ y, x ^ n * y ∈ I → y ∈ I := by134    induction n with135    | zero => simp136    | succ n ih => exact fun y hy ↦ hx _ (ih _ (by rwa [pow_succ, mul_assoc] at hy))137  have hone : Module.length R (R ⧸ (I ⊔ Ideal.span {x})) = 1 := by138    rw [← Ideal.span_insert t {x}]139    have : IsSimpleModule R (R ⧸ Ideal.span ({t, x} : Set R)) :=140      isSimpleModule_iff_quot_maximal.mpr ⟨_, inferInstance, ⟨LinearEquiv.refl _ _⟩⟩141    exact Module.length_eq_one R _142  rw [span_sup_eq_sup_span hfI, length_quotient_sup_mul_eq_add R I (x ^ d) (c (Fin.last d)) (hxd d),143    length_quotient_sup_pow_eq_mul R I x hx d, hone, mul_one, add_comm]144  congr 1145  have hgW : g - algebraMap R B (c (Fin.last d)) ∈ Ideal.span {W} := by146    rw [hg, Fin.sum_univ_castSucc]147    simp only [Fin.val_last, Nat.sub_self, pow_zero, mul_one, add_sub_cancel_right]148    exact Ideal.sum_mem _ fun i _ ↦ Ideal.mul_mem_left _ _149      (Ideal.pow_mem_of_mem _ (Ideal.mem_span_singleton_self W) _ (Nat.sub_pos_of_lt i.isLt))150  rw [span_sup_eq_sup_span hgW]151  obtain ⟨ρ, hρ, -⟩ := boundary_chart_quotient_equiv R t x152  symm153  apply quotient_ring_length_intrinsic154  refine (DoubleQuot.quotQuotEquivQuotSup _ _).symm.trans155    ((Ideal.quotientEquiv _ _ ρ ?_).trans (DoubleQuot.quotQuotEquivQuotSup _ _))156  simp only [Ideal.map_span, Set.image_singleton]157  congr 2158  exact (hρ _).symm159 160/-- At a point `P` of the exceptional line corresponding to the irreducible `φ`, the image of the161contracted level-one curve ideal in `k[X]` is `(φ^r)`, where `r ≤ L` is the length of the162completed level-one quotient. -/163private theorem contracted_level_one_ideal_is_irreducible_power (R : Type) [CommRing R] (t x : R)164    [(Ideal.span ({t,x} : Set R)).IsMaximal] [IsNoetherianRing (BlowupChart R t x)]165    (e : (BlowupChart R t x ⧸ chartExceptional R t x) ≃+*166      Polynomial (R ⧸ Ideal.span ({t,x} : Set R)))167    (P : Ideal (BlowupChart R t x)) [P.IsMaximal]168    (φ : Polynomial (R ⧸ Ideal.span ({t,x} : Set R)))169    (hφ : (P.map (Ideal.Quotient.mk (chartExceptional R t x))).map e = Ideal.span {φ})170    (hirr : Irreducible φ) (g : CompletedLocalAt (BlowupChart R t x) P) (L : ℕ)171    (hL : ((IsLocalRing.maximalIdeal (Localization.AtPrime P)).map172      (localCompletionMap (Localization.AtPrime P))) ^ L ≤ finiteLocalCurveIdeal (BlowupChart R t x)173      P (chartBase R t x t) g 1) :174    ∃ r : ℕ, r ≤ L ∧175        ((contractedLocalCurveIdeal (BlowupChart R t x) P (chartBase R t x t) g 1).map176        (Ideal.Quotient.mk (chartExceptional R t x))).map e = Ideal.span {φ^r} ∧177        Module.length (CompletedLocalAt (BlowupChart R t x) P) (CompletedLocalAt (BlowupChart R t x)178        P ⧸ finiteLocalCurveIdeal (BlowupChart R t x) P (chartBase R t x t) g 1) = (r : ℕ∞) := by179  set A := BlowupChart R t x180  set I := finiteLocalCurveIdeal A P (chartBase R t x t) g 1 with hIdef181  set J := contractedLocalCurveIdeal A P (chartBase R t x t) g 1 with hJdef182  have hPL : P ^ L ≤ J := completed_point_power_contraction A P L I hL183  have hTJ : chartExceptional R t x ≤ J := by184    rw [show chartExceptional R t x = Ideal.span {chartBase R t x t} from rfl, Ideal.span_le]185    rintro _ rfl186    change completedPointMap A P (chartBase R t x t) ∈ I187    rw [hIdef, finiteLocalCurveIdeal, pow_one]188    exact Ideal.subset_span (by simp)189  have hle : Ideal.span {φ ^ L} ≤ (J.map (Ideal.Quotient.mk (chartExceptional R t x))).map e := by190    have h1 := Ideal.map_pow e (Ideal.map (Ideal.Quotient.mk (chartExceptional R t x)) P) L191    have h0 := Ideal.map_pow (Ideal.Quotient.mk (chartExceptional R t x)) P L192    rw [← Ideal.span_singleton_pow, ← hφ, ← h1, ← h0]193    exact Ideal.map_mono (Ideal.map_mono hPL)194  have hK : RingHom.ker ((Ideal.Quotient.mk I).comp (completedPointMap A P)) = J := by195    rw [← RingHom.comap_ker, Ideal.mk_ker]; rfl196  have E1 : (A ⧸ J) ≃+* (CompletedLocalAt A P ⧸ I) :=197    (Ideal.quotEquivOfEq hK.symm).trans (RingHom.quotientKerEquivOfSurjective198      (finite_completed_point_quotient_surjective A P L I hL))199  have hlen := quotient_ring_length_intrinsic _ _ _ _ E1200  obtain ⟨r, hrL, hr⟩ : ∃ r ≤ L,201      (J.map (Ideal.Quotient.mk (chartExceptional R t x))).map e = Ideal.span {φ ^ r} := by202    let _ := Ideal.Quotient.field (Ideal.span ({t,x} : Set R))203    exact polynomial_ideal_of_irreducible_pow_le _ φ hirr _ L hle204  have hφ : Module.length (Polynomial (R ⧸ Ideal.span ({t,x} : Set R)))205      (Polynomial (R ⧸ Ideal.span ({t,x} : Set R)) ⧸ Ideal.span {φ ^ r}) = r := by206    let _ := Ideal.Quotient.field (Ideal.span ({t,x} : Set R))207    exact (polynomial_quotient_irreducible_pow_length _ φ hirr r).1208  refine ⟨r, hrL, hr, ?_⟩209  rw [← hlen, ← hφ]210  exact quotient_ring_length_intrinsic _ _ _ _211    ((DoubleQuot.quotQuotEquivQuotOfLE hTJ).symm.trans (Ideal.quotientEquiv _ _ e hr.symm))212 213private theorem length_quot_span_pair_toNat_eq {S S' : Type} [CommRing S] [CommRing S']214    (Φ : S ≃+* S') (g e : S) (g' e' : S')215    (hg : Φ g = g') (he : Ideal.span {Φ e} = Ideal.span {e'}) :216    (Module.length S (S ⧸ Ideal.span {g, e ^ 1})).toNat =217      (Module.length S' (S' ⧸ Ideal.span {g', e' ^ 1})).toNat := by218  rw [pow_one, pow_one]219  have h : Ideal.span {g', e'} = (Ideal.span {g, e}).map Φ := by220    rw [Ideal.map_span, Set.image_pair, hg, Ideal.span_insert, Ideal.span_insert, he]221  rw [quotient_ring_length_intrinsic S S' (Ideal.span {g, e}) (Ideal.span {g', e'})222    (Ideal.quotientEquiv _ _ Φ h)]223 224/-- At a common point of the two charts, the left and right multiplicities agree with the225multiplicity computed on the overlap. -/226theorem two_chart_common_multiplicity_eq (R : Type) [CommRing R] (t x : R)227    (beta : BlowupRestriction R t x) (D : TwoChartCurveData R t x beta) (i : D.ι) :228    leftMultiplicity D (Sum.inl i) = commonMultiplicity D i ∧229      rightMultiplicity D (Sum.inl i) = commonMultiplicity D i := by230  constructor231  · unfold leftMultiplicity commonMultiplicity leftLevelIdeal commonLevelIdeal finiteLocalCurveIdeal232    symm233    refine length_quot_span_pair_toNat_eq (D.leftIso i) _ _ _ _ rfl ?_234    have := D.leftIso_compat i (chartBase R t x t)235    unfold overlapException236    rw [this]; rfl237  · unfold rightMultiplicity commonMultiplicity rightLevelIdeal commonLevelIdeal238      finiteLocalCurveIdeal239    symm240    refine length_quot_span_pair_toNat_eq (D.rightIso i) _ _ _ _ rfl ?_241    have hx := D.rightIso_compat i (chartBase R x t x)242    have hrel : beta.right (chartBase R x t x) = overlapException R t x * overlapSlope R t x := by243      have h1 : beta.right (chartBase R x t x) = algebraMap R (BlowupOverlap R t x) x :=244        beta.right.commutes x245      have h2 := congrArg (algebraMap (BlowupChart R t x) (BlowupOverlap R t x))246        (blowup_chart_relation R t x)247      rw [h1]248      unfold overlapException overlapSlope249      rw [← map_mul, h2]250      exact (IsScalarTower.algebraMap_apply R (BlowupChart R t x) (BlowupOverlap R t x) x).symm251    have hu : IsUnit (overlapSlope R t x) := IsLocalization.Away.algebraMap_isUnit _252    have hu' : IsUnit (D.rightIso i253        (completedPointMap (BlowupOverlap R t x) (D.Q i) (overlapSlope R t x))) :=254      (hu.map _).map _255    rw [hrel, map_mul, map_mul] at hx256    refine Eq.trans ?_ (congrArg Ideal.span (congrArg _ hx))257    exact Ideal.span_singleton_mul_right_unit hu' _ |>.symm258 259private noncomputable def completedLocalCast {A : Type} [CommRing A] {P' P : Ideal A} [P'.IsPrime]260    [P.IsPrime] (h : P' = P) :261    CompletedLocalAt A P' ≃+* CompletedLocalAt A P := by262  subst h; exact RingEquiv.refl _263 264private theorem completedLocalCast_completedPointMap {A : Type} [CommRing A] {P' P : Ideal A}265    [P'.IsPrime] [P.IsPrime] (h : P' = P) (a : A) :266    completedLocalCast h (completedPointMap A P' a) = completedPointMap A P a := by267  subst h; rfl268 269private theorem length_finiteLocalCurveIdeal_transport {A S : Type} [CommRing A] [CommRing S]270    {P' P : Ideal A} [P'.IsPrime] [P.IsPrime]271    (Φ : S ≃+* CompletedLocalAt A P') (h : P' = P) (gC : CompletedLocalAt A P) (e0 : A) (n : ℕ∞)272    (hl : Module.length (CompletedLocalAt A P) (CompletedLocalAt A P ⧸273      (Ideal.span {gC} ⊔ Ideal.span {completedPointMap A P e0})) = n) :274    Module.length (CompletedLocalAt A P') (CompletedLocalAt A P' ⧸275      finiteLocalCurveIdeal A P' e0 (Φ ((Φ.trans (completedLocalCast h)).symm gC)) 1) = n := by276  rw [RingEquiv.symm_trans_apply, RingEquiv.apply_symm_apply]277  subst h278  rw [finiteLocalCurveIdeal, pow_one, Ideal.span_insert]279  exact hl280 281private theorem strictTransformAt_transport (R : Type) [CommRing R] (t x : R)282    {S : Type} [CommRing S]283    {P' P : Ideal (BlowupChart R t x)} [P'.IsPrime] [P.IsPrime]284    (Φ : S ≃+* CompletedLocalAt (BlowupChart R t x) P') (h : P' = P)285    (gC : CompletedLocalAt (BlowupChart R t x) P) (d : ℕ) (J : Ideal R)286    (hs : strictTransformAt R t x P' d J =287        Ideal.span {Φ ((Φ.trans (completedLocalCast h)).symm gC)}) :288    strictTransformAt R t x P d J = Ideal.span {gC} := by289  rw [RingEquiv.symm_trans_apply, RingEquiv.apply_symm_apply] at hs290  subst h291  exact hs292 293private theorem length_finiteLocalCurveIdeal_toNat {A : Type} [CommRing A] {P : Ideal A} [P.IsPrime]294    (g : CompletedLocalAt A P) (e0 : A) (n : ℕ)295    (hl : Module.length (CompletedLocalAt A P) (CompletedLocalAt A P ⧸296      (Ideal.span {g} ⊔ Ideal.span {completedPointMap A P e0})) = n) :297    n = (Module.length (CompletedLocalAt A P) (CompletedLocalAt A P ⧸298      finiteLocalCurveIdeal A P e0 g 1)).toNat := by299  rw [finiteLocalCurveIdeal, pow_one, Ideal.span_insert, hl, ENat.toNat_natCast]300 301/-- At the prime `P` of `A`, every element `g` of the completed local ring such that `(g, z)` has302finite colength `n` is transverse to `z` (multiplication by `z` is injective modulo `g`), and the303ideal `(g, z)` contains a power of the maximal ideal. -/304private def TransverseFiniteAt (A : Type) [CommRing A] (P : Ideal A) [P.IsPrime] (z : A) : Prop :=305  ∀ (g : CompletedLocalAt A P) (n : ℕ),306    Module.length (CompletedLocalAt A P) (CompletedLocalAt A P ⧸307      (Ideal.span {g} ⊔ Ideal.span {completedPointMap A P z})) = n →308    Function.Injective (fun w : CompletedLocalAt A P ⧸ Ideal.span {g} =>309      Ideal.Quotient.mk (Ideal.span {g}) (completedPointMap A P z) * w) ∧310    ∃ L : ℕ, ((IsLocalRing.maximalIdeal (Localization.AtPrime P)).map311      (localCompletionMap (Localization.AtPrime P)))^L ≤ finiteLocalCurveIdeal A P z g 1312 313/-- The nonzero affine directions in the support of the divisor `Dv`. -/314private abbrev CommonDirections {k : Type} [Field k] (Dv : ExceptionalDivisor k) : Type :=315  {φ : AffineDirection k // φ ≠ zeroAffine k ∧ 0 < Dv (some φ)}316 317/-- The overlap point of a nonzero direction (a named function, so that the instance arguments318in the curve datum built below stay syntactically uniform). -/319private noncomputable def commonPoint (R : Type) [CommRing R] [IsLocalRing R] (t x : R)320    (e : (BlowupChart R t x ⧸ chartExceptional R t x) ≃+* Polynomial (IsLocalRing.ResidueField R))321    {Dv : ExceptionalDivisor (IsLocalRing.ResidueField R)} (i : CommonDirections Dv) :322    Ideal (BlowupOverlap R t x) :=323  (directionPoint R t x e i.1).map (algebraMap (BlowupChart R t x) (BlowupOverlap R t x))324 325/-- Generic form of `child_ideals_curve_datum`: the points of the exceptional line are assumed to326have the expected properties, and child-ideal generators are assumed transverse and finite. -/327private theorem child_ideals_curve_datum_of_points (R : Type) [CommRing R] [IsLocalRing R] (t x : R)328    [IsNoetherianRing (BlowupChart R t x)] [IsNoetherianRing (BlowupChart R x t)]329    (e : (BlowupChart R t x ⧸ chartExceptional R t x) ≃+* Polynomial (IsLocalRing.ResidueField R))330    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField R)) (hinf : (infinityPoint R t x).IsPrime)331    (s : State) (d : ℕ) (beta : BlowupRestriction R t x)332    (I : ∀ Q : divisorSupport Dv, Ideal (divisorLocalRing R t x e Dv hinf Q))333    (hI : ∀ Q : divisorSupport Dv, I Q ∈ childIdealSet R t x e Dv hinf s d Q)334    (hdir : ∀ φ, (directionPoint R t x e φ).IsMaximal ∧335      chartBase R t x t ∈ directionPoint R t x e φ ∧336      (chartSlope R t x ∈ directionPoint R t x e φ ↔ φ = zeroAffine (IsLocalRing.ResidueField R)))337    (hinj : Function.Injective (directionPoint R t x e))338    (hover : ∀ φ, φ ≠ zeroAffine (IsLocalRing.ResidueField R) →339      ((directionPoint R t x e φ).map340        (algebraMap (BlowupChart R t x) (BlowupOverlap R t x))).IsMaximal ∧341      ((directionPoint R t x e φ).map (algebraMap (BlowupChart R t x) (BlowupOverlap R t x))).comap342        (algebraMap (BlowupChart R t x) (BlowupOverlap R t x)) = directionPoint R t x e φ)343    (hinfmax : (infinityPoint R t x).IsMaximal ∧ chartBase R x t x ∈ infinityPoint R t x ∧344      chartSlope R x t ∈ infinityPoint R t x)345    (htrL : ∀ (P : Ideal (BlowupChart R t x)) [P.IsMaximal], chartBase R t x t ∈ P →346      TransverseFiniteAt (BlowupChart R t x) P (chartBase R t x t))347    (htrR : ∀ (P : Ideal (BlowupChart R x t)) [P.IsMaximal], chartBase R x t x ∈ P →348      chartSlope R x t ∈ P → TransverseFiniteAt (BlowupChart R x t) P (chartBase R x t x)) :349    ∃ D : TwoChartCurveData R t x beta, MatchesDivisor e D Dv ∧ ∀ f : R,350      (∀ s : D.ι ⊕ D.ι0, strictTransformAt R t x (leftPoint D s) d (Ideal.span {f}) =351          Ideal.span {leftData D s}) →352      (∀ s : D.ι ⊕ D.ιinf, strictTransformAt R x t (rightPoint D s) d (Ideal.span {f}) =353          Ideal.span {rightData D s}) →354      ∀ Q : divisorSupport Dv, divisorStrictTransform R t x e Dv hinf355          d (Ideal.span {f}) Q = I Q := by356  set k := IsLocalRing.ResidueField R357  set alpha := algebraMap (BlowupChart R t x) (BlowupOverlap R t x)358  choose gen hgen using fun Q ↦ (hI Q).1359  have hlen : ∀ Q : divisorSupport Dv, Module.length (divisorLocalRing R t x e Dv hinf Q)360      (divisorLocalRing R t x e Dv hinf Q ⧸ (Ideal.span {gen Q} ⊔361        Ideal.span {divisorException R t x e Dv hinf Q})) = (Dv Q.val : ℕ∞) :=362    fun Q ↦ hgen Q ▸ (hI Q).2.1363  have hQmax : ∀ i : CommonDirections Dv, (commonPoint R t x e i).IsMaximal :=364    fun i ↦ (hover i.1 i.2.1).1365  have hcomap (i : CommonDirections Dv) : (commonPoint R t x e i).comap alpha =366      directionPoint R t x e i.1 := (hover i.1 i.2.1).2367  have hinfM : (infinityPoint R t x).IsMaximal := hinfmax.1368  have hdirM : ∀ φ, (directionPoint R t x e φ).IsMaximal := fun φ ↦ (hdir φ).1369  have := divisorSupport_finite Dv370  choose Φ hΦ using fun i : CommonDirections Dv ↦371    completed_point_transport_left R t x (commonPoint R t x e i)372  choose Ψ hΨ using fun i : CommonDirections Dv ↦373    completed_point_transport_right R t x beta (commonPoint R t x e i)374  -- `Θ i` identifies the completion at the overlap point `i` with the one at the chart point375  let Θ (i : CommonDirections Dv) := (Φ i).trans (completedLocalCast (hcomap i))376  have hΘ (i : CommonDirections Dv) (a) : Θ i (completedPointMap _ _ (alpha a)) =377      completedPointMap (BlowupChart R t x) (directionPoint R t x e i.1) a := by378    rw [RingEquiv.trans_apply, hΦ i a, completedLocalCast_completedPointMap]379  let gC (i : CommonDirections Dv) : CompletedLocalAt _ (directionPoint R t x e i.1) :=380    gen ⟨some i.1, i.2.2⟩381  have htrC (i : CommonDirections Dv) := @htrL (directionPoint R t x e i.1) (hdirM _)382    (hdir i.1).2.1 (gC i) _ (hlen ⟨some i.1, i.2.2⟩)383  have htr0 (l : {_u : Unit // 0 < Dv (zeroDirection k)}) := @htrL _ (hdirM (zeroAffine k))384    (hdir _).2.1 (gen ⟨zeroDirection k, l.2⟩) _ (hlen ⟨zeroDirection k, l.2⟩)385  have htrI (l : {_u : Unit // 0 < Dv none}) := @htrR (infinityPoint R t x) hinfM hinfmax.2.1386    hinfmax.2.2 (gen ⟨none, l.2⟩) _ (hlen ⟨none, l.2⟩)387  have he (i : CommonDirections Dv) : (Θ i).symm (completedPointMap _ _ (chartBase R t x t)) * 1 =388      completedPointMap _ (commonPoint R t x e i) (overlapException R t x) := by389    rw [mul_one, RingEquiv.symm_apply_eq]; exact (hΘ i _).symm390  have hM (i : CommonDirections Dv) :391      (IsLocalRing.maximalIdeal (Localization.AtPrime (commonPoint R t x e i))).map392        (localCompletionMap _) ≤393      ((IsLocalRing.maximalIdeal (Localization.AtPrime (directionPoint R t x e i.1))).map394        (localCompletionMap _)).map (Θ i).symm := by395    rw [Ideal.map_symm, ← Ideal.map_le_iff_le_comap,396      map_maximalIdeal_localCompletion (commonPoint R t x e i)]397    exact (map_maximalIdeal_localCompletion_transport alpha _ _ (Θ i) (hΘ i)).le398  let D : TwoChartCurveData R t x beta :=399    { ι := CommonDirections Dv400      fin := Finite.of_injective (β := divisorSupport Dv) (fun i ↦ ⟨some i.1, i.2.2⟩)401          fun i j h ↦ Subtype.ext (Option.some_injective _ (congrArg Subtype.val h))402      Q := commonPoint R t x e403      maximal := hQmax404      inj := fun i j h ↦ Subtype.ext <| hinj <|405        (hcomap i).symm.trans <| (congrArg (Ideal.comap alpha) h).trans (hcomap j)406      onE := fun i ↦ Ideal.mem_map_of_mem _ (hdir i.1).2.1407      g := fun i ↦ (Θ i).symm (gC i)408      transverse := fun i ↦ mul_injective_quotient_transport _ isUnit_one (he i) (htrC i).1409      finite := fun i ↦ exists_pow_le_span_pair_transport _ isUnit_one (he i) (hM i) (htrC i).2 1410      leftIso := Φ411      leftIso_compat := hΦ412      rightIso := Ψ413      rightIso_compat := hΨ414      ι0 := {_u : Unit // 0 < Dv (zeroDirection k)}415      P0 := fun _ ↦ directionPoint R t x e (zeroAffine k)416      maximal0 := fun _ ↦ hdirM _417      inj0 := fun a b _ ↦ Subsingleton.elim a b418      slope0 := fun _ ↦ ((hdir _).2.2).2 rfl419      onE0 := fun _ ↦ (hdir _).2.1420      g0 := fun l ↦ gen ⟨zeroDirection k, l.2⟩421      transverse0 := fun l ↦ (htr0 l).1422      finite0 := fun l ↦ (htr0 l).2423      ιinf := {_u : Unit // 0 < Dv none}424      Pinf := fun _ ↦ infinityPoint R t x425      maximalinf := fun _ ↦ hinfM426      injinf := fun a b _ ↦ Subsingleton.elim a b427      slopeinf := fun _ ↦ hinfmax.2.2428      onEinf := fun _ ↦ hinfmax.2.1429      ginf := fun l ↦ gen ⟨none, l.2⟩430      transverseinf := fun l ↦ (htrI l).1431      finiteinf := fun l ↦ (htrI l).2 }432  refine ⟨D, ⟨fun i ↦ ⟨i.1, i.2.1, rfl, ?_⟩, fun φ hφ hpos ↦ ⟨⟨φ, hφ, hpos⟩, rfl⟩,433    fun l ↦ ⟨rfl, length_finiteLocalCurveIdeal_toNat (P := directionPoint R t x e (zeroAffine k))434      _ _ _ (hlen ⟨zeroDirection k, l.2⟩)⟩, fun h ↦ ⟨⟨(), h⟩⟩,435    fun l ↦ ⟨rfl, length_finiteLocalCurveIdeal_toNat (P := infinityPoint R t x) _ _ _436      (hlen ⟨none, l.2⟩)⟩, fun h ↦ ⟨⟨(), h⟩⟩⟩, fun f hL hR ↦ ?_⟩437  · rw [← (two_chart_common_multiplicity_eq R t x beta D i).1]438    exact ((congrArg ENat.toNat (length_finiteLocalCurveIdeal_transport (Φ i) (hcomap i) (gC i)439      (chartBase R t x t) _ (hlen ⟨some i.1, i.2.2⟩))).trans (ENat.toNat_natCast _)).symm440  rintro ⟨_ | φ, hQ⟩441  · exact (hR (Sum.inr ⟨(), hQ⟩)).trans (hgen _).symm442  by_cases hφ : φ = zeroAffine k443  · subst hφ444    exact (hL (Sum.inr ⟨(), hQ⟩)).trans (hgen _).symm445  · exact (strictTransformAt_transport R t x (Φ ⟨φ, hφ, hQ⟩) (hcomap ⟨φ, hφ, hQ⟩) (gC ⟨φ, hφ, hQ⟩)446      d _ (hL (Sum.inl ⟨φ, hφ, hQ⟩))).trans (hgen _).symm447 448private theorem directionPoint_overlap_facts (O R : Type) [CommRing O] [IsDomain O]449    [IsDiscreteValuationRing O] [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R]450    (S : SurfaceData O R) (t x : R) (ht : S.t = t) (hx : S.x = x)451    (e : (BlowupChart R t x ⧸ chartExceptional R t x) ≃+* Polynomial (IsLocalRing.ResidueField R))452    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R t x) (chartBase R t x r)) =453      Polynomial.C (IsLocalRing.residue R r))454    (heZ : e (Ideal.Quotient.mk (chartExceptional R t x) (chartSlope R t x)) = Polynomial.X)455    (φ : AffineDirection (IsLocalRing.ResidueField R))456    (hφ : φ ≠ zeroAffine (IsLocalRing.ResidueField R)) :457    ((directionPoint R t x e φ).map458        (algebraMap (BlowupChart R t x) (BlowupOverlap R t x))).IsMaximal ∧459      ((directionPoint R t x e φ).map (algebraMap (BlowupChart R t x) (BlowupOverlap R t x))).comap460        (algebraMap (BlowupChart R t x) (BlowupOverlap R t x)) = directionPoint R t x e φ := by461  subst ht hx462  obtain ⟨h1, -, h2⟩ := direction_point_overlap_maximal O R S e he heZ φ hφ463  exact ⟨h1, h2⟩464 465private theorem infinityPoint_facts (O R : Type) [CommRing O] [IsDomain O]466    [IsDiscreteValuationRing O] [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R]467    (S : SurfaceData O R) (t x : R) (ht : S.t = t) (hx : S.x = x) :468    (infinityPoint R t x).IsMaximal ∧ chartBase R x t x ∈ infinityPoint R t x ∧469      chartSlope R x t ∈ infinityPoint R t x := by470  subst ht hx471  obtain ⟨h1, h2, h3, -⟩ := infinity_point_maximal O R S472  exact ⟨h1, h2, h3⟩473 474private theorem length_quot_span_one_sup {A : Type} [CommRing A] (P : Ideal A) [P.IsPrime]475    (y : CompletedLocalAt A P) :476    Module.length (CompletedLocalAt A P) (CompletedLocalAt A P ⧸477      (Ideal.span {(1 : CompletedLocalAt A P)} ⊔ Ideal.span {y})) = ((0 : ℕ) : ℕ∞) := by478  rw [Ideal.span_singleton_one, top_sup_eq, Nat.cast_zero, Module.length_eq_zero_iff]479  exact Ideal.Quotient.subsingleton_iff.mpr rfl480 481/-- Every family of child ideals over the support of `Dv` is realized by a two-chart curve datum482matching `Dv`: any global function with the prescribed chart strict transforms has strict483transform `I Q` at every point `Q`. -/484theorem child_ideals_curve_datum (O : Type) [CommRing O] [IsDomain O] [IsDiscreteValuationRing O]Lemma 4.3485    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)486    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)487        [IsLocalRing (ConcreteSurface O pi u a b)]488    (e : (tChart O pi u a b ⧸ tExc O pi u a b) ≃+* Polynomial (IsLocalRing.ResidueField489        (ConcreteSurface O pi u a b)))490    (he : ∀ r : ConcreteSurface O pi u a b, e (Ideal.Quotient.mk (tExc O pi u a b)491        (tBase O pi u a b r)) = Polynomial.C (IsLocalRing.residue (ConcreteSurface O pi u a b) r))492    (heZ : e (Ideal.Quotient.mk (tExc O pi u a b) (tSlope O pi u a b)) = Polynomial.X)493    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))494    (hinf : (infinityPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b)495        (surfaceX O pi u a b)).IsPrime) (s : State) (d : ℕ)496    (beta : BlowupRestriction (ConcreteSurface O pi u a b) (surfaceT O pi u a b)497        (surfaceX O pi u a b))498    (I : ∀ Q : divisorSupport Dv, Ideal (divisorLocalRing (ConcreteSurface O pi u a b)499        (surfaceT O pi u a b) (surfaceX O pi u a b) e Dv hinf Q))500    (hI : ∀ Q : divisorSupport Dv, I Q ∈ childIdealSet (ConcreteSurface O pi u a b)501        (surfaceT O pi u a b) (surfaceX O pi u a b) e Dv hinf s d Q) :502    ∃ D : TwoChartCurveData (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)503        beta, MatchesDivisor e D Dv ∧ ∀ f : ConcreteSurface O pi u a b,504      (∀ s : D.ι ⊕ D.ι0,505        strictTransformAt (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)506            (leftPoint D s) d (Ideal.span {f}) = Ideal.span {leftData D s}) →507      (∀ s : D.ι ⊕ D.ιinf, strictTransformAt (ConcreteSurface O pi u a b) (surfaceX O pi u a b)508          (surfaceT O pi u a b) (rightPoint D s) d (Ideal.span {f}) =509        Ideal.span {rightData D s}) →510      ∀ Q : divisorSupport Dv, divisorStrictTransform (ConcreteSurface O pi u a b)511          (surfaceT O pi u a b) (surfaceX O pi u a b) e Dv hinf d (Ideal.span {f}) Q =512        I Q := by513  have := blowupChart_concrete_isNoetherianRing O pi u a b (surfaceT O pi u a b)514      (surfaceX O pi u a b)515  have := blowupChart_concrete_isNoetherianRing O pi u a b (surfaceX O pi u a b)516      (surfaceT O pi u a b)517  obtain ⟨hDom, hReg, S, -, hSt, hSx, -⟩ :=518    concrete_surface_data_exists_unconditional O pi hpi u a b ha519  have : (Ideal.span ({surfaceT O pi u a b, surfaceX O pi u a b} : Set520      (ConcreteSurface O pi u a b))).IsMaximal :=521    concrete_surface_parameterIdeal_isMaximal O pi hpi u a b ha522  obtain ⟨hdir, hinj, -⟩ := directionPoint_properties _ _ _ e he heZ523  have hinfmax := infinityPoint_facts O _ S _ _ hSt hSx524  refine child_ideals_curve_datum_of_points _ _ _ e Dv hinf s d beta I hI525    (fun φ ↦ ⟨(hdir φ).1, (hdir φ).2.1, (hdir φ).2.2.1⟩) hinj526    (directionPoint_overlap_facts O _ S _ _ hSt hSx e he heZ) hinfmax527    (fun P _ hP g n hg ↦ ?_) (fun P _ hP hW g n hg ↦ ?_)528  · have := @child_ideal_generator_transverse_finite O _ _ _ _ _ pi hpi u a b ha P _ _ hP g n hg529      (infinityPoint _ _ _) hinfmax.1 hinfmax.1.isPrime hinfmax.2.1 hinfmax.2.2 1530      0 (length_quot_span_one_sup _ _)531    exact ⟨this.1.1, this.1.2.2⟩532  · have := @child_ideal_generator_transverse_finite O _ _ _ _ _ pi hpi u a b ha533      (directionPoint _ _ _ e (zeroAffine _)) (hdir _).1 (hdir _).1.isPrime (hdir _).2.1 1 0534      (length_quot_span_one_sup _ _) P _ _ hP hW g n hg535    exact ⟨this.2.1, this.2.2.2⟩536 537/-- For a curve datum built from `f = ∑ cᵢ tᵈ⁻ⁱ xⁱ` with residue form `H` of divisor `Dv`, the538common points are nonzero affine directions with the right multiplicities, and the zero-slope539points sit at the zero direction with multiplicity `Dv 0`. -/540private theorem curve_datum_common_and_zero_clauses (O : Type) [CommRing O] [IsDomain O]541    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]542    [Finite (IsLocalRing.ResidueField O)] (pi : O) (hpi : Irreducible pi) (u : (TwoSeries O)ˣ)543    (a b : ℕ) (ha : 0 < a) (d : ℕ) (c : Fin (d + 1) → ConcreteSurface O pi u a b)544    [IsLocalRing (ConcreteSurface O pi u a b)]545    (H : Polynomial (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))546    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))547    (hH : HasHomogeneousDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)) d H Dv)548    (hcH : ∀ i : Fin (d+1), IsLocalRing.residue (ConcreteSurface O pi u a b) (c i) = H.coeff i.val)549    (e : (tChart O pi u a b ⧸ tExc O pi u a b) ≃+*550      Polynomial (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))551    (he : ∀ r : ConcreteSurface O pi u a b, e (Ideal.Quotient.mk (tExc O pi u a b)552      (tBase O pi u a b r)) = Polynomial.C (IsLocalRing.residue (ConcreteSurface O pi u a b) r))553    (heZ : e (Ideal.Quotient.mk (tExc O pi u a b) (tSlope O pi u a b)) = Polynomial.X)554    (beta : BlowupRestriction (ConcreteSurface O pi u a b) (surfaceT O pi u a b)555      (surfaceX O pi u a b))556    (D : TwoChartCurveData (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)557      beta)558    (hleft : ∀ s : D.ι ⊕ D.ι0,559      leftData D s = completedPointMap (tChart O pi u a b) (leftPoint D s)560        (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b) (tChart O pi u a b) (c i) *561            tSlope O pi u a b^i.val) ∧562      (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b) (tChart O pi u a b) (c i) *563          tSlope O pi u a b^i.val) ∈ leftPoint D s) :564    (∀ i : D.ι, ∃ φ : AffineDirection (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)),565      φ ≠ zeroAffine (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)) ∧566      D.Q i = (directionPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b)567          (surfaceX O pi u a b) e φ).map (algebraMap (tChart O pi u a b) (tOverlap O pi u a b)) ∧568      Dv (some φ) = commonMultiplicity D i) ∧569    ∀ k : D.ι0, D.P0 k = directionPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b)570        (surfaceX O pi u a b) e571          (zeroAffine (IsLocalRing.ResidueField (ConcreteSurface O pi u a b))) ∧572      Dv (zeroDirection (IsLocalRing.ResidueField (ConcreteSurface O pi u a b))) =573        leftMultiplicity D (Sum.inr k) := by574  have hmax : (Ideal.span ({surfaceT O pi u a b, surfaceX O pi u a b} : Set575      (ConcreteSurface O pi u a b))).IsMaximal :=576    concrete_surface_parameterIdeal_isMaximal O pi hpi u a b ha577  have hne : ∃ i : Fin (d+1), c i ∉ Ideal.span {surfaceT O pi u a b, surfaceX O pi u a b} := by578    obtain ⟨j, hj⟩ : ∃ j, H.coeff j ≠ 0 := by579      by_contra! h; exact hH.1 (Polynomial.ext h)580    have hjd : j < d + 1 := Nat.lt_succ_of_le ((Polynomial.le_natDegree_of_ne_zero hj).trans hH.2.1)581    refine ⟨⟨j, hjd⟩, fun hmem ↦ hj ?_⟩582    rw [← hcH ⟨j, hjd⟩]583    exact (IsLocalRing.residue_eq_zero_iff _).2 (IsLocalRing.le_maximalIdeal hmax.ne_top hmem)584  have hHBAR := reduced_form_eq_of_residue_coeff (ConcreteSurface O pi u a b) d c H hH.2.1 hcH585  have hlc : H.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.2 hH.1586  obtain ⟨hlm, -, hlt⟩ := two_chart_left_points_maximal _ _ _ beta D587  have : ∀ s, (leftPoint D s).IsMaximal := hlm588  have mult (s : D.ι ⊕ D.ι0) (φ : AffineDirection (IsLocalRing.ResidueField589      (ConcreteSurface O pi u a b)))590      (hPφ : ((leftPoint D s).map (Ideal.Quotient.mk (tExc O pi u a b))).map e = Ideal.span591          {φ.val}) :592      Dv (some φ) = leftMultiplicity D s := by593    unfold leftMultiplicity leftLevelIdeal finiteLocalCurveIdeal594    rw [(hleft s).1, pow_one, concrete_strict_transform_multiplicity O pi hpi u a b ha d c hne595      (leftPoint D s) (hlt s) e he heZ φ.val φ.property hPφ, hHBAR, ENat.toNat_natCast]596    conv_rhs => rw [hH.2.2.2]597    exact ((count_normalizedFactors_divisorAffinePolynomial _ Dv _ hlc φ).1).symm598  refine ⟨fun i ↦ ?_, fun k ↦ ?_⟩599  · obtain ⟨φ, hφ, himg, hslope⟩ :=600      chart_point_eq_directionPoint _ _ _ e he heZ (leftPoint D (Sum.inl i)) (hlt (Sum.inl i))601    have hZ := (overlap_exceptional_point_comap_maximal _ _ _ (D.Q i) (D.onE i)).2.1602    refine ⟨φ, fun h0 ↦ hZ (hslope.2 h0), ?_, ?_⟩603    · rw [← show leftPoint D (Sum.inl i) = _ from hφ]604      exact (IsLocalization.map_under (Submonoid.powers (tSlope O pi u a b)) _ (D.Q i)).symm605    · rw [mult (Sum.inl i) φ himg]606      exact (two_chart_common_multiplicity_eq _ _ _ beta D i).1607  · obtain ⟨φ, hφ, himg, hslope⟩ :=608      chart_point_eq_directionPoint _ _ _ e he heZ (leftPoint D (Sum.inr k)) (hlt (Sum.inr k))609    obtain rfl : φ = zeroAffine _ := hslope.1 (D.slope0 k)610    exact ⟨hφ, mult (Sum.inr k) _ himg⟩611 612/-- A curve datum built from `f = ∑ cᵢ tᵈ⁻ⁱ xⁱ`, whose residue form has divisor `Dv`, matches613`Dv`. -/614private theorem curve_datum_matches_divisor (O : Type) [CommRing O] [IsDomain O]615    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]616    [Finite (IsLocalRing.ResidueField O)] (pi : O) (hpi : Irreducible pi) (u : (TwoSeries O)ˣ)617    (a b : ℕ) (ha : 0 < a) (d : ℕ) (f : ConcreteSurface O pi u a b)618    (c : Fin (d + 1) → ConcreteSurface O pi u a b)619    (hc : f = ∑ i : Fin (d + 1), c i * surfaceT O pi u a b ^ (d - i.val) *620      surfaceX O pi u a b ^ i.val)621    [IsLocalRing (ConcreteSurface O pi u a b)]622    (H : Polynomial (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))623    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))624    (hH : HasHomogeneousDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)) d H Dv)625    (hcH : ∀ i : Fin (d+1), IsLocalRing.residue (ConcreteSurface O pi u a b) (c i) = H.coeff i.val)626    (e : (tChart O pi u a b ⧸ tExc O pi u a b) ≃+*627      Polynomial (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))628    (he : ∀ r : ConcreteSurface O pi u a b, e (Ideal.Quotient.mk (tExc O pi u a b)629      (tBase O pi u a b r)) = Polynomial.C (IsLocalRing.residue (ConcreteSurface O pi u a b) r))630    (heZ : e (Ideal.Quotient.mk (tExc O pi u a b) (tSlope O pi u a b)) = Polynomial.X)631    (beta : BlowupRestriction (ConcreteSurface O pi u a b) (surfaceT O pi u a b)632      (surfaceX O pi u a b))633    (D : TwoChartCurveData (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)634      beta)635    (hleft : ∀ s : D.ι ⊕ D.ι0, leftData D s = completedPointMap (tChart O pi u a b) (leftPoint D s)636      (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b) (tChart O pi u a b) (c i) *637        tSlope O pi u a b^i.val) ∧ (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)638          (tChart O pi u a b) (c i) * tSlope O pi u a b^i.val) ∈ leftPoint D s)639    (hleftsurj : ∀ P : Ideal (tChart O pi u a b), P.IsMaximal →640      tBase O pi u a b (surfaceT O pi u a b) ∈ P → (∑ i : Fin (d+1), algebraMap641        (ConcreteSurface O pi u a b) (tChart O pi u a b) (c i) * tSlope O pi u a b^i.val) ∈ P →642      ∃ s : D.ι ⊕ D.ι0, leftPoint D s = P)643    (hright : ∀ s : D.ι ⊕ D.ιinf, Ideal.span {rightData D s} =644      Ideal.span {completedPointMap (xChart O pi u a b) (rightPoint D s)645                    (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)646                      (xChart O pi u a b) (c i) * xSlope O pi u a b^(d - i.val))} ∧647      (∑ i : Fin (d+1), algebraMap648          (ConcreteSurface O pi u a b) (xChart O pi u a b) (c i) * xSlope O pi u a b^(d - i.val)) ∈649        rightPoint D s)650    (hrightsurj : ∀ P : Ideal (xChart O pi u a b), P.IsMaximal →651      xBase O pi u a b (surfaceX O pi u a b) ∈ P → (∑ i : Fin (d+1), algebraMap652        (ConcreteSurface O pi u a b) (xChart O pi u a b) (c i) * xSlope O pi u a b^(d - i.val)) ∈653          P → ∃ s : D.ι ⊕ D.ιinf, rightPoint D s = P) :654    MatchesDivisor e D Dv := by655  have h1 := curve_datum_common_and_zero_clauses O pi hpi u a b ha d c H Dv hH hcH e he heZ beta D656    hleft657  have h2 := curve_datum_surj_and_inf_clauses O pi hpi u a b ha d f c hc H Dv hH hcH e he heZ beta D658    hleft hleftsurj hright hrightsurj659  exact ⟨h1.1, h2.1, h1.2, h2.2.1, h2.2.2.1, h2.2.2.2⟩660 661/-- If a two-chart curve datum matches the divisor `Dv`, the degree of `Dv` is the curve datum662degree. -/663theorem matches_divisor_degree (O R : Type) [CommRing O] [IsDomain O] [IsDiscreteValuationRing O]Lemma 4.3664    [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R] (S : SurfaceData O R)665    (beta : BlowupRestriction R S.t S.x) (D : TwoChartCurveData R S.t S.x beta)666    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField R))667    (e : (BlowupChart R S.t S.x ⧸ chartExceptional R S.t S.x) ≃+*668      Polynomial (IsLocalRing.ResidueField R))669    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartBase R S.t S.x r)) =670      Polynomial.C (IsLocalRing.residue R r))671    (heZ : e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartSlope R S.t S.x)) = Polynomial.X)672    (hm : MatchesDivisor e D Dv) [IsNoetherianRing (BlowupChart R S.t S.x)]673    [IsNoetherianRing (BlowupChart R S.x S.t)] :674    exceptionalDegree (IsLocalRing.ResidueField R) Dv = curveDataDegree D := by675  classical676  set F := IsLocalRing.ResidueField R677  have hP := direction_point_maximal O R S e he heZ678  have hO := direction_point_overlap_maximal O R S e he heZ679  have hinjdir : Function.Injective (directionPoint R S.t S.x e) := (hP (zeroAffine F)).2.2.2.2.2680  choose φ hφ0 hφQ hφm using hm.common681  have hleft (i) : leftPoint D (Sum.inl i) = directionPoint R S.t S.x e (φ i) := by682    change (D.Q i).comap _ = _683    rw [hφQ i]; exact (hO (φ i) (hφ0 i)).2.2684  have hφinj : Function.Injective φ := fun i j h ↦ D.inj (by rw [hφQ i, hφQ j, h])685  have hsurj : ∀ ψ : AffineDirection F, ψ ≠ zeroAffine F → 0 < Dv (some ψ) → ∃ i, φ i = ψ := by686    intro ψ hψ hpos687    obtain ⟨i, hi⟩ := hm.common_surj ψ hψ hpos688    refine ⟨i, hinjdir ?_⟩689    rw [← hleft i]690    change (D.Q i).comap _ = _691    rw [hi]; exact (hO ψ hψ).2.2692  have hdeg (ψ : AffineDirection F) :693      (Module.length R (BlowupChart R S.t S.x ⧸ directionPoint R S.t S.x e ψ)).toNat =694        ψ.val.natDegree := by695    rw [(hP ψ).2.2.2.2.1]; rfl696  have : Fintype D.ι := Fintype.ofFinite _697  have : Fintype D.ι0 := Fintype.ofFinite _698  have : Fintype D.ιinf := Fintype.ofFinite _699  unfold curveDataDegree700  rw [finsum_eq_sum_of_fintype, finsum_eq_sum_of_fintype, Fintype.sum_sum_type]701  have hc : ∀ i, leftResidueDegree D (Sum.inl i) * leftMultiplicity D (Sum.inl i) =702      directionDegree F (some (φ i)) * Dv (some (φ i)) := by703    intro i704    unfold leftResidueDegree705    rw [hleft i, hdeg, (two_chart_common_multiplicity_eq R _ _ beta D i).1, hφm i]706    rfl707  have hz : ∑ k : D.ι0, leftResidueDegree D (Sum.inr k) * leftMultiplicity D (Sum.inr k) =708      directionDegree F (zeroDirection F) * Dv (zeroDirection F) := by709    by_cases hne : Nonempty D.ι0710    · obtain ⟨k⟩ := hne711      have : Subsingleton D.ι0 := ⟨fun a b => D.inj0 ((hm.zero a).1.trans (hm.zero b).1.symm)⟩712      rw [Fintype.sum_subsingleton _ k]713      unfold leftResidueDegree714      change (Module.length R (BlowupChart R S.t S.x ⧸ D.P0 k)).toNat * _ = _715      rw [(hm.zero k).1, hdeg, ← (hm.zero k).2]716      rfl717    · have h0 : Dv (zeroDirection F) = 0 := by718        by_contra h; exact hne (hm.zero_surj (Nat.pos_of_ne_zero h))719      rw [h0, mul_zero]720      have : IsEmpty D.ι0 := not_nonempty_iff.mp hne721      simp722  have hi : ∑ l : D.ιinf, rightMultiplicity D (Sum.inr l) =723      directionDegree F none * Dv none := by724    by_cases hne : Nonempty D.ιinf725    · obtain ⟨l⟩ := hne726      have : Subsingleton D.ιinf := ⟨fun a b => D.injinf ((hm.inf a).1.trans (hm.inf b).1.symm)⟩727      rw [Fintype.sum_subsingleton _ l, ← (hm.inf l).2]728      change _ = 1 * _729      rw [one_mul]730    · have h0 : Dv none = 0 := by731        by_contra h; exact hne (hm.inf_surj (Nat.pos_of_ne_zero h))732      rw [h0, mul_zero]733      have : IsEmpty D.ιinf := not_nonempty_iff.mp hne734      simp735  rw [Finset.sum_congr rfl (fun i _ => hc i), hz, hi]736  have hz1 : ∀ i, (some (φ i) : ClosedDirection F) ≠ zeroDirection F := by737    intro i h738    exact hφ0 i (Option.some_injective _ h)739  unfold exceptionalDegree740  rw [Finsupp.sum_of_support_subset Dv (s := insert none (insert (zeroDirection F)741      (Finset.univ.image (fun i => (some (φ i) : ClosedDirection F))))) ?_ _ (by simp)]742  · rw [Finset.sum_insert (by simp [zeroDirection]), Finset.sum_insert (by simpa using hz1),743      Finset.sum_image (fun a _ b _ h => hφinj (Option.some_injective _ h))]744    ring745  · intro P hPm746    rw [Finsupp.mem_support_iff] at hPm747    rcases P with _ | ψ748    · simp749    · by_cases hψ : ψ = zeroAffine F750      · subst hψ; simp [zeroDirection, zeroAffine]751      · obtain ⟨i, rfl⟩ := hsurj ψ hψ (Nat.pos_of_ne_zero hPm)752        simp753 754/-- Every ideal `J` of the fixed tangent cell is principal, generated by a degree-`d` form `f`755whose chart strict transforms define a two-chart curve datum matching `Dv` of degree `deg Dv`. -/756theorem fixed_tangent_cell_curve_datum (O : Type) [CommRing O] [IsDomain O]757    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]758    [Finite (IsLocalRing.ResidueField O)] (pi : O) (hpi : Irreducible pi) (u : (TwoSeries O)ˣ)759    (a b : ℕ) (ha : 0 < a) [IsDomain (ConcreteSurface O pi u a b)]760        [IsRegularLocalRing (ConcreteSurface O pi u a b)] (S : SurfaceData O761            (ConcreteSurface O pi u a b))762    (hS : S.t = surfaceT O pi u a b ∧ S.x = surfaceX O pi u a b) (e :763        (tChart O pi u a b ⧸ tExc O pi u a b) ≃+* Polynomial (IsLocalRing.ResidueField764            (ConcreteSurface O pi u a b)))765    (he : ∀ r : ConcreteSurface O pi u a b, e (Ideal.Quotient.mk (tExc O pi u a b)766        (tBase O pi u a b r)) = Polynomial.C (IsLocalRing.residue (ConcreteSurface O pi u a b) r))767    (heZ : e (Ideal.Quotient.mk (tExc O pi u a b) (tSlope O pi u a b)) = Polynomial.X)768    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b))) (s : State)769        (d : ℕ) (J : Ideal (ConcreteSurface O pi u a b))770    (hJ : J ∈ fixedTangentCell O (ConcreteSurface O pi u a b) S s d Dv)771        (beta : BlowupRestriction (ConcreteSurface O pi u a b) (surfaceT O pi u a b)772            (surfaceX O pi u a b)) :773    ∃ (f : ConcreteSurface O pi u a b) (c : Fin (d+1) → ConcreteSurface O pi u a b)774        (D : TwoChartCurveData (ConcreteSurface O pi u a b) (surfaceT O pi u a b)775            (surfaceX O pi u a b) beta), J = Ideal.span {f} ∧776      f = ∑ i : Fin (d+1), c i * surfaceT O pi u a b^(d - i.val) * surfaceX O pi u a b^i.val ∧777      (∀ s : D.ι ⊕ D.ι0,778        leftData D s = completedPointMap (tChart O pi u a b) (leftPoint D s)779          (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b) (tChart O pi u a b) (c i) *780              tSlope O pi u a b^i.val) ∧781        (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b) (tChart O pi u a b) (c i) *782            tSlope O pi u a b^i.val) ∈ leftPoint D s) ∧783      (∀ s : D.ι ⊕ D.ιinf,784        Ideal.span {rightData D s} =785          Ideal.span {completedPointMap (xChart O pi u a b) (rightPoint D s)786                        (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)787                          (xChart O pi u a b) (c i) * xSlope O pi u a b^(d - i.val))} ∧788        (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b) (xChart O pi u a b) (c i) *789            xSlope O pi u a b^(d - i.val)) ∈ rightPoint D s) ∧790      (∀ s : D.ι ⊕ D.ι0,791        strictTransformAt (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)792            (leftPoint D s) d J = Ideal.span {leftData D s}) ∧793      (∀ s : D.ι ⊕ D.ιinf,794        strictTransformAt (ConcreteSurface O pi u a b) (surfaceX O pi u a b) (surfaceT O pi u a b)795            (rightPoint D s) d J = Ideal.span {rightData D s}) ∧796      MatchesDivisor e D Dv ∧797      curveDataDegree D = exceptionalDegree (IsLocalRing.ResidueField (ConcreteSurface O pi u a b))798          Dv := by799  obtain ⟨ht, hx⟩ := hS800  cases S with | mk a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15801  dsimp only at ht hx802  subst ht hx803  obtain ⟨f, c, H, hJf, hf, hH, hcH, hne⟩ :=804    fixed_tangent_cell_generator_coefficients O _ _ s d Dv J hJ805  obtain ⟨D, hl, hls, hr, hrs, hst1, hst2⟩ :=806    curve_datum_of_parent_function O pi hpi u a b ha d f c hf hne beta807  have hm : MatchesDivisor e D Dv :=808    curve_datum_matches_divisor O pi hpi u a b ha d f c hf H Dv hH hcH e he heZ beta D hl hls hr hrs809  have := blowupChart_concrete_isNoetherianRing O pi u a b (surfaceT O pi u a b)810      (surfaceX O pi u a b)811  have := blowupChart_concrete_isNoetherianRing O pi u a b (surfaceX O pi u a b)812      (surfaceT O pi u a b)813  have hd := matches_divisor_degree O (ConcreteSurface O pi u a b)814    ⟨a1, a2, surfaceT O pi u a b, surfaceX O pi u a b, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14,815        a15⟩ beta D Dv e he heZ hm816  subst hJf817  exact ⟨f, c, D, rfl, hf, hl, hr, hst1, hst2, hm, hd.symm⟩818 819/-- **Level-one kernels on a blow-up chart.** Let `e` identify the exceptional line of the chart820`R[x/t]` with `k[X]` (`k = R ⧸ I`, `I = (t, x)`), and let `P s` be finitely many distinct821closed points of the exceptional line carrying finite-length level-one curve data `g s`. Then the822points correspond to distinct monic irreducibles `φ s` (with `φ s = X` exactly at the points where823the slope vanishes, and `deg φ s` the residue degree), the level-one lengths are finite numbers824`m s`, and the intersection of the contracted level-one ideals maps to `(∏ φ s ^ m s)`. -/825theorem level_one_kernel_polynomial (R : Type) [CommRing R] (t x : R) (I : Ideal R) [I.IsMaximal]826    (hI : Ideal.span ({t,x} : Set R) = I) [IsNoetherianRing (BlowupChart R t x)]827    (e : (BlowupChart R t x ⧸ chartExceptional R t x) ≃+* Polynomial (R ⧸ I))828    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R t x) (chartBase R t x r)) =829      Polynomial.C (Ideal.Quotient.mk I r))830    (heZ : e (Ideal.Quotient.mk (chartExceptional R t x) (chartSlope R t x)) = Polynomial.X)831    {ι : Type} [Finite ι] (P : ι → Ideal (BlowupChart R t x)) [∀ s, (P s).IsMaximal]832    (hinjP : Function.Injective P) (htP : ∀ s, chartBase R t x t ∈ P s)833    (g : ∀ s, CompletedLocalAt (BlowupChart R t x) (P s))834    (hfin : ∀ s, ∃ L : ℕ, ((IsLocalRing.maximalIdeal (Localization.AtPrime (P s))).map835      (localCompletionMap (Localization.AtPrime (P s))))^L ≤836      finiteLocalCurveIdeal (BlowupChart R t x) (P s) (chartBase R t x t) (g s) 1) :837    ∃ (φ : ι → Polynomial (R ⧸ I)) (m : ι → ℕ), (∀ s, (φ s).Monic ∧ Irreducible (φ s)) ∧838      Function.Injective φ ∧ (∀ s, chartSlope R t x ∈ P s ↔ φ s = Polynomial.X) ∧839      (∀ s, Module.length R (BlowupChart R t x ⧸ P s) = ((φ s).natDegree : ℕ∞)) ∧840      (∀ s, Module.length (CompletedLocalAt (BlowupChart R t x) (P s))841        (CompletedLocalAt (BlowupChart R t x) (P s) ⧸842          finiteLocalCurveIdeal (BlowupChart R t x) (P s) (chartBase R t x t) (g s) 1) =843        (m s : ℕ∞)) ∧844      ((⨅ s, contractedLocalCurveIdeal (BlowupChart R t x) (P s) (chartBase R t x t) (g s) 1).map845        (Ideal.Quotient.mk (chartExceptional R t x))).map e = Ideal.span {∏ᶠ s, φ s ^ m s} := by846  subst hI847  choose φ hmon hirr hφ hslope hlen using fun s ↦848    blowup_chart_exceptional_point_polynomial R t x e he heZ (P s) (htP s)849  -- the exceptional ideal lies in each point and in each contracted ideal850  have hker_le (J : Ideal (BlowupChart R t x)) (hJ : chartBase R t x t ∈ J) :851      (J.map (Ideal.Quotient.mk (chartExceptional R t x))).comap852        (Ideal.Quotient.mk (chartExceptional R t x)) = J := by853    rw [Ideal.comap_map_of_surjective _ Ideal.Quotient.mk_surjective, ← RingHom.ker_eq_comap_bot,854      Ideal.mk_ker]855    refine sup_eq_left.mpr ?_856    unfold chartExceptional857    rw [Ideal.span_le]; simpa using hJ858  have hemap_inj (J J' : Ideal (BlowupChart R t x ⧸ chartExceptional R t x))859      (h : J.map e = J'.map e) : J = J' := by860    rw [← Ideal.comap_map_of_bijective e e.bijective (I := J),861      ← Ideal.comap_map_of_bijective e e.bijective (I := J'), h]862  have hinj : Function.Injective φ := fun s s' h ↦ hinjP <| by863    rw [← hker_le _ (htP s), ← hker_le _ (htP s'), hemap_inj _ _ ((hφ s).trans (h ▸ (hφ s').symm))]864  -- multiplicities865  have hpow : ∀ s, ∃ r : ℕ, ((contractedLocalCurveIdeal (BlowupChart R t x) (P s)866      (chartBase R t x t) (g s) 1).map (Ideal.Quotient.mk (chartExceptional R t x))).map e =867        Ideal.span {φ s ^ r} ∧868      Module.length (CompletedLocalAt (BlowupChart R t x) (P s))869        (CompletedLocalAt (BlowupChart R t x) (P s) ⧸870          finiteLocalCurveIdeal (BlowupChart R t x) (P s) (chartBase R t x t) (g s) 1) =871        (r : ℕ∞) := fun s => by872    obtain ⟨L, hL⟩ := hfin s873    obtain ⟨r, -, hr, hrlen⟩ := contracted_level_one_ideal_is_irreducible_power R t x e874      (P s) (φ s) (hφ s) (hirr s) (g s) L hL875    exact ⟨r, hr, hrlen⟩876  choose m hmult hm using hpow877  refine ⟨φ, m, fun s => ⟨hmon s, hirr s⟩, hinj, hslope, hlen, hm, ?_⟩878  set J : ι → Ideal (BlowupChart R t x) := fun s =>879    contractedLocalCurveIdeal (BlowupChart R t x) (P s) (chartBase R t x t) (g s) 1880  have hJt : ∀ s, chartBase R t x t ∈ J s := by881    intro s882    change completedPointMap (BlowupChart R t x) (P s) (chartBase R t x t) ∈883      finiteLocalCurveIdeal (BlowupChart R t x) (P s) (chartBase R t x t) (g s) 1884    unfold finiteLocalCurveIdeal885    exact Ideal.subset_span (by simp)886  have h1 : (⨅ s, J s).map (Ideal.Quotient.mk (chartExceptional R t x)) =887      ⨅ s, (J s).map (Ideal.Quotient.mk (chartExceptional R t x)) := by888    rw [show (⨅ s, J s) = ⨅ s, ((J s).map (Ideal.Quotient.mk (chartExceptional R t x))).comap889        (Ideal.Quotient.mk (chartExceptional R t x)) from890        iInf_congr (fun s => (hker_le _ (hJt s)).symm)]891    exact Ideal.map_iInf_comap_of_surjective _ Ideal.Quotient.mk_surjective _892  have h2 (K : ι → Ideal (BlowupChart R t x ⧸ chartExceptional R t x)) :893      (⨅ s, K s).map e = ⨅ s, (K s).map e := by894    rw [show (⨅ s, K s) = ⨅ s, ((K s).map e).comap e from895        iInf_congr (fun s => (Ideal.comap_map_of_bijective e e.bijective).symm)]896    exact Ideal.map_iInf_comap_of_surjective _ e.surjective _897  let _ : Fintype ι := Fintype.ofFinite _898  rw [h1, h2, iInf_congr hmult, finprod_eq_prod_of_fintype]899  let _ := Ideal.Quotient.field (Ideal.span ({t,x} : Set R))900  exact pairwise_distinct_irreducible_pow_iInf (R ⧸ Ideal.span ({t,x} : Set R)) ι φ hmon hirr hinj m901 902/-- The level-one left kernel, transported to `k[X]` along an identification of the exceptional903line, is generated by `∏ φₛ ^ multₛ` for distinct monic irreducibles `φₛ`, with `φ = X`904exactly at the zero-slope points. -/905theorem two_chart_left_level_one_kernel_polynomial (R : Type) [CommRing R] (t x : R)906    (beta : BlowupRestriction R t x) (D : TwoChartCurveData R t x beta)907    [(Ideal.span ({t,x} : Set R)).IsMaximal] [IsNoetherianRing (BlowupChart R t x)]908    (e : (BlowupChart R t x ⧸ chartExceptional R t x) ≃+*909      Polynomial (R ⧸ Ideal.span ({t,x} : Set R)))910    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R t x) (chartBase R t x r)) =911      Polynomial.C (Ideal.Quotient.mk (Ideal.span ({t,x} : Set R)) r))912    (heZ : e (Ideal.Quotient.mk (chartExceptional R t x) (chartSlope R t x)) = Polynomial.X) :913    ∃ φ : D.ι ⊕ D.ι0 → Polynomial (R ⧸ Ideal.span ({t,x} : Set R)),914        (∀ s, (φ s).Monic ∧ Irreducible (φ s)) ∧ Function.Injective φ ∧915        (∀ i, φ (Sum.inl i) ≠ Polynomial.X) ∧ (∀ k, φ (Sum.inr k) = Polynomial.X) ∧916        (∀ s, (φ s).natDegree = leftResidueDegree D s) ∧ (∀ k, leftResidueDegree D (Sum.inr k) = 1)917        ∧ ((leftKernel D 1).map (Ideal.Quotient.mk (chartExceptional R t x))).map e =918        Ideal.span {∏ᶠ s, φ s ^ leftMultiplicity D s} := by919  obtain ⟨hmax, hinjP, htP⟩ := two_chart_left_points_maximal R t x beta D920  obtain ⟨φ, m, hφ, hinj, hslope, hlen, hm, hker⟩ := level_one_kernel_polynomial R t x _ rfl e he921    heZ (leftPoint D) hinjP htP (leftData D)922    (two_chart_left_data_transverse_finite R t x beta D 1).2923  have hmult : leftMultiplicity D = m := funext fun s => by924    unfold leftMultiplicity leftLevelIdeal; rw [hm s]; rfl925  have hdeg : ∀ s, (φ s).natDegree = leftResidueDegree D s := by926    intro s; unfold leftResidueDegree; rw [hlen s]; rfl927  have hX : ∀ k, φ (Sum.inr k) = Polynomial.X := fun k => (hslope (Sum.inr k)).1 (D.slope0 k)928  refine ⟨φ, hφ, hinj, fun i hi => ?_, hX, hdeg, fun k => ?_, by rw [hmult]; exact hker⟩929  · have hQ := D.onE i930    have := D.maximal i931    exact (overlap_exceptional_point_comap_maximal R t x (D.Q i) hQ).2.1 ((hslope (Sum.inl i)).2 hi)932  · rw [← hdeg, hX]; exact Polynomial.natDegree_X933 934private noncomputable def restrictLeftData {R : Type} [CommRing R] {t x : R}935    {beta : BlowupRestriction R t x}936    (D : TwoChartCurveData R t x beta) (p : D.ι → Prop) (q : D.ι0 → Prop) :937    TwoChartCurveData R t x beta where938  ι := {i // p i}939  fin := inferInstance940  Q := fun i => D.Q i.1941  maximal := fun i => D.maximal i.1942  inj := fun _ _ h => Subtype.ext (D.inj h)943  onE := fun i => D.onE i.1944  g := fun i => D.g i.1945  transverse := fun i => D.transverse i.1946  finite := fun i => D.finite i.1947  leftIso := fun i => D.leftIso i.1948  leftIso_compat := fun i => D.leftIso_compat i.1949  rightIso := fun i => D.rightIso i.1950  rightIso_compat := fun i => D.rightIso_compat i.1951  ι0 := {k // q k}952  fin0 := inferInstance953  P0 := fun k => D.P0 k.1954  maximal0 := fun k => D.maximal0 k.1955  inj0 := fun _ _ h => Subtype.ext (D.inj0 h)956  slope0 := fun k => D.slope0 k.1957  onE0 := fun k => D.onE0 k.1958  g0 := fun k => D.g0 k.1959  transverse0 := fun k => D.transverse0 k.1960  finite0 := fun k => D.finite0 k.1961  ιinf := D.ιinf962  fininf := D.fininf963  Pinf := D.Pinf964  maximalinf := D.maximalinf965  injinf := D.injinf966  slopeinf := D.slopeinf967  onEinf := D.onEinf968  ginf := D.ginf969  transverseinf := D.transverseinf970  finiteinf := D.finiteinf971 972private theorem leftKernel_le_restrictLeftData {R : Type} [CommRing R] {t x : R}973    {beta : BlowupRestriction R t x}974    (D : TwoChartCurveData R t x beta) (p : D.ι → Prop) (q : D.ι0 → Prop) :975    leftKernel D 1 ≤ leftKernel (restrictLeftData D p q) 1 := by976  unfold leftKernel finiteSupportKernel977  refine le_iInf ?_978  rintro (i | k)979  exacts [iInf_le _ (Sum.inl i.1), iInf_le _ (Sum.inr k.1)]980 981private theorem left_kernel_polynomial_residueField (O R : Type) [CommRing O] [IsDomain O]982    [IsDiscreteValuationRing O] [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R]983    (S : SurfaceData O R) (beta : BlowupRestriction R S.t S.x) (D : TwoChartCurveData R S.t S.x984      beta) (e : (BlowupChart R S.t S.x ⧸ chartExceptional R S.t S.x) ≃+*985      Polynomial (IsLocalRing.ResidueField R))986    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartBase R S.t S.x r)) =987      Polynomial.C (IsLocalRing.residue R r))988    (heZ : e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartSlope R S.t S.x)) = Polynomial.X)989    [IsNoetherianRing (BlowupChart R S.t S.x)] :990    ∃ ψ : D.ι ⊕ D.ι0 → Polynomial (IsLocalRing.ResidueField R),991        (∀ s, (ψ s).Monic ∧ Irreducible (ψ s)) ∧ (∀ s, (ψ s).natDegree = leftResidueDegree D s) ∧992      ((leftKernel D 1).map (Ideal.Quotient.mk (chartExceptional R S.t S.x))).map e =993          Ideal.span {∏ᶠ s, ψ s ^ leftMultiplicity D s} := by994  have : (Ideal.span ({S.t, S.x} : Set R)).IsMaximal := by995    rw [S.parameters]; exact IsLocalRing.maximalIdeal.isMaximal R996  let κ : (R ⧸ Ideal.span ({S.t, S.x} : Set R)) ≃+* IsLocalRing.ResidueField R :=997    Ideal.quotEquivOfEq S.parameters998  let e₀ := e.trans (Polynomial.mapEquiv κ).symm999  have he₀ : ∀ r : R, e₀ (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartBase R S.t S.x r)) =1000      Polynomial.C (Ideal.Quotient.mk (Ideal.span ({S.t,S.x} : Set R)) r) := by1001    intro r1002    simp only [e₀, RingEquiv.trans_apply, he]1003    rw [Polynomial.mapEquiv_symm_apply, Polynomial.map_C]1004    congr 11005  have heZ₀ : e₀ (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartSlope R S.t S.x)) =1006      Polynomial.X := by1007    simp only [e₀, RingEquiv.trans_apply, heZ]1008    rw [Polynomial.mapEquiv_symm_apply, Polynomial.map_X]1009  obtain ⟨φ, hφ, -, -, -, hdeg, -, hK⟩ :=1010    two_chart_left_level_one_kernel_polynomial R S.t S.x beta D e₀ he₀ heZ₀1011  refine ⟨fun s => (φ s).map (κ : _ →+* _), fun s => ⟨(hφ s).1.map _, ?_⟩, fun s => ?_, ?_⟩1012  · exact (MulEquiv.irreducible_iff (Polynomial.mapEquiv κ).toMulEquiv).2 (hφ s).21013  · rw [Polynomial.natDegree_map_eq_of_injective κ.injective, hdeg]1014  · have hmap : ∀ I : Ideal (BlowupChart R S.t S.x ⧸ chartExceptional R S.t S.x),1015        I.map e = (I.map e₀).map (Polynomial.mapEquiv κ) := by1016      intro I1017      rw [← Ideal.map_coe e, ← Ideal.map_coe e₀, ← Ideal.map_coe (Polynomial.mapEquiv κ),1018          Ideal.map_map]1019      congr 11020      exact RingHom.ext fun a => by1021        simp only [e₀, RingHom.coe_comp, Function.comp_apply, RingEquiv.coe_toRingHom,1022          RingEquiv.trans_apply, RingEquiv.apply_symm_apply]1023    rw [hmap, hK, Ideal.map_span, Set.image_singleton]1024    congr 21025    have : Fintype (D.ι ⊕ D.ι0) := Fintype.ofFinite _1026    rw [finprod_eq_prod_of_fintype, finprod_eq_prod_of_fintype, map_prod]1027    simp [Polynomial.mapEquiv_apply, Polynomial.map_pow]1028 1029private theorem pow_le_comap_completedPointMap (A : Type) [CommRing A] (P : Ideal A) [P.IsPrime]1030    (J : Ideal (CompletedLocalAt A P)) (L : ℕ)1031    (hL : ((IsLocalRing.maximalIdeal (Localization.AtPrime P)).map1032        (localCompletionMap (Localization.AtPrime P))) ^ L ≤ J) :1033    P^L ≤ J.comap (completedPointMap A P) := by1034  rw [← Ideal.map_le_iff_le_comap, Ideal.map_pow]1035  refine le_trans (le_of_eq ?_) hL1036  congr 11037  unfold completedPointMap1038  rw [← Ideal.map_map, Localization.AtPrime.map_eq_maximalIdeal]1039 1040/-- The image in `k[X]` of the level-one left kernel lies in `(ψ₀ ^ mult s₀)` whenever the left1041point `s₀` is the direction point of `ψ₀`; proved by restricting `D` to the point `s₀`. -/1042private theorem left_kernel_map_le_span_direction_pow (O R : Type) [CommRing O] [IsDomain O]1043    [IsDiscreteValuationRing O] [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R]1044    (S : SurfaceData O R) (beta : BlowupRestriction R S.t S.x)1045    (D : TwoChartCurveData R S.t S.x beta)1046    (e : (BlowupChart R S.t S.x ⧸ chartExceptional R S.t S.x) ≃+*1047      Polynomial (IsLocalRing.ResidueField R))1048    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartBase R S.t S.x r)) =1049      Polynomial.C (IsLocalRing.residue R r))1050    (heZ : e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartSlope R S.t S.x)) = Polynomial.X)1051    [IsNoetherianRing (BlowupChart R S.t S.x)] (s₀ : D.ι ⊕ D.ι0)1052    (ψ₀ : AffineDirection (IsLocalRing.ResidueField R))1053    (hP : leftPoint D s₀ = directionPoint R S.t S.x e ψ₀) :1054    ((leftKernel D 1).map (Ideal.Quotient.mk (chartExceptional R S.t S.x))).map e ≤1055      Ideal.span {ψ₀.val ^ leftMultiplicity D s₀} := by1056  have hmax : (Ideal.span ({S.t, S.x} : Set R)).IsMaximal := by1057    rw [S.parameters]; exact IsLocalRing.maximalIdeal.isMaximal R1058  set q := Ideal.Quotient.mk (chartExceptional R S.t S.x)1059  let D' := restrictLeftData D (fun i ↦ Sum.inl i = s₀) (fun j ↦ Sum.inr j = s₀)1060  have hsub : ∀ s s' : D'.ι ⊕ D'.ι0, s = s' := by1061    rintro (⟨i, hi⟩ | ⟨j, hj⟩) (⟨i', hi'⟩ | ⟨j', hj'⟩) <;>1062      first1063      | (cases hi.trans hi'.symm; rfl) | cases hi.trans hj'.symm1064      | cases hj.trans hi'.symm | (cases hj.trans hj'.symm; rfl)1065  obtain ⟨s₁, hm₁⟩ : ∃ s₁ : D'.ι ⊕ D'.ι0, leftMultiplicity D' s₁ = leftMultiplicity D s₀ := by1066    rcases s₀ with i | j1067    exacts [⟨.inl ⟨i, rfl⟩, rfl⟩, ⟨.inr ⟨j, rfl⟩, rfl⟩]1068  obtain ⟨ψ, hψ, -, hK'⟩ := left_kernel_polynomial_residueField O R S beta D' e he heZ1069  rw [finprod_eq_single _ s₁ (fun s hs ↦ absurd (hsub s s₁) hs), hm₁] at hK'1070  have hmono : ((leftKernel D 1).map q).map e ≤ ((leftKernel D' 1).map q).map e :=1071    Ideal.map_mono (Ideal.map_mono (leftKernel_le_restrictLeftData D _ _))1072  rcases Nat.eq_zero_or_pos (leftMultiplicity D s₀) with h0 | hpos1073  · rw [h0, pow_zero, Ideal.span_singleton_one]; exact le_top1074  obtain ⟨L, hL⟩ := (two_chart_left_data_transverse_finite R S.t S.x beta D 1).2 s₀1075  have hPL : (leftPoint D s₀)^L ≤ leftKernel D' 1 := by1076    unfold leftKernel finiteSupportKernel1077    have h := pow_le_comap_completedPointMap _ _ _ L hL1078    refine le_iInf fun s ↦ ?_1079    rcases s with ⟨i, rfl⟩ | ⟨j, rfl⟩ <;> exact h1080  have hmemP : ψ₀.val ∈ ((leftPoint D s₀).map q).map e := by1081    rw [hP, (direction_point_maximal O R S e he heZ ψ₀).2.2.2.1]; exact Ideal.subset_span rfl1082  have hsurj : Function.Surjective (fun a ↦ e (q a)) :=1083    e.surjective.comp Ideal.Quotient.mk_surjective1084  rw [← Ideal.map_coe e, Ideal.map_map] at hmemP1085  obtain ⟨a, ha, hae⟩ := (Ideal.mem_map_iff_of_surjective _ hsurj).1 hmemP1086  have h1 : Ideal.span {ψ₀.val ^ L} ≤ Ideal.span {ψ s₁ ^ leftMultiplicity D s₀} := by1087    rw [← hK', Ideal.span_singleton_le_iff_mem, ← hae, ← map_pow]1088    exact Ideal.mem_map_of_mem _ (Ideal.mem_map_of_mem _ (hPL (Ideal.pow_mem_pow ha L)))1089  rw [Ideal.span_singleton_le_span_singleton] at h11090  have h4 : ψ s₁ = ψ₀.val := Polynomial.eq_of_monic_of_associated (hψ s₁).1 ψ₀.2.11091    ((hψ s₁).2.associated_of_dvd ψ₀.2.21092      ((hψ s₁).2.prime.dvd_of_dvd_pow ((dvd_pow_self _ hpos.ne').trans h1)))1093  rw [← h4, ← hK']1094  exact hmono1095 1096/-- If a curve datum matches `Dv`, the level-one left kernel maps to the ideal of `k[X]` generated1097by the affine polynomial of `Dv`. -/1098theorem matches_divisor_level_one_polynomial (O R : Type) [CommRing O] [IsDomain O]1099    [IsDiscreteValuationRing O] [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R]1100    (S : SurfaceData O R) (beta : BlowupRestriction R S.t S.x)1101    (D : TwoChartCurveData R S.t S.x beta) (Dv : ExceptionalDivisor (IsLocalRing.ResidueField R))1102    (e : (BlowupChart R S.t S.x ⧸ chartExceptional R S.t S.x) ≃+*1103      Polynomial (IsLocalRing.ResidueField R))1104    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartBase R S.t S.x r)) =1105      Polynomial.C (IsLocalRing.residue R r))1106    (heZ : e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartSlope R S.t S.x)) = Polynomial.X)1107    (hm : MatchesDivisor e D Dv) [IsNoetherianRing (BlowupChart R S.t S.x)] :1108    ((leftKernel D 1).map (Ideal.Quotient.mk (chartExceptional R S.t S.x))).map e =1109      Ideal.span {divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv} := by1110  classical1111  have hmax : (Ideal.span ({S.t, S.x} : Set R)).IsMaximal := by1112    rw [S.parameters]; exact IsLocalRing.maximalIdeal.isMaximal R1113  set k := IsLocalRing.ResidueField R1114  set q := Ideal.Quotient.mk (chartExceptional R S.t S.x)1115  have hdp := direction_point_maximal O R S e he heZ1116  have hQ {i : D.ι} {ψ : AffineDirection k} (hψ : ψ ≠ zeroAffine k)1117      (h : D.Q i = (directionPoint R S.t S.x e ψ).map1118        (algebraMap (BlowupChart R S.t S.x) (BlowupOverlap R S.t S.x))) :1119      leftPoint D (Sum.inl i) = directionPoint R S.t S.x e ψ := by1120    change (D.Q i).comap _ = _1121    rw [h]; exact (direction_point_overlap_maximal O R S e he heZ ψ hψ).2.21122  choose φ hφne hφQ hφDv using hm.common1123  -- the direction of each left point1124  let dir : D.ι ⊕ D.ι0 → AffineDirection k := Sum.elim φ (fun _ ↦ zeroAffine k)1125  have hdirP : ∀ s, leftPoint D s = directionPoint R S.t S.x e (dir s) := by1126    rintro (i | j)1127    exacts [hQ (hφne i) (hφQ i), (hm.zero j).1]1128  have hdirM : ∀ s, Dv (some (dir s)) = leftMultiplicity D s := by1129    rintro (i | j)1130    exacts [(hφDv i).trans (two_chart_common_multiplicity_eq R S.t S.x beta D i).1.symm,1131      (hm.zero j).2]1132  have hdirDeg (s) : (dir s).val.natDegree = leftResidueDegree D s := by1133    rw [leftResidueDegree, hdirP, (hdp (dir s)).2.2.2.2.1, ENat.toNat_natCast]1134  have hdirInj : Function.Injective dir := fun s s' h ↦1135    (two_chart_left_points_maximal R S.t S.x beta D).2.1 (by rw [hdirP, hdirP, h])1136  have hmonic_eq {p p' : AffineDirection k} (h : p.val ∣ p'.val) : p.val = p'.val :=1137    Polynomial.eq_of_monic_of_associated p.2.1 p'.2.1 (p.2.2.associated_of_dvd p'.2.2 h)1138  have hC (s₀) : ((leftKernel D 1).map q).map e ≤1139      Ideal.span {(dir s₀).val ^ leftMultiplicity D s₀} :=1140    left_kernel_map_le_span_direction_pow O R S beta D e he heZ s₀ _ (hdirP s₀)1141  have : Fintype (D.ι ⊕ D.ι0) := Fintype.ofFinite _1142  obtain ⟨ψ, hψ, hψdeg, hK⟩ := left_kernel_polynomial_residueField O R S beta D e he heZ1143  rw [finprod_eq_prod_of_fintype] at hK1144  -- `∏ dir s ^ mult s ∣ ∏ ψ s ^ mult s`, and both are monic of the same degree1145  have hdvd : (∏ s, (dir s).val ^ leftMultiplicity D s) ∣ ∏ s, ψ s ^ leftMultiplicity D s := by1146    refine Finset.prod_dvd_of_coprime (fun s _ s' _ hne ↦ IsCoprime.pow ?_) fun s _ ↦1147      Ideal.mem_span_singleton.1 (hC s (by rw [hK]; exact Ideal.subset_span rfl))1148    rw [Irreducible.coprime_iff_not_dvd (dir s).2.2]1149    exact fun hd ↦ hne (hdirInj (Subtype.ext (hmonic_eq hd)))1150  have hGP := Polynomial.eq_of_monic_of_dvd_of_natDegree_le1151    (Polynomial.monic_prod_of_monic _ _ fun s _ ↦ (dir s).2.1.pow _)1152    (Polynomial.monic_prod_of_monic _ _ fun s _ ↦ (hψ s).1.pow _) hdvd <| by1153      rw [Polynomial.natDegree_prod_of_monic _ _ fun s _ ↦ (hψ s).1.pow _,1154        Polynomial.natDegree_prod_of_monic _ _ fun s _ ↦ (dir s).2.1.pow _]1155      refine le_of_eq (Finset.sum_congr rfl fun s _ ↦ ?_)1156      rw [Polynomial.natDegree_pow, Polynomial.natDegree_pow, hψdeg, hdirDeg]1157  rw [hK, hGP]1158  refine congrArg (fun p ↦ Ideal.span {p}) ?_1159  unfold divisorAffinePolynomial1160  -- finally, the support of `Dv` consists of `∞` and the directions of the left points1161  have hsub : Dv.support ⊆ insert none (Finset.univ.image (fun s ↦ some (dir s))) := by1162    rintro (_ | ψ0) hP1163    · exact Finset.mem_insert_self _ _1164    rw [Finsupp.mem_support_iff] at hP1165    refine Finset.mem_insert_of_mem (Finset.mem_image.2 ?_)1166    by_cases hz : ψ0 = zeroAffine k1167    · subst hz1168      obtain ⟨j⟩ := hm.zero_surj (Nat.pos_of_ne_zero hP)1169      exact ⟨Sum.inr j, Finset.mem_univ _, rfl⟩1170    · obtain ⟨i, hi⟩ := hm.common_surj ψ0 hz (Nat.pos_of_ne_zero hP)1171      exact ⟨Sum.inl i, Finset.mem_univ _,1172        congrArg some ((hdp ψ0).2.2.2.2.2 ((hdirP _).symm.trans (hQ hz hi)))⟩1173  symm1174  rw [Finsupp.prod_of_support_subset Dv hsub _ (by rintro (_ | ψ0) _ <;> simp),1175    Finset.prod_insert (by simp),1176    Finset.prod_image (fun a _ b _ h ↦ hdirInj (Option.some_injective _ h))]1177  simp only [one_mul]1178  exact Finset.prod_congr rfl fun s _ ↦ by rw [hdirM]1179 1180/-- The common computation behind `global_function_has_tangent_divisor`: the glued function is1181`f = ∑ cᵢ tᵈ⁻ⁱ xⁱ` with residue form `P · a`, where `P` is the (monic) affine polynomial of `Dv`1182and `a ≠ 0`. -/1183private theorem glued_level_one_data (O R : Type) [CommRing O] [IsDomain O]1184    [IsDiscreteValuationRing O] [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R]1185    (S : SurfaceData O R) (beta : BlowupRestriction R S.t S.x)1186    (D : TwoChartCurveData R S.t S.x beta) (Dv : ExceptionalDivisor (IsLocalRing.ResidueField R))1187    (e : (BlowupChart R S.t S.x ⧸ chartExceptional R S.t S.x) ≃+*1188      Polynomial (IsLocalRing.ResidueField R))1189    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartBase R S.t S.x r)) =1190      Polynomial.C (IsLocalRing.residue R r))1191    (heZ : e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartSlope R S.t S.x)) = Polynomial.X)1192    (hm : MatchesDivisor e D Dv) [IsNoetherianRing (BlowupChart R S.t S.x)]1193    [IsNoetherianRing (BlowupChart R S.x S.t)] (hreg : RegularParameterPair R S.t S.x)1194    (hregSwap : RegularParameterPair R S.x S.t) (f : R)1195    (G : GluedGenerators R S.t S.x beta (curveDataDegree D))1196    (hf : ∀ j : ℕ, surfaceToCechInput R S.t S.x j f =1197      (cechInputLattice R S.t S.x j).mkQ (gluedFunctionPair R S.t S.x G j))1198    (hG : ∀ j : ℕ,1199      Ideal.span {Ideal.Quotient.mk ((chartExceptional R S.t S.x)^j) (G.left j)} =1200        leftLevelKernel D j ∧1201      Ideal.span {Ideal.Quotient.mk ((chartExceptional R S.x S.t)^j) (G.right j)} =1202        rightLevelKernel D j) :1203    ∃ (c : Fin (curveDataDegree D+1) → R) (a : IsLocalRing.ResidueField R),1204      f = ∑ i : Fin (curveDataDegree D+1), c i * S.t^(curveDataDegree D - i.val) * S.x^i.val ∧1205      a ≠ 0 ∧ (divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv).Monic ∧1206      (divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv).natDegree + Dv none =1207        curveDataDegree D ∧1208      ∀ i : Fin (curveDataDegree D+1),1209        (divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv * Polynomial.C a).coeff i.val =1210          IsLocalRing.residue R (c i) := by1211  classical1212  obtain ⟨c, hfc, hGc, -⟩ := glued_function_initial_form R S.t S.x beta _ G hreg hregSwap f hf1213  set k := IsLocalRing.ResidueField R1214  set H : Polynomial k := ∑ i : Fin (curveDataDegree D+1),1215    Polynomial.C (IsLocalRing.residue R (c i)) * Polynomial.X ^ i.val with hHdef1216  set P := divisorAffinePolynomial k Dv with hPdef1217  -- `e` maps the class of `G.left 1` to `H`, which therefore generates the same ideal as `P`1218  have hal (r : R) : algebraMap R (BlowupChart R S.t S.x) r = chartBase R S.t S.x r := rfl1219  have heG : e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (G.left 1)) = H := by1220    rw [Ideal.Quotient.eq.mpr hGc, map_sum, map_sum]1221    exact Finset.sum_congr rfl fun i _ ↦ by rw [map_mul, map_mul, map_pow, map_pow, hal, he, heZ]1222  have hspan : Ideal.span {H} = Ideal.span {P} := by1223    have hle : (chartExceptional R S.t S.x) ^ 1 ≤ chartExceptional R S.t S.x := by rw [pow_one]1224    have h2 := congrArg (fun I ↦ (I.map (Ideal.Quotient.factor hle)).map e) (hG 1).11225    rw [Ideal.map_span, Set.image_singleton, Ideal.map_span, Set.image_singleton] at h21226    have hψ : Ideal.Quotient.factor hle (Ideal.Quotient.mk _ (G.left 1)) =1227        Ideal.Quotient.mk (chartExceptional R S.t S.x) (G.left 1) := rfl1228    rw [hψ, heG] at h21229    rw [h2, ← matches_divisor_level_one_polynomial O R S beta D Dv e he heZ hm]1230    congr 11231    unfold leftLevelKernel finiteSupportLevelKernel1232    exact Ideal.map_map _ _1233  -- `P = ∏ g Q ^ Dv Q` is monic of degree `deg Dv - Dv ∞`1234  set g : ClosedDirection k → ℕ → Polynomial k := fun Q r ↦ Option.elim Q 1 (fun phi ↦ phi.val ^ r)1235  have hPprod : P = ∏ Q ∈ Dv.support, g Q (Dv Q) := by1236    rw [hPdef, divisorAffinePolynomial, Finsupp.prod]1237    exact Finset.prod_congr rfl fun Q _ ↦ by cases Q <;> rfl1238  have hterm (Q : ClosedDirection k) (r : ℕ) : (g Q r).Monic ∧1239      directionDegree k Q * r = (g Q r).natDegree + (if Q = none then r else 0) := by1240    cases Q with1241    | none => simp [g, directionDegree]1242    | some phi =>1243      exact ⟨phi.2.1.pow r, by simp [g, directionDegree, phi.2.1.natDegree_pow, mul_comm]⟩1244  have hPmon : P.Monic := hPprod ▸ Polynomial.monic_prod_of_monic _ _ fun Q _ ↦ (hterm Q _).11245  have hPdeg : P.natDegree + Dv none = exceptionalDegree k Dv := by1246    rw [hPprod, exceptionalDegree, Finsupp.sum,1247      Polynomial.natDegree_prod_of_monic (h := fun Q _ ↦ (hterm Q (Dv Q)).1),1248      Finset.sum_congr rfl fun Q _ ↦ (hterm Q (Dv Q)).2, Finset.sum_add_distrib, Finset.sum_ite_eq']1249    split_ifs with h1250    · rfl1251    · rw [Finsupp.notMem_support_iff.mp h]1252  -- hence `H = P * C a` with `a ≠ 0`1253  obtain ⟨u, hu⟩ := Ideal.span_singleton_eq_span_singleton.mp hspan.symm1254  obtain ⟨a, ha, hau⟩ := Polynomial.isUnit_iff.mp u.isUnit1255  have hHP : H = P * Polynomial.C a := by rw [← hu, hau]1256  refine ⟨c, a, hfc, ha.ne_zero, hPmon,1257    hPdeg.trans (matches_divisor_degree O R S beta D Dv e he heZ hm), fun i ↦ ?_⟩1258  rw [← hHP, hHdef, Polynomial.finsetSum_coeff, Finset.sum_eq_single i (fun b _ hb ↦ ?_) (by simp)]1259  · simp1260  · rw [Polynomial.coeff_C_mul_X_pow, ite_eq_right fun h ↦ hb (Fin.ext h.symm)]1261 1262/-- A global function glued from the generators of a curve datum matching `Dv` has tangent1263divisor `Dv` in degree `deg D`. -/1264theorem global_function_has_tangent_divisor (O R : Type) [CommRing O] [IsDomain O]1265    [IsDiscreteValuationRing O] [CommRing R] [IsDomain R] [Algebra O R] [IsRegularLocalRing R]1266    (S : SurfaceData O R) (beta : BlowupRestriction R S.t S.x)1267    (D : TwoChartCurveData R S.t S.x beta) (Dv : ExceptionalDivisor (IsLocalRing.ResidueField R))1268    (e : (BlowupChart R S.t S.x ⧸ chartExceptional R S.t S.x) ≃+*1269      Polynomial (IsLocalRing.ResidueField R))1270    (he : ∀ r : R, e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartBase R S.t S.x r)) =1271      Polynomial.C (IsLocalRing.residue R r))1272    (heZ : e (Ideal.Quotient.mk (chartExceptional R S.t S.x) (chartSlope R S.t S.x)) = Polynomial.X)1273    (hm : MatchesDivisor e D Dv) [IsNoetherianRing (BlowupChart R S.t S.x)]1274    [IsNoetherianRing (BlowupChart R S.x S.t)] (hreg : RegularParameterPair R S.t S.x)1275    (hregSwap : RegularParameterPair R S.x S.t) (f : R)1276    (G : GluedGenerators R S.t S.x beta (curveDataDegree D))1277    (hf : ∀ j : ℕ, surfaceToCechInput R S.t S.x j f =1278      (cechInputLattice R S.t S.x j).mkQ (gluedFunctionPair R S.t S.x G j))1279    (hG : ∀ j : ℕ,1280      Ideal.span {Ideal.Quotient.mk ((chartExceptional R S.t S.x)^j) (G.left j)} =1281        leftLevelKernel D j ∧1282      Ideal.span {Ideal.Quotient.mk ((chartExceptional R S.x S.t)^j) (G.right j)} =1283        rightLevelKernel D j) :1284    HasTangentDivisor O R S (Ideal.span {f}) (curveDataDegree D) Dv := by1285  obtain ⟨c, a, hfc, ha0, hPmon, hPdeg, hcoeff⟩ :=1286    glued_level_one_data O R S beta D Dv e he heZ hm hreg hregSwap f G hf hG1287  set P := divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv1288  have hnd : (P * Polynomial.C a).natDegree = P.natDegree := Polynomial.natDegree_mul_C ha01289  refine ⟨f, P * Polynomial.C a, rfl, ⟨?_, ?_, ?_, ?_⟩, ?_⟩1290  · exact mul_ne_zero hPmon.ne_zero (Polynomial.C_ne_zero.2 ha0)1291  · rw [hnd]; omega1292  · rw [hnd]; omega1293  · rw [Polynomial.leadingCoeff_mul, hPmon.leadingCoeff, Polynomial.leadingCoeff_C,1294      one_mul, mul_comm]1295  · rw [hfc]1296    unfold tangentLift1297    apply initial_form_lift_independent1298    intro i1299    rw [hcoeff i, ← IsLocalRing.residue_eq_zero_iff, map_sub, sub_eq_zero]1300    unfold residueRepresentative1301    exact (Function.invFun_eq (IsLocalRing.residue_surjective _)).symm1302 1303private theorem span_sup_eq_top_of_isUnit_coeff {R B C : Type} [CommRing R] [CommRing B]1304    [CommRing C] [Algebra R B] (φ : B →+* C) (w : B)1305    (d : ℕ) (c : Fin (d + 1) → R) (n : Fin (d + 1) → ℕ) (j : Fin (d + 1)) (hj : IsUnit (c j))1306        (hnj : n j = 0)1307    (hn : ∀ i, i ≠ j → n i ≠ 0) :1308    Ideal.span {φ (∑ i : Fin (d+1), algebraMap R B (c i) * w^(n i))} ⊔ Ideal.span {φ w} = ⊤ := by1309  set J := Ideal.span {φ (∑ i : Fin (d+1), algebraMap R B (c i) * w^(n i))} ⊔ Ideal.span {φ w}1310  have hw : Ideal.Quotient.mk J (φ w) = 0 :=1311    Ideal.Quotient.eq_zero_iff_mem.mpr (Ideal.mem_sup_right (Ideal.subset_span rfl))1312  have hF : Ideal.Quotient.mk J (φ (∑ i : Fin (d+1), algebraMap R B (c i) * w^(n i))) = 0 :=1313    Ideal.Quotient.eq_zero_iff_mem.mpr (Ideal.mem_sup_left (Ideal.subset_span rfl))1314  have hF' : Ideal.Quotient.mk J (φ (∑ i : Fin (d+1), algebraMap R B (c i) * w^(n i))) =1315      Ideal.Quotient.mk J (φ (algebraMap R B (c j))) := by1316    simp only [map_sum, map_mul, map_pow, hw]1317    rw [Finset.sum_eq_single j]1318    · rw [hnj, pow_zero, mul_one]1319    · intro i _ hi1320      rw [zero_pow (hn i hi), mul_zero]1321    · intro h; exact absurd (Finset.mem_univ j) h1322  rw [hF] at hF'1323  have hmem : φ (algebraMap R B (c j)) ∈ J := Ideal.Quotient.eq_zero_iff_mem.mp hF'.symm1324  exact Ideal.eq_top_of_isUnit_mem _ hmem ((hj.map (algebraMap R B)).map φ)1325 1326/-- If the residues of `c₀, …, c_n` are the coefficients of `P · κ` (`κ ≠ 0`), where `P` is the1327monic affine polynomial of `Dv` and `deg P + Dv ∞ = n`, then `c_n` is a unit when `Dv` avoids1328`∞`, and `c₀` is a unit when `Dv` avoids the zero direction. -/1329private theorem isUnit_coeffs_of_residue_eq {R : Type} [CommRing R] [IsLocalRing R]1330    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField R)) {n : ℕ} (c : Fin (n + 1) → R)1331    (κ : IsLocalRing.ResidueField R) (hκ : κ ≠ 0)1332    (hPmon : (divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv).Monic)1333    (hPdeg : (divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv).natDegree + Dv none = n)1334    (hcoeff : ∀ i : Fin (n + 1), (divisorAffinePolynomial (IsLocalRing.ResidueField R) Dv *1335      Polynomial.C κ).coeff i.val = IsLocalRing.residue R (c i)) :1336    (Dv none = 0 → IsUnit (c (Fin.last n))) ∧1337      (Dv (zeroDirection (IsLocalRing.ResidueField R)) = 0 → IsUnit (c 0)) := by1338  refine ⟨fun h0 ↦ ?_, fun h0 ↦ ?_⟩ <;>1339    rw [← IsLocalRing.notMem_maximalIdeal, ← IsLocalRing.residue_eq_zero_iff, ← hcoeff,1340      Polynomial.coeff_mul_C]1341  · rw [Fin.val_last, ← hPdeg, h0, add_zero, ← Polynomial.leadingCoeff, hPmon.leadingCoeff,1342      one_mul]1343    exact hκ1344  · refine mul_ne_zero (fun hP ↦ ?_) hκ1345    rw [Fin.val_zero, ← Polynomial.X_dvd_iff] at hP1346    exact (Nat.pos_iff_ne_zero.mp ((count_normalizedFactors_divisorAffinePolynomial _ Dv 11347      one_ne_zero (zeroAffine _)).2.mp hP)) h01348 1349/-- A global function glued from a curve datum matching `Dv`, whose strict transforms are the1350prescribed child ideals, generates an ideal of the fixed tangent cell. -/1351theorem global_function_mem_cell (O : Type) [CommRing O] [IsDomain O] [IsDiscreteValuationRing O]1352    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)1353    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)1354    [IsDomain (ConcreteSurface O pi u a b)] [IsRegularLocalRing (ConcreteSurface O pi u a b)]1355    (S : SurfaceData O (ConcreteSurface O pi u a b))1356    (hS : S.t = surfaceT O pi u a b ∧ S.x = surfaceX O pi u a b ∧ S.a = a ∧ S.b = b)1357    (e : (tChart O pi u a b ⧸ tExc O pi u a b) ≃+*1358      Polynomial (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))1359    (he : ∀ r : ConcreteSurface O pi u a b, e (Ideal.Quotient.mk (tExc O pi u a b)1360      (tBase O pi u a b r)) = Polynomial.C (IsLocalRing.residue (ConcreteSurface O pi u a b) r))1361    (heZ : e (Ideal.Quotient.mk (tExc O pi u a b) (tSlope O pi u a b)) = Polynomial.X)1362    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))1363    (hinf : (infinityPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b)1364      (surfaceX O pi u a b)).IsPrime) (s : State) (d : ℕ) (hd : 0 < d)1365    (hs : (∃ c : ℕ, s = State.single a c ∧ b = 0) ∨ (∃ c h : ℕ, s = State.crossing a b c h ∧ 0 < b))1366    (hdc : d ≤ stateContactT s) (hdh : ∀ h : ℕ, stateContactX s = some h → d ≤ h)1367    (hDinf : 0 < Dv none ↔ d < stateContactT s)1368    (hDzero : ∀ h : ℕ, stateContactX s = some h →1369      (0 < Dv (zeroDirection (IsLocalRing.ResidueField (ConcreteSurface O pi u a b))) ↔ d < h))1370    (beta : BlowupRestriction (ConcreteSurface O pi u a b) (surfaceT O pi u a b)1371      (surfaceX O pi u a b))1372    (D : TwoChartCurveData (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)1373      beta)1374    (hm : MatchesDivisor e D Dv) (hdD : curveDataDegree D = d) (f : ConcreteSurface O pi u a b)1375    (G : GluedGenerators (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)1376      beta d)1377    (hf : ∀ j : ℕ, surfaceToCechInput (ConcreteSurface O pi u a b) (surfaceT O pi u a b)1378      (surfaceX O pi u a b) j f = (cechInputLattice (ConcreteSurface O pi u a b)1379        (surfaceT O pi u a b) (surfaceX O pi u a b) j).mkQ (gluedFunctionPair1380          (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b) G j))1381    (hG : ∀ j : ℕ,1382      Ideal.span {Ideal.Quotient.mk (tExc O pi u a b^j) (G.left j)} = leftLevelKernel D j ∧1383      Ideal.span {Ideal.Quotient.mk (xExc O pi u a b^j) (G.right j)} = rightLevelKernel D j)1384    (I : ∀ Q : divisorSupport Dv, Ideal (divisorLocalRing (ConcreteSurface O pi u a b)1385      (surfaceT O pi u a b) (surfaceX O pi u a b) e Dv hinf Q))1386    (hI : ∀ Q : divisorSupport Dv, I Q ∈ childIdealSet (ConcreteSurface O pi u a b)1387      (surfaceT O pi u a b) (surfaceX O pi u a b) e Dv hinf s d Q)1388    (hIf : ∀ Q : divisorSupport Dv, divisorStrictTransform (ConcreteSurface O pi u a b)1389      (surfaceT O pi u a b) (surfaceX O pi u a b) e Dv hinf d (Ideal.span {f}) Q = I Q) :1390    Ideal.span {f} ∈ (fixedTangentCell O (ConcreteSurface O pi u a b) S s d Dv) := by1391  classical1392  have hreg := concrete_surface_regular_pair_tx O pi hpi.ne_zero u a b ha1393  have hregSwap := concrete_surface_regular_pair_xt O pi hpi.ne_zero u a b ha1394  have := blowupChart_concrete_isNoetherianRing O pi u a b (surfaceT O pi u a b)1395      (surfaceX O pi u a b)1396  have := blowupChart_concrete_isNoetherianRing O pi u a b (surfaceX O pi u a b)1397      (surfaceT O pi u a b)1398  obtain ⟨ht, hx, hA, hB⟩ := hS1399  rcases S with ⟨pi', hpi', t0, x0, un, a0, b0, ha0, hpar, hdim, hcomp, hinj, rE, rC, hvert⟩1400  dsimp only at ht hx hA hB1401  subst t0 x0 a0 b0 hdD1402  set S' : SurfaceData O (ConcreteSurface O pi u a b) :=1403    ⟨pi', hpi', _, _, un, a, b, ha0, hpar, hdim, hcomp, hinj, rE, rC, hvert⟩1404  -- the coefficients of `f` at `x^d` and `t^d` are units when `Dv` avoids `∞`, resp. `0`1405  obtain ⟨c, κ, hfc, hκ, hPmon, hPdeg, hcoeff⟩ :=1406    glued_level_one_data O _ S' beta D Dv e he heZ hm hreg hregSwap f G hf hG1407  obtain ⟨hcT, hcX⟩ := isUnit_coeffs_of_residue_eq Dv c κ hκ hPmon hPdeg hcoeff1408  refine ⟨⟨⟨f, rfl⟩, ?_⟩, global_function_has_tangent_divisor O _ S' beta D Dv e he heZ hm hreg1409    hregSwap f G hf hG⟩1410  have : (Ideal.span ({surfaceT O pi u a b, surfaceX O pi u a b} : Set1411      (ConcreteSurface O pi u a b))).IsMaximal := hpar ▸ IsLocalRing.maximalIdeal.isMaximal _1412  obtain ⟨hdir, -, hdz⟩ := directionPoint_properties (ConcreteSurface O pi u a b) _ _ e he heZ1413  obtain ⟨hP0max, hP0t, -, -⟩ := hdir (zeroAffine _)1414  obtain ⟨hinfmax, hxinf, hWinf, -⟩ := infinity_point_maximal O _ S'1415  have : (infinityPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b)1416      (surfaceX O pi u a b)).IsMaximal := hinfmax1417  obtain ⟨hstA, hstB⟩ := concrete_strict_transform_generators O pi hpi u a b ha _ f c hfc _ hP0t1418    (infinityPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)) hxinf1419      hWinf1420  -- the contact orders of `f` with `t = 0` and `x = 0`1421  have htc : Module.length (ConcreteSurface O pi u a b) (ConcreteSurface O pi u a b ⧸1422      (Ideal.span {f} ⊔ Ideal.span {surfaceT O pi u a b})) = stateContactT s := by1423    rw [concrete_infinity_boundary_contact O pi hpi u a b ha _ f c hfc1424        (infinityPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b))1425      hxinf hWinf]1426    by_cases hpos : 0 < Dv none1427    · have h1 := (hI ⟨none, hpos⟩).2.2.1 rfl1428      rw [← hIf ⟨none, hpos⟩] at h11429      rw [← hstB]1430      exact (congrArg ((curveDataDegree D : ℕ∞) + ·) h1).trans1431        (by rw [← Nat.cast_add, Nat.add_sub_cancel' hdc])1432    · have hcd : stateContactT s = curveDataDegree D := by have := hDinf.not.mp hpos; omega1433      rw [span_sup_eq_top_of_isUnit_coeff _ _ _ c (fun i ↦ curveDataDegree D - i.val) (Fin.last _)1434        (hcT (by omega)) (by simp) (fun i hi ↦ by have := Fin.val_lt_last hi; omega),1435        Module.length_eq_zero, add_zero, hcd]1436  have hxc (h' : ℕ) (hsx : stateContactX s = some h') (hb : 0 < b) :1437      Module.length (ConcreteSurface O pi u a b) (ConcreteSurface O pi u a b ⧸1438          (Ideal.span {f} ⊔ Ideal.span {surfaceX O pi u a b})) = h' := by1439    rw [concrete_zero_boundary_contact O pi hpi u a b ha hb _ f c hfc1440      (directionPoint (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b) e1441          (zeroAffine _)) hdz]1442    by_cases hpos : 0 < Dv (zeroDirection (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))1443    · have h1 := (hI ⟨_, hpos⟩).2.2.2 rfl h' hsx1444      rw [← hIf ⟨_, hpos⟩] at h11445      rw [← hstA]1446      exact (congrArg ((curveDataDegree D : ℕ∞) + ·) h1).trans1447        (by rw [← Nat.cast_add, Nat.add_sub_cancel' (hdh h' hsx)])1448    · have h0 : Dv (zeroDirection (IsLocalRing.ResidueField (ConcreteSurface O pi u a b))) = 0 := by1449        omega1450      have hcd : h' = curveDataDegree D := by1451        have := hdh h' hsx; have := (hDzero h' hsx).not.mp hpos; omega1452      rw [span_sup_eq_top_of_isUnit_coeff _ _ _ c (fun i ↦ i.val) 0 (hcX h0) (by simp)1453        (fun i hi h ↦ hi (Fin.ext h)), Module.length_eq_zero, add_zero, hcd]1454  rcases hs with ⟨c', rfl, hb0⟩ | ⟨c', h', rfl, hb⟩1455  · have hdc' : curveDataDegree D ≤ c' := hdc1456    exact ⟨⟨ha, by omega⟩, rfl, hb0, htc⟩1457  · have hdc' : curveDataDegree D ≤ c' := hdc1458    have hdh' := hdh h' rfl1459    exact ⟨⟨ha, hb, by omega, by omega⟩, rfl, rfl, htc, hxc h' rfl hb⟩1460 1461end SurfaceBlowup