Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/RingTheory/OrderOfVanishing/     Datei vom 15.10.2026 mit Größe 12 kB image not shown  

Quelle  Basic.lean   Sprache: Lean

 

/-
Copyright (c) 2025 Raphael Douglas Giles. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Raphael Douglas Giles
-/

module

public import Mathlib.RingTheory.HopkinsLevitzki
public import Mathlib.RingTheory.Length

import Mathlib.Algebra.Ring.Hom.InjSurj
import Mathlib.RingTheory.Ideal.Quotient.Noetherian
import Mathlib.RingTheory.KrullDimension.NonZeroDivisors

/-!
# Order of vanishing

This file defines the order of vanishing of an element of a ring as the length of the quotient of
the ring by the ideal generated by that element. We also define the extension of this notion to the
field of fractions
-/


@[expose] public section

open LinearMap Pointwise IsLocalization Ideal WithZero

variable {R : Type*} {M : Type*} [AddCommMonoid M]

namespace Ring

variable (R) [Ring R]
/--
Order of vanishing function for elements of a ring.
-/

@[stacks 02MD]
noncomputable
def ord (x : R) : ℕ∞ := Module.length R (R ⧸ Ideal.span {x})

@[simp]
lemma ord_one : ord R 1 = 0 := by
  simp_all [ord,
    Ideal.span_singleton_one, Submodule.Quotient.subsingleton_iff]

end Ring

variable [CommRing R] [Module R M]

/--
The map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a`
-/

def Ideal.mulQuot (a : R) (I : Ideal R) :
    R ⧸ I →ₗ[R] R ⧸ (a • I) :=
  Submodule.mapQ _ _ (LinearMap.mul R R a) (Submodule.le_comap_map _ _)

/--
The map `R ⧸ I →ₗ[R] R ⧸ (a • I)` defined by multiplication by `a` is injective if `a` is
a nonzero divisor.
-/

lemma Ideal.mulQuot_injective {a : R} (I : Ideal R) (ha : a ∈ nonZeroDivisors R) :
    Function.Injective (Ideal.mulQuot a I) := by
  simp only [mulQuot, Submodule.mapQ, ← ker_eq_bot]
  apply Submodule.ker_liftQ_eq_bot'
  apply le_antisymm
  · have : Submodule.map (mul R R a) I = a • I := rfl
    rw [le_ker_iff_map, Submodule.map_comp, this, Submodule.mkQ_map_self]
  · have m : I = Submodule.comap (mul R R a) (a • I) := by
      ext b
      exact (Submodule.mul_mem_smul_iff ha).symm
    simp [← m, ker_comp]

/--
The quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})`.
-/

def Ideal.quotOfMul (a : R) (I : Ideal R) :
    (R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a}) :=
  Submodule.factor <| Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I

/--
The quotient map `(R ⧸ a • I) →ₗ[R] (R ⧸ Ideal.span {a})` is surjective.
-/

lemma Ideal.quotOfMul_surjective {a : R} (I : Ideal R) :
    Function.Surjective (Ideal.quotOfMul a I) := by
  simp only [Ideal.quotOfMul]
  exact Submodule.factor_surjective <|
    Submodule.singleton_set_smul I a ▸ Submodule.smul_le_span {a} I

set_option backward.isDefEq.respectTransparency.types false in
/--
The sequence `R ⧸ I →ₗ[R] R ⧸ (a • I) →ₗ[R] R ⧸ (Ideal.span {a})` given by multiplication
by `a` then quotienting by the ideal generated by `a` is exact.
-/

lemma Ideal.exact_mulQuot_quotOfMul {a : R} (I : Ideal R) :
    Function.Exact (Ideal.mulQuot a I) (Ideal.quotOfMul a I) := by
  simp only [exact_iff]
  have : ker (Ideal.quotOfMul a I) = a • ⊤ := by
    simp only [← submodule_span_eq, quotOfMul, Submodule.factor, Submodule.mapQ, comp_id,
      Submodule.ker_liftQ, Submodule.ker_mkQ, Submodule.map_span, Submodule.mkQ_apply,
      Quotient.mk_eq_mk, Set.image_singleton, Quotient.smul_top]
  simp [this, Ideal.mulQuot, Submodule.mapQ.eq_1, Submodule.range_liftQ,
    range_comp, Ideal.Quotient.smul_top, ← Ideal.submodule_span_eq, LinearMap.map_span]

namespace Ring
variable (R)
/--
The order of vanishing of `a * b` is the order of vanishing of `a` plus the order
of vanishing of `b`.
-/

theorem ord_mul {a b : R} (hb : b ∈ nonZeroDivisors R) :
    ord R (a * b) = ord R a + ord R b := by
  have := Module.length_eq_add_of_exact (Ideal.mulQuot b (Ideal.span {a}))
          (Ideal.quotOfMul b (Ideal.span {a})) (Ideal.mulQuot_injective (Ideal.span {a}) hb)
          (Ideal.quotOfMul_surjective (Ideal.span {a}))
          (Ideal.exact_mulQuot_quotOfMul (Ideal.span {a}))
  simp only [Ring.ord, ← this]
  have lem : (({b} : Set R) • Ideal.span {a}) = Ideal.span {b * a} := by
    simp [← Ideal.submodule_span_eq, Submodule.set_smul_span]
  have : (({b} : Set R) • Ideal.span {a}) = b • Ideal.span {a} := Submodule.singleton_set_smul
    (Ideal.span {a}) b
  rw [this] at lem
  rw [lem, mul_comm]

/--
Variation of `ord_mul` where the user has to show the first input is a non
zero divisor rather than the second.
-/

lemma ord_mul' {a b : R} (ha : a ∈ nonZeroDivisors R) :
    ord R (a * b) = ord R a + ord R b := by
  rw [mul_comm, ord_mul R ha, add_comm]

/--
The order of zero is `Module.length R R`. Use this when it is necessary to unfold the definition
of `ord` to avoid annoyances of working with `R ⧸ Ideal.span {0}` instead of `R`.
-/

lemma ord_zero : ord R 0 = Module.length R R := by
  simp only [ord]
  let m := (Submodule.quotEquivOfEqBot (Ideal.span {0} : Submodule R R) (span_singleton_zero))
  exact le_antisymm (Module.length_le_of_injective m m.injective)
      (Module.length_le_of_surjective m m.surjective)

variable {R}
/--
For `x : R` a non zero divisor, `ord R (x ^ n) = n • ord R x`.
-/

@[simp]
theorem ord_pow {x : R} (hx : x ∈ nonZeroDivisors R) (n : ℕ) : ord R (x ^ n) = n • ord R x := by
  induction n with
  | zero => simp
  | succ n ih =>
    rw [pow_succ, ord_mul, ih, succ_nsmul]
    exact hx

@[simp]
lemma ord_mul_of_isUnit_left {a : R} (h : IsUnit a) (x : R) : ord R (a * x) = ord R x := by
  rw [ord, ord, Ideal.span_singleton_mul_left_unit h x]

@[simp]
lemma ord_mul_of_isUnit_right {a : R} (h : IsUnit a) (x : R) : ord R (x * a) = ord R x := by
  rw [ord, ord, Ideal.span_singleton_mul_right_unit h x]

lemma ord_eq_of_associated {x y : R} (h : Associated x y) : ord R x = ord R y := by
  obtain ⟨a, rfl⟩ := h
  simp

@[simp]
lemma ord_neg (x : R) : ord R (-x) = ord R x := by
    simp [ord_eq_of_associated (x := -x) (y := x) (by simp)]

/--
In an `S` algebra `R`, the order of vanishing of `x : R` is equal to the order of vanishing
of `a • x` for `a` a unit in `S`.
-/

@[simp]
lemma ord_smul_of_isUnit {S : Type*} [CommRing S] [Algebra S R]
    {a : S} (h : IsUnit a) (x : R) : ord R (a • x) = ord R x := by
  rw [Algebra.smul_def a x]
  exact ord_mul_of_isUnit_left (RingHom.isUnit_map (algebraMap S R) h) x

/-
Note that the order here is the order on `ℕ∞` where `∞` is a top element, rather than the order on
`ℤᵐ⁰` which also comes up when working with orders of vanishing.
-/

lemma ord_le_ord_mul (a : R) (x : R) : ord R x ≤ ord R (a * x) := by
  simp only [ord]
  suffices Ideal.span {a * x} ≤ Ideal.span {x} by
    let g : (R ⧸ Ideal.span {a * x}) →ₗ[R] (R ⧸ Ideal.span {x}) := Submodule.factor this
    refine Module.length_le_of_surjective (Submodule.factor this) (Submodule.factor_surjective this)
  rw [Ideal.span_singleton_le_span_singleton]
  exact Dvd.intro_left (algebraMap R R a) rfl

lemma ord_le_ord_of_dvd {a x : R} (h : a ∣ x) : ord R a ≤ ord R x := by
  obtain ⟨b, rfl⟩ := h
  rw [mul_comm]
  exact ord_le_ord_mul b a

/--
In an `S` algebra `R`, the order of vanishing of `x : R` is less than or equal
to the order of vanishing of `a • x` for any `a : S`. One should note that the order here
is the order on `ℕ∞` where `∞` is a top element.
-/

lemma ord_le_smul {S : Type*} [CommRing S] [Algebra S R] (a : S) (x : R) :
    ord R x ≤ ord R (a • x) := by simp [Algebra.smul_def, ord_le_ord_mul]

/--
The order of vanishing of a unit is `0`.
-/

@[simp]
lemma ord_of_isUnit {x : R} (hx : IsUnit x) : ord R x = 0 := by
  simpa using ord_smul_of_isUnit hx (1 : R)

section IsPrincipalIdealRing

variable [IsPrincipalIdealRing R]

/--
In a principal ideal ring, the order of vanishing of an irreducible element is `1`.
-/

theorem ord_of_irreducible {ϖ : R} (hϖ : Irreducible ϖ) : ord R ϖ = 1 := by
  rw [Ring.ord, Module.length_eq_one_iff]
  have : (Ideal.span {ϖ}).IsMaximal :=
    PrincipalIdealRing.isMaximal_of_irreducible hϖ
  rw [isSimpleModule_iff_isSimpleModule_of_algebraMap_surjective (S := R ⧸ Ideal.span {ϖ})
    Ideal.Quotient.mk_surjective]
  let := Ideal.Quotient.field (Ideal.span {ϖ})
  exact instIsSimpleModule _

end IsPrincipalIdealRing

variable (R)

open scoped Classical in
/--
Zero-preserving monoid homomorphism from a nontrivial commutative ring `R` to `ℤᵐ⁰`.

Note that we cannot just use `fun x ↦ ord R x` without further assumptions on `R`.
This is because if R is finite length, then ord R 0 will be some non-top value,
meaning in this case `0` will not be mapped to `⊤`.
-/

@[stacks 02MD]
noncomputable
def ordMonoidWithZeroHom [Nontrivial R] : R →*₀ ℤᵐ⁰ where
  toFun x := if x ∈ nonZeroDivisors R
             then (ENat.recTopCoe 0 (WithZero.coe <| Multiplicative.ofAdd ·) (Ring.ord R x))
             else 0
  map_zero' := by simp [nonZeroDivisors, exists_ne]
  map_one' := by simp [nonZeroDivisors]
  map_mul' := by
    intro x y
    split_ifs with _ _ b
    · rw [ord_mul _ b]
      generalize ord R x = x'
      generalize ord R y = y'
      cases x' <;> cases y'
      on_goal 4 =>
        simp only [← ENat.natCast_add, ENat.recTopCoe_natCast, Nat.cast_add (R := ℤ),
          ofAdd_add, WithZero.coe_mul]
      all_goals simp
    all_goals simp_all [mul_mem_nonZeroDivisors]

lemma ordMonoidWithZeroHom_eq_zero_iff [Nontrivial R] (y : nonZeroDivisors R) :
    ordMonoidWithZeroHom R y = 0 ↔ ord R y = ⊤ := by
  simp only [ordMonoidWithZeroHom, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, SetLike.coe_mem,
    ↓reduceIte]
  generalize ord R y = k
  cases k
  all_goals simp

variable {R} in
/--
If `x` is a non zero divisor, `ordMonoidWithZeroHom` is equal to the canonical embedding
of `Ring.ord R x` into `WithZero (Multiplicative ℤ)`.
-/

theorem ordMonoidWithZeroHom_eq_ord [Nontrivial R] {x : R} (h : x ∈ nonZeroDivisors R) :
    ordMonoidWithZeroHom R x =
  (ENat.recTopCoe 0 (WithZero.coe <| Multiplicative.ofAdd ·) (Ring.ord R x)) := dite_eq_left h

lemma ordMonoidWithZeroHom_eq_coe
    [Nontrivial R] {x : R} (hx : x ∈ nonZeroDivisors R) {n : ℕ} (hn : Ring.ord R x = n) :
    ordMonoidWithZeroHom R x = Multiplicative.ofAdd (n : ℤ) := by
  simp [ordMonoidWithZeroHom_eq_ord hx, hn]

variable {R} in
/--
If `x` is not a non zero divisor, `ordMonoidWithZeroHom` is equal to `0`.
-/

@[simp]
theorem ordMonoidWithZeroHom_eq_zero [Nontrivial R] {x : R} (h : x ∉ nonZeroDivisors R) :
    ordMonoidWithZeroHom R x = 0 := dite_eq_right h

/--
The quotient of a Noetherian ring of krull dimension less than or equal to `1` by a principal ideal
is of finite length.
-/

theorem _root_.isFiniteLength_quotient_span_singleton [IsNoetherianRing R]
    [Ring.KrullDimLE 1 R] {x : R} (hx : x ∈ nonZeroDivisors R) :
    IsFiniteLength R (R ⧸ Ideal.span {x}) := by
  rw [isFiniteLength_iff_isNoetherian_isArtinian]
  suffices IsArtinianRing (R ⧸ Ideal.span {x}) from
    ⟨isNoetherian_quotient (Ideal.span {x}),
      isArtinian_of_surjective_algebraMap (Ideal.Quotient.mk_surjective (I := .span {x}))⟩
  rw [isArtinianRing_iff_krullDimLE_zero, Ring.KrullDimLE, Order.krullDimLE_iff,
    ← ENat.WithBot.add_le_add_one_right_iff, Nat.cast_zero, zero_add]
  exact (ringKrullDim_quotient_succ_le_of_nonZeroDivisor hx).trans (Order.KrullDimLE.krullDim_le)

variable [IsNoetherianRing R] [Ring.KrullDimLE 1 R]
variable {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]

variable {R} in
lemma ord_ne_top {a : R} (ha : a ∈ nonZeroDivisors R) : ord R a ≠ ⊤ := by
  simp [isFiniteLength_quotient_span_singleton R ha, Ring.ord, Module.length_ne_top_iff]

variable {R} in
lemma ord_lt_top {a : R} (ha : a ∈ nonZeroDivisors R) : ord R a < ⊤ := (ord_ne_top ha).lt_top

variable [Nontrivial R]

lemma ordMonoidWithZeroHom_isUnit (y : nonZeroDivisors R) : IsUnit (ordMonoidWithZeroHom R y) := by
  simp [ordMonoidWithZeroHom_eq_zero_iff, ord_ne_top]

/--
Order of vanishing function for elements of the fraction field defined as the extension of
`CommRing.ordMonoidWithZeroHom` to the field of fractions.
-/

@[stacks 02MD]
noncomputable
def ordFrac : K →*₀ ℤᵐ⁰ :=
  (toLocalizationMap (nonZeroDivisors R) K).lift₀ (ordMonoidWithZeroHom R) <|
  ordMonoidWithZeroHom_isUnit R

lemma ordFrac_eq_ord {x : R} :
    ordFrac R (algebraMap R K x) = ordMonoidWithZeroHom R x := by
  rcases eq_or_ne x 0 with rfl | hx
  · simp
  have := (FaithfulSMul.algebraMap_injective R K).isDomain
  refine (Submonoid.LocalizationMap.lift_eq ..).trans ?_
  simp [ordMonoidWithZeroHom, mem_nonZeroDivisors_iff_ne_zero.mpr hx]

lemma ordFrac_eq_div (a : nonZeroDivisors R) (b : nonZeroDivisors R) :
    ordFrac R (IsLocalization.mk' K a.1 b) =
      ordMonoidWithZeroHom R a / ordMonoidWithZeroHom R b := by
  simp [ordFrac_eq_ord]

end Ring

Messung
CHZG
9110010096

¤ Dauer der Verarbeitung: 0.14 Sekunden  ¤

*© Formatika GbR, Deutschland