Lean sources / SurfaceBlowup / Recursion / RootCellLaw.lean

The root cell law

1366 lines · 7 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.Assembly.MonicCells7import SurfaceBlowup.Blowup.FixedTangentCellBijection8import SurfaceBlowup.Measure.MemberBoxes9import SurfaceBlowup.Recursion.Events10 11/-!12# The root cell law13 14The *root cell law* (`RootCellLaw`) computes the measure of the set of `π`-scaled monic15polynomials `monicPolynomial O (π • z)`, `z ∈ O^r`, with a given factorization type `σ`. This16file proves it unconditionally by building a concrete surface universe: every concrete member is17decomposed into cells, each cell ideal is sent to its strict transforms on the children, and the18termination hypotheses (child types exist, order defect decreases) are verified via the index map19of a cell.20 21## Main results22 23* `root_cell_law_at_universe_member`: the root cell law at a single universe member.24* `cell_member_index_map`: the index map `R ⧸ J → ∏ B j` of a cell, with cokernel length `d(d-1)/2`.25* `cell_child_bijOn`, `concrete_member_cells_cover`: cells and their children.26* `concrete_universe_exists`: a surface universe indexed by concrete members exists.27* `root_cell_law`: the root cell law.28* `monic_type_event_measurable_of_root_cell_law`: measurability of monic type events.29 30Provenance: `Thm_SurfaceBlowupV2_{algebra_type_ascent, etale_children_types_exist,31etale_recursion_data_abstract, concrete_termination_data_of_index_map,32monic_type_event_measurable_of_root_cell_law, root_cell_law_at_universe_member,33root_cell_law_of_universe, cell_child_bijOn, cell_datum_multiplicities_pos, cell_member_index_map,34cell_child_termination_data, cell_child_type_add, state_ideal_has_multiplicity,35state_ideal_multiplicity_le_contacts, concrete_member_cells_cover,36concrete_universe_of_cell_measure, concrete_universe_exists, root_cell_law}`.37-/38 39noncomputable section40 41namespace SurfaceBlowup42 43open scoped BigOperators ENNReal44 45/-! ### Algebra types along unramified extensions -/46 47/-- **Type ascent.** If `O → Oδ` is a finite free unramified extension of rank `δ` of complete DVRs48and the `Oδ`-algebra `B` has `O`-algebra type `σ`, then `B` has some `Oδ`-algebra type `τ` with49`σ = scaleType δ τ`. -/50private theorem algebra_type_ascent (O Oδ : Type) [CommRing O] [IsDomain O]51    [IsDiscreteValuationRing O]52    [CommRing Oδ] [IsDomain Oδ] [IsDiscreteValuationRing Oδ] [Algebra O Oδ] [Module.Finite O Oδ]53    [Module.Free O Oδ] (δ : ℕ) (hrank : Module.finrank O Oδ = δ) (pi : O) (hpi : Irreducible pi)54    (hpiδ : Irreducible (algebraMap O Oδ pi)) [IsAdicComplete (IsLocalRing.maximalIdeal O) O]55    [Finite (IsLocalRing.ResidueField O)] (B : Type) [CommRing B] [Algebra O B] [Algebra Oδ B]56    [IsScalarTower O Oδ B] (σ : FactorType) (h : HasAlgebraType O B σ) :57    ∃ τ : FactorType, HasAlgebraType Oδ B τ ∧ σ = scaleType δ τ := by58  have ⟨ι, hι, L, hF, _, _, _, _, e, _, hfinL⟩ := h59  obtain ⟨a1, a2, a3, a4, E, hc⟩ :=60    unramified_generic_fibre_ascent O Oδ δ hrank pi hpi hpiδ B ι L e61  -- closure finiteness over `Oδ` follows from finiteness over `O` (same fields `L i`)62  have hfinδ (i) : Module.Finite Oδ (integralClosure Oδ (L i)) :=63    have : IsScalarTower O Oδ (L i) := .of_algebraMap_eq fun c => by64      rw [hc i c, ← IsScalarTower.algebraMap_apply]65    closure_finite_ascent O Oδ (L i) (hfinL i)66  have hτ : HasAlgebraType Oδ B (∑ i, ({fieldInvariant Oδ (L i)} : FactorType)) :=67    ⟨ι, hι, L, hF, a1, a2, a3, a4, E, rfl, hfinδ⟩68  exact ⟨_, hτ, algebra_type_unique O B σ _ h69    (algebra_type_unramified_descent O Oδ δ hrank pi hpi hpiδ B _ hτ)⟩70 71/-- If `A` has an algebra type and `ψ : A → ∏ B j` is injective with finite-length cokernel, where72each `B j` is an algebra over an unramified extension `O_j` of `O`, then every `B j` has an73`O_j`-algebra type. -/74private theorem etale_children_types_exist (O : Type) [CommRing O] [IsDomain O]75    [IsDiscreteValuationRing O]76    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (n : ℕ)77    (Oj : Fin n → Type) [∀ j, CommRing (Oj j)] [∀ j, IsDomain (Oj j)]78    [∀ j, IsDiscreteValuationRing (Oj j)] [∀ j, Algebra O (Oj j)] [∀ j, Module.Finite O (Oj j)]79    [∀ j, Module.Free O (Oj j)] (δ : Fin n → ℕ) (hrank : ∀ j, Module.finrank O (Oj j) = δ j)80    (pi : O) (hpi : Irreducible pi) (hpiδ : ∀ j, Irreducible (algebraMap O (Oj j) pi)) (A : Type)81    [CommRing A] [Algebra O A] (B : Fin n → Type) [∀ j, CommRing (B j)] [∀ j, Algebra O (B j)]82    [∀ j, Algebra (Oj j) (B j)] [∀ j, IsScalarTower O (Oj j) (B j)] (ψ : A →ₐ[O] ∀ j, B j)83    (hinj : Function.Injective ψ) (ℓ : ℕ) (hℓ : Module.length O84    ((∀ j, B j) ⧸ LinearMap.range ψ.toLinearMap) = ℓ) (σ : FactorType) (hσ : HasAlgebraType O A σ) :85    ∀ j, ∃ τ : FactorType, HasAlgebraType (Oj j) (B j) τ := by86  intro j87  obtain ⟨τ₀, h₀⟩ := algebra_type_children_exists O A n B ψ hinj ℓ hℓ σ hσ j88  obtain ⟨τ, hτ, -⟩ := algebra_type_ascent O (Oj j) (δ j) (hrank j) pi hpi (hpiδ j) (B j) τ₀ h₀89  exact ⟨τ, hτ⟩90 91/-- The abstract étale recursion data: in the situation of `etale_children_types_exist`, every92child `B j` has an algebra type, its order defect is at most that of `A`, and strictly smaller93when the cokernel of `ψ` is nonzero. -/94private theorem etale_recursion_data_abstract (O : Type) [CommRing O] [IsDomain O]95    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]96    [Finite (IsLocalRing.ResidueField O)] (n : ℕ) (Oj : Fin n → Type) [∀ j, CommRing (Oj j)]97    [∀ j, IsDomain (Oj j)] [∀ j, IsDiscreteValuationRing (Oj j)] [∀ j, Algebra O (Oj j)]98    [∀ j, Module.Finite O (Oj j)] [∀ j, Module.Free O (Oj j)] (δ : Fin n → ℕ)99    (hrank : ∀ j, Module.finrank O (Oj j) = δ j) (pi : O) (hpi : Irreducible pi)100    (hpiδ : ∀ j, Irreducible (algebraMap O (Oj j) pi)) (A : Type) [CommRing A] [Algebra O A]101    [Module.Finite O A] [Module.Free O A] (B : Fin n → Type) [∀ j, CommRing (B j)]102    [∀ j, Algebra O (B j)] [∀ j, Module.Finite O (B j)] [∀ j, Module.Free O (B j)]103    [∀ j, Algebra (Oj j) (B j)] [∀ j, IsScalarTower O (Oj j) (B j)] (ψ : A →ₐ[O] ∀ j, B j)104    (hinj : Function.Injective ψ) (ℓ : ℕ) (hℓ : Module.length O105    ((∀ j, B j) ⧸ LinearMap.range ψ.toLinearMap) = ℓ) (σ : FactorType) (hσ : HasAlgebraType O A σ) :106    ∀ j, (∃ τ : FactorType, HasAlgebraType (Oj j) (B j) τ) ∧ (orderDefect (Oj j) (B j)).toNat ≤107        (orderDefect O A).toNat ∧ (1 ≤ ℓ → (orderDefect (Oj j) (B j)).toNat <108        (orderDefect O A).toNat) := fun j ↦109  ⟨etale_children_types_exist O n Oj δ hrank pi hpi hpiδ A B ψ hinj ℓ hℓ σ hσ j,110    etale_invariant_children O n Oj δ hrank pi hpi hpiδ A B ψ hinj ℓ hℓ σ hσ j⟩111 112/-- `etale_recursion_data_abstract` specialised to a concrete member `m`, a cell ideal `J` and113child members `mc j`: the quotient `R ⧸ J` plays the role of `A`. -/114private theorem concrete_termination_data_of_index_map (m : ConcreteMember) (n : ℕ)115    (mc : Fin n → ConcreteMember) [∀ j, Algebra m.O (mc j).O] [∀ j, Module.Finite m.O (mc j).O]116    [∀ j, Module.Free m.O (mc j).O] (δ : Fin n → ℕ)117    (hrank : ∀ j, Module.finrank m.O (mc j).O = δ j)118    (hpi : ∀ j, Irreducible (algebraMap m.O (mc j).O m.pi)) (J : Ideal m.R) (B : Fin n → Type)119    [∀ j, CommRing (B j)] [∀ j, Algebra m.O (B j)] [∀ j, Algebra (mc j).O (B j)]120    [∀ j, IsScalarTower m.O (mc j).O (B j)] [∀ j, Module.Finite (mc j).O (B j)]121    [∀ j, Module.Free (mc j).O (B j)] (ψ : (m.R ⧸ J) →ₐ[m.O] ∀ j, B j) (hψ : Function.Injective ψ)122    (ℓ : ℕ) (hlen : Module.length m.O ((∀ j, B j) ⧸ LinearMap.range ψ.toLinearMap) = (ℓ : ℕ∞))123    [Module.Finite m.O (m.R ⧸ J)] [Module.Free m.O (m.R ⧸ J)] (σ : FactorType)124    (hσ : HasAlgebraType m.O (m.R ⧸ J) σ) :125    ∀ j, (∃ τ : FactorType, HasAlgebraType (mc j).O (B j) τ) ∧ (orderDefect (mc j).O (B j)).toNat ≤126        (orderDefect m.O (m.R ⧸ J)).toNat ∧ (1 ≤ ℓ → (orderDefect (mc j).O (B j)).toNat <127        (orderDefect m.O (m.R ⧸ J)).toNat) := by128  have : ∀ j, Module.Finite m.O (B j) := fun j => Module.Finite.trans (mc j).O (B j)129  have : ∀ j, Module.Free m.O (B j) := fun j => Module.Free.trans (S := (mc j).O)130  have h := etale_recursion_data_abstract m.O n (fun j => (mc j).O) δ hrank m.pi m.hpi hpi131    (m.R ⧸ J) B132  exact h ψ hψ ℓ hlen σ hσ133 134/-- Assuming the root cell law, the set of monic polynomials of degree `n` over `O` with135factorization type `σ` is measurable. -/136theorem monic_type_event_measurable_of_root_cell_law (hroot : RootCellLaw) (O : Type) [CommRing O]137    [IsDomain O] [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]138    [Finite (IsLocalRing.ResidueField O)] [TopologicalSpace O] [IsTopologicalRing O]139    [CompactSpace O] [T2Space O] [SecondCountableTopology O] [MeasurableSpace O] [BorelSpace O]140    (htop : IsAdic (IsLocalRing.maximalIdeal O)) (n : ℕ) (σ : FactorType) :141    MeasurableSet {a : Fin n→O | HasPolynomialTypeF O (monicPolynomial O a) σ} := by142  obtain ⟨⟨S, hS⟩, hcov, -⟩ := monic_cells_partition O htop n143  have key : {a : Fin n→O | HasPolynomialTypeF O (monicPolynomial O a) σ} =144      ⋃ D ∈ S, (residueCell O n (divisorAffinePolynomial (IsLocalRing.ResidueField O) D) ∩145          typeEvent O n σ) := by146    ext a147    simp only [Set.mem_ofPred_eq, Set.mem_iUnion, Set.mem_inter_iff, exists_prop]148    refine ⟨fun h ↦ ?_, fun ⟨_, _, _, h⟩ ↦ h⟩149    obtain ⟨D, ⟨hD, ha⟩, -⟩ := hcov a150    exact ⟨D, (hS D).2 hD, ha, h⟩151  rw [key]152  refine Finset.measurableSet_biUnion _ fun D hD => ?_153  have hD' := (hS D).1 hD154  obtain ⟨⟨m, hm, -⟩, -⟩ := divisor_array_exists_unique (IsLocalRing.ResidueField O) n D hD'.2155  exact (monic_cell_law hroot O htop n D hD' m hm σ).1156 157/-! ### The root cell law from a concrete universe -/158 159/-- A surface universe indexed by all concrete members, satisfying the termination hypotheses. -/160private def ConcreteUniverse : Prop :=161  ∃ U : SurfaceUniverse, ∃ eι : U.ι ≃ ConcreteMember, (∀ i, U.M i = (eι i).toMeasured) ∧162    U.ChildTypesExist ∧163      U.InvariantDecreases fun i J ↦ (orderDefect (U.M i).O ((U.M i).R ⧸ J)).toNat164 165/-- **Root cell law at a universe member.** Let `i` be a member of a surface universe satisfying166the termination hypotheses, whose state is the single state `(1, r)` and whose measure is the167pushforward of the coefficient measure along a coordinate chart `z ↦ (f, b)(π z)` matching168algebra types with polynomial types. Then the type-`σ` event of `π`-scaled monic polynomials is169measurable and has mass `densityValue (lawCoeff (stateLaw (single 1 r)) σ) q`. -/170theorem root_cell_law_at_universe_member (U : SurfaceUniverse)171    (hE1 : U.ChildTypesExist)172    (hE2 : U.InvariantDecreases fun i J ↦ (orderDefect (U.M i).O ((U.M i).R ⧸ J)).toNat)173    (i : U.ι) (r : ℕ) (hr : 0 < r)174    (hs : (U.M i).s = State.single 1 r) (f : (U.M i).R)175    (b : Fin (State.single 1 r).degree → (U.M i).R)176    (hmeas : Measurable (coordinateIdeal (U.M i).S.pi f b))177    (hμ : (U.M i).μ = (((U.M i).q : ℝ≥0∞)⁻¹ ^ (State.single 1 r).degree) •178    (coefficientMeasure (U.M i).O (State.single 1 r).degree).map179    (coordinateIdeal (U.M i).S.pi f b)) (hcell : ∀ z : Fin (State.single 1 r).degree → (U.M i).O,180    (coordinateIdeal (U.M i).S.pi f b) z ∈ (U.M i).stateSet)181    (htype : ∀ (z : Fin (State.single 1 r).degree → (U.M i).O) (σ : FactorType), HasAlgebraType182    (U.M i).O ((U.M i).R ⧸ (coordinateIdeal (U.M i).S.pi f b) z) σ ↔ HasPolynomialTypeF (U.M i).O183    (monicPolynomial (U.M i).O ((U.M i).S.pi • z)) σ) (σ : FactorType) :184    MeasurableSet {z : Fin (State.single 1 r).degree → (U.M i).O | HasPolynomialTypeF (U.M i).O185        (monicPolynomial (U.M i).O ((U.M i).S.pi • z)) σ} ∧ coefficientMeasure (U.M i).O186        (State.single 1 r).degree {z : Fin (State.single 1 r).degree → (U.M i).O |187        HasPolynomialTypeF (U.M i).O (monicPolynomial (U.M i).O ((U.M i).S.pi • z)) σ} =188        densityValue (lawCoeff (stateLaw (State.single 1 r)) σ) (U.M i).q := by189  have hpre : coordinateIdeal (U.M i).S.pi f b ⁻¹' U.typeEvent i σ =190      {z : Fin (State.single 1 r).degree → (U.M i).O | HasPolynomialTypeF (U.M i).O191          (monicPolynomial (U.M i).O ((U.M i).S.pi • z)) σ} := by192    ext z193    simp only [Set.mem_preimage, SurfaceUniverse.typeEvent, Set.mem_ofPred_eq]194    exact ⟨fun h => (htype z σ).1 h.2, fun h => ⟨hcell z, (htype z σ).2 h⟩⟩195  refine ⟨?_, ?_⟩196  · rw [← hpre]197    exact hmeas (etale_type_event_measurable U hE1198      (fun i J => (orderDefect (U.M i).O ((U.M i).R ⧸ J)).toNat) hE2 i σ)199  · have hd : (State.single 1 r).degree = r := by simp [State.degree]200    have hdpos : 0 < (State.single 1 r).degree := by rw [hd]; exact hr201    obtain ⟨hFm, hFE, hEF, hN⟩ := type_event_null_difference U i σ202    have hL := ((universal_law_statement U i).1 σ).2.2203    rw [hs] at hL204    have e : stateLaw (State.single 1 (State.single 1 r).degree) = stateLaw (State.single 1 r) := by205      rw [hd]206    have key := chart_cell_law_generic (U.M i).O (U.M i).htop (U.M i).S.pi207      (U.M i).R (State.single 1 r).degree f b hmeas208      (U.M i).stateSet hcell (U.M i).μ hμ htype σ (U.termTypeEvent i σ) (U.nonterminatingSet i)209      hFm hFE hEF hN (by rw [e]; exact hL)210    rw [e] at key211    exact key.1212 213/-- The root cell law follows from the existence of a concrete surface universe: the one-chart214member with state `(1, r)` realises the root cell, and the universal law computes its mass. -/215private theorem root_cell_law_of_universe (hU : ConcreteUniverse) : RootCellLaw := by216  obtain ⟨U, eι, hM, hE1, hE2⟩ := hU217  intro O _ _ _ _ _ _ _ _ _ _ _ _ htop pi hpi r hr σ218  obtain ⟨hD, hReg, S, hSpi, hSt, hSx, -, hSa, hSb⟩ :=219    concrete_surface_data_exists_unconditional O pi hpi 1 1 0 one_pos220  obtain ⟨A, i₀, hi₀, hf, hb, hμA⟩ :=221    repeated_root_one_chart_atlas O pi hpi S hSpi hSt hSa hSb r hr222  have hshape : StateShape 1 0 (State.single 1 r) := ⟨rfl, rfl, hr⟩223  let m₀ : ConcreteMember :=224    { O := O, htop := htop, pi := pi, hpi := hpi, u := 1, a := 1, b := 0, ha := one_pos,225      S := S, hS_pi := hSpi, hS_t := hSt, hS_x := hSx, hS_a := hSa, hS_b := hSb,226      s := State.single 1 r, shape := hshape, atlas := A }227  set i := eι.symm m₀228  have hMi : U.M i = m₀.toMeasured := by rw [hM i]; simp [i]229  have hdeg : 0 < (State.single 1 r).degree := by simpa [State.degree] using hr230  have key : ∀ M : MeasuredSurface, M = m₀.toMeasured →231      (M.s = State.single 1 r) ∧ ∃ (f : M.R) (b : Fin (State.single 1 r).degree → M.R),232        Measurable (coordinateIdeal M.S.pi f b) ∧233        M.μ = ((M.q : ℝ≥0∞)⁻¹ ^ (State.single 1 r).degree) •234          (coefficientMeasure M.O (State.single 1 r).degree).map (coordinateIdeal M.S.pi f b) ∧235        (∀ z : Fin (State.single 1 r).degree → M.O, (coordinateIdeal M.S.pi f b) z ∈ M.stateSet) ∧236        (∀ (z : Fin (State.single 1 r).degree → M.O) (σ : FactorType),237          HasAlgebraType M.O (M.R ⧸ (coordinateIdeal M.S.pi f b) z) σ ↔238            HasPolynomialTypeF M.O (monicPolynomial M.O (M.S.pi • z)) σ) := by239    intro M hM'240    subst hM'241    have hch := concrete_member_charts m₀ i₀242    refine ⟨rfl, (A.chart i₀).f, (A.chart i₀).b, hch.2.2, ?_, ?_, ?_⟩243    · let _ : MeasurableSpace (Ideal (ConcreteSurface O pi 1 1 0)) :=244        idealChartSigma O (ConcreteSurface O pi 1 1 0) S.pi245      change stateMeasure O (ConcreteSurface O pi 1 1 0) S.pi (State.single 1 r).degree246        (Nat.card (IsLocalRing.ResidueField O)) A = _247      rw [hμA]248      change _ = _ • (coefficientMeasure O (State.single 1 r).degree).map249        (coordinateIdeal S.pi (A.chart i₀).f (A.chart i₀).b)250      rw [hf, hb]251      rfl252    · intro z253      have hz : coordinateIdeal m₀.S.pi (m₀.atlas.chart i₀).f (m₀.atlas.chart i₀).b z ∈254          residueIdealCell (algebraMap m₀.O m₀.R m₀.S.pi) (m₀.atlas.chart i₀).f := by255        rw [← hch.2.1]; exact ⟨z, rfl⟩256      exact (Set.ext_iff.1 A.cover _).2 (Set.mem_iUnion.2 ⟨i₀, hz⟩)257    · intro z τ258      have e : ∀ z' : Fin (State.single 1 r).degree → O,259          HasAlgebraType O (ConcreteSurface O pi 1 1 0 ⧸260            coordinateIdeal S.pi (A.chart i₀).f (A.chart i₀).b z') τ ↔261          HasPolynomialTypeF O (monicPolynomial O (S.pi • z')) τ := by262        intro z'263        rw [hf, hb, hSpi]264        exact repeated_root_chart_type O pi hpi _ hdeg z' τ265      exact e z266  have back : ∀ M : MeasuredSurface, M = m₀.toMeasured →267      (MeasurableSet {z : Fin (State.single 1 r).degree → M.O | HasPolynomialTypeF M.O268          (monicPolynomial M.O (M.S.pi • z)) σ} ∧ coefficientMeasure M.O (State.single 1 r).degree269          {z : Fin (State.single 1 r).degree → M.O | HasPolynomialTypeF M.O270          (monicPolynomial M.O (M.S.pi • z)) σ} = densityValue271          (lawCoeff (stateLaw (State.single 1 r)) σ) M.q) →272      MeasurableSet {z : Fin r → O | HasPolynomialTypeF O (monicPolynomial O (pi • z)) σ} ∧273      coefficientMeasure O r {z : Fin r → O | HasPolynomialTypeF O (monicPolynomial O (pi • z)) σ} =274        densityValue (lawCoeff (stateLaw (State.single 1 r)) σ)275            (Nat.card (IsLocalRing.ResidueField O)) := by276    intro M hM' h277    subst hM'278    have hpi' : m₀.toMeasured.S.pi = pi := hSpi279    rw [hpi'] at h280    exact root_cell_clauses_reindex O pi σ _ _ r (Nat.one_mul r) h281  obtain ⟨hs, f, b, hmeas, hμ, hcell, htype⟩ := key (U.M i) hMi282  exact back (U.M i) hMi (root_cell_law_at_universe_member U hE1 hE2 i r hr hs f b hmeas hμ hcell283      htype σ)284 285private theorem pattern_degree_facts_of_hasPattern (k : Type) [Field k] (a b : ℕ) (s : State)286    (hsh : StateShape a b s)287    (P : TangentPattern s.degree) (hP : Allowed s P) (Dv : ExceptionalDivisor k)288        (hD : HasPattern k s Dv P) :289    0 < P.d.val ∧290    ((∃ c : ℕ, s = State.single a c ∧ b = 0) ∨ (∃ c h : ℕ, s = State.crossing a b c h ∧ 0 < b)) ∧291    P.d.val ≤ stateContactT s ∧ (∀ h : ℕ, stateContactX s = some h → P.d.val ≤ h) ∧292    (0 < Dv none ↔ P.d.val < stateContactT s) ∧293    (∀ h : ℕ, stateContactX s = some h → (0 < Dv (zeroDirection k) ↔ P.d.val < h)) ∧294    exceptionalDegree k Dv = P.d.val := by295  obtain ⟨hdeg, hinf, hz, -⟩ := hD296  have hinf' : Dv none = P.rt.val := hinf297  cases s with298  | single a' c =>299    obtain ⟨rfl, hb, -⟩ := hsh300    obtain ⟨h0, -, h1, -, h3⟩ := hP301    refine ⟨h0, Or.inl ⟨c, rfl, hb⟩, h1, fun h hh => by simp [stateContactX] at hh, ?_,302      fun h hh => by simp [stateContactX] at hh, hdeg⟩303    rw [hinf']; exact h3304  | crossing a' b' c h =>305    obtain ⟨rfl, rfl, hb, -, -⟩ := hsh306    obtain ⟨h0, -, h1, h2, h3, h4⟩ := hP307    have hz' : Dv (zeroDirection k) = P.rx.val := hz308    refine ⟨h0, Or.inr ⟨c, h, rfl, hb⟩, h1, fun h' hh => ?_, ?_, fun h' hh => ?_, hdeg⟩309    · simp only [stateContactX, Option.some.injEq] at hh; subst hh; exact h2310    · rw [hinf']; exact h3311    · simp only [stateContactX, Option.some.injEq] at hh; subst hh; rw [hz']; exact h4312 313private theorem divisorStrictTransform_bijOn (m : ConcreteMember) (t x : m.R)314    (ht : t = surfaceT m.O m.pi m.u m.a m.b) (hx : x = surfaceX m.O m.pi m.u m.a m.b)315    (e : (BlowupChart m.R t x ⧸ chartExceptional m.R t x) ≃+* Polynomial316        (IsLocalRing.ResidueField m.R))317    (he : ∀ r : m.R, e (Ideal.Quotient.mk (chartExceptional m.R t x) (chartBase m.R t x r)) =318      Polynomial.C (IsLocalRing.residue m.R r))319    (heZ : e (Ideal.Quotient.mk (chartExceptional m.R t x) (chartSlope m.R t x)) = Polynomial.X)320    (hinf : (infinityPoint m.R t x).IsPrime)321    (P : TangentPattern m.s.degree) (hP : Allowed m.s P)322    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField m.R))323    (hD : HasPattern (IsLocalRing.ResidueField m.R) m.s Dv P) :324    Set.BijOn (fun J Q => divisorStrictTransform m.R t x e Dv hinf P.d.val J Q)325      (fixedTangentCell m.O m.R m.S m.s P.d.val Dv)326      (Set.pi Set.univ (childIdealSet m.R t x e Dv hinf m.s P.d.val)) := by327  subst ht hx328  obtain ⟨h1, h2, h3, h4, h5, h6, h7⟩ :=329    pattern_degree_facts_of_hasPattern (IsLocalRing.ResidueField m.R) m.a m.b m.s m.shape P hP Dv hD330  exact strict_transform_bijOn_child_ideals m.O m.pi m.hpi m.u m.a m.b m.ha m.S ⟨m.hS_t, m.hS_x,331      m.hS_a, m.hS_b⟩ e he332      heZ Dv hinf333    m.s P.d.val h1 h2 h3 h4 h5 h6 h7334 335/-! ### Cells and their children -/336 337/-- The child map `J ↦ (Φ J j)_j` is a bijection from the cell `c` of a concrete member onto the338product of the children's state sets. -/339theorem cell_child_bijOn (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c) :340    Set.BijOn (fun J j => D.Φ J j) (m.toMeasured.cell c)341        (Set.pi Set.univ fun j => (D.mc j).toMeasured.stateSet) := by342  have hF := divisorStrictTransform_bijOn m m.S.t m.S.x m.hS_t m.hS_x D.e D.he D.heZ D.hinf c.1.1343      c.1.2 c.2.1344      c.2.2345  set d := m.toMeasured.cellDegree c346  let T : (∀ Q, Ideal (divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf Q)) →347      ∀ j : m.toMeasured.childIdx c, Ideal (D.mc j).R :=348    fun u j => Ideal.map (D.Eq j : divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf (D.point j)349        →+* (D.mc j).R)350      (u (D.point j))351  have hmapmap : ∀ j (I : Ideal (divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf (D.point j))),352      Ideal.map ((D.Eq j).symm : (D.mc j).R →+* divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf353          (D.point j)) (Ideal.map354          (D.Eq j : divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf (D.point j) →+* (D.mc j).R)355          I) = I := fun j _ ↦ Ideal.map_of_equiv (D.Eq j)356  have hmapmap' : ∀ j (I : Ideal (D.mc j).R),357      Ideal.map (D.Eq j : divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf (D.point j) →+*358          (D.mc j).R) (Ideal.map359          ((D.Eq j).symm : (D.mc j).R →+* divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf360          (D.point j)) I) = I := fun j _ ↦ Ideal.map_of_equiv (D.Eq j).symm361  have hsurjpt : ∀ Q : divisorSupport c.2.1, ∃ j, D.point j = Q := by362    intro Q363    obtain ⟨j, hj⟩ := (D.asg.supp Q.1).mp Q.2364    exact ⟨j, Subtype.ext hj⟩365  have hbij : Function.Bijective (fun j => D.point j) :=366    ⟨fun i j h => D.asg.inj (congrArg Subtype.val h), hsurjpt⟩367  let σ := Equiv.ofBijective _ hbij368  have hT : Set.BijOn T (Set.pi Set.univ (childIdealSet m.R m.S.t m.S.x D.e c.2.1 D.hinf m.s d))369      (Set.pi Set.univ fun j => (D.mc j).toMeasured.stateSet) := by370    refine ⟨?_, ?_, ?_⟩371    · intro u hu j _372      exact (child_ideal_set_map_iff_stateSet m c D j (u (D.point j))).mp (hu _ (Set.mem_univ _))373    · intro u _ v _ huv374      funext Q375      obtain ⟨j, rfl⟩ := hsurjpt Q376      have := congrFun huv j377      rw [← hmapmap j (u (D.point j)), ← hmapmap j (v (D.point j))]378      exact congrArg _ this379    · intro w hw380      let v : ∀ j : m.toMeasured.childIdx c, Ideal381          (divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf (D.point j)) :=382        fun j => Ideal.map ((D.Eq j).symm : (D.mc j).R →+* divisorLocalRing m.R m.S.t m.S.x D.e383            c.2.1 D.hinf (D.point j)) (w j)384      let u := Equiv.piCongrLeft (fun Q => Ideal385          (divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf Q)) σ v386      have hu : ∀ j, u (D.point j) = v j := fun j => Equiv.piCongrLeft_apply_apply387          (fun Q => Ideal (divisorLocalRing m.R m.S.t m.S.x D.e c.2.1 D.hinf Q)) σ v j388      refine ⟨u, ?_, ?_⟩389      · intro Q _390        obtain ⟨j, rfl⟩ := hsurjpt Q391        rw [hu]392        apply (child_ideal_set_map_iff_stateSet m c D j _).mpr393        exact (hmapmap' j (w j)).symm ▸ hw j (Set.mem_univ _)394      · funext j395        change Ideal.map _ (u (D.point j)) = w j396        rw [hu]397        exact hmapmap' j (w j)398  have hcomp : (fun J j => D.Φ J j) =399      T ∘ (fun J Q => divisorStrictTransform m.R m.S.t m.S.x D.e c.2.1 D.hinf d J Q) := by400    funext J j401    exact cell_child_Phi_eq_map m c D J j402  rw [hcomp]403  exact hT.comp hF404 405/-- The residue polynomial `H = ∑ᵢ c̄ᵢ Xⁱ` of a family `c` has coefficients `c̄ᵢ`. -/406private theorem residue_sum_coeff {R : Type} [CommRing R] [IsLocalRing R] (d : ℕ)407    (c : Fin (d + 1) → R) (i : Fin (d + 1)) :408    (∑ j : Fin (d + 1), Polynomial.C (IsLocalRing.residue R (c j)) * Polynomial.X ^ j.val).coeff i =409      IsLocalRing.residue R (c i) := by410  simp only [Polynomial.finsetSum_coeff, Polynomial.coeff_C_mul_X_pow]411  rw [Finset.sum_eq_single i (fun j _ hj ↦ ite_eq_right fun h ↦ hj (Fin.ext h.symm)) (by simp)]412  simp413 414/-- The residue polynomial `H = ∑ᵢ c̄ᵢ Xⁱ` of a curve `∑ cᵢ tᵈ⁻ⁱ xⁱ` of multiplicity `d` on a415concrete surface is nonzero. -/416private theorem residue_sum_ne_zero (O : Type) [CommRing O] [IsDomain O]417    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O] (pi : O)418    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)419    [IsLocalRing (ConcreteSurface O pi u a b)] (d : ℕ)420    (c : Fin (d + 1) → (ConcreteSurface O pi u a b))421    (hne : ∃ i : Fin (d + 1), c i ∉ Ideal.span {(surfaceT O pi u a b), (surfaceX O pi u a b)}) :422    ∑ j : Fin (d + 1), Polynomial.C (IsLocalRing.residue _ (c j)) * Polynomial.X ^ j.val ≠ 0 := by423  obtain ⟨i, hi⟩ := hne424  intro h0425  have := residue_sum_coeff d c i426  rw [h0, Polynomial.coeff_zero, eq_comm, IsLocalRing.residue_eq_zero_iff,427    concrete_surface_maximalIdeal_eq O pi hpi u a b ha] at this428  exact hi this429 430/-- For a curve `f = ∑ cᵢ tᵈ⁻ⁱ xⁱ` of multiplicity `d` on a concrete surface and two-chart curve431data `D` of its strict transform, all point multiplicities in the `t`-chart are positive. -/432private theorem cell_datum_left_multiplicity_pos (O : Type) [CommRing O] [IsDomain O]433    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]434    [Finite (IsLocalRing.ResidueField O)] (pi : O) (hpi : Irreducible pi) (u : (TwoSeries O)ˣ)435    (a b : ℕ) (ha : 0 < a) [IsLocalRing (ConcreteSurface O pi u a b)] (d : ℕ)436    (c : Fin (d + 1) → (ConcreteSurface O pi u a b))437    (hne : ∃ i : Fin (d + 1), c i ∉ Ideal.span438    {(surfaceT O pi u a b), (surfaceX O pi u a b)})439    (e : ((BlowupChart (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)) ⧸440    chartExceptional (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)) ≃+*441    Polynomial (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))442    (he : ∀ r : (ConcreteSurface O pi u a b), e (Ideal.Quotient.mk443    (chartExceptional (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b))444    ((chartBase (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)) r)) =445    Polynomial.C (IsLocalRing.residue (ConcreteSurface O pi u a b) r))446    (heZ : e (Ideal.Quotient.mk447    (chartExceptional (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b))448    (chartSlope (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b))) =449    Polynomial.X) (beta : BlowupRestriction (ConcreteSurface O pi u a b) (surfaceT O pi u a b)450    (surfaceX O pi u a b)) (D : TwoChartCurveData (ConcreteSurface O pi u a b)451    (surfaceT O pi u a b) (surfaceX O pi u a b) beta)452    (hl : ∀ s : D.ι ⊕ D.ι0, leftData D s = completedPointMap453    (BlowupChart (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b))454    (leftPoint D s) (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)455    (BlowupChart (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)) (c i) *456    (chartSlope (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b))^i.val) ∧457    (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)458    (BlowupChart (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b)) (c i) *459    (chartSlope (ConcreteSurface O pi u a b) (surfaceT O pi u a b) (surfaceX O pi u a b))^i.val) ∈460    leftPoint D s) (s : D.ι ⊕ D.ι0) :461    0 < leftMultiplicity D s := by462  classical463  -- the point is a direction point `φ` dividing the residue polynomial `H`464  have : (Ideal.span ({surfaceT O pi u a b, surfaceX O pi u a b} : Set465      (ConcreteSurface O pi u a b))).IsMaximal :=466    concrete_surface_parameterIdeal_isMaximal O pi hpi u a b ha467  obtain ⟨hPmax, -, hPt⟩ := two_chart_left_points_maximal (ConcreteSurface O pi u a b) _ _468    beta D469  have := hPmax s470  obtain ⟨φ, hPφ, hmap, -⟩ := chart_point_eq_directionPoint _ _ _ e he heZ _ (hPt s)471  have hdvd : φ.val ∣ ∑ i : Fin (d + 1),472      Polynomial.C (IsLocalRing.residue _ (c i)) * Polynomial.X ^ i.val := by473    have hmem := (hl s).2474    rw [hPφ] at hmem475    unfold directionPoint at hmem476    rw [Ideal.mem_comap, Ideal.mem_span_singleton] at hmem477    convert hmem using 1478    simp only [RingHom.comp_apply, RingEquiv.toRingHom_eq_coe, RingHom.coe_coe, map_sum,479      map_mul, map_pow, heZ]480    exact Finset.sum_congr rfl fun i _ ↦ congrArg (· * _) (he (c i)).symm481  unfold leftMultiplicity leftLevelIdeal finiteLocalCurveIdeal482  rw [(hl s).1, pow_one, concrete_strict_transform_multiplicity O pi hpi u a b ha d c hne483    (leftPoint D s) (hPt s) e he heZ φ.val φ.property hmap, ENat.toNat_natCast]484  exact Multiset.count_pos.mpr ((UniqueFactorizationMonoid.mem_normalizedFactors_iff'485    (residue_sum_ne_zero O pi hpi u a b ha d c hne)).mpr486    ⟨φ.2.2, φ.2.1.normalize_eq_self, hdvd⟩)487 488/-- For a curve `f = ∑ cᵢ tᵈ⁻ⁱ xⁱ` of multiplicity `d` on a concrete surface and two-chart curve489data `D` of its strict transform, the multiplicities at the points of the `x`-chart away from the490`t`-chart are positive. -/491private theorem cell_datum_right_multiplicity_pos (O : Type) [CommRing O] [IsDomain O]492    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]493    [Finite (IsLocalRing.ResidueField O)] (pi : O) (hpi : Irreducible pi) (u : (TwoSeries O)ˣ)494    (a b : ℕ) (ha : 0 < a) [IsLocalRing (ConcreteSurface O pi u a b)] (d : ℕ)495    (c : Fin (d + 1) → (ConcreteSurface O pi u a b))496    (hne : ∃ i : Fin (d + 1), c i ∉ Ideal.span497    {(surfaceT O pi u a b), (surfaceX O pi u a b)})498    (beta : BlowupRestriction (ConcreteSurface O pi u a b) (surfaceT O pi u a b)499    (surfaceX O pi u a b)) (D : TwoChartCurveData (ConcreteSurface O pi u a b)500    (surfaceT O pi u a b) (surfaceX O pi u a b) beta)501    (hr : ∀ s : D.ι ⊕ D.ιinf, Ideal.span {rightData D s} = Ideal.span502    {completedPointMap (BlowupChart (ConcreteSurface O pi u a b) (surfaceX O pi u a b)503    (surfaceT O pi u a b)) (rightPoint D s) (∑ i : Fin (d+1), algebraMap504    (ConcreteSurface O pi u a b) (BlowupChart (ConcreteSurface O pi u a b) (surfaceX O pi u a b)505    (surfaceT O pi u a b)) (c i) * (chartSlope (ConcreteSurface O pi u a b) (surfaceX O pi u a b)506    (surfaceT O pi u a b))^(d - i.val))} ∧ (∑ i : Fin (d+1), algebraMap507    (ConcreteSurface O pi u a b) (BlowupChart (ConcreteSurface O pi u a b) (surfaceX O pi u a b)508    (surfaceT O pi u a b)) (c i) * (chartSlope (ConcreteSurface O pi u a b) (surfaceX O pi u a b)509    (surfaceT O pi u a b))^(d - i.val)) ∈ rightPoint D s) (l : D.ιinf) :510    0 < rightMultiplicity D (Sum.inr l) := by511  have : (Ideal.span ({surfaceT O pi u a b, surfaceX O pi u a b} : Set512      (ConcreteSurface O pi u a b))).IsMaximal :=513    concrete_surface_parameterIdeal_isMaximal O pi hpi u a b ha514  set H : Polynomial (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)) :=515    ∑ i : Fin (d+1), Polynomial.C (IsLocalRing.residue _ (c i)) * Polynomial.X ^ i.val with hH516  obtain ⟨hPmax, -, hPx⟩ := two_chart_right_points_maximal (ConcreteSurface O pi u a b) _ _517    beta D518  have hW := D.slopeinf l519  -- the top coefficient lies in the maximal ideal, so `H` has degree `< d`520  have hcd : c (Fin.last d) ∈ IsLocalRing.maximalIdeal _ := by521    by_contra hnot522    have hmem := (hr (Sum.inr l)).2523    rw [Fin.sum_univ_castSucc] at hmem524    simp only [Fin.val_last, Nat.sub_self, pow_zero, mul_one] at hmem525    refine (hPmax (Sum.inr l)).ne_top (Ideal.eq_top_of_isUnit_mem _526      ((Ideal.add_mem_iff_right _ (Ideal.sum_mem _ fun i _ ↦ ?_)).1 hmem)527      ((IsLocalRing.notMem_maximalIdeal.mp hnot).map _))528    have := i.isLt529    obtain ⟨k, hk⟩ := Nat.exists_eq_succ_of_ne_zero530      (by simp only [Fin.val_castSucc]; omega : d - (Fin.castSucc i).val ≠ 0)531    rw [hk, pow_succ]532    exact Ideal.mul_mem_left _ _ (Ideal.mul_mem_left _ _ hW)533  have hlt : H.natDegree < d := by534    refine (Polynomial.natDegree_sum_le_of_forall_le _ _ fun i _ ↦535      (Polynomial.natDegree_C_mul_X_pow_le _ _).trans (Nat.lt_succ_iff.mp i.isLt)).lt_of_ne536      fun h ↦ residue_sum_ne_zero O pi hpi u a b ha d c hne ?_537    rw [← Polynomial.leadingCoeff_eq_zero, Polynomial.leadingCoeff, h]538    simpa [IsLocalRing.residue_eq_zero_iff] using (residue_sum_coeff d c (Fin.last d)).trans539      ((IsLocalRing.residue_eq_zero_iff _).2 hcd)540  unfold rightMultiplicity rightLevelIdeal finiteLocalCurveIdeal541  rw [pow_one, Ideal.span_insert, (hr (Sum.inr l)).1, ← Ideal.span_insert,542    concrete_infinity_strict_transform_multiplicity O pi hpi u a b ha d c hne543      (rightPoint D (Sum.inr l)) (hPx _) hW, ENat.toNat_natCast, ← hH]544  omega545 546private theorem concrete_index_map_reindexed_of_eq (O : Type) [CommRing O] [IsDomain O]547    [IsDiscreteValuationRing O]548    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)549    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)550    (t x : ConcreteSurface O pi u a b) (ht : t = surfaceT O pi u a b)551    (hx : x = surfaceX O pi u a b) (beta : BlowupRestriction (ConcreteSurface O pi u a b) t x)552    (D : TwoChartCurveData (ConcreteSurface O pi u a b) t x beta) (f : ConcreteSurface O pi u a b)553    (G : GluedGenerators (ConcreteSurface O pi u a b) t x beta (curveDataDegree D))554    (hf : ∀ j : ℕ, surfaceToCechInput (ConcreteSurface O pi u a b) t x j f =555    (cechInputLattice (ConcreteSurface O pi u a b) t x j).mkQ556    (gluedFunctionPair (ConcreteSurface O pi u a b) t x G j))557    (hG : ∀ j : ℕ, Ideal.span558    {Ideal.Quotient.mk ((chartExceptional (ConcreteSurface O pi u a b) t x)^j) (G.left j)} =559    leftLevelKernel D j ∧ Ideal.span560    {Ideal.Quotient.mk ((chartExceptional (ConcreteSurface O pi u a b) x t)^j) (G.right j)} =561    rightLevelKernel D j) (n : ℕ) (e : Fin n ≃ AllPoints D) (B : Fin n → Type)562    [∀ j, CommRing (B j)] [∀ j, Algebra O (B j)] (eB : ∀ j, B j ≃+*563    (localRing D (e j) ⧸ Ideal.span {localCurve D (e j)}))564    (hB : ∀ (j : Fin n) (c : O), (eB j) (algebraMap O (B j) c) = Ideal.Quotient.mk565    (Ideal.span {localCurve D (e j)}) (localFromSurface D (e j)566    (algebraMap O (ConcreteSurface O pi u a b) c))) :567    ∃ ψ : ((ConcreteSurface O pi u a b) ⧸ Ideal.span {f}) →ₐ[O] ∀ j, B j, Function.Injective ψ ∧568        Module.length O ((∀ j, B j) ⧸ LinearMap.range ψ.toLinearMap) =569        (chooseTwo (curveDataDegree D) : ℕ∞) ∧ ∀ (r : (ConcreteSurface O pi u a b)) (j : Fin n),570        (eB j) (ψ (Ideal.Quotient.mk (Ideal.span {f}) r) j) = Ideal.Quotient.mk571        (Ideal.span {localCurve D (e j)}) (localFromSurface D (e j) r) := by572  subst ht hx573  exact concrete_index_map_reindexed O pi hpi u a b ha beta D f G hf hG n e B eB hB574 575/-- All common, left-only and right-only point multiplicities of two-chart curve data of a curve576of multiplicity `d` are positive, with the chart parameters given up to equality. -/577private theorem cell_datum_multiplicities_pos_of_eq (O : Type) [CommRing O] [IsDomain O]578    [IsDiscreteValuationRing O]579    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)580    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)581    (t x : ConcreteSurface O pi u a b) (ht : t = surfaceT O pi u a b)582    (hx : x = surfaceX O pi u a b) [IsLocalRing (ConcreteSurface O pi u a b)] (d : ℕ)583    (c : Fin (d + 1) → (ConcreteSurface O pi u a b))584    (hne : ∃ i : Fin (d + 1), c i ∉ Ideal.span {t, x})585    (e : ((BlowupChart (ConcreteSurface O pi u a b) t x) ⧸ chartExceptional586    (ConcreteSurface O pi u a b) t x) ≃+* Polynomial587    (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))588    (he : ∀ r : (ConcreteSurface O pi u a b), e (Ideal.Quotient.mk589    (chartExceptional (ConcreteSurface O pi u a b) t x)590    ((chartBase (ConcreteSurface O pi u a b) t x) r)) = Polynomial.C591    (IsLocalRing.residue (ConcreteSurface O pi u a b) r))592    (heZ : e (Ideal.Quotient.mk (chartExceptional (ConcreteSurface O pi u a b) t x)593    (chartSlope (ConcreteSurface O pi u a b) t x)) = Polynomial.X)594    (beta : BlowupRestriction (ConcreteSurface O pi u a b) t x)595    (D : TwoChartCurveData (ConcreteSurface O pi u a b) t x beta)596    (hl : ∀ s : D.ι ⊕ D.ι0, leftData D s = completedPointMap597    (BlowupChart (ConcreteSurface O pi u a b) t x) (leftPoint D s)598    (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)599    (BlowupChart (ConcreteSurface O pi u a b) t x) (c i) *600    (chartSlope (ConcreteSurface O pi u a b) t x)^i.val) ∧601    (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)602    (BlowupChart (ConcreteSurface O pi u a b) t x) (c i) *603    (chartSlope (ConcreteSurface O pi u a b) t x)^i.val) ∈ leftPoint D s)604    (hr : ∀ s : D.ι ⊕ D.ιinf, Ideal.span {rightData D s} = Ideal.span605    {completedPointMap (BlowupChart (ConcreteSurface O pi u a b) x t) (rightPoint D s)606       (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)607       (BlowupChart (ConcreteSurface O pi u a b) x t) (c i) *608       (chartSlope (ConcreteSurface O pi u a b) x t)^(d - i.val))} ∧609    (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)610    (BlowupChart (ConcreteSurface O pi u a b) x t) (c i) *611    (chartSlope (ConcreteSurface O pi u a b) x t)^(d - i.val)) ∈ rightPoint D s) :612    (∀ i : D.ι, 0 < commonMultiplicity D i) ∧ (∀ k : D.ι0, 0 < leftMultiplicity D (Sum.inr k)) ∧ ∀613        l : D.ιinf, 0 < rightMultiplicity D (Sum.inr l) := by614  subst ht hx615  refine ⟨fun i ↦ ?_, fun k ↦ cell_datum_left_multiplicity_pos O pi hpi u a b ha d c hne e he heZ616    beta D hl (Sum.inr k), cell_datum_right_multiplicity_pos O pi hpi u a b ha d c hne beta D hr⟩617  rw [← (two_chart_common_multiplicity_eq (ConcreteSurface O pi u a b) _ _ beta D i).1]618  exact cell_datum_left_multiplicity_pos O pi hpi u a b ha d c hne e he heZ beta D hl (Sum.inl i)619 620private theorem two_chart_datum_concrete_instances_of_eq (O : Type) [CommRing O] [IsDomain O]621    [IsDiscreteValuationRing O]622    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)623    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)624    (t x : ConcreteSurface O pi u a b) (ht : t = surfaceT O pi u a b)625    (hx : x = surfaceX O pi u a b) (beta : BlowupRestriction (ConcreteSurface O pi u a b) t x)626    (D : TwoChartCurveData (ConcreteSurface O pi u a b) t x beta) :627    (∀ s : D.ι ⊕ D.ι0, IsNoetherianRing (CompletedLocalAt628        (BlowupChart (ConcreteSurface O pi u a b) t x) (leftPoint D s)) ∧ Function.Injective629        (fun y : (CompletedLocalAt (BlowupChart (ConcreteSurface O pi u a b) t x)630        (leftPoint D s)) => (completedPointMap (BlowupChart (ConcreteSurface O pi u a b) t x)631        (leftPoint D s)) ((chartBase (ConcreteSurface O pi u a b) t x) t) * y)) ∧632        (∀ s : D.ι ⊕ D.ιinf, IsNoetherianRing (CompletedLocalAt633        (BlowupChart (ConcreteSurface O pi u a b) x t) (rightPoint D s)) ∧ Function.Injective634        (fun y : (CompletedLocalAt (BlowupChart (ConcreteSurface O pi u a b) x t)635        (rightPoint D s)) => (completedPointMap (BlowupChart (ConcreteSurface O pi u a b) x t)636        (rightPoint D s)) ((chartBase (ConcreteSurface O pi u a b) x t) x) * y)) ∧ ∀ p : AllPoints637        D, IsNoetherianRing (localRing D p) ∧ ∃ _ : IsLocalRing (localRing D p), IsAdicComplete638        (IsLocalRing.maximalIdeal (localRing D p)) (localRing D p) ∧ localException D p ∈639        IsLocalRing.maximalIdeal (localRing D p) := by640  subst ht hx641  exact two_chart_datum_concrete_instances O pi hpi u a b ha beta D642 643private theorem concrete_two_chart_glued_generators_exist_of_eq (O : Type) [CommRing O] [IsDomain O]644    [IsDiscreteValuationRing O]645    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)646    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)647    (t x : ConcreteSurface O pi u a b) (ht : t = surfaceT O pi u a b)648    (hx : x = surfaceX O pi u a b) (beta : BlowupRestriction (ConcreteSurface O pi u a b) t x)649    (D : TwoChartCurveData (ConcreteSurface O pi u a b) t x beta) :650    ∃ f : ConcreteSurface O pi u a b, ∃ G : GluedGenerators (ConcreteSurface O pi u a b) t x beta651        (curveDataDegree D), (∀ j : ℕ, surfaceToCechInput (ConcreteSurface O pi u a b) t x j f =652        (cechInputLattice (ConcreteSurface O pi u a b) t x j).mkQ653        (gluedFunctionPair (ConcreteSurface O pi u a b) t x G j)) ∧ ∀ j : ℕ, Ideal.span654        {Ideal.Quotient.mk ((chartExceptional (ConcreteSurface O pi u a b) t x)^j) (G.left j)} =655        leftLevelKernel D j ∧ Ideal.span656        {Ideal.Quotient.mk ((chartExceptional (ConcreteSurface O pi u a b) x t)^j) (G.right j)} =657        rightLevelKernel D j := by658  subst ht hx659  exact concrete_two_chart_glued_generators_exist O pi hpi u a b ha beta D660 661private theorem fixed_tangent_cell_curve_datum_of_eq (O : Type) [CommRing O] [IsDomain O]662    [IsDiscreteValuationRing O]663    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)664    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)665    (t x : ConcreteSurface O pi u a b) (ht : t = surfaceT O pi u a b)666    (hx : x = surfaceX O pi u a b) [IsDomain (ConcreteSurface O pi u a b)]667    [IsRegularLocalRing (ConcreteSurface O pi u a b)]668    (S : SurfaceData O (ConcreteSurface O pi u a b)) (hS : S.t = t ∧ S.x = x)669    (e : ((BlowupChart (ConcreteSurface O pi u a b) t x) ⧸ chartExceptional670    (ConcreteSurface O pi u a b) t x) ≃+* Polynomial671    (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)))672    (he : ∀ r : (ConcreteSurface O pi u a b), e (Ideal.Quotient.mk673    (chartExceptional (ConcreteSurface O pi u a b) t x)674    ((chartBase (ConcreteSurface O pi u a b) t x) r)) = Polynomial.C675    (IsLocalRing.residue (ConcreteSurface O pi u a b) r))676    (heZ : e (Ideal.Quotient.mk (chartExceptional (ConcreteSurface O pi u a b) t x)677    (chartSlope (ConcreteSurface O pi u a b) t x)) = Polynomial.X)678    (Dv : ExceptionalDivisor (IsLocalRing.ResidueField (ConcreteSurface O pi u a b))) (s : State)679    (d : ℕ) (J : Ideal (ConcreteSurface O pi u a b))680    (hJ : J ∈ fixedTangentCell O (ConcreteSurface O pi u a b) S s d Dv)681    (beta : BlowupRestriction (ConcreteSurface O pi u a b) t x) :682    ∃ (f : (ConcreteSurface O pi u a b)) (c : Fin (d+1) → (ConcreteSurface O pi u a b))683        (D : TwoChartCurveData (ConcreteSurface O pi u a b) t x beta), J = Ideal.span {f} ∧ f = ∑ i684        : Fin (d+1), c i * t^(d - i.val) * x^i.val ∧685        (∀ s : D.ι ⊕ D.ι0, leftData D s = completedPointMap686        (BlowupChart (ConcreteSurface O pi u a b) t x) (leftPoint D s)687        (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)688        (BlowupChart (ConcreteSurface O pi u a b) t x) (c i) *689        (chartSlope (ConcreteSurface O pi u a b) t x)^i.val) ∧690        (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)691        (BlowupChart (ConcreteSurface O pi u a b) t x) (c i) *692        (chartSlope (ConcreteSurface O pi u a b) t x)^i.val) ∈ leftPoint D s) ∧693        (∀ s : D.ι ⊕ D.ιinf, Ideal.span {rightData D s} = Ideal.span694        {completedPointMap (BlowupChart (ConcreteSurface O pi u a b) x t) (rightPoint D s)695           (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)696           (BlowupChart (ConcreteSurface O pi u a b) x t) (c i) *697           (chartSlope (ConcreteSurface O pi u a b) x t)^(d - i.val))} ∧698        (∑ i : Fin (d+1), algebraMap (ConcreteSurface O pi u a b)699        (BlowupChart (ConcreteSurface O pi u a b) x t) (c i) *700        (chartSlope (ConcreteSurface O pi u a b) x t)^(d - i.val)) ∈ rightPoint D s) ∧701        (∀ s : D.ι ⊕ D.ι0, strictTransformAt (ConcreteSurface O pi u a b) t x (leftPoint D s) d J =702        Ideal.span {leftData D s}) ∧ (∀ s : D.ι ⊕ D.ιinf, strictTransformAt703        (ConcreteSurface O pi u a b) x t (rightPoint D s) d J = Ideal.span {rightData D s}) ∧704        MatchesDivisor e D Dv ∧ curveDataDegree D = exceptionalDegree705        (IsLocalRing.ResidueField (ConcreteSurface O pi u a b)) Dv := by706  subst ht hx707  exact fixed_tangent_cell_curve_datum O pi hpi u a b ha S hS e he heZ Dv s d J hJ beta708 709/-- If a form `∑ᵢ cᵢ tᵈ⁻ⁱ xⁱ` of degree `d` does not lie in `(t, x)ᵈ⁺¹`, then some coefficient710`cᵢ` does not lie in `(t, x)`. -/711private theorem exists_coeff_notMem_span_of_notMem_pow {R : Type} [CommRing R] (t x : R) (d : ℕ)712    (c : Fin (d + 1) → R)713    (h : ∑ i : Fin (d + 1), c i * t ^ (d - i.val) * x ^ i.val ∉ Ideal.span {t, x} ^ (d + 1)) :714    ∃ i : Fin (d + 1), c i ∉ Ideal.span {t, x} := by715  by_contra! hc716  refine h (Ideal.sum_mem _ fun i _ ↦ ?_)717  have := Ideal.mul_mem_mul (hc i) (Ideal.mul_mem_mul718    (Ideal.pow_mem_pow (Ideal.subset_span (by simp) : t ∈ Ideal.span ({t, x} : Set R)) (d - i.val))719    (Ideal.pow_mem_pow (Ideal.subset_span (by simp) : x ∈ Ideal.span ({t, x} : Set R)) i.val))720  rw [← Ideal.IsTwoSided.pow_add, Nat.sub_add_cancel (Nat.lt_succ_iff.mp i.isLt)] at this721  rwa [mul_assoc, Ideal.IsTwoSided.pow_succ]722 723/-- **The index map of a cell.** For a cell ideal `J` of a concrete member and child quotients724`B j ≅ R_j ⧸ Φ J j`, there is an injective `O`-algebra map `R ⧸ J → ∏ B j` with cokernel of length725`d(d-1)/2` (`d` the cell degree), compatible with the child maps `α j`. -/726theorem cell_member_index_map (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c)Proposition 4.4727    (J : Ideal m.R) (hJ : J ∈ m.toMeasured.cell c) (B : m.toMeasured.childIdx c → Type)728    [∀ j, CommRing (B j)] [∀ j, Algebra m.O (B j)] (eB : ∀ j, B j ≃+* (D.mc j).R ⧸ D.Φ J j)729    (hB : ∀ (j : m.toMeasured.childIdx c) (r : m.O), eB j (algebraMap m.O (B j) r) =730    Ideal.Quotient.mk (D.Φ J j) (algebraMap m.O (D.mc j).R r)) :731    ∃ ψ : (m.R ⧸ J) →ₐ[m.O] ∀ j, B j, Function.Injective ψ ∧ Module.length m.O732        ((∀ j, B j) ⧸ LinearMap.range ψ.toLinearMap) = (chooseTwo (m.toMeasured.cellDegree c) : ℕ∞)733        ∧ ∀ (r : m.R) (j : m.toMeasured.childIdx c), eB j (ψ (Ideal.Quotient.mk J r) j) =734        Ideal.Quotient.mk (D.Φ J j) (D.alpha j r) := by735  set d := m.toMeasured.cellDegree c736  obtain ⟨beta⟩ := actual_blowup_restriction_exists m.R m.S.t m.S.x737  obtain ⟨f, cf, Df, hJf, hcf, hl, hr, hstl, hstr, hmatch, hdeg⟩ :=738    fixed_tangent_cell_curve_datum_of_eq m.O m.pi m.hpi m.u m.a m.b m.ha m.S.t m.S.x m.hS_t m.hS_x739      m.S ⟨rfl, rfl⟩ D.e D.he D.heZ c.2.1 m.s d J hJ beta740  have hdeg' : curveDataDegree Df = d := hdeg.trans c.2.2.1741  have hreg : RegularParameterPair m.R m.S.t m.S.x := by742    rw [m.hS_t, m.hS_x]743    exact concrete_surface_regular_pair_tx m.O m.pi m.hpi.ne_zero m.u m.a m.b m.ha744  have hregSwap : RegularParameterPair m.R m.S.x m.S.t := by745    rw [m.hS_t, m.hS_x]746    exact concrete_surface_regular_pair_xt m.O m.pi m.hpi.ne_zero m.u m.a m.b m.ha747  have hmultJ := has_tangent_divisor_multiplicity m.O m.R m.S hreg J d c.2.1 hJ.2748  have hmax : IsLocalRing.maximalIdeal m.R = Ideal.span {m.S.t, m.S.x} := by749    rw [concrete_surface_maximalIdeal_eq m.O m.pi m.hpi m.u m.a m.b m.ha, surfaceParameterIdeal,750        m.hS_t, m.hS_x]751  have hd : f ∈ (Ideal.span {m.S.t, m.S.x})^d := by752    have := hmultJ.1; rwa [hJf, Ideal.span_singleton_le_iff_mem, hmax] at this753  have hmult : f ∉ (Ideal.span {m.S.t, m.S.x})^(d+1) := by754    have := hmultJ.2; rwa [hJf, Ideal.span_singleton_le_iff_mem, hmax] at this755  have hne : ∃ i : Fin (d+1), cf i ∉ Ideal.span {m.S.t, m.S.x} :=756    exists_coeff_notMem_span_of_notMem_pow m.S.t m.S.x d cf (hcf ▸ hmult)757  have hpos := cell_datum_multiplicities_pos_of_eq m.O m.pi m.hpi m.u m.a m.b m.ha m.S.t m.S.x758    m.hS_t m.hS_x d cf hne D.e D.he D.heZ beta Df hl hr759  obtain ⟨ee, hee⟩ := cell_datum_point_equiv m c D J beta Df ⟨hstl, hstr⟩ hmatch hpos760  choose ι hι1 hι2 using hee761  obtain ⟨f', G, hf', hG⟩ := concrete_two_chart_glued_generators_exist_of_eq m.O m.pi m.hpi m.u m.a762    m.b m.ha m.S.t m.S.x m.hS_t m.hS_x beta Df763  have : (Ideal.span ({m.S.t, m.S.x} : Set m.R)).IsMaximal := by764    rw [m.hS_t, m.hS_x]765    exact concrete_surface_parameterIdeal_isMaximal m.O m.pi m.hpi m.u m.a m.b m.ha766  have : IsNoetherianRing m.R := concrete_surface_isNoetherianRing m.O m.pi m.u m.a m.b767  have : IsNoetherianRing (BlowupChart m.R m.S.t m.S.x) :=768    blowupChart_concrete_isNoetherianRing m.O m.pi m.u m.a m.b _ _769  have : IsNoetherianRing (BlowupChart m.R m.S.x m.S.t) :=770    blowupChart_concrete_isNoetherianRing m.O m.pi m.u m.a m.b _ _771  have hregF := fun j ↦ two_chart_left_generators_regular_on_overlap m.R m.S.t m.S.x beta Df _ G772    hG hreg hregSwap j773  have h910 := two_chart_datum_concrete_instances_of_eq m.O m.pi m.hpi m.u m.a m.b m.ha m.S.t m.S.x774    m.hS_t m.hS_x beta Df775  have hmem := strict_transforms_give_level_lattice_membership m.R m.S.t m.S.x beta Df776    (curveDataDegree Df) G hG f (hdeg' ▸ hd) (fun s ↦ by rw [hdeg', ← hJf]; exact hstl s)777    (fun s ↦ by rw [hdeg', ← hJf]; exact hstr s)778  have hJf' : J = Ideal.span {f'} := hJf.trans <| parent_ideal_unique_of_level_lattice m.R m.S.t779    m.S.x hreg hregSwap beta _ G hregF f' hf' f hmem (hdeg' ▸ hmult)780  have hmapΦ : ∀ j, Ideal.span {localCurve Df (ee j)} =781      (D.Φ J j).map (((D.Eq j).symm.trans (ι j) : (D.mc j).R ≃+* localRing Df (ee j)) :782        (D.mc j).R →+* localRing Df (ee j)) := by783    intro j784    rw [cell_child_Phi_eq_map m c D J j, Ideal.map_map, ← hι2 j]785    congr 1786    ext y787    simp788  let qE : ∀ j, (D.mc j).R ⧸ D.Φ J j ≃+* localRing Df (ee j) ⧸ Ideal.span {localCurve Df (ee j)} :=789    fun j => Ideal.quotientEquiv _ _ ((D.Eq j).symm.trans (ι j)) (hmapΦ j)790  have hqE : ∀ j (r : m.R), qE j (Ideal.Quotient.mk (D.Φ J j) (D.alpha j r)) =791      Ideal.Quotient.mk _ (localFromSurface Df (ee j) r) := by792    intro j r793    change Ideal.Quotient.mk _ (ι j794        ((D.Eq j).symm (D.Eq j (divisorFromSurface m.R m.S.t m.S.x D.e c.2.1 D.hinf795      (D.point j) r)))) = _796    rw [RingEquiv.symm_apply_apply, hι1]797  let eB' : ∀ j, B j ≃+* localRing Df (ee j) ⧸ Ideal.span {localCurve Df (ee j)} :=798    fun j => (eB j).trans (qE j)799  have hB' : ∀ (j : m.toMeasured.childIdx c) (r : m.O), eB' j (algebraMap m.O (B j) r) =800      Ideal.Quotient.mk (Ideal.span {localCurve Df (ee j)})801          (localFromSurface Df (ee j) (algebraMap m.O m.R r)) := by802    intro j r803    change qE j (eB j (algebraMap m.O (B j) r)) = _804    rw [hB, ← (D.alpha j).commutes r, hqE]805  obtain ⟨ψ', hinj, hlen, hform⟩ := concrete_index_map_reindexed_of_eq m.O m.pi m.hpi m.u m.a m.b806    m.ha m.S.t m.S.x m.hS_t m.hS_x beta Df f' G hf' hG _ ee B eB' hB'807  let E := Ideal.quotientEquivAlgOfEq m.O hJf'808  refine ⟨ψ'.comp E.toAlgHom, hinj.comp E.injective, ?_, fun r j ↦ (qE j).injective ?_⟩809  · rw [AlgHom.comp_toLinearMap, LinearMap.range_comp_of_range_eq_top _810      (LinearMap.range_eq_top.mpr E.surjective), hlen, hdeg']811  · rw [hqE]812    exact hform r j813 814private theorem one_le_chooseTwo_of_selfPattern (s : State) (hv : s.Valid)815    (hnt : s.terminal = false)816    (P : TangentPattern s.degree)817    (hA : Allowed s P) (hs : SelfPattern s P) : 1 ≤ chooseTwo P.d.val := by818  cases s with819  | crossing a b c h =>820    obtain ⟨a', c', h', -⟩ := hs821    cases h'822  | single a c₀ =>823    obtain ⟨a', c', h', hch⟩ := hs824    cases h'825    have hc : 2 ≤ c₀ := by826      rcases hv with ⟨-, hc0⟩827      by_contra hlt828      have : c₀ = 1 := by omega829      subst this830      simp [State.terminal] at hnt831    have := (self_patterns_of_single_state a c₀ 2 hv.1 hc).1 P hA ⟨a, c₀, rfl, hch⟩832    rw [this.1]833    unfold chooseTwo834    apply Nat.div_pos _ (by norm_num)835    rcases c₀ with _ | _ | k836    · omega837    · omega838    · simp only [Nat.add_sub_cancel]; nlinarith839 840/-- The child quotients `B j ≅ R_j ⧸ Φ J j` of a cell ideal are free and finite over `O_j`. -/841private theorem cellChild_free_finite (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c)842    (J : Ideal m.R) (hJ : J ∈ m.toMeasured.cell c) (B : m.toMeasured.childIdx c → Type)843    [∀ j, CommRing (B j)] (eB : ∀ j, B j ≃+* (D.mc j).R ⧸ D.Φ J j)844    [∀ j, Algebra (D.mc j).O (B j)] (hBalg : ∀ (j : m.toMeasured.childIdx c)845    (o : (D.mc j).O), eB j (algebraMap (D.mc j).O (B j) o) = Ideal.Quotient.mk (D.Φ J j)846    (algebraMap (D.mc j).O (D.mc j).R o)) (j : m.toMeasured.childIdx c) :847    Module.Free (D.mc j).O (B j) ∧ Module.Finite (D.mc j).O (B j) := by848  have hmem : D.Φ J j ∈ (D.mc j).toMeasured.stateSet :=849    (cell_child_bijOn m c D).mapsTo hJ j (Set.mem_univ j)850  obtain ⟨_, _, -⟩ := concrete_member_curve_order_free (D.mc j) _ hmem851  let e : B j ≃ₐ[(D.mc j).O] (D.mc j).R ⧸ D.Φ J j :=852    AlgEquiv.ofRingEquiv (f := eB j) fun o ↦ by rw [hBalg j o]; rfl853  exact ⟨.of_equiv e.symm.toLinearEquiv, .equiv e.symm.toLinearEquiv⟩854 855/-- Termination data for the children of a cell ideal with algebra type `σ`: each child has an856algebra type, and its order defect is at most that of `R ⧸ J`, strictly smaller on self cells. -/857private theorem cell_child_termination_data (m : ConcreteMember) (c : m.cellIndex)858    (hnt : m.s.terminal = false) (D : CellChildData m c) (J : Ideal m.R)859    (hJ : J ∈ m.toMeasured.cell c) (B : m.toMeasured.childIdx c → Type) [∀ j, CommRing (B j)]860    [∀ j, Algebra m.O (B j)] (eB : ∀ j, B j ≃+* (D.mc j).R ⧸ D.Φ J j)861    (hB : ∀ (j : m.toMeasured.childIdx c) (r : m.O), eB j (algebraMap m.O (B j) r) =862    Ideal.Quotient.mk (D.Φ J j) (algebraMap m.O (D.mc j).R r)) [∀ j, Algebra (D.mc j).O (B j)]863    [∀ j, IsScalarTower m.O (D.mc j).O (B j)] (hBalg : ∀ (j : m.toMeasured.childIdx c)864    (o : (D.mc j).O), eB j (algebraMap (D.mc j).O (B j) o) = Ideal.Quotient.mk (D.Φ J j)865    (algebraMap (D.mc j).O (D.mc j).R o)) (σ : FactorType) (hσ : HasAlgebraType m.O (m.R ⧸ J) σ) :866    ∀ j, (∃ τ : FactorType, HasAlgebraType (D.mc j).O (B j) τ) ∧867        (orderDefect (D.mc j).O (B j)).toNat ≤ (orderDefect m.O (m.R ⧸ J)).toNat ∧868        (m.toMeasured.IsSelfCell c → (orderDefect (D.mc j).O (B j)).toNat <869        (orderDefect m.O (m.R ⧸ J)).toNat) := by870  obtain ⟨ψ, hψi, hlen, -⟩ := cell_member_index_map m c D J hJ B eB hB871  obtain ⟨hfree, hfin, -⟩ := concrete_member_curve_order_free m J hJ.1872  have hfr := cellChild_free_finite m c D J hJ B eB hBalg873  have key := @concrete_termination_data_of_index_map m _ (fun j => D.mc j) _ _ _874    (fun j => m.toMeasured.childDelta c j) (fun j => (D.child j).hrank)875    (fun j => by rw [← (D.child j).hpi]; exact (D.mc j).hpi) J B _ _ _ _ (fun j => (hfr j).2)876    (fun j => (hfr j).1) ψ hψi (chooseTwo (m.toMeasured.cellDegree c)) hlen hfin hfree σ hσ877  intro j878  obtain ⟨h1, h2, h3⟩ := key j879  exact ⟨h1, h2, fun hs ↦880    h3 (one_le_chooseTwo_of_selfPattern m.s m.toMeasured.valid hnt c.1.1 c.1.2 hs)⟩881 882/-- **Type additivity.** If the children `B j` of a cell ideal `J` have algebra types `τ j`, then883`R ⧸ J` has algebra type `∑ j, scaleType δ_j (τ j)`. -/884private theorem cell_child_type_add (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c)885    (J : Ideal m.R) (hJ : J ∈ m.toMeasured.cell c) (B : m.toMeasured.childIdx c → Type)886    [∀ j, CommRing (B j)] [∀ j, Algebra m.O (B j)] (eB : ∀ j, B j ≃+* (D.mc j).R ⧸ D.Φ J j)887    (hB : ∀ (j : m.toMeasured.childIdx c) (r : m.O), eB j (algebraMap m.O (B j) r) =888    Ideal.Quotient.mk (D.Φ J j) (algebraMap m.O (D.mc j).R r)) [∀ j, Algebra (D.mc j).O (B j)]889    [∀ j, IsScalarTower m.O (D.mc j).O (B j)] (hBalg : ∀ (j : m.toMeasured.childIdx c)890    (o : (D.mc j).O), eB j (algebraMap (D.mc j).O (B j) o) = Ideal.Quotient.mk (D.Φ J j)891    (algebraMap (D.mc j).O (D.mc j).R o)) (τ : m.toMeasured.childIdx c → FactorType)892    (hτ : ∀ j, HasAlgebraType (D.mc j).O (B j) (τ j)) :893    HasAlgebraType m.O (m.R ⧸ J) (∑ j, scaleType (m.toMeasured.childDelta c j) (τ j)) := by894  obtain ⟨ψ, hψ, hlen, -⟩ := cell_member_index_map m c D J hJ B eB hB895  have hfr := cellChild_free_finite m c D J hJ B eB hBalg896  have : ∀ j, Module.Free (D.mc j).O (B j) := fun j ↦ (hfr j).1897  have : ∀ j, Module.Finite (D.mc j).O (B j) := fun j ↦ (hfr j).2898  exact concrete_type_add_of_index_map m _ D.mc (m.toMeasured.childDelta c)899    (fun j => (D.child j).hrank) (fun j => by rw [← (D.child j).hpi]; exact (D.mc j).hpi) J B ψ hψ900        _ hlen τ hτ901 902/-! ### Every state ideal lies in a cell -/903 904/-- Every ideal in a state set of a concrete surface has a positive multiplicity `d`. -/905private theorem state_ideal_has_multiplicity (O : Type) [CommRing O] [IsDomain O]906    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]907    [Finite (IsLocalRing.ResidueField O)] (pi : O) (hpi : Irreducible pi) (u : (TwoSeries O)ˣ)908    (a b : ℕ) (ha : 0 < a) [IsDomain (ConcreteSurface O pi u a b)]909    [IsRegularLocalRing (ConcreteSurface O pi u a b)]910    (S : SurfaceData O (ConcreteSurface O pi u a b)) (hSt : S.t = surfaceT O pi u a b) (s : State)911    (J : Ideal (ConcreteSurface O pi u a b))912    (hJ : J ∈ surfaceStateSet O (ConcreteSurface O pi u a b) S s) :913    ∃ d : ℕ, 0 < d ∧ HasMultiplicity (ConcreteSurface O pi u a b) J d := by914  classical915  set R := ConcreteSurface O pi u a b916  obtain ⟨f, hf⟩ := hJ.1917  have hfm : f ∈ IsLocalRing.maximalIdeal R :=918    surface_state_generator_mem_maximal O R S s J hJ f hf919  -- contact is finite920  have hfin : ∃ c : ℕ, idealContact R J S.t = c := by921    have h2 := hJ.2.2922    cases s with923    | single a' c => exact ⟨c, h2.2.2⟩924    | crossing a' b' c h => exact ⟨c, h2.2.2.1⟩925  have hf0 : f ≠ 0 := by926    intro h0927    obtain ⟨c, hc⟩ := hfin928    have hJ0 : J = ⊥ := by rw [hf, h0]; simp929    unfold idealContact at hc930    rw [hJ0, hSt] at hc931    obtain ⟨q, -⟩ := concrete_surface_quotient_T_equiv O pi hpi u a b ha932    let e : (R ⧸ (⊥ ⊔ Ideal.span {surfaceT O pi u a b})) ≃+*933        (PowerSeries (IsLocalRing.ResidueField O) ⧸934          Ideal.span {(0 : PowerSeries (IsLocalRing.ResidueField O))}) :=935      (Ideal.quotEquivOfEq (by simp)).trans936        (q.trans ((RingEquiv.quotientBot _).symm.trans937          (Ideal.quotEquivOfEq (by simp)).symm))938    have := quotient_ring_length_intrinsic _ _ _ _ e939    have h3 := (powerSeries_quotient_length_eq_order (IsLocalRing.ResidueField O) 0).1940    rw [hc] at this941    rw [← this] at h3942    simp at h3943  have hne : IsLocalRing.maximalIdeal R ≠ ⊤ := IsLocalRing.maximalIdeal.isMaximal R |>.ne_top944  have hK := iInf_sup_pow_eq_of_isLocalRing R (IsLocalRing.maximalIdeal R) ⊥ hne945  have hex : ∃ n : ℕ, f ∉ (IsLocalRing.maximalIdeal R)^(n+1) := by946    by_contra hcon947    push Not at hcon948    have : f ∈ (⨅ n : ℕ, ⊥ ⊔ (IsLocalRing.maximalIdeal R)^n) := by949      rw [Ideal.mem_iInf]950      intro n951      rcases n with _ | n952      · simp953      · simpa using hcon n954    rw [hK] at this955    exact hf0 (by simpa using this)956  have hpos : Nat.find hex ≠ 0 := fun h0 ↦ by957    have := Nat.find_spec hex958    rw [h0] at this959    exact this (by simpa using hfm)960  refine ⟨Nat.find hex, Nat.pos_of_ne_zero hpos, ?_,961    fun hle ↦ Nat.find_spec hex (hle (hf ▸ Ideal.mem_span_singleton_self f))⟩962  rw [hf, Ideal.span_le, Set.singleton_subset_iff]963  obtain ⟨k, hk⟩ : ∃ k, Nat.find hex = k + 1 := ⟨Nat.find hex - 1, by omega⟩964  rw [hk]965  exact not_not.mp (Nat.find_min hex (show k < Nat.find hex by omega))966 967private theorem le_and_lt_iff_of_natCast_eq_add (d c : ℕ) (ℓ : ℕ∞) (h : (c : ℕ∞) = (d : ℕ∞) + ℓ) :968    d ≤ c ∧ (d < c ↔ ℓ ≠ 0) := by969  induction ℓ using ENat.recTopCoe with970  | top => simp at h971  | coe n =>972    obtain rfl : c = d + n := by exact_mod_cast h973    exact ⟨by omega, by simp; omega⟩974 975/-- For a state ideal `J = (f)` with `f = ∑ cᵢ tᵈ⁻ⁱ xⁱ` of multiplicity `d`, the multiplicity is976bounded by the contact orders of the state, with strict inequality exactly when the corresponding977boundary coefficient lies in the maximal ideal. -/978private theorem state_ideal_multiplicity_le_contacts (O : Type) [CommRing O] [IsDomain O]979    [IsDiscreteValuationRing O] [IsAdicComplete (IsLocalRing.maximalIdeal O) O]980    [Finite (IsLocalRing.ResidueField O)] (pi : O) (hpi : Irreducible pi) (u : (TwoSeries O)ˣ)981    (a b : ℕ) (ha : 0 < a) [IsDomain (ConcreteSurface O pi u a b)]982    [IsRegularLocalRing (ConcreteSurface O pi u a b)]983    (S : SurfaceData O (ConcreteSurface O pi u a b)) (hSt : S.t = surfaceT O pi u a b)984    (hSx : S.x = surfaceX O pi u a b) (s : State) (J : Ideal (ConcreteSurface O pi u a b))985    (hJ : J ∈ surfaceStateSet O (ConcreteSurface O pi u a b) S s) (d : ℕ)986    (f : (ConcreteSurface O pi u a b)) (hf : J = Ideal.span {f})987    (c : Fin (d + 1) → (ConcreteSurface O pi u a b))988    (hc : f = (∑ i : Fin (d + 1), c i * (surfaceT O pi u a b) ^ (d - i.val) *989    (surfaceX O pi u a b) ^ i.val)) :990    match s with991    | State.single _ c₀ =>992      d ≤ c₀ ∧ (d < c₀ ↔ c (Fin.last d) ∈ IsLocalRing.maximalIdeal (ConcreteSurface O pi u a b))993    | State.crossing _ _ c₀ h₀ =>994      d ≤ c₀ ∧ (d < c₀ ↔ c (Fin.last d) ∈ IsLocalRing.maximalIdeal (ConcreteSurface O pi u a b)) ∧995        d ≤ h₀ ∧ (d < h₀ ↔ c 0 ∈ IsLocalRing.maximalIdeal (ConcreteSurface O pi u a b)) := by996  set t := surfaceT O pi u a b997  set x := surfaceX O pi u a b998  have hpi0 : pi ≠ 0 := hpi.ne_zero999  have hmax : IsLocalRing.maximalIdeal (ConcreteSurface O pi u a b) = Ideal.span {t, x} := by1000    rw [← S.parameters, hSt, hSx]1001  have hmax' : IsLocalRing.maximalIdeal (ConcreteSurface O pi u a b) = Ideal.span {x, t} := by1002    rw [hmax, Ideal.span_pair_comm]1003  have : (Ideal.span ({t, x} : Set (ConcreteSurface O pi u a b))).IsMaximal := by1004    rw [← hmax]; exact IsLocalRing.maximalIdeal.isMaximal (ConcreteSurface O pi u a b)1005  have : (Ideal.span ({x, t} : Set (ConcreteSurface O pi u a b))).IsMaximal := by1006    rw [← hmax']; exact IsLocalRing.maximalIdeal.isMaximal (ConcreteSurface O pi u a b)1007  -- t-contact1008  have ht := (boundary_contact_of_twisted_generator (ConcreteSurface O pi u a b) t x1009    (concrete_surface_regular_pair_tx O pi hpi0 u a b ha) d f c hc).21010  have htn := boundary_contact_length_ne_zero_iff (ConcreteSurface O pi u a b) t x hmax d c1011  -- x-contact1012  have hc' : f = ∑ j : Fin (d+1), c (Fin.rev j) * x^(d - j.val) * t^j.val := by1013    rw [hc, ← Equiv.sum_comp Fin.revPerm]1014    refine Finset.sum_congr rfl fun j _ => ?_1015    simp only [Fin.revPerm_apply, Fin.val_rev]1016    have hj := j.isLt1017    rw [show d - (d + 1 - (j.val + 1)) = j.val by omega,1018      show d + 1 - (j.val + 1) = d - j.val by omega]1019    ring1020  have hx := (boundary_contact_of_twisted_generator (ConcreteSurface O pi u a b) x t1021    (concrete_surface_regular_pair_xt O pi hpi0 u a b ha) d f (fun j => c (Fin.rev j)) hc').21022  have hxn := boundary_contact_length_ne_zero_iff (ConcreteSurface O pi u a b) x t hmax' d1023      (fun j => c (Fin.rev j))1024  simp only [Fin.rev_last] at hxn1025  obtain ⟨-, -, hs⟩ := hJ1026  rw [hf] at hs1027  cases s with1028  | single a' c₀ =>1029    obtain ⟨-, -, h1⟩ := hs1030    unfold idealContact at h11031    rw [hSt, ht] at h11032    exact (le_and_lt_iff_of_natCast_eq_add d c₀ _ h1.symm).imp_right (·.trans htn)1033  | crossing a' b' c₀ h₀ =>1034    obtain ⟨-, -, h1, h2⟩ := hs1035    unfold idealContact at h1 h21036    rw [hSt, ht] at h11037    rw [hSx, hx] at h21038    have e1 := le_and_lt_iff_of_natCast_eq_add d c₀ _ h1.symm1039    have e2 := le_and_lt_iff_of_natCast_eq_add d h₀ _ h2.symm1040    exact ⟨e1.1, e1.2.trans htn, e2.1, e2.2.trans hxn⟩1041 1042private theorem allowed_pattern_of_cell_ideal (O : Type) [CommRing O] [IsDomain O]1043    [IsDiscreteValuationRing O]1044    [IsAdicComplete (IsLocalRing.maximalIdeal O) O] [Finite (IsLocalRing.ResidueField O)] (pi : O)1045    (hpi : Irreducible pi) (u : (TwoSeries O)ˣ) (a b : ℕ) (ha : 0 < a)1046    [IsDomain (ConcreteSurface O pi u a b)] [IsRegularLocalRing (ConcreteSurface O pi u a b)]1047    (S : SurfaceData O (ConcreteSurface O pi u a b)) (hSt : S.t = surfaceT O pi u a b)1048    (hSx : S.x = surfaceX O pi u a b) (s : State) (J : Ideal (ConcreteSurface O pi u a b))1049    (hJ : J ∈ surfaceStateSet O (ConcreteSurface O pi u a b) S s) (d : ℕ)1050    (f : (ConcreteSurface O pi u a b)) (hf : J = Ideal.span {f})1051    (c : Fin (d + 1) → (ConcreteSurface O pi u a b))1052    (hc : f = (∑ i : Fin (d + 1), c i * (surfaceT O pi u a b) ^ (d - i.val) *1053        (surfaceX O pi u a b) ^ i.val))1054    {k : Type} [Field k] (Dv : ExceptionalDivisor k)1055    (e1 : 0 < Dv (infinityDirection k) ↔ c (Fin.last d) ∈ IsLocalRing.maximalIdeal1056        (ConcreteSurface O pi u a b))1057    (e0 : 0 < Dv (zeroDirection k) ↔ c 0 ∈ IsLocalRing.maximalIdeal (ConcreteSurface O pi u a b))1058    (hs : s.Valid) [Finite k] (hd : 0 < d) (hdeg : exceptionalDegree k Dv = d)1059    (hQ : ∀ Q, 0 < Dv Q → directionDegree k Q ≤ d) (hmult : ∀ Q, Dv Q ≤ d) :1060    ∃ P : TangentPattern s.degree, P.d.val = d ∧ Allowed s P ∧ HasPattern k s Dv P := by1061  have hcon := state_ideal_multiplicity_le_contacts O pi hpi u a b ha S hSt hSx s J hJ1062    d f hf c hc1063  cases s with1064  | single a' c' =>1065    obtain ⟨h1, h2⟩ := hcon1066    exact allowed_pattern_of_divisor k _ hs Dv d hd hdeg hQ hmult ⟨h1, e1.trans h2.symm⟩1067  | crossing a' b' c' h' =>1068    obtain ⟨h1, h2, h3, h4⟩ := hcon1069    exact allowed_pattern_of_divisor k _ hs Dv d hd hdeg hQ hmult1070      ⟨h1, e1.trans h2.symm, h3, e0.trans h4.symm⟩1071 1072/-- The cells of a concrete member cover its state set. -/1073theorem concrete_member_cells_cover (m : ConcreteMember) :Proposition 6.11074    m.toMeasured.stateSet = ⋃ c : m.toMeasured.cellIndex, m.toMeasured.cell c := by1075  ext J1076  simp only [Set.mem_iUnion]1077  refine ⟨fun hJ ↦ ?_, fun ⟨_, hc⟩ ↦ hc.1⟩1078  change J ∈ surfaceStateSet m.O m.R m.S m.s at hJ1079  obtain ⟨d, hd, hmul⟩ := state_ideal_has_multiplicity m.O m.pi m.hpi m.u m.a m.b m.ha m.S1080    m.hS_t m.s J hJ1081  obtain ⟨f, hf⟩ := hJ.11082  have hf1 : f ∈ (IsLocalRing.maximalIdeal m.R)^d :=1083    hmul.1 (hf ▸ Ideal.subset_span (Set.mem_singleton f))1084  have hf2 : f ∉ (IsLocalRing.maximalIdeal m.R)^(d+1) := fun h ↦1085    hmul.2 (by rw [hf, Ideal.span_le, Set.singleton_subset_iff]; exact h)1086  have hmax : IsLocalRing.maximalIdeal m.R = Ideal.span {surfaceT m.O m.pi m.u m.a m.b,1087      surfaceX m.O m.pi m.u m.a m.b} := by1088    rw [← m.hS_t, ← m.hS_x]; exact m.S.parameters.symm1089  obtain ⟨c, hc, i₀, hi₀⟩ := has_multiplicity_initial_form m.R _ _ hmax d f hf1 hf21090  set H : Polynomial (IsLocalRing.ResidueField m.R) :=1091    ∑ i : Fin (d+1), Polynomial.C (IsLocalRing.residue m.R (c i)) * Polynomial.X^i.val with hH1092  have hcoeff : ∀ n : Fin (d+1), H.coeff n = IsLocalRing.residue m.R (c n) := by1093    intro n1094    rw [hH, Polynomial.finsetSum_coeff]1095    simp only [Polynomial.coeff_C_mul_X_pow, Fin.val_inj]1096    simp1097  have hH0 : H ≠ 0 := by1098    intro h01099    have := hcoeff i₀1100    rw [h0, Polynomial.coeff_zero, eq_comm, IsLocalRing.residue_eq_zero_iff] at this1101    exact hi₀ this1102  have hdeg : H.natDegree ≤ d := by1103    rw [hH]1104    refine Polynomial.natDegree_sum_le_of_forall_le _ _ (fun i _ => ?_)1105    exact (Polynomial.natDegree_C_mul_X_pow_le _ _).trans (Nat.lt_succ_iff.mp i.isLt)1106  obtain ⟨Dv, hDv, hinf, haff, hdegDv⟩ := homogeneous_divisor_of_polynomial _ d H hH0 hdeg1107  have hT := initial_form_has_tangent_divisor m.O m.R m.S d f c1108    (by rw [m.hS_t, m.hS_x]; exact hc) H hH Dv hDv1109  obtain ⟨b1, b2, b3, b4⟩ := homogeneous_divisor_boundary_multiplicities _ d H hH0 hdeg Dv hinf1110      haff1111  have e1 : 0 < Dv (infinityDirection _) ↔ c (Fin.last d) ∈ IsLocalRing.maximalIdeal m.R := by1112    rw [b1, ← IsLocalRing.residue_eq_zero_iff]1113    have := hcoeff (Fin.last d); simp only [Fin.val_last] at this; rw [this]1114  have e0 : 0 < Dv (zeroDirection _) ↔ c 0 ∈ IsLocalRing.maximalIdeal m.R := by1115    rw [b2, ← IsLocalRing.residue_eq_zero_iff]1116    have := hcoeff 0; simp only [Fin.val_zero] at this; rw [this]1117  have : Finite (IsLocalRing.ResidueField m.R) := Finite.of_equiv _ m.S.residueEquiv.toEquiv1118  obtain ⟨P, hPd, hPa, hPD⟩ := allowed_pattern_of_cell_ideal m.O m.pi m.hpi m.u m.a m.b m.ha m.S1119    m.hS_t m.hS_x m.s J hJ d f hf c hc Dv e1 e0 (m.shape.valid m.ha)1120    hd hdegDv b4 b31121  refine ⟨⟨⟨P, hPa⟩, ⟨Dv, hPD⟩⟩, ?_⟩1122  change J ∈ fixedTangentCell m.O m.R m.S m.s P.d.val Dv1123  rw [hPd]1124  exact ⟨hJ, hf ▸ hT⟩1125 1126/-! ### Existence of a concrete universe -/1127 1128/-- A concrete universe exists provided the child maps of all cells are measurable and scale the1129measure by `q^{-tri d}` on boxes. -/1130private theorem concrete_universe_of_cell_measure (hmeas : ∀ (m : ConcreteMember) (c : m.cellIndex)1131    (D : CellChildData m c), m.s.terminal = false → ∀1132    (G : ∀ j : m.toMeasured.childIdx c, Set (Ideal (D.mc j).toMeasured.R)),1133    (∀ j, MeasurableSet (G j)) → MeasurableSet (m.toMeasured.cell c ∩ (fun J j => D.Φ J j) ⁻¹'1134    Set.pi Set.univ G)) (hmass : ∀ (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c),1135    m.s.terminal = false → ∀ (G : ∀ j : m.toMeasured.childIdx c, Set1136    (Ideal (D.mc j).toMeasured.R)), (∀ j, MeasurableSet (G j)) → m.toMeasured.μ1137    (m.toMeasured.cell c ∩ (fun J j => D.Φ J j) ⁻¹' Set.pi Set.univ G) = (m.toMeasured.q : ℝ≥0∞)⁻¹1138    ^ tri (m.toMeasured.cellDegree c) * ∏ j, (D.mc j).toMeasured.μ (G j)) :1139    ConcreteUniverse := by1140  let D : ∀ (m : ConcreteMember) (c : m.cellIndex), CellChildData m c :=1141    fun m c => Classical.choice (cell_child_data_exists m c)1142  let U : SurfaceUniverse :=1143    { ι := ConcreteMember1144      M := ConcreteMember.toMeasured1145      stateSet_measurable := concrete_member_stateSet_measurable1146      volume := concrete_member_volume1147      divisors_finite := fun m => (concrete_member_divisor_count m).11148      divisor_count := fun m => (concrete_member_divisor_count m).21149      cell_measurable := fun m _ c => concrete_member_cell_measurable m c1150      cells_cover := fun m _ => concrete_member_cells_cover m1151      cells_disjoint := fun m _ => concrete_member_cells_disjoint m1152      child := fun m c j => (D m c).mc j1153      child_state := fun m c j => ((D m c).child j).hstate1154      child_residue := fun m c j => ((D m c).child j).hcard1155      Φ := fun m c J j => (D m c).Φ J j1156      Φ_bij := fun m _ c => cell_child_bijOn m c (D m c)1157      Φ_measurable := fun m hnt c G hG => hmeas m c (D m c) hnt G hG1158      Φ_measure := fun m hnt c G hG => hmass m c (D m c) hnt G hG1159      type_add := fun m _ c J hJ τ hτ =>1160        cell_child_type_add m c (D m c) J hJ (fun j => ((D m c).mc j).R ⧸ (D m c).Φ J j)1161          (fun j => RingEquiv.refl _) (fun _ _ => rfl) (fun _ _ => rfl) τ hτ1162      terminal_type := fun m a hs J hJ => concrete_member_terminal_type m a hs J hJ }1163  refine ⟨U, Equiv.refl _, fun _ => rfl, ?_, ?_⟩1164  · intro i hnt c J hJ σ hσ j1165    exact (cell_child_termination_data i c hnt (D i c) J hJ1166        (fun j => ((D i c).mc j).R ⧸ (D i c).Φ J j)1167      (fun j => RingEquiv.refl _) (fun _ _ => rfl) (fun _ _ => rfl) σ hσ j).11168  · rintro i hnt c J hJ ⟨σ, hσ⟩ j1169    exact (cell_child_termination_data i c hnt (D i c) J hJ1170        (fun j => ((D i c).mc j).R ⧸ (D i c).Φ J j)1171      (fun j => RingEquiv.refl _) (fun _ _ => rfl) (fun _ _ => rfl) σ hσ j).21172 1173private theorem firstContact_pointChildState (k : Type) [Field k] (s : State) (d : ℕ)1174    (Dv : ExceptionalDivisor k) (Q : ClosedDirection k) :1175    (pointChildState k s d Dv Q).firstContact = Dv Q := by1176  cases s <;> unfold pointChildState <;> split_ifs <;> rfl1177 1178private theorem cellChild_algebraMap_pi (m : ConcreteMember) (c : m.cellIndex)1179    (D : CellChildData m c) : ∀ j,1180    algebraMap m.O (D.mc j).O m.S.pi = (D.mc j).S.pi := by1181  intro j1182  rw [m.hS_pi, (D.mc j).hS_pi, ← (D.child j).hpi]1183 1184private theorem cellChild_degree_sum (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c)1185    : ∑ j,1186    m.toMeasured.childDelta c j * (D.mc j).toMeasured.s.degree = m.toMeasured.s.degree := by1187  rw [← member_children_degree_sum m c]1188  refine Finset.sum_congr rfl fun j _ => ?_1189  change _ * (D.child j).mc.s.degree = _1190  rw [(D.child j).hstate]1191 1192private theorem cellChild_pi_pow_eq (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c)1193    : ∀ j, ∃1194    (s : ℕ) (cj : (D.mc j).R), algebraMap m.O (D.mc j).R m.S.pi ^ s = (D.mc j).S.t ^1195    m.toMeasured.cellDegree c * cj := by1196  intro j1197  refine ⟨m.toMeasured.cellDegree c, ((D.mc j).S.unit : (D.mc j).R) ^ m.toMeasured.cellDegree c *1198      (D.mc j).S.t ^ (m.toMeasured.cellDegree c * ((D.mc j).S.a - 1)) * (D.mc j).S.x ^1199      (m.toMeasured.cellDegree c * (D.mc j).S.b), ?_⟩1200  rw [IsScalarTower.algebraMap_apply m.O (D.mc j).O (D.mc j).R, cellChild_algebraMap_pi m c D j,1201    (D.mc j).S.vertical]1202  have ha := (D.mc j).S.a_pos1203  obtain ⟨k, hk⟩ : ∃ k, (D.mc j).S.a = k + 1 := ⟨_, (Nat.succ_pred_eq_of_pos ha).symm⟩1204  rw [hk, Nat.add_sub_cancel]1205  ring1206 1207private theorem cellChild_firstContact_sum (m : ConcreteMember) (c : m.cellIndex)1208    (D : CellChildData m c) : ∑ j,1209    m.toMeasured.childDelta c j * (D.mc j).toMeasured.s.firstContact = m.toMeasured.cellDegree c :=1210    by1211  have h1 : ∀ j, m.toMeasured.childDelta c j * (D.mc j).toMeasured.s.firstContact = directionDegree1212      _ (D.asg.pt j) * c.2.1 (D.asg.pt j) := by1213    intro j1214    change _ * (D.child j).mc.s.firstContact = _1215    rw [(D.child j).hstate]1216    have hd := D.asg.deg j1217    have hs := D.asg.state j1218    change ((children m.s c.1.1).get j).1 * ((children m.s c.1.1).get j).2.firstContact = _1219    rw [← hd, hs]1220    rw [firstContact_pointChildState]1221  rw [Finset.sum_congr rfl fun j _ => h1 j]1222  have h2 := c.2.2.11223  change _ = c.1.1.d.val1224  rw [← h2, exceptionalDegree, Finsupp.sum]1225  refine Finset.sum_bij (fun j _ => D.asg.pt j) ?_ ?_ ?_ ?_1226  · intro j _1227    rw [Finsupp.mem_support_iff]1228    exact Nat.pos_iff_ne_zero.mp ((D.asg.supp _).mpr ⟨j, rfl⟩)1229  · intro a _ b _ h; exact D.asg.inj h1230  · intro Q hQ1231    obtain ⟨j, hj⟩ := (D.asg.supp Q).mp (Nat.pos_of_ne_zero (Finsupp.mem_support_iff.mp hQ))1232    exact ⟨j, Finset.mem_univ _, hj⟩1233  · intro j _; rfl1234 1235private theorem divisorFromSurface_t_x_dvd (R : Type) [CommRing R] (t x : R) [IsLocalRing R]1236  (e : (BlowupChart R t x ⧸ chartExceptional R t x) ≃+* Polynomial (IsLocalRing.ResidueField R))1237  (Dv : ExceptionalDivisor (IsLocalRing.ResidueField R)) (hinf : (infinityPoint R t x).IsPrime)1238      (Q : divisorSupport Dv) :1239    ∃ a1 a2, divisorFromSurface R t x e Dv hinf Q t = divisorException R t x e Dv hinf Q * a1 ∧1240      divisorFromSurface R t x e Dv hinf Q x = divisorException R t x e Dv hinf Q * a2 := by1241  rcases Q with ⟨_ | φ, hQ⟩1242  · refine ⟨@completedPointMap (BlowupChart R x t) _ (infinityPoint R t x) hinf (chartSlope R x t),1243      (1 : @CompletedLocalAt (BlowupChart R x t) _ (infinityPoint R t x) hinf), ?_, ?_⟩1244    · change (@completedPointMap (BlowupChart R x t) _ (infinityPoint R t x) hinf)1245        (chartBase R x t t) = _1246      rw [chartBase_x_eq, map_mul]; rfl1247    · change (@completedPointMap (BlowupChart R x t) _ (infinityPoint R t x) hinf)1248        (chartBase R x t x) = (@completedPointMap (BlowupChart R x t) _ (infinityPoint R t x) hinf)1249        (chartBase R x t x) * 11250      exact (mul_one _).symm1251  · refine ⟨(1 : CompletedLocalAt (BlowupChart R t x) (directionPoint R t x e φ)),1252      completedPointMap (BlowupChart R t x) (directionPoint R t x e φ) (chartSlope R t x), ?_, ?_⟩1253    · change (completedPointMap (BlowupChart R t x) (directionPoint R t x e φ)) (chartBase R t x t)1254        =1255        (completedPointMap (BlowupChart R t x) (directionPoint R t x e φ)) (chartBase R t x t) * 11256      exact (mul_one _).symm1257    · change (completedPointMap (BlowupChart R t x) (directionPoint R t x e φ)) (chartBase R t x x)1258        =1259        _1260      rw [chartBase_x_eq, map_mul]; rfl1261 1262private theorem cellChild_strict_generator (m : ConcreteMember) (c : m.cellIndex)1263    (D : CellChildData m c) : ∀ f :1264    m.R, Ideal.span {f} ∈ m.toMeasured.cell c → ∃ g : (∀ j, (D.mc j).R), ∀ j, D.alpha j f =1265    (D.mc j).S.t ^ m.toMeasured.cellDegree c * g j := by1266  intro f hf1267  obtain ⟨f', co, H, hspan, hf', -⟩ := fixed_tangent_cell_generator_coefficients m.O m.R m.S m.s1268      (m.toMeasured.cellDegree c) c.2.1 _ hf1269  obtain ⟨r, hr⟩ : ∃ r, f = r * f' := by1270    have : f ∈ Ideal.span {f'} := hspan ▸ Ideal.subset_span rfl1271    obtain ⟨r, hr⟩ := Ideal.mem_span_singleton'.mp this1272    exact ⟨r, hr.symm⟩1273  have hab : ∀ j, ∃ a1 a2, D.alpha j m.S.t = (D.mc j).S.t * a1 ∧ D.alpha j m.S.x = (D.mc j).S.t *1274      a2 := by1275    intro j1276    obtain ⟨a1, a2, h1, h2⟩ := divisorFromSurface_t_x_dvd m.R m.S.t m.S.x D.e c.2.1 D.hinf1277        (D.point j)1278    refine ⟨D.Eq j a1, D.Eq j a2, ?_, ?_⟩1279    · change D.Eq j _ = _1280      rw [h1, map_mul]; exact congrArg (· * _) (D.hEq_e j)1281    · change D.Eq j _ = _1282      rw [h2, map_mul]; exact congrArg (· * _) (D.hEq_e j)1283  choose a1 a2 h1 h2 using hab1284  refine ⟨fun j => D.alpha j r * ∑ i : Fin (m.toMeasured.cellDegree c + 1), D.alpha j (co i) * a1 j1285      ^ (m.toMeasured.cellDegree c - i.val) * a2 j ^ i.val, fun j => ?_⟩1286  simp only1287  rw [hr, hf', map_mul, map_sum, Finset.mul_sum, Finset.mul_sum, Finset.mul_sum]1288  refine Finset.sum_congr rfl fun i _ => ?_1289  rw [map_mul, map_mul, map_pow, map_pow, h1, h2, mul_pow, mul_pow]1290  rw [← pow_mul_pow_sub ((D.mc j).S.t) (show i.val ≤ m.toMeasured.cellDegree c by omega)]1291  ring1292 1293private theorem member_t_ne_zero (m : ConcreteMember) : m.S.t ≠ 0 := by1294  intro h1295  have hv := m.S.vertical1296  rw [h, zero_pow m.S.a_pos.ne', mul_zero, zero_mul, ← map_zero (algebraMap m.O m.R)] at hv1297  exact m.S.pi_irreducible.ne_zero (m.S.base_injective hv)1298 1299private theorem cellChild_index_map (m : ConcreteMember) (c : m.cellIndex) (D : CellChildData m c)1300    : ∀ f :1301    m.R, Ideal.span {f} ∈ m.toMeasured.cell c → ∀ g : (∀ j, (D.mc j).R),1302    (∀ j, D.alpha j f = (D.mc j).S.t ^ m.toMeasured.cellDegree c * g j) → ∀ iota :1303    (m.R ⧸ Ideal.span {f}) →ₗ[m.O] ((∀ j, (D.mc j).R) ⧸ Ideal.span {g}),1304    (∀ h : m.R, iota (Ideal.Quotient.mk (Ideal.span {f}) h) = Ideal.Quotient.mk (Ideal.span {g})1305    (fun j => D.alpha j h)) → Function.Injective iota ∧ Module.length m.O1306    (((∀ j, (D.mc j).R) ⧸ Ideal.span {g}) ⧸ LinearMap.range iota) =1307    (chooseTwo (m.toMeasured.cellDegree c) : ℕ∞) := by1308  intro f hf g hg iota hiota1309  have hΦ : ∀ j, D.Φ (Ideal.span {f}) j = Ideal.span {g j} := fun j =>1310    strict_transform_ideal_of_generator m.O m.R (D.mc j).R (D.alpha j) ((D.mc j).S.t) (g j) _ f1311        (hg j)1312      (fun a b hab => mul_left_cancel₀ (member_t_ne_zero (D.mc j)) hab)1313  obtain ⟨ψ, hψinj, hlen, hψ⟩ := cell_member_index_map m c D (Ideal.span {f}) hf1314      (fun j => (D.mc j).R ⧸ Ideal.span {g j})1315    (fun j => Ideal.quotEquivOfEq (hΦ j).symm) (fun j r => rfl)1316  obtain ⟨⟨Ψ, hΨ⟩, -⟩ := pi_quotient_span_linearEquiv m.O (m.toMeasured.childIdx c)1317      (fun j => (D.mc j).R) g g1318  have hψ' : ∀ h : m.R, ψ (Ideal.Quotient.mk _ h) = fun j => Ideal.Quotient.mk (Ideal.span {g j})1319      (D.alpha j h) := by1320    intro h; funext j1321    apply (Ideal.quotEquivOfEq (hΦ j).symm).injective1322    rw [hψ h j]; rfl1323  have hcomp : ∀ x, iota x = Ψ.symm (ψ x) := by1324    intro x1325    obtain ⟨h, rfl⟩ := Ideal.Quotient.mk_surjective x1326    rw [hiota, hψ', ← hΨ, LinearEquiv.symm_apply_apply]1327  have hrange : (LinearMap.range ψ.toLinearMap).map (Ψ.symm : _ →ₗ[m.O] _) = LinearMap.range1328      iota := by1329    have hEq : (Ψ.symm : _ →ₗ[m.O] _) ∘ₗ ψ.toLinearMap = iota := LinearMap.ext fun x =>1330        (hcomp x).symm1331    rw [← LinearMap.range_comp, hEq]1332  refine ⟨?_, ?_⟩1333  · intro a b hab1334    rw [hcomp, hcomp] at hab1335    exact hψinj (Ψ.symm.injective hab)1336  · rw [← hlen]1337    exact (LinearEquiv.length_eq (Submodule.Quotient.equiv _ _ Ψ.symm hrange)).symm1338 1339 1340/-- **A concrete universe exists**: choosing child data for every cell of every concrete member1341yields a surface universe indexed by concrete members that satisfies the termination1342hypotheses. -/1343theorem concrete_universe_exists : ConcreteUniverse :=Theorem 6.21344  concrete_universe_of_cell_measure1345    (fun m c D _ ↦ @member_cell_box_measurable m c D.mc (fun j ↦ (D.child j).algO)1346      (fun j ↦ inferInstanceAs (Algebra m.O (D.mc j).R))1347      (fun j ↦ inferInstanceAs (IsScalarTower m.O (D.mc j).O (D.mc j).R)) (fun j ↦ (D.child j).pc)1348      (fun j ↦ (D.child j).pc_cont.2.2.1) (fun j ↦ (D.child j).pc_cont.2.2.2)1349      (fun j ↦ (D.child j).hcard) (cellChild_algebraMap_pi m c D) (cellChild_degree_sum m c D)1350      D.alpha (fun j ↦ (D.mc j).S.t) (fun _ ↦ rfl) (cellChild_pi_pow_eq m c D)1351      (cell_child_bijOn m c D) (cellChild_strict_generator m c D) (cellChild_index_map m c D)1352      (cellChild_firstContact_sum m c D))1353    (fun m c D _ ↦ @member_cell_box_measure m c D.mc (fun j ↦ (D.child j).algO)1354      (fun j ↦ inferInstanceAs (Algebra m.O (D.mc j).R))1355      (fun j ↦ inferInstanceAs (IsScalarTower m.O (D.mc j).O (D.mc j).R)) (fun j ↦ (D.child j).pc)1356      (fun j ↦ (D.child j).pc_cont.2.2.1) (fun j ↦ (D.child j).pc_cont.2.2.2)1357      (fun j ↦ (D.child j).hcard) (cellChild_algebraMap_pi m c D) (cellChild_degree_sum m c D)1358      D.alpha (fun j ↦ (D.mc j).S.t) (fun _ ↦ rfl) (cellChild_pi_pow_eq m c D)1359      (cell_child_bijOn m c D) (cellChild_strict_generator m c D) (cellChild_index_map m c D)1360      (cellChild_firstContact_sum m c D))1361 1362/-- **The root cell law** holds unconditionally. -/1363theorem root_cell_law : RootCellLaw :=(1.3)Cluster model and cluster law B_n(7.1)1364  root_cell_law_of_universe concrete_universe_exists1365 1366end SurfaceBlowup