Module

ValuativeProperness.lean

Nyll.SchemeTheory.Morphisms.ValuativeProperness
15 declarations indexed from sourceView source ↗

Valuation models and codimension-one boundaries

Proper birational maps preserve normal codimension-one stalks. Valuation rings of function fields produce proper models with codimension-one centers and detect the boundary of a nonproper variety. Function-field maps and section algebras use their existing canonical owners.

Declarations

AlgebraicGeometry.exists_base_eq_isIso_stalkMap_of_isProper_of_ringKrullDim_stalk_eq_one
Source context 7 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_base_eq_isIso_stalkMap_of_isProper_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace AlgebraicGeometry
theorem
    exists_base_eq_isIso_stalkMap_of_isProper_of_ringKrullDim_stalk_eq_one
    {k : Type u} [Field k] {P' P : Scheme.{u}} (p : P ⟶ Spec (.of k))
    [LocallyOfFiniteType p] [QuasiCompact p]
    [IsIntegral P] [IsIntegral P'] (π : P' ⟶ P) [IsProper π]
    (W : P.Opens) (hW : (W : Set P).Nonempty) [IsIso (π ∣_ W)]
    (w : P) (hw₁ : ringKrullDim (P.presheaf.stalk w) = 1)
    (hwn : IsIntegrallyClosed (P.presheaf.stalk w)) :
    ∃ w' : P', π.base w' = w ∧ IsIso (π.stalkMap w')
SchemeTheory.ValuativeProperness.NormalCompactification.isIso_stalkMap_of_isIso_morphismRestrict
Source context 12 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_isProper_isIntegrallyClosed_stalk_isOpenImmersion_comp_eq_of_isSeparated.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open _root_.CategoryTheory
open _root_.CategoryTheory.Limits
open _root_.AlgebraicGeometry
open _root_.TopologicalSpace
namespace NormalCompactification
theorem isIso_stalkMap_of_isIso_morphismRestrict {X Y : Scheme.{u}} (g : X ⟶ Y) (U : Y.Opens)
    [IsIso (g ∣_ U)] (x : X) (hx : g.base x ∈ U) : IsIso (g.stalkMap x)
AlgebraicGeometry.exists_isProper_isIntegrallyClosed_stalk_isOpenImmersion_comp_eq_of_isSeparated
Source context 8 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_isProper_isIntegrallyClosed_stalk_isOpenImmersion_comp_eq_of_isSeparated.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace AlgebraicGeometry
open SchemeTheory.ValuativeProperness.NormalCompactification
theorem
    exists_isProper_isIntegrallyClosed_stalk_isOpenImmersion_comp_eq_of_isSeparated
    (k : Type u) [Field k] {X : Scheme.{u}} (f : X ⟶ Spec (CommRingCat.of k))
    [IsIntegral X] [IsSeparated f] [LocallyOfFiniteType f] [QuasiCompact f]
    (hX : ∀ x : X, IsIntegrallyClosed (X.presheaf.stalk x)) :
    ∃ (P : Scheme.{u}) (p : P ⟶ Spec (CommRingCat.of k)) (D : P.Opens)
      (τ : (D : Scheme.{u}) ⟶ X) (V : X.Opens) (ι : (V : Scheme.{u}) ⟶ (D : Scheme.{u})),
      IsProper p ∧ IsIntegral P ∧ (∀ y : P, IsIntegrallyClosed (P.presheaf.stalk y)) ∧
      IsProper τ ∧ τ ≫ f = D.ι ≫ p ∧
      Nonempty (V : Scheme.{u}) ∧ IsOpenImmersion ι ∧ ι ≫ τ = V.ι
SchemeTheory.ValuativeProperness.StalkValuations.stalkValuationSubring

The valuation subring given by the image of a valuation stalk in its function field.

Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace StalkValuations
variable {k : Type u} [Field k]
def stalkValuationSubring (V : Scheme.{u}) [IsIntegral V] (z : V)
    [ValuationRing (V.presheaf.stalk z)] :
    ValuationSubring V.functionField where
  toSubring := (algebraMap (V.presheaf.stalk z) V.functionField).range
  mem_or_inv_mem' x := by
    rcases ValuationRing.isInteger_or_isInteger (V.presheaf.stalk z) x with h | h
    · exact Or.inl h
    · exact Or.inr h
SchemeTheory.ValuativeProperness.StalkValuations.valuationRing_of_ringKrullDim_eq_one
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace StalkValuations
variable {k : Type u} [Field k]
theorem valuationRing_of_ringKrullDim_eq_one {R : Type u} [CommRing R] [IsDomain R] [IsLocalRing R]
    [IsNoetherianRing R] (h1 : ringKrullDim R = 1) (hn : IsIntegrallyClosed R) :
    ValuationRing R
SchemeTheory.ValuativeProperness.Transcendence.c_eq_algebraMap_germ
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace Transcendence
variable {k : Type u} [Field k]
theorem c_eq_algebraMap_germ {Y : Scheme.{u}} [IsIntegral Y]
    (fY : Y ⟶ Spec (.of k)) (y : Y) (x : k) :
    baseToFunctionField fY x = algebraMap (Y.presheaf.stalk y) Y.functionField
      ((Y.presheaf.germ ⊤ y trivial).hom
        (fY.appTop.hom ((Scheme.ΓSpecIso (.of k)).inv.hom x)))
SchemeTheory.ValuativeProperness.Transcendence.isScalarTower_chart_ff
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace Transcendence
variable {k : Type u} [Field k]

/- The chart-tower argument is from the codimension-one boundary source unit attributed below. -/
theorem isScalarTower_chart_ff {X : Scheme.{u}} [IsIntegral X] (f : X ⟶ Spec (CommRingCat.of k))
    (U : X.Opens) [Nonempty U] :
    let : Algebra k Γ(X, U) := f.sectionsAlgebra U
    let : Algebra k X.functionField := (baseToFunctionField f).toAlgebra
    IsScalarTower k Γ(X, U) X.functionField := by
  intro algA algK
  refine IsScalarTower.of_algebraMap_eq' ?_
  change (X.presheaf.germ ⊤ (genericPoint X) trivial).hom.comp
      (f.appTop.hom.comp (Scheme.ΓSpecIso (CommRingCat.of k)).inv.hom) =
    (X.germToFunctionField U).hom.comp
      ((f.appLE ⊤ U le_top).hom.comp (Scheme.ΓSpecIso (CommRingCat.of k)).inv.hom)
  have hgerm : X.presheaf.map (homOfLE (le_top : U ≤ ⊤)).op ≫ X.germToFunctionField U =
      X.presheaf.germ ⊤ (genericPoint X) trivial :=
    X.presheaf.germ_res _ _ _
  simp only [Scheme.Hom.appLE, Scheme.Hom.appTop, ← RingHom.comp_assoc]
  congr 1
  rw [← hgerm]
  rfl
SchemeTheory.ValuativeProperness.Transcendence.trdeg_eq_of_isFractionRing
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace Transcendence
variable {k : Type u} [Field k]

/- The chart-tower argument is from the codimension-one boundary source unit attributed below. -/
theorem trdeg_eq_of_isFractionRing (k A K : Type u) [Field k] [CommRing A] [IsDomain A] [Field K]
    [Algebra k A] [Algebra A K] [IsFractionRing A K] [Algebra k K] [IsScalarTower k A K] :
    Algebra.trdeg k K = Algebra.trdeg k A
SchemeTheory.ValuativeProperness.Transcendence.exists_nat_trdeg_functionField
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace Transcendence
variable {k : Type u} [Field k]

/- The chart-tower argument is from the codimension-one boundary source unit attributed below. -/
theorem exists_nat_trdeg_functionField {X : Scheme.{u}} [IsIntegral X] (f : X ⟶ Spec (.of k))
    [LocallyOfFiniteType f] :
    let : Algebra k X.functionField := (baseToFunctionField f).toAlgebra
    ∃ n : ℕ, Algebra.trdeg k X.functionField = n ∧ topologicalKrullDim X = (n : WithBot ℕ∞) := by
  intro algK
  obtain ⟨_, ⟨U, hU, rfl⟩, hζU, -⟩ :=
    X.isBasis_affineOpens.exists_subset_of_mem_open (Set.mem_univ (genericPoint X)) isOpen_univ
  have : Nonempty U := ⟨⟨_, hζU⟩⟩
  let algA : Algebra k Γ(X, U) := f.sectionsAlgebra U
  have : Algebra.FiniteType k Γ(X, U) := chart_finiteType f hU
  have : IsScalarTower k Γ(X, U) X.functionField := isScalarTower_chart_ff f U
  have : IsFractionRing Γ(X, U) X.functionField :=
    functionField_isFractionRing_of_isAffineOpen X U hU
  have htr : Algebra.trdeg k X.functionField = Algebra.trdeg k Γ(X, U) :=
    trdeg_eq_of_isFractionRing k Γ(X, U) X.functionField
  obtain ⟨n, hn⟩ := Cardinal.lt_aleph0.mp (trdeg_lt_aleph0_of_finiteType (R := k) (S := Γ(X, U)))
  refine ⟨n, htr.trans hn, ?_⟩
  rw [topologicalKrullDim_eq_ringKrullDim_of_isAffineOpen_of_isIntegral f hU ⟨_, hζU⟩,
    Algebra.ringKrullDim_eq_toENat_trdeg_of_finiteType k Γ(X, U), hn, Cardinal.toENat_nat]
  rfl
SchemeTheory.ValuativeProperness.Transcendence.trdeg_residueField_stalk_eq
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace Transcendence
variable {k : Type u} [Field k]

/- The chart-tower argument is from the codimension-one boundary source unit attributed below. -/
theorem trdeg_residueField_stalk_eq {X : Scheme.{u}} [IsIntegral X] (f : X ⟶ Spec (.of k))
    [LocallyOfFiniteType f] (z : X) (hz : ringKrullDim (X.presheaf.stalk z) = 1)
    (n : ℕ) (hX : topologicalKrullDim X = (n : WithBot ℕ∞)) :
    let : Algebra k (IsLocalRing.ResidueField (X.presheaf.stalk z)) :=
      ((IsLocalRing.residue _).comp ((X.presheaf.germ ⊤ z trivial).hom.comp
        (f.appTop.hom.comp (Scheme.ΓSpecIso (.of k)).inv.hom))).toAlgebra
    Algebra.trdeg k (IsLocalRing.ResidueField (X.presheaf.stalk z)) = (n - 1 : ℕ) := by
  intro alg
  have hL1 :
      (Cardinal.toENat (Algebra.trdeg k (IsLocalRing.ResidueField (X.presheaf.stalk z))) :
        WithBot ℕ∞) =
      topologicalKrullDim ↥(closure ({z} : Set X)) :=
    AlgebraicGeometry.toENat_trdeg_residueField_eq_topologicalKrullDim_closure f z
  have hcd := ringKrullDim_stalk_add_topologicalKrullDim_closure_of_isIntegral f z
  rw [hz, hX, ← hL1] at hcd
  have h1 : (1 : WithBot ℕ∞) +
      Cardinal.toENat (Algebra.trdeg k (IsLocalRing.ResidueField (X.presheaf.stalk z))) =
      ((n : ℕ∞) : WithBot ℕ∞) := hcd
  have h2 : (1 : ℕ∞) +
      Cardinal.toENat (Algebra.trdeg k (IsLocalRing.ResidueField (X.presheaf.stalk z))) = n := by
    exact_mod_cast h1
  have h3 : Cardinal.toENat (Algebra.trdeg k (IsLocalRing.ResidueField (X.presheaf.stalk z))) =
      (n - 1 : ℕ) := by
    have hfin :
        Cardinal.toENat (Algebra.trdeg k (IsLocalRing.ResidueField (X.presheaf.stalk z))) ≠ ⊤ := by
      intro ht
      rw [ht, add_top] at h2
      exact ENat.top_ne_natCast n h2
    obtain ⟨m, hm⟩ := ENat.ne_top_iff_exists.mp hfin
    rw [← hm] at h2 ⊢
    have : 1 + m = n := by exact_mod_cast h2
    congr 1
    omega
  exact Cardinal.toENat_eq_natCast.mp h3
SchemeTheory.ValuativeProperness.StalkValuations.core
Source context 9 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace
namespace StalkValuations
theorem core {V Y : Scheme.{u}} [IsIntegral V] [IsIntegral Y] (α : V ⟶ Y) (hdom : DenseRange α.base)
    (z : V) [ValuationRing (V.presheaf.stalk z)]
    (hnd : ringKrullDim (Y.presheaf.stalk (α.base z)) ≠ 0) :
    ∃ (O : ValuationSubring Y.functionField) (_ : O ≠ ⊤) (ℓ₀ : Spec (CommRingCat.of O) ⟶ Y)
      (_ : Spec.map (CommRingCat.ofHom (algebraMap O Y.functionField)) ≫ ℓ₀ =
        Y.fromSpecStalk (genericPoint Y))
      (φ : CommRingCat.of O ⟶ V.presheaf.stalk z),
      IsLocalHom φ.hom ∧ Spec.map φ ≫ ℓ₀ = V.fromSpecStalk z ≫ α ∧
      O = (stalkValuationSubring V z).comap (α.functionFieldMap hdom)
AlgebraicGeometry.exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one
Source context 9 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace AlgebraicGeometry
open SchemeTheory.ValuativeProperness.Transcendence
open SchemeTheory.ValuativeProperness.StalkValuations
theorem
    exists_valuationSubring_functionField_of_ringKrullDim_stalk_eq_one
    {k : Type u} [Field k] {X Y : Scheme.{u}} (fX : X ⟶ Spec (.of k)) (fY : Y ⟶ Spec (.of k))
    [IsIntegral X] [LocallyOfFiniteType fX] [QuasiCompact fX] [IsIntegral Y] [IsProper fY]
    (U : X.Opens) (α : (U : Scheme.{u}) ⟶ Y) (hα : α ≫ fY = U.ι ≫ fX) (hdom : DenseRange α.base)
    (z : X) (hzU : z ∈ U) (hz₁ : ringKrullDim (X.presheaf.stalk z) = 1)
    (hzn : IsIntegrallyClosed (X.presheaf.stalk z))
    (hnd : ringKrullDim (Y.presheaf.stalk (α.base ⟨z, hzU⟩)) ≠ 0) :
    ∃ (O : ValuationSubring Y.functionField) (_ : O ≠ ⊤) (ℓ₀ : Spec (CommRingCat.of O) ⟶ Y)
      (_ : Spec.map (CommRingCat.ofHom (algebraMap O Y.functionField)) ≫ ℓ₀ =
        Y.fromSpecStalk (genericPoint Y))
      (d : ℕ) (_ : ((d + 1 : ℕ) : WithBot ℕ∞) = topologicalKrullDim Y)
      (g : Fin d → Y.functionField) (_ : ∀ i, g i ∈ O)
      (_ : ∀ Q : MvPolynomial (Fin d) k,
        O.valuation (Q.eval₂ ((Y.presheaf.germ ⊤ (genericPoint Y) trivial).hom.comp
          (fY.appTop.hom.comp (Scheme.ΓSpecIso (CommRingCat.of k)).inv.hom)) g) < 1 → Q = 0)
      (φ : CommRingCat.of O ⟶ X.presheaf.stalk z),
      IsLocalHom φ.hom ∧ Spec.map φ ≫ ℓ₀ = U.fromSpecStalkOfMem z hzU ≫ α
SchemeTheory.ValuativeProperness.Boundary.exists_notMem
Source context 10 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_isProper_notMem_ringKrullDim_stalk_eq_one_of_not_isProper.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace SchemeTheory.ValuativeProperness
open CategoryTheory CategoryTheory.Limits TopologicalSpace Topology
namespace Boundary
open AlgebraicGeometry
theorem exists_notMem {k : Type u} [Field k] {X : Scheme.{u}} (f : X ⟶ Spec (CommRingCat.of k))
    [IsIntegral X] [IsSeparated f] [LocallyOfFiniteType f] [QuasiCompact f]
    (hX : ¬ IsProper f)
    {P : Scheme.{u}} (p : P ⟶ Spec (CommRingCat.of k)) [IsProper p]
    (D : P.Opens) (τ : (D : Scheme.{u}) ⟶ X) [IsProper τ] (hτ : τ ≫ f = D.ι ≫ p)
    (V : X.Opens) [hV : Nonempty (V : Scheme.{u})] (ι : (V : Scheme.{u}) ⟶ (D : Scheme.{u}))
    (hτι : ι ≫ τ = V.ι) :
    ∃ x : P, x ∉ D
AlgebraicGeometry.exists_isProper_notMem_ringKrullDim_stalk_eq_one_of_not_isProper
Source context 9 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_isProper_notMem_ringKrullDim_stalk_eq_one_of_not_isProper.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace AlgebraicGeometry
open SchemeTheory.ValuativeProperness.Boundary
open SchemeTheory.ValuativeProperness.Transcendence
theorem
    exists_isProper_notMem_ringKrullDim_stalk_eq_one_of_not_isProper
    (k : Type u) [Field k] {X : Scheme.{u}} (f : X ⟶ Spec (CommRingCat.of k))
    [IsIntegral X] [IsSeparated f] [LocallyOfFiniteType f] [QuasiCompact f]
    (hX : ¬ IsProper f)
    {P : Scheme.{u}} (p : P ⟶ Spec (CommRingCat.of k)) [IsProper p] [IsIntegral P]
    (hn : ∀ y : P, IsIntegrallyClosed (P.presheaf.stalk y))
    (D : P.Opens) (τ : (D : Scheme.{u}) ⟶ X) [IsProper τ] (hτ : τ ≫ f = D.ι ≫ p)
    (V : X.Opens) [Nonempty (V : Scheme.{u})] (ι : (V : Scheme.{u}) ⟶ (D : Scheme.{u}))
    [IsOpenImmersion ι] (hτι : ι ≫ τ = V.ι) :
    ∃ (P' : Scheme.{u}) (π : P' ⟶ P) (V' : X.Opens)
      (ι' : (V' : Scheme.{u}) ⟶ (π ⁻¹ᵁ D : Scheme.{u})),
      IsIntegral P' ∧ (∀ y : P', IsIntegrallyClosed (P'.presheaf.stalk y)) ∧ IsProper π ∧
      Nonempty (V' : Scheme.{u}) ∧ IsOpenImmersion ι' ∧ ι' ≫ (π ∣_ D) ≫ τ = V'.ι ∧
      ∃ w : P', w ∉ (π ⁻¹ᵁ D : Set P') ∧ ringKrullDim (P'.presheaf.stalk w) = 1
AlgebraicGeometry.exists_isProper_isIso_morphismRestrict_ringKrullDim_stalk_eq_one_of_ringKrullDim_stalk_eq_one
Source context 7 commands

Surrounding namespaces, section variables, and local commands at this declaration.

@[expose] public section
open CategoryTheory CategoryTheory.Limits AlgebraicGeometry TopologicalSpace Topology
open AlgebraicCurve
universe u
open AbelianVarieties.NOSProofs.VarietyNormalization.AlgebraicGeometry.NormalizationOfVariety
  (chart_finiteType)
section
/-
Anthropic FLT upstream notice: Copyright 2026 Anthropic, PBC.
Released under Apache 2.0 license as described in the file LICENSE.
Adapted Anthropic FLT source (pinned revision):
https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/P2M/Sol/S_AlgebraicGeometry_exists_isProper_isIso_morphismRestrict_ringKrullDim_stalk_eq_one_of_ringKrullDim_stalk_eq_one.lean
Upstream NOTICE: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/NOTICE
Upstream per-file ATTRIBUTION: https://github.com/anthropics/fermats-last-theorem/blob/6e837e75355538c7f80bab5b956861e86c4eacc2/ATTRIBUTION.md
Copies of these notices are retained in the AbelianVarieties directory.
Existing upstream author/copyright comments in the source are retained below.

Local adaptation and maintenance: Naganori Yamaguchi (https://github.com/n-yamaguchi-0729).
AI assistance in local adaptation and maintenance: OpenAI Codex.
-/
namespace AlgebraicGeometry
theorem
    exists_isProper_isIso_morphismRestrict_ringKrullDim_stalk_eq_one_of_ringKrullDim_stalk_eq_one
    {k : Type u} [Field k] {X Y : Scheme.{u}} (fX : X ⟶ Spec (.of k)) (fY : Y ⟶ Spec (.of k))
    [IsIntegral X] [LocallyOfFiniteType fX] [QuasiCompact fX] [IsIntegral Y] [IsProper fY]
    (U : X.Opens) (α : (U : Scheme.{u}) ⟶ Y) (hα : α ≫ fY = U.ι ≫ fX) (hdom : DenseRange α.base)
    (z : X) (hzU : z ∈ U) (hz₁ : ringKrullDim (X.presheaf.stalk z) = 1)
    (hzn : IsIntegrallyClosed (X.presheaf.stalk z))
    (hnd : ringKrullDim (Y.presheaf.stalk (α.base ⟨z, hzU⟩)) ≠ 0) :
    ∃ (Y' : Scheme.{u}) (fY' : Y' ⟶ Spec (.of k)) (_ : IsIntegral Y') (_ : IsProper fY')
      (β : Y' ⟶ Y) (_ : β ≫ fY = fY') (W : Y.Opens) (_ : Dense (W : Set ↥Y)) (_ : IsIso (β ∣_ W))
      (U' : X.Opens) (hU' : U' ≤ U) (hzU' : z ∈ U')
      (α' : (U' : Scheme.{u}) ⟶ Y') (_ : α' ≫ β = X.homOfLE hU' ≫ α),
      ringKrullDim (Y'.presheaf.stalk (α'.base ⟨z, hzU'⟩)) = 1