Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

YukonModule.ProximityPrize.SubmissionLower.HFreeLocal6812.part0

Definition
Yukon_590a300e51c847902c7c8694

by yukon · Sep 30, 2026 · Mathlib 0df444a (Lean v4.33.1)

better-codes

Source module ProximityPrize.SubmissionLower.HFreeLocal6812.

Definition code
import Mathlib.RingTheory.Valuation.Basic
import Mathlib.RingTheory.Derivation.Basic
import Mathlib.Algebra.Polynomial.Eval.Defs
import Mathlib.Algebra.Order.GroupWithZero.Canonical
import Mathlib.Tactic.LinearCombination
import Mathlib.Algebra.BigOperators.Group.Finset.Basic


import Init
set_option backward.isDefEq.respectTransparency.types false
/-!
# H-free first cut, lemma (c): the per-place multiplicity dichotomy

Setting (all hypotheses explicit, Mathlib-level): `φ : A →+* L` (the map
`K[X,Y,Y',γ] → L0 = Frac(K[X,Y,Y',γ]/(F))`), a normalized valuation `v : Valuation L ℤᵐ⁰`
integral on `φ A`, with centre `𝔓 = {g | v (φ g) < 1}` locally generated by two elements
`a, b` (the regular system of parameters of the 2-dimensional regular local ring `A_𝔓`),
`φ F = 0`, `D₀` a derivation of `A` (`∂/∂Y'`), and `n₁` a lower bound for `ord_v` on `𝔓`.

Claim (`local_dichotomy`): `n₁ ≤ 1` or `3 n₁ ≤ 2 ord_v (D₀ F)`.

Route (no regularity theory, no blow-up ring, no base change): write `s F = α a + β b`.
* `(1)` `α` or `β` a unit: `𝔓` is locally principal, so `n₁ = 1` (`smooth_branch`).
* otherwise `s F = A₂ a² + B₂ a b + C₂ b²` (inside `local_dichotomy`);
  * `(2)` all coefficients in `𝔓`: `D₀ F ∈ 𝔓²` locally, `ord (D₀ F) ≥ 2 n₁` (`cube_case`);
  * `(3a)` discriminant `δ = B₂² - 4 A₂ C₂ ∈ 𝔓`: `4 A₂ s F = ℓ² - δ b²` gives
    `2 ord ℓ ≥ 3 n₁` and `ord (D₀ F) ≥ min (ord ℓ, 2 n₁)` (`cusp_case`);
  * `(3b)` `δ` a unit: with `z = b / a`, `Q(z) = 0` and `Q'(z)² = δ`; the ring `A[z]` has
    centre locally generated by `a` (degree reduction by `γ`, then a norm identity for
    `c₀ + c₁ z`), so `ord a = 1` (`node_case`).

`smooth_branch` is the valuation-theoretic core of "a DVR is maximal for domination":
if the centre of `v` on a subring `S` with `Frac S = L` is locally generated by `t`, then
`ord t = 1` (induction on `ord`, no Noetherianity or Krull intersection needed).

Downstream obligations: `hgen` (the height-2 prime `𝔓` of `K[X,Y,Y',γ]` is generated by two
elements after inverting something outside `𝔓`, i.e. `A_𝔓` is regular of dimension 2),
`hint` (the centre lies on the chart), `hfrac`, `hsurj` (normalization), `v 2 = 1`.
`per_place_law` also needs `0 ≤ T ≤ ord H` (true at affine places).
-/

namespace ProximityPrize.SubmissionLower.HFree6812

open WithZero Polynomial

section Local

variable {L : Type*} [Field L] (v : Valuation L ℤᵐ⁰)

/-- Smooth-branch lemma: a subring `S ⊆ O_v` with fraction field `L`, whose centre is locally
generated by `t`, forces `ord t = 1` for a normalized `v`. -/
theorem smooth_branch (S : Subring L) (hS : ∀ h ∈ S, v h ≤ 1)
    (hfrac : ∀ x : L, ∃ f ∈ S, ∃ g ∈ S, g ≠ 0 ∧ x = f / g)
    (hsurj : ∃ x : L, v x = exp (-1))
    (t : L) (ht : v t < 1)
    (hloc : ∀ h ∈ S, v h < 1 → ∃ u ∈ S, v u = 1 ∧ ∃ h' ∈ S, u * h = t * h') :
    v t = exp (-1) := by
  obtain ⟨x₀, hx₀⟩ := hsurj
  obtain ⟨f, hf, g, hg, hg0, rfl⟩ := hfrac x₀
  have hvg : v g ≠ 0 := (Valuation.ne_zero_iff v).2 hg0
  have hvf : v f = exp (-1) * v g := by
    rw [map_div₀, div_eq_iff hvg] at hx₀; exact hx₀
  have hf0 : f ≠ 0 := by
    intro h; rw [h, v.map_zero] at hvf; exact (mul_ne_zero exp_ne_zero hvg) hvf.symm
  have hflt : v f < 1 := by
    rw [hvf]
    calc exp (-1) * v g ≤ exp (-1) * 1 := mul_le_mul_right (hS g hg) _
      _ < 1 := by rw [mul_one, ← exp_zero, exp_lt_exp]; omega
  have ht0 : t ≠ 0 := by
    intro ht0
    obtain ⟨u, -, hu, h', -, hu'⟩ := hloc f hf hflt
    rw [ht0, zero_mul] at hu'
    have hu0 : u ≠ 0 := by rintro rfl; simp at hu
    exact hf0 ((mul_eq_zero.1 hu').resolve_left hu0)
  have hvt0 : v t ≠ 0 := (Valuation.ne_zero_iff v).2 ht0
  set m : ℤ := -(v t).log with hm_def
  have hvt : v t = exp (-m) := by rw [hm_def, neg_neg, exp_log hvt0]
  have hm : 1 ≤ m := by
    have h1 : v t < exp 0 := by rw [exp_zero]; exact ht
    rw [hvt, exp_lt_exp] at h1; omega
  have key : ∀ n : ℕ, ∀ h ∈ S, v h = exp (-(n : ℤ)) → ∃ k : ℕ, v h = exp (-(m * k)) := by
    intro n
    induction n using Nat.strong_induction_on with
    | _ n ih =>
      intro h hh hvh
      rcases Nat.eq_zero_or_pos n with rfl | hn
      · exact ⟨0, by simpa using hvh⟩
      have hlt : v h < 1 := by rw [hvh, ← exp_zero, exp_lt_exp]; omega
      obtain ⟨u, -, hu1, h', hh', hu'⟩ := hloc h hh hlt
      have hvv : v h = v t * v h' := by
        have := congrArg v hu'; rwa [v.map_mul, v.map_mul, hu1, one_mul] at this
      have hvh'0 : v h' ≠ 0 := by
        intro h0; rw [h0, mul_zero, hvh] at hvv; exact exp_ne_zero hvv
      have hvh' : v h' = exp (v h').log := (exp_log hvh'0).symm
      have hn' : (v h').log ≤ 0 := by
        rw [← exp_le_exp, ← hvh', exp_zero]; exact hS h' hh'
      have heq : -(n : ℤ) = -m + (v h').log := by
        rw [hvh, hvt, hvh', ← exp_add, exp_inj] at hvv; exact hvv
      obtain ⟨k, hk⟩ := ih (-(v h').log).toNat (by omega) h' hh'
        (hvh'.trans (by congr 1; omega))
      exact ⟨k + 1, by rw [hvv, hvt, hk, ← exp_add]; congr 1; push_cast; ring⟩
  have ord : ∀ h ∈ S, h ≠ 0 → ∃ k : ℕ, v h = exp (-(m * k)) := by
    intro h hh h0
    have hvh0 := (Valuation.ne_zero_iff v).2 h0
    have hle : (v h).log ≤ 0 := by
      rw [← exp_le_exp, exp_log hvh0, exp_zero]; exact hS h hh
    exact key (-(v h).log).toNat h hh ((exp_log hvh0).symm.trans (by congr 1; omega))
  obtain ⟨k₁, hk₁⟩ := ord f hf hf0
  obtain ⟨k₂, hk₂⟩ := ord g hg hg0
  rw [hk₁, hk₂, ← exp_add, exp_inj] at hvf
  have hmk : m * ((k₂ : ℤ) - k₁) = -1 := by linear_combination hvf
  have hm1 : m = 1 := by
    rcases Int.eq_one_or_neg_one_of_mul_eq_neg_one hmk with h | h <;> omega
  rw [hvt, hm1]

variable {A : Type*} [CommRing A] (φ : A →+* L)

/-- The image of `A` is a subring of `O_v` with fraction field `L`. -/
theorem range_frac (hfrac : ∀ x : L, ∃ f g : A, φ g ≠ 0 ∧ x = φ f / φ g) :
    ∀ x : L, ∃ f ∈ φ.range, ∃ g ∈ φ.range, g ≠ 0 ∧ x = f / g := by
  intro x
  obtain ⟨f, g, hg, rfl⟩ := hfrac x
  exact ⟨φ f, ⟨f, rfl⟩, φ g, ⟨g, rfl⟩, hg, rfl⟩

/-- Some element of the centre has nonzero image. -/
theorem center_nonzero (hint : ∀ g : A, v (φ g) ≤ 1) (hsurj : ∃ x : L, v x = exp (-1))
    (hfrac : ∀ x : L, ∃ f g : A, φ g ≠ 0 ∧ x = φ f / φ g) :
    ∃ f : A, v (φ f) < 1 ∧ φ f ≠ 0 := by
  obtain ⟨x₀, hx₀⟩ := hsurj
  obtain ⟨f, g, hg0, rfl⟩ := hfrac x₀
  have hvg : v (φ g) ≠ 0 := (Valuation.ne_zero_iff v).2 hg0
  have hvf : v (φ f) = exp (-1) * v (φ g) := by
    rw [map_div₀, div_eq_iff hvg] at hx₀; exact hx₀
  refine ⟨f, ?_, ?_⟩
  · rw [hvf]
    calc exp (-1) * v (φ g) ≤ exp (-1) * 1 := mul_le_mul_right (hint g) _
      _ < 1 := by rw [mul_one, ← exp_zero, exp_lt_exp]; omega
  · intro h; rw [h, v.map_zero] at hvf; exact (mul_ne_zero exp_ne_zero hvg) hvf.symm

theorem v_eq_one_of_not_lt (hint : ∀ g : A, v (φ g) ≤ 1) (g : A) (h : ¬ v (φ g) < 1) :
    v (φ g) = 1 :=
  le_antisymm (hint g) (not_lt.1 h)

/-- Case `(1)`: a relation `α a + β b = 0` with `α` a unit makes `b` a local generator. -/
theorem linear_case (hint : ∀ g : A, v (φ g) ≤ 1) (hsurj : ∃ x : L, v x = exp (-1))
    (hfrac : ∀ x : L, ∃ f g : A, φ g ≠ 0 ∧ x = φ f / φ g)
    (a b : A) (hb : v (φ b) < 1)
    (hgen : ∀ g : A, v (φ g) < 1 → ∃ s x y : A, v (φ s) = 1 ∧ s * g = x * a + y * b)
    (α β : A) (hα : v (φ α) = 1) (hrel : φ α * φ a + φ β * φ b = 0) :
    v (φ b) = exp (-1) := by
  refine smooth_branch v φ.range ?_ (range_frac φ hfrac) hsurj (φ b) hb ?_
  · rintro _ ⟨g, rfl⟩; exact hint g
  · rintro _ ⟨g, rfl⟩ hlt
    obtain ⟨s, x, y, hs, hsg⟩ := hgen g hlt
    refine ⟨φ (α * s), ⟨_, rfl⟩, by rw [map_mul, v.map_mul, hα, hs, one_mul],
      φ (y * α - x * β), ⟨_, rfl⟩, ?_⟩
    have h1 := congrArg φ hsg
    simp only [map_mul, map_add, map_sub] at h1 ⊢
    linear_combination φ α * h1 + φ x * hrel

/-- Case `(3b)`: a quadratic relation with unit discriminant and `γ` a unit makes `a` a
local generator of the centre of `A[b/a]`, hence `ord a = 1`. -/
theorem node_case (hint : ∀ g : A, v (φ g) ≤ 1) (hsurj : ∃ x : L, v x = exp (-1))
    (hfrac : ∀ x : L, ∃ f g : A, φ g ≠ 0 ∧ x = φ f / φ g)
    (a b : A) (ha : v (φ a) < 1)
    (hgen : ∀ g : A, v (φ g) < 1 → ∃ s x y : A, v (φ s) = 1 ∧ s * g = x * a + y * b)
    (α β γ : A) (hγ : v (φ γ) = 1) (hδ : v (φ (β ^ 2 - 4 * α * γ)) = 1)
    (hrel : φ α * φ a ^ 2 + φ β * φ a * φ b + φ γ * φ b ^ 2 = 0) :
    v (φ a) = exp (-1) := by
  have hγ0 : φ γ ≠ 0 := by intro h; rw [h, v.map_zero] at hγ; exact zero_ne_one hγ
  have hunit : ∀ g : A, v (φ g) = 1 → φ g ≠ 0 := by
    intro g hg h; rw [h, v.map_zero] at hg; exact zero_ne_one hg
  -- `φ a ≠ 0`
  have ha0 : φ a ≠ 0 := by
    intro ha0
    have hb0 : φ b = 0 := by
      rw [ha0] at hrel
      have h1 : φ γ * φ b ^ 2 = 0 := by linear_combination hrel
      exact pow_eq_zero_iff (n := 2) (by norm_num) |>.1 ((mul_eq_zero.1 h1).resolve_left hγ0)
    obtain ⟨f, hf, hf0⟩ := center_nonzero v φ hint hsurj hfrac
    obtain ⟨s, x, y, hs, hsf⟩ := hgen f hf
    have h1 := congrArg φ hsf
    simp only [map_mul, map_add, ha0, hb0, mul_zero, add_zero] at h1
    exact hf0 ((mul_eq_zero.1 h1).resolve_left (hunit s hs))
  set z : L := φ b / φ a with hz_def
  have hz : φ b = φ a * z := by rw [hz_def, mul_div_cancel₀ _ ha0]
  have hQ : φ α + φ β * z + φ γ * z ^ 2 = 0 := by
    have h1 : φ a ^ 2 * (φ α + φ β * z + φ γ * z ^ 2) = 0 := by
      rw [hz] at hrel; linear_combination hrel
    exact (mul_eq_zero.1 h1).resolve_left (pow_ne_zero 2 ha0)
  -- `z` is integral
  have hzint : v z ≤ 1 := by
    by_contra hz1
    rw [not_le] at hz1
    have h1 : φ γ * z ^ 2 = -(φ α + φ β * z) := by linear_combination hQ
    have h2 := congrArg v h1
    rw [v.map_mul, hγ, one_mul, v.map_pow, v.map_neg] at h2
    have h3 : v (φ α + φ β * z) ≤ v z := by
      refine (v.map_add _ _).trans (max_le ((hint α).trans hz1.le) ?_)
      rw [v.map_mul]; exact mul_le_of_le_one_left' (hint β)
    have h4 : v z < v z ^ 2 := by
      rw [sq]; exact lt_mul_of_one_lt_left (zero_lt_one.trans hz1) hz1
    rw [← h2] at h3
    exact absurd h3 (not_le.2 h4)
  -- `w = Q'(z)` is a unit
  set w : L := 2 * φ γ * z + φ β with hw_def
  have hw2 : w ^ 2 = φ (β ^ 2 - 4 * α * γ) := by
    rw [hw_def]; simp only [map_sub, map_mul, map_pow, map_ofNat]
    linear_combination 4 * φ γ * hQ
  have hw : v w = 1 := by
    have h1 : v w ^ 2 = 1 := by rw [← v.map_pow, hw2, hδ]
    rcases lt_trichotomy (v w) 1 with h | h | h
    · exact absurd h1 (ne_of_lt (by rw [sq]; exact mul_lt_one_of_nonneg_of_lt_one_left zero_le h h.le))
    · exact h
    · exact absurd h1 (ne_of_gt (by rw [sq]; exact one_lt_mul_of_lt_of_le h h.le))
  -- the ring `A[z]`
  set S : Subring L := (Polynomial.eval₂RingHom φ z).range with hS_def
  have hSφ : ∀ g : A, φ g ∈ S := fun g => ⟨C g, by simp⟩
  have hSz : z ∈ S := ⟨X, by simp⟩
  have h2S : (2 : L) ∈ S := by rw [← map_ofNat φ 2]; exact hSφ 2
  have hSint : ∀ h ∈ S, v h ≤ 1 := by
    rintro _ ⟨P, rfl⟩
    rw [Polynomial.coe_eval₂RingHom]
    induction P using Polynomial.induction_on' with
    | add P Q hP hQ' => rw [Polynomial.eval₂_add]; exact (v.map_add _ _).trans (max_le hP hQ')
    | monomial n g =>
      rw [Polynomial.eval₂_monomial, v.map_mul, v.map_pow]
      exact mul_le_one' (hint g) (pow_le_one' hzint n)
  -- degree reduction by `γ`
  have hpow : ∀ n : ℕ, ∃ c₀ c₁ : A, φ γ ^ n * z ^ n = φ c₀ + φ c₁ * z := by
    intro n
    induction n with
    | zero => exact ⟨1, 0, by simp⟩
    | succ n ih =>
      obtain ⟨c₀, c₁, h⟩ := ih
      refine ⟨-(c₁ * α), γ * c₀ - c₁ * β, ?_⟩
      simp only [map_neg, map_mul, map_sub]
      linear_combination (φ γ * z) * h + φ c₁ * hQ
  have hlin : ∀ P : A[X], ∃ N : ℕ, ∃ c₀ c₁ : A,
      φ γ ^ N * P.eval₂ φ z = φ c₀ + φ c₁ * z := by
    intro P
    induction P using Polynomial.induction_on' with
    | add P Q hP hQ' =>
      obtain ⟨N₁, c₀, c₁, h₁⟩ := hP
      obtain ⟨N₂, d₀, d₁, h₂⟩ := hQ'
      refine ⟨N₁ + N₂, γ ^ N₂ * c₀ + γ ^ N₁ * d₀, γ ^ N₂ * c₁ + γ ^ N₁ * d₁, ?_⟩
      simp only [Polynomial.eval₂_add, map_add, map_mul, map_pow, pow_add]
      linear_combination φ γ ^ N₂ * h₁ + φ γ ^ N₁ * h₂
    | monomial n g =>
      obtain ⟨c₀, c₁, h⟩ := hpow n
      refine ⟨n, g * c₀, g * c₁, ?_⟩
      simp only [Polynomial.eval₂_monomial, map_mul]
      linear_combination φ g * h
  -- degree-one elements of the centre are locally divisible by `a`
  have hdeg1 : ∀ c₀ c₁ : A, v (φ c₀ + φ c₁ * z) < 1 →
      ∃ u ∈ S, v u = 1 ∧ ∃ h' ∈ S, u * (φ c₀ + φ c₁ * z) = φ a * h' := by
    intro c₀ c₁ he
    by_cases hc₁ : v (φ c₁) < 1
    · have hc₀ : v (φ c₀) < 1 := by
        have h1 : φ c₀ = (φ c₀ + φ c₁ * z) - φ c₁ * z := by ring
        rw [h1]
        refine (v.map_sub _ _).trans_lt (max_lt he ?_)
        rw [v.map_mul]
        exact lt_of_le_of_lt (mul_le_of_le_one_right' hzint) hc₁
      obtain ⟨s₀, x₀, y₀, hs₀, h₀⟩ := hgen c₀ hc₀
      obtain ⟨s₁, x₁, y₁, hs₁, h₁⟩ := hgen c₁ hc₁
      have h₀' := congrArg φ h₀
      have h₁' := congrArg φ h₁
      simp only [map_mul, map_add] at h₀' h₁'
      refine ⟨φ (s₀ * s₁), hSφ _, by rw [map_mul, v.map_mul, hs₀, hs₁, one_mul],
        φ s₁ * (φ x₀ + φ y₀ * z) + φ s₀ * (φ x₁ + φ y₁ * z) * z, ?_, ?_⟩
      · exact S.add_mem (S.mul_mem (hSφ _) (S.add_mem (hSφ _) (S.mul_mem (hSφ _) hSz)))
          (S.mul_mem (S.mul_mem (hSφ _) (S.add_mem (hSφ _) (S.mul_mem (hSφ _) hSz))) hSz)
      · rw [map_mul]
        linear_combination φ s₁ * h₀' + φ s₀ * z * h₁' + (φ s₁ * φ y₀ + φ s₀ * φ y₁ * z) * hz
    · have hc₁1 : v (φ c₁) = 1 := v_eq_one_of_not_lt v φ hint c₁ hc₁
      set e : L := φ c₀ + φ c₁ * z with he_def
      set M : L := φ c₁ * w - φ γ * e with hM_def
      have hM : v M = 1 := by
        rw [hM_def, Valuation.map_sub_eq_of_lt_left]
        · rw [v.map_mul, hc₁1, hw, one_mul]
        · rw [v.map_mul, v.map_mul, hγ, hc₁1, hw, one_mul, one_mul]; exact he
      have hN : φ (c₁ ^ 2 * α - c₁ * c₀ * β + c₀ ^ 2 * γ) = -(e * M) := by
        rw [hM_def, he_def, hw_def]; simp only [map_sub, map_add, map_mul, map_pow]
        linear_combination φ c₁ ^ 2 * hQ
      have hNlt : v (φ (c₁ ^ 2 * α - c₁ * c₀ * β + c₀ ^ 2 * γ)) < 1 := by
        rw [hN, v.map_neg, v.map_mul, hM, mul_one]; exact he
      obtain ⟨s, x, y, hs, hsN⟩ := hgen _ hNlt
      have h1 := congrArg φ hsN
      rw [map_mul, hN, map_add, map_mul, map_mul] at h1
      have hMS : M ∈ S := by
        rw [hM_def, hw_def, he_def]
        exact S.sub_mem (S.mul_mem (hSφ _) (S.add_mem (S.mul_mem (S.mul_mem h2S (hSφ _)) hSz)
          (hSφ _))) (S.mul_mem (hSφ _) (S.add_mem (hSφ _) (S.mul_mem (hSφ _) hSz)))
      refine ⟨φ s * M, S.mul_mem (hSφ _) hMS, by rw [v.map_mul, hs, hM, one_mul],
        -(φ x + φ y * z), S.neg_mem (S.add_mem (hSφ _) (S.mul_mem (hSφ _) hSz)), ?_⟩
      linear_combination -h1 - φ y * hz
  -- local generation of the centre of `A[z]` by `a`
  have hloc : ∀ h ∈ S, v h < 1 → ∃ u ∈ S, v u = 1 ∧ ∃ h' ∈ S, u * h = φ a * h' := by
    rintro _ ⟨P, rfl⟩ hlt
    rw [Polynomial.coe_eval₂RingHom] at hlt ⊢
    obtain ⟨N, c₀, c₁, hN⟩ := hlin P
    have hvN : v (φ γ ^ N) = 1 := by rw [v.map_pow, hγ, one_pow]
    have he : v (φ c₀ + φ c₁ * z) < 1 := by rw [← hN, v.map_mul, hvN, one_mul]; exact hlt
    obtain ⟨u, huS, hu, h', hh', hu'⟩ := hdeg1 c₀ c₁ he
    refine ⟨u * φ γ ^ N, S.mul_mem huS (S.pow_mem (hSφ _) _), by
      rw [v.map_mul, hu, hvN, one_mul], h', hh', ?_⟩
    rw [mul_assoc, hN, hu']
  have hfracS : ∀ x : L, ∃ f ∈ S, ∃ g ∈ S, g ≠ 0 ∧ x = f / g := by
    intro x
    obtain ⟨f, g, hg, rfl⟩ := hfrac x
    exact ⟨φ f, hSφ f, φ g, hSφ g, hg, rfl⟩
  exact smooth_branch v S hSint hfracS hsurj (φ a) ha hloc

variable {R : Type*} [CommRing R] [Algebra R A] (D₀ : Derivation R A A)

/-- `D₀` of a product of three centre elements has order at least `2 n₁`. -/
theorem deriv_triple (hint : ∀ g : A, v (φ g) ≤ 1) (e : ℤᵐ⁰) (x y z : A)
    (hx : v (φ x) ≤ e) (hy : v (φ y) ≤ e) (hz : v (φ z) ≤ e) :
    v (φ (D₀ (x * y * z))) ≤ e * e := by
  rw [Derivation.leibniz, Derivation.leibniz]
  simp only [smul_eq_mul, map_add, map_mul]
  refine (v.map_add _ _).trans (max_le ?_ ?_)
  · rw [v.map_mul, v.map_mul]
    calc v (φ x) * v (φ y) * v (φ (D₀ z)) ≤ e * e * 1 :=
          mul_le_mul' (mul_le_mul' hx hy) (hint _)
      _ = e * e := mul_one _
  · rw [v.map_mul]
    refine (mul_le_mul' hz ((v.map_add _ _).trans (max_le ?_ ?_))).trans (le_of_eq (mul_comm _ _))
    · rw [v.map_mul]; exact (mul_le_mul' hx (hint _)).trans (le_of_eq (mul_one _))
    · rw [v.map_mul]; exact (mul_le_mul' hy (hint _)).trans (le_of_eq (mul_one _))

/-- `D₀` of a square has order at least that of the base. -/
theorem deriv_square (hint : ∀ g : A, v (φ g) ≤ 1) (x : A) :
    v (φ (D₀ (x * x))) ≤ v (φ x) := by
  rw [Derivation.leibniz]
  simp only [smul_eq_mul, map_add, map_mul]
  refine (v.map_add _ _).trans (max_le ?_ ?_) <;> rw [v.map_mul] <;>
    exact mul_le_of_le_one_right' (hint _)

/-- Case `(2)`: `s F ∈ 𝔓³` gives `ord (D₀ F) ≥ 2 n₁`. -/
theorem cube_case (hint : ∀ g : A, v (φ g) ≤ 1) (F : A) (hF : φ F = 0)
    (n₁ : ℕ) (hn₁ : ∀ g : A, v (φ g) < 1 → v (φ g) ≤ exp (-(n₁ : ℤ)))
    (a b : A) (ha : v (φ a) < 1) (hb : v (φ b) < 1)
    (s α β γ : A) (hs : v (φ s) = 1) (hα : v (φ α) < 1) (hβ : v (φ β) < 1)
    (hγ : v (φ γ) < 1) (hrep : s * F = α * a ^ 2 + β * a * b + γ * b ^ 2) :
    v (φ (D₀ F)) ≤ exp (-(2 * n₁ : ℤ)) := by
  set e : ℤᵐ⁰ := exp (-(n₁ : ℤ)) with he
  have hrep' : s * F = α * a * a + β * a * b + γ * b * b := by rw [hrep]; ring
  have h1 : φ (D₀ (s * F)) = φ s * φ (D₀ F) := by
    rw [Derivation.leibniz]; simp only [smul_eq_mul, map_add, map_mul, hF, zero_mul, add_zero]
  have hbd : v (φ (D₀ (s * F))) ≤ e * e := by
    rw [hrep']
    simp only [map_add]
    refine (v.map_add _ _).trans (max_le ((v.map_add _ _).trans (max_le ?_ ?_)) ?_)
    · exact deriv_triple v φ D₀ hint e _ _ _ (hn₁ _ hα) (hn₁ _ ha) (hn₁ _ ha)
    · exact deriv_triple v φ D₀ hint e _ _ _ (hn₁ _ hβ) (hn₁ _ ha) (hn₁ _ hb)
    · exact deriv_triple v φ D₀ hint e _ _ _ (hn₁ _ hγ) (hn₁ _ hb) (hn₁ _ hb)
  rw [h1, v.map_mul, hs, one_mul] at hbd
  refine hbd.trans (le_of_eq ?_)
  rw [he, ← exp_add]; congr 1; ring

/-- Case `(3a)`: a square leading form (`δ ∈ 𝔓`, `α` a unit) gives `3 n₁ ≤ 2 ord (D₀ F)`. -/
theorem cusp_case (hint : ∀ g : A, v (φ g) ≤ 1) (h2 : v (2 : L) = 1) (F : A) (hF : φ F = 0)
    (n₁ : ℕ) (hn₁ : ∀ g : A, v (φ g) < 1 → v (φ g) ≤ exp (-(n₁ : ℤ)))
    (a b : A) (hb : v (φ b) < 1)
    (s α β γ : A) (hs : v (φ s) = 1) (hα : v (φ α) = 1)
    (hδ : v (φ (β ^ 2 - 4 * α * γ)) < 1)
    (hrep : s * F = α * a ^ 2 + β * a * b + γ * b ^ 2) :
    v (φ (D₀ F)) ^ 2 ≤ exp (-(3 * n₁ : ℤ)) := by
  set e : ℤᵐ⁰ := exp (-(n₁ : ℤ)) with he
  have he1 : e ≤ 1 := by rw [he, ← exp_zero, exp_le_exp]; omega
  set δ : A := β ^ 2 - 4 * α * γ with hδ_def
  set ℓ : A := 2 * α * a + β * b with hℓ_def
  have hid : (4 * α * s) * F = ℓ * ℓ - δ * b * b := by
    rw [hℓ_def, hδ_def]; linear_combination (4 * α) * hrep
  -- `2 ord ℓ ≥ 3 n₁`
  have hℓ : v (φ ℓ) * v (φ ℓ) ≤ e * e * e := by
    have h1 := congrArg φ hid
    rw [map_mul, hF, mul_zero, map_sub, eq_comm, sub_eq_zero] at h1
    have h3 := congrArg v h1
    simp only [map_mul, v.map_mul] at h3
    rw [h3]
    exact mul_le_mul' (mul_le_mul' (hn₁ _ hδ) (hn₁ _ hb)) (hn₁ _ hb)
  -- `ord (D₀ F) ≥ min (ord ℓ, 2 n₁)`
  have h4 : φ (D₀ ((4 * α * s) * F)) = φ (4 * α * s) * φ (D₀ F) := by
    rw [Derivation.leibniz]; simp only [smul_eq_mul, map_add, map_mul, hF, zero_mul, add_zero]
  have h4' : v (4 : L) = 1 := by
    rw [show (4 : L) = 2 * 2 by norm_num, v.map_mul, h2, one_mul]
  have hunit : v (φ (4 * α * s)) = 1 := by
    simp only [map_mul, map_ofNat, v.map_mul, hα, hs, h4', one_mul]
  have hbd : v (φ (D₀ F)) ≤ max (v (φ ℓ)) (e * e) := by
    have h5 := congrArg (fun g => v (φ (D₀ g))) hid
    rw [h4, v.map_mul, hunit, one_mul] at h5
    rw [h5, map_sub, map_sub]
    exact (v.map_sub _ _).trans (max_le_max (deriv_square v φ D₀ hint ℓ)
      (deriv_triple v φ D₀ hint e _ _ _ (hn₁ _ hδ) (hn₁ _ hb) (hn₁ _ hb)))
  have hsq : v (φ (D₀ F)) ^ 2 ≤ e * e * e := by
    rw [sq]
    refine (mul_le_mul' hbd hbd).trans ?_
    rcases le_total (v (φ ℓ)) (e * e) with h | h
    · rw [max_eq_right h]
      calc e * e * (e * e) ≤ e * e * (e * 1) := mul_le_mul' le_rfl (mul_le_mul' le_rfl he1)
        _ = e * e * e := by rw [mul_one]
    · rw [max_eq_left h]; exact hℓ
  refine hsq.trans (le_of_eq ?_)
  rw [he, ← exp_add, ← exp_add]; congr 1; ring

/-- **Lemma (c)**, the per-place multiplicity dichotomy: `n₁ ≤ 1` or `3 n₁ ≤ 2 ord (D₀ F)`. -/
theorem local_dichotomy (hint : ∀ g : A, v (φ g) ≤ 1) (hsurj : ∃ x : L, v x = exp (-1))
    (hfrac : ∀ x : L, ∃ f g : A, φ g ≠ 0 ∧ x = φ f / φ g) (h2 : v (2 : L) = 1)
    (F : A) (hF : φ F = 0)
    (a b : A) (ha : v (φ a) < 1) (hb : v (φ b) < 1)
    (hgen : ∀ g : A, v (φ g) < 1 → ∃ s x y : A, v (φ s) = 1 ∧ s * g = x * a + y * b)
    (n₁ : ℕ) (hn₁ : ∀ g : A, v (φ g) < 1 → v (φ g) ≤ exp (-(n₁ : ℤ))) :
    n₁ ≤ 1 ∨ v (φ (D₀ F)) ^ 2 ≤ exp (-(3 * n₁ : ℤ)) := by
  have hone : ∀ t : A, v (φ t) < 1 → v (φ t) = exp (-1) → n₁ ≤ 1 := by
    intro t ht h1
    have h3 := hn₁ t ht
    rw [h1, exp_le_exp] at h3; omega
  have hswap : ∀ g : A, v (φ g) < 1 → ∃ s x y : A, v (φ s) = 1 ∧ s * g = x * b + y * a := by
    intro g hg
    obtain ⟨s, x, y, h1, h3⟩ := hgen g hg
    exact ⟨s, y, x, h1, by rw [h3]; ring⟩
  have hunit := v_eq_one_of_not_lt v φ hint
  have hFP : v (φ F) < 1 := by rw [hF, v.map_zero]; exact zero_lt_one
  obtain ⟨s, α, β, hs, hsF⟩ := hgen F hFP
  have hφsF := congrArg φ hsF
  simp only [map_mul, map_add, hF, mul_zero] at hφsF
  -- case (1): a unit coefficient in the linear representation
  by_cases hα : v (φ α) < 1
  swap
  · exact Or.inl (hone b hb (linear_case v φ hint hsurj hfrac a b hb hgen α β (hunit α hα)
      (by linear_combination -hφsF)))
  by_cases hβ : v (φ β) < 1
  swap
  · exact Or.inl (hone a ha (linear_case v φ hint hsurj hfrac b a ha hswap β α (hunit β hβ)
      (by linear_combination -hφsF)))
  -- the quadratic representation
  obtain ⟨s₁, α₁, α₂, hs₁, h₁⟩ := hgen α hα
  obtain ⟨s₂, β₁, β₂, hs₂, h₂⟩ := hgen β hβ
  have hrep : (s₁ * s₂ * s) * F = (s₂ * α₁) * a ^ 2 + (s₂ * α₂ + s₁ * β₁) * a * b +
      (s₁ * β₂) * b ^ 2 := by
    linear_combination (s₁ * s₂) * hsF + s₂ * a * h₁ + s₁ * b * h₂
  set s' := s₁ * s₂ * s
  set A₂ := s₂ * α₁
  set B₂ := s₂ * α₂ + s₁ * β₁
  set C₂ := s₁ * β₂
  have hs' : v (φ s') = 1 := by simp only [s', map_mul, v.map_mul, hs, hs₁, hs₂, one_mul]
  have hrel : φ A₂ * φ a ^ 2 + φ B₂ * φ a * φ b + φ C₂ * φ b ^ 2 = 0 := by
    have h3 := congrArg φ hrep
    simp only [map_mul, map_add, map_pow, hF, mul_zero] at h3
    linear_combination -h3
  -- case (2): the leading form vanishes
  by_cases hall : v (φ A₂) < 1 ∧ v (φ B₂) < 1 ∧ v (φ C₂) < 1
  · right
    have h3 := cube_case v φ D₀ hint F hF n₁ hn₁ a b ha hb s' A₂ B₂ C₂ hs' hall.1 hall.2.1
      hall.2.2 hrep
    rw [sq]
    refine (mul_le_mul' h3 h3).trans ?_
    rw [← exp_add, exp_le_exp]; omega
  by_cases hδ : v (φ (B₂ ^ 2 - 4 * A₂ * C₂)) < 1
  · -- case (3a): a square leading form
    right
    by_cases hA : v (φ A₂) < 1
    · have hC : ¬ v (φ C₂) < 1 := by
        intro hC
        apply hall
        refine ⟨hA, ?_, hC⟩
        by_contra hB
        have hB1 := hunit B₂ hB
        have h3 : φ B₂ ^ 2 = φ (B₂ ^ 2 - 4 * A₂ * C₂) + 4 * φ A₂ * φ C₂ := by
          simp only [map_sub, map_mul, map_pow, map_ofNat]; ring
        have h4 := congrArg v h3
        rw [v.map_pow, hB1, one_pow] at h4
        have h5 : v (4 * φ A₂ * φ C₂) < 1 := by
          rw [v.map_mul, v.map_mul]
          exact lt_of_le_of_lt (mul_le_of_le_one_left' (mul_le_one' (by
            rw [show (4 : L) = φ 4 from (map_ofNat φ 4).symm]; exact hint 4) (hint A₂)))
            hC
        exact absurd h4 (ne_of_gt ((v.map_add _ _).trans_lt (max_lt hδ h5)))
      exact cusp_case v φ D₀ hint h2 F hF n₁ hn₁ b a ha s' C₂ B₂ A₂ hs' (hunit C₂ hC)
        (by rwa [show B₂ ^ 2 - 4 * C₂ * A₂ = B₂ ^ 2 - 4 * A₂ * C₂ by ring])
        (by rw [hrep]; ring)
    · exact cusp_case v φ D₀ hint h2 F hF n₁ hn₁ a b hb s' A₂ B₂ C₂ hs' (hunit A₂ hA) hδ hrep
  -- case (3b): a unit discriminant (distinct tangents)
  left
  have hδ1 := hunit _ hδ
  by_cases hC : v (φ C₂) < 1
  · by_cases hA : v (φ A₂) < 1
    · -- both `A₂, C₂ ∈ 𝔓`: use the generators `a + b, b`
      have hB : v (φ B₂) = 1 := by
        by_contra hB
        have hB' : v (φ B₂) < 1 := lt_of_le_of_ne (hint B₂) hB
        exact hall ⟨hA, hB', hC⟩
      have hγ' : v (φ (A₂ - B₂ + C₂)) = 1 := by
        have h3 : φ (A₂ - B₂ + C₂) = -φ B₂ + (φ A₂ + φ C₂) := by
          simp only [map_add, map_sub]; ring
        rw [h3, Valuation.map_add_eq_of_lt_left, v.map_neg, hB]
        rw [v.map_neg, hB]
        exact (v.map_add _ _).trans_lt (max_lt hA hC)
      have hgen' : ∀ g : A, v (φ g) < 1 →
          ∃ s x y : A, v (φ s) = 1 ∧ s * g = x * (a + b) + y * b := by
        intro g hg
        obtain ⟨s, x, y, h1, h3⟩ := hgen g hg
        exact ⟨s, x, y - x, h1, by rw [h3]; ring⟩
      have hab : v (φ (a + b)) < 1 := by
        rw [map_add]; exact (v.map_add _ _).trans_lt (max_lt ha hb)
      exact hone _ hab (node_case v φ hint hsurj hfrac (a + b) b hab hgen' A₂ (B₂ - 2 * A₂)
        (A₂ - B₂ + C₂) hγ'
        (by rwa [show (B₂ - 2 * A₂) ^ 2 - 4 * A₂ * (A₂ - B₂ + C₂) = B₂ ^ 2 - 4 * A₂ * C₂ by ring])
        (by simp only [map_add, map_sub, map_mul, map_ofNat]; linear_combination hrel))
    · exact hone b hb (node_case v φ hint hsurj hfrac b a hb hswap C₂ B₂ A₂ (hunit A₂ hA)
        (by rwa [show B₂ ^ 2 - 4 * C₂ * A₂ = B₂ ^ 2 - 4 * A₂ * C₂ by ring])
        (by linear_combination hrel))
  · exact hone a ha (node_case v φ hint hsurj hfrac a b ha hgen A₂ B₂ C₂ (hunit C₂ hC) hδ1 hrel)

end Local













end ProximityPrize.SubmissionLower.HFree6812


Source
https://github.com/proximity-prize/proximity-prize/blob/9008f0e2b2edb0647da15baac454a68072f0ba29/ProximityPrize/SubmissionLower/HFreeLocal6812.lean provider-v8:8caa1c6489fc9630ef355dbb39499ca82de7a5abe9a1655b86b46263cf6ad5c3 [yukon-proof-receipt:eyJ2IjoxLCJtYXJrZXIiOiJwcm92aWRlci12ODo4Y2FhMWM2NDg5ZmM5NjMwZWYzNTVkYmIzOTQ5OWNhODJkZTdhNWFiZTlhMTY1NWI4NmI0NjI2M2NmNmFkNWMzIiwiaGFzaCI6IjI1MTExNDg3NjVhYTJjOTExNTMwZjExYjkyNThlMjFkNjkxNTFmYjZiYjQ5OGVhOWM0YWUzZjY2MDhjZDk1OWQiLCJraW5kIjoiZGVmaW5pdGlvbiIsInRhcmdldCI6Ill1a29uXzU5MGEzMDBlNTFjODQ3OTAyYzdjODY5NCIsImVudmlyb25tZW50Ijp7Im1hdGhsaWJSZXYiOiIwZGY0NDRhMzYwZWFhNjBhYjhjMTFkY2E1MWE4NmFmNjkyOTU1NDc0IiwidG9vbGNoYWluIjoibGVhbnByb3Zlci9sZWFuNDp2NC4zMy4xIn0sInRhZyI6ImJldHRlci1jb2RlcyJ9]

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me