doc-next-gen

Mathlib.RingTheory.FinitePresentation

Module docstring

{"# Finiteness conditions in commutative algebra

In this file we define several notions of finiteness that are common in commutative algebra.

Main declarations

  • Module.Finite, RingHom.Finite, AlgHom.Finite all of these express that some object is finitely generated as module over some base ring.
  • Algebra.FiniteType, RingHom.FiniteType, AlgHom.FiniteType all of these express that some object is finitely generated as algebra over some base ring.
  • Algebra.FinitePresentation, RingHom.FinitePresentation, AlgHom.FinitePresentation all of these express that some object is finitely presented as algebra over some base ring.

"}

Algebra.FinitePresentation structure
[CommSemiring R] [Semiring A] [Algebra R A]
Full source
/-- An algebra over a commutative semiring is `Algebra.FinitePresentation` if it is the quotient of
a polynomial ring in `n` variables by a finitely generated ideal. -/
class Algebra.FinitePresentation [CommSemiring R] [Semiring A] [Algebra R A] : Prop where
  out : ∃ (n : ℕ) (f : MvPolynomial (Fin n) R →ₐ[R] A), Surjective f ∧ (RingHom.ker f.toRingHom).FG
Finitely presented algebra
Informal description
An algebra $A$ over a commutative semiring $R$ is said to be *finitely presented* if it is isomorphic to the quotient of a polynomial ring $R[X_1, \dots, X_n]$ by a finitely generated ideal.
Algebra.FiniteType.of_finitePresentation instance
[FinitePresentation R A] : FiniteType R A
Full source
/-- A finitely presented algebra is of finite type. -/
instance of_finitePresentation [FinitePresentation R A] : FiniteType R A := by
  obtain ⟨n, f, hf⟩ := FinitePresentation.out (R := R) (A := A)
  apply FiniteType.iff_quotient_mvPolynomial''.2
  exact ⟨n, f, hf.1⟩
Finitely Presented Algebras are Finitely Generated
Informal description
Every finitely presented algebra $A$ over a commutative semiring $R$ is also finitely generated as an algebra over $R$.
Algebra.FinitePresentation.of_finiteType theorem
[IsNoetherianRing R] : FiniteType R A ↔ FinitePresentation R A
Full source
/-- An algebra over a Noetherian ring is finitely generated if and only if it is finitely
presented. -/
theorem of_finiteType [IsNoetherianRing R] : FiniteTypeFiniteType R A ↔ FinitePresentation R A := by
  refine ⟨fun h => ?_, fun hfp => Algebra.FiniteType.of_finitePresentation⟩
  obtain ⟨n, f, hf⟩ := Algebra.FiniteType.iff_quotient_mvPolynomial''.1 h
  refine ⟨n, f, hf, ?_⟩
  have hnoet : IsNoetherianRing (MvPolynomial (Fin n) R) := by infer_instance
  -- Porting note: rewrote code to help typeclass inference
  rw [isNoetherianRing_iff] at hnoet
  letI : Module (MvPolynomial (Fin n) R) (MvPolynomial (Fin n) R) := Semiring.toModule
  convert hnoet.noetherian (RingHom.ker f.toRingHom)
Equivalence of Finite Generation and Finite Presentation for Algebras over Noetherian Rings
Informal description
Let $R$ be a Noetherian commutative semiring and $A$ an $R$-algebra. Then $A$ is finitely generated as an $R$-algebra if and only if it is finitely presented as an $R$-algebra.
Algebra.FinitePresentation.equiv theorem
[FinitePresentation R A] (e : A ≃ₐ[R] B) : FinitePresentation R B
Full source
/-- If `e : A ≃ₐ[R] B` and `A` is finitely presented, then so is `B`. -/
theorem equiv [FinitePresentation R A] (e : A ≃ₐ[R] B) : FinitePresentation R B := by
  obtain ⟨n, f, hf⟩ := FinitePresentation.out (R := R) (A := A)
  use n, AlgHom.comp (↑e) f
  constructor
  · rw [AlgHom.coe_comp]
    exact Function.Surjective.comp e.surjective hf.1
  suffices (RingHom.ker (AlgHom.comp (e : A →ₐ[R] B) f).toRingHom) = RingHom.ker f.toRingHom by
    rw [this]
    exact hf.2
  have hco : (AlgHom.comp (e : A →ₐ[R] B) f).toRingHom = RingHom.comp (e.toRingEquiv : A ≃+* B)
    f.toRingHom := by
    have h : (AlgHom.comp (e : A →ₐ[R] B) f).toRingHom =
      e.toAlgHom.toRingHom.comp f.toRingHom := rfl
    have h1 : ↑e.toRingEquiv = e.toAlgHom.toRingHom := rfl
    rw [h, h1]
  rw [RingHom.ker_eq_comap_bot, hco, ← Ideal.comap_comap, ← RingHom.ker_eq_comap_bot,
    RingHom.ker_coe_equiv (AlgEquiv.toRingEquiv e), RingHom.ker_eq_comap_bot]
Finitely Presented Algebra is Preserved under Algebra Isomorphism
Informal description
Let $A$ and $B$ be algebras over a commutative semiring $R$, and let $e : A \simeq_{R} B$ be an $R$-algebra isomorphism. If $A$ is finitely presented as an $R$-algebra, then $B$ is also finitely presented as an $R$-algebra.
Algebra.FinitePresentation.mvPolynomial instance
(ι : Type*) [Finite ι] : FinitePresentation R (MvPolynomial ι R)
Full source
/-- The ring of polynomials in finitely many variables is finitely presented. -/
protected instance mvPolynomial (ι : Type*) [Finite ι] :
    FinitePresentation R (MvPolynomial ι R) where
  out := by
    cases nonempty_fintype ι
    let eqv := (MvPolynomial.renameEquiv R <| Fintype.equivFin ι).symm
    exact
      ⟨Fintype.card ι, eqv, eqv.surjective,
        ((RingHom.injective_iff_ker_eq_bot _).1 eqv.injective).symm ▸ Submodule.fg_bot⟩
Finitely Presented Polynomial Ring in Finite Variables
Informal description
For any finite type $\iota$ and commutative semiring $R$, the polynomial ring $\text{MvPolynomial}(\iota, R)$ in finitely many variables is finitely presented as an $R$-algebra.
Algebra.FinitePresentation.self instance
: FinitePresentation R R
Full source
/-- `R` is finitely presented as `R`-algebra. -/
instance self : FinitePresentation R R :=
  -- Porting note: replaced `PEmpty` with `Empty`
  equiv (MvPolynomial.isEmptyAlgEquiv R Empty)
A Commutative Semiring is Finitely Presented over Itself
Informal description
For any commutative semiring $R$, $R$ is finitely presented as an algebra over itself.
Algebra.FinitePresentation.quotient theorem
{I : Ideal A} (h : I.FG) [FinitePresentation R A] : FinitePresentation R (A ⧸ I)
Full source
/-- The quotient of a finitely presented algebra by a finitely generated ideal is finitely
presented. -/
protected theorem quotient {I : Ideal A} (h : I.FG) [FinitePresentation R A] :
    FinitePresentation R (A ⧸ I) where
  out := by
    obtain ⟨n, f, hf⟩ := FinitePresentation.out (R := R) (A := A)
    refine ⟨n, (Ideal.Quotient.mkₐ R I).comp f, ?_, ?_⟩
    · exact (Ideal.Quotient.mkₐ_surjective R I).comp hf.1
    · refine Ideal.fg_ker_comp _ _ hf.2 ?_ hf.1
      simp [h]
Quotient of Finitely Presented Algebra by Finitely Generated Ideal is Finitely Presented
Informal description
Let $A$ be a finitely presented algebra over a commutative semiring $R$, and let $I$ be a finitely generated ideal of $A$. Then the quotient algebra $A/I$ is also finitely presented over $R$.
Algebra.FinitePresentation.of_surjective theorem
{f : A →ₐ[R] B} (hf : Function.Surjective f) (hker : (RingHom.ker f.toRingHom).FG) [FinitePresentation R A] : FinitePresentation R B
Full source
/-- If `f : A →ₐ[R] B` is surjective with finitely generated kernel and `A` is finitely presented,
then so is `B`. -/
theorem of_surjective {f : A →ₐ[R] B} (hf : Function.Surjective f)
    (hker : (RingHom.ker f.toRingHom).FG)
    [FinitePresentation R A] : FinitePresentation R B :=
  letI : FinitePresentation R (A ⧸ RingHom.ker f) := FinitePresentation.quotient hker
  equiv (Ideal.quotientKerAlgEquivOfSurjective hf)
Finitely Presented Algebra via Surjective Homomorphism with Finitely Generated Kernel
Informal description
Let $R$ be a commutative semiring, and let $A$ and $B$ be $R$-algebras. Given a surjective $R$-algebra homomorphism $f \colon A \to B$ with finitely generated kernel, if $A$ is finitely presented as an $R$-algebra, then $B$ is also finitely presented as an $R$-algebra.
Algebra.FinitePresentation.iff theorem
: FinitePresentation R A ↔ ∃ (n : _) (I : Ideal (MvPolynomial (Fin n) R)) (_ : (_ ⧸ I) ≃ₐ[R] A), I.FG
Full source
theorem iff :
    FinitePresentationFinitePresentation R A ↔
      ∃ (n : _) (I : Ideal (MvPolynomial (Fin n) R)) (_ : (_ ⧸ I) ≃ₐ[R] A), I.FG := by
  constructor
  · rintro ⟨n, f, hf⟩
    exact ⟨n, RingHom.ker f.toRingHom, Ideal.quotientKerAlgEquivOfSurjective hf.1, hf.2⟩
  · rintro ⟨n, I, e, hfg⟩
    letI := (FinitePresentation.mvPolynomial R _).quotient hfg
    exact equiv e
Characterization of Finitely Presented Algebras via Polynomial Quotients
Informal description
An algebra $A$ over a commutative semiring $R$ is finitely presented if and only if there exists a natural number $n$, a finitely generated ideal $I$ of the polynomial ring $\text{MvPolynomial}(\text{Fin}(n), R)$, and an $R$-algebra isomorphism between the quotient $\text{MvPolynomial}(\text{Fin}(n), R)/I$ and $A$.
Algebra.FinitePresentation.iff_quotient_mvPolynomial' theorem
: FinitePresentation R A ↔ ∃ (ι : Type*) (_ : Fintype ι) (f : MvPolynomial ι R →ₐ[R] A), Surjective f ∧ (RingHom.ker f.toRingHom).FG
Full source
/-- An algebra is finitely presented if and only if it is a quotient of a polynomial ring whose
variables are indexed by a fintype by a finitely generated ideal. -/
theorem iff_quotient_mvPolynomial' :
    FinitePresentationFinitePresentation R A ↔
      ∃ (ι : Type*) (_ : Fintype ι) (f : MvPolynomial ι R →ₐ[R] A),
        Surjective f ∧ (RingHom.ker f.toRingHom).FG := by
  constructor
  · rintro ⟨n, f, hfs, hfk⟩
    set ulift_var := MvPolynomial.renameEquiv R Equiv.ulift
    refine
      ⟨ULift (Fin n), inferInstance, f.comp ulift_var.toAlgHom, hfs.comp ulift_var.surjective,
        Ideal.fg_ker_comp _ _ ?_ hfk ulift_var.surjective⟩
    simpa using Submodule.fg_bot
  · rintro ⟨ι, hfintype, f, hf⟩
    have equiv := MvPolynomial.renameEquiv R (Fintype.equivFin ι)
    use Fintype.card ι, f.comp equiv.symm, hf.1.comp (AlgEquiv.symm equiv).surjective
    refine Ideal.fg_ker_comp (S := MvPolynomial ι R) (A := A) _ f ?_ hf.2 equiv.symm.surjective
    simpa using Submodule.fg_bot
Characterization of Finitely Presented Algebras via Quotients of Multivariate Polynomial Rings
Informal description
An $R$-algebra $A$ is finitely presented if and only if there exists a finite type $\iota$ (i.e., $\iota$ is a fintype), a surjective $R$-algebra homomorphism $f \colon R[X_i]_{i \in \iota} \to A$, and the kernel of $f$ is finitely generated as an ideal.
Algebra.FinitePresentation.mvPolynomial_of_finitePresentation theorem
[FinitePresentation.{w₁, w₂} R A] (ι : Type v) [Finite ι] : FinitePresentation.{w₁, max v w₂} R (MvPolynomial ι A)
Full source
/-- If `A` is a finitely presented `R`-algebra, then `MvPolynomial (Fin n) A` is finitely presented
as `R`-algebra. -/
theorem mvPolynomial_of_finitePresentation [FinitePresentation.{w₁, w₂} R A]
    (ι : Type v) [Finite ι] :
    FinitePresentation.{w₁, max v w₂} R (MvPolynomial ι A) := by
  have hfp : FinitePresentation.{w₁, w₂} R A := inferInstance
  rw [iff_quotient_mvPolynomial'] at hfp ⊢
  classical
  -- Porting note: use the same universe level
  obtain ⟨(ι' : Type v), _, f, hf_surj, hf_ker⟩ := hfp
  let g := (MvPolynomial.mapAlgHom f).comp (MvPolynomial.sumAlgEquiv R ι ι').toAlgHom
  cases nonempty_fintype (ι ⊕ ι')
  refine
    ⟨ι ⊕ ι', by infer_instance, g,
      (MvPolynomial.map_surjective f.toRingHom hf_surj).comp (AlgEquiv.surjective _),
      Ideal.fg_ker_comp _ _ ?_ ?_ (AlgEquiv.surjective _)⟩
  · rw [AlgEquiv.toAlgHom_eq_coe, AlgEquiv.toAlgHom_toRingHom, AlgHom.ker_coe_equiv]
    exact Submodule.fg_bot
  · rw [AlgHom.toRingHom_eq_coe, MvPolynomial.mapAlgHom_coe_ringHom, MvPolynomial.ker_map]
    exact hf_ker.map MvPolynomial.C
Finitely Presented Multivariate Polynomial Algebra over Finitely Presented Base
Informal description
Let $R$ be a commutative semiring and $A$ a finitely presented $R$-algebra. For any finite type $\iota$, the algebra of multivariate polynomials $\text{MvPolynomial}(\iota, A)$ is finitely presented as an $R$-algebra.
Algebra.FinitePresentation.trans theorem
[Algebra A B] [IsScalarTower R A B] [FinitePresentation R A] [FinitePresentation A B] : FinitePresentation R B
Full source
/-- If `A` is an `R`-algebra and `S` is an `A`-algebra, both finitely presented, then `S` is
  finitely presented as `R`-algebra. -/
theorem trans [Algebra A B] [IsScalarTower R A B] [FinitePresentation R A]
    [FinitePresentation A B] : FinitePresentation R B := by
  have hfpB : FinitePresentation A B := inferInstance
  obtain ⟨n, I, e, hfg⟩ := iff.1 hfpB
  letI : FinitePresentation R (MvPolynomialMvPolynomial (Fin n) A ⧸ I) :=
    (mvPolynomial_of_finitePresentation _).quotient hfg
  exact equiv (e.restrictScalars R)
Transitivity of Finite Presentation for Algebras
Informal description
Let $R$ be a commutative semiring, $A$ an $R$-algebra, and $B$ an $A$-algebra such that the scalar multiplication is compatible (i.e., $[IsScalarTower R A B]$). If $A$ is finitely presented as an $R$-algebra and $B$ is finitely presented as an $A$-algebra, then $B$ is finitely presented as an $R$-algebra.
Algebra.FinitePresentation.of_restrict_scalars_finitePresentation theorem
[Algebra A B] [IsScalarTower R A B] [FinitePresentation.{w₁, w₃} R B] [FiniteType R A] : FinitePresentation.{w₂, w₃} A B
Full source
@[stacks 0561]
theorem of_restrict_scalars_finitePresentation [Algebra A B] [IsScalarTower R A B]
    [FinitePresentation.{w₁, w₃} R B] [FiniteType R A] :
    FinitePresentation.{w₂, w₃} A B := by
  classical
  obtain ⟨n, f, hf, s, hs⟩ := FinitePresentation.out (R := R) (A := B)
  letI RX := MvPolynomial (Fin n) R
  letI AX := MvPolynomial (Fin n) A
  refine ⟨n, MvPolynomial.aeval (f ∘ X), ?_, ?_⟩
  · rw [← AlgHom.range_eq_top, ← Algebra.adjoin_range_eq_range_aeval,
      Set.range_comp f MvPolynomial.X, eq_top_iff, ← @adjoin_adjoin_of_tower R A B,
      adjoin_image, adjoin_range_X, Algebra.map_top, (AlgHom.range_eq_top _).mpr hf]
    exact fun {x} => subset_adjoin ⟨⟩
  · obtain ⟨t, ht⟩ := FiniteType.out (R := R) (A := A)
    have := fun i : t => hf (algebraMap A B i)
    choose t' ht' using this
    have ht'' : Algebra.adjoin R (algebraMapalgebraMap A AX '' talgebraMap A AX '' t ∪ Set.range (X : _ → AX)) =  := by
      rw [adjoin_union_eq_adjoin_adjoin, ← Subalgebra.restrictScalars_top R (A := AX)
        (S := { x // x ∈ adjoin R ((algebraMap A AX) '' t) })]
      refine congrArg (Subalgebra.restrictScalars R) ?_
      rw [adjoin_algebraMap, ht]
      apply Subalgebra.restrictScalars_injective R
      rw [← adjoin_restrictScalars, adjoin_range_X, Subalgebra.restrictScalars_top,
        Subalgebra.restrictScalars_top]
    letI g : t → AX := fun x => MvPolynomial.C (x : A) - map (algebraMap R A) (t' x)
    refine ⟨s.image (map (algebraMap R A)) ∪ t.attach.image g, ?_⟩
    rw [Finset.coe_union, Finset.coe_image, Finset.coe_image, Finset.attach_eq_univ,
      Finset.coe_univ, Set.image_univ]
    let s₀ := (MvPolynomial.map (algebraMap R A)) '' s(MvPolynomial.map (algebraMap R A)) '' s ∪ Set.range g
    let I := RingHom.ker (MvPolynomial.aeval (R := A) (f ∘ MvPolynomial.X))
    change Ideal.span s₀ = I
    have leI : Ideal.span ((MvPolynomial.map (algebraMap R A)) '' s(MvPolynomial.map (algebraMap R A)) '' s ∪ Set.range g) ≤
      RingHom.ker (MvPolynomial.aeval (R := A) (f ∘ MvPolynomial.X)) := by
      rw [Ideal.span_le]
      rintro _ (⟨x, hx, rfl⟩ | ⟨⟨x, hx⟩, rfl⟩) <;>
      rw [SetLike.mem_coe, RingHom.mem_ker]
      · rw [MvPolynomial.aeval_map_algebraMap (R := R) (A := A), ← aeval_unique]
        have := Ideal.subset_span hx
        rwa [hs] at this
      · rw [map_sub, MvPolynomial.aeval_map_algebraMap, ← aeval_unique,
          MvPolynomial.aeval_C, ht', Subtype.coe_mk, sub_self]
    apply leI.antisymm
    intro x hx
    rw [RingHom.mem_ker] at hx
    let s₀ := (MvPolynomial.map (algebraMap R A)) '' ↑s(MvPolynomial.map (algebraMap R A)) '' ↑s ∪ Set.range g
    change x ∈ Ideal.span s₀
    have : x ∈ (MvPolynomial.map (algebraMap R A) : _ →+* AX).range.toAddSubmonoid ⊔
      (Ideal.span s₀).toAddSubmonoid := by
      have : x ∈ (⊤ : Subalgebra R AX) := trivial
      rw [← ht''] at this
      refine adjoin_induction ?_ ?_ ?_ ?_ this
      · rintro _ (⟨x, hx, rfl⟩ | ⟨i, rfl⟩)
        · rw [MvPolynomial.algebraMap_eq, ← sub_add_cancel (MvPolynomial.C x)
            (map (algebraMap R A) (t' ⟨x, hx⟩)), add_comm]
          apply AddSubmonoid.add_mem_sup
          · exact Set.mem_range_self _
          · apply Ideal.subset_span
            apply Set.mem_union_right
            exact Set.mem_range_self _
        · apply AddSubmonoid.mem_sup_left
          exact ⟨X i, map_X _ _⟩
      · intro r
        apply AddSubmonoid.mem_sup_left
        exact ⟨C r, map_C _ _⟩
      · intro _ _ _ _ h₁ h₂
        exact add_mem h₁ h₂
      · intro x₁ x₂ _ _ h₁ h₂
        obtain ⟨_, ⟨p₁, rfl⟩, q₁, hq₁, rfl⟩ := AddSubmonoid.mem_sup.mp h₁
        obtain ⟨_, ⟨p₂, rfl⟩, q₂, hq₂, rfl⟩ := AddSubmonoid.mem_sup.mp h₂
        rw [add_mul, mul_add, add_assoc, ← map_mul]
        apply AddSubmonoid.add_mem_sup
        · exact Set.mem_range_self _
        · refine add_mem (Ideal.mul_mem_left _ _ hq₂) (Ideal.mul_mem_right _ _ hq₁)
    obtain ⟨_, ⟨p, rfl⟩, q, hq, rfl⟩ := AddSubmonoid.mem_sup.mp this
    rw [map_add, aeval_map_algebraMap, ← aeval_unique, show MvPolynomial.aeval (f ∘ X) q = 0
      from leI hq, add_zero] at hx
    suffices Ideal.span (s : Set RX) ≤ (Ideal.span s₀).comap (MvPolynomial.map <| algebraMap R A) by
      refine add_mem ?_ hq
      rw [hs] at this
      exact this hx
    rw [Ideal.span_le]
    intro x hx
    apply Ideal.subset_span
    apply Set.mem_union_left
    exact Set.mem_image_of_mem _ hx
Finitely presented algebra under scalar restriction
Informal description
Let $R$ be a commutative semiring, $A$ a $R$-algebra, and $B$ an $A$-algebra such that the scalar multiplication is compatible (i.e., $[IsScalarTower R A B]$). If $B$ is finitely presented as an $R$-algebra and $A$ is finitely generated as an $R$-algebra, then $B$ is finitely presented as an $A$-algebra.
Algebra.FinitePresentation.ker_fg_of_mvPolynomial theorem
{n : ℕ} (f : MvPolynomial (Fin n) R →ₐ[R] A) (hf : Function.Surjective f) [FinitePresentation R A] : (RingHom.ker f.toRingHom).FG
Full source
/-- This is used to prove the strictly stronger `ker_fg_of_surjective`. Use it instead. -/
theorem ker_fg_of_mvPolynomial {n : } (f : MvPolynomialMvPolynomial (Fin n) R →ₐ[R] A)
    (hf : Function.Surjective f) [FinitePresentation R A] : (RingHom.ker f.toRingHom).FG := by
  classical
    obtain ⟨m, f', hf', s, hs⟩ := FinitePresentation.out (R := R) (A := A)
    let RXn := MvPolynomial (Fin n) R
    let RXm := MvPolynomial (Fin m) R
    have := fun i : Fin n => hf' (f <| X i)
    choose g hg using this
    have := fun i : Fin m => hf (f' <| X i)
    choose h hh using this
    let aeval_h : RXm →ₐ[R] RXn := aeval h
    let g' : Fin n → RXn := fun i => X i - aeval_h (g i)
    refine ⟨Finset.univ.image g' ∪ s.image aeval_h, ?_⟩
    simp only [Finset.coe_image, Finset.coe_union, Finset.coe_univ, Set.image_univ]
    have hh' : ∀ x, f (aeval_h x) = f' x := by
      intro x
      rw [← f.coe_toRingHom, map_aeval]
      simp_rw [AlgHom.coe_toRingHom, hh]
      rw [AlgHom.comp_algebraMap, ← aeval_eq_eval₂Hom,
        -- Porting note: added line below
        ← funext fun i => Function.comp_apply (f := ↑f') (g := MvPolynomial.X),
        ← aeval_unique]
    let s' := Set.rangeSet.range g' ∪ aeval_h '' s
    have leI : Ideal.span s' ≤ RingHom.ker f.toRingHom := by
      rw [Ideal.span_le]
      rintro _ (⟨i, rfl⟩ | ⟨x, hx, rfl⟩)
      · change f (g' i) = 0
        rw [map_sub, ← hg, hh', sub_self]
      · change f (aeval_h x) = 0
        rw [hh']
        change x ∈ RingHom.ker f'.toRingHom
        rw [← hs]
        exact Ideal.subset_span hx
    apply leI.antisymm
    intro x hx
    have : x ∈ aeval_h.range.toAddSubmonoid ⊔ (Ideal.span s').toAddSubmonoid := by
      have : x ∈ adjoin R (Set.range X : Set RXn) := by
        rw [adjoin_range_X]
        trivial
      refine adjoin_induction ?_ ?_ ?_ ?_ this
      · rintro _ ⟨i, rfl⟩
        rw [← sub_add_cancel (X i) (aeval h (g i)), add_comm]
        apply AddSubmonoid.add_mem_sup
        · exact Set.mem_range_self _
        · apply Submodule.subset_span
          apply Set.mem_union_left
          exact Set.mem_range_self _
      · intro r
        apply AddSubmonoid.mem_sup_left
        exact ⟨C r, aeval_C _ _⟩
      · intro _ _ _ _ h₁ h₂
        exact add_mem h₁ h₂
      · intro p₁ p₂ _ _ h₁ h₂
        obtain ⟨_, ⟨x₁, rfl⟩, y₁, hy₁, rfl⟩ := AddSubmonoid.mem_sup.mp h₁
        obtain ⟨_, ⟨x₂, rfl⟩, y₂, hy₂, rfl⟩ := AddSubmonoid.mem_sup.mp h₂
        rw [mul_add, add_mul, add_assoc, ← map_mul]
        apply AddSubmonoid.add_mem_sup
        · exact Set.mem_range_self _
        · exact add_mem (Ideal.mul_mem_right _ _ hy₁) (Ideal.mul_mem_left _ _ hy₂)
    obtain ⟨_, ⟨x, rfl⟩, y, hy, rfl⟩ := AddSubmonoid.mem_sup.mp this
    refine add_mem ?_ hy
    simp only [RXn, RingHom.mem_ker, AlgHom.toRingHom_eq_coe, AlgHom.coe_toRingHom, map_add,
      show f y = 0 from leI hy, add_zero, hh'] at hx
    suffices Ideal.span (s : Set RXm) ≤ (Ideal.span s').comap aeval_h by
      apply this
      rwa [hs]
    rw [Ideal.span_le]
    intro x hx
    apply Submodule.subset_span
    apply Set.mem_union_right
    exact Set.mem_image_of_mem _ hx
Kernel of a surjective polynomial algebra map is finitely generated for finitely presented algebras
Informal description
Let $R$ be a commutative semiring and $A$ be a finitely presented $R$-algebra. For any natural number $n$ and any surjective $R$-algebra homomorphism $f \colon R[X_1, \dots, X_n] \to A$, the kernel of $f$ (as a ring homomorphism) is a finitely generated ideal.
Algebra.FinitePresentation.ker_fG_of_surjective theorem
(f : A →ₐ[R] B) (hf : Function.Surjective f) [FinitePresentation R A] [FinitePresentation R B] : (RingHom.ker f.toRingHom).FG
Full source
/-- If `f : A →ₐ[R] B` is a surjection between finitely-presented `R`-algebras, then the kernel of
`f` is finitely generated. -/
theorem ker_fG_of_surjective (f : A →ₐ[R] B) (hf : Function.Surjective f)
    [FinitePresentation R A] [FinitePresentation R B] : (RingHom.ker f.toRingHom).FG := by
  obtain ⟨n, g, hg, _⟩ := FinitePresentation.out (R := R) (A := A)
  convert (ker_fg_of_mvPolynomial (f.comp g) (hf.comp hg)).map g.toRingHom
  simp_rw [RingHom.ker_eq_comap_bot, AlgHom.toRingHom_eq_coe, AlgHom.comp_toRingHom]
  rw [← Ideal.comap_comap, Ideal.map_comap_of_surjective (g : MvPolynomialMvPolynomial (Fin n) R →+* A) hg]
Kernel of a surjective algebra homomorphism between finitely presented algebras is finitely generated
Informal description
Let $R$ be a commutative semiring, and let $A$ and $B$ be finitely presented $R$-algebras. For any surjective $R$-algebra homomorphism $f \colon A \to B$, the kernel of $f$ (as a ring homomorphism) is a finitely generated ideal.
RingHom.FinitePresentation definition
(f : A →+* B) : Prop
Full source
/-- A ring morphism `A →+* B` is of `RingHom.FinitePresentation` if `B` is finitely presented as
`A`-algebra. -/
@[algebraize]
def FinitePresentation (f : A →+* B) : Prop :=
  @Algebra.FinitePresentation A B _ _ f.toAlgebra
Finitely presented ring homomorphism
Informal description
A ring homomorphism $f \colon A \to B$ is said to be *finitely presented* if $B$ is finitely presented as an $A$-algebra via $f$. This means that $B$ is isomorphic to the quotient of a polynomial ring $A[X_1, \dots, X_n]$ by a finitely generated ideal.
RingHom.finitePresentation_algebraMap theorem
[Algebra A B] : (algebraMap A B).FinitePresentation ↔ Algebra.FinitePresentation A B
Full source
@[simp]
lemma finitePresentation_algebraMap [Algebra A B] :
    (algebraMap A B).FinitePresentation ↔ Algebra.FinitePresentation A B := by
  delta RingHom.FinitePresentation
  congr!
  exact Algebra.algebra_ext _ _ fun _ ↦ rfl
Finitely Presented Algebra Map iff Algebra is Finitely Presented
Informal description
Let $A$ and $B$ be rings with $B$ an $A$-algebra via the algebra map $\text{algebraMap} \colon A \to B$. Then the ring homomorphism $\text{algebraMap}$ is finitely presented if and only if the $A$-algebra $B$ is finitely presented.
RingHom.FiniteType.of_finitePresentation theorem
{f : A →+* B} (hf : f.FinitePresentation) : f.FiniteType
Full source
theorem of_finitePresentation {f : A →+* B} (hf : f.FinitePresentation) : f.FiniteType :=
  @Algebra.FiniteType.of_finitePresentation A B _ _ f.toAlgebra hf
Finitely presented ring homomorphisms are finitely generated
Informal description
Let $f \colon A \to B$ be a ring homomorphism. If $f$ is finitely presented, then $f$ is also finitely generated as an algebra homomorphism.
RingHom.FinitePresentation.id theorem
: FinitePresentation (RingHom.id A)
Full source
theorem id : FinitePresentation (RingHom.id A) :=
  Algebra.FinitePresentation.self A
Identity Ring Homomorphism is Finitely Presented
Informal description
The identity ring homomorphism $\mathrm{id}_A \colon A \to A$ is finitely presented.
RingHom.FinitePresentation.comp_surjective theorem
{f : A →+* B} {g : B →+* C} (hf : f.FinitePresentation) (hg : Surjective g) (hker : (RingHom.ker g).FG) : (g.comp f).FinitePresentation
Full source
theorem comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.FinitePresentation) (hg : Surjective g)
    (hker : (RingHom.ker g).FG) : (g.comp f).FinitePresentation := by
  algebraize [f, g.comp f]
  exact Algebra.FinitePresentation.of_surjective
    (f :=
      { g with
        toFun := g
        commutes' := fun _ => rfl })
    hg hker
Composition of Finitely Presented Ring Homomorphism with Surjective Homomorphism Having Finitely Generated Kernel is Finitely Presented
Informal description
Let $f \colon A \to B$ and $g \colon B \to C$ be ring homomorphisms. If $f$ is finitely presented, $g$ is surjective, and the kernel of $g$ is finitely generated, then the composition $g \circ f \colon A \to C$ is also finitely presented.
RingHom.FinitePresentation.of_surjective theorem
(f : A →+* B) (hf : Surjective f) (hker : (RingHom.ker f).FG) : f.FinitePresentation
Full source
theorem of_surjective (f : A →+* B) (hf : Surjective f) (hker : (RingHom.ker f).FG) :
    f.FinitePresentation := by
  rw [← f.comp_id]
  exact (id A).comp_surjective hf hker
Surjective Ring Homomorphism with Finitely Generated Kernel is Finitely Presented
Informal description
Let $f \colon A \to B$ be a surjective ring homomorphism with finitely generated kernel. Then $f$ is finitely presented.
RingHom.FinitePresentation.of_finiteType theorem
[IsNoetherianRing A] {f : A →+* B} : f.FiniteType ↔ f.FinitePresentation
Full source
theorem of_finiteType [IsNoetherianRing A] {f : A →+* B} : f.FiniteType ↔ f.FinitePresentation :=
  @Algebra.FinitePresentation.of_finiteType A B _ _ f.toAlgebra _
Equivalence of Finite Generation and Finite Presentation for Ring Homomorphisms over Noetherian Rings
Informal description
Let $A$ be a Noetherian ring and $f \colon A \to B$ a ring homomorphism. Then $f$ is finitely generated as an $A$-algebra if and only if it is finitely presented as an $A$-algebra.
RingHom.FinitePresentation.comp theorem
{g : B →+* C} {f : A →+* B} (hg : g.FinitePresentation) (hf : f.FinitePresentation) : (g.comp f).FinitePresentation
Full source
theorem comp {g : B →+* C} {f : A →+* B} (hg : g.FinitePresentation) (hf : f.FinitePresentation) :
    (g.comp f).FinitePresentation := by
  -- Porting note: specify `Algebra` instances to get `SMul`
  algebraize [f, g, g.comp f]
  exact Algebra.FinitePresentation.trans A B C
Composition of Finitely Presented Ring Homomorphisms is Finitely Presented
Informal description
Let $f \colon A \to B$ and $g \colon B \to C$ be ring homomorphisms. If $f$ and $g$ are both finitely presented, then their composition $g \circ f \colon A \to C$ is also finitely presented.
RingHom.FinitePresentation.of_comp_finiteType theorem
(f : A →+* B) {g : B →+* C} (hg : (g.comp f).FinitePresentation) (hf : f.FiniteType) : g.FinitePresentation
Full source
theorem of_comp_finiteType (f : A →+* B) {g : B →+* C} (hg : (g.comp f).FinitePresentation)
    (hf : f.FiniteType) : g.FinitePresentation := by
  -- Porting note: need to specify some instances
  algebraize [f, g, g.comp f]
  exact Algebra.FinitePresentation.of_restrict_scalars_finitePresentation A B C
Finitely presentedness via composition with finitely generated homomorphism
Informal description
Let $f \colon A \to B$ and $g \colon B \to C$ be ring homomorphisms. If the composition $g \circ f \colon A \to C$ is finitely presented and $f$ is finitely generated as an $A$-algebra, then $g$ is finitely presented.
RingHom.FinitePresentation.polynomial_induction theorem
(P : ∀ (R : Type u) [CommRing R] (S : Type u) [CommRing S], (R →+* S) → Prop) (Q : ∀ (R : Type u) [CommRing R] (S : Type v) [CommRing S], (R →+* S) → Prop) (polynomial : ∀ (R) [CommRing R], P R R[X] C) (fg_ker : ∀ (R : Type u) [CommRing R] (S : Type v) [CommRing S] (f : R →+* S), Surjective f → (ker f).FG → Q R S f) (comp : ∀ (R) [CommRing R] (S) [CommRing S] (T) [CommRing T] (f : R →+* S) (g : S →+* T), P R S f → Q S T g → Q R T (g.comp f)) {R : Type u} {S : Type v} [CommRing R] [CommRing S] (f : R →+* S) (hf : f.FinitePresentation) : Q R S f
Full source
/-- Induction principle for finitely presented ring homomorphisms.

For a property to hold for all finitely presented ring homs, it suffices for it to hold for
`Polynomial.C : R → R[X]`, surjective ring homs with finitely generated kernels, and to be closed
under composition.

Note that to state this conveniently for ring homs between rings of different universes, we carry
around two predicates `P` and `Q`, which should be "the same" apart from universes:
* `P`, for ring homs `(R : Type u) → (S : Type u)`.
* `Q`, for ring homs `(R : Type u) → (S : Type v)`.
-/
lemma polynomial_induction
    (P : ∀ (R : Type u) [CommRing R] (S : Type u) [CommRing S], (R →+* S) → Prop)
    (Q : ∀ (R : Type u) [CommRing R] (S : Type v) [CommRing S], (R →+* S) → Prop)
    (polynomial : ∀ (R) [CommRing R], P R R[X] C)
    (fg_ker : ∀ (R : Type u) [CommRing R] (S : Type v) [CommRing S] (f : R →+* S),
      Surjective f → (ker f).FG → Q R S f)
    (comp : ∀ (R) [CommRing R] (S) [CommRing S] (T) [CommRing T] (f : R →+* S) (g : S →+* T),
      P R S f → Q S T g → Q R T (g.comp f))
    {R : Type u} {S : Type v} [CommRing R] [CommRing S] (f : R →+* S) (hf : f.FinitePresentation) :
    Q R S f := by
  letI := f.toAlgebra
  obtain ⟨n, g, hg, hg'⟩ := hf
  let g' := g.toRingHom
  change Surjective g' at hg
  change (ker g').FG at hg'
  have : g'.comp MvPolynomial.C = f := g.comp_algebraMap
  clear_value g'
  subst this
  clear g
  induction n generalizing R S with
  | zero =>
    refine fg_ker _ _ _ (hg.comp (MvPolynomial.C_surjective (Fin 0))) ?_
    rw [← comap_ker]
    convert hg'.map (MvPolynomial.isEmptyRingEquiv R (Fin 0)).toRingHom using 1
    simp only [RingEquiv.toRingHom_eq_coe]
    exact Ideal.comap_symm (MvPolynomial.isEmptyRingEquiv R (Fin 0))
  | succ n IH =>
    let e : MvPolynomialMvPolynomial (Fin (n + 1)) R ≃ₐ[R] MvPolynomial (Fin n) R[X] :=
      (MvPolynomial.renameEquiv R (finSuccEquiv n)).trans (MvPolynomial.optionEquivRight R (Fin n))
    have he : (ker (g'.comp <| RingHomClass.toRingHom e.symm)).FG := by
      rw [← RingHom.comap_ker]
      convert hg'.map e.toAlgHom.toRingHom using 1
      exact Ideal.comap_symm e.toRingEquiv
    have := IH (R := R[X]) (S := S) (g'.comp e.symm) (hg.comp e.symm.surjective) he
    convert comp _ _ _ _ _ (polynomial _) this using 1
    rw [comp_assoc, comp_assoc]
    congr 1 with r
    simp [e]
Induction Principle for Finitely Presented Ring Homomorphisms
Informal description
Let $P$ and $Q$ be predicates on ring homomorphisms, where $P$ applies to homomorphisms between rings in the same universe and $Q$ applies to homomorphisms between rings in possibly different universes. Suppose the following conditions hold: 1. For any commutative ring $R$, the polynomial ring homomorphism $C \colon R \to R[X]$ satisfies $P$. 2. For any surjective ring homomorphism $f \colon R \to S$ with finitely generated kernel, $Q$ holds for $f$. 3. For any ring homomorphisms $f \colon R \to S$ and $g \colon S \to T$, if $P$ holds for $f$ and $Q$ holds for $g$, then $Q$ holds for their composition $g \circ f$. Then, for any finitely presented ring homomorphism $f \colon R \to S$, the predicate $Q$ holds for $f$.
AlgHom.FinitePresentation definition
(f : A →ₐ[R] B) : Prop
Full source
/-- An algebra morphism `A →ₐ[R] B` is of `AlgHom.FinitePresentation` if it is of finite
presentation as ring morphism. In other words, if `B` is finitely presented as `A`-algebra. -/
def FinitePresentation (f : A →ₐ[R] B) : Prop :=
  f.toRingHom.FinitePresentation
Finitely presented algebra homomorphism
Informal description
An algebra homomorphism $f \colon A \to B$ over a base ring $R$ is said to be *finitely presented* if the corresponding ring homomorphism is finitely presented, meaning that $B$ is isomorphic to the quotient of a polynomial ring $A[X_1, \dots, X_n]$ by a finitely generated ideal.
AlgHom.FiniteType.of_finitePresentation theorem
{f : A →ₐ[R] B} (hf : f.FinitePresentation) : f.FiniteType
Full source
theorem of_finitePresentation {f : A →ₐ[R] B} (hf : f.FinitePresentation) : f.FiniteType :=
  RingHom.FiniteType.of_finitePresentation hf
Finitely presented algebra homomorphisms are finitely generated
Informal description
Let $R$ be a commutative ring, and let $A$ and $B$ be $R$-algebras. Given an algebra homomorphism $f \colon A \to B$ that is finitely presented (i.e., $B$ is isomorphic to a quotient of a polynomial ring $A[X_1, \dots, X_n]$ by a finitely generated ideal), then $f$ is also finitely generated as an algebra homomorphism (i.e., $B$ is finitely generated as an $A$-algebra).
AlgHom.FinitePresentation.id theorem
: FinitePresentation (AlgHom.id R A)
Full source
theorem id : FinitePresentation (AlgHom.id R A) :=
  RingHom.FinitePresentation.id A
Identity Algebra Homomorphism is Finitely Presented
Informal description
The identity algebra homomorphism $\mathrm{id}_A \colon A \to A$ over a base ring $R$ is finitely presented.
AlgHom.FinitePresentation.comp theorem
{g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.FinitePresentation) (hf : f.FinitePresentation) : (g.comp f).FinitePresentation
Full source
theorem comp {g : B →ₐ[R] C} {f : A →ₐ[R] B} (hg : g.FinitePresentation)
    (hf : f.FinitePresentation) : (g.comp f).FinitePresentation :=
  RingHom.FinitePresentation.comp hg hf
Composition of Finitely Presented Algebra Homomorphisms is Finitely Presented
Informal description
Let $R$ be a commutative ring, and let $A$, $B$, and $C$ be $R$-algebras. Given algebra homomorphisms $f \colon A \to B$ and $g \colon B \to C$ that are both finitely presented, their composition $g \circ f \colon A \to C$ is also finitely presented.
AlgHom.FinitePresentation.comp_surjective theorem
{f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.FinitePresentation) (hg : Surjective g) (hker : (RingHom.ker g.toRingHom).FG) : (g.comp f).FinitePresentation
Full source
theorem comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.FinitePresentation)
    (hg : Surjective g) (hker : (RingHom.ker g.toRingHom).FG) : (g.comp f).FinitePresentation :=
  RingHom.FinitePresentation.comp_surjective hf hg hker
Composition of Finitely Presented Algebra Homomorphism with Surjective Homomorphism Having Finitely Generated Kernel is Finitely Presented
Informal description
Let $f \colon A \to B$ and $g \colon B \to C$ be algebra homomorphisms over a base ring $R$. If $f$ is finitely presented, $g$ is surjective, and the kernel of the underlying ring homomorphism of $g$ is finitely generated, then the composition $g \circ f \colon A \to C$ is also finitely presented.
AlgHom.FinitePresentation.of_surjective theorem
(f : A →ₐ[R] B) (hf : Surjective f) (hker : (RingHom.ker f.toRingHom).FG) : f.FinitePresentation
Full source
theorem of_surjective (f : A →ₐ[R] B) (hf : Surjective f) (hker : (RingHom.ker f.toRingHom).FG) :
    f.FinitePresentation := by
  -- Porting note: added `convert`
  convert RingHom.FinitePresentation.of_surjective f hf hker
Surjective algebra homomorphism with finitely generated kernel is finitely presented
Informal description
Let $f \colon A \to B$ be a surjective algebra homomorphism over a base ring $R$. If the kernel of the underlying ring homomorphism of $f$ is finitely generated, then $f$ is finitely presented.
AlgHom.FinitePresentation.of_finiteType theorem
[IsNoetherianRing A] {f : A →ₐ[R] B} : f.FiniteType ↔ f.FinitePresentation
Full source
theorem of_finiteType [IsNoetherianRing A] {f : A →ₐ[R] B} : f.FiniteType ↔ f.FinitePresentation :=
  RingHom.FinitePresentation.of_finiteType
Equivalence of Finite Generation and Finite Presentation for Algebra Homomorphisms over Noetherian Rings
Informal description
Let $A$ be a Noetherian ring and $f \colon A \to B$ an algebra homomorphism over a base ring $R$. Then $f$ is finitely generated as an $R$-algebra if and only if it is finitely presented as an $R$-algebra.
AlgHom.FinitePresentation.of_comp_finiteType theorem
(f : A →ₐ[R] B) {g : B →ₐ[R] C} (h : (g.comp f).FinitePresentation) (h' : f.FiniteType) : g.FinitePresentation
Full source
nonrec theorem of_comp_finiteType (f : A →ₐ[R] B) {g : B →ₐ[R] C}
    (h : (g.comp f).FinitePresentation) (h' : f.FiniteType) : g.FinitePresentation :=
  h.of_comp_finiteType _ h'
Finitely presentedness of algebra homomorphism via composition with finitely generated homomorphism
Informal description
Let $f \colon A \to B$ and $g \colon B \to C$ be algebra homomorphisms over a base ring $R$. If the composition $g \circ f \colon A \to C$ is finitely presented and $f$ is finitely generated as an $R$-algebra, then $g$ is finitely presented.