Module

Charts.lean

Nyll.SchemeTheory.RingTheory.Smooth.Charts
59 declarations indexed from sourceView source ↗

Smooth affine charts and coordinates

Polynomial presentations, differential bases and localization construct smooth affine charts with prescribed special-fibre equations. The final construction works over a DVR.

Imports27
  • Mathlib.Algebra.MvPolynomial.PDeriv
  • Mathlib.Data.Matrix.Block
  • Mathlib.LinearAlgebra.Dimension.Finite
  • Mathlib.LinearAlgebra.Dimension.Free
  • Mathlib.LinearAlgebra.Dual.Lemmas
  • Mathlib.LinearAlgebra.LinearIndependent.Lemmas
  • Mathlib.LinearAlgebra.Matrix.NonsingularInverse
  • Mathlib.LinearAlgebra.TensorProduct.Basis
  • Mathlib.LinearAlgebra.TensorProduct.RightExactness
  • Mathlib.LinearAlgebra.TensorProduct.Tower
  • Mathlib.RingTheory.Etale.Kaehler
  • Mathlib.RingTheory.Extension.Generators
  • Mathlib.RingTheory.Ideal.Cotangent
  • Mathlib.RingTheory.OrzechProperty
  • Mathlib.RingTheory.Kaehler.JacobiZariski
  • Mathlib.RingTheory.Kaehler.Polynomial
  • Mathlib.RingTheory.Localization.AtPrime.Basic
  • Mathlib.RingTheory.Localization.Ideal
  • Mathlib.RingTheory.Smooth.StandardSmooth
  • Mathlib.RingTheory.Smooth.StandardSmoothOfFree
  • Mathlib.Tactic.Choose
  • Mathlib.Tactic.Convert
  • Mathlib.Tactic.LinearCombination
  • Mathlib.Tactic.Set
  • Nyll.SchemeTheory.RingTheory.Smooth.AlgebraFormallyEtaleFormallySmooth
  • Nyll.SchemeTheory.RingTheory.Localization.LocalAlgebraCriteria
  • Nyll.SchemeTheory.RingTheory.Smooth.DifferentialCriteria
Imported by5

Declarations

SchemeTheory.SmoothCharts.EtaleCriteria.mapBaseChange_surjective_of_formallyUnramified
Source context 11 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_Etale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension.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.SmoothCharts
open _root_.KaehlerDifferential
open _root_.Algebra
open _root_.TensorProduct
open _root_.Algebra.TensorProduct
universe u
namespace EtaleCriteria
section algebra
variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
  [Algebra R S] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
theorem mapBaseChange_surjective_of_formallyUnramified [Algebra.FormallyUnramified S T] :
    Function.Surjective (KaehlerDifferential.mapBaseChange R S T)
SchemeTheory.SmoothCharts.EtaleCriteria.bijective_of_surjective_of_finrank_eq
Source context 11 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_Etale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension.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.SmoothCharts
open _root_.KaehlerDifferential
open _root_.Algebra
open _root_.TensorProduct
open _root_.Algebra.TensorProduct
universe u
namespace EtaleCriteria
section algebra
variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
  [Algebra R S] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
theorem bijective_of_surjective_of_finrank_eq {A : Type*} [CommRing A] [Nontrivial A]
    {M N : Type*} [AddCommGroup M] [Module A M] [AddCommGroup N] [Module A N]
    [Module.Free A M] [Module.Finite A M] [Module.Free A N] [Module.Finite A N]
    (f : M →ₗ[A] N) (hf : Function.Surjective f)
    (hrank : Module.finrank A M = Module.finrank A N) : Function.Bijective f
SchemeTheory.SmoothCharts.EtaleCriteria.formallyEtale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension
Source context 11 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_Etale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension.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.SmoothCharts
open _root_.KaehlerDifferential
open _root_.Algebra
open _root_.TensorProduct
open _root_.Algebra.TensorProduct
universe u
namespace EtaleCriteria
section algebra
variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
  [Algebra R S] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
theorem formallyEtale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension (n : ℕ)
    [Algebra.IsStandardSmoothOfRelativeDimension n R S]
    [Algebra.IsStandardSmoothOfRelativeDimension n R T]
    [Algebra.FormallyUnramified S T] :
    Algebra.FormallyEtale S T
SchemeTheory.SmoothCharts.EtaleCriteria.etale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension
Source context 11 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_Etale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension.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.SmoothCharts
open _root_.KaehlerDifferential
open _root_.Algebra
open _root_.TensorProduct
open _root_.Algebra.TensorProduct
universe u
namespace EtaleCriteria
section algebra
variable {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
  [Algebra R S] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
theorem etale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension (n : ℕ)
    [Algebra.IsStandardSmoothOfRelativeDimension n R S]
    [Algebra.IsStandardSmoothOfRelativeDimension n R T]
    [Algebra.FormallyUnramified S T] :
    Algebra.Etale S T
Algebra.Etale.of_formallyUnramified_of_isStandardSmoothOfRelativeDimension
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_Etale_of_formallyUnramified_of_isStandardSmoothOfRelativeDimension.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 Algebra.Etale
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem of_formallyUnramified_of_isStandardSmoothOfRelativeDimension
    {R S T : Type*} [CommRing R] [CommRing S] [CommRing T]
    [Algebra R S] [Algebra R T] [Algebra S T] [IsScalarTower R S T] (n : ℕ)
    [Algebra.IsStandardSmoothOfRelativeDimension n R S]
    [Algebra.IsStandardSmoothOfRelativeDimension n R T]
    [Algebra.FormallyUnramified S T] :
    Algebra.Etale S T
MvPolynomial.isStandardSmoothOfRelativeDimension_natCard
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_MvPolynomial_isStandardSmoothOfRelativeDimension_natCard.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 MvPolynomial
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem isStandardSmoothOfRelativeDimension_natCard
    (S : Type u) [CommRing S] (ι : Type v) [Finite ι] :
    Algebra.IsStandardSmoothOfRelativeDimension (Nat.card ι) S (MvPolynomial ι S)
SchemeTheory.SmoothCharts.JacobianSelection.exists_derivation_of_surjective
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_FinitePresentation_exists_surjective_aeval_det_pderiv_not_mem_of_basis_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 SchemeTheory.SmoothCharts
open TensorProduct KaehlerDifferential MvPolynomial
universe u
namespace JacobianSelection
section Descent
variable {R : Type*} [CommRing R] {P S : Type*} [CommRing P] [CommRing S] [Algebra R P] [Algebra R
    S]
  {M : Type*} [AddCommGroup M] [Module R M] [Module S M]
theorem exists_derivation_of_surjective (f : P →ₐ[R] S) (hf : Function.Surjective f)
    (d : P →ₗ[R] M) (hleib : ∀ p q, d (p * q) = f p • d q + f q • d p)
    (hker : ∀ p, f p = 0 → d p = 0) :
    ∃ δ : Derivation R S M, ∀ p, δ (f p) = d p
SchemeTheory.SmoothCharts.JacobianSelection.main
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_FinitePresentation_exists_surjective_aeval_det_pderiv_not_mem_of_basis_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 SchemeTheory.SmoothCharts
open TensorProduct KaehlerDifferential MvPolynomial
universe u
namespace JacobianSelection
section Main
variable {R : Type u} [CommRing R] {S : Type u} [CommRing S] [Algebra R S]
theorem main [Algebra.FinitePresentation R S]
    (u : Ideal S) [u.IsPrime]
    {ι : Type} [Finite ι] (w : ι → S)
    (b₀ : Module.Basis ι u.ResidueField (u.ResidueField ⊗[S] Ω[S⁄R]))
    (hb₀ : ∀ i, b₀ i = (1 : u.ResidueField) ⊗ₜ[S] D R S (w i)) :
    ∃ (m : ℕ) (x : Fin m → S) (h : Fin m → MvPolynomial (ι ⊕ Fin m) R),
      Function.Surjective (MvPolynomial.aeval (Sum.elim w x) : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] S) ∧
      (∀ a, MvPolynomial.aeval (Sum.elim w x) (h a) = 0) ∧
      MvPolynomial.aeval (Sum.elim w x)
        (Matrix.det (Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h a))) ∉ u := by
  classical
  obtain ⟨s, hs⟩ := Algebra.FiniteType.out (R := R) (A := S)
  set m := s.card with hm
  let x : Fin m → S := fun a => (s.equivFin.symm a : S)
  let f : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] S := MvPolynomial.aeval (Sum.elim w x)
  have hf : Function.Surjective f := by
    rw [← AlgHom.range_eq_top, ← Algebra.adjoin_range_eq_range_aeval, eq_top_iff, ← hs]
    apply Algebra.adjoin_mono
    intro y hy
    exact ⟨Sum.inr (s.equivFin ⟨y, hy⟩), congrArg Subtype.val (s.equivFin.symm_apply_apply _)⟩
  set κ := u.ResidueField with hκ
  let Xgrad : MvPolynomial (ι ⊕ Fin m) R → (Fin m → κ) := fun p b => algebraMap S κ (f (pderiv
      (Sum.inr b) p))
  have Xgrad_add : ∀ p q, Xgrad (p + q) = Xgrad p + Xgrad q := by
    intro p q; funext b; simp only [Xgrad, map_add, Pi.add_apply]
  have Xgrad_smul : ∀ (c : R) p, Xgrad (c • p) = c • Xgrad p := by
    intro c p; funext b
    change algebraMap S κ (f (pderiv (Sum.inr b) (c • p))) = c • algebraMap S κ (f (pderiv (Sum.inr
        b) p))
    rw [Derivation.map_smul, map_smul, Algebra.smul_def, map_mul, Algebra.smul_def, ←
        IsScalarTower.algebraMap_apply R S κ]
  have Xgrad_mul : ∀ p q, Xgrad (p * q) = algebraMap S κ (f p) • Xgrad q + algebraMap S κ (f q) •
      Xgrad p := by
    intro p q; funext b
    simp only [Xgrad, Derivation.leibniz, smul_eq_mul, map_add, map_mul, Pi.add_apply,
        Pi.smul_apply]
  have Xgrad_X_inl : ∀ i, Xgrad (X (Sum.inl i)) = 0 := by
    intro i; funext b
    change algebraMap S κ (f (pderiv (Sum.inr b) (X (Sum.inl i)))) = 0
    rw [pderiv_X_of_ne (Sum.inl_ne_inr), map_zero, map_zero]
  have Xgrad_X_inr : ∀ b, Xgrad (X (Sum.inr b)) = Pi.single b 1 := by
    intro b
    funext b'
    by_cases hb : b = b'
    · subst b'
      simp only [Xgrad, pderiv_X_self, map_one, Pi.single_eq_same]
    · change algebraMap S κ (f (pderiv (Sum.inr b') (X (Sum.inr b)))) =
        (Pi.single b (1 : κ) : Fin m → κ) b'
      rw [pderiv_X_of_ne (fun h => hb (Sum.inr.inj h)), map_zero, map_zero,
        Pi.single_eq_of_ne (fun h => hb h.symm)]
  let t : Set (Fin m → κ) := Set.range fun p : ↥(RingHom.ker f.toRingHom) => Xgrad p.1
  have hspan : Submodule.span κ t = ⊤ := by
    by_contra hne
    obtain ⟨φ, hφ0, hφ⟩ := Submodule.exists_dual_map_eq_bot_of_lt_top (lt_top_iff_ne_top.mpr hne)
        inferInstance
    have hφt : ∀ p : MvPolynomial (ι ⊕ Fin m) R, f p = 0 → φ (Xgrad p) = 0 := by
      intro p hp
      have : φ (Xgrad p) ∈ (Submodule.span κ t).map φ := Submodule.mem_map_of_mem
          (Submodule.subset_span ⟨⟨p, hp⟩, rfl⟩)
      rwa [hφ, Submodule.mem_bot] at this
    let d : MvPolynomial (ι ⊕ Fin m) R →ₗ[R] κ :=
      { toFun := fun p => φ (Xgrad p)
        map_add' := fun p q => by rw [Xgrad_add, map_add]
        map_smul' := fun c p => by rw [Xgrad_smul, LinearMap.map_smul_of_tower]; rfl }
    have hd : ∀ p, d p = φ (Xgrad p) := fun p => rfl
    obtain ⟨δ, hδ⟩ := exists_derivation_of_surjective f hf d
      (fun p q => by
        rw [hd, hd, hd, Xgrad_mul, map_add, map_smul, map_smul, smul_eq_mul, smul_eq_mul,
            Algebra.smul_def,
          Algebra.smul_def])
      (fun p hp => hφt p hp)
    let ℓ : Ω[S⁄R] →ₗ[S] κ := δ.liftKaehlerDifferential
    let L : κ ⊗[S] Ω[S⁄R] →ₗ[κ] κ := ℓ.liftBaseChange κ
    have hL : L = 0 := by
      refine b₀.ext fun i => ?_
      rw [hb₀ i, LinearMap.zero_apply]
      change (1 : κ) • ℓ (D R S (w i)) = 0
      rw [one_smul]
      change δ.liftKaehlerDifferential (D R S (w i)) = 0
      rw [Derivation.liftKaehlerDifferential_comp_D]
      have : f (X (Sum.inl i)) = w i := by rw [MvPolynomial.aeval_X]; rfl
      rw [← this, hδ, hd, Xgrad_X_inl, map_zero]
    have hφb : ∀ b, φ (Pi.single b 1) = 0 := by
      intro b
      have h1 : L ((1 : κ) ⊗ₜ[S] D R S (x b)) = 0 := by rw [hL, LinearMap.zero_apply]
      change (1 : κ) • ℓ (D R S (x b)) = 0 at h1
      rw [one_smul] at h1
      change δ.liftKaehlerDifferential (D R S (x b)) = 0 at h1
      rw [Derivation.liftKaehlerDifferential_comp_D] at h1
      have : f (X (Sum.inr b)) = x b := by rw [MvPolynomial.aeval_X]; rfl
      rw [← this, hδ, hd, Xgrad_X_inr] at h1
      exact h1
    apply hφ0
    refine (Pi.basisFun κ (Fin m)).ext fun b => ?_
    rw [Pi.basisFun_apply, LinearMap.zero_apply]
    exact hφb b
  obtain ⟨bs, hbt, hbspan, hli⟩ := exists_linearIndependent κ t
  rw [hspan] at hbspan
  let B : Module.Basis bs κ (Fin m → κ) := Module.Basis.mk hli (by rw [Subtype.range_coe_subtype,
      Set.ofPred_mem_eq, hbspan])
  have : Finite bs := Module.Finite.finite_basis B
  let : Fintype bs := Fintype.ofFinite bs
  have hcard : Fintype.card bs = m := by
    have := Module.finrank_eq_card_basis B
    rw [Module.finrank_fintype_fun_eq_card, Fintype.card_fin] at this
    exact this.symm
  let e : bs ≃ Fin m := Fintype.equivOfCardEq (by rw [hcard, Fintype.card_fin])
  have hmem : ∀ a : Fin m, ∃ p : ↥(RingHom.ker f.toRingHom), Xgrad p.1 = (e.symm a : Fin m → κ) :=
    fun a => hbt (e.symm a).2
  choose hp hhp using hmem
  let h : Fin m → MvPolynomial (ι ⊕ Fin m) R := fun a => (hp a).1
  refine ⟨m, x, h, hf, fun a => (hp a).2, ?_⟩
  set N : Matrix (Fin m) (Fin m) (MvPolynomial (ι ⊕ Fin m) R) :=
    Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h a) with hN
  have hrow : (N.map ((algebraMap S κ).comp f.toRingHom)) = Matrix.of fun a => (e.symm a : Fin m →
      κ) := by
    ext a b
    change algebraMap S κ (f (pderiv (Sum.inr b) (h a))) = (e.symm a : Fin m → κ) b
    rw [← hhp a]
  have hliRows : LinearIndependent κ (N.map ((algebraMap S κ).comp f.toRingHom)).row := by
    rw [hrow]
    change LinearIndependent κ (fun a => ((e.symm a : bs) : Fin m → κ))
    have hB : (fun a => ((e.symm a : bs) : Fin m → κ)) = ⇑B ∘ ⇑e.symm := by
      funext a; exact (Module.Basis.mk_apply hli _ _).symm
    rw [hB]
    exact B.linearIndependent.comp e.symm e.symm.injective
  have hunit : IsUnit (N.map ((algebraMap S κ).comp f.toRingHom)) :=
      Matrix.linearIndependent_row_iff_isUnit.mp hliRows
  have hdet : (N.map ((algebraMap S κ).comp f.toRingHom)).det ≠ 0 :=
    ((Matrix.isUnit_iff_isUnit_det _).mp hunit).ne_zero
  have hdet' : ((algebraMap S κ).comp f.toRingHom) N.det ≠ 0 := by
    rw [RingHom.map_det]; exact hdet
  intro hmemu
  apply hdet'
  change algebraMap S κ (f N.det) = 0
  exact Ideal.algebraMap_residueField_eq_zero.mpr hmemu
Algebra.FinitePresentation.exists_surjective_aeval_det_pderiv_not_mem_of_basis_residueField
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_FinitePresentation_exists_surjective_aeval_det_pderiv_not_mem_of_basis_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 Algebra.FinitePresentation
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem exists_surjective_aeval_det_pderiv_not_mem_of_basis_residueField
    {R : Type u} [CommRing R] {S : Type u} [CommRing S] [Algebra R S] [Algebra.FinitePresentation R
        S]
    (u : Ideal S) [u.IsPrime]
    {ι : Type} [Finite ι] (w : ι → S)
    (b₀ : Module.Basis ι u.ResidueField (u.ResidueField ⊗[S] Ω[S⁄R]))
    (hb₀ : ∀ i, b₀ i = (1 : u.ResidueField) ⊗ₜ[S] D R S (w i)) :
    ∃ (m : ℕ) (x : Fin m → S) (h : Fin m → MvPolynomial (ι ⊕ Fin m) R),
      Function.Surjective (MvPolynomial.aeval (Sum.elim w x) : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] S) ∧
      (∀ a, MvPolynomial.aeval (Sum.elim w x) (h a) = 0) ∧
      MvPolynomial.aeval (Sum.elim w x)
        (Matrix.det (Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h a))) ∉ u :=
  JacobianSelection.main u w b₀ hb₀
abbrev

V

L464 ↗
SchemeTheory.SmoothCharts.SubmersiveQuotient.V

The original variables and the added inverse variable.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
abbrev V (ι : Type) (m : ℕ) : Type
SchemeTheory.SmoothCharts.SubmersiveQuotient.Rel

The original equations and the added inverse equation.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
abbrev Rel (m : ℕ) : Type
SchemeTheory.SmoothCharts.SubmersiveQuotient.Δ

The determinant of the selected Jacobian minor.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
def Δ : MvPolynomial (ι ⊕ Fin m) R
SchemeTheory.SmoothCharts.SubmersiveQuotient.emb

The polynomial inclusion adding an inverse variable.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
abbrev emb : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] MvPolynomial (V ι m) R
SchemeTheory.SmoothCharts.SubmersiveQuotient.rel

The chart equations together with the Jacobian-inverse equation.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
def rel : Rel m → MvPolynomial (V ι m) R
SchemeTheory.SmoothCharts.SubmersiveQuotient.rel_inl
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem rel_inl (a : Fin m) : rel h (Sum.inl a) = emb (h a)
SchemeTheory.SmoothCharts.SubmersiveQuotient.rel_inr
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem rel_inr (x : Unit) : rel h (Sum.inr x) = emb (Δ h) * X (Sum.inr ()) - 1
SchemeTheory.SmoothCharts.SubmersiveQuotient.I

The ideal generated by the chart equations.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
def I : Ideal (MvPolynomial (V ι m) R)
abbrev

Q

L488 ↗
SchemeTheory.SmoothCharts.SubmersiveQuotient.Q

The quotient ring of the standard smooth chart.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
abbrev Q : Type u
SchemeTheory.SmoothCharts.SubmersiveQuotient.φ

The polynomial map into the chart ring.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
def φ : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] Q h
SchemeTheory.SmoothCharts.SubmersiveQuotient.φ_apply
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem φ_apply (p : MvPolynomial (ι ⊕ Fin m) R) : φ h p = Ideal.Quotient.mk (I h) (emb p)
SchemeTheory.SmoothCharts.SubmersiveQuotient.rel_mem
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem rel_mem (r : Rel m) : rel h r ∈ I h
SchemeTheory.SmoothCharts.SubmersiveQuotient.φ_h
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem φ_h (a : Fin m) : φ h (h a) = 0
SchemeTheory.SmoothCharts.SubmersiveQuotient.φ_Δ_mul_Y
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem φ_Δ_mul_Y : φ h (Δ h) * Ideal.Quotient.mk (I h) (X (Sum.inr ())) = 1
SchemeTheory.SmoothCharts.SubmersiveQuotient.isUnit_φ_Δ
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem isUnit_φ_Δ : IsUnit (φ h (Δ h))
SchemeTheory.SmoothCharts.SubmersiveQuotient.univ
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem univ (B : Type u) [CommRing B] [Algebra R B] (ψ : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] B)
    (hψ : ∀ a, ψ (h a) = 0) (hu : IsUnit (ψ (Δ h))) : ∃ χ : Q h →ₐ[R] B, χ.comp (φ h) = ψ
SchemeTheory.SmoothCharts.SubmersiveQuotient.gens

The canonical polynomial generators of the chart quotient.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
abbrev gens : Algebra.Generators R (Q h) (V ι m)
SchemeTheory.SmoothCharts.SubmersiveQuotient.gens_val
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem gens_val (v : V ι m) : (gens h).val v = Ideal.Quotient.mk (I h) (X v)
SchemeTheory.SmoothCharts.SubmersiveQuotient.gens_ker
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem gens_ker : (gens h).ker = I h
SchemeTheory.SmoothCharts.SubmersiveQuotient.pres

The presentation with the chosen Jacobian variables.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
def pres : Algebra.PreSubmersivePresentation R (Q h) (V ι m) (Rel m) where
  toGenerators := gens h
  relation := rel h
  span_range_relation_eq_ker := by rw [gens_ker]; rfl
  map := Sum.map Sum.inr id
  map_inj := Sum.map_injective.mpr ⟨Sum.inr_injective, fun _ _ h => h⟩
SchemeTheory.SmoothCharts.SubmersiveQuotient.pderiv_inr_emb
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem pderiv_inr_emb (p : MvPolynomial (ι ⊕ Fin m) R) : pderiv (Sum.inr ()) (emb p : MvPolynomial
    (V ι m) R) = 0
SchemeTheory.SmoothCharts.SubmersiveQuotient.pderiv_inl_emb
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem pderiv_inl_emb (j : ι ⊕ Fin m) (p : MvPolynomial (ι ⊕ Fin m) R) :
    pderiv (Sum.inl j) (emb p : MvPolynomial (V ι m) R) = emb (pderiv j p)
SchemeTheory.SmoothCharts.SubmersiveQuotient.jacobiMatrix_eq
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem jacobiMatrix_eq :
    (pres h).jacobiMatrix =
      Matrix.fromBlocks
        ((Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h a)).transpose.map (emb :
            MvPolynomial (ι ⊕ Fin m) R →ₐ[R] MvPolynomial (V ι m) R))
        (Matrix.of fun (a : Fin m) (_ : Unit) => pderiv (Sum.inl (Sum.inr a)) (emb (Δ h) * X
            (Sum.inr ()) - 1))
        0
        (Matrix.of fun (_ _ : Unit) => (emb (Δ h) : MvPolynomial (V ι m) R)) := by
  refine Matrix.ext fun i j => ?_
  rw [Algebra.PreSubmersivePresentation.jacobiMatrix_apply]
  rcases i with a | x <;> rcases j with b | y
  · simp only [Matrix.fromBlocks_apply₁₁, Matrix.map_apply, Matrix.transpose_apply, Matrix.of_apply]
    change pderiv (Sum.inl (Sum.inr a)) (emb (h b)) = emb (pderiv (Sum.inr a) (h b))
    exact pderiv_inl_emb _ _
  · simp only [Matrix.fromBlocks_apply₁₂, Matrix.of_apply]
    rfl
  · simp only [Matrix.fromBlocks_apply₂₁, Matrix.zero_apply]
    change pderiv (Sum.inr x) (emb (h b)) = 0
    cases x
    exact pderiv_inr_emb _
  · simp only [Matrix.fromBlocks_apply₂₂, Matrix.of_apply]
    change pderiv (Sum.inr x) (emb (Δ h) * X (Sum.inr ()) - 1) = emb (Δ h)
    cases x
    rw [map_sub, Derivation.map_one_eq_zero, sub_zero, Derivation.leibniz, pderiv_X_self,
        pderiv_inr_emb, smul_zero,
      add_zero, smul_eq_mul, mul_one]
SchemeTheory.SmoothCharts.SubmersiveQuotient.jacobian_eq
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem jacobian_eq : (pres h).jacobian = φ h (Δ h) * φ h (Δ h)
SchemeTheory.SmoothCharts.SubmersiveQuotient.spres

The submersive presentation obtained by inverting its Jacobian.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
def spres : Algebra.SubmersivePresentation R (Q h) (V ι m) (Rel m) where
  toPreSubmersivePresentation := pres h
  jacobian_isUnit := by rw [jacobian_eq]; exact (isUnit_φ_Δ h).mul (isUnit_φ_Δ h)
SchemeTheory.SmoothCharts.SubmersiveQuotient.isCompl_range
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem isCompl_range :
    IsCompl (Set.range (fun i : ι => (Sum.inl (Sum.inl i) : V ι m))) (Set.range (pres h).map) := by
  constructor
  · rw [Set.disjoint_iff]
    rintro v ⟨⟨i, rfl⟩, ⟨r, hr⟩⟩
    rcases r with a | x
    · exact Sum.inr_ne_inl (Sum.inl.inj hr)
    · exact Sum.inr_ne_inl hr
  · rw [codisjoint_iff, eq_top_iff]
    intro v _
    change v ∈ (Set.range fun i : ι => (Sum.inl (Sum.inl i) : V ι m)) ∪ Set.range (pres h).map
    rcases v with (i | a) | x
    · exact Or.inl ⟨i, rfl⟩
    · exact Or.inr ⟨Sum.inl a, rfl⟩
    · exact Or.inr ⟨Sum.inr x, rfl⟩
SchemeTheory.SmoothCharts.SubmersiveQuotient.basis

The differential basis associated to the unselected variables.

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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
def basis : Module.Basis ι (Q h) Ω[Q h⁄R]
SchemeTheory.SmoothCharts.SubmersiveQuotient.basis_apply
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem basis_apply (i : ι) : basis h i = D R (Q h) (φ h (X (Sum.inl i)))
SchemeTheory.SmoothCharts.SubmersiveQuotient.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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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.SmoothCharts
open KaehlerDifferential MvPolynomial
universe u
namespace SubmersiveQuotient
variable {R : Type u} [CommRing R] {ι : Type} {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin
    m) R)
theorem main [Finite ι] :
    ∃ (C : Type u) (_ : CommRing C) (_ : Algebra R C) (φ : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] C),
      Algebra.IsStandardSmooth R C ∧
      (∀ a, φ (h a) = 0) ∧
      IsUnit (φ (Matrix.det (Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h a)))) ∧
      (∀ (B : Type u) [CommRing B] [Algebra R B] (ψ : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] B),
          (∀ a, ψ (h a) = 0) →
          IsUnit (ψ (Matrix.det (Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h
              a)))) →
          ∃ χ : C →ₐ[R] B, χ.comp φ = ψ) ∧
      ∃ b : Module.Basis ι C Ω[C⁄R], ∀ i, b i = D R C (φ (MvPolynomial.X (Sum.inl i))) :=
  ⟨Q h, inferInstance, inferInstance, φ h, (spres h).isStandardSmooth, φ_h h, isUnit_φ_Δ h,
    fun B _ _ ψ hψ hu => univ h B ψ hψ hu, basis h, basis_apply h⟩
MvPolynomial.exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential
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_MvPolynomial_exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential.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 MvPolynomial
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem exists_isStandardSmooth_algHom_isUnit_det_pderiv_basis_kaehlerDifferential
    {R : Type u} [CommRing R] {ι : Type} [Finite ι] {m : ℕ} (h : Fin m → MvPolynomial (ι ⊕ Fin m) R)
        :
    ∃ (C : Type u) (_ : CommRing C) (_ : Algebra R C) (φ : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] C),
      Algebra.IsStandardSmooth R C ∧
      (∀ a, φ (h a) = 0) ∧
      IsUnit (φ (Matrix.det (Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h a)))) ∧
      (∀ (B : Type u) [CommRing B] [Algebra R B] (ψ : MvPolynomial (ι ⊕ Fin m) R →ₐ[R] B),
          (∀ a, ψ (h a) = 0) →
          IsUnit (ψ (Matrix.det (Matrix.of fun a b : Fin m => MvPolynomial.pderiv (Sum.inr b) (h
              a)))) →
          ∃ χ : C →ₐ[R] B, χ.comp φ = ψ) ∧
      ∃ b : Module.Basis ι C Ω[C⁄R], ∀ i, b i = D R C (φ (MvPolynomial.X (Sum.inl i))) :=
  SubmersiveQuotient.main h
Algebra.FormallySmooth.etale_aeval_of_basis_kaehlerDifferential
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_FormallySmooth_etale_aeval_of_basis_kaehlerDifferential.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 Algebra.FormallySmooth
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem etale_aeval_of_basis_kaehlerDifferential
    {R : Type u} [CommRing R] {A : Type u} [CommRing A] [Algebra R A]
    [Algebra.FinitePresentation R A] [Algebra.FormallySmooth R A]
    {ι : Type u} [Finite ι] (a : ι → A)
    (b : Module.Basis ι A (Ω[A⁄R])) (hb : ∀ i, b i = KaehlerDifferential.D R A (a i)) :
    (MvPolynomial.aeval a : MvPolynomial ι R →ₐ[R] A).toRingHom.Etale
Algebra.Etale.of_basis_eq_D
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_Etale_of_basis_eq_D.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 Algebra.Etale
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem of_basis_eq_D
    {R : Type u} [CommRing R] {S : Type u} [CommRing S] [Algebra R S] [Algebra.Smooth R S]
    {ι : Type v} [Finite ι] (x : ι → S) (b : Module.Basis ι S Ω[S⁄R]) (hb : ∀ i, b i = D R S (x i))
    [Algebra (MvPolynomial ι R) S] [IsScalarTower R (MvPolynomial ι R) S]
    (hx : ∀ i, algebraMap (MvPolynomial ι R) S (MvPolynomial.X i) = x i) :
    Algebra.Etale (MvPolynomial ι R) S
SchemeTheory.SmoothCharts.MinimalAmbient.main
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_exists_isStandardSmooth_surjective_localizationAway_basis_kaehlerDifferential_of_basis_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 SchemeTheory.SmoothCharts
open TensorProduct KaehlerDifferential MvPolynomial
universe u
namespace MinimalAmbient
theorem main
    {R : Type u} [CommRing R] {S : Type u} [CommRing S] [Algebra R S] [Algebra.FinitePresentation R
        S]
    (u : Ideal S) [u.IsPrime]
    {ι : Type} [Finite ι] (w : ι → S)
    (b₀ : Module.Basis ι u.ResidueField (u.ResidueField ⊗[S] Ω[S⁄R]))
    (hb₀ : ∀ i, b₀ i = (1 : u.ResidueField) ⊗ₜ[S] D R S (w i)) :
    ∃ (g : S) (_ : g ∉ u) (C : Type u) (_ : CommRing C) (_ : Algebra R C)
      (_ : Algebra C (Localization.Away g)) (_ : IsScalarTower R C (Localization.Away g)),
      Algebra.IsStandardSmooth R C ∧ Function.Surjective (algebraMap C (Localization.Away g)) ∧
      ∃ (W : ι → C) (b : Module.Basis ι C Ω[C⁄R]),
        (∀ i, algebraMap C (Localization.Away g) (W i) = algebraMap S (Localization.Away g) (w i)) ∧
        (∀ i, b i = D R C (W i))
Algebra.exists_isStandardSmooth_surjective_localizationAway_basis_kaehlerDifferential_of_basis_residueField
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_exists_isStandardSmooth_surjective_localizationAway_basis_kaehlerDifferential_of_basis_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 Algebra
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem
 exists_isStandardSmooth_surjective_localizationAway_basis_kaehlerDifferential_of_basis_residueField
    {R : Type u} [CommRing R] {S : Type u} [CommRing S] [Algebra R S] [Algebra.FinitePresentation R
        S]
    (u : Ideal S) [u.IsPrime]
    {ι : Type} [Finite ι] (w : ι → S)
    (b₀ : Module.Basis ι u.ResidueField (u.ResidueField ⊗[S] Ω[S⁄R]))
    (hb₀ : ∀ i, b₀ i = (1 : u.ResidueField) ⊗ₜ[S] D R S (w i)) :
    ∃ (g : S) (_ : g ∉ u) (C : Type u) (_ : CommRing C) (_ : Algebra R C)
      (_ : Algebra C (Localization.Away g)) (_ : IsScalarTower R C (Localization.Away g)),
      Algebra.IsStandardSmooth R C ∧ Function.Surjective (algebraMap C (Localization.Away g)) ∧
      ∃ (W : ι → C) (b : Module.Basis ι C Ω[C⁄R]),
        (∀ i, algebraMap C (Localization.Away g) (W i) = algebraMap S (Localization.Away g) (w i)) ∧
        (∀ i, b i = D R C (W i))
Algebra.exists_notMem_map_ker_eq_bot_of_surjective_of_isSmoothAt_of_finrank_le
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_exists_notMem_map_ker_eq_bot_of_surjective_of_isSmoothAt_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 Algebra
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem exists_notMem_map_ker_eq_bot_of_surjective_of_isSmoothAt_of_finrank_le
    {k : Type u} [Field k] {B : Type u} [CommRing B] [Algebra k B] [Algebra.FiniteType k B]
        [Algebra.Smooth k B]
    {B' : Type u} [CommRing B'] [Algebra k B'] (ψ : B →ₐ[k] B') (hψ : Function.Surjective ψ)
    (v' : Ideal B') [v'.IsPrime] (v : Ideal B) [v.IsPrime] (hv' : v'.comap ψ.toRingHom = v)
    (hsm : Algebra.IsSmoothAt k v')
    (hrank : Module.finrank v.ResidueField (v.ResidueField ⊗[B] Ω[B⁄k]) ≤
      Module.finrank v'.ResidueField (v'.ResidueField ⊗[B'] Ω[B'⁄k])) :
    ∃ t : B, t ∉ v ∧ (RingHom.ker ψ.toRingHom).map (algebraMap B (Localization.Away t)) = ⊥
SchemeTheory.SmoothCharts.ResidueBasis.span_one_tmul_D_eq_top
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ResidueBasis
theorem span_one_tmul_D_eq_top {R A κ : Type*} [CommRing R] [CommRing A] [Algebra R A] [CommRing κ]
    [Algebra A κ] :
    Submodule.span κ (Set.range fun a : A => (1 : κ) ⊗ₜ[A] D R A a) = ⊤ := by
  have h := congrArg (fun p : Submodule A Ω[A⁄R] => p.baseChange κ)
    (KaehlerDifferential.span_range_derivation R A)
  rw [Submodule.baseChange_span, Submodule.baseChange_top, ← Set.range_comp] at h
  exact h
SchemeTheory.SmoothCharts.ResidueBasis.exists_basis_adapted

A finite basis chosen from a spanning family, adapted to a specified subfamily.

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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ResidueBasis
theorem exists_basis_adapted {A κ M : Type u} [Field κ] [AddCommGroup M] [Module κ M]
    [Module.Finite κ M] (v : A → M) (hv : Submodule.span κ (Set.range v) = ⊤)
    (J : Set A) :
    ∃ (r n : ℕ) (yb : Fin r → A) (zb : Fin n → A), (∀ j, zb j ∈ J) ∧
      (∃ b₀ : Module.Basis (Fin r ⊕ Fin n) κ M,
        ∀ i, b₀ i = v (Sum.elim yb zb i)) ∧
      (∀ z ∈ J, v z ∈ Submodule.span κ (Set.range fun j : Fin n => v (zb j))) := by
  classical
  obtain ⟨bJ, hbJJ, -, hJspan, hbJli⟩ :=
    exists_linearIndepOn_extension (K := κ) (v := v) (linearIndepOn_empty κ v) (Set.empty_subset J)
  obtain ⟨b, -, hbJb, hspan, hbli⟩ := exists_linearIndepOn_extension (K := κ) (v := v) hbJli
      (Set.subset_univ bJ)
  have htop : ⊤ ≤ Submodule.span κ (Set.range fun i : b => v i) := by
    have hr : Set.range (fun i : b => v i) = v '' b := by
      exact (Set.image_eq_range v b).symm
    rw [hr, ← hv, Submodule.span_le, ←
        Set.image_univ]
    exact hspan
  have hlin : LinearIndependent κ (fun i : b => v i) := hbli
  let B₀ : Module.Basis b κ M := Module.Basis.mk hlin htop
  have : Finite b := Module.Finite.finite_basis B₀
  have : Finite (↥(b \ bJ) : Type u) := Finite.Set.subset b Set.sdiff_subset
  have : Finite (↥bJ : Type u) := Finite.Set.subset b hbJb
  let : Fintype (↥(b \ bJ) : Type u) := Fintype.ofFinite _
  let : Fintype (↥bJ : Type u) := Fintype.ofFinite _
  set r := Fintype.card (↥(b \ bJ) : Type u) with hr
  set n := Fintype.card (↥bJ : Type u) with hn
  let eR : (↥(b \ bJ) : Type u) ≃ Fin r := Fintype.equivFin _
  let eJ : (↥bJ : Type u) ≃ Fin n := Fintype.equivFin _
  let e' : Fin r ⊕ Fin n ≃ (b : Type u) :=
    ((Equiv.sumCongr eR.symm eJ.symm).trans (Equiv.sumComm _ _)).trans (Equiv.Set.sumDiffSubset
        hbJb)
  let yb : Fin r → A := fun i => ((eR.symm i : ↥(b \ bJ)) : A)
  let zb : Fin n → A := fun j => ((eJ.symm j : ↥bJ) : A)
  refine ⟨r, n, yb, zb, fun j => hbJJ (eJ.symm j).2, ⟨B₀.reindex e'.symm, fun i => ?_⟩, fun z hz =>
      ?_⟩
  · rw [Module.Basis.reindex_apply, Equiv.symm_symm]
    change (Module.Basis.mk hlin htop) (e' i) = v (Sum.elim yb zb i)
    rw [Module.Basis.mk_apply]
    cases i <;> rfl
  · have h1 : v z ∈ Submodule.span κ (v '' bJ) := hJspan ⟨z, hz, rfl⟩
    have hsubset : v '' bJ ⊆ Set.range (fun j : Fin n => v (zb j)) := by
      rintro _ ⟨x, hx, rfl⟩
      refine ⟨eJ ⟨x, hx⟩, ?_⟩
      exact congrArg (fun y : bJ => v y) (eJ.symm_apply_apply ⟨x, hx⟩)
    exact Submodule.span_mono hsubset h1
SchemeTheory.SmoothCharts.ResidueBasis.exists_b0
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ResidueBasis
theorem exists_b0 {R : Type u} [CommRing R] {A : Type u} [CommRing A] [Algebra R A]
    [Algebra.FiniteType R A]
    (J : Ideal A) (𝔭 : Ideal A) [𝔭.IsPrime] :
    ∃ (r n : ℕ) (yb : Fin r → A) (zb : Fin n → A), (∀ j, zb j ∈ J) ∧
      (∃ b₀ : Module.Basis (Fin r ⊕ Fin n) 𝔭.ResidueField (𝔭.ResidueField ⊗[A] Ω[A⁄R]),
        ∀ i, b₀ i = (1 : 𝔭.ResidueField) ⊗ₜ[A] D R A (Sum.elim yb zb i)) ∧
      (∀ z ∈ J, (1 : 𝔭.ResidueField) ⊗ₜ[A] D R A z ∈
        Submodule.span 𝔭.ResidueField (Set.range fun j : Fin n => (1 : 𝔭.ResidueField) ⊗ₜ[A] D R A
            (zb j))) := by
  exact exists_basis_adapted (fun a : A => (1 : 𝔭.ResidueField) ⊗ₜ[A] D R A a)
    (span_one_tmul_D_eq_top (R := R) (A := A) (κ := 𝔭.ResidueField)) (J : Set A)
SchemeTheory.SmoothCharts.ResidueBasis.ker_lTensor_mapBaseChange_le_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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ResidueBasis
theorem ker_lTensor_mapBaseChange_le_span {R : Type u} [CommRing R] {A : Type u} [CommRing A]
    [Algebra R A]
    (J : Ideal A) (κ : Type u) [Field κ] [Algebra (A ⧸ J) κ] [Algebra A κ] [IsScalarTower A (A ⧸ J)
        κ]
    (x : κ ⊗[A ⧸ J] ((A ⧸ J) ⊗[A] Ω[A⁄R]))
    (hx : LinearMap.lTensor κ (mapBaseChange R A (A ⧸ J)) x = 0) :
    x ∈ Submodule.span κ (Set.range fun z : J => (1 : κ) ⊗ₜ[A ⧸ J] ((1 : A ⧸ J) ⊗ₜ[A] D R A (z :
        A))) := by
  set B := A ⧸ J with hB
  set G := mapBaseChange R A B with hG
  have hGs : Function.Surjective G := mapBaseChange_surjective R A B Ideal.Quotient.mk_surjective
  have hex : Function.Exact (LinearMap.ker G).subtype G := LinearMap.exact_subtype_ker_map G
  have hexκ : Function.Exact (LinearMap.lTensor κ (LinearMap.ker G).subtype) (LinearMap.lTensor κ G)
      :=
    lTensor_exact (R := B) (M := LinearMap.ker G) (N := B ⊗[A] Ω[A⁄R]) (P := Ω[B⁄R]) κ hex hGs
  have hx' : x ∈ LinearMap.ker (LinearMap.lTensor κ G) := hx
  rw [hexκ.linearMap_ker_eq] at hx'
  obtain ⟨y, rfl⟩ := hx'
  clear hx
  induction y using TensorProduct.inductionOn with
  | add y₁ y₂ h₁ h₂ => rw [map_add]; exact Submodule.add_mem _ h₁ h₂
  | tmul c w =>
    rw [LinearMap.lTensor_tmul, Submodule.subtype_apply]
    have hw : (w : B ⊗[A] Ω[A⁄R]) ∈ LinearMap.range (kerCotangentToTensor R A B) := by
      rw [← (exact_kerCotangentToTensor_mapBaseChange R A B
          Ideal.Quotient.mk_surjective).linearMap_ker_eq]
      exact w.2
    obtain ⟨t, ht⟩ := hw
    obtain ⟨z, rfl⟩ := Ideal.toCotangent_surjective _ t
    rw [kerCotangentToTensor_toCotangent] at ht
    rw [← ht]
    have hz : (z : A) ∈ J := by
      have hz2 : algebraMap A B (z : A) = 0 := z.2
      exact Ideal.Quotient.eq_zero_iff_mem.mp hz2
    have : c ⊗ₜ[B] ((1 : B) ⊗ₜ[A] D R A (z : A)) = c • ((1 : κ) ⊗ₜ[B] ((1 : B) ⊗ₜ[A] D R A (z : A)))
        := by
      rw [TensorProduct.smul_tmul', smul_eq_mul, mul_one]
    rw [this]
    exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨⟨z, hz⟩, rfl⟩)
SchemeTheory.SmoothCharts.ResidueBasis.kaehlerEquivOfSurjective

Differentials are unchanged after a surjective base-ring 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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ResidueBasis
def kaehlerEquivOfSurjective {R : Type u} [CommRing R] (k : Type u) [Field k] [Algebra
    R k]
    (hk : Function.Surjective (algebraMap R k)) (B : Type u) [CommRing B] [Algebra R B] [Algebra k
        B] [IsScalarTower R k B] :
    Ω[B⁄R] ≃ₗ[B] Ω[B⁄k]
SchemeTheory.SmoothCharts.ResidueBasis.fibreBasis
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ResidueBasis
theorem fibreBasis
    {R : Type u} [CommRing R] {A : Type u} [CommRing A] [Algebra R A] [Algebra.FiniteType R A]
    (k : Type u) [Field k] [Algebra R k] (hk : Function.Surjective (algebraMap R k))
    (J : Ideal A) [Algebra k (A ⧸ J)] [IsScalarTower R k (A ⧸ J)]
    (𝔭 : Ideal A) [𝔭.IsPrime] (𝔮 : Ideal (A ⧸ J)) [𝔮.IsPrime] (h𝔮 : 𝔮.comap (Ideal.Quotient.mk J) =
        𝔭) :
    ∃ (r n : ℕ) (yb : Fin r → A) (zb : Fin n → A), (∀ j, zb j ∈ J) ∧
      (∃ b₀ : Module.Basis (Fin r ⊕ Fin n) 𝔭.ResidueField (𝔭.ResidueField ⊗[A] Ω[A⁄R]),
        ∀ i, b₀ i = (1 : 𝔭.ResidueField) ⊗ₜ[A] D R A (Sum.elim yb zb i)) ∧
      (∃ b₁ : Module.Basis (Fin r ⊕ Fin n) 𝔮.ResidueField (𝔮.ResidueField ⊗[A ⧸ J] ((A ⧸ J) ⊗[A]
          Ω[A⁄R])),
        ∀ i, b₁ i = (1 : 𝔮.ResidueField) ⊗ₜ[A ⧸ J] ((1 : A ⧸ J) ⊗ₜ[A] D R A (Sum.elim yb zb i))) ∧
      Module.finrank 𝔮.ResidueField (𝔮.ResidueField ⊗[A ⧸ J] Ω[(A ⧸ J)⁄k]) = r
SchemeTheory.SmoothCharts.LocalizedBasis.linIndep_of_basis_localizedModule
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace LocalizedBasis
theorem linIndep_of_basis_localizedModule
    {R : Type u} [CommRing R] {A : Type u} [CommRing A] [Algebra R A]
    (J : Ideal A) (t : A ⧸ J) {ι : Type} (w : ι → A)
    (bM : Module.Basis ι (Localization.Away t)
      (LocalizedModule (Submonoid.powers t) ((A ⧸ J) ⊗[A] Ω[A⁄R])))
    (hbM : ∀ i, bM i = LocalizedModule.mkLinearMap (Submonoid.powers t) ((A ⧸ J) ⊗[A] Ω[A⁄R])
      ((1 : A ⧸ J) ⊗ₜ[A] D R A (w i)))
    (S : Type u) [CommRing S] [Algebra A S] [Algebra R S] [IsScalarTower R A S]
    (M : Submonoid A) [IsLocalization M S]
    (ht : IsUnit (algebraMap (A ⧸ J) (S ⧸ J.map (algebraMap A S)) t)) :
    LinearIndependent (S ⧸ J.map (algebraMap A S))
      fun i : ι => (1 : S ⧸ J.map (algebraMap A S)) ⊗ₜ[S] D R S (algebraMap A S (w i)) := by
  let algLS' : Algebra (Localization.Away t) (S ⧸ J.map (algebraMap A S)) :=
    (Localization.awayLift (algebraMap (A ⧸ J) (S ⧸ J.map (algebraMap A S))) t ht).toAlgebra
  have : IsScalarTower (A ⧸ J) (Localization.Away t) (S ⧸ J.map (algebraMap A S)) :=
    IsScalarTower.of_algebraMap_eq fun b =>
      (IsLocalization.Away.lift_eq t ht b).symm
  have : Algebra.FormallyEtale A S := Algebra.FormallyEtale.of_isLocalization (Rₘ := S) M
  have hbc := IsLocalizedModule.isBaseChange (Submonoid.powers t) (Localization.Away t)
    (LocalizedModule.mkLinearMap (Submonoid.powers t) ((A ⧸ J) ⊗[A] Ω[A⁄R]))
  let E : (S ⧸ J.map (algebraMap A S)) ⊗[Localization.Away t] LocalizedModule (Submonoid.powers t)
      ((A ⧸ J) ⊗[A] Ω[A⁄R])
      ≃ₗ[S ⧸ J.map (algebraMap A S)] (S ⧸ J.map (algebraMap A S)) ⊗[S] Ω[S⁄R] :=
    (TensorProduct.AlgebraTensorModule.congr (LinearEquiv.refl (S ⧸ J.map (algebraMap A S)) _)
        hbc.equiv.symm).trans
    ((TensorProduct.AlgebraTensorModule.cancelBaseChange (A ⧸ J) (Localization.Away t) (S ⧸ J.map
        (algebraMap A S))
      (S ⧸ J.map (algebraMap A S)) ((A ⧸ J) ⊗[A] Ω[A⁄R])).trans
    ((TensorProduct.AlgebraTensorModule.cancelBaseChange A (A ⧸ J) (S ⧸ J.map (algebraMap A S))
      (S ⧸ J.map (algebraMap A S)) Ω[A⁄R]).trans
    ((TensorProduct.AlgebraTensorModule.cancelBaseChange A S (S ⧸ J.map (algebraMap A S))
      (S ⧸ J.map (algebraMap A S)) Ω[A⁄R]).symm.trans
    (TensorProduct.AlgebraTensorModule.congr (LinearEquiv.refl (S ⧸ J.map (algebraMap A S)) _)
      (KaehlerDifferential.tensorKaehlerEquivOfFormallyEtale R A S)))))
  have key : ∀ i, E ((1 : S ⧸ J.map (algebraMap A S)) ⊗ₜ[Localization.Away t] bM i) =
      (1 : S ⧸ J.map (algebraMap A S)) ⊗ₜ[S] D R S (algebraMap A S (w i)) := by
    intro i
    rw [hbM]
    simp only [E, LinearEquiv.trans_apply, TensorProduct.AlgebraTensorModule.congr_tmul,
        LinearEquiv.refl_apply,
      IsBaseChange.equiv_symm_apply, TensorProduct.AlgebraTensorModule.cancelBaseChange_tmul,
          one_smul,
      TensorProduct.AlgebraTensorModule.cancelBaseChange_symm_tmul,
      KaehlerDifferential.tensorKaehlerEquivOfFormallyEtale_apply, mapBaseChange_tmul,
          KaehlerDifferential.map_D]
  have li := ((Algebra.TensorProduct.basis (S ⧸ J.map (algebraMap A S)) bM).map E).linearIndependent
  convert li using 1
  funext i
  rw [Module.Basis.map_apply, Algebra.TensorProduct.basis_apply, key]
SchemeTheory.SmoothCharts.LocalizedCentre.centre_localized_smooth_and_rank
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace LocalizedCentre
theorem centre_localized_smooth_and_rank
    (k : Type u) [Field k] (T : Type u) [CommRing T] [Algebra k T] [Algebra.FiniteType k T]
    (𝔮 : Ideal T) [𝔮.IsPrime] (hsmooth : Algebra.IsSmoothAt k 𝔮)
    (r : ℕ) (hrank : Module.finrank 𝔮.ResidueField (𝔮.ResidueField ⊗[T] Ω[T⁄k]) = r)
    (t : T) (ht : t ∉ 𝔮)
    (L : Type u) [CommRing L] [Algebra T L] [IsLocalization.Away t L]
    [Algebra k L] [IsScalarTower k T L] :
    ∃ (𝔮' : Ideal L) (_ : 𝔮'.IsPrime), 𝔮'.comap (algebraMap T L) = 𝔮 ∧
      Algebra.IsSmoothAt k 𝔮' ∧
      Module.finrank 𝔮'.ResidueField (𝔮'.ResidueField ⊗[L] Ω[L⁄k]) = r
SchemeTheory.SmoothCharts.CoordinateQuotient.formallySmooth_quotient_span_of_basis
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace CoordinateQuotient
theorem formallySmooth_quotient_span_of_basis
    {R : Type u} [CommRing R] {C : Type u} [CommRing C] [Algebra R C] [Algebra.FormallySmooth R C]
    {r n : ℕ} (W : Fin r ⊕ Fin n → C) (b : Module.Basis (Fin r ⊕ Fin n) C Ω[C⁄R])
    (hb : ∀ i, b i = D R C (W i)) :
    Algebra.FormallySmooth R (C ⧸ Ideal.span (Set.range (W ∘ Sum.inr)))
SchemeTheory.SmoothCharts.SpecialFibre.quot_smooth
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace SpecialFibre
theorem quot_smooth
    {R : Type u} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
    (π : R) (hπ : IsLocalRing.maximalIdeal R = Ideal.span {π})
    {C : Type u} [CommRing C] [Algebra R C] (hC : Algebra.IsStandardSmooth R C)
    {r n : ℕ} (W : Fin r ⊕ Fin n → C) (b : Module.Basis (Fin r ⊕ Fin n) C Ω[C⁄R])
    (hb : ∀ i, b i = D R C (W i))
    (JC : Ideal C) (hJC : JC = Ideal.span (insert (algebraMap R C π) (Set.range (W ∘ Sum.inr))))
    [Algebra (IsLocalRing.ResidueField R) (C ⧸ JC)] [IsScalarTower R (IsLocalRing.ResidueField R) (C
        ⧸ JC)] :
    Algebra.FiniteType (IsLocalRing.ResidueField R) (C ⧸ JC) ∧
    Algebra.Smooth (IsLocalRing.ResidueField R) (C ⧸ JC)
SchemeTheory.SmoothCharts.ChartTransport.quot_rank
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ChartTransport
theorem quot_rank
    {R : Type u} [CommRing R]
    (π : R) (k : Type u) [Field k] [Algebra R k]
    {C : Type u} [CommRing C] [Algebra R C]
    {r n : ℕ} (W : Fin r ⊕ Fin n → C) (b : Module.Basis (Fin r ⊕ Fin n) C Ω[C⁄R])
    (hb : ∀ i, b i = D R C (W i))
    (JC : Ideal C) (hJC : JC = Ideal.span (insert (algebraMap R C π) (Set.range (W ∘ Sum.inr))))
    [Algebra k (C ⧸ JC)] [IsScalarTower R k (C ⧸ JC)]
    (v : Ideal (C ⧸ JC)) [v.IsPrime] :
    Module.finrank v.ResidueField (v.ResidueField ⊗[C ⧸ JC] Ω[(C ⧸ JC)⁄k]) ≤ r
SchemeTheory.SmoothCharts.ChartTransport.quot_smooth_and_rank
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ChartTransport
theorem quot_smooth_and_rank
    {R : Type u} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
    (π : R) (hπ : IsLocalRing.maximalIdeal R = Ideal.span {π})
    {C : Type u} [CommRing C] [Algebra R C] (hC : Algebra.IsStandardSmooth R C)
    {r n : ℕ} (W : Fin r ⊕ Fin n → C) (b : Module.Basis (Fin r ⊕ Fin n) C Ω[C⁄R])
    (hb : ∀ i, b i = D R C (W i))
    (JC : Ideal C) (hJC : JC = Ideal.span (insert (algebraMap R C π) (Set.range (W ∘ Sum.inr))))
    [Algebra (IsLocalRing.ResidueField R) (C ⧸ JC)] [IsScalarTower R (IsLocalRing.ResidueField R) (C
        ⧸ JC)] :
    Algebra.FiniteType (IsLocalRing.ResidueField R) (C ⧸ JC) ∧
    Algebra.Smooth (IsLocalRing.ResidueField R) (C ⧸ JC) ∧
    ∀ (v : Ideal (C ⧸ JC)) [v.IsPrime],
      Module.finrank v.ResidueField (v.ResidueField ⊗[C ⧸ JC] Ω[(C ⧸ JC)⁄IsLocalRing.ResidueField
          R]) ≤ r
SchemeTheory.SmoothCharts.ChartTransport.linearIndependent_of_semilinear
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ChartTransport
theorem linearIndependent_of_semilinear
    {R₁ R₂ : Type*} [Ring R₁] [Ring R₂] {M₁ M₂ : Type*} [AddCommGroup M₁] [AddCommGroup M₂]
    [Module R₁ M₁] [Module R₂ M₂] (σ : R₁ →+* R₂) (hσ : Function.Injective σ)
    (j : M₁ →+ M₂) (hj : ∀ (r : R₁) (m : M₁), j (r • m) = σ r • j m)
    {ι : Type*} (v : ι → M₁) (hv : LinearIndependent R₂ (j ∘ v)) : LinearIndependent R₁ v
SchemeTheory.SmoothCharts.ChartTransport.finalTransport
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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.SmoothCharts
open TensorProduct KaehlerDifferential
universe u
namespace ChartTransport
theorem finalTransport
    {R : Type u} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
    (π : R) {A : Type u} [CommRing A] [Algebra R A]
    (J : Ideal A) (𝔭 : Ideal A) [𝔭.IsPrime]
    {r n : ℕ} (yb : Fin r → A) (zb : Fin n → A)
    (g₁ : A) (hg₁ : g₁ ∉ 𝔭) (C : Type u) [CommRing C] [Algebra R C]
    [Algebra C (Localization.Away g₁)] [IsScalarTower R C (Localization.Away g₁)]
    (hCstd : Algebra.IsStandardSmooth R C) (hθ : Function.Surjective (algebraMap C
        (Localization.Away g₁)))
    (W : Fin r ⊕ Fin n → C) (b : Module.Basis (Fin r ⊕ Fin n) C Ω[C⁄R])
    (hW : ∀ i, algebraMap C (Localization.Away g₁) (W i) = algebraMap A (Localization.Away g₁)
        (Sum.elim yb zb i))
    (hb : ∀ i, b i = D R C (W i))
    (c : C) (a : A) (ha : a ∉ 𝔭) (hca : algebraMap C (Localization.Away g₁) c = algebraMap A
        (Localization.Away g₁) a)
    (hIdeal : (Ideal.comap (algebraMap C (Localization.Away g₁)) (J.map (algebraMap A
        (Localization.Away g₁)))).map
        (algebraMap C (Localization.Away c)) =
      (Ideal.span (insert (algebraMap R C π) (Set.range (W ∘ Sum.inr)))).map (algebraMap C
          (Localization.Away c)))
    (g₂ : A) (hg₂a : g₂ ∣ a)
    (hlinS : ∀ (S : Type u) [CommRing S] [Algebra A S] [Algebra R S] [IsScalarTower R A S]
      (M : Submonoid A) [IsLocalization M S],
      IsUnit (algebraMap A S g₂) →
      LinearIndependent (S ⧸ J.map (algebraMap A S))
        fun j : Fin n => (1 : S ⧸ J.map (algebraMap A S)) ⊗ₜ[S] D R S (algebraMap A S (zb j))) :
    ∃ (g : A) (_ : g ∉ 𝔭) (r n : ℕ) (C : Type u) (_ : CommRing C) (_ : Algebra R C)
      (_ : Algebra C (Localization.Away g)) (_ : IsScalarTower R C (Localization.Away g)),
      Algebra.Smooth R C ∧ Function.Surjective (algebraMap C (Localization.Away g)) ∧
      ∃ (y : Fin r → C) (z : Fin n → C) (b : Module.Basis (Fin r ⊕ Fin n) C Ω[C⁄R]),
        (∀ i, b (Sum.inl i) = D R C (y i)) ∧ (∀ j, b (Sum.inr j) = D R C (z j)) ∧
        Ideal.comap (algebraMap C (Localization.Away g)) (J.map (algebraMap A (Localization.Away
            g))) =
          Ideal.span (insert (algebraMap R C π) (Set.range z)) ∧
        LinearIndependent (C ⧸ Ideal.span (insert (algebraMap R C π) (Set.range z)))
          fun j : Fin n => (1 : C ⧸ Ideal.span (insert (algebraMap R C π) (Set.range z))) ⊗ₜ[C]
            D R (Localization.Away g) (algebraMap C (Localization.Away g) (z j)) := by
  classical
  let θ : C →ₐ[R] (Localization.Away g₁) := ⟨algebraMap C (Localization.Away g₁), fun r' =>
      (IsScalarTower.algebraMap_apply R C (Localization.Away g₁) r').symm⟩
  have hAwayθc : IsLocalization.Away (θ c) (Localization.Away (algebraMap A (Localization.Away g₁)
      a)) := by
    change IsLocalization.Away (algebraMap C (Localization.Away g₁) c) (Localization.Away
        (algebraMap A (Localization.Away g₁) a)); rw [hca]; infer_instance
  let φT : (Localization.Away c) →ₐ[R] (Localization.Away (algebraMap A (Localization.Away g₁) a))
      := IsLocalization.Away.mapₐ (Localization.Away c) (Localization.Away (algebraMap A
      (Localization.Away g₁) a)) θ c
  have hφT_surj : Function.Surjective φT := IsLocalization.Away.mapₐ_surjective_of_surjective c hθ
  have hφT_apply : ∀ x : C, φT (algebraMap C (Localization.Away c) x) = algebraMap
      (Localization.Away g₁) (Localization.Away (algebraMap A (Localization.Away g₁) a)) (algebraMap
      C (Localization.Away g₁) x) := by
    intro x
    rw [IsLocalization.Away.mapₐ_apply]
    exact IsLocalization.map_eq _ _
  let e : (Localization.Away (algebraMap A (Localization.Away g₁) a)) ≃ₐ[A] (Localization.Away (g₁ *
      a)) := IsLocalization.algEquiv (Submonoid.powers (g₁ * a)) (Localization.Away (algebraMap A
      (Localization.Away g₁) a)) (Localization.Away (g₁ * a))
  let φ : (Localization.Away c) →+* (Localization.Away (g₁ * a)) := (e : (Localization.Away
      (algebraMap A (Localization.Away g₁) a)) →+* (Localization.Away (g₁ * a))).comp φT.toRingHom
  let iCSg : Algebra (Localization.Away c) (Localization.Away (g₁ * a)) := φ.toAlgebra
  have hφ_alg : ∀ x : (Localization.Away c), algebraMap (Localization.Away c) (Localization.Away (g₁
      * a)) x = e (φT x) := fun _ => rfl
  have hφC : ∀ x : C, algebraMap (Localization.Away c) (Localization.Away (g₁ * a)) (algebraMap C
      (Localization.Away c) x) = e (algebraMap (Localization.Away g₁) (Localization.Away (algebraMap
      A (Localization.Away g₁) a)) (algebraMap C (Localization.Away g₁) x)) := by
    intro x; rw [hφ_alg, hφT_apply]
  have heA₁ : ∀ y : A, e (algebraMap (Localization.Away g₁) (Localization.Away (algebraMap A
      (Localization.Away g₁) a)) (algebraMap A (Localization.Away g₁) y)) = algebraMap A
      (Localization.Away (g₁ * a)) y := by
    intro y
    rw [← IsScalarTower.algebraMap_apply A (Localization.Away g₁) (Localization.Away (algebraMap A
        (Localization.Away g₁) a))]
    exact e.commutes y
  have : IsScalarTower R (Localization.Away c) (Localization.Away (g₁ * a)) :=
      IsScalarTower.of_algebraMap_eq' (by
    ext r'
    rw [RingHom.comp_apply, IsScalarTower.algebraMap_apply R C (Localization.Away c), hφC,
      ← IsScalarTower.algebraMap_apply R C (Localization.Away g₁), IsScalarTower.algebraMap_apply R
          A (Localization.Away g₁), heA₁,
      IsScalarTower.algebraMap_apply R A (Localization.Away (g₁ * a))])
  have : Algebra.IsStandardSmooth R C := hCstd
  have : Algebra.IsStandardSmooth C (Localization.Away c) :=
      Algebra.IsStandardSmooth.localization_away c
  have : Algebra.IsStandardSmooth R (Localization.Away c) := Algebra.IsStandardSmooth.trans R C
      (Localization.Away c)
  have hCsm : Algebra.Smooth R (Localization.Away c) := inferInstance
  have hsurj : Function.Surjective (algebraMap (Localization.Away c) (Localization.Away (g₁ * a)))
      := by
    intro s; obtain ⟨t, rfl⟩ := e.surjective s; obtain ⟨x, rfl⟩ := hφT_surj t; exact ⟨x, rfl⟩
  let z' : Fin n → (Localization.Away c) := fun j => algebraMap C (Localization.Away c) (W (Sum.inr
      j))
  let b' : Module.Basis (Fin r ⊕ Fin n) (Localization.Away c) Ω[(Localization.Away c)⁄R] :=
    b.ofIsLocalizedModule (Localization.Away c) (Submonoid.powers c) (KaehlerDifferential.map R R C
        (Localization.Away c))
  have hb' : ∀ i, b' i = D R (Localization.Away c) (algebraMap C (Localization.Away c) (W i)) := by
    intro i
    rw [Module.Basis.ofIsLocalizedModule_apply, hb, KaehlerDifferential.map_D]
  have hz'S : ∀ j, algebraMap (Localization.Away c) (Localization.Away (g₁ * a)) (z' j) = algebraMap
      A (Localization.Away (g₁ * a)) (zb j) := by
    intro j; change algebraMap (Localization.Away c) (Localization.Away (g₁ * a)) (algebraMap C
        (Localization.Away c) (W (Sum.inr j))) = _; rw [hφC, hW, Sum.elim_inr, heA₁]
  have hspan_map : (Ideal.span (insert (algebraMap R C π) (Set.range (W ∘ Sum.inr)))).map
      (algebraMap C (Localization.Away c)) =
      Ideal.span (insert (algebraMap R (Localization.Away c) π) (Set.range z')) := by
    rw [Ideal.map_span, Set.image_insert_eq, ← Set.range_comp, ← IsScalarTower.algebraMap_apply R C
        (Localization.Away c)]
    rfl
  have hmapJ : (J.map (algebraMap A (Localization.Away g₁))).map ((e : (Localization.Away
      (algebraMap A (Localization.Away g₁) a)) →+* (Localization.Away (g₁ * a))).comp (algebraMap
      (Localization.Away g₁) (Localization.Away (algebraMap A (Localization.Away g₁) a)))) =
      J.map (algebraMap A (Localization.Away (g₁ * a))) := by
    rw [Ideal.map_map]; congr 1; ext y; exact heA₁ y
  have hmem_e : ∀ (I : Ideal (Localization.Away (algebraMap A (Localization.Away g₁) a))) (y :
      (Localization.Away (algebraMap A (Localization.Away g₁) a))), e y ∈ I.map (e :
      (Localization.Away (algebraMap A (Localization.Away g₁) a)) →+* (Localization.Away (g₁ * a)))
      → y ∈ I := by
    intro I y hy
    have h := Ideal.mem_map_of_mem (e.symm : (Localization.Away (g₁ * a)) →+* (Localization.Away
        (algebraMap A (Localization.Away g₁) a))) hy
    rw [Ideal.map_map] at h
    have hcomp : (e.symm : (Localization.Away (g₁ * a)) →+* (Localization.Away (algebraMap A
        (Localization.Away g₁) a))).comp (e : (Localization.Away (algebraMap A (Localization.Away
        g₁) a)) →+* (Localization.Away (g₁ * a))) = RingHom.id _ := by
      ext t; exact e.symm_apply_apply t
    rw [hcomp, Ideal.map_id] at h
    change e.symm (e y) ∈ I at h
    rwa [e.symm_apply_apply] at h
  have hJC' : Ideal.comap (algebraMap (Localization.Away c) (Localization.Away (g₁ * a))) (J.map
      (algebraMap A (Localization.Away (g₁ * a)))) =
      Ideal.span (insert (algebraMap R (Localization.Away c) π) (Set.range z')) := by
    rw [← hspan_map, ← hIdeal]
    apply le_antisymm
    · intro x' hx'
      rw [Ideal.mem_comap] at hx'
      obtain ⟨m, x, hmx⟩ := IsLocalization.Away.surj c x'
      have h1 : algebraMap (Localization.Away c) (Localization.Away (g₁ * a)) (algebraMap C
          (Localization.Away c) x) ∈ J.map (algebraMap A (Localization.Away (g₁ * a))) := by
        rw [← hmx, map_mul, map_pow]
        exact Ideal.mul_mem_right _ _ hx'
      rw [hφC, ← hmapJ, ← Ideal.map_map] at h1
      have h2 := hmem_e _ _ h1
      rw [IsLocalization.algebraMap_mem_map_algebraMap_iff (Submonoid.powers (algebraMap A
          (Localization.Away g₁) a))] at h2
      obtain ⟨_, ⟨m', rfl⟩, hm'⟩ := h2
      beta_reduce at hm'
      rw [← hca, ← map_pow, ← map_mul] at hm'
      have h3 : c ^ m' * x ∈ Ideal.comap (algebraMap C (Localization.Away g₁)) (J.map (algebraMap A
          (Localization.Away g₁))) := by
        rw [Ideal.mem_comap]; exact hm'
      have h4 := Ideal.mem_map_of_mem (algebraMap C (Localization.Away c)) h3
      rw [map_mul, map_pow] at h4
      have hcu : IsUnit (algebraMap C (Localization.Away c) c ^ m') :=
          (IsLocalization.Away.algebraMap_isUnit c).pow m'
      rw [Ideal.unit_mul_mem_iff_mem _ hcu] at h4
      have hcu' : IsUnit (algebraMap C (Localization.Away c) c ^ m) :=
          (IsLocalization.Away.algebraMap_isUnit c).pow m
      rw [← Ideal.unit_mul_mem_iff_mem _ hcu', mul_comm, hmx]
      exact h4
    · rw [Ideal.map_le_iff_le_comap]
      intro x hx
      rw [Ideal.mem_comap, Ideal.mem_comap, hφC, ← hmapJ, ← Ideal.map_map]
      apply Ideal.mem_map_of_mem
      apply Ideal.mem_map_of_mem
      rw [Ideal.mem_comap] at hx
      exact hx
  have hg₂unit : IsUnit (algebraMap A (Localization.Away (g₁ * a)) g₂) :=
    IsLocalization.Away.isUnit_of_dvd (g₁ * a) (hg₂a.trans (Dvd.intro_left g₁ rfl))
  have hlin0 := hlinS (Localization.Away (g₁ * a)) (Submonoid.powers (g₁ * a)) hg₂unit
  let Qc := (Localization.Away c) ⧸
    Ideal.span (insert (algebraMap R (Localization.Away c) π) (Set.range z'))
  let Qs := (Localization.Away (g₁ * a)) ⧸
    J.map (algebraMap A (Localization.Away (g₁ * a)))
  have hlin : LinearIndependent Qc
      fun j : Fin n => (1 : (Localization.Away c) ⧸ Ideal.span (insert (algebraMap R
          (Localization.Away c) π) (Set.range z'))) ⊗ₜ[(Localization.Away c)]
        D R (Localization.Away (g₁ * a)) (algebraMap (Localization.Away c) (Localization.Away (g₁ *
            a)) (z' j)) := by
    have hle : Ideal.span (insert (algebraMap R (Localization.Away c) π) (Set.range z')) ≤ (J.map
        (algebraMap A (Localization.Away (g₁ * a)))).comap (algebraMap (Localization.Away c)
        (Localization.Away (g₁ * a))) :=
      hJC'.symm.le
    let σ : Qc →+* Qs :=
      Ideal.quotientMap (J.map (algebraMap A (Localization.Away (g₁ * a)))) (algebraMap
          (Localization.Away c) (Localization.Away (g₁ * a))) hle
    have hσmk : ∀ x : (Localization.Away c), σ (Ideal.Quotient.mk _ x) = Ideal.Quotient.mk _
        (algebraMap (Localization.Away c) (Localization.Away (g₁ * a)) x) :=
      fun x => Ideal.quotientMap_mk
    have hσ : Function.Injective σ := Ideal.quotientMap_injective' hJC'.le
    let j0 : Qc →+ (Ω[(Localization.Away (g₁ * a))⁄R] →+ (Qs ⊗[(Localization.Away (g₁ * a))]
        Ω[(Localization.Away (g₁ * a))⁄R])) :=
      { toFun := fun x => (TensorProduct.mk (Localization.Away (g₁ * a)) Qs Ω[(Localization.Away (g₁
          * a))⁄R] (σ x)).toAddMonoidHom
        map_zero' := by
          ext ω
          exact (congrArg (fun q => q ⊗ₜ[(Localization.Away (g₁ * a))] ω) (map_zero σ)).trans
            (TensorProduct.zero_tmul _ ω)
        map_add' := fun x y => by
          ext ω
          exact (congrArg (fun q => q ⊗ₜ[(Localization.Away (g₁ * a))] ω) (map_add σ x y)).trans
            (TensorProduct.add_tmul _ _ ω) }
    have hj0 : ∀ x ω, j0 x ω = σ x ⊗ₜ[(Localization.Away (g₁ * a))] ω := fun _ _ => rfl
    let j : Qc ⊗[(Localization.Away c)] Ω[(Localization.Away (g₁ * a))⁄R] →+ Qs ⊗[(Localization.Away
        (g₁ * a))] Ω[(Localization.Away (g₁ * a))⁄R] :=
      TensorProduct.liftAddHom j0 (fun r' x ω => by
        rw [hj0, hj0]
        obtain ⟨x0, rfl⟩ := Ideal.Quotient.mk_surjective x
        have e1 : r' • Ideal.Quotient.mk (Ideal.span (insert (algebraMap R (Localization.Away c) π)
            (Set.range z'))) x0 =
            Ideal.Quotient.mk _ (r' * x0) := rfl
        rw [e1, hσmk, hσmk, map_mul, ← algebraMap_smul (A := (Localization.Away (g₁ * a))) r' ω,
            TensorProduct.tmul_smul,
          TensorProduct.smul_tmul']
        rfl)
    have hjt : ∀ (x : Qc) (ω : Ω[(Localization.Away (g₁ * a))⁄R]), j (x ⊗ₜ ω) = σ x ⊗ₜ ω := fun x ω
        => by
      change j0 x ω = _; rw [hj0]
    have hj : ∀ (r' : Qc) (m : Qc ⊗[(Localization.Away c)] Ω[(Localization.Away (g₁ * a))⁄R]), j (r'
        • m) = σ r' • j m := by
      intro r' m
      induction m using TensorProduct.inductionOn with
      | tmul x ω =>
        rw [TensorProduct.smul_tmul', smul_eq_mul, hjt, hjt, map_mul, TensorProduct.smul_tmul',
            smul_eq_mul]
      | add m₁ m₂ h₁ h₂ => rw [smul_add, map_add, h₁, h₂, map_add, smul_add]
    refine linearIndependent_of_semilinear σ hσ j hj _ ?_
    have : (j ∘ fun j' : Fin n => (1 : Qc) ⊗ₜ[(Localization.Away c)] D R (Localization.Away (g₁ *
        a)) (algebraMap (Localization.Away c) (Localization.Away (g₁ * a)) (z' j'))) =
        fun j' : Fin n => (1 : (Localization.Away (g₁ * a)) ⧸ J.map (algebraMap A (Localization.Away
            (g₁ * a)))) ⊗ₜ[(Localization.Away (g₁ * a))] D R (Localization.Away (g₁ * a))
            (algebraMap A (Localization.Away (g₁ * a)) (zb j')) := by
      funext j'
      simp only [Function.comp_apply]
      rw [hjt, map_one, hz'S]
    rw [this]
    exact hlin0
  refine ⟨g₁ * a, fun h => (Ideal.IsPrime.mem_or_mem ‹𝔭.IsPrime› h).elim hg₁ ha, r, n,
      (Localization.Away c), inferInstance,
    inferInstance, iCSg, inferInstance, hCsm, hsurj, fun i => algebraMap C (Localization.Away c) (W
        (Sum.inl i)), z', b',
    fun i => hb' (Sum.inl i), fun j => hb' (Sum.inr j), hJC', hlin⟩
Algebra.exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span
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_exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span.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 Algebra
open SchemeTheory.SmoothCharts
open _root_.KaehlerDifferential _root_.TensorProduct _root_.MvPolynomial
open scoped TensorProduct
universe u v
theorem exists_smooth_surjective_localizationAway_basis_kaehlerDifferential_comap_eq_span
    {R : Type u} [CommRing R] [IsDomain R] [IsDiscreteValuationRing R]
    (π : R) (hπ : IsLocalRing.maximalIdeal R = Ideal.span {π})
    {A : Type u} [CommRing A] [Algebra R A] [Algebra.FiniteType R A]
    (J : Ideal A) (hπJ : algebraMap R A π ∈ J)
    [Algebra (IsLocalRing.ResidueField R) (A ⧸ J)] [IsScalarTower R (IsLocalRing.ResidueField R) (A
        ⧸ J)]
    (𝔭 : Ideal A) [𝔭.IsPrime]
    (𝔮 : Ideal (A ⧸ J)) [𝔮.IsPrime] (h𝔮 : 𝔮.comap (Ideal.Quotient.mk J) = 𝔭)
    (hsmooth : Algebra.IsSmoothAt (IsLocalRing.ResidueField R) 𝔮)
    (hfree : (⟨𝔮, ‹_›⟩ : PrimeSpectrum (A ⧸ J)) ∈ Module.freeLocus (A ⧸ J) ((A ⧸ J) ⊗[A] Ω[A⁄R])) :
    ∃ (g : A) (_ : g ∉ 𝔭) (r n : ℕ) (C : Type u) (_ : CommRing C) (_ : Algebra R C)
      (_ : Algebra C (Localization.Away g)) (_ : IsScalarTower R C (Localization.Away g)),
      Algebra.Smooth R C ∧ Function.Surjective (algebraMap C (Localization.Away g)) ∧
      ∃ (y : Fin r → C) (z : Fin n → C) (b : Module.Basis (Fin r ⊕ Fin n) C Ω[C⁄R]),
        (∀ i, b (Sum.inl i) = D R C (y i)) ∧ (∀ j, b (Sum.inr j) = D R C (z j)) ∧
        Ideal.comap (algebraMap C (Localization.Away g)) (J.map (algebraMap A (Localization.Away
            g))) =
          Ideal.span (insert (algebraMap R C π) (Set.range z)) ∧
        LinearIndependent (C ⧸ Ideal.span (insert (algebraMap R C π) (Set.range z)))
          fun j : Fin n => (1 : C ⧸ Ideal.span (insert (algebraMap R C π) (Set.range z))) ⊗ₜ[C]
            D R (Localization.Away g) (algebraMap C (Localization.Away g) (z j)) := by
  classical
  set k : Type u := IsLocalRing.ResidueField R with hkdef
  have : IsNoetherianRing R := inferInstance
  have hAfp : Algebra.FinitePresentation R A := Algebra.FinitePresentation.of_finiteType.mp
      inferInstance
  have hk : Function.Surjective (algebraMap R k) := Ideal.Quotient.mk_surjective
  have hJ𝔭 : J ≤ 𝔭 := by
    intro x hx; rw [← h𝔮, Ideal.mem_comap]; rw [Ideal.Quotient.eq_zero_iff_mem.mpr hx]; exact
        Ideal.zero_mem _
  obtain ⟨r, n, yb, zb, hzb, ⟨b₀, hb₀⟩, ⟨b₁, hb₁⟩, hrank⟩ := ResidueBasis.fibreBasis k hk J 𝔭 𝔮 h𝔮
  obtain ⟨g₁, hg₁, C, iC, iRC, iCA, iT, hCstd, hθ, W, b, hW, hb⟩ :=
    MinimalAmbient.main
      𝔭 (Sum.elim yb zb) b₀ hb₀
  have : Module.FinitePresentation (A ⧸ J) ((A ⧸ J) ⊗[A] Ω[A⁄R]) := inferInstance
  obtain ⟨t, ht, bM, hbM⟩ :=
    Module.FinitePresentation.exists_notMem_basis_localizedModule_of_basis_residueField_tensor
      𝔮 hfree (fun i => (1 : A ⧸ J) ⊗ₜ[A] D R A (Sum.elim yb zb i)) b₁ hb₁
  obtain ⟨g₂, hg₂t⟩ := Ideal.Quotient.mk_surjective t
  have hg₂ : g₂ ∉ 𝔭 := by rw [← h𝔮, Ideal.mem_comap, hg₂t]; exact ht
  set A₁ : Type u := Localization.Away g₁ with hA₁
  set JC : Ideal C := Ideal.span (insert (algebraMap R C π) (Set.range (W ∘ Sum.inr))) with hJCdef
  set I₁ : Ideal C := Ideal.comap (algebraMap C A₁) (J.map (algebraMap A A₁)) with hI₁
  have hJCI : JC ≤ I₁ := by
    rw [hJCdef, Ideal.span_le]
    rintro x (rfl | ⟨j, rfl⟩)
    · change algebraMap R C π ∈ I₁
      rw [hI₁, Ideal.mem_comap, ← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R A
          A₁]
      exact Ideal.mem_map_of_mem _ hπJ
    · change W (Sum.inr j) ∈ I₁
      rw [hI₁, Ideal.mem_comap, hW]
      exact Ideal.mem_map_of_mem _ (hzb j)
  set B : Type u := C ⧸ JC with hB
  have hπB : ∀ x ∈ IsLocalRing.maximalIdeal R, algebraMap R B x = 0 := by
    intro x hx
    rw [hπ, Ideal.mem_span_singleton] at hx
    obtain ⟨y, rfl⟩ := hx
    change Ideal.Quotient.mk JC (algebraMap R C (π * y)) = 0
    have hπJC : algebraMap R C π ∈ JC := Ideal.subset_span (Set.mem_insert _ _)
    rw [map_mul, map_mul, Ideal.Quotient.eq_zero_iff_mem.mpr hπJC, zero_mul]
  let iKB : Algebra k B := (Ideal.Quotient.lift (IsLocalRing.maximalIdeal R) (algebraMap R B)
      hπB).toAlgebra
  have : IsScalarTower R k B := IsScalarTower.of_algebraMap_eq' (by
    ext x
    exact (Ideal.Quotient.lift_mk (IsLocalRing.maximalIdeal R) (algebraMap R B) hπB).symm)
  obtain ⟨hBft, hBsm, hBrank⟩ := ChartTransport.quot_smooth_and_rank π hπ hCstd W b hb JC hJCdef
  set gb₁ : A ⧸ J := Ideal.Quotient.mk J g₁ with hgb₁
  have hgb₁𝔮 : gb₁ ∉ 𝔮 := by rw [← h𝔮, Ideal.mem_comap] at hg₁; exact hg₁
  set L : Type u := Localization.Away gb₁ with hL
  have : Algebra.FiniteType R (A ⧸ J) := inferInstance
  have : Algebra.FiniteType k (A ⧸ J) := Algebra.FiniteType.of_restrictScalars_finiteType R k (A ⧸
      J)
  obtain ⟨𝔮', i𝔮', h𝔮', hsm', hrank'⟩ :=
    LocalizedCentre.centre_localized_smooth_and_rank k (A ⧸ J) 𝔮 hsmooth r hrank gb₁ hgb₁𝔮 L
  have hunit : IsUnit (((algebraMap (A ⧸ J) L).comp (Ideal.Quotient.mk J)) g₁) :=
    IsLocalization.Away.algebraMap_isUnit gb₁
  set lam₁ : A₁ →+* L := IsLocalization.Away.lift g₁ hunit with hlam₁
  have hlam₁ : ∀ x : A, lam₁ (algebraMap A A₁ x) = algebraMap (A ⧸ J) L (Ideal.Quotient.mk J x) :=
    fun x => IsLocalization.Away.lift_eq g₁ hunit x
  set ψ₀ : C →+* L := lam₁.comp (algebraMap C A₁) with hψ₀
  have hlamJ : ∀ x ∈ J, lam₁ (algebraMap A A₁ x) = 0 := fun x hx => by
    rw [hlam₁, Ideal.Quotient.eq_zero_iff_mem.mpr hx, map_zero]
  have hψ₀J : ∀ x ∈ JC, ψ₀ x = 0 := by
    have hle : JC ≤ RingHom.ker ψ₀ := by
      rw [hJCdef, Ideal.span_le]
      rintro x (rfl | ⟨j, rfl⟩)
      · simp only [SetLike.mem_coe, RingHom.mem_ker, hψ₀, RingHom.comp_apply]
        rw [← IsScalarTower.algebraMap_apply R C A₁, IsScalarTower.algebraMap_apply R A A₁]
        exact hlamJ _ hπJ
      · simp only [SetLike.mem_coe, RingHom.mem_ker, hψ₀, RingHom.comp_apply, Function.comp_apply]
        rw [hW, Sum.elim_inr]
        exact hlamJ _ (hzb j)
    exact fun x hx => hle hx
  set ψ₁ : B →+* L := Ideal.Quotient.lift JC ψ₀ hψ₀J with hψ₁
  have hψ₁k : ∀ x : k, ψ₁ (algebraMap k B x) = algebraMap k L x := by
    intro x
    obtain ⟨r', rfl⟩ := hk x
    rw [← IsScalarTower.algebraMap_apply R k B, IsScalarTower.algebraMap_apply R C B,
      Ideal.Quotient.algebraMap_eq, hψ₁, Ideal.Quotient.lift_mk, hψ₀, RingHom.comp_apply,
      ← IsScalarTower.algebraMap_apply R C A₁, IsScalarTower.algebraMap_apply R A A₁, hlam₁,
      IsScalarTower.algebraMap_apply k (A ⧸ J) L, ← IsScalarTower.algebraMap_apply R k (A ⧸ J),
      IsScalarTower.algebraMap_apply R A (A ⧸ J), Ideal.Quotient.algebraMap_eq]
  let ψ : B →ₐ[k] L := AlgHom.mk ψ₁ hψ₁k
  have e1 : lam₁ (algebraMap A A₁ g₁) = algebraMap (A ⧸ J) L gb₁ :=
    (hlam₁ g₁).trans (congrArg (algebraMap (A ⧸ J) L) hgb₁).symm
  have hlam₁surj : Function.Surjective lam₁ := by
    intro zL
    obtain ⟨m, ā, hm⟩ := IsLocalization.Away.surj gb₁ zL
    obtain ⟨a₀, rfl⟩ := Ideal.Quotient.mk_surjective ā
    refine ⟨IsLocalization.mk' A₁ a₀ (⟨g₁ ^ m, m, rfl⟩ : Submonoid.powers g₁), ?_⟩
    have hu : IsUnit (algebraMap (A ⧸ J) L gb₁ ^ m) := (IsLocalization.Away.algebraMap_isUnit
        gb₁).pow m
    apply hu.mul_left_injective
    change lam₁ _ * algebraMap (A ⧸ J) L gb₁ ^ m = zL * algebraMap (A ⧸ J) L gb₁ ^ m
    rw [hm, ← e1, ← map_pow, ← map_mul, ← map_pow]
    erw [IsLocalization.mk'_spec]
    rw [hlam₁]
  have hψ : Function.Surjective ψ := by
    intro zL
    obtain ⟨y, hy⟩ := hlam₁surj zL
    obtain ⟨c, rfl⟩ := hθ y
    refine ⟨Ideal.Quotient.mk JC c, ?_⟩
    change ψ₁ (Ideal.Quotient.mk JC c) = zL
    rw [hψ₁, Ideal.Quotient.lift_mk, hψ₀, RingHom.comp_apply, hy]
  set v : Ideal B := 𝔮'.comap ψ.toRingHom with hv
  have : v.IsPrime := Ideal.comap_isPrime _ _
  have : Algebra.FiniteType k B := hBft
  have : Algebra.Smooth k B := hBsm
  obtain ⟨t₃, ht₃, hker⟩ :=
    Algebra.exists_notMem_map_ker_eq_bot_of_surjective_of_isSmoothAt_of_finrank_le
      ψ hψ 𝔮' v rfl hsm' ((hBrank v).trans hrank'.symm.le)
  have : ∃ (c : C) (a : A), a ∉ 𝔭 ∧ g₂ ∣ a ∧ algebraMap C A₁ c = algebraMap A A₁ a ∧
      (I₁.map (algebraMap C (Localization.Away c)) = JC.map (algebraMap C (Localization.Away c)))
          := by
    obtain ⟨c₃, rfl⟩ := Ideal.Quotient.mk_surjective t₃
    obtain ⟨m, a₃, hm⟩ := IsLocalization.Away.surj g₁ (algebraMap C A₁ c₃)
    obtain ⟨u₁, hu₁⟩ := hθ (algebraMap A A₁ (g₁ ^ m))
    obtain ⟨u₂, hu₂⟩ := hθ (algebraMap A A₁ g₂)
    have ha₃ : a₃ ∉ 𝔭 := by
      intro ha₃
      have h1 : lam₁ (algebraMap A A₁ a₃) ∈ 𝔮' := by
        rw [hlam₁]
        have : Ideal.Quotient.mk J a₃ ∈ 𝔮 := by rw [← h𝔮, Ideal.mem_comap] at ha₃; exact ha₃
        rw [← h𝔮'] at this
        exact this
      rw [← hm, map_mul, map_pow] at h1
      rcases (Ideal.IsPrime.mem_or_mem i𝔮' h1) with h2 | h2
      · apply ht₃
        rw [hv, Ideal.mem_comap]
        change ψ₁ (Ideal.Quotient.mk JC c₃) ∈ 𝔮'
        rwa [hψ₁, Ideal.Quotient.lift_mk, hψ₀, RingHom.comp_apply]
      · have hu : IsUnit (lam₁ (algebraMap A A₁ g₁) ^ m) := by
          rw [e1]; exact (IsLocalization.Away.algebraMap_isUnit gb₁).pow m
        exact (Ideal.IsPrime.ne_top i𝔮') (Ideal.eq_top_of_isUnit_mem _ h2 hu)
    refine ⟨c₃ * u₁ * u₂, a₃ * g₂, ?_, dvd_mul_left _ _, ?_, ?_⟩
    · exact fun h => (Ideal.IsPrime.mem_or_mem ‹𝔭.IsPrime› h).elim ha₃ hg₂
    · rw [map_mul, map_mul, hu₁, hu₂, map_mul, ← hm, map_pow]
    · set Cc : Type u := Localization.Away (c₃ * u₁ * u₂) with hCc
      apply le_antisymm
      · rw [Ideal.map_le_iff_le_comap]
        intro x hx
        rw [Ideal.mem_comap]
        have hxker : Ideal.Quotient.mk JC x ∈ RingHom.ker ψ.toRingHom := by
          rw [RingHom.mem_ker]
          change ψ₁ (Ideal.Quotient.mk JC x) = 0
          rw [hψ₁, Ideal.Quotient.lift_mk, hψ₀, RingHom.comp_apply]
          rw [hI₁, Ideal.mem_comap] at hx
          have : J.map (algebraMap A A₁) ≤ RingHom.ker lam₁ := by
            rw [Ideal.map_le_iff_le_comap]; intro y hy; exact hlamJ y hy
          exact this hx
        have h0 : algebraMap B (Localization.Away (Ideal.Quotient.mk JC c₃)) (Ideal.Quotient.mk JC
            x) = 0 := by
          have := Ideal.mem_map_of_mem (algebraMap B (Localization.Away (Ideal.Quotient.mk JC c₃)))
              hxker
          rwa [hker, Ideal.mem_bot] at this
        rw [IsLocalization.map_eq_zero_iff (Submonoid.powers (Ideal.Quotient.mk JC c₃))] at h0
        obtain ⟨⟨_, ⟨m', rfl⟩⟩, hm'⟩ := h0
        have hmem : c₃ ^ m' * x ∈ JC := by
          rw [← Ideal.Quotient.eq_zero_iff_mem, map_mul, map_pow]; exact hm'
        have hc₃unit : IsUnit (algebraMap C Cc (c₃ ^ m')) := by
          rw [map_pow]; refine IsUnit.pow _ ?_
          exact IsLocalization.Away.isUnit_of_dvd (c₃ * u₁ * u₂) ⟨u₁ * u₂, by ring⟩
        have := Ideal.mem_map_of_mem (algebraMap C Cc) hmem
        rw [map_mul] at this
        exact (Ideal.unit_mul_mem_iff_mem _ hc₃unit).mp this
      · exact Ideal.map_mono hJCI
  obtain ⟨c, a, ha, hg₂a, hca, hIdeal⟩ := this
  exact ChartTransport.finalTransport π J 𝔭 yb zb g₁ hg₁ C hCstd hθ W b hW hb c a ha hca hIdeal g₂
      hg₂a
    (fun S _ _ _ _ M _ hu => LocalizedBasis.linIndep_of_basis_localizedModule J t (Sum.elim yb zb)
        bM hbM S M (by
        rw [← hg₂t]
        exact hu.map (algebraMap S (S ⧸ J.map (algebraMap A S)))) |>.comp Sum.inr Sum.inr_injective)