Module

DifferentialCriteria.lean

Nyll.SchemeTheory.RingTheory.Smooth.DifferentialCriteria
23 declarations indexed from sourceView source ↗

Differential criteria for smoothness

Cotangent ranks control specialization over a discrete valuation ring. The other criteria control generic transcendence degree, kernels of smooth quotients, the smooth free locus, and descent along smooth morphisms.

Imports19
Imported by6

Declarations

AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.finrank_tensor_kaehler_eq_finrank_range_add
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
theorem finrank_tensor_kaehler_eq_finrank_range_add
    {R P S : Type u} [CommRing R] [CommRing P] [CommRing S]
    [Algebra R P] [Algebra P S] [Algebra R S] [IsScalarTower R P S]
    (hsurj : Function.Surjective (algebraMap P S)) [Module.Finite P Ω[P⁄R]]
    (k : Type u) [Field k] [Algebra S k] [Algebra P k] [IsScalarTower P S k] :
    Module.finrank k (k ⊗[P] Ω[P⁄R]) =
      Module.finrank k (LinearMap.range (cotangentComplexBaseChange R S P k)) +
        Module.finrank k (k ⊗[S] Ω[S⁄R])
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.ker_localRingHom
Source context 9 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
section LocSurj
variable {B A : Type u} [CommRing B] [CommRing A] (g : B →+* A) (hg : Function.Surjective g)
  (p : Ideal A) [p.IsPrime] (I : Ideal B) [I.IsPrime] (hI : I = Ideal.comap g p)
include hg in
theorem ker_localRingHom :
    RingHom.ker (Localization.localRingHom I p g hI) =
      (RingHom.ker g).map (algebraMap B (Localization.AtPrime I))
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.localRingHom_surjective_of_eq
Source context 9 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
section LocSurj
variable {B A : Type u} [CommRing B] [CommRing A] (g : B →+* A) (hg : Function.Surjective g)
  (p : Ideal A) [p.IsPrime] (I : Ideal B) [I.IsPrime] (hI : I = Ideal.comap g p)
include hg in
theorem localRingHom_surjective_of_eq :
    Function.Surjective (Localization.localRingHom I p g hI)
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.localRingHom_algebraMap
Source context 8 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
section Tower
variable {R B A : Type u} [CommRing R] [CommRing B] [CommRing A] [Algebra R B] [Algebra R A]
  (g : B →ₐ[R] A) (p : Ideal A) [p.IsPrime] (I : Ideal B) [I.IsPrime]
  (hI : I = Ideal.comap g.toRingHom p)
theorem localRingHom_algebraMap (r : R) :
    Localization.localRingHom I p g.toRingHom hI (algebraMap R _ r) =
      algebraMap R (Localization.AtPrime p) r
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.linearIndependent_one_tmul_of_map
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
theorem linearIndependent_one_tmul_of_map
    {P : Type u} [CommRing P] {k₁ k₂ : Type u} [Field k₁] [Field k₂] [Algebra P k₁] [Algebra P k₂]
    (σ : k₁ →+* k₂) (hσ : σ.comp (algebraMap P k₁) = algebraMap P k₂)
    {M : Type u} [AddCommGroup M] [Module P M] {ι : Type*} (m : ι → M)
    (h : LinearIndependent k₂ (fun i => (1 : k₂) ⊗ₜ[P] m i)) :
    LinearIndependent k₁ (fun i => (1 : k₁) ⊗ₜ[P] m i) := by
  classical
  let σₗ : k₁ →ₗ[P] k₂ :=
    { toFun := σ, map_add' := σ.map_add, map_smul' := fun p c => by
        simp only [Algebra.smul_def, map_mul, RingHom.id_apply]
        rw [← hσ]; rfl }
  let θ : k₁ ⊗[P] M →ₗ[P] k₂ ⊗[P] M := TensorProduct.map σₗ LinearMap.id
  have hθ : ∀ (c : k₁) (x : M), θ (c • ((1 : k₁) ⊗ₜ[P] x)) = σ c • ((1 : k₂) ⊗ₜ[P] x) := by
    intro c x
    rw [TensorProduct.smul_tmul', TensorProduct.smul_tmul', smul_eq_mul, mul_one, smul_eq_mul,
      mul_one]
    rfl
  rw [linearIndependent_iff'] at h ⊢
  intro s c hc i hi
  have := congrArg θ hc
  rw [map_sum, map_zero] at this
  simp only [hθ] at this
  have := h s (fun j => σ (c j)) this i hi
  exact (map_eq_zero σ).mp this
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.injective_of_linearIndependent_of_span
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
theorem injective_of_linearIndependent_of_span
    {k V W : Type*} [Field k] [AddCommGroup V] [Module k V] [AddCommGroup W] [Module k W]
    (T : V →ₗ[k] W) {ι : Type*} [Fintype ι] (u : ι → V)
    (hu : ∀ v : V, ∃ c : ι → k, ∑ i, c i • u i = v)
    (hT : LinearIndependent k (fun i => T (u i))) : Function.Injective T := by
  rw [← LinearMap.ker_eq_bot, Submodule.eq_bot_iff]
  intro v hv
  obtain ⟨c, rfl⟩ := hu v
  rw [LinearMap.mem_ker, map_sum] at hv
  simp only [map_smul] at hv
  have hc := Fintype.linearIndependent_iff.mp hT c hv
  simp only [hc, zero_smul, Finset.sum_const_zero]
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.exists_sum_smul_one_tmul
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
theorem exists_sum_smul_one_tmul
    {P : Type u} [CommRing P] (k : Type u) [CommRing k] [Algebra P k]
    {ι : Type*} [Fintype ι] (w : ι → P) (K : Ideal P) (hK : K = Ideal.span (Set.range w))
    (v : k ⊗[P] K) :
    ∃ c : ι → k, ∑ i, c i • ((1 : k) ⊗ₜ[P] (⟨w i, hK ▸ Ideal.subset_span ⟨i, rfl⟩⟩ : K)) = v
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.cotangent_one_tmul
Source context 8 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
section CotangentRank
variable (R P S κ : Type u) [CommRing R] [CommRing P] [CommRing S] [Field κ]
  [Algebra R P] [Algebra P S] [Algebra P κ] [Algebra S κ] [IsScalarTower P S κ]
theorem cotangent_one_tmul (w : RingHom.ker (algebraMap P S)) :
    cotangentComplexBaseChange R S P κ ((1 : κ) ⊗ₜ[P] w) =
      (1 : κ) ⊗ₜ[P] D R P w.val
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.cotangent_range_eq_span
Source context 8 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
section CotangentRank
variable (R P S κ : Type u) [CommRing R] [CommRing P] [CommRing S] [Field κ]
  [Algebra R P] [Algebra P S] [Algebra P κ] [Algebra S κ] [IsScalarTower P S κ]
theorem cotangent_range_eq_span
    {ι : Type*} [Finite ι] (w : ι → P)
    (hker : RingHom.ker (algebraMap P S) = Ideal.span (Set.range w)) :
    LinearMap.range (cotangentComplexBaseChange R S P κ) =
      Submodule.span κ (Set.range (fun i => cotangentComplexBaseChange R S P κ
        ((1 : κ) ⊗ₜ[P] ⟨w i, hker ▸ Ideal.subset_span ⟨i, rfl⟩⟩))) := by
  let : Fintype ι := Fintype.ofFinite ι
  apply le_antisymm
  · rintro _ ⟨x, rfl⟩
    obtain ⟨c, rfl⟩ := exists_sum_smul_one_tmul κ w _ hker x
    rw [map_sum]
    refine Submodule.sum_mem _ fun j _ => ?_
    rw [map_smul]
    exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨j, rfl⟩)
  · rw [Submodule.span_le]
    rintro _ ⟨j, rfl⟩
    exact ⟨(1 : κ) ⊗ₜ[P] ⟨w j, hker ▸ Ideal.subset_span ⟨j, rfl⟩⟩, rfl⟩
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.cotangent_injective_and_finrank
Source context 8 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
section CotangentRank
variable (R P S κ : Type u) [CommRing R] [CommRing P] [CommRing S] [Field κ]
  [Algebra R P] [Algebra P S] [Algebra P κ] [Algebra S κ] [IsScalarTower P S κ]
theorem cotangent_injective_and_finrank
    {ι : Type*} [Fintype ι] (w : ι → P)
    (hker : RingHom.ker (algebraMap P S) = Ideal.span (Set.range w))
    (hli : LinearIndependent κ (fun i => (1 : κ) ⊗ₜ[P] D R P (w i))) :
    Function.Injective (cotangentComplexBaseChange R S P κ) ∧
      Module.finrank κ (LinearMap.range (cotangentComplexBaseChange R S P κ)) =
        Fintype.card ι := by
  classical
  let u : ι → κ ⊗[P] RingHom.ker (algebraMap P S) :=
    fun i => (1 : κ) ⊗ₜ[P] ⟨w i, hker ▸ Ideal.subset_span ⟨i, rfl⟩⟩
  have hcomp : (fun i => cotangentComplexBaseChange R S P κ (u i)) =
      (fun i => (1 : κ) ⊗ₜ[P] D R P (w i)) := by
    funext i
    exact cotangent_one_tmul R P S κ ⟨w i, hker ▸ Ideal.subset_span ⟨i, rfl⟩⟩
  have hliImage : LinearIndependent κ
      (fun i => cotangentComplexBaseChange R S P κ (u i)) := hcomp.symm ▸ hli
  have hgen : ∀ v, ∃ c : ι → κ, ∑ i, c i • u i = v :=
    exists_sum_smul_one_tmul κ w _ hker
  have hinj : Function.Injective (cotangentComplexBaseChange R S P κ) :=
    injective_of_linearIndependent_of_span _ u hgen hliImage
  have hliSource : LinearIndependent κ u :=
    LinearIndependent.of_comp (cotangentComplexBaseChange R S P κ) hliImage
  have hspan : Submodule.span κ (Set.range u) = ⊤ := by
    rw [eq_top_iff]
    rintro v -
    obtain ⟨c, rfl⟩ := hgen v
    exact Submodule.sum_mem _ fun i _ =>
      Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, rfl⟩)
  let b : Module.Basis ι κ (κ ⊗[P] RingHom.ker (algebraMap P S)) :=
    Module.Basis.mk hliSource hspan.ge
  refine ⟨hinj, ?_⟩
  rw [LinearMap.finrank_range_of_inj hinj]
  exact Module.finrank_eq_card_basis b
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.eq_bot_of_finrank_tensor_eq_zero
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
theorem eq_bot_of_finrank_tensor_eq_zero
    {T : Type u} [CommRing T] [IsLocalRing T] (K : Ideal T) (hK : K.FG)
    (k : Type u) [Field k] [Algebra T k]
    [Algebra (IsLocalRing.ResidueField T) k] [IsScalarTower T (IsLocalRing.ResidueField T) k]
    (h : Module.finrank k (k ⊗[T] K) = 0) : K = ⊥
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.finrank_residueField_tensor_kaehler_localization
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
theorem finrank_residueField_tensor_kaehler_localization
    {R A : Type u} [CommRing R] [CommRing A] [Algebra R A] (p : Ideal A) [p.IsPrime] :
    Module.finrank p.ResidueField
        (p.ResidueField ⊗[Localization.AtPrime p] Ω[Localization.AtPrime p⁄R]) =
      Module.finrank p.ResidueField (p.ResidueField ⊗[A] Ω[A⁄R])
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.isDomain_localization_of_isSmoothAt
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
theorem isDomain_localization_of_isSmoothAt
    {R : Type u} [CommRing R] [IsDomain R] [UniqueFactorizationMonoid R]
    {C : Type u} [CommRing C] [Algebra R C] [Algebra.FinitePresentation R C]
    (P : Ideal C) [P.IsPrime] [Algebra.IsSmoothAt R P] :
    IsDomain (Localization.AtPrime P)
AbelianVarieties.NOSProofs.SmoothSpecialization.JacobianCriterion.isSmoothAt_of_relations
Source context 8 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
namespace JacobianCriterion
section Main
variable {R B A : Type u} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
  [CommRing B] [Nontrivial B] [Algebra R B] [IsNoetherianRing B] [Algebra.FinitePresentation R B]
  [Algebra.FormallySmooth R B] [Module.Free B Ω[B⁄R]] [Module.Finite B Ω[B⁄R]]
  [CommRing A] [Algebra R A]
theorem isSmoothAt_of_relations (g : B →ₐ[R] A) (hg : Function.Surjective g)
    (p q : Ideal A) [p.IsPrime] [q.IsPrime] (hqp : q ≤ p) [Algebra.IsSmoothAt R q]
    {ι : Type*} [Fintype ι] (z : ι → B) (hz : ∀ i, g (z i) = 0)
    (hli : letI := ((algebraMap (Localization.AtPrime p) p.ResidueField).comp
        (Localization.localRingHom (Ideal.comap g.toRingHom p) p g.toRingHom rfl)).toAlgebra
      LinearIndependent p.ResidueField (fun i => (1 : p.ResidueField)
        ⊗ₜ[Localization.AtPrime (Ideal.comap g.toRingHom p)]
          D R (Localization.AtPrime (Ideal.comap g.toRingHom p))
            (algebraMap B (Localization.AtPrime (Ideal.comap g.toRingHom p)) (z i))))
    (hcount : Module.finrank B Ω[B⁄R] =
      Fintype.card ι + Module.finrank q.ResidueField (q.ResidueField ⊗[A] Ω[A⁄R])) :
    Algebra.IsSmoothAt R p := by
  classical
  set J₀ : Ideal B := Ideal.span (Set.range z) with hJ₀
  have hJ₀le : ∀ b ∈ J₀, g b = 0 := by
    intro b hb
    rw [← RingHom.mem_ker]
    revert b hb
    change J₀ ≤ RingHom.ker g
    rw [hJ₀, Ideal.span_le]
    rintro _ ⟨i, rfl⟩
    exact hz i
  have : Algebra.FinitePresentation R (B ⧸ J₀) :=
    Algebra.FinitePresentation.quotient ⟨(Set.finite_range z).toFinset, by rw
        [Set.Finite.coe_toFinset, hJ₀]⟩
  set π : B ⧸ J₀ →ₐ[R] A := Ideal.Quotient.liftₐ J₀ g hJ₀le with hπdef
  have hπmk : ∀ b : B, π (Ideal.Quotient.mk J₀ b) = g b := fun b => rfl
  have hπsurj : Function.Surjective π :=
    Ideal.Quotient.lift_surjective_of_surjective J₀ hJ₀le hg
  have hπcomp : π.toRingHom.comp (Ideal.Quotient.mk J₀) = g.toRingHom := RingHom.ext fun b => rfl
  set 𝔓 : Ideal B := Ideal.comap g.toRingHom p with h𝔓
  set 𝔓C : Ideal (B ⧸ J₀) := Ideal.comap π.toRingHom p with h𝔓C
  set 𝔮C : Ideal (B ⧸ J₀) := Ideal.comap π.toRingHom q with h𝔮C
  have h𝔮𝔓 : 𝔮C ≤ 𝔓C := Ideal.comap_mono hqp
  have h𝔓' : 𝔓 = Ideal.comap (Ideal.Quotient.mk J₀) 𝔓C := by
    rw [h𝔓C, Ideal.comap_comap, hπcomp]
  set φ : Localization.AtPrime 𝔓 →+* Localization.AtPrime p :=
    Localization.localRingHom 𝔓 p g.toRingHom rfl with hφ
  set χ : Localization.AtPrime 𝔓 →+* Localization.AtPrime 𝔓C :=
    Localization.localRingHom 𝔓 𝔓C (Ideal.Quotient.mk J₀) h𝔓' with hχ
  set φ' : Localization.AtPrime 𝔓C →+* Localization.AtPrime p :=
    Localization.localRingHom 𝔓C p π.toRingHom rfl with hφ'
  set φq : Localization.AtPrime 𝔮C →+* Localization.AtPrime q :=
    Localization.localRingHom 𝔮C q π.toRingHom rfl with hφq
  have hφsurj : Function.Surjective φ := RingHom.surjective_localRingHom_of_surjective g.toRingHom
      hg p
  have hχsurj : Function.Surjective χ :=
    localRingHom_surjective_of_eq (Ideal.Quotient.mk J₀)
      Ideal.Quotient.mk_surjective 𝔓C 𝔓 h𝔓'
  have hφ'surj : Function.Surjective φ' := RingHom.surjective_localRingHom_of_surjective
      π.toRingHom hπsurj p
  have hφqsurj : Function.Surjective φq := RingHom.surjective_localRingHom_of_surjective
      π.toRingHom hπsurj q
  have hχker : RingHom.ker χ = J₀.map (algebraMap B (Localization.AtPrime 𝔓)) := by
    rw [hχ, ker_localRingHom (Ideal.Quotient.mk J₀) Ideal.Quotient.mk_surjective 𝔓C 𝔓 h𝔓',
      Ideal.mk_ker]
  have hφ'ker : RingHom.ker φ' = (RingHom.ker π).map (algebraMap (B ⧸ J₀) (Localization.AtPrime
      𝔓C)) :=
    ker_localRingHom π.toRingHom hπsurj p 𝔓C rfl
  have hφqker : RingHom.ker φq = (RingHom.ker π).map (algebraMap (B ⧸ J₀) (Localization.AtPrime
      𝔮C)) :=
    ker_localRingHom π.toRingHom hπsurj q 𝔮C rfl
  have hφ'χ : φ'.comp χ = φ := by
    refine IsLocalization.ringHom_ext 𝔓.primeCompl (RingHom.ext fun b => ?_)
    simp only [RingHom.coe_comp, Function.comp_apply]
    rw [hχ, Localization.localRingHom_to_map, hφ', Localization.localRingHom_to_map, hφ,
      Localization.localRingHom_to_map]
    rfl
  let iPS : Algebra (Localization.AtPrime 𝔓) (Localization.AtPrime p) := φ.toAlgebra
  let iPS' : Algebra (Localization.AtPrime 𝔓) (Localization.AtPrime 𝔓C) := χ.toAlgebra
  let iS'S : Algebra (Localization.AtPrime 𝔓C) (Localization.AtPrime p) := φ'.toAlgebra
  let iTU : Algebra (Localization.AtPrime 𝔮C) (Localization.AtPrime q) := φq.toAlgebra
  have : IsScalarTower R (Localization.AtPrime 𝔓) (Localization.AtPrime p) :=
    IsScalarTower.of_algebraMap_eq fun r => (localRingHom_algebraMap g p 𝔓 rfl r).symm
  have : IsScalarTower R (Localization.AtPrime 𝔓C) (Localization.AtPrime p) :=
    IsScalarTower.of_algebraMap_eq fun r => (localRingHom_algebraMap π p 𝔓C rfl r).symm
  have : IsScalarTower R (Localization.AtPrime 𝔮C) (Localization.AtPrime q) :=
    IsScalarTower.of_algebraMap_eq fun r => (localRingHom_algebraMap π q 𝔮C rfl r).symm
  have : IsScalarTower R (Localization.AtPrime 𝔓) (Localization.AtPrime 𝔓C) :=
    IsScalarTower.of_algebraMap_eq fun r => by
      change _ = χ _
      rw [hχ, IsScalarTower.algebraMap_apply R B (Localization.AtPrime 𝔓),
        Localization.localRingHom_to_map,
        IsScalarTower.algebraMap_apply R (B ⧸ J₀) (Localization.AtPrime 𝔓C)]
      rfl
  have : IsScalarTower (Localization.AtPrime 𝔓) (Localization.AtPrime 𝔓C) (Localization.AtPrime p)
      :=
    IsScalarTower.of_algebraMap_eq fun x => (RingHom.congr_fun hφ'χ x).symm
  let iPκ : Algebra (Localization.AtPrime 𝔓) p.ResidueField :=
    ((algebraMap (Localization.AtPrime p) p.ResidueField).comp φ).toAlgebra
  have : IsScalarTower (Localization.AtPrime 𝔓) (Localization.AtPrime p) p.ResidueField :=
    IsScalarTower.of_algebraMap_eq fun _ => rfl
  let iPκ' : Algebra (Localization.AtPrime 𝔓) 𝔓C.ResidueField :=
    ((algebraMap (Localization.AtPrime 𝔓C) 𝔓C.ResidueField).comp χ).toAlgebra
  have : IsScalarTower (Localization.AtPrime 𝔓) (Localization.AtPrime 𝔓C) 𝔓C.ResidueField :=
    IsScalarTower.of_algebraMap_eq fun _ => rfl
  let iTκU : Algebra (Localization.AtPrime 𝔮C) q.ResidueField :=
    ((algebraMap (Localization.AtPrime q) q.ResidueField).comp φq).toAlgebra
  have : IsScalarTower (Localization.AtPrime 𝔮C) (Localization.AtPrime q) q.ResidueField :=
    IsScalarTower.of_algebraMap_eq fun _ => rfl
  have : SMulCommClass (Localization.AtPrime 𝔓) p.ResidueField p.ResidueField :=
    @Algebra.to_smulCommClass _ _ _ _ iPκ
  have hcommPκ : SMulCommClass (Localization.AtPrime 𝔓) 𝔓C.ResidueField 𝔓C.ResidueField :=
    @Algebra.to_smulCommClass _ _ _ _ iPκ'
  have hcommTκ : SMulCommClass (Localization.AtPrime 𝔮C) q.ResidueField q.ResidueField :=
    @Algebra.to_smulCommClass _ _ _ _ iTκU
  let tensorDifferentials : Module 𝔓C.ResidueField
      (𝔓C.ResidueField ⊗[Localization.AtPrime 𝔓] Ω[Localization.AtPrime 𝔓⁄R]) :=
    @TensorProduct.leftModule (Localization.AtPrime 𝔓) 𝔓C.ResidueField _ _
      𝔓C.ResidueField Ω[Localization.AtPrime 𝔓⁄R] _ _ _
      (@Algebra.toModule _ _ _ _ iPκ') _ hcommPκ
  let tensorKernelQ : Module q.ResidueField
      (q.ResidueField ⊗[Localization.AtPrime 𝔮C]
        RingHom.ker (algebraMap (Localization.AtPrime 𝔮C) (Localization.AtPrime q))) :=
    @TensorProduct.leftModule (Localization.AtPrime 𝔮C) q.ResidueField _ _
      q.ResidueField (RingHom.ker (algebraMap (Localization.AtPrime 𝔮C)
        (Localization.AtPrime q))) _ _ _ (@Algebra.toModule _ _ _ _ iTκU) _ hcommTκ
  have : Algebra.FormallyEtale B (Localization.AtPrime 𝔓) :=
    Algebra.FormallyEtale.of_isLocalization (M := 𝔓.primeCompl)
  have : Algebra.FormallySmooth R (Localization.AtPrime 𝔓) :=
    Algebra.FormallySmooth.comp R B (Localization.AtPrime 𝔓)
  have eΩP : Localization.AtPrime 𝔓 ⊗[B] Ω[B⁄R] ≃ₗ[Localization.AtPrime 𝔓]
      Ω[Localization.AtPrime 𝔓⁄R] :=
    KaehlerDifferential.tensorKaehlerEquivOfFormallyEtale R B (Localization.AtPrime 𝔓)
  have : Module.Free (Localization.AtPrime 𝔓) Ω[Localization.AtPrime 𝔓⁄R] := Module.Free.of_equiv
      eΩP
  have : Module.Finite (Localization.AtPrime 𝔓) Ω[Localization.AtPrime 𝔓⁄R] :=
    Module.Finite.equiv eΩP
  have hrankP : Module.finrank (Localization.AtPrime 𝔓) Ω[Localization.AtPrime 𝔓⁄R] =
      Module.finrank B Ω[B⁄R] := by
    rw [← eΩP.finrank_eq, Module.finrank_baseChange]
  have hzker : ∀ i, algebraMap B (Localization.AtPrime 𝔓) (z i) ∈ RingHom.ker χ := fun i => by
    rw [hχker]; exact Ideal.mem_map_of_mem _ (Ideal.subset_span ⟨i, rfl⟩)
  have hkerspan : RingHom.ker (algebraMap (Localization.AtPrime 𝔓) (Localization.AtPrime 𝔓C)) =
      Ideal.span (Set.range (fun i => algebraMap B (Localization.AtPrime 𝔓) (z i))) := by
    change RingHom.ker χ = _
    rw [hχker, hJ₀, Ideal.map_span, ← Set.range_comp]
    rfl
  have hli' : LinearIndependent 𝔓C.ResidueField (fun i => (1 : 𝔓C.ResidueField)
      ⊗ₜ[Localization.AtPrime 𝔓] D R (Localization.AtPrime 𝔓)
        (algebraMap B (Localization.AtPrime 𝔓) (z i))) := by
    have : IsLocalHom φ' := Localization.isLocalHom_localRingHom 𝔓C p π.toRingHom rfl
    refine linearIndependent_one_tmul_of_map (IsLocalRing.ResidueField.map φ') ?_ _ hli
    refine RingHom.ext fun x => ?_
    change IsLocalRing.ResidueField.map φ' (IsLocalRing.residue _ (χ x)) =
      IsLocalRing.residue _ (φ x)
    rw [IsLocalRing.ResidueField.map_residue, ← hφ'χ]
    rfl
  obtain ⟨hinj', hrange'⟩ := cotangent_injective_and_finrank R
    (Localization.AtPrime 𝔓) (Localization.AtPrime 𝔓C) 𝔓C.ResidueField
    (fun i => algebraMap B (Localization.AtPrime 𝔓) (z i)) hkerspan hli'
  have hS'sm : Algebra.IsSmoothAt R 𝔓C :=
    (Algebra.FormallySmooth.iff_injective_cotangentComplexBaseChange_residueField (R := R)
      (S := Localization.AtPrime 𝔓C) (Localization.AtPrime 𝔓) hχsurj
        (IsNoetherian.noetherian _)).mpr hinj'
  have : Module.Finite (Localization.AtPrime 𝔓C) Ω[Localization.AtPrime 𝔓C⁄R] := inferInstance
  have : Module.Free (Localization.AtPrime 𝔓C) Ω[Localization.AtPrime 𝔓C⁄R] :=
    Module.free_of_flat_of_isLocalRing
  have hcountS' := finrank_tensor_kaehler_eq_finrank_range_add (R := R) hχsurj 𝔓C.ResidueField
  have hrankS' : Module.finrank (Localization.AtPrime 𝔓C) Ω[Localization.AtPrime 𝔓C⁄R] =
      Module.finrank q.ResidueField (q.ResidueField ⊗[A] Ω[A⁄R]) := by
    rw [← Module.finrank_baseChange (R := 𝔓C.ResidueField)]
    rw [hrange', Module.finrank_baseChange, hrankP, hcount] at hcountS'
    omega
  have : IsDomain (Localization.AtPrime 𝔓C) := isDomain_localization_of_isSmoothAt (R := R) 𝔓C
  have hTsm : Algebra.IsSmoothAt R 𝔮C := by
    have hmem : (⟨𝔓C, inferInstance⟩ : PrimeSpectrum (B ⧸ J₀)) ∈ Algebra.smoothLocus R (B ⧸ J₀) :=
      hS'sm
    have hspec : (⟨𝔮C, inferInstance⟩ : PrimeSpectrum (B ⧸ J₀)) ⤳ ⟨𝔓C, inferInstance⟩ :=
      (PrimeSpectrum.le_iff_specializes _ _).mp h𝔮𝔓
    exact hspec.mem_open Algebra.isOpen_smoothLocus hmem
  let iS'T : Algebra (Localization.AtPrime 𝔓C) (Localization.AtPrime 𝔮C) :=
    IsLocalization.localizationAlgebraOfSubmonoidLe (Localization.AtPrime 𝔓C)
      (Localization.AtPrime 𝔮C) 𝔓C.primeCompl 𝔮C.primeCompl
      (fun x hx h => hx (h𝔮𝔓 h))
  have : IsScalarTower (B ⧸ J₀) (Localization.AtPrime 𝔓C) (Localization.AtPrime 𝔮C) :=
    IsLocalization.localization_isScalarTower_of_submonoid_le _ _ _ _ _
  have : IsScalarTower R (Localization.AtPrime 𝔓C) (Localization.AtPrime 𝔮C) :=
    IsScalarTower.of_algebraMap_eq fun r => by
      rw [IsScalarTower.algebraMap_apply R (B ⧸ J₀) (Localization.AtPrime 𝔮C),
        IsScalarTower.algebraMap_apply R (B ⧸ J₀) (Localization.AtPrime 𝔓C),
        ← IsScalarTower.algebraMap_apply (B ⧸ J₀)]
  have : IsLocalization (𝔮C.primeCompl.map (algebraMap (B ⧸ J₀) (Localization.AtPrime 𝔓C)))
      (Localization.AtPrime 𝔮C) :=
    IsLocalization.isLocalization_of_submonoid_le _ _ 𝔓C.primeCompl 𝔮C.primeCompl
      (fun x hx h => hx (h𝔮𝔓 h))
  have : Algebra.FormallyEtale (Localization.AtPrime 𝔓C) (Localization.AtPrime 𝔮C) :=
    Algebra.FormallyEtale.of_isLocalization
      (M := 𝔮C.primeCompl.map (algebraMap (B ⧸ J₀) (Localization.AtPrime 𝔓C)))
  have eΩT : Localization.AtPrime 𝔮C ⊗[Localization.AtPrime 𝔓C] Ω[Localization.AtPrime 𝔓C⁄R]
      ≃ₗ[Localization.AtPrime 𝔮C] Ω[Localization.AtPrime 𝔮C⁄R] :=
    KaehlerDifferential.tensorKaehlerEquivOfFormallyEtale R _ _
  have : Module.Free (Localization.AtPrime 𝔮C) Ω[Localization.AtPrime 𝔮C⁄R] :=
    Module.Free.of_equiv eΩT
  have : Module.Finite (Localization.AtPrime 𝔮C) Ω[Localization.AtPrime 𝔮C⁄R] :=
    Module.Finite.equiv eΩT
  have hrankT : Module.finrank (Localization.AtPrime 𝔮C) Ω[Localization.AtPrime 𝔮C⁄R] =
      Module.finrank q.ResidueField (q.ResidueField ⊗[A] Ω[A⁄R]) := by
    rw [← eΩT.finrank_eq, Module.finrank_baseChange, hrankS']
  have hinjU : Function.Injective (cotangentComplexBaseChange R (Localization.AtPrime q)
      (Localization.AtPrime 𝔮C) q.ResidueField) :=
    (Algebra.FormallySmooth.iff_injective_cotangentComplexBaseChange_residueField (R := R)
      (S := Localization.AtPrime q) (Localization.AtPrime 𝔮C) hφqsurj
        (IsNoetherian.noetherian _)).mp ‹Algebra.IsSmoothAt R q›
  have hcountU := finrank_tensor_kaehler_eq_finrank_range_add (R := R) hφqsurj q.ResidueField
  rw [Module.finrank_baseChange, hrankT, finrank_residueField_tensor_kaehler_localization,
    LinearMap.finrank_range_of_inj hinjU] at hcountU
  have hkerU : RingHom.ker φq = ⊥ := by
    have : IsLocalHom φq := Localization.isLocalHom_localRingHom 𝔮C q π.toRingHom rfl
    let : Algebra (IsLocalRing.ResidueField (Localization.AtPrime 𝔮C)) q.ResidueField :=
      (IsLocalRing.ResidueField.map φq).toAlgebra
    have : IsScalarTower (Localization.AtPrime 𝔮C)
        (IsLocalRing.ResidueField (Localization.AtPrime 𝔮C)) q.ResidueField :=
      IsScalarTower.of_algebraMap_eq fun x => by
        change IsLocalRing.residue _ (φq x) = IsLocalRing.ResidueField.map φq (IsLocalRing.residue
            _ x)
        rw [IsLocalRing.ResidueField.map_residue]
    have h0 : Module.finrank q.ResidueField (q.ResidueField ⊗[Localization.AtPrime 𝔮C]
        (RingHom.ker (algebraMap (Localization.AtPrime 𝔮C) (Localization.AtPrime q)))) = 0 := by
      have hcountU' : Module.finrank q.ResidueField (q.ResidueField ⊗[A] Ω[A⁄R]) =
          Module.finrank q.ResidueField (q.ResidueField ⊗[Localization.AtPrime 𝔮C]
            RingHom.ker (algebraMap (Localization.AtPrime 𝔮C) (Localization.AtPrime q))) +
            Module.finrank q.ResidueField (q.ResidueField ⊗[A] Ω[A⁄R]) := hcountU
      omega
    exact eq_bot_of_finrank_tensor_eq_zero _ (IsNoetherian.noetherian _) q.ResidueField h0
  have hkerS' : RingHom.ker φ' = ⊥ := by
    rw [hφ'ker, Ideal.map_eq_bot_iff_le_ker]
    intro c hc
    rw [RingHom.mem_ker]
    have hcT : algebraMap (B ⧸ J₀) (Localization.AtPrime 𝔮C) c = 0 := by
      have hmem : algebraMap (B ⧸ J₀) (Localization.AtPrime 𝔮C) c ∈ RingHom.ker φq := by
        rw [hφqker]; exact Ideal.mem_map_of_mem _ hc
      rwa [hkerU, Ideal.mem_bot] at hmem
    obtain ⟨⟨t, ht⟩, htc⟩ := (IsLocalization.map_eq_zero_iff 𝔮C.primeCompl _ c).mp hcT
    have hmul : algebraMap (B ⧸ J₀) (Localization.AtPrime 𝔓C) t *
        algebraMap (B ⧸ J₀) (Localization.AtPrime 𝔓C) c = 0 := by
      rw [← map_mul, htc, map_zero]
    rcases mul_eq_zero.mp hmul with h0 | h0
    · exfalso
      obtain ⟨⟨s, hs⟩, hst⟩ := (IsLocalization.map_eq_zero_iff 𝔓C.primeCompl _ t).mp h0
      have : s * t ∈ 𝔮C := by rw [hst]; exact 𝔮C.zero_mem
      rcases (inferInstance : 𝔮C.IsPrime).mem_or_mem this with h1 | h1
      · exact hs (h𝔮𝔓 h1)
      · exact ht h1
    · exact h0
  have hφ'inj : Function.Injective φ' := (RingHom.injective_iff_ker_eq_bot φ').mpr hkerS'
  let φ'ₐ : Localization.AtPrime 𝔓C →ₐ[R] Localization.AtPrime p :=
    { φ' with commutes' := fun r => localRingHom_algebraMap π p 𝔓C rfl r }
  exact Algebra.FormallySmooth.of_equiv (AlgEquiv.ofBijective φ'ₐ ⟨hφ'inj, hφ'surj⟩)
Algebra.isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq
Source context 6 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq.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 AbelianVarieties.NOSProofs.SmoothSpecialization
open TensorProduct KaehlerDifferential
universe u
open JacobianCriterion
theorem _root_.Algebra.isSmoothAt_of_le_of_finrank_tensorProduct_kaehlerDifferential_eq
    {R : Type u} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
    {A : Type u} [CommRing A] [Algebra R A] [Algebra.FiniteType R A]
    (p q : Ideal A) [p.IsPrime] [q.IsPrime] (hqp : q ≤ p) [Algebra.IsSmoothAt R q]
    (h : Module.finrank p.ResidueField (p.ResidueField ⊗[A] Ω[A⁄R]) =
      Module.finrank q.ResidueField (q.ResidueField ⊗[A] Ω[A⁄R])) :
    Algebra.IsSmoothAt R p
AbelianVarieties.NOSProofs.GenericTranscendence.GenericBound.main
Source context 7 commands

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

@[expose] public section
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_Algebra_FiniteType_exists_notMem_under_forall_trdeg_quotient_le.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 AbelianVarieties.NOSProofs.GenericTranscendence
open Polynomial
universe u v
namespace GenericBound
open AbelianVarieties.NOSProofs.TensorTranscendence.TensorPrimes
theorem main
    {A : Type u} {B : Type v} [CommRing A] [CommRing B] [Algebra A B] [Algebra.FiniteType A B]
    (𝔮 : Ideal B) [𝔮.IsPrime] :
    ∃ s : A, s ∉ 𝔮.under A ∧ ∀ (𝔔 : Ideal B) [𝔔.IsPrime], 𝔮 ≤ 𝔔 → s ∉ 𝔔.under A →
      Algebra.trdeg (A ⧸ 𝔔.under A) (B ⧸ 𝔔) ≤ Algebra.trdeg (A ⧸ 𝔮.under A) (B ⧸ 𝔮)
Algebra.FiniteType.exists_notMem_under_forall_trdeg_quotient_le
Source context 5 commands

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

@[expose] public section
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_Algebra_FiniteType_exists_notMem_under_forall_trdeg_quotient_le.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 AbelianVarieties.NOSProofs.GenericTranscendence
open Polynomial
universe u v
theorem _root_.Algebra.FiniteType.exists_notMem_under_forall_trdeg_quotient_le
    {A : Type u} {B : Type v} [CommRing A] [CommRing B] [Algebra A B] [Algebra.FiniteType A B]
    (𝔮 : Ideal B) [𝔮.IsPrime] :
    ∃ s : A, s ∉ 𝔮.under A ∧ ∀ (𝔔 : Ideal B) [𝔔.IsPrime], 𝔮 ≤ 𝔔 → s ∉ 𝔔.under A →
      Algebra.trdeg (A ⧸ 𝔔.under A) (B ⧸ 𝔔) ≤ Algebra.trdeg (A ⧸ 𝔮.under A) (B ⧸ 𝔮)
Algebra.ker_algebraMap_eq_bot_of_formallySmooth_of_finrank_le
Source context 5 commands

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

@[expose] public section
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_Algebra_ker_algebraMap_eq_bot_of_formallySmooth_of_finrank_le.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 AbelianVarieties.NOSProofs.CotangentKernel
open TensorProduct
universe u
theorem _root_.Algebra.ker_algebraMap_eq_bot_of_formallySmooth_of_finrank_le
    {k P S : Type u} [Field k] [CommRing P] [CommRing S] [IsLocalRing P] [IsLocalRing S]
        [IsNoetherianRing P]
    [Algebra k P] [Algebra k S] [Algebra P S] [IsScalarTower k P S]
    [Algebra.FormallySmooth k P] [Algebra.FormallySmooth k S] [Module.Finite P Ω[P⁄k]]
    (hPS : Function.Surjective (algebraMap P S))
    (hrank : Module.finrank (IsLocalRing.ResidueField S) (IsLocalRing.ResidueField S ⊗[S] (S ⊗[P]
        Ω[P⁄k])) ≤
      Module.finrank (IsLocalRing.ResidueField S) (IsLocalRing.ResidueField S ⊗[S] Ω[S⁄k])) :
    RingHom.ker (algebraMap P S) = ⊥
AbelianVarieties.NOSProofs.SmoothMinimalPrimes.MinimalPrimes.isSmoothAt_of_forall_linearIndepOn_pow
Source context 5 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_mem_minimalPrimes_of_dense_of_formallySmooth_residueField.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 AbelianVarieties.NOSProofs.SmoothMinimalPrimes
universe u
namespace MinimalPrimes
theorem isSmoothAt_of_forall_linearIndepOn_pow
    {k : Type u} [Field k] {B : Type u} [CommRing B] [Algebra k B] [Algebra.FiniteType k B]
        [IsReduced B]
    (p : ℕ) [ExpChar k p]
    (𝔮 : Ideal B) [𝔮.IsPrime] (h𝔮 : 𝔮 ∈ minimalPrimes B)
    (H : ∀ s : Finset (Localization.AtPrime 𝔮), LinearIndepOn k _root_.id (s : Set
        (Localization.AtPrime 𝔮)) →
      LinearIndepOn k (· ^ p) (s : Set (Localization.AtPrime 𝔮))) :
    Algebra.IsSmoothAt k 𝔮
Algebra.isSmoothAt_of_mem_minimalPrimes_of_dense_of_formallySmooth_residueField
Source context 4 commands

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

@[expose] public section
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_Algebra_isSmoothAt_of_mem_minimalPrimes_of_dense_of_formallySmooth_residueField.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 AbelianVarieties.NOSProofs.SmoothMinimalPrimes
universe u
theorem _root_.Algebra.isSmoothAt_of_mem_minimalPrimes_of_dense_of_formallySmooth_residueField
    {k : Type u} [Field k] {B : Type u} [CommRing B] [Algebra k B] [Algebra.FiniteType k B]
        [IsReduced B]
    (S : Set (PrimeSpectrum B))
    (hdense : ∀ g : B, (∀ 𝔰 ∈ S, g ∈ 𝔰.asIdeal) → g = 0)
    (hsep : ∀ 𝔰 ∈ S, ∃ (K : Type u) (_ : Field K) (_ : Algebra k K),
      Algebra.FormallySmooth k K ∧ Nonempty (𝔰.asIdeal.ResidueField →ₐ[k] K))
    (𝔮 : Ideal B) [𝔮.IsPrime] (h𝔮 : 𝔮 ∈ minimalPrimes B) :
    Algebra.IsSmoothAt k 𝔮
Algebra.isOpen_setOf_isSmoothAt_and_mem_freeLocus_and_minimalPrimes_subset
Source context 5 commands

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

@[expose] public section
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_Algebra_isOpen_setOf_isSmoothAt_and_mem_freeLocus_and_minimalPrimes_subset.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 AbelianVarieties.NOSProofs.SmoothFreeLocus
open TensorProduct
universe u
theorem _root_.Algebra.isOpen_setOf_isSmoothAt_and_mem_freeLocus_and_minimalPrimes_subset
    {k : Type u} [Field k] {A : Type u} [CommRing A] (M : Type u) [AddCommGroup M] [Module A M]
    [Module.FinitePresentation A M] (J : Ideal A)
    [Algebra k (A ⧸ J)] [Algebra.FiniteType k (A ⧸ J)] [IsReduced (A ⧸ J)]
    (S : Set (PrimeSpectrum (A ⧸ J)))
    (hdense : ∀ g : A ⧸ J, (∀ 𝔰 ∈ S, g ∈ 𝔰.asIdeal) → g = 0)
    (hsep : ∀ 𝔰 ∈ S, ∃ (K : Type u) (_ : Field K) (_ : Algebra k K),
      Algebra.FormallySmooth k K ∧ Nonempty (𝔰.asIdeal.ResidueField →ₐ[k] K)) :
    IsOpen {𝔮 : PrimeSpectrum (A ⧸ J) | Algebra.IsSmoothAt k 𝔮.asIdeal ∧
      𝔮 ∈ Module.freeLocus (A ⧸ J) ((A ⧸ J) ⊗[A] M)} ∧
    ∀ 𝔮 : PrimeSpectrum (A ⧸ J), 𝔮.asIdeal ∈ minimalPrimes (A ⧸ J) →
      Algebra.IsSmoothAt k 𝔮.asIdeal ∧ 𝔮 ∈ Module.freeLocus (A ⧸ J) ((A ⧸ J) ⊗[A] M)
AbelianVarieties.NOSProofs.SmoothDescent.Descent.projective_kaehlerDifferential_of_faithfullyFlat
Source context 6 commands

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

@[expose] public section
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_Algebra_IsSmoothAt_of_isSmoothAt_of_smooth.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 AbelianVarieties.NOSProofs.SmoothDescent
universe u
open TensorProduct
namespace Descent
theorem projective_kaehlerDifferential_of_faithfullyFlat (R A B : Type u) [CommRing R] [CommRing
    A] [CommRing B]
    [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B]
    [Module.FinitePresentation A Ω[A⁄R]] [Module.FaithfullyFlat A B]
    [Algebra.FormallySmooth A B] [Algebra.FormallySmooth R B] :
    Module.Projective A Ω[A⁄R]
Algebra.IsSmoothAt.of_isSmoothAt_of_smooth
Source context 5 commands

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

@[expose] public section
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_Algebra_IsSmoothAt_of_isSmoothAt_of_smooth.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 AbelianVarieties.NOSProofs.SmoothDescent
universe u
open TensorProduct
theorem
    _root_.Algebra.IsSmoothAt.of_isSmoothAt_of_smooth (R S T : Type u) [CommRing R] [CommRing S]
        [CommRing T]
    [Algebra R S] [Algebra S T] [Algebra R T] [IsScalarTower R S T]
    [Algebra.FinitePresentation R S] [Algebra.Smooth S T] (𝔓 : Ideal T) [𝔓.IsPrime]
    (h : Algebra.IsSmoothAt R 𝔓) (𝔭 : Ideal S) [𝔭.IsPrime] (h𝔭 : 𝔓.under S = 𝔭) :
    Algebra.IsSmoothAt R 𝔭