source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/SelmerGroup.lean | import Mathlib.Algebra.Group.Equiv.TypeTags
import Mathlib.Data.ZMod.QuotientGroup
import Mathlib.RingTheory.DedekindDomain.AdicValuation
import Mathlib.Algebra.Group.Int.TypeTags
/-!
# Selmer groups of fraction fields of Dedekind domains
Let $K$ be the field of fractions of a Dedekind domain $R$. For any set $S$ of prime ideals in the
height one spectrum of $R$, and for any natural number $n$, the Selmer group $K(S, n)$ is defined to
be the subgroup of the unit group $K^\times$ modulo $n$-th powers where each element has $v$-adic
valuation divisible by $n$ for all prime ideals $v$ away from $S$. In other words, this is precisely
$$ K(S, n) := \{x(K^\times)^n \in K^\times / (K^\times)^n \ \mid \
\forall v \notin S, \ \mathrm{ord}_v(x) \equiv 0 \pmod n\}. $$
There is a fundamental short exact sequence
$$ 1 \to R_S^\times / (R_S^\times)^n \to K(S, n) \to \mathrm{Cl}_S(R)[n] \to 0, $$
where $R_S^\times$ is the $S$-unit group of $R$ and $\mathrm{Cl}_S(R)$ is the $S$-class group of
$R$. If the flanking groups are both finite, then $K(S, n)$ is finite by the first isomorphism
theorem. Such is the case when $R$ is the ring of integers of a number field $K$, $S$ is finite, and
$n$ is positive, in which case $R_S^\times$ is finitely generated by Dirichlet's unit theorem and
$\mathrm{Cl}_S(R)$ is finite by the class number theorem.
This file defines the Selmer group $K(S, n)$ and some basic facts.
## Main definitions
* `IsDedekindDomain.selmerGroup`: the Selmer group.
* TODO: maps in the sequence.
## Main statements
* TODO: proofs of exactness of the sequence.
* TODO: proofs of finiteness for global fields.
## Notation
* `K⟮S, n⟯`: the Selmer group with parameters `K`, `S`, and `n`.
## Implementation notes
The Selmer group is typically defined as a subgroup of the Galois cohomology group $H^1(K, \mu_n)$
with certain local conditions defined by $v$-adic valuations, where $\mu_n$ is the group of $n$-th
roots of unity over a separable closure of $K$. Here $H^1(K, \mu_n)$ is identified with
$K^\times / (K^\times)^n$ by the long exact sequence from Kummer theory and Hilbert's theorem 90,
and the fundamental short exact sequence becomes an easy consequence of the snake lemma. This file
will define all the maps explicitly for computational purposes, but isomorphisms to the Galois
cohomological definition will be provided when possible.
## References
https://doc.sagemath.org/html/en/reference/number_fields/sage/rings/number_field/selmer_group.html
## Tags
class group, selmer group, unit group
-/
set_option quotPrecheck false
local notation K "/" n => Kˣ ⧸ (powMonoidHom n : Kˣ →* Kˣ).range
namespace IsDedekindDomain
noncomputable section
open WithZero
open scoped WithZero nonZeroDivisors
universe u v
variable {R : Type u} [CommRing R] [IsDedekindDomain R] {K : Type v} [Field K]
[Algebra R K] [IsFractionRing R K] (v : HeightOneSpectrum R)
/-! ### Valuations of non-zero elements -/
namespace HeightOneSpectrum
open Classical in
/-- The multiplicative `v`-adic valuation on `Kˣ`. -/
def valuationOfNeZeroToFun (x : Kˣ) : Multiplicative ℤ :=
let hx := IsLocalization.sec R⁰ (x : K)
Multiplicative.ofAdd <|
(-(Associates.mk v.asIdeal).count (Associates.mk <| Ideal.span {hx.fst}).factors : ℤ) -
(-(Associates.mk v.asIdeal).count (Associates.mk <| Ideal.span {(hx.snd : R)}).factors : ℤ)
@[simp]
theorem valuationOfNeZeroToFun_eq (x : Kˣ) :
(v.valuationOfNeZeroToFun x : ℤᵐ⁰) = v.valuation K x := by
classical
rw [show v.valuation K x = _ * _ by rfl]
rw [Units.val_inv_eq_inv_val]
change _ = ite _ _ _ * (ite _ _ _)⁻¹
simp_rw [IsLocalization.toLocalizationMap_sec, SubmonoidClass.coe_subtype,
if_neg <| IsLocalization.sec_fst_ne_zero x.ne_zero,
if_neg (nonZeroDivisors.coe_ne_zero _),
← exp_neg, ← exp_add, valuationOfNeZeroToFun, ← sub_eq_add_neg, exp]
/-- The multiplicative `v`-adic valuation on `Kˣ`. -/
def valuationOfNeZero : Kˣ →* Multiplicative ℤ where
toFun := v.valuationOfNeZeroToFun
map_one' := by rw [← WithZero.coe_inj, valuationOfNeZeroToFun_eq]; exact map_one _
map_mul' _ _ := by
rw [← WithZero.coe_inj, WithZero.coe_mul]
simp only [valuationOfNeZeroToFun_eq]; exact map_mul _ _ _
@[simp]
theorem valuationOfNeZero_eq (x : Kˣ) : (v.valuationOfNeZero x : ℤᵐ⁰) = v.valuation K x :=
valuationOfNeZeroToFun_eq v x
@[simp]
theorem valuation_of_unit_eq (x : Rˣ) :
v.valuationOfNeZero (Units.map (algebraMap R K : R →* K) x) = 1 := by
rw [← WithZero.coe_inj, valuationOfNeZero_eq, Units.coe_map, eq_iff_le_not_lt]
constructor
· exact v.valuation_le_one x
· obtain ⟨x, _, hx, _⟩ := x
change ¬v.valuation K (algebraMap R K x) < 1
apply_fun v.intValuation at hx
rw [map_one, map_mul] at hx
rw [not_lt, ← hx, ← mul_one <| v.valuation _ _, valuation_of_algebraMap]
gcongr
exact v.intValuation_le_one _
/-- The multiplicative `v`-adic valuation on `Kˣ` modulo `n`-th powers. -/
def valuationOfNeZeroMod (n : ℕ) : (K / n) →* Multiplicative (ZMod n) :=
-- TODO: this definition does a lot of defeq abuse between `Multiplicative` and `Additive`,
-- so we need `erw` below.
(Int.quotientZMultiplesNatEquivZMod n).toMultiplicative.toMonoidHom.comp <|
QuotientGroup.map (powMonoidHom n : Kˣ →* Kˣ).range
(AddSubgroup.toSubgroup (AddSubgroup.zmultiples (n : ℤ)))
v.valuationOfNeZero
(by
rintro _ ⟨x, rfl⟩
exact
⟨v.valuationOfNeZero x, by simp only [powMonoidHom_apply, map_pow, Int.toAdd_pow]; rfl⟩)
@[simp]
theorem valuation_of_unit_mod_eq (n : ℕ) (x : Rˣ) :
v.valuationOfNeZeroMod n (Units.map (algebraMap R K : R →* K) x : K / n) = 1 := by
-- This used to be `rw`, but we need `erw` after https://github.com/leanprover/lean4/pull/2644
erw [valuationOfNeZeroMod, MonoidHom.comp_apply, ← QuotientGroup.coe_mk',
QuotientGroup.map_mk' (G := Kˣ) (N := MonoidHom.range (powMonoidHom n)),
valuation_of_unit_eq, QuotientGroup.mk_one, map_one]
end HeightOneSpectrum
/-! ### Selmer groups -/
variable {S S' : Set <| HeightOneSpectrum R} {n : ℕ}
/-- The Selmer group `K⟮S, n⟯`. -/
def selmerGroup : Subgroup <| K / n where
carrier := {x : K/n | ∀ (v) (_ : v ∉ S), (v : HeightOneSpectrum R).valuationOfNeZeroMod n x = 1}
one_mem' _ _ := by rw [map_one]
mul_mem' hx hy v hv := by rw [map_mul, hx v hv, hy v hv, one_mul]
inv_mem' hx v hv := by rw [map_inv, hx v hv, inv_one]
-- Porting note: was `scoped[SelmerGroup]` but that does not work even using `open SelmerGroup`
local notation K "⟮" S "," n "⟯" => @selmerGroup _ _ _ K _ _ _ S n
namespace selmerGroup
theorem monotone (hS : S ≤ S') : K⟮S,n⟯ ≤ K⟮S',n⟯ := fun _ hx v => hx v ∘ mt (@hS v)
/-- The multiplicative `v`-adic valuations on `K⟮S, n⟯` for all `v ∈ S`. -/
def valuation : K⟮S,n⟯ →* S → Multiplicative (ZMod n) where
toFun x v := (v : HeightOneSpectrum R).valuationOfNeZeroMod n (x : K/n)
map_one' := funext fun _ => map_one _
map_mul' x y := by simp only [Subgroup.coe_mul, map_mul]; rfl
theorem valuation_ker_eq :
valuation.ker = K⟮(∅ : Set <| HeightOneSpectrum R),n⟯.subgroupOf (K⟮S,n⟯) := by
ext ⟨_, hx⟩
constructor
· intro hx' v _
by_cases hv : v ∈ S
· exact congr_fun hx' ⟨v, hv⟩
· exact hx v hv
· exact fun hx' => funext fun v => hx' v <| Set.notMem_empty v
/-- The natural homomorphism from `Rˣ` to `K⟮∅, n⟯`. -/
def fromUnit {n : ℕ} : Rˣ →* K⟮(∅ : Set <| HeightOneSpectrum R),n⟯ where
toFun x :=
⟨QuotientGroup.mk <| Units.map (algebraMap R K).toMonoidHom x, fun v _ =>
v.valuation_of_unit_mod_eq n x⟩
map_one' := by simp only [map_one, QuotientGroup.mk_one, Subgroup.mk_eq_one]
map_mul' _ _ := by simp only [RingHom.toMonoidHom_eq_coe, map_mul, QuotientGroup.mk_mul,
MulMemClass.mk_mul_mk]
theorem fromUnit_ker [hn : Fact <| 0 < n] :
(@fromUnit R _ _ K _ _ _ n).ker = (powMonoidHom n : Rˣ →* Rˣ).range := by
ext ⟨_, _, _, _⟩
constructor
· intro hx
rcases (QuotientGroup.eq_one_iff _).mp (Subtype.mk.inj hx) with ⟨⟨v, i, vi, iv⟩, hx⟩
have hv : ↑(_ ^ n : Kˣ) = algebraMap R K _ := congr_arg Units.val hx
have hi : ↑(_ ^ n : Kˣ)⁻¹ = algebraMap R K _ := congr_arg Units.inv hx
rw [Units.val_pow_eq_pow_val] at hv
rw [← inv_pow, Units.inv_mk, Units.val_pow_eq_pow_val] at hi
rcases IsIntegrallyClosed.exists_algebraMap_eq_of_isIntegral_pow (R := R) (x := v) hn.out
(hv.symm ▸ isIntegral_algebraMap) with
⟨v', rfl⟩
rcases IsIntegrallyClosed.exists_algebraMap_eq_of_isIntegral_pow (R := R) (x := i) hn.out
(hi.symm ▸ isIntegral_algebraMap) with
⟨i', rfl⟩
rw [← map_mul, map_eq_one_iff _ <| FaithfulSMul.algebraMap_injective R K] at vi
rw [← map_mul, map_eq_one_iff _ <| FaithfulSMul.algebraMap_injective R K] at iv
rw [Units.val_mk, ← map_pow] at hv
exact ⟨⟨v', i', vi, iv⟩, by
simpa only [Units.ext_iff, powMonoidHom_apply, Units.val_pow_eq_pow_val] using
FaithfulSMul.algebraMap_injective R K hv⟩
· rintro ⟨x, hx⟩
rw [← hx]
exact Subtype.mk_eq_mk.mpr <| (QuotientGroup.eq_one_iff _).mpr ⟨Units.map (algebraMap R K) x,
by simp only [powMonoidHom_apply, RingHom.toMonoidHom_eq_coe, map_pow]⟩
/-- The injection induced by the natural homomorphism from `Rˣ` to `K⟮∅, n⟯`. -/
def fromUnitLift [Fact <| 0 < n] : (R / n) →* K⟮(∅ : Set <| HeightOneSpectrum R),n⟯ :=
(QuotientGroup.kerLift _).comp
(QuotientGroup.quotientMulEquivOfEq (fromUnit_ker (R := R))).symm.toMonoidHom
theorem fromUnitLift_injective [Fact <| 0 < n] :
Function.Injective <| @fromUnitLift R _ _ K _ _ _ n _ := by
dsimp only [fromUnitLift, MonoidHom.coe_comp, MulEquiv.coe_toMonoidHom]
exact Function.Injective.comp (QuotientGroup.kerLift_injective _) (MulEquiv.injective _)
end selmerGroup
end
end IsDedekindDomain |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/PID.lean | import Mathlib.RingTheory.DedekindDomain.Dvr
import Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas
import Mathlib.RingTheory.PrincipalIdealDomainOfPrime
/-!
# Criteria under which a Dedekind domain is a PID
This file contains some results that we can use to test whether all ideals in a Dedekind domain are
principal.
## Main results
* `Ideal.IsPrincipal.of_finite_maximals_of_isUnit`: an invertible ideal in a commutative ring
with finitely many maximal ideals, is a principal ideal.
* `IsPrincipalIdealRing.of_finite_primes`: if a Dedekind domain has finitely many prime ideals,
it is a principal ideal domain.
* `IsPrincipalIdealRing.of_isDedekindDomain_of_uniqueFactorizationMonoid`: a Dedekind domain
that is a unique factorisation domain, is also a principal ideal domain.
-/
variable {R : Type*} [CommRing R]
open Ideal
open UniqueFactorizationMonoid
open scoped nonZeroDivisors
/-- Let `P` be a prime ideal, `x ∈ P \ P²` and `x ∉ Q` for all prime ideals `Q ≠ P`.
Then `P` is generated by `x`. -/
theorem Ideal.eq_span_singleton_of_mem_of_notMem_sq_of_notMem_prime_ne {P : Ideal R}
(hP : P.IsPrime) [IsDedekindDomain R] {x : R} (x_mem : x ∈ P) (hxP2 : x ∉ P ^ 2)
(hxQ : ∀ Q : Ideal R, IsPrime Q → Q ≠ P → x ∉ Q) : P = Ideal.span {x} := by
letI := Classical.decEq (Ideal R)
have hx0 : x ≠ 0 := by
rintro rfl
exact hxP2 (zero_mem _)
by_cases hP0 : P = ⊥
· subst hP0
rwa [eq_comm, span_singleton_eq_bot, ← mem_bot]
have hspan0 : span ({x} : Set R) ≠ ⊥ := mt Ideal.span_singleton_eq_bot.mp hx0
have span_le := (Ideal.span_singleton_le_iff_mem _).mpr x_mem
refine
associated_iff_eq.mp
((associated_iff_normalizedFactors_eq_normalizedFactors hP0 hspan0).mpr
(le_antisymm ((dvd_iff_normalizedFactors_le_normalizedFactors hP0 hspan0).mp ?_) ?_))
· rwa [Ideal.dvd_iff_le, Ideal.span_singleton_le_iff_mem]
simp only [normalizedFactors_irreducible (Ideal.prime_of_isPrime hP0 hP).irreducible,
normalize_eq, Multiset.le_iff_count, Multiset.count_singleton]
intro Q
split_ifs with hQ
· subst hQ
refine (Ideal.count_normalizedFactors_eq ?_ ?_).le <;>
simp only [Ideal.span_singleton_le_iff_mem, pow_one] <;>
assumption
by_cases hQp : IsPrime Q
· refine (Ideal.count_normalizedFactors_eq ?_ ?_).le <;>
simp [Ideal.span_singleton_le_iff_mem]
exact hxQ _ hQp hQ
· exact
(Multiset.count_eq_zero.mpr fun hQi =>
hQp
(isPrime_of_prime
(irreducible_iff_prime.mp (irreducible_of_normalized_factor _ hQi)))).le
@[deprecated (since := "2025-05-23")]
alias Ideal.eq_span_singleton_of_mem_of_not_mem_sq_of_not_mem_prime_ne :=
Ideal.eq_span_singleton_of_mem_of_notMem_sq_of_notMem_prime_ne
-- Porting note: replaced three implicit coercions of `I` with explicit `(I : Submodule R A)`
theorem FractionalIdeal.isPrincipal_of_unit_of_comap_mul_span_singleton_eq_top {R A : Type*}
[CommRing R] [CommRing A] [Algebra R A] {S : Submonoid R} [IsLocalization S A]
(I : (FractionalIdeal S A)ˣ) {v : A} (hv : v ∈ (↑I⁻¹ : FractionalIdeal S A))
(h : Submodule.comap (Algebra.linearMap R A) ((I : Submodule R A) * Submodule.span R {v}) = ⊤) :
Submodule.IsPrincipal (I : Submodule R A) := by
have hinv := I.mul_inv
set J := Submodule.comap (Algebra.linearMap R A) ((I : Submodule R A) * Submodule.span R {v})
have hJ : IsLocalization.coeSubmodule A J = ↑I * Submodule.span R {v} := by
rw [coe_ext_iff, coe_mul, coe_one] at hinv
apply Submodule.map_comap_eq_self
grw [← Submodule.one_eq_range, ← hinv, (Submodule.span_singleton_le_iff_mem _ _).2 hv]
have : (1 : A) ∈ ↑I * Submodule.span R {v} := by
rw [← hJ, h, IsLocalization.coeSubmodule_top, Submodule.mem_one]
exact ⟨1, (algebraMap R _).map_one⟩
obtain ⟨w, hw, hvw⟩ := Submodule.mem_mul_span_singleton.1 this
refine ⟨⟨w, ?_⟩⟩
rw [← FractionalIdeal.coe_spanSingleton S, ← inv_inv I, eq_comm]
refine congr_arg coeToSubmodule (Units.eq_inv_of_mul_eq_one_left (le_antisymm ?_ ?_))
· conv_rhs => rw [← hinv, mul_comm]
grw [FractionalIdeal.spanSingleton_le_iff_mem.mpr hw]
· rw [FractionalIdeal.one_le, ← hvw, mul_comm]
exact FractionalIdeal.mul_mem_mul (FractionalIdeal.mem_spanSingleton_self _ _) hv
/--
An invertible fractional ideal of a commutative ring with finitely many maximal ideals is principal.
https://math.stackexchange.com/a/95857 -/
theorem FractionalIdeal.isPrincipal.of_finite_maximals_of_inv {A : Type*} [CommRing A]
[Algebra R A] {S : Submonoid R} [IsLocalization S A] (hS : S ≤ R⁰)
(hf : {I : Ideal R | I.IsMaximal}.Finite) (I I' : FractionalIdeal S A) (hinv : I * I' = 1) :
Submodule.IsPrincipal (I : Submodule R A) := by
have hinv' := hinv
rw [coe_ext_iff, coe_mul] at hinv
let s := hf.toFinset
haveI := Classical.decEq (Ideal R)
have coprime : ∀ M ∈ s, ∀ M' ∈ s.erase M, M ⊔ M' = ⊤ := by
simp_rw [s, Finset.mem_erase, hf.mem_toFinset]
rintro M hM M' ⟨hne, hM'⟩
exact Ideal.IsMaximal.coprime_of_ne hM hM' hne.symm
have nle : ∀ M ∈ s, ¬⨅ M' ∈ s.erase M, M' ≤ M := fun M hM =>
left_lt_sup.1
((hf.mem_toFinset.1 hM).ne_top.lt_top.trans_eq (Ideal.sup_iInf_eq_top <| coprime M hM).symm)
have : ∀ M ∈ s, ∃ a ∈ I, ∃ b ∈ I', a * b ∉ IsLocalization.coeSubmodule A M := by
intro M hM; by_contra! h
obtain ⟨x, hx, hxM⟩ :=
SetLike.exists_of_lt
((IsLocalization.coeSubmodule_strictMono hS (hf.mem_toFinset.1 hM).ne_top.lt_top).trans_eq
hinv.symm)
exact hxM (Submodule.mul_le.2 h hx)
choose! a ha b hb hm using this
choose! u hu hum using fun M hM => SetLike.not_le_iff_exists.1 (nle M hM)
let v := ∑ M ∈ s, u M • b M
have hv : v ∈ I' := Submodule.sum_mem _ fun M hM => Submodule.smul_mem _ _ <| hb M hM
refine
FractionalIdeal.isPrincipal_of_unit_of_comap_mul_span_singleton_eq_top
(Units.mkOfMulEqOne I I' hinv') hv (of_not_not fun h => ?_)
obtain ⟨M, hM, hJM⟩ := Ideal.exists_le_maximal _ h
replace hM := hf.mem_toFinset.2 hM
have : ∀ a ∈ I, ∀ b ∈ I', ∃ c, algebraMap R _ c = a * b := by
intro a ha b hb; have hi := hinv.le
obtain ⟨c, -, hc⟩ := hi (Submodule.mul_mem_mul ha hb)
exact ⟨c, hc⟩
have hmem : a M * v ∈ IsLocalization.coeSubmodule A M := by
obtain ⟨c, hc⟩ := this _ (ha M hM) v hv
refine IsLocalization.coeSubmodule_mono _ hJM ⟨c, ?_, hc⟩
have := Submodule.mul_mem_mul (ha M hM) (Submodule.mem_span_singleton_self v)
rwa [← hc] at this
simp_rw [v, Finset.mul_sum, mul_smul_comm] at hmem
rw [← s.add_sum_erase _ hM, Submodule.add_mem_iff_left] at hmem
· refine hm M hM ?_
obtain ⟨c, hc : algebraMap R A c = a M * b M⟩ := this _ (ha M hM) _ (hb M hM)
rw [← hc] at hmem ⊢
rw [Algebra.smul_def, ← map_mul] at hmem
obtain ⟨d, hdM, he⟩ := hmem
rw [IsLocalization.injective _ hS he] at hdM
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to specify the value of `f`
exact Submodule.mem_map_of_mem (f := Algebra.linearMap _ _)
(((hf.mem_toFinset.1 hM).isPrime.mem_or_mem hdM).resolve_left <| hum M hM)
· refine Submodule.sum_mem _ fun M' hM' => ?_
rw [Finset.mem_erase] at hM'
obtain ⟨c, hc⟩ := this _ (ha M hM) _ (hb M' hM'.2)
rw [← hc, Algebra.smul_def, ← map_mul]
specialize hu M' hM'.2
simp_rw [Ideal.mem_iInf, Finset.mem_erase] at hu
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to specify the value of `f`
exact Submodule.mem_map_of_mem (f := Algebra.linearMap _ _)
(M.mul_mem_right _ <| hu M ⟨hM'.1.symm, hM⟩)
/-- An invertible ideal in a commutative ring with finitely many maximal ideals is principal.
https://math.stackexchange.com/a/95857 -/
theorem Ideal.IsPrincipal.of_finite_maximals_of_isUnit (hf : {I : Ideal R | I.IsMaximal}.Finite)
{I : Ideal R} (hI : IsUnit (I : FractionalIdeal R⁰ (FractionRing R))) : I.IsPrincipal :=
(IsLocalization.coeSubmodule_isPrincipal _ le_rfl).mp
(FractionalIdeal.isPrincipal.of_finite_maximals_of_inv le_rfl hf I
(↑hI.unit⁻¹ : FractionalIdeal R⁰ (FractionRing R)) hI.unit.mul_inv)
/-- A Dedekind domain is a PID if its set of maximal ideals is finite. -/
theorem IsPrincipalIdealRing.of_finite_maximals [IsDedekindDomain R]
(h : {I : Ideal R | I.IsMaximal}.Finite) : IsPrincipalIdealRing R :=
⟨fun I => by
obtain rfl | hI := eq_or_ne I ⊥
· exact bot_isPrincipal
apply Ideal.IsPrincipal.of_finite_maximals_of_isUnit h
exact .of_mul_eq_one _ (FractionalIdeal.coe_ideal_mul_inv I hI)⟩
/-- A Dedekind domain is a PID if its set of primes is finite. -/
theorem IsPrincipalIdealRing.of_finite_primes [IsDedekindDomain R]
(h : {I : Ideal R | I.IsPrime}.Finite) : IsPrincipalIdealRing R :=
IsPrincipalIdealRing.of_finite_maximals <| h.subset fun _ hi ↦ hi.isPrime
section
variable [IsDedekindDomain R]
variable (S : Type*) [CommRing S]
variable [Algebra R S] [NoZeroSMulDivisors R S] [Module.Finite R S]
variable (p : Ideal R) (hp0 : p ≠ ⊥) [IsPrime p]
variable {Sₚ : Type*} [CommRing Sₚ] [Algebra S Sₚ]
variable [IsLocalization (Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ]
variable [Algebra R Sₚ] [IsScalarTower R S Sₚ]
include hp0
/- The first hypothesis below follows from properties of the localization but is needed for the
second, so we leave it to the user to provide (automatically). -/
variable [IsDedekindDomain Sₚ]
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [IsDomain S]
{P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
map_le_nonZeroDivisors_of_injective _ (FaithfulSMul.algebraMap_injective _ _)
p.primeCompl_le_nonZeroDivisors
letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
IsScalarTower.of_algebraMap_eq fun x => by
rw [IsScalarTower.algebraMap_apply R S]
exact (IsLocalization.map_eq (T := Algebra.algebraMapSubmonoid S (primeCompl p))
(Submonoid.le_comap_map _) x).symm
obtain ⟨pid, p', ⟨hp'0, hp'p⟩, hpu⟩ :=
(IsDiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime p)).mp
(IsLocalization.AtPrime.isDiscreteValuationRing_of_dedekind_domain R hp0 _)
have : IsLocalRing.maximalIdeal (Localization.AtPrime p) ≠ ⊥ := by
rw [Submodule.ne_bot_iff] at hp0 ⊢
obtain ⟨x, x_mem, x_ne⟩ := hp0
exact
⟨algebraMap _ _ x, (IsLocalization.AtPrime.to_map_mem_maximal_iff _ _ _).mpr x_mem,
IsLocalization.to_map_ne_zero_of_mem_nonZeroDivisors _ p.primeCompl_le_nonZeroDivisors
(mem_nonZeroDivisors_of_ne_zero x_ne)⟩
rw [← Multiset.singleton_le, ← normalize_eq P, ←
normalizedFactors_irreducible (Ideal.prime_of_isPrime hP0 hP).irreducible, ←
dvd_iff_normalizedFactors_le_normalizedFactors hP0, dvd_iff_le,
IsScalarTower.algebraMap_eq R (Localization.AtPrime p) Sₚ, ← Ideal.map_map,
Localization.AtPrime.map_eq_maximalIdeal, Ideal.map_le_iff_le_comap,
hpu (IsLocalRing.maximalIdeal _) ⟨this, _⟩, hpu (comap _ _) ⟨_, _⟩]
· have : Algebra.IsIntegral (Localization.AtPrime p) Sₚ := ⟨isIntegral_localization⟩
exact mt (Ideal.eq_bot_of_comap_eq_bot) hP0
· exact Ideal.comap_isPrime (algebraMap (Localization.AtPrime p) Sₚ) P
· exact (IsLocalRing.maximalIdeal.isMaximal _).isPrime
· rw [Ne, zero_eq_bot, Ideal.map_eq_bot_iff_of_injective]
· assumption
rw [IsScalarTower.algebraMap_eq R S Sₚ]
exact
(IsLocalization.injective Sₚ non_zero_div).comp (FaithfulSMul.algebraMap_injective _ _)
/-- Let `p` be a prime in the Dedekind domain `R` and `S` be an integral extension of `R`,
then the localization `Sₚ` of `S` at `p` is a PID. -/
theorem IsDedekindDomain.isPrincipalIdealRing_localization_over_prime [IsDomain S] :
IsPrincipalIdealRing Sₚ := by
letI := Classical.decEq (Ideal Sₚ)
letI := Classical.decPred fun P : Ideal Sₚ => P.IsPrime
refine
IsPrincipalIdealRing.of_finite_primes
(Set.Finite.ofFinset
{P ∈ {⊥} ∪ (normalizedFactors (Ideal.map (algebraMap R Sₚ) p)).toFinset | P.IsPrime}
fun P => ?_)
rw [Finset.mem_filter, Finset.mem_union, Finset.mem_singleton, Set.mem_setOf,
Multiset.mem_toFinset]
exact
and_iff_right_of_imp fun hP =>
or_iff_not_imp_left.mpr (IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime S p hp0 hP)
end
-- not an instance because this might cause a timeout
theorem IsPrincipalIdealRing.of_isDedekindDomain_of_uniqueFactorizationMonoid
(R : Type*) [CommRing R] [IsDedekindDomain R] [UniqueFactorizationMonoid R] :
IsPrincipalIdealRing R := by
refine .of_prime_ne_bot fun P hp hp₀ ↦ ?_
obtain ⟨x, hx₁, hx₂⟩ := hp.exists_mem_prime_of_ne_bot hp₀
suffices Ideal.span {x} = P from this ▸ inferInstance
have := (Ideal.span_singleton_prime hx₂.ne_zero).mpr hx₂
exact (Ring.DimensionLeOne.prime_le_prime_iff_eq (by aesop)).mp <|
P.span_singleton_le_iff_mem.mpr hx₁ |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/Basic.lean | import Mathlib.RingTheory.Ideal.GoingUp
import Mathlib.RingTheory.Polynomial.RationalRoot
/-!
# Dedekind rings and domains
This file defines the notion of a Dedekind ring (domain),
as a Noetherian integrally closed commutative ring (domain) of Krull dimension at most one.
## Main definitions
- `IsDedekindRing` defines a Dedekind ring as a commutative ring that is
Noetherian, integrally closed in its field of fractions and has Krull dimension at most one.
`isDedekindRing_iff` shows that this does not depend on the choice of field of fractions.
- `IsDedekindDomain` defines a Dedekind domain as a Dedekind ring that is a domain.
## Implementation notes
The definitions that involve a field of fractions choose a canonical field of fractions,
but are independent of that choice. The `..._iff` lemmas express this independence.
`IsDedekindRing` and `IsDedekindDomain` form a cycle in the typeclass hierarchy:
`IsDedekindRing R + IsDomain R` imply `IsDedekindDomain R`, which implies `IsDedekindRing R`.
This should be safe since the start and end point is the literal same expression,
which the tabled typeclass synthesis algorithm can deal with.
Often, definitions assume that Dedekind rings are not fields. We found it more practical
to add a `(h : ¬ IsField A)` assumption whenever this is explicitly needed.
## References
* [D. Marcus, *Number Fields*][marcus1977number]
* [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring
-/
variable (R A K : Type*) [CommRing R] [CommRing A] [Field K]
open scoped nonZeroDivisors Polynomial
/-- A ring `R` has Krull dimension at most one if all nonzero prime ideals are maximal. -/
class Ring.DimensionLEOne : Prop where
(maximalOfPrime : ∀ {p : Ideal R}, p ≠ ⊥ → p.IsPrime → p.IsMaximal)
open Ideal Ring
theorem Ideal.IsPrime.isMaximal {R : Type*} [CommRing R] [DimensionLEOne R]
{p : Ideal R} (h : p.IsPrime) (hp : p ≠ ⊥) : p.IsMaximal :=
DimensionLEOne.maximalOfPrime hp h
namespace Ring
instance DimensionLEOne.principal_ideal_ring [IsDomain A] [IsPrincipalIdealRing A] :
DimensionLEOne A where
maximalOfPrime := fun nonzero _ =>
IsPrime.to_maximal_ideal nonzero
theorem DimensionLEOne.isIntegralClosure (B : Type*) [CommRing B] [IsDomain B] [Nontrivial R]
[Algebra R A] [Algebra R B] [Algebra B A] [IsScalarTower R B A] [IsIntegralClosure B R A]
[DimensionLEOne R] : DimensionLEOne B where
maximalOfPrime := fun {p} ne_bot _ =>
IsIntegralClosure.isMaximal_of_isMaximal_comap (R := R) A p
(Ideal.IsPrime.isMaximal inferInstance (IsIntegralClosure.comap_ne_bot A ne_bot))
nonrec instance DimensionLEOne.integralClosure [Nontrivial R] [IsDomain A] [Algebra R A]
[DimensionLEOne R] : DimensionLEOne (integralClosure R A) :=
DimensionLEOne.isIntegralClosure R A (integralClosure R A)
variable {R}
theorem DimensionLEOne.not_lt_lt [Ring.DimensionLEOne R] (p₀ p₁ p₂ : Ideal R) [hp₁ : p₁.IsPrime]
[hp₂ : p₂.IsPrime] : ¬(p₀ < p₁ ∧ p₁ < p₂)
| ⟨h01, h12⟩ => h12.ne ((hp₁.isMaximal (bot_le.trans_lt h01).ne').eq_of_le hp₂.ne_top h12.le)
theorem DimensionLEOne.eq_bot_of_lt [Ring.DimensionLEOne R] (p P : Ideal R) [p.IsPrime]
[P.IsPrime] (hpP : p < P) : p = ⊥ :=
by_contra fun hp0 => not_lt_lt ⊥ p P ⟨Ne.bot_lt hp0, hpP⟩
end Ring
/-- A Dedekind ring is a commutative ring that is Noetherian, integrally closed, and
has Krull dimension at most one.
This is exactly `IsDedekindDomain` minus the `IsDomain` hypothesis.
The integral closure condition is independent of the choice of field of fractions:
use `isDedekindRing_iff` to prove `IsDedekindRing` for a given `fraction_map`.
-/
class IsDedekindRing : Prop
extends IsNoetherian A A, DimensionLEOne A, IsIntegralClosure A A (FractionRing A)
/-- An integral domain is a Dedekind domain if and only if it is
Noetherian, has dimension ≤ 1, and is integrally closed in a given fraction field.
In particular, this definition does not depend on the choice of this fraction field. -/
theorem isDedekindRing_iff (K : Type*) [CommRing K] [Algebra A K] [IsFractionRing A K] :
IsDedekindRing A ↔
IsNoetherianRing A ∧ DimensionLEOne A ∧
∀ {x : K}, IsIntegral A x → ∃ y, algebraMap A K y = x :=
⟨fun _ => ⟨inferInstance, inferInstance,
fun {_} => (isIntegrallyClosed_iff K).mp inferInstance⟩,
fun ⟨hr, hd, hi⟩ => { hr, hd, (isIntegrallyClosed_iff K).mpr @hi with }⟩
/-- A Dedekind domain is an integral domain that is Noetherian, integrally closed, and
has Krull dimension at most one.
This is definition 3.2 of [Neukirch1992].
This is exactly `IsDedekindRing` plus the `IsDomain` hypothesis.
The integral closure condition is independent of the choice of field of fractions:
use `isDedekindDomain_iff` to prove `IsDedekindDomain` for a given `fraction_map`.
This is the default implementation, but there are equivalent definitions,
`IsDedekindDomainDvr` and `IsDedekindDomainInv`.
-/
class IsDedekindDomain : Prop
extends IsDomain A, IsDedekindRing A
attribute [instance 90] IsDedekindDomain.toIsDomain
/-- Make a Dedekind domain from a Dedekind ring given that it is a domain.
`IsDedekindRing` and `IsDedekindDomain` form a cycle in the typeclass hierarchy:
`IsDedekindRing R + IsDomain R` imply `IsDedekindDomain R`, which implies `IsDedekindRing R`.
This should be safe since the start and end point is the literal same expression,
which the tabled typeclass synthesis algorithm can deal with.
-/
instance [IsDomain A] [IsDedekindRing A] : IsDedekindDomain A where
/-- An integral domain is a Dedekind domain iff and only if it is
Noetherian, has dimension ≤ 1, and is integrally closed in a given fraction field.
In particular, this definition does not depend on the choice of this fraction field. -/
theorem isDedekindDomain_iff (K : Type*) [CommRing K] [Algebra A K] [IsFractionRing A K] :
IsDedekindDomain A ↔
IsDomain A ∧ IsNoetherianRing A ∧ DimensionLEOne A ∧
∀ {x : K}, IsIntegral A x → ∃ y, algebraMap A K y = x :=
⟨fun _ => ⟨inferInstance, inferInstance, inferInstance,
fun {_} => (isIntegrallyClosed_iff K).mp inferInstance⟩,
fun ⟨hid, hr, hd, hi⟩ => { hid, hr, hd, (isIntegrallyClosed_iff K).mpr @hi with }⟩
-- See library note [lower instance priority]
instance (priority := 100) IsPrincipalIdealRing.isDedekindDomain
[IsDomain A] [IsPrincipalIdealRing A] :
IsDedekindDomain A :=
{ PrincipalIdealRing.isNoetherianRing, Ring.DimensionLEOne.principal_ideal_ring A,
UniqueFactorizationMonoid.instIsIntegrallyClosed with }
variable {R} in
theorem IsLocalRing.primesOver_eq [IsLocalRing A] [IsDedekindDomain A] [Algebra R A]
[FaithfulSMul R A] [Module.Finite R A] {p : Ideal R} [p.IsMaximal] (hp0 : p ≠ ⊥) :
Ideal.primesOver p A = {IsLocalRing.maximalIdeal A} := by
refine Set.eq_singleton_iff_nonempty_unique_mem.mpr ⟨?_, fun P hP ↦ ?_⟩
· obtain ⟨w', hmax, hover⟩ := exists_maximal_ideal_liesOver_of_isIntegral (S := A) p
exact ⟨w', hmax.isPrime, hover⟩
· exact IsLocalRing.eq_maximalIdeal <| hP.1.isMaximal (Ideal.ne_bot_of_mem_primesOver hp0 hP) |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/AdicValuation.lean | import Mathlib.Algebra.Order.Ring.IsNonarchimedean
import Mathlib.Data.Int.WithZero
import Mathlib.RingTheory.DedekindDomain.Ideal.Lemmas
import Mathlib.RingTheory.Valuation.ExtendToLocalization
import Mathlib.Topology.Algebra.Valued.ValuedField
import Mathlib.Topology.Algebra.Valued.WithVal
/-!
# Adic valuations on Dedekind domains
Given a Dedekind domain `R` of Krull dimension 1 and a maximal ideal `v` of `R`, we define the
`v`-adic valuation on `R` and its extension to the field of fractions `K` of `R`.
We prove several properties of this valuation, including the existence of uniformizers.
We define the completion of `K` with respect to the `v`-adic valuation, denoted
`v.adicCompletion`, and its ring of integers, denoted `v.adicCompletionIntegers`.
## Main definitions
- `IsDedekindDomain.HeightOneSpectrum.intValuation v` is the `v`-adic valuation on `R`.
- `IsDedekindDomain.HeightOneSpectrum.valuation v` is the `v`-adic valuation on `K`.
- `IsDedekindDomain.HeightOneSpectrum.adicCompletion v` is the completion of `K` with respect
to its `v`-adic valuation.
- `IsDedekindDomain.HeightOneSpectrum.adicCompletionIntegers v` is the ring of integers of
`v.adicCompletion`.
- `IsDedekindDomain.HeightOneSpectrum.adicAbv v`is the `v`-adic absolute value on `K` defined as `b`
raised to negative `v`-adic valuation, for some `b` in `ℝ≥0`.
## Main results
- `IsDedekindDomain.HeightOneSpectrum.intValuation_le_one` : The `v`-adic valuation on `R` is
bounded above by 1.
- `IsDedekindDomain.HeightOneSpectrum.intValuation_lt_one_iff_dvd` : The `v`-adic valuation of
`r ∈ R` is less than 1 if and only if `v` divides the ideal `(r)`.
- `IsDedekindDomain.HeightOneSpectrum.intValuation_le_pow_iff_dvd` : The `v`-adic valuation of
`r ∈ R` is less than or equal to `WithZero.exp (-n)` if and only if `vⁿ` divides the
ideal `(r)`.
- `IsDedekindDomain.HeightOneSpectrum.intValuation_exists_uniformizer` : There exists `π ∈ R`
with `v`-adic valuation `WithZero.exp (-1)`.
- `IsDedekindDomain.HeightOneSpectrum.valuation_of_mk'` : The `v`-adic valuation of `r/s ∈ K`
is the valuation of `r` divided by the valuation of `s`.
- `IsDedekindDomain.HeightOneSpectrum.valuation_of_algebraMap` : The `v`-adic valuation on `K`
extends the `v`-adic valuation on `R`.
- `IsDedekindDomain.HeightOneSpectrum.valuation_exists_uniformizer` : There exists `π ∈ K` with
`v`-adic valuation `WithZero.exp (-1)`.
## Implementation notes
We are only interested in Dedekind domains with Krull dimension 1.
## References
* [G. J. Janusz, *Algebraic Number Fields*][janusz1996]
* [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring, adic valuation
-/
noncomputable section
open WithZero Multiplicative IsDedekindDomain
variable {R : Type*} [CommRing R] [IsDedekindDomain R] {K S : Type*} [Field K] [CommSemiring S]
[Algebra R K] [IsFractionRing R K] (v : HeightOneSpectrum R)
namespace IsDedekindDomain.HeightOneSpectrum
/-! ### Adic valuations on the Dedekind domain R -/
open scoped Classical in
/-- The additive `v`-adic valuation of `r ∈ R` is the exponent of `v` in the factorization of the
ideal `(r)`, if `r` is nonzero, or infinity, if `r = 0`. `intValuationDef` is the corresponding
multiplicative valuation. -/
def intValuationDef (r : R) : ℤᵐ⁰ :=
if r = 0 then 0
else
exp (-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : ℤ)
theorem intValuationDef_if_pos {r : R} (hr : r = 0) : v.intValuationDef r = 0 :=
if_pos hr
@[simp]
theorem intValuationDef_zero : v.intValuationDef 0 = 0 :=
if_pos rfl
open scoped Classical in
theorem intValuationDef_if_neg {r : R} (hr : r ≠ 0) :
v.intValuationDef r = exp
(-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : ℤ) :=
if_neg hr
/-- The `v`-adic valuation of `0 : R` equals 0. -/
theorem intValuation.map_zero' : v.intValuationDef 0 = 0 :=
v.intValuationDef_if_pos rfl
/-- The `v`-adic valuation of `1 : R` equals 1. -/
theorem intValuation.map_one' : v.intValuationDef 1 = 1 := by
classical
rw [v.intValuationDef_if_neg one_ne_zero, Ideal.span_singleton_one, ← Ideal.one_eq_top,
Associates.mk_one, Associates.factors_one, Associates.count_zero v.associates_irreducible,
Int.ofNat_zero, neg_zero, exp_zero]
/-- The `v`-adic valuation of a product equals the product of the valuations. -/
theorem intValuation.map_mul' (x y : R) :
v.intValuationDef (x * y) = v.intValuationDef x * v.intValuationDef y := by
classical
simp only [intValuationDef]
by_cases hx : x = 0
· rw [hx, zero_mul, if_pos rfl, zero_mul]
· by_cases hy : y = 0
· rw [hy, mul_zero, if_pos rfl, mul_zero]
· rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), ← exp_add,
← Ideal.span_singleton_mul_span_singleton, ← Associates.mk_mul_mk, ← neg_add,
Associates.count_mul (Associates.mk_ne_zero'.mpr hx) (Associates.mk_ne_zero'.mpr hy)
v.associates_irreducible,
Nat.cast_add]
-- TODO: unused, this is general over any linear order
theorem intValuation.le_max_iff_min_le {a b c : ℕ} :
Multiplicative.ofAdd (-c : ℤ) ≤
max (Multiplicative.ofAdd (-a : ℤ)) (Multiplicative.ofAdd (-b : ℤ)) ↔
min a b ≤ c := by
rw [le_max_iff, ofAdd_le, ofAdd_le, neg_le_neg_iff, neg_le_neg_iff, Int.ofNat_le, Int.ofNat_le,
← min_le_iff]
/-- The `v`-adic valuation of a sum is bounded above by the maximum of the valuations. -/
theorem intValuation.map_add_le_max' (x y : R) :
v.intValuationDef (x + y) ≤ max (v.intValuationDef x) (v.intValuationDef y) := by
classical
by_cases hx : x = 0
· rw [hx, zero_add]
order
· by_cases hy : y = 0
· rw [hy, add_zero]
order
· by_cases hxy : x + y = 0
· rw [intValuationDef, if_pos hxy]; exact zero_le'
· rw [v.intValuationDef_if_neg hxy, v.intValuationDef_if_neg hx, v.intValuationDef_if_neg hy,
le_max_iff]
simp only [exp_le_exp, neg_le_neg_iff, Nat.cast_le, ← min_le_iff]
set nmin :=
min ((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {x})).factors)
((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {y})).factors)
have h_dvd_x : x ∈ v.asIdeal ^ nmin := by
rw [← Associates.le_singleton_iff x nmin _,
Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hx) _]
· exact min_le_left _ _
exact v.associates_irreducible
have h_dvd_y : y ∈ v.asIdeal ^ nmin := by
rw [← Associates.le_singleton_iff y nmin _,
Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hy) _]
· exact min_le_right _ _
exact v.associates_irreducible
have h_dvd_xy : Associates.mk v.asIdeal ^ nmin ≤ Associates.mk (Ideal.span {x + y}) := by
rw [Associates.le_singleton_iff]
exact Ideal.add_mem (v.asIdeal ^ nmin) h_dvd_x h_dvd_y
rw [Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hxy) _] at h_dvd_xy
· exact h_dvd_xy
exact v.associates_irreducible
/-- The `v`-adic valuation on `R`. -/
def intValuation : Valuation R ℤᵐ⁰ where
toFun := v.intValuationDef
map_zero' := intValuation.map_zero' v
map_one' := intValuation.map_one' v
map_mul' := intValuation.map_mul' v
map_add_le_max' := intValuation.map_add_le_max' v
theorem intValuation_apply {r : R} (v : IsDedekindDomain.HeightOneSpectrum R) :
intValuation v r = intValuationDef v r := rfl
open scoped Classical in
theorem intValuation_def {r : R} :
v.intValuation r = if r = 0 then 0 else
exp (-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : ℤ) :=
rfl
@[deprecated intValuation_apply (since := "2025-04-26")]
theorem intValuation_toFun (r : R) :
v.intValuation r = v.intValuationDef r := rfl
open scoped Classical in
theorem intValuation_if_neg {r : R} (hr : r ≠ 0) :
v.intValuation r = exp
(-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : ℤ) :=
intValuationDef_if_neg _ hr
/-- Nonzero elements have nonzero adic valuation. -/
theorem intValuation_ne_zero (x : R) (hx : x ≠ 0) : v.intValuation x ≠ 0 := by
rw [v.intValuation_if_neg hx]
exact WithZero.coe_ne_zero
/-- Nonzero divisors have nonzero valuation. -/
theorem intValuation_ne_zero' (x : nonZeroDivisors R) : v.intValuation x ≠ 0 :=
v.intValuation_ne_zero x (nonZeroDivisors.coe_ne_zero x)
/-- Nonzero divisors have valuation greater than zero. -/
theorem intValuation_zero_lt (x : nonZeroDivisors R) : 0 < v.intValuation x := by
rw [v.intValuation_if_neg (nonZeroDivisors.coe_ne_zero x)]
exact WithZero.zero_lt_coe _
@[deprecated (since := "2025-05-11")]
alias intValuation_zero_le := intValuation_zero_lt
/-- The `v`-adic valuation on `R` is bounded above by 1. -/
theorem intValuation_le_one (x : R) : v.intValuation x ≤ 1 := by
by_cases hx : x = 0
· rw [hx, Valuation.map_zero]; exact WithZero.zero_le 1
· rw [v.intValuation_if_neg hx, ← exp_zero, exp_le_exp, Right.neg_nonpos_iff]
exact Int.natCast_nonneg _
/-- The `v`-adic valuation of `r ∈ R` is less than 1 if and only if `v` divides the ideal `(r)`. -/
theorem intValuation_lt_one_iff_dvd (r : R) :
v.intValuation r < 1 ↔ v.asIdeal ∣ Ideal.span {r} := by
classical
by_cases hr : r = 0
· simp [hr]
· rw [v.intValuation_if_neg hr, ← exp_zero, exp_lt_exp,
neg_lt_zero, ← Int.ofNat_zero, Int.ofNat_lt, zero_lt_iff]
have h : (Ideal.span {r} : Ideal R) ≠ 0 := by
rw [Ne, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]
exact hr
exact Associates.count_ne_zero_iff_dvd h v.irreducible
/-- The `v`-adic valuation of `r ∈ R` is less than 1 if and only if `r ∈ v`. -/
theorem intValuation_lt_one_iff_mem (r : R) :
v.intValuation r < 1 ↔ r ∈ v.asIdeal := by
rw [intValuation_lt_one_iff_dvd, Ideal.dvd_span_singleton]
/-- The `v`-adic valuation of `r ∈ R` is less than `WithZero.exp (-n)` if and only if
`vⁿ` divides the ideal `(r)`. -/
theorem intValuation_le_pow_iff_dvd (r : R) (n : ℕ) :
v.intValuation r ≤ exp (-(n : ℤ)) ↔ v.asIdeal ^ n ∣ Ideal.span {r} := by
classical
by_cases hr : r = 0
· simp_rw [hr, Valuation.map_zero, Ideal.dvd_span_singleton, zero_le', Submodule.zero_mem]
· rw [v.intValuation_if_neg hr, exp_le_exp, neg_le_neg_iff, Int.ofNat_le,
Ideal.dvd_span_singleton, ← Associates.le_singleton_iff,
Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hr) v.associates_irreducible]
/-- The `v`-adic valuation of `r ∈ R` is less than `WithZero.exp (-n)` if and only if
`r ∈ vⁿ`. -/
theorem intValuation_le_pow_iff_mem (r : R) (n : ℕ) :
v.intValuation r ≤ exp (-(n : ℤ)) ↔ r ∈ v.asIdeal ^ n := by
rw [intValuation_le_pow_iff_dvd, Ideal.dvd_span_singleton]
/-- There exists `π ∈ R` with `v`-adic valuation `WithZero.exp (-1)`. -/
theorem intValuation_exists_uniformizer :
∃ π : R, v.intValuation π = WithZero.exp (-1 : ℤ) := by
classical
have hv : Irreducible (Associates.mk v.asIdeal) := v.associates_irreducible
have hlt : v.asIdeal ^ 2 < v.asIdeal := by
rw [← Ideal.dvdNotUnit_iff_lt]
exact ⟨v.ne_bot, v.asIdeal, Ideal.isUnit_iff.not.mpr v.isPrime.ne_top, sq v.asIdeal⟩
obtain ⟨π, mem, notMem⟩ := SetLike.exists_of_lt hlt
have hπ : Associates.mk (Ideal.span {π}) ≠ 0 := by
rw [Associates.mk_ne_zero']
intro h
rw [h] at notMem
exact notMem (Submodule.zero_mem (v.asIdeal ^ 2))
use π
rw [intValuation_if_neg _ (Associates.mk_ne_zero'.mp hπ), exp_inj]
apply congr_arg
rw [← Int.ofNat_one, Int.natCast_inj]
rw [← Ideal.dvd_span_singleton, ← Associates.mk_le_mk_iff_dvd] at mem notMem
rw [← pow_one (Associates.mk v.asIdeal), Associates.prime_pow_dvd_iff_le hπ hv] at mem
rw [Associates.mk_pow, Associates.prime_pow_dvd_iff_le hπ hv, not_le] at notMem
exact Nat.eq_of_le_of_lt_succ mem notMem
/-- The `I`-adic valuation of a generator of `I` equals `(-1 : ℤᵐ⁰)` -/
theorem intValuation_singleton {r : R} (hr : r ≠ 0) (hv : v.asIdeal = Ideal.span {r}) :
v.intValuation r = exp (-1 : ℤ) := by
classical
rw [v.intValuation_if_neg hr, ← hv, Associates.count_self, Int.ofNat_one]
exact v.associates_irreducible
/-! ### Adic valuations on the field of fractions `K` -/
variable (K) in
/-- The `v`-adic valuation of `x ∈ K` is the valuation of `r` divided by the valuation of `s`,
where `r` and `s` are chosen so that `x = r/s`. -/
def valuation (v : HeightOneSpectrum R) : Valuation K ℤᵐ⁰ :=
v.intValuation.extendToLocalization
(fun r hr => Set.mem_compl <| v.intValuation_ne_zero' ⟨r, hr⟩) K
theorem valuation_def (x : K) :
v.valuation K x =
v.intValuation.extendToLocalization
(fun r hr => Set.mem_compl (v.intValuation_ne_zero' ⟨r, hr⟩)) K x :=
rfl
/-- The `v`-adic valuation of `r/s ∈ K` is the valuation of `r` divided by the valuation of `s`. -/
theorem valuation_of_mk' {r : R} {s : nonZeroDivisors R} :
v.valuation K (IsLocalization.mk' K r s) = v.intValuation r / v.intValuation s := by
rw [valuation_def, Valuation.extendToLocalization_mk', div_eq_mul_inv]
open scoped algebraMap in
/-- The `v`-adic valuation on `K` extends the `v`-adic valuation on `R`. -/
theorem valuation_of_algebraMap (r : R) : v.valuation K r = v.intValuation r := by
rw [valuation_def, Valuation.extendToLocalization_apply_map_apply]
open scoped algebraMap in
@[deprecated valuation_of_algebraMap (since := "2025-05-11")]
lemma valuation_eq_intValuationDef (r : R) : v.valuation K r = v.intValuationDef r :=
Valuation.extendToLocalization_apply_map_apply ..
open scoped algebraMap in
/-- The `v`-adic valuation on `R` is bounded above by 1. -/
theorem valuation_le_one (r : R) : v.valuation K r ≤ 1 := by
rw [valuation_of_algebraMap]; exact v.intValuation_le_one r
open scoped algebraMap in
/-- The `v`-adic valuation of `r ∈ R` is less than 1 if and only if `v` divides the ideal `(r)`. -/
theorem valuation_lt_one_iff_dvd (r : R) :
v.valuation K r < 1 ↔ v.asIdeal ∣ Ideal.span {r} := by
rw [valuation_of_algebraMap]; exact v.intValuation_lt_one_iff_dvd r
open scoped algebraMap in
/-- The `v`-adic valuation of `r ∈ R` is less than 1 if and only if `r ∈ v`. -/
theorem valuation_lt_one_iff_mem (r : R) :
v.valuation K r < 1 ↔ r ∈ v.asIdeal := by
rw [valuation_of_algebraMap]; exact v.intValuation_lt_one_iff_mem r
variable (K)
/-- There exists `π ∈ K` with `v`-adic valuation `WithZero.exp (-1)`. -/
theorem valuation_exists_uniformizer : ∃ π : K,
v.valuation K π = exp (-1 : ℤ) := by
obtain ⟨r, hr⟩ := v.intValuation_exists_uniformizer
use algebraMap R K r
rw [valuation_def, Valuation.extendToLocalization_apply_map_apply]
exact hr
lemma valuation_surjective :
Function.Surjective (v.valuation K) := by
intro x
rcases GroupWithZero.eq_zero_or_unit x with (rfl | ⟨x, rfl⟩)
· simp
· obtain ⟨π, hπ⟩ := v.valuation_exists_uniformizer K
refine ⟨π ^ (- log x.val), ?_⟩
simp [hπ, exp_log]
/-- Uniformizers are nonzero. -/
theorem valuation_uniformizer_ne_zero : Classical.choose (v.valuation_exists_uniformizer K) ≠ 0 :=
haveI hu := Classical.choose_spec (v.valuation_exists_uniformizer K)
(Valuation.ne_zero_iff _).mp (ne_of_eq_of_ne hu WithZero.coe_ne_zero)
theorem mem_integers_of_valuation_le_one (x : K)
(h : ∀ v : HeightOneSpectrum R, v.valuation K x ≤ 1) : x ∈ (algebraMap R K).range := by
obtain ⟨⟨n, d, hd⟩, hx⟩ := IsLocalization.surj (nonZeroDivisors R) x
obtain rfl : x = IsLocalization.mk' K n ⟨d, hd⟩ := IsLocalization.eq_mk'_iff_mul_eq.mpr hx
obtain rfl | hn0 := eq_or_ne n 0
· simp
have hd0 := nonZeroDivisors.ne_zero hd
suffices Ideal.span {d} ∣ (Ideal.span {n} : Ideal R) by
obtain ⟨z, rfl⟩ := Ideal.span_singleton_le_span_singleton.1 (Ideal.le_of_dvd this)
use z
rw [map_mul, mul_comm, mul_eq_mul_left_iff] at hx
exact (hx.resolve_right fun h => by simp [hd0] at h).symm
classical
have ine {r : R} : r ≠ 0 → Ideal.span {r} ≠ ⊥ := mt Ideal.span_singleton_eq_bot.mp
rw [← Associates.mk_le_mk_iff_dvd, ← Associates.factors_le, Associates.factors_mk _ (ine hn0),
Associates.factors_mk _ (ine hd0), WithTop.coe_le_coe, Multiset.le_iff_count]
rintro ⟨v, hv⟩
obtain ⟨v, rfl⟩ := Associates.mk_surjective v
have hv' := hv
rw [Associates.irreducible_mk, irreducible_iff_prime] at hv
specialize h ⟨v, Ideal.isPrime_of_prime hv, hv.ne_zero⟩
simp_rw [valuation_of_mk', intValuation_if_neg _ hn0, intValuation_if_neg _ hd0, ← exp_sub,
← exp_zero, exp_le_exp, Associates.factors_mk _ (ine hn0),
Associates.factors_mk _ (ine hd0), Associates.count_some hv'] at h
simpa using h
variable {K}
theorem eq_of_valuation_isEquiv_valuation {p q : HeightOneSpectrum R}
(hpq : (valuation K p).IsEquiv (valuation K q)) : p = q := by
simp_all [Valuation.isEquiv_iff_val_lt_one, HeightOneSpectrum.ext_iff, Ideal.ext_iff,
← valuation_lt_one_iff_mem (K := K)]
/-! ### Completions with respect to adic valuations
Given a Dedekind domain `R` with field of fractions `K` and a maximal ideal `v` of `R`, we define
the completion of `K` with respect to its `v`-adic valuation, denoted `v.adicCompletion`, and its
ring of integers, denoted `v.adicCompletionIntegers`. -/
/-- `K` as a valued field with the `v`-adic valuation. -/
def adicValued : Valued K ℤᵐ⁰ :=
Valued.mk' (v.valuation K)
theorem adicValued_apply {x : K} : v.adicValued.v x = v.valuation K x :=
rfl
@[simp]
theorem adicValued_apply' (x : WithVal (v.valuation K)) : v.adicValued.v x = v.valuation K x :=
rfl
variable (K)
/-- The completion of `K` with respect to its `v`-adic valuation. -/
abbrev adicCompletion := (v.valuation K).Completion
theorem valuedAdicCompletion_def {x : v.adicCompletion K} : Valued.v x = Valued.extension x :=
rfl
lemma valuedAdicCompletion_surjective :
Function.Surjective (Valued.v : (v.adicCompletion K) → ℤᵐ⁰) :=
Valued.valuedCompletion_surjective_iff.mpr (v.valuation_surjective K)
/-- The ring of integers of `adicCompletion`. -/
def adicCompletionIntegers : ValuationSubring (v.adicCompletion K) :=
Valued.v.valuationSubring
instance : Inhabited (adicCompletionIntegers K v) :=
⟨0⟩
variable (R)
theorem mem_adicCompletionIntegers {x : v.adicCompletion K} :
x ∈ v.adicCompletionIntegers K ↔ Valued.v x ≤ 1 :=
Iff.rfl
theorem notMem_adicCompletionIntegers {x : v.adicCompletion K} :
x ∉ v.adicCompletionIntegers K ↔ 1 < Valued.v x := by
rw [not_congr <| mem_adicCompletionIntegers R K v]
exact not_le
@[deprecated (since := "2025-05-23")]
alias not_mem_adicCompletionIntegers := notMem_adicCompletionIntegers
section AlgebraInstances
instance (priority := 100) adicValued.has_uniform_continuous_const_smul' :
UniformContinuousConstSMul R (WithVal <| v.valuation K) :=
uniformContinuousConstSMul_of_continuousConstSMul R (WithVal <| v.valuation K)
section Algebra
variable [Algebra S K]
instance adicValued.uniformContinuousConstSMul :
UniformContinuousConstSMul S (WithVal <| v.valuation K) := by
refine ⟨fun l ↦ ?_⟩
simp_rw [Algebra.smul_def]
exact (Ring.uniformContinuousConstSMul (WithVal <| v.valuation K)).uniformContinuous_const_smul _
open UniformSpace in
instance : Algebra S (v.adicCompletion K) where
toSMul := Completion.instSMul _ _
algebraMap := Completion.coeRingHom.comp (algebraMap _ _)
commutes' r x := by
induction x using Completion.induction_on with
| hp =>
exact isClosed_eq (continuous_mul_left _) (continuous_mul_right _)
| ih x =>
change (↑(algebraMap S (WithVal <| v.valuation K) r) : v.adicCompletion K) * x
= x * (↑(algebraMap S (WithVal <| v.valuation K) r) : v.adicCompletion K)
norm_cast
rw [Algebra.commutes]
smul_def' r x := by
induction x using Completion.induction_on with
| hp =>
exact isClosed_eq (continuous_const_smul _) (continuous_mul_left _)
| ih x =>
change _ = (↑(algebraMap S (WithVal <| v.valuation K) r) : v.adicCompletion K) * x
norm_cast
rw [← Algebra.smul_def]
theorem coe_smul_adicCompletion (r : S) (x : WithVal (v.valuation K)) :
(↑(r • x) : v.adicCompletion K) = r • (↑x : v.adicCompletion K) :=
UniformSpace.Completion.coe_smul r x
theorem algebraMap_adicCompletion : ⇑(algebraMap S <| v.adicCompletion K) = (↑) ∘ algebraMap S K :=
rfl
end Algebra
theorem coe_algebraMap_mem (r : R) : ↑((algebraMap R K) r) ∈ adicCompletionIntegers K v := by
rw [mem_adicCompletionIntegers, Valued.valuedCompletion_apply]
exact v.valuation_le_one _
instance : Algebra R (v.adicCompletionIntegers K) where
smul r x :=
⟨r • (x : v.adicCompletion K), by
have h :
(algebraMap R (adicCompletion K v)) r = (algebraMap R K r : adicCompletion K v) := rfl
rw [Algebra.smul_def]
refine ValuationSubring.mul_mem _ _ _ ?_ x.2
rw [h]
exact coe_algebraMap_mem _ _ v r⟩
algebraMap :=
{ toFun r :=
⟨(algebraMap R K r : adicCompletion K v), coe_algebraMap_mem _ _ v r⟩
map_one' := by ext; simp
map_mul' x y := by
ext
simp only [map_mul, UniformSpace.Completion.coe_mul, MulMemClass.mk_mul_mk]
map_zero' := by ext; simp
map_add' x y := by
ext
simp only [map_add, UniformSpace.Completion.coe_add, AddMemClass.mk_add_mk] }
commutes' r x := by
rw [mul_comm]
smul_def' r x := by
ext
simp only [Algebra.smul_def]
rfl
@[simp]
lemma algebraMap_adicCompletionIntegers_apply (r : R) :
algebraMap R (v.adicCompletionIntegers K) r = (algebraMap R K r : v.adicCompletion K) :=
rfl
instance [FaithfulSMul R K] : FaithfulSMul R (v.adicCompletionIntegers K) := by
rw [faithfulSMul_iff_algebraMap_injective]
intro x y
simp [Subtype.ext_iff, (FaithfulSMul.algebraMap_injective R K).eq_iff]
variable {R K} in
open scoped algebraMap in -- to make the coercions from `R` fire
/-- The valuation on the completion agrees with the global valuation on elements of the
integer ring. -/
theorem valuedAdicCompletion_eq_valuation (r : R) :
Valued.v (r : v.adicCompletion K) = v.valuation K r := by
convert Valued.valuedCompletion_apply (r : K)
variable {R K} in
/-- The valuation on the completion agrees with the global valuation on elements of the field. -/
theorem valuedAdicCompletion_eq_valuation' (k : K) :
Valued.v (k : v.adicCompletion K) = v.valuation K k := by
convert Valued.valuedCompletion_apply k
variable {R K} in
open scoped algebraMap in -- to make the coercion from `R` fire
/-- A global integer is in the local integers. -/
lemma coe_mem_adicCompletionIntegers (r : R) :
(r : adicCompletion K v) ∈ adicCompletionIntegers K v := by
rw [mem_adicCompletionIntegers, valuedAdicCompletion_eq_valuation]
exact valuation_le_one v r
@[simp]
theorem coe_smul_adicCompletionIntegers (r : R) (x : v.adicCompletionIntegers K) :
(↑(r • x) : v.adicCompletion K) = r • (x : v.adicCompletion K) :=
rfl
instance : NoZeroSMulDivisors R (v.adicCompletionIntegers K) where
eq_zero_or_eq_zero_of_smul_eq_zero {c x} := by simp
instance adicCompletion.instIsScalarTower' :
IsScalarTower R (v.adicCompletionIntegers K) (v.adicCompletion K) where
smul_assoc x y z := by simp only [Algebra.smul_def]; apply mul_assoc
end AlgebraInstances
open nonZeroDivisors algebraMap in
variable {R K} in
lemma adicCompletion.mul_nonZeroDivisor_mem_adicCompletionIntegers (v : HeightOneSpectrum R)
(a : v.adicCompletion K) : ∃ b ∈ R⁰, a * b ∈ v.adicCompletionIntegers K := by
by_cases ha : a ∈ v.adicCompletionIntegers K
· use 1
simp [ha]
· rw [notMem_adicCompletionIntegers] at ha
-- let ϖ be a uniformiser
obtain ⟨ϖ, hϖ⟩ := intValuation_exists_uniformizer v
have : Valued.v (algebraMap R (v.adicCompletion K) ϖ) = (exp (1 : ℤ))⁻¹ := by
simp [valuedAdicCompletion_eq_valuation, valuation_of_algebraMap, hϖ, exp]
have hϖ0 : ϖ ≠ 0 := by rintro rfl; simp [exp_ne_zero.symm] at hϖ
refine ⟨ϖ^(log (Valued.v a)).natAbs, pow_mem (mem_nonZeroDivisors_of_ne_zero hϖ0) _, ?_⟩
-- now manually translate the goal (an inequality in ℤᵐ⁰) to an inequality of "log" of ℤ
simp only [map_pow, mem_adicCompletionIntegers, map_mul, this, inv_pow, ← exp_nsmul, nsmul_one,
Int.natCast_natAbs]
exact mul_inv_le_one_of_le₀ (le_exp_log.trans (by simp [le_abs_self])) (zero_le _)
section AbsoluteValue
open WithZeroMulInt
variable {R K} in
/-- The `v`-adic absolute value function on `K` defined as `b` raised to negative `v`-adic
valuation, for some `b` in `ℝ≥0` -/
def adicAbvDef (v : HeightOneSpectrum R) {b : NNReal} (hb : 1 < b) :=
fun x ↦ toNNReal (ne_zero_of_lt hb) (v.valuation K x)
variable {R K} in
lemma isNonarchimedean_adicAbvDef {b : NNReal} (hb : 1 < b) :
IsNonarchimedean (α := K) (fun x ↦ v.adicAbvDef hb x) := by
intro x y
simp only [adicAbvDef]
have h_mono := (toNNReal_strictMono hb).monotone
rw [← h_mono.map_max]
exact h_mono ((v.valuation _).map_add x y)
variable {R K} in
/-- The `v`-adic absolute value on `K` defined as `b` raised to negative `v`-adic
valuation, for some `b` in `ℝ≥0` -/
def adicAbv (v : HeightOneSpectrum R) {b : NNReal} (hb : 1 < b) : AbsoluteValue K ℝ where
toFun x := v.adicAbvDef hb x
map_mul' _ _ := by simp [adicAbvDef]
nonneg' _ := NNReal.zero_le_coe
eq_zero' _ := by simp [adicAbvDef]
add_le' _ _ := (isNonarchimedean_adicAbvDef v hb).add_le fun _ ↦ bot_le
variable {R K} in
/-- The `v`-adic absolute value is nonarchimedean -/
theorem isNonarchimedean_adicAbv (v : HeightOneSpectrum R) {b : NNReal} (hb : 1 < b) :
IsNonarchimedean (α := K) (v.adicAbv hb) := isNonarchimedean_adicAbvDef v hb
variable {R K} in
theorem adicAbv_coe_le_one {b : NNReal} (hb : 1 < b) (r : R) :
v.adicAbv hb (algebraMap R K r) ≤ 1 := by
simpa [adicAbv, adicAbvDef, toNNReal_le_one_iff hb] using valuation_le_one v r
variable {R K} in
theorem adicAbv_coe_lt_one_iff {b : NNReal} (hb : 1 < b) (r : R) :
v.adicAbv hb (algebraMap R K r) < 1 ↔ r ∈ v.asIdeal := by
simpa [adicAbv, adicAbvDef, toNNReal_lt_one_iff hb] using valuation_lt_one_iff_mem v r
variable {R K} in
theorem adicAbv_coe_eq_one_iff {b : NNReal} (hb : 1 < b) (r : R) :
v.adicAbv hb (algebraMap R K r) = 1 ↔ r ∉ v.asIdeal := by
rw [← not_iff_not, not_not, ← v.adicAbv_coe_lt_one_iff (K := K) hb, ne_iff_lt_iff_le]
exact adicAbv_coe_le_one v hb r
end AbsoluteValue
end IsDedekindDomain.HeightOneSpectrum |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/Factorization.lean | import Mathlib.NumberTheory.RamificationInertia.Basic
import Mathlib.Order.Filter.Cofinite
/-!
# Factorization of ideals and fractional ideals of Dedekind domains
Every nonzero ideal `I` of a Dedekind domain `R` can be factored as a product `∏_v v^{n_v}` over the
maximal ideals of `R`, where the exponents `n_v` are natural numbers.
Similarly, every nonzero fractional ideal `I` of a Dedekind domain `R` can be factored as a product
`∏_v v^{n_v}` over the maximal ideals of `R`, where the exponents `n_v` are integers. We define
`FractionalIdeal.count K v I` (abbreviated as `val_v(I)` in the documentation) to be `n_v`, and we
prove some of its properties. If `I = 0`, we define `val_v(I) = 0`.
## Main definitions
- `FractionalIdeal.count` : If `I` is a nonzero fractional ideal, `a ∈ R`, and `J` is an ideal of
`R` such that `I = a⁻¹J`, then we define `val_v(I)` as `(val_v(J) - val_v(a))`. If `I = 0`, we
set `val_v(I) = 0`.
## Main results
- `Ideal.finite_factors` : Only finitely many maximal ideals of `R` divide a given nonzero ideal.
- `Ideal.finprod_heightOneSpectrum_factorization` : The ideal `I` equals the finprod
`∏_v v^(val_v(I))`, where `val_v(I)` denotes the multiplicity of `v` in the factorization of `I`
and `v` runs over the maximal ideals of `R`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization` : If `I` is a nonzero fractional ideal,
`a ∈ R`, and `J` is an ideal of `R` such that `I = a⁻¹J`, then `I` is equal to the product
`∏_v v^(val_v(J) - val_v(a))`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization'` : If `I` is a nonzero fractional
ideal, then `I` is equal to the product `∏_v v^(val_v(I))`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization_principal` : For a nonzero `k = r/s ∈ K`,
the fractional ideal `(k)` is equal to the product `∏_v v^(val_v(r) - val_v(s))`.
- `FractionalIdeal.finite_factors` : If `I ≠ 0`, then `val_v(I) = 0` for all but finitely many
maximal ideals of `R`.
- `IsDedekindDomain.exists_sup_span_eq`: For every ideals `0 < I ≤ J`,
there exists `a` such that `J = I + ⟨a⟩`.
- `Ideal.map_algebraMap_eq_finset_prod_pow`: if `p` is a maximal ideal, then the lift of `p`
in an extension is the product of the primes over `p` to the power the ramification index.
## Implementation notes
Since we are only interested in the factorization of nonzero fractional ideals, we define
`val_v(0) = 0` so that every `val_v` is in `ℤ` and we can avoid having to use `WithTop ℤ`.
## Tags
dedekind domain, fractional ideal, ideal, factorization
-/
noncomputable section
open scoped nonZeroDivisors
open Set Function UniqueFactorizationMonoid IsDedekindDomain IsDedekindDomain.HeightOneSpectrum
variable {R : Type*} [CommRing R] {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
/-! ### Factorization of ideals of Dedekind domains -/
variable [IsDedekindDomain R] (v : HeightOneSpectrum R)
open scoped Classical in
/-- Given a maximal ideal `v` and an ideal `I` of `R`, `maxPowDividing` returns the maximal
power of `v` dividing `I`. -/
def IsDedekindDomain.HeightOneSpectrum.maxPowDividing (I : Ideal R) : Ideal R :=
v.asIdeal ^ (Associates.mk v.asIdeal).count (Associates.mk I).factors
open Associates in
theorem IsDedekindDomain.HeightOneSpectrum.maxPowDividing_eq_pow_multiset_count
[DecidableEq (Ideal R)] {I : Ideal R} (hI : I ≠ 0) :
maxPowDividing v I =
v.asIdeal ^ Multiset.count v.asIdeal (normalizedFactors I) := by
classical
rw [maxPowDividing, factors_mk _ hI, count_some (irreducible_mk.mpr v.irreducible),
← Multiset.count_map_eq_count' _ _ Subtype.val_injective, map_subtype_coe_factors',
factors_eq_normalizedFactors, ← Multiset.count_map_eq_count' _ _ (mk_injective (M := Ideal R))]
/-- Only finitely many maximal ideals of `R` divide a given nonzero ideal. -/
theorem Ideal.finite_factors {I : Ideal R} (hI : I ≠ 0) :
{v : HeightOneSpectrum R | v.asIdeal ∣ I}.Finite := by
rw [← Set.finite_coe_iff, Set.coe_setOf]
haveI h_fin := fintypeSubtypeDvd I hI
refine
Finite.of_injective (fun v => (⟨(v : HeightOneSpectrum R).asIdeal, v.2⟩ : { x // x ∣ I })) ?_
intro v w hvw
exact Subtype.coe_injective (HeightOneSpectrum.ext (by simpa using hvw))
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that the
multiplicity of `v` in the factorization of `I`, denoted `val_v(I)`, is nonzero. -/
theorem Associates.finite_factors {I : Ideal R} (hI : I ≠ 0) :
∀ᶠ v : HeightOneSpectrum R in Filter.cofinite,
((Associates.mk v.asIdeal).count (Associates.mk I).factors : ℤ) = 0 := by
have h_supp : {v : HeightOneSpectrum R | ¬((Associates.mk v.asIdeal).count
(Associates.mk I).factors : ℤ) = 0} = {v : HeightOneSpectrum R | v.asIdeal ∣ I} := by
ext v
simp_rw [Int.natCast_eq_zero]
exact Associates.count_ne_zero_iff_dvd hI v.irreducible
rw [Filter.eventually_cofinite, h_supp]
exact Ideal.finite_factors hI
namespace Ideal
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that
`v^(val_v(I))` is not the unit ideal. -/
theorem finite_mulSupport {I : Ideal R} (hI : I ≠ 0) :
(mulSupport fun v : HeightOneSpectrum R => v.maxPowDividing I).Finite :=
haveI h_subset : {v : HeightOneSpectrum R | v.maxPowDividing I ≠ 1} ⊆
{v : HeightOneSpectrum R |
((Associates.mk v.asIdeal).count (Associates.mk I).factors : ℤ) ≠ 0} := by
intro v hv h_zero
have hv' : v.maxPowDividing I = 1 := by
rw [IsDedekindDomain.HeightOneSpectrum.maxPowDividing, Int.natCast_eq_zero.mp h_zero,
pow_zero _]
exact hv hv'
Finite.subset (Filter.eventually_cofinite.mp (Associates.finite_factors hI)) h_subset
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that
`v^(val_v(I))`, regarded as a fractional ideal, is not `(1)`. -/
theorem finite_mulSupport_coe {I : Ideal R} (hI : I ≠ 0) :
(mulSupport fun v : HeightOneSpectrum R => (v.asIdeal : FractionalIdeal R⁰ K) ^
((Associates.mk v.asIdeal).count (Associates.mk I).factors : ℤ)).Finite := by
rw [mulSupport]
simp_rw [Ne, zpow_natCast, ← FractionalIdeal.coeIdeal_pow, FractionalIdeal.coeIdeal_eq_one]
exact finite_mulSupport hI
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that
`v^-(val_v(I))` is not the unit ideal. -/
theorem finite_mulSupport_inv {I : Ideal R} (hI : I ≠ 0) :
(mulSupport fun v : HeightOneSpectrum R => (v.asIdeal : FractionalIdeal R⁰ K) ^
(-((Associates.mk v.asIdeal).count (Associates.mk I).factors : ℤ))).Finite := by
rw [mulSupport]
simp_rw [zpow_neg, Ne, inv_eq_one]
exact finite_mulSupport_coe hI
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, `v^(val_v(I) + 1)` does not divide `∏_v v^(val_v(I))`. -/
theorem finprod_not_dvd (I : Ideal R) (hI : I ≠ 0) :
¬v.asIdeal ^ ((Associates.mk v.asIdeal).count (Associates.mk I).factors + 1) ∣
∏ᶠ v : HeightOneSpectrum R, v.maxPowDividing I := by
have hf := finite_mulSupport hI
have h_ne_zero : v.maxPowDividing I ≠ 0 := pow_ne_zero _ v.ne_bot
rw [← mul_finprod_cond_ne v hf, pow_add, pow_one, finprod_cond_ne _ _ hf]
intro h_contr
have hv_prime : Prime v.asIdeal := Ideal.prime_of_isPrime v.ne_bot v.isPrime
obtain ⟨w, hw, hvw'⟩ :=
Prime.exists_mem_finset_dvd hv_prime ((mul_dvd_mul_iff_left h_ne_zero).mp h_contr)
have hw_prime : Prime w.asIdeal := Ideal.prime_of_isPrime w.ne_bot w.isPrime
have hvw := Prime.dvd_of_dvd_pow hv_prime hvw'
rw [Prime.dvd_prime_iff_associated hv_prime hw_prime, associated_iff_eq] at hvw
exact (Finset.mem_erase.mp hw).1 (HeightOneSpectrum.ext hvw.symm)
end Ideal
theorem Associates.finprod_ne_zero (I : Ideal R) :
Associates.mk (∏ᶠ v : HeightOneSpectrum R, v.maxPowDividing I) ≠ 0 := by
classical
rw [Associates.mk_ne_zero, finprod_def]
split_ifs
· rw [Finset.prod_ne_zero_iff]
intro v _
apply pow_ne_zero _ v.ne_bot
· exact one_ne_zero
namespace Ideal
open scoped Classical in
/-- The multiplicity of `v` in `∏_v v^(val_v(I))` equals `val_v(I)`. -/
theorem finprod_count (I : Ideal R) (hI : I ≠ 0) : (Associates.mk v.asIdeal).count
(Associates.mk (∏ᶠ v : HeightOneSpectrum R, v.maxPowDividing I)).factors =
(Associates.mk v.asIdeal).count (Associates.mk I).factors := by
have h_ne_zero := Associates.finprod_ne_zero I
have hv : Irreducible (Associates.mk v.asIdeal) := v.associates_irreducible
have h_dvd := finprod_mem_dvd v (Ideal.finite_mulSupport hI)
have h_not_dvd := Ideal.finprod_not_dvd v I hI
simp only [IsDedekindDomain.HeightOneSpectrum.maxPowDividing] at h_dvd h_ne_zero h_not_dvd
rw [← Associates.mk_dvd_mk] at h_dvd h_not_dvd
simp only [Associates.dvd_eq_le] at h_dvd h_not_dvd
rw [Associates.mk_pow, Associates.prime_pow_dvd_iff_le h_ne_zero hv] at h_dvd h_not_dvd
rw [not_le] at h_not_dvd
apply Nat.eq_of_le_of_lt_succ h_dvd h_not_dvd
/-- The ideal `I` equals the finprod `∏_v v^(val_v(I))`. -/
theorem finprod_heightOneSpectrum_factorization {I : Ideal R} (hI : I ≠ 0) :
∏ᶠ v : HeightOneSpectrum R, v.maxPowDividing I = I := by
rw [← associated_iff_eq, ← Associates.mk_eq_mk_iff_associated]
classical
apply Associates.eq_of_eq_counts
· apply Associates.finprod_ne_zero I
· apply Associates.mk_ne_zero.mpr hI
intro v hv
obtain ⟨J, hJv⟩ := Associates.exists_rep v
rw [← hJv, Associates.irreducible_mk] at hv
rw [← hJv]
apply Ideal.finprod_count
⟨J, Ideal.isPrime_of_prime (irreducible_iff_prime.mp hv), Irreducible.ne_zero hv⟩ I hI
variable (K)
open scoped Classical in
/-- The ideal `I` equals the finprod `∏_v v^(val_v(I))`, when both sides are regarded as fractional
ideals of `R`. -/
theorem finprod_heightOneSpectrum_factorization_coe {I : Ideal R} (hI : I ≠ 0) :
(∏ᶠ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal R⁰ K) ^
((Associates.mk v.asIdeal).count (Associates.mk I).factors : ℤ)) = I := by
conv_rhs => rw [← Ideal.finprod_heightOneSpectrum_factorization hI]
rw [FractionalIdeal.coeIdeal_finprod R⁰ K (le_refl _)]
simp_rw [IsDedekindDomain.HeightOneSpectrum.maxPowDividing, FractionalIdeal.coeIdeal_pow,
zpow_natCast]
end Ideal
/-! ### Factorization of fractional ideals of Dedekind domains -/
namespace FractionalIdeal
open Int IsLocalization
open scoped Classical in
/-- If `I` is a nonzero fractional ideal, `a ∈ R`, and `J` is an ideal of `R` such that
`I = a⁻¹J`, then `I` is equal to the product `∏_v v^(val_v(J) - val_v(a))`. -/
theorem finprod_heightOneSpectrum_factorization {I : FractionalIdeal R⁰ K} (hI : I ≠ 0) {a : R}
{J : Ideal R} (haJ : I = spanSingleton R⁰ ((algebraMap R K) a)⁻¹ * ↑J) :
∏ᶠ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal R⁰ K) ^
((Associates.mk v.asIdeal).count (Associates.mk J).factors -
(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors : ℤ) = I := by
have hJ_ne_zero : J ≠ 0 := ideal_factor_ne_zero hI haJ
have hJ := Ideal.finprod_heightOneSpectrum_factorization_coe K hJ_ne_zero
have ha_ne_zero : Ideal.span {a} ≠ 0 := constant_factor_ne_zero hI haJ
have ha := Ideal.finprod_heightOneSpectrum_factorization_coe K ha_ne_zero
rw [haJ, ← div_spanSingleton, div_eq_mul_inv, ← coeIdeal_span_singleton, ← hJ, ← ha,
← finprod_inv_distrib]
simp_rw [← zpow_neg]
rw [← finprod_mul_distrib (Ideal.finite_mulSupport_coe hJ_ne_zero)
(Ideal.finite_mulSupport_inv ha_ne_zero)]
apply finprod_congr
intro v
rw [← zpow_add₀ ((@coeIdeal_ne_zero R _ K _ _ _ _).mpr v.ne_bot), sub_eq_add_neg]
open scoped Classical in
/-- For a nonzero `k = r/s ∈ K`, the fractional ideal `(k)` is equal to the product
`∏_v v^(val_v(r) - val_v(s))`. -/
theorem finprod_heightOneSpectrum_factorization_principal_fraction {n : R} (hn : n ≠ 0) (d : ↥R⁰) :
∏ᶠ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal R⁰ K) ^
((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {n} : Ideal R)).factors -
(Associates.mk v.asIdeal).count (Associates.mk ((Ideal.span {(↑d : R)}) :
Ideal R)).factors : ℤ) = spanSingleton R⁰ (mk' K n d) := by
have hd_ne_zero : (algebraMap R K) (d : R) ≠ 0 :=
map_ne_zero_of_mem_nonZeroDivisors _ (IsFractionRing.injective R K) d.property
have h0 : spanSingleton R⁰ (mk' K n d) ≠ 0 := by
rw [spanSingleton_ne_zero_iff, IsFractionRing.mk'_eq_div, ne_eq, div_eq_zero_iff, not_or]
exact ⟨(map_ne_zero_iff (algebraMap R K) (IsFractionRing.injective R K)).mpr hn, hd_ne_zero⟩
have hI : spanSingleton R⁰ (mk' K n d) =
spanSingleton R⁰ ((algebraMap R K) d)⁻¹ * ↑(Ideal.span {n} : Ideal R) := by
rw [coeIdeal_span_singleton, spanSingleton_mul_spanSingleton]
apply congr_arg
rw [IsFractionRing.mk'_eq_div, div_eq_mul_inv, mul_comm]
exact finprod_heightOneSpectrum_factorization h0 hI
open Classical in
/-- For a nonzero `k = r/s ∈ K`, the fractional ideal `(k)` is equal to the product
`∏_v v^(val_v(r) - val_v(s))`. -/
theorem finprod_heightOneSpectrum_factorization_principal {I : FractionalIdeal R⁰ K} (hI : I ≠ 0)
(k : K) (hk : I = spanSingleton R⁰ k) :
∏ᶠ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal R⁰ K) ^
((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {choose
(exists_mk'_eq R⁰ k)} : Ideal R)).factors -
(Associates.mk v.asIdeal).count (Associates.mk ((Ideal.span {(↑(choose
(choose_spec (exists_mk'_eq R⁰ k)) : ↥R⁰) : R)}) : Ideal R)).factors : ℤ) = I := by
set n : R := choose (exists_mk'_eq R⁰ k)
set d : ↥R⁰ := choose (choose_spec (exists_mk'_eq R⁰ k))
have hnd : mk' K n d = k := choose_spec (choose_spec (exists_mk'_eq R⁰ k))
have hn0 : n ≠ 0 := by
by_contra h
rw [← hnd, h, IsFractionRing.mk'_eq_div, map_zero, zero_div, spanSingleton_zero] at hk
exact hI hk
rw [finprod_heightOneSpectrum_factorization_principal_fraction hn0 d, hk, hnd]
variable (K)
open Classical in
/-- If `I` is a nonzero fractional ideal, `a ∈ R`, and `J` is an ideal of `R` such that `I = a⁻¹J`,
then we define `val_v(I)` as `(val_v(J) - val_v(a))`. If `I = 0`, we set `val_v(I) = 0`. -/
def count (I : FractionalIdeal R⁰ K) : ℤ :=
dite (I = 0) (fun _ : I = 0 => 0) fun _ : ¬I = 0 =>
let a := choose (exists_eq_spanSingleton_mul I)
let J := choose (choose_spec (exists_eq_spanSingleton_mul I))
((Associates.mk v.asIdeal).count (Associates.mk J).factors -
(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors : ℤ)
/-- val_v(0) = 0. -/
lemma count_zero : count K v (0 : FractionalIdeal R⁰ K) = 0 := by simp only [count, dif_pos]
open Classical in
lemma count_ne_zero {I : FractionalIdeal R⁰ K} (hI : I ≠ 0) :
count K v I = ((Associates.mk v.asIdeal).count (Associates.mk
(choose (choose_spec (exists_eq_spanSingleton_mul I)))).factors -
(Associates.mk v.asIdeal).count
(Associates.mk (Ideal.span {choose (exists_eq_spanSingleton_mul I)})).factors : ℤ) := by
simp only [count, dif_neg hI]
open Classical in
/-- `val_v(I)` does not depend on the choice of `a` and `J` used to represent `I`. -/
theorem count_well_defined {I : FractionalIdeal R⁰ K} (hI : I ≠ 0) {a : R}
{J : Ideal R} (h_aJ : I = spanSingleton R⁰ ((algebraMap R K) a)⁻¹ * ↑J) :
count K v I = ((Associates.mk v.asIdeal).count (Associates.mk J).factors -
(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors : ℤ) := by
set a₁ := choose (exists_eq_spanSingleton_mul I)
set J₁ := choose (choose_spec (exists_eq_spanSingleton_mul I))
have h_a₁J₁ : I = spanSingleton R⁰ ((algebraMap R K) a₁)⁻¹ * ↑J₁ :=
(choose_spec (choose_spec (exists_eq_spanSingleton_mul I))).2
have h_a₁_ne_zero : a₁ ≠ 0 := (choose_spec (choose_spec (exists_eq_spanSingleton_mul I))).1
have h_J₁_ne_zero : J₁ ≠ 0 := ideal_factor_ne_zero hI h_a₁J₁
have h_a_ne_zero : Ideal.span {a} ≠ 0 := constant_factor_ne_zero hI h_aJ
have h_J_ne_zero : J ≠ 0 := ideal_factor_ne_zero hI h_aJ
have h_a₁' : spanSingleton R⁰ ((algebraMap R K) a₁) ≠ 0 := by
rw [ne_eq, spanSingleton_eq_zero_iff, ← (algebraMap R K).map_zero,
Injective.eq_iff (IsLocalization.injective K (le_refl R⁰))]
exact h_a₁_ne_zero
have h_a' : spanSingleton R⁰ ((algebraMap R K) a) ≠ 0 := by
rw [ne_eq, spanSingleton_eq_zero_iff, ← (algebraMap R K).map_zero,
Injective.eq_iff (IsLocalization.injective K (le_refl R⁰))]
rw [ne_eq, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot] at h_a_ne_zero
exact h_a_ne_zero
have hv : Irreducible (Associates.mk v.asIdeal) := by
exact Associates.irreducible_mk.mpr v.irreducible
rw [h_a₁J₁, ← div_spanSingleton, ← div_spanSingleton, div_eq_div_iff h_a₁' h_a',
← coeIdeal_span_singleton, ← coeIdeal_span_singleton, ← coeIdeal_mul, ← coeIdeal_mul] at h_aJ
rw [count, dif_neg hI, sub_eq_sub_iff_add_eq_add, ← natCast_add, ← natCast_add, natCast_inj,
← Associates.count_mul _ _ hv, ← Associates.count_mul _ _ hv, Associates.mk_mul_mk,
Associates.mk_mul_mk, coeIdeal_injective h_aJ]
· rw [ne_eq, Associates.mk_eq_zero]; exact h_J_ne_zero
· rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]
exact h_a₁_ne_zero
· rw [ne_eq, Associates.mk_eq_zero]; exact h_J₁_ne_zero
· rw [ne_eq, Associates.mk_eq_zero]; exact h_a_ne_zero
/-- For nonzero `I, I'`, `val_v(I*I') = val_v(I) + val_v(I')`. -/
theorem count_mul {I I' : FractionalIdeal R⁰ K} (hI : I ≠ 0) (hI' : I' ≠ 0) :
count K v (I * I') = count K v I + count K v I' := by
classical
have hv : Irreducible (Associates.mk v.asIdeal) := by apply v.associates_irreducible
obtain ⟨a, J, ha, haJ⟩ := exists_eq_spanSingleton_mul I
have ha_ne_zero : Associates.mk (Ideal.span {a} : Ideal R) ≠ 0 := by
rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]; exact ha
have hJ_ne_zero : Associates.mk J ≠ 0 := Associates.mk_ne_zero.mpr (ideal_factor_ne_zero hI haJ)
obtain ⟨a', J', ha', haJ'⟩ := exists_eq_spanSingleton_mul I'
have ha'_ne_zero : Associates.mk (Ideal.span {a'} : Ideal R) ≠ 0 := by
rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]; exact ha'
have hJ'_ne_zero : Associates.mk J' ≠ 0 :=
Associates.mk_ne_zero.mpr (ideal_factor_ne_zero hI' haJ')
have h_prod : I * I' = spanSingleton R⁰ ((algebraMap R K) (a * a'))⁻¹ * ↑(J * J') := by
rw [haJ, haJ', mul_assoc, mul_comm (J : FractionalIdeal R⁰ K), mul_assoc, ← mul_assoc,
spanSingleton_mul_spanSingleton, coeIdeal_mul, RingHom.map_mul, mul_inv,
mul_comm (J : FractionalIdeal R⁰ K)]
rw [count_well_defined K v hI haJ, count_well_defined K v hI' haJ',
count_well_defined K v (mul_ne_zero hI hI') h_prod, ← Associates.mk_mul_mk,
Associates.count_mul hJ_ne_zero hJ'_ne_zero hv, ← Ideal.span_singleton_mul_span_singleton,
← Associates.mk_mul_mk, Associates.count_mul ha_ne_zero ha'_ne_zero hv]
push_cast
ring
/-- For nonzero `I, I'`, `val_v(I*I') = val_v(I) + val_v(I')`. If `I` or `I'` is zero, then
`val_v(I*I') = 0`. -/
theorem count_mul' (I I' : FractionalIdeal R⁰ K) [Decidable (I ≠ 0 ∧ I' ≠ 0)] :
count K v (I * I') = if I ≠ 0 ∧ I' ≠ 0 then count K v I + count K v I' else 0 := by
split_ifs with h
· exact count_mul K v h.1 h.2
· rw [← mul_ne_zero_iff, not_ne_iff] at h
rw [h, count_zero]
/-- val_v(1) = 0. -/
theorem count_one : count K v (1 : FractionalIdeal R⁰ K) = 0 := by
have h1 : (1 : FractionalIdeal R⁰ K) =
spanSingleton R⁰ ((algebraMap R K) 1)⁻¹ * ↑(1 : Ideal R) := by
rw [(algebraMap R K).map_one, Ideal.one_eq_top, coeIdeal_top, mul_one, inv_one,
spanSingleton_one]
rw [count_well_defined K v one_ne_zero h1, Ideal.span_singleton_one, Ideal.one_eq_top, sub_self]
theorem count_prod {ι} (s : Finset ι) (I : ι → FractionalIdeal R⁰ K) (hS : ∀ i ∈ s, I i ≠ 0) :
count K v (∏ i ∈ s, I i) = ∑ i ∈ s, count K v (I i) := by
classical
induction s using Finset.induction with
| empty => rw [Finset.prod_empty, Finset.sum_empty, count_one]
| insert i s hi hrec =>
have hS' : ∀ i ∈ s, I i ≠ 0 := fun j hj => hS j (Finset.mem_insert_of_mem hj)
have hS0 : ∏ i ∈ s, I i ≠ 0 := Finset.prod_ne_zero_iff.mpr hS'
have hi0 : I i ≠ 0 := hS i (Finset.mem_insert_self i s)
rw [Finset.prod_insert hi, Finset.sum_insert hi, count_mul K v hi0 hS0, hrec hS']
/-- For every `n ∈ ℕ` and every ideal `I`, `val_v(I^n) = n*val_v(I)`. -/
theorem count_pow (n : ℕ) (I : FractionalIdeal R⁰ K) :
count K v (I ^ n) = n * count K v I := by
induction n with
| zero => rw [pow_zero, ofNat_zero, zero_mul, count_one]
| succ n h =>
classical rw [pow_succ, count_mul']
by_cases hI : I = 0
· have h_neg : ¬(I ^ n ≠ 0 ∧ I ≠ 0) := by order
rw [if_neg h_neg, hI, count_zero, mul_zero]
· rw [if_pos (And.intro (pow_ne_zero n hI) hI), h, Nat.cast_add,
Nat.cast_one]
ring
/-- `val_v(v) = 1`, when `v` is regarded as a fractional ideal. -/
theorem count_self : count K v (v.asIdeal : FractionalIdeal R⁰ K) = 1 := by
have hv : (v.asIdeal : FractionalIdeal R⁰ K) ≠ 0 := coeIdeal_ne_zero.mpr v.ne_bot
have h_self : (v.asIdeal : FractionalIdeal R⁰ K) =
spanSingleton R⁰ ((algebraMap R K) 1)⁻¹ * ↑v.asIdeal := by
rw [(algebraMap R K).map_one, inv_one, spanSingleton_one, one_mul]
have hv_irred : Irreducible (Associates.mk v.asIdeal) := by apply v.associates_irreducible
classical rw [count_well_defined K v hv h_self, Associates.count_self hv_irred,
Ideal.span_singleton_one, ← Ideal.one_eq_top, Associates.mk_one, Associates.factors_one,
Associates.count_zero hv_irred, ofNat_zero, sub_zero, ofNat_one]
/-- `val_v(v^n) = n` for every `n ∈ ℕ`. -/
theorem count_pow_self (n : ℕ) :
count K v ((v.asIdeal : FractionalIdeal R⁰ K) ^ n) = n := by
rw [count_pow, count_self, mul_one]
/-- `val_v(I⁻ⁿ) = -val_v(Iⁿ)` for every `n ∈ ℤ`. -/
theorem count_neg_zpow (n : ℤ) (I : FractionalIdeal R⁰ K) :
count K v (I ^ (-n)) = -count K v (I ^ n) := by
by_cases hI : I = 0
· by_cases hn : n = 0
· rw [hn, neg_zero, zpow_zero, count_one, neg_zero]
· rw [hI, zero_zpow n hn, zero_zpow (-n) (neg_ne_zero.mpr hn), count_zero, neg_zero]
· rw [eq_neg_iff_add_eq_zero, ← count_mul K v (zpow_ne_zero _ hI) (zpow_ne_zero _ hI),
← zpow_add₀ hI, neg_add_cancel, zpow_zero]
exact count_one K v
theorem count_inv (I : FractionalIdeal R⁰ K) :
count K v (I⁻¹) = -count K v I := by
rw [← zpow_neg_one, count_neg_zpow K v (1 : ℤ) I, zpow_one]
/-- `val_v(Iⁿ) = n*val_v(I)` for every `n ∈ ℤ`. -/
theorem count_zpow (n : ℤ) (I : FractionalIdeal R⁰ K) :
count K v (I ^ n) = n * count K v I := by
obtain n | n := n
· rw [ofNat_eq_coe, zpow_natCast]
exact count_pow K v n I
· rw [negSucc_eq, count_neg_zpow, ← Int.natCast_succ, zpow_natCast, count_pow]
ring
/-- `val_v(v^n) = n` for every `n ∈ ℤ`. -/
theorem count_zpow_self (n : ℤ) :
count K v ((v.asIdeal : FractionalIdeal R⁰ K) ^ n) = n := by
rw [count_zpow, count_self, mul_one]
/-- If `v ≠ w` are two maximal ideals of `R`, then `val_v(w) = 0`. -/
theorem count_maximal_coprime {w : HeightOneSpectrum R} (hw : w ≠ v) :
count K v (w.asIdeal : FractionalIdeal R⁰ K) = 0 := by
have hw_fact : (w.asIdeal : FractionalIdeal R⁰ K) =
spanSingleton R⁰ ((algebraMap R K) 1)⁻¹ * ↑w.asIdeal := by
rw [(algebraMap R K).map_one, inv_one, spanSingleton_one, one_mul]
have hw_ne_zero : (w.asIdeal : FractionalIdeal R⁰ K) ≠ 0 :=
coeIdeal_ne_zero.mpr w.ne_bot
have hv : Irreducible (Associates.mk v.asIdeal) := by apply v.associates_irreducible
have hw' : Irreducible (Associates.mk w.asIdeal) := by apply w.associates_irreducible
classical
rw [count_well_defined K v hw_ne_zero hw_fact, Ideal.span_singleton_one, ← Ideal.one_eq_top,
Associates.mk_one, Associates.factors_one, Associates.count_zero hv, ofNat_zero, sub_zero,
natCast_eq_zero, ← pow_one (Associates.mk w.asIdeal), Associates.factors_prime_pow hw',
Associates.count_some hv, Multiset.replicate_one, Multiset.count_eq_zero,
Multiset.mem_singleton]
simp only [Subtype.mk.injEq]
rw [Associates.mk_eq_mk_iff_associated, associated_iff_eq, ← HeightOneSpectrum.ext_iff]
exact Ne.symm hw
theorem count_maximal (w : HeightOneSpectrum R) [Decidable (w = v)] :
count K v (w.asIdeal : FractionalIdeal R⁰ K) = if w = v then 1 else 0 := by
split_ifs with h
· rw [h, count_self]
· exact count_maximal_coprime K v h
/-- `val_v(∏_{w ≠ v} w^{exps w}) = 0`. -/
theorem count_finprod_coprime (exps : HeightOneSpectrum R → ℤ) :
count K v (∏ᶠ (w : HeightOneSpectrum R) (_ : w ≠ v),
(w.asIdeal : (FractionalIdeal R⁰ K)) ^ exps w) = 0 := by
apply finprod_mem_induction fun I => count K v I = 0
· exact count_one K v
· intro I I' hI hI'
classical
by_cases h : I ≠ 0 ∧ I' ≠ 0
· rw [count_mul' K v, if_pos h, hI, hI', add_zero]
· rw [count_mul' K v, if_neg h]
· intro w hw
rw [count_zpow, count_maximal_coprime K v hw, mul_zero]
theorem count_finsuppProd (exps : HeightOneSpectrum R →₀ ℤ) :
count K v (exps.prod (HeightOneSpectrum.asIdeal · ^ ·)) = exps v := by
rw [Finsupp.prod, count_prod]
· classical simp only [count_zpow, count_maximal, mul_ite, mul_one, mul_zero, Finset.sum_ite_eq',
exps.mem_support_iff, ne_eq, ite_not, ite_eq_right_iff, @eq_comm ℤ 0, imp_self]
· exact fun v hv ↦ zpow_ne_zero _ (coeIdeal_ne_zero.mpr v.ne_bot)
/-- If `exps` is finitely supported, then `val_v(∏_w w^{exps w}) = exps v`. -/
theorem count_finprod (exps : HeightOneSpectrum R → ℤ)
(h_exps : ∀ᶠ v : HeightOneSpectrum R in Filter.cofinite, exps v = 0) :
count K v (∏ᶠ v : HeightOneSpectrum R,
(v.asIdeal : FractionalIdeal R⁰ K) ^ exps v) = exps v := by
convert count_finsuppProd K v (Finsupp.mk h_exps.toFinset exps (fun _ ↦ h_exps.mem_toFinset))
rw [finprod_eq_finset_prod_of_mulSupport_subset (s := h_exps.toFinset), Finsupp.prod]
· rfl
· rw [Finite.coe_toFinset]
intro v hv h
rw [mem_mulSupport, h, zpow_zero] at hv
exact hv (Eq.refl 1)
open scoped Classical in
theorem count_coe {J : Ideal R} (hJ : J ≠ 0) :
count K v J = (Associates.mk v.asIdeal).count (Associates.mk J).factors := by
rw [count_well_defined K (J := J) (a := 1), Ideal.span_singleton_one, sub_eq_self,
Nat.cast_eq_zero, ← Ideal.one_eq_top, Associates.mk_one, Associates.factors_one,
Associates.count_zero v.associates_irreducible]
· simpa only [ne_eq, coeIdeal_eq_zero]
· simp only [map_one, inv_one, spanSingleton_one, one_mul]
theorem count_coe_nonneg (J : Ideal R) : 0 ≤ count K v J := by
by_cases hJ : J = 0
· simp only [hJ, Submodule.zero_eq_bot, coeIdeal_bot, count_zero, le_refl]
· classical simp only [count_coe K v hJ, Nat.cast_nonneg]
theorem count_mono {I J} (hI : I ≠ 0) (h : I ≤ J) : count K v J ≤ count K v I := by
by_cases hJ : J = 0
· exact (hI (FractionalIdeal.le_zero_iff.mp (h.trans hJ.le))).elim
have := mul_le_mul_left' h J⁻¹
rw [inv_mul_cancel₀ hJ, FractionalIdeal.le_one_iff_exists_coeIdeal] at this
obtain ⟨J', hJ'⟩ := this
rw [← mul_inv_cancel_left₀ hJ I, ← hJ', count_mul K v hJ, le_add_iff_nonneg_right]
· exact count_coe_nonneg K v J'
· exact hJ' ▸ mul_ne_zero (inv_ne_zero hJ) hI
/-- If `I` is a nonzero fractional ideal, then `I` is equal to the product `∏_v v^(count K v I)`. -/
theorem finprod_heightOneSpectrum_factorization' {I : FractionalIdeal R⁰ K} (hI : I ≠ 0) :
∏ᶠ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal R⁰ K) ^ (count K v I) = I := by
have h := (Classical.choose_spec (Classical.choose_spec (exists_eq_spanSingleton_mul I))).2
conv_rhs => rw [← finprod_heightOneSpectrum_factorization hI h]
apply finprod_congr
intro w
apply congr_arg
rw [count_ne_zero K w hI]
variable {K}
open scoped Classical in
/-- If `I ≠ 0`, then `val_v(I) = 0` for all but finitely many maximal ideals of `R`. -/
theorem finite_factors' {I : FractionalIdeal R⁰ K} (hI : I ≠ 0) {a : R}
{J : Ideal R} (haJ : I = spanSingleton R⁰ ((algebraMap R K) a)⁻¹ * ↑J) :
∀ᶠ v : HeightOneSpectrum R in Filter.cofinite,
((Associates.mk v.asIdeal).count (Associates.mk J).factors : ℤ) -
(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors = 0 := by
have ha_ne_zero : Ideal.span {a} ≠ 0 := constant_factor_ne_zero hI haJ
have hJ_ne_zero : J ≠ 0 := ideal_factor_ne_zero hI haJ
have h_subset :
{v : HeightOneSpectrum R | ¬((Associates.mk v.asIdeal).count (Associates.mk J).factors : ℤ) -
↑((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors) = 0} ⊆
{v : HeightOneSpectrum R | v.asIdeal ∣ J} ∪
{v : HeightOneSpectrum R | v.asIdeal ∣ Ideal.span {a}} := by
intro v hv
have hv_irred : Irreducible v.asIdeal := v.irreducible
by_contra h_notMem
rw [mem_union, mem_setOf_eq, mem_setOf_eq] at h_notMem
push_neg at h_notMem
rw [← Associates.count_ne_zero_iff_dvd ha_ne_zero hv_irred, not_not,
← Associates.count_ne_zero_iff_dvd hJ_ne_zero hv_irred, not_not] at h_notMem
rw [mem_setOf_eq, h_notMem.1, h_notMem.2, sub_self] at hv
exact hv (Eq.refl 0)
exact Finite.subset (Finite.union (Ideal.finite_factors (ideal_factor_ne_zero hI haJ))
(Ideal.finite_factors (constant_factor_ne_zero hI haJ))) h_subset
open Classical in
/-- `val_v(I) = 0` for all but finitely many maximal ideals of `R`. -/
theorem finite_factors (I : FractionalIdeal R⁰ K) :
∀ᶠ v : HeightOneSpectrum R in Filter.cofinite, count K v I = 0 := by
by_cases hI : I = 0
· simp only [hI, count_zero, Filter.eventually_cofinite, not_true_eq_false, setOf_false,
finite_empty]
· convert finite_factors' hI (choose_spec (choose_spec (exists_eq_spanSingleton_mul I))).2
rw [count_ne_zero K _ hI]
end FractionalIdeal
section div
/-- In a Dedekind domain, for every ideals `0 < I ≤ J` there exists `a` such that `J = I + ⟨a⟩`.
TODO: Show that this property uniquely characterizes Dedekind domains. -/
lemma IsDedekindDomain.exists_sup_span_eq {I J : Ideal R} (hIJ : I ≤ J) (hI : I ≠ 0) :
∃ a, I ⊔ Ideal.span {a} = J := by
classical
obtain ⟨I, rfl⟩ := Ideal.dvd_iff_le.mpr hIJ
simp only [ne_eq, mul_eq_zero, not_or] at hI
obtain ⟨hJ, hI⟩ := hI
suffices ∃ a, ∃ K, J * K = Ideal.span {a} ∧ I + K = ⊤ by
obtain ⟨a, K, e, e'⟩ := this
exact ⟨a, by rw [← e, ← Ideal.add_eq_sup, ← mul_add, e', Ideal.mul_top]⟩
let s := (I.finite_factors hI).toFinset
have : ∀ p ∈ s, J * ∏ q ∈ s, q.asIdeal < J * ∏ q ∈ s \ {p}, q.asIdeal := by
intro p hps
conv_rhs => rw [← mul_one (J * _)]
rw [Finset.prod_eq_mul_prod_diff_singleton hps, ← mul_assoc,
mul_right_comm _ p.asIdeal]
refine mul_lt_mul_of_pos_left ?_ ?_
· rw [Ideal.one_eq_top, lt_top_iff_ne_top]
exact p.2.ne_top
· rw [Ideal.zero_eq_bot, bot_lt_iff_ne_bot, ← Ideal.zero_eq_bot,
mul_ne_zero_iff, Finset.prod_ne_zero_iff]
exact ⟨hJ, fun x _ ↦ x.3⟩
choose! a ha ha' using fun p hps ↦ SetLike.exists_of_lt (this p hps)
obtain ⟨K, hK⟩ : J ∣ Ideal.span {∑ p ∈ s, a p} := by
rw [Ideal.dvd_iff_le, Ideal.span_singleton_le_iff_mem]
exact sum_mem fun p hp ↦ Ideal.mul_le_right (ha p hp)
refine ⟨_, _, hK.symm, ?_⟩
by_contra H
obtain ⟨p, hp, h⟩ := Ideal.exists_le_maximal _ H
let p' : HeightOneSpectrum R := ⟨p, hp.isPrime, fun e ↦ hI (by simp_all)⟩
have hp's : p' ∈ s := by simpa [p', s, Ideal.dvd_iff_le] using le_sup_left.trans h
have H₁ : J * K ≤ J * p := Ideal.mul_mono_right (le_sup_right.trans h)
replace H₁ := hK.trans_le H₁ (Ideal.mem_span_singleton_self _)
have H₂ : ∑ q ∈ s \ {p'}, a q ∈ J * p := by
refine sum_mem fun q hq ↦ ?_
rw [Finset.mem_sdiff, Finset.mem_singleton] at hq
refine Ideal.mul_mono_right ?_ (ha q hq.1)
exact Ideal.prod_le_inf.trans (Finset.inf_le (b := p') (by simpa [hp's] using Ne.symm hq.2))
apply ha' _ hp's
have := IsDedekindDomain.inf_prime_pow_eq_prod s (fun i ↦ i.asIdeal) (fun _ ↦ 1)
(fun i _ ↦ i.prime) (fun i _ j _ e ↦ mt HeightOneSpectrum.ext e)
simp only [pow_one] at this
have inst : Nonempty {x // x ∈ s} := ⟨_, hp's⟩
rw [← this, Finset.inf_eq_iInf, iInf_subtype', Ideal.mul_iInf, Ideal.mem_iInf]
rintro ⟨q, hq⟩
by_cases hqp : q = p'
· subst hqp
convert sub_mem H₁ H₂
rw [Finset.sum_eq_add_sum_diff_singleton hp's, add_sub_cancel_right]
· refine Ideal.mul_mono_right ?_ (ha p' hp's)
exact Ideal.prod_le_inf.trans (Finset.inf_le (b := q) (by simpa [hq] using hqp))
/-- In a Dedekind domain, any ideal is spanned by two elements, where one of the element
could be any fixed non-zero element in the ideal. -/
lemma IsDedekindDomain.exists_eq_span_pair {I : Ideal R} {x : R} (hxI : x ∈ I) (hx : x ≠ 0) :
∃ y, I = .span {x, y} := by
obtain ⟨y, rfl⟩ := exists_sup_span_eq (I.span_singleton_le_iff_mem.mpr hxI) (by simpa)
simp_rw [← Ideal.span_union, Set.union_singleton, Set.pair_comm x]
use y
lemma IsDedekindDomain.exists_add_spanSingleton_mul_eq
{a b c : FractionalIdeal R⁰ K} (hac : a ≤ c) (ha : a ≠ 0) (hb : b ≠ 0) :
∃ x : K, a + FractionalIdeal.spanSingleton R⁰ x * b = c := by
wlog hb' : b = 1
· obtain ⟨x, e⟩ := this (a := b⁻¹ * a) (b := 1) (c := b⁻¹ * c) (by gcongr) (by simp [ha, hb])
one_ne_zero rfl
use x
simpa [hb, ← mul_assoc, mul_add, mul_comm b (.spanSingleton _ _)] using congr(b * $e)
subst hb'
have H : Ideal.span {c.den.1} * a.num ≤ c.num * Ideal.span {a.den.1} := by
rw [← FractionalIdeal.coeIdeal_le_coeIdeal K]
simp only [FractionalIdeal.coeIdeal_mul, FractionalIdeal.coeIdeal_span_singleton, ←
FractionalIdeal.den_mul_self_eq_num']
ring_nf
gcongr
obtain ⟨x, hx⟩ := exists_sup_span_eq H
(by simpa using FractionalIdeal.num_eq_zero_iff.not.mpr ha)
refine ⟨algebraMap R K x / algebraMap R K (a.den.1 * c.den.1), ?_⟩
refine mul_left_injective₀ (b := .spanSingleton _
(algebraMap R K (a.den.1 * c.den.1))) ?_ ?_
· simp [FractionalIdeal.spanSingleton_eq_zero_iff]
· simp only [map_mul, mul_one, add_mul, FractionalIdeal.spanSingleton_mul_spanSingleton,
isUnit_iff_ne_zero, ne_eq, mul_eq_zero, FaithfulSMul.algebraMap_eq_zero_iff,
nonZeroDivisors.coe_ne_zero, or_self, not_false_eq_true, IsUnit.div_mul_cancel]
rw [← FractionalIdeal.spanSingleton_mul_spanSingleton, ← mul_assoc, mul_comm a,
FractionalIdeal.den_mul_self_eq_num', ← mul_assoc, mul_right_comm,
mul_comm c, FractionalIdeal.den_mul_self_eq_num', mul_comm]
simp_rw [← FractionalIdeal.coeIdeal_span_singleton, ← FractionalIdeal.coeIdeal_mul,
← hx, ← FractionalIdeal.coeIdeal_sup]
namespace FractionalIdeal
/-- `c.divMod b a` (i.e. `c / b mod a`) is an arbitrary `x` such that `c = bx + a`.
This is zero if the above is not possible, i.e. when `a = 0` or `b = 0` or `¬ a ≤ c`. -/
noncomputable
def divMod (c b a : FractionalIdeal R⁰ K) : K :=
letI := Classical.propDecidable
if h : a ≤ c ∧ a ≠ 0 ∧ b ≠ 0 then
(IsDedekindDomain.exists_add_spanSingleton_mul_eq h.1 h.2.1 h.2.2).choose else 0
lemma divMod_spec
{a b c : FractionalIdeal R⁰ K} (hac : a ≤ c) (ha : a ≠ 0) (hb : b ≠ 0) :
a + spanSingleton R⁰ (c.divMod b a) * b = c := by
rw [divMod, dif_pos ⟨hac, ha, hb⟩]
exact (IsDedekindDomain.exists_add_spanSingleton_mul_eq hac ha hb).choose_spec
@[simp]
lemma divMod_zero_left {I J : FractionalIdeal R⁰ K} : I.divMod 0 J = 0 := by
simp [divMod]
@[simp]
lemma divMod_zero_right {I J : FractionalIdeal R⁰ K} : I.divMod J 0 = 0 := by
simp [divMod]
@[simp]
lemma zero_divMod {I J : FractionalIdeal R⁰ K} :
(0 : FractionalIdeal R⁰ K).divMod I J = 0 := by
simp [divMod, ← and_assoc]
lemma divMod_zero_of_not_le {a b c : FractionalIdeal R⁰ K} (hac : ¬ a ≤ c) :
c.divMod b a = 0 := by
simp [divMod, hac]
/-- Let `I J I' J'` be nonzero fractional ideals in a Dedekind domain with `J ≤ I` and `J' ≤ I'`.
If `I/J = I'/J'` in the group of fractional ideals (i.e. `I * J' = I' * J`),
then `I/J ≃ I'/J'` as quotient `R`-modules. -/
noncomputable
def quotientEquiv (I J I' J' : FractionalIdeal R⁰ K)
(H : I * J' = I' * J) (h : J ≤ I) (h' : J' ≤ I') (hJ' : J' ≠ 0) (hI : I ≠ 0) :
(I ⧸ J.coeToSubmodule.comap I.coeToSubmodule.subtype) ≃ₗ[R]
I' ⧸ J'.coeToSubmodule.comap I'.coeToSubmodule.subtype := by
haveI : J' ⊓ spanSingleton R⁰ (I'.divMod I J') * I = spanSingleton R⁰ (I'.divMod I J') * J := by
have := FractionalIdeal.sup_mul_inf J' (spanSingleton R⁰ (I'.divMod I J') * I)
rwa [FractionalIdeal.sup_eq_add, divMod_spec h' hJ' hI, mul_left_comm, mul_comm J' I, H,
mul_comm I' J, ← mul_assoc, (mul_left_injective₀ _).eq_iff] at this
rintro rfl
exact hJ' (by simpa using h')
refine .ofBijective (Submodule.mapQ _ _ (LinearMap.restrict
(Algebra.lsmul R _ _ (I'.divMod I J')) ?_) ?_) ⟨?_, ?_⟩
· intro x hx
refine (divMod_spec h' hJ' hI).le ?_
exact Submodule.mem_sup_right (mul_mem_mul (mem_spanSingleton_self _ _) hx)
· rw [← Submodule.comap_comp, LinearMap.subtype_comp_restrict, LinearMap.domRestrict,
Submodule.comap_comp]
refine Submodule.comap_mono ?_
intro x hx
refine (Submodule.mem_inf.mp (this.ge ?_)).1
simp only [val_eq_coe, Algebra.lsmul_coe, smul_eq_mul, mem_coe]
exact mul_mem_mul (mem_spanSingleton_self _ _) hx
· rw [← LinearMap.ker_eq_bot, Submodule.mapQ, Submodule.ker_liftQ,
LinearMap.ker_comp, Submodule.ker_mkQ, ← Submodule.comap_comp,
LinearMap.subtype_comp_restrict, ← le_bot_iff, Submodule.map_le_iff_le_comap,
Submodule.comap_bot, Submodule.ker_mkQ, LinearMap.domRestrict,
Submodule.comap_comp, ← Submodule.map_le_iff_le_comap,
Submodule.map_comap_eq, Submodule.range_subtype]
by_cases H' : I'.divMod I J' = 0
· obtain rfl : J' = I' := by simpa [H'] using divMod_spec h' hJ' hI
obtain rfl : I = J := mul_left_injective₀ hJ' (H.trans (mul_comm _ _))
exact inf_le_left
rw [← inv_mul_eq_iff_eq_mul₀ (by simpa [spanSingleton_eq_zero_iff] using H'), mul_inf₀
(zero_le _), inv_mul_cancel_left₀ (by simpa [spanSingleton_eq_zero_iff] using H')] at this
rw [← this, inf_comm, coe_inf]
refine inf_le_inf ?_ le_rfl
intro x hx
rw [spanSingleton_inv]
convert mul_mem_mul (mem_spanSingleton_self _ _) hx
simp [H']
· have H : Submodule.map (Algebra.lsmul R R K (I'.divMod I J')) ↑I =
(spanSingleton R⁰ (I'.divMod I J') * I) := by
ext x
simp [Submodule.mem_span_singleton_mul]
rw [← LinearMap.range_eq_top, Submodule.mapQ, Submodule.range_liftQ,
LinearMap.range_comp, LinearMap.restrict, LinearMap.range_codRestrict,
LinearMap.range_domRestrict, ← top_le_iff, H,
← LinearMap.range_eq_top.mpr (Submodule.mkQ_surjective _),
← Submodule.map_top, Submodule.map_le_iff_le_comap, Submodule.comap_map_eq, Submodule.ker_mkQ,
← Submodule.map_le_map_iff_of_injective I'.coeToSubmodule.injective_subtype,
Submodule.map_top, Submodule.map_sup,
Submodule.map_comap_eq, Submodule.map_comap_eq, Submodule.range_subtype, sup_comm,
inf_eq_right.mpr, inf_eq_right.mpr]
· exact le_trans (divMod_spec h' hJ' hI).ge (by simp)
· exact le_trans (by simp) (divMod_spec h' hJ' hI).le
· exact h'
end FractionalIdeal
end div
section primesOver
variable {S : Type*} [CommRing S] [Algebra S R] [Algebra.IsIntegral S R] [NoZeroSMulDivisors S R]
open IsDedekindDomain Ideal.IsDedekindDomain HeightOneSpectrum
/--
If `p` is a maximal ideal, then the lift of `p` in an extension is the product of the primes
over `p` to the power the ramification index.
-/
theorem Ideal.map_algebraMap_eq_finset_prod_pow {p : Ideal S} [p.IsMaximal] (hp : p ≠ 0) :
map (algebraMap S R) p = ∏ P ∈ p.primesOver R, P ^ p.ramificationIdx (algebraMap S R) P := by
classical
have h : map (algebraMap S R) p ≠ 0 := map_ne_bot_of_ne_bot hp
rw [← finprod_heightOneSpectrum_factorization (I := p.map (algebraMap S R)) h]
let hF : Fintype {v : HeightOneSpectrum R | v.asIdeal ∣ map (algebraMap S R) p} :=
(finite_factors h).fintype
rw [finprod_eq_finset_prod_of_mulSupport_subset
(s := {v | v.asIdeal ∣ p.map (algebraMap S R)}.toFinset), ← Finset.prod_set_coe,
← Finset.prod_set_coe]
· let _ : Fintype {v : HeightOneSpectrum R // v.asIdeal ∣ map (algebraMap S R) p} := hF
refine Fintype.prod_equiv (equivPrimesOver _ hp) _ _ fun ⟨v, _⟩ ↦ ?_
simp [maxPowDividing_eq_pow_multiset_count _ h,
ramificationIdx_eq_factors_count h v.isPrime v.ne_bot]
· intro v hv
simpa [maxPowDividing, Function.mem_mulSupport, IsPrime.ne_top _,
Associates.count_ne_zero_iff_dvd h (irreducible v)] using hv
end primesOver |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/Dvr.lean | import Mathlib.RingTheory.DiscreteValuationRing.TFAE
import Mathlib.RingTheory.LocalProperties.IntegrallyClosed
/-!
# Dedekind domains
This file defines an equivalent notion of a Dedekind domain (or Dedekind ring),
namely a Noetherian integral domain where the localization at every nonzero prime ideal is a DVR.
## Main definitions
- `IsDedekindDomainDvr` alternatively defines a Dedekind domain as an integral domain that
is Noetherian, and the localization at every nonzero prime ideal is a DVR.
## Main results
- `IsLocalization.AtPrime.isDiscreteValuationRing_of_dedekind_domain` shows that
`IsDedekindDomain` implies the localization at each nonzero prime ideal is a DVR.
- `IsDedekindDomain.isDedekindDomainDvr` is one direction of the equivalence of definitions
of a Dedekind domain
## Implementation notes
The definitions that involve a field of fractions choose a canonical field of fractions,
but are independent of that choice. The `..._iff` lemmas express this independence.
Often, definitions assume that Dedekind domains are not fields. We found it more practical
to add a `(h : ¬ IsField A)` assumption whenever this is explicitly needed.
## References
* [D. Marcus, *Number Fields*][marcus1977number]
* [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring
-/
variable (A : Type*) [CommRing A] [IsDomain A]
open scoped nonZeroDivisors Polynomial
/-- A Dedekind domain is an integral domain that is Noetherian, and the
localization at every nonzero prime is a discrete valuation ring.
This is equivalent to `IsDedekindDomain`.
-/
class IsDedekindDomainDvr : Prop extends IsNoetherian A A where
is_dvr_at_nonzero_prime : ∀ P ≠ (⊥ : Ideal A), ∀ _ : P.IsPrime,
IsDiscreteValuationRing (Localization.AtPrime P)
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.
Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
[CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
[h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
intro p hp0 hpp
refine Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => ?_⟩
have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP
rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP'
haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p) :=
((IsLocalization.orderIsoOfPrime M Rₘ) ⟨p, hpp⟩).2.1
haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P) :=
((IsLocalization.orderIsoOfPrime M Rₘ) ⟨P, hPm.isPrime⟩).2.1
have hlt : Ideal.comap (algebraMap R Rₘ) p < Ideal.comap (algebraMap R Rₘ) P := hpP'
refine h.not_lt_lt ⊥ (Ideal.comap _ _) (Ideal.comap _ _) ⟨?_, hlt⟩
exact IsLocalization.bot_lt_comap_prime _ _ hM _ hp0⟩
/-- The localization of a Dedekind domain is a Dedekind domain. -/
theorem IsLocalization.isDedekindDomain [IsDedekindDomain A] {M : Submonoid A} (hM : M ≤ A⁰)
(Aₘ : Type*) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization M Aₘ] :
IsDedekindDomain Aₘ := by
have h : ∀ y : M, IsUnit (algebraMap A (FractionRing A) y) := by
rintro ⟨y, hy⟩
exact IsUnit.mk0 _ (mt IsFractionRing.to_map_eq_zero_iff.mp (nonZeroDivisors.ne_zero (hM hy)))
letI : Algebra Aₘ (FractionRing A) := RingHom.toAlgebra (IsLocalization.lift h)
haveI : IsScalarTower A Aₘ (FractionRing A) :=
IsScalarTower.of_algebraMap_eq fun x => (IsLocalization.lift_eq h x).symm
haveI : IsFractionRing Aₘ (FractionRing A) :=
IsFractionRing.isFractionRing_of_isDomain_of_isLocalization M _ _
refine (isDedekindDomain_iff _ (FractionRing A)).mpr ⟨?_, ?_, ?_, ?_⟩
· infer_instance
· exact IsLocalization.isNoetherianRing M _ inferInstance
· exact Ring.DimensionLEOne.localization Aₘ hM
· intro x hx
obtain ⟨⟨y, y_mem⟩, hy⟩ := hx.exists_multiple_integral_of_isLocalization M _
obtain ⟨z, hz⟩ := (isIntegrallyClosed_iff _).mp IsDedekindRing.toIsIntegralClosure hy
refine ⟨IsLocalization.mk' Aₘ z ⟨y, y_mem⟩, (IsLocalization.lift_mk'_spec _ _ _ _).mpr ?_⟩
rw [hz, ← Algebra.smul_def]
rfl
/-- The localization of a Dedekind domain at every nonzero prime ideal is a Dedekind domain. -/
theorem IsLocalization.AtPrime.isDedekindDomain [IsDedekindDomain A] (P : Ideal A) [P.IsPrime]
(Aₘ : Type*) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] :
IsDedekindDomain Aₘ :=
IsLocalization.isDedekindDomain A P.primeCompl_le_nonZeroDivisors Aₘ
instance Localization.AtPrime.isDedekindDomain [IsDedekindDomain A] (P : Ideal A) [P.IsPrime] :
IsDedekindDomain (Localization.AtPrime P) :=
IsLocalization.AtPrime.isDedekindDomain A P _
theorem IsLocalization.AtPrime.not_isField {P : Ideal A} (hP : P ≠ ⊥) [pP : P.IsPrime] (Aₘ : Type*)
[CommRing Aₘ] [Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] : ¬ IsField Aₘ := by
intro h
letI := h.toField
obtain ⟨x, x_mem, x_ne⟩ := P.ne_bot_iff.mp hP
exact
(IsLocalRing.maximalIdeal.isMaximal _).ne_top
(Ideal.eq_top_of_isUnit_mem _
((IsLocalization.AtPrime.to_map_mem_maximal_iff Aₘ P _).mpr x_mem)
(isUnit_iff_ne_zero.mpr
((map_ne_zero_iff (algebraMap A Aₘ)
(IsLocalization.injective Aₘ P.primeCompl_le_nonZeroDivisors)).mpr
x_ne)))
/-- In a Dedekind domain, the localization at every nonzero prime ideal is a DVR. -/
theorem IsLocalization.AtPrime.isDiscreteValuationRing_of_dedekind_domain [IsDedekindDomain A]
{P : Ideal A} (hP : P ≠ ⊥) [pP : P.IsPrime] (Aₘ : Type*) [CommRing Aₘ] [IsDomain Aₘ]
[Algebra A Aₘ] [IsLocalization.AtPrime Aₘ P] : IsDiscreteValuationRing Aₘ := by
classical
letI : IsNoetherianRing Aₘ :=
IsLocalization.isNoetherianRing P.primeCompl _ IsDedekindRing.toIsNoetherian
letI : IsLocalRing Aₘ := IsLocalization.AtPrime.isLocalRing Aₘ P
have hnf := IsLocalization.AtPrime.not_isField A hP Aₘ
exact
((IsDiscreteValuationRing.TFAE Aₘ hnf).out 0 2).mpr
(IsLocalization.AtPrime.isDedekindDomain A P _)
/-- Dedekind domains, in the sense of Noetherian integrally closed domains of Krull dimension ≤ 1,
are also Dedekind domains in the sense of Noetherian domains where the localization at every
nonzero prime ideal is a DVR. -/
instance IsDedekindDomain.isDedekindDomainDvr [IsDedekindDomain A] : IsDedekindDomainDvr A where
is_dvr_at_nonzero_prime := fun _ hP _ =>
IsLocalization.AtPrime.isDiscreteValuationRing_of_dedekind_domain A hP _
instance IsDedekindDomainDvr.ring_dimensionLEOne [h : IsDedekindDomainDvr A] :
Ring.DimensionLEOne A where
maximalOfPrime := by
intro p hp hpp
rcases p.exists_le_maximal (Ideal.IsPrime.ne_top hpp) with ⟨q, hq, hpq⟩
let f := (IsLocalization.orderIsoOfPrime q.primeCompl (Localization.AtPrime q)).symm
let P := f ⟨p, hpp, hpq.disjoint_compl_left⟩
let Q := f ⟨q, hq.isPrime, Set.disjoint_left.mpr fun _ a => a⟩
have hinj : Function.Injective (algebraMap A (Localization.AtPrime q)) :=
IsLocalization.injective (Localization.AtPrime q) q.primeCompl_le_nonZeroDivisors
have hp1 : P.1 ≠ ⊥ := fun x => hp ((p.map_eq_bot_iff_of_injective hinj).mp x)
have hq1 : Q.1 ≠ ⊥ :=
fun x => (ne_bot_of_le_ne_bot hp hpq) ((q.map_eq_bot_iff_of_injective hinj).mp x)
rcases (IsDiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime q)).mp
(h.is_dvr_at_nonzero_prime q (ne_bot_of_le_ne_bot hp hpq) hq.isPrime) with ⟨_, huq⟩
rw [show p = q from Subtype.val_inj.mpr <| f.injective <|
Subtype.val_inj.mp (huq.unique ⟨hp1, P.2⟩ ⟨hq1, Q.2⟩)]
exact hq
instance IsDedekindDomainDvr.isIntegrallyClosed [h : IsDedekindDomainDvr A] :
IsIntegrallyClosed A :=
IsIntegrallyClosed.of_localization_maximal <| fun p hp0 hpm ↦
let ⟨_, _⟩ := (IsDiscreteValuationRing.iff_pid_with_one_nonzero_prime
(Localization.AtPrime p)).mp (h.is_dvr_at_nonzero_prime p hp0 hpm.isPrime)
inferInstance
/-- If an integral domain is Noetherian, and the localization at every nonzero prime is
a discrete valuation ring, then it is a Dedekind domain. -/
instance IsDedekindDomainDvr.isDedekindDomain [IsDedekindDomainDvr A] : IsDedekindDomain A where |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/IntegralClosure.lean | import Mathlib.LinearAlgebra.BilinearForm.DualLattice
import Mathlib.LinearAlgebra.FreeModule.PID
import Mathlib.RingTheory.DedekindDomain.Basic
import Mathlib.RingTheory.Trace.Basic
/-!
# Integral closure of Dedekind domains
This file shows the integral closure of a Dedekind domain (in particular, the ring of integers
of a number field) is a Dedekind domain.
## Implementation notes
The definitions that involve a field of fractions choose a canonical field of fractions,
but are independent of that choice. The `..._iff` lemmas express this independence.
Often, definitions assume that Dedekind domains are not fields. We found it more practical
to add a `(h : ¬IsField A)` assumption whenever this is explicitly needed.
## References
* [D. Marcus, *Number Fields*][marcus1977number]
* [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring
-/
open Algebra Module
open scoped nonZeroDivisors Polynomial
variable (A K : Type*) [CommRing A] [Field K]
section IsIntegralClosure
/-! ### `IsIntegralClosure` section
We show that an integral closure of a Dedekind domain in a finite separable
field extension is again a Dedekind domain. This implies the ring of integers
of a number field is a Dedekind domain. -/
variable [Algebra A K] [IsFractionRing A K]
variable (L : Type*) [Field L] (C : Type*) [CommRing C]
variable [Algebra K L] [Algebra A L] [IsScalarTower A K L]
variable [Algebra C L] [IsIntegralClosure C A L] [Algebra A C] [IsScalarTower A C L]
include K L
/-- If `L` is an algebraic extension of `K = Frac(A)` and `L` has no zero smul divisors by `A`,
then `L` is the localization of the integral closure `C` of `A` in `L` at `A⁰`. -/
theorem IsIntegralClosure.isLocalization [IsDomain A] [Algebra.IsAlgebraic K L] :
IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L := by
haveI : IsDomain C :=
(IsIntegralClosure.equiv A C L (integralClosure A L)).toMulEquiv.isDomain (integralClosure A L)
haveI : NoZeroSMulDivisors A L := NoZeroSMulDivisors.trans_faithfulSMul A K L
haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L
refine ⟨?_, fun z => ?_, fun {x y} h => ⟨1, ?_⟩⟩
· rintro ⟨_, x, hx, rfl⟩
rw [isUnit_iff_ne_zero, map_ne_zero_iff _ (IsIntegralClosure.algebraMap_injective C A L),
Subtype.coe_mk, map_ne_zero_iff _ (FaithfulSMul.algebraMap_injective A C)]
exact mem_nonZeroDivisors_iff_ne_zero.mp hx
· obtain ⟨m, hm⟩ :=
IsIntegral.exists_multiple_integral_of_isLocalization A⁰ z
(Algebra.IsIntegral.isIntegral (R := K) z)
obtain ⟨x, hx⟩ : ∃ x, algebraMap C L x = m • z := IsIntegralClosure.isIntegral_iff.mp hm
refine ⟨⟨x, algebraMap A C m, m, SetLike.coe_mem m, rfl⟩, ?_⟩
rw [Subtype.coe_mk, ← IsScalarTower.algebraMap_apply, hx, mul_comm, Submonoid.smul_def,
smul_def]
· simp only [IsIntegralClosure.algebraMap_injective C A L h]
theorem IsIntegralClosure.isLocalization_of_isSeparable [IsDomain A] [Algebra.IsSeparable K L] :
IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L :=
IsIntegralClosure.isLocalization A K L C
variable [FiniteDimensional K L]
variable {A K L}
theorem IsIntegralClosure.range_le_span_dualBasis [Algebra.IsSeparable K L] {ι : Type*} [Fintype ι]
[DecidableEq ι] (b : Basis ι K L) (hb_int : ∀ i, IsIntegral A (b i)) [IsIntegrallyClosed A] :
LinearMap.range ((Algebra.linearMap C L).restrictScalars A) ≤
Submodule.span A (Set.range <| (traceForm K L).dualBasis (traceForm_nondegenerate K L) b) := by
rw [← LinearMap.BilinForm.dualSubmodule_span_of_basis,
← LinearMap.BilinForm.le_flip_dualSubmodule, Submodule.span_le]
rintro _ ⟨i, rfl⟩ _ ⟨y, rfl⟩
simp only [LinearMap.coe_restrictScalars, linearMap_apply, LinearMap.BilinForm.flip_apply,
traceForm_apply]
refine Submodule.mem_one.mpr <| IsIntegrallyClosed.isIntegral_iff.mp ?_
exact isIntegral_trace ((IsIntegralClosure.isIntegral A L y).algebraMap.mul (hb_int i))
theorem integralClosure_le_span_dualBasis [Algebra.IsSeparable K L] {ι : Type*} [Fintype ι]
[DecidableEq ι] (b : Basis ι K L) (hb_int : ∀ i, IsIntegral A (b i)) [IsIntegrallyClosed A] :
Subalgebra.toSubmodule (integralClosure A L) ≤
Submodule.span A (Set.range <| (traceForm K L).dualBasis (traceForm_nondegenerate K L) b) := by
refine le_trans ?_ (IsIntegralClosure.range_le_span_dualBasis (integralClosure A L) b hb_int)
intro x hx
exact ⟨⟨x, hx⟩, rfl⟩
variable [IsDomain A]
variable (A K)
/-- Send a set of `x`s in a finite extension `L` of the fraction field of `R`
to `(y : R) • x ∈ integralClosure R L`. -/
theorem exists_integral_multiples (s : Finset L) :
∃ y ≠ (0 : A), ∀ x ∈ s, IsIntegral A (y • x) :=
have := IsLocalization.isAlgebraic K (nonZeroDivisors A)
have := Algebra.IsAlgebraic.trans A K L
Algebra.IsAlgebraic.exists_integral_multiples ..
variable (L)
/-- If `L` is a finite extension of `K = Frac(A)`,
then `L` has a basis over `A` consisting of integral elements. -/
theorem FiniteDimensional.exists_is_basis_integral :
∃ (s : Finset L) (b : Basis s K L), ∀ x, IsIntegral A (b x) := by
letI := Classical.decEq L
letI : IsNoetherian K L := IsNoetherian.iff_fg.2 inferInstance
let s' := IsNoetherian.finsetBasisIndex K L
let bs' := IsNoetherian.finsetBasis K L
obtain ⟨y, hy, his'⟩ := exists_integral_multiples A K (Finset.univ.image bs')
have hy' : algebraMap A L y ≠ 0 := by
refine mt ((injective_iff_map_eq_zero (algebraMap A L)).mp ?_ _) hy
rw [IsScalarTower.algebraMap_eq A K L]
exact (algebraMap K L).injective.comp (IsFractionRing.injective A K)
refine ⟨s', bs'.map {Algebra.lmul _ _ (algebraMap A L y) with
toFun := fun x => algebraMap A L y * x
invFun := fun x => (algebraMap A L y)⁻¹ * x
left_inv := ?_
right_inv := ?_}, ?_⟩
· intro x; simp only [inv_mul_cancel_left₀ hy']
· intro x; simp only [mul_inv_cancel_left₀ hy']
· rintro ⟨x', hx'⟩
simp only [Algebra.smul_def, Finset.mem_image, Finset.mem_univ,
true_and] at his'
simp only [Basis.map_apply, LinearEquiv.coe_mk]
exact his' _ ⟨_, rfl⟩
variable [Algebra.IsSeparable K L]
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is
integrally closed and Noetherian, the integral closure `C` of `A` in `L` is
Noetherian over `A`. -/
theorem IsIntegralClosure.isNoetherian [IsIntegrallyClosed A] [IsNoetherianRing A] :
IsNoetherian A C := by
haveI := Classical.decEq L
obtain ⟨s, b, hb_int⟩ := FiniteDimensional.exists_is_basis_integral A K L
let b' := (traceForm K L).dualBasis (traceForm_nondegenerate K L) b
letI := isNoetherian_span_of_finite A (Set.finite_range b')
let f : C →ₗ[A] Submodule.span A (Set.range b') :=
(Submodule.inclusion (IsIntegralClosure.range_le_span_dualBasis C b hb_int)).comp
((Algebra.linearMap C L).restrictScalars A).rangeRestrict
refine isNoetherian_of_ker_bot f ?_
rw [LinearMap.ker_comp, Submodule.ker_inclusion, Submodule.comap_bot, LinearMap.ker_codRestrict]
exact LinearMap.ker_eq_bot_of_injective (IsIntegralClosure.algebraMap_injective C A L)
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is
integrally closed and Noetherian, the integral closure `C` of `A` in `L` is
Noetherian. -/
theorem IsIntegralClosure.isNoetherianRing [IsIntegrallyClosed A] [IsNoetherianRing A] :
IsNoetherianRing C :=
isNoetherianRing_iff.mpr <| isNoetherian_of_tower A (IsIntegralClosure.isNoetherian A K L C)
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is
integrally closed and Noetherian, the integral closure `C` of `A` in `L` is
finite over `A`. -/
theorem IsIntegralClosure.finite [IsIntegrallyClosed A] [IsNoetherianRing A] :
Module.Finite A C := by
haveI := IsIntegralClosure.isNoetherian A K L C
exact Module.IsNoetherian.finite A C
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a principal ring
and `L` has no zero smul divisors by `A`, the integral closure `C` of `A` in `L` is
a free `A`-module. -/
theorem IsIntegralClosure.module_free [NoZeroSMulDivisors A L] [IsPrincipalIdealRing A] :
Module.Free A C :=
haveI : NoZeroSMulDivisors A C := IsIntegralClosure.noZeroSMulDivisors A L
haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L _
inferInstance
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a principal ring
and `L` has no zero smul divisors by `A`, the `A`-rank of the integral closure `C` of `A` in `L`
is equal to the `K`-rank of `L`. -/
theorem IsIntegralClosure.rank [IsPrincipalIdealRing A] [NoZeroSMulDivisors A L] :
Module.finrank A C = Module.finrank K L := by
haveI : Module.Free A C := IsIntegralClosure.module_free A K L C
haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L C
haveI : IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L :=
IsIntegralClosure.isLocalization A K L C
let b := Basis.localizationLocalization K A⁰ L (Module.Free.chooseBasis A C)
rw [Module.finrank_eq_card_chooseBasisIndex, Module.finrank_eq_card_basis b]
variable {A K}
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is
integrally closed and Noetherian, the integral closure of `A` in `L` is
Noetherian. -/
theorem integralClosure.isNoetherianRing [IsIntegrallyClosed A] [IsNoetherianRing A] :
IsNoetherianRing (integralClosure A L) :=
IsIntegralClosure.isNoetherianRing A K L (integralClosure A L)
variable (A K) [IsDomain C]
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a Dedekind domain,
the integral closure `C` of `A` in `L` is a Dedekind domain.
This cannot be an instance since `A`, `K` or `L` can't be inferred. See also the instance
`integralClosure.isDedekindDomain_fractionRing` where `K := FractionRing A`
and `C := integralClosure A L`. -/
theorem IsIntegralClosure.isDedekindDomain [IsDedekindDomain A] : IsDedekindDomain C :=
have : IsFractionRing C L := IsIntegralClosure.isFractionRing_of_finite_extension A K L C
have : Algebra.IsIntegral A C := IsIntegralClosure.isIntegral_algebra A L
{ IsIntegralClosure.isNoetherianRing A K L C,
Ring.DimensionLEOne.isIntegralClosure A L C,
(isIntegrallyClosed_iff L).mpr fun {x} hx =>
⟨IsIntegralClosure.mk' C x (isIntegral_trans (R := A) _ hx),
IsIntegralClosure.algebraMap_mk' _ _ _⟩ with : IsDedekindDomain C }
/-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a Dedekind domain,
the integral closure of `A` in `L` is a Dedekind domain.
This cannot be an instance since `K` can't be inferred. See also the instance
`integralClosure.isDedekindDomain_fractionRing` where `K := FractionRing A`. -/
theorem integralClosure.isDedekindDomain [IsDedekindDomain A] :
IsDedekindDomain (integralClosure A L) :=
IsIntegralClosure.isDedekindDomain A K L (integralClosure A L)
variable [Algebra (FractionRing A) L] [IsScalarTower A (FractionRing A) L]
variable [FiniteDimensional (FractionRing A) L] [Algebra.IsSeparable (FractionRing A) L]
/-- If `L` is a finite separable extension of `Frac(A)`, where `A` is a Dedekind domain,
the integral closure of `A` in `L` is a Dedekind domain.
See also the lemma `integralClosure.isDedekindDomain` where you can choose
the field of fractions yourself. -/
instance integralClosure.isDedekindDomain_fractionRing [IsDedekindDomain A] :
IsDedekindDomain (integralClosure A L) :=
integralClosure.isDedekindDomain A (FractionRing A) L
end IsIntegralClosure |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/SInteger.lean | import Mathlib.RingTheory.DedekindDomain.AdicValuation
/-!
# `S`-integers and `S`-units of fraction fields of Dedekind domains
Let `K` be the field of fractions of a Dedekind domain `R`, and let `S` be a set of prime ideals in
the height one spectrum of `R`. An `S`-integer of `K` is defined to have `v`-adic valuation at most
one for all primes ideals `v` away from `S`, whereas an `S`-unit of `Kˣ` is defined to have `v`-adic
valuation exactly one for all prime ideals `v` away from `S`.
This file defines the subalgebra of `S`-integers of `K` and the subgroup of `S`-units of `Kˣ`, where
`K` can be specialised to the case of a number field or a function field separately.
## Main definitions
* `Set.integer`: `S`-integers.
* `Set.unit`: `S`-units.
* TODO: localised notation for `S`-integers.
## Main statements
* `Set.unitEquivUnitsInteger`: `S`-units are units of `S`-integers.
* `IsDedekindDomain.integer_empty`: `∅`-integers is the usual ring of integers.
* TODO: proof that `S`-units is the kernel of a map to a product.
* TODO: finite generation of `S`-units and Dirichlet's `S`-unit theorem.
## References
* [D Marcus, *Number Fields*][marcus1977number]
* [J W S Cassels, A Fröhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
S integer, S-integer, S unit, S-unit
-/
noncomputable section
open IsDedekindDomain
open scoped nonZeroDivisors
universe u v
variable {R : Type u} [CommRing R] [IsDedekindDomain R]
(S : Set <| HeightOneSpectrum R) (K : Type v) [Field K] [Algebra R K] [IsFractionRing R K]
/-! ## `S`-integers -/
namespace Set
/-- The `R`-subalgebra of `S`-integers of `K`. -/
@[simps!]
def integer : Subalgebra R K :=
{
(⨅ (v) (_ : v ∉ S), (v.valuation K).valuationSubring.toSubring).copy
{x : K | ∀ (v) (_ : v ∉ S), v.valuation K x ≤ 1} <|
Set.ext fun _ => by simp [SetLike.mem_coe] with
algebraMap_mem' := fun x v _ => v.valuation_le_one x }
theorem integer_eq :
(S.integer K).toSubring =
⨅ (v) (_ : v ∉ S), (v.valuation K).valuationSubring.toSubring :=
SetLike.ext' <| by ext; simp
theorem integer_valuation_le_one (x : S.integer K) {v : HeightOneSpectrum R} (hv : v ∉ S) :
v.valuation K x ≤ 1 :=
x.property v hv
end Set
namespace IsDedekindDomain
variable (R)
/-- If `S` is the whole set of places of `K`, then the `S`-integers are the whole of `K`. -/
@[simp] lemma integer_univ : (Set.univ : Set (HeightOneSpectrum R)).integer K = ⊤ := by
ext
tauto
/-- If `S` is the empty set, then the `S`-integers are the minimal `R`-subalgebra of `K` (which is
just `R` itself, via `Algebra.botEquivOfInjective` and `IsFractionRing.injective`). -/
@[simp] lemma integer_empty : (∅ : Set (HeightOneSpectrum R)).integer K = ⊥ := by
ext x
simp only [Set.integer, Set.mem_empty_iff_false, not_false_eq_true, true_implies]
refine ⟨HeightOneSpectrum.mem_integers_of_valuation_le_one K x, ?_⟩
rintro ⟨y, rfl⟩ v
exact v.valuation_le_one y
end IsDedekindDomain
/-! ## `S`-units -/
namespace Set
/-- The subgroup of `S`-units of `Kˣ`. -/
@[simps!]
def unit : Subgroup Kˣ :=
(⨅ (v) (_ : v ∉ S), (v.valuation K).valuationSubring.unitGroup).copy
{x : Kˣ | ∀ (v) (_ : v ∉ S), (v : HeightOneSpectrum R).valuation K x = 1} <|
Set.ext fun _ => by
simp only [mem_setOf, SetLike.mem_coe, Subgroup.mem_iInf, Valuation.mem_unitGroup_iff]
theorem unit_eq :
S.unit K = ⨅ (v) (_ : v ∉ S), (v.valuation K).valuationSubring.unitGroup :=
Subgroup.copy_eq _ _ _
theorem unit_valuation_eq_one (x : S.unit K) {v : HeightOneSpectrum R} (hv : v ∉ S) :
v.valuation K (x : Kˣ) = 1 :=
x.property v hv
/-- The group of `S`-units is the group of units of the ring of `S`-integers. -/
@[simps apply_val_coe symm_apply_coe]
def unitEquivUnitsInteger : S.unit K ≃* (S.integer K)ˣ where
toFun x :=
⟨⟨((x : Kˣ) : K), fun v hv => (x.property v hv).le⟩,
⟨((x⁻¹ : Kˣ) : K), fun v hv => (x⁻¹.property v hv).le⟩,
Subtype.ext x.val.val_inv, Subtype.ext x.val.inv_val⟩
invFun x :=
⟨Units.mk0 x fun hx => x.ne_zero (ZeroMemClass.coe_eq_zero.mp hx),
fun v hv =>
eq_one_of_one_le_mul_left (x.val.property v hv) (x.inv.property v hv) <|
Eq.ge <| by
rw [← map_mul, Units.val_mk0, Subtype.mk_eq_mk.mp x.val_inv, map_one]⟩
map_mul' _ _ := by ext; rfl
end Set |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/LinearDisjoint.lean | import Mathlib.FieldTheory.LinearDisjoint
import Mathlib.RingTheory.DedekindDomain.Different
/-!
# Disjoint extensions with coprime different ideals
Let `A ⊆ B` be a finite extension of Dedekind domains and assume that `A ⊆ R₁, R₂ ⊆ B` are two
subrings such that `Frac R₁ ⊔ Frac R₂ = Frac B`, `Frac R₁` and `Frac R₂` are linearly disjoint
over `Frac A`, and that `𝓓(R₁/A)` and `𝓓(R₂/A)` are coprime where `𝓓` denotes the different ideal
and `Frac R` denotes the fraction field of a domain `R`.
## Main results and definitions
* `FractionalIdeal.differentIdeal_eq_map_differentIdeal`: `𝓓(B/R₁) = 𝓓(R₂/A)`
* `FractionalIdeal.differentIdeal_eq_differentIdeal_mul_differentIdeal_of_isCoprime`:
`𝓓(B/A) = 𝓓(R₁/A) * 𝓓(R₂/A)`.
* `Module.Basis.ofIsCoprimeDifferentIdeal`: Construct a `R₁`-basis of `B` by lifting an
`A`-basis of `R₂`.
* `IsDedekindDomain.range_sup_range_eq_top_of_isCoprime_differentIdeal`: `B` is generated
(as an `A`-algebra) by `R₁` and `R₂`.
-/
open FractionalIdeal nonZeroDivisors IntermediateField Algebra Module Submodule
variable (A B : Type*) {K L : Type*} [CommRing A] [Field K] [Algebra A K] [IsFractionRing A K]
[CommRing B] [Field L] [Algebra B L] [Algebra A L] [Algebra K L] [FiniteDimensional K L]
[IsScalarTower A K L]
variable (R₁ R₂ : Type*) [CommRing R₁] [CommRing R₂] [Algebra A R₁] [Algebra A R₂] [Algebra R₁ B]
[Algebra R₂ B] [Algebra R₁ L] [Algebra R₂ L] [IsScalarTower A R₁ L] [IsScalarTower R₁ B L]
[IsScalarTower R₂ B L] [Module.Finite A R₂]
variable {F₁ F₂ : IntermediateField K L} [Algebra R₁ F₁] [Algebra R₂ F₂] [NoZeroSMulDivisors R₁ F₁]
[IsScalarTower A F₂ L] [IsScalarTower A R₂ F₂] [IsScalarTower R₁ F₁ L] [IsScalarTower R₂ F₂ L]
[Algebra.IsSeparable K F₂] [Algebra.IsSeparable F₁ L]
theorem Submodule.traceDual_le_span_map_traceDual [Module.Free A R₂]
[IsLocalization (Algebra.algebraMapSubmonoid R₂ A⁰) F₂] (h₁ : F₁.LinearDisjoint F₂)
(h₂ : F₁ ⊔ F₂ = ⊤) :
(traceDual R₁ F₁ (1 : Submodule B L)).restrictScalars R₁ ≤
span R₁ (algebraMap F₂ L '' (traceDual A K (1 : Submodule R₂ F₂))) := by
intro x hx
have h₂' : F₁.toSubalgebra ⊔ F₂.toSubalgebra = ⊤ := by
simpa [sup_toSubalgebra_of_isAlgebraic_right] using congr_arg IntermediateField.toSubalgebra h₂
let b₂ := (Free.chooseBasis A R₂).localizationLocalization K A⁰ F₂
let B₁ := h₁.basisOfBasisRight h₂' b₂
have h_main : x ∈ span R₁ (Set.range B₁.traceDual) := by
rw [B₁.traceDual.mem_span_iff_repr_mem R₁ x]
intro i
rw [B₁.traceDual_repr_apply]
refine mem_traceDual.mp hx _ ?_
rw [LinearDisjoint.basisOfBasisRight_apply, Basis.localizationLocalization_apply,
← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R₂ B L, mem_one]
exact ⟨_, rfl⟩
have h : Set.range B₁.traceDual =
Set.range (IsScalarTower.toAlgHom A F₂ L ∘ b₂.traceDual) := by
refine congr_arg Set.range <| B₁.traceDual_eq_iff.mpr fun i j ↦ ?_
rw [LinearDisjoint.basisOfBasisRight_apply, traceForm_apply, Function.comp_apply,
IsScalarTower.coe_toAlgHom', ← map_mul, h₁.trace_algebraMap h₂, b₂.trace_traceDual_mul,
MonoidWithZeroHom.map_ite_one_zero]
rwa [← span_span_of_tower A R₁, h, Set.range_comp, ← map_span,
← traceDual_span_of_basis A (1 : Submodule R₂ F₂) b₂
(by rw [Basis.localizationLocalization_span K A⁰ F₂]; ext; simp)] at h_main
attribute [local instance] FractionRing.liftAlgebra
variable [IsDomain A] [IsDedekindDomain B] [IsDedekindDomain R₁] [IsDedekindDomain R₂]
[IsFractionRing B L] [IsFractionRing R₁ F₁] [IsFractionRing R₂ F₂] [IsIntegrallyClosed A]
[IsIntegralClosure B R₁ L] [NoZeroSMulDivisors R₁ B] [NoZeroSMulDivisors R₂ B]
namespace IsDedekindDomain
theorem differentIdeal_dvd_map_differentIdeal [Algebra.IsIntegral R₂ B]
[Module.Free A R₂] [IsLocalization (Algebra.algebraMapSubmonoid R₂ A⁰) F₂]
(h₁ : F₁.LinearDisjoint F₂) (h₂ : F₁ ⊔ F₂ = ⊤) :
differentIdeal R₁ B ∣ Ideal.map (algebraMap R₂ B) (differentIdeal A R₂) := by
have : Algebra.IsSeparable (FractionRing A) (FractionRing R₂) := by
refine Algebra.IsSeparable.of_equiv_equiv (FractionRing.algEquiv A K).symm.toRingEquiv
(FractionRing.algEquiv R₂ F₂).symm.toRingEquiv ?_
ext _
exact IsFractionRing.algEquiv_commutes (FractionRing.algEquiv A K).symm
(FractionRing.algEquiv R₂ ↥F₂).symm _
rw [Ideal.dvd_iff_le, ← coeIdeal_le_coeIdeal L, coeIdeal_differentIdeal R₁ F₁ L B,
← extendedHomₐ_coeIdeal_eq_map L B (K := F₂), le_inv_comm _ (by simp), ← map_inv₀,
coeIdeal_differentIdeal A K, inv_inv, ← coe_le_coe, coe_dual_one, coe_extendedHomₐ_eq_span,
← coeToSet_coeToSubmodule, coe_dual_one]
· have := Submodule.span_mono (R := B) <| traceDual_le_span_map_traceDual A B R₁ R₂ h₁ h₂
rwa [← span_coe_eq_restrictScalars, span_span_of_tower, span_span_of_tower, span_eq] at this
· exact (_root_.map_ne_zero _).mpr <| coeIdeal_eq_zero.not.mpr differentIdeal_ne_bot
variable [Algebra A B] [Module.Finite A B] [NoZeroSMulDivisors A B] [NoZeroSMulDivisors A R₁]
[NoZeroSMulDivisors A R₂] [Module.Finite A R₁] [Module.Finite R₂ B] [IsScalarTower A R₂ B]
[Module.Finite R₁ B] [Algebra.IsSeparable (FractionRing A) (FractionRing B)]
[IsScalarTower A R₁ B]
theorem map_differentIdeal_dvd_differentIdeal
(h : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) :
Ideal.map (algebraMap R₂ B) (differentIdeal A R₂) ∣ differentIdeal R₁ B :=
have := (differentIdeal_eq_differentIdeal_mul_differentIdeal A R₂ B).symm.trans
(differentIdeal_eq_differentIdeal_mul_differentIdeal A R₁ B)
h.symm.dvd_of_dvd_mul_right (dvd_of_mul_left_eq _ this)
theorem differentIdeal_eq_map_differentIdeal [Module.Free A R₂] (h₁ : F₁.LinearDisjoint F₂)
(h₂ : F₁ ⊔ F₂ = ⊤)
(h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) :
differentIdeal R₁ B = Ideal.map (algebraMap R₂ B) (differentIdeal A R₂) := by
apply dvd_antisymm
· exact differentIdeal_dvd_map_differentIdeal A B R₁ R₂ h₁ h₂
· exact map_differentIdeal_dvd_differentIdeal A B R₁ R₂ h₃
/--
Let `A ⊆ B` be a finite extension of Dedekind domains and assume that `A ⊆ R₁, R₂ ⊆ B` are two
subrings such that `Frac R₁ ⊔ Frac R₂ = Frac B`, `Frac R₁` and `Frac R₂` are linearly disjoint
over `Frac A`, and that `𝓓(R₁/A)` and `𝓓(R₂/A)` are coprime where `𝓓` denotes the different ideal
and `Frac R` denotes the fraction field of a domain `R`.
We have `𝓓(B/A) = 𝓓(R₁/A) * 𝓓(R₂/A)`.
-/
theorem differentIdeal_eq_differentIdeal_mul_differentIdeal_of_isCoprime
[Module.Free A R₂] (h₁ : F₁.LinearDisjoint F₂) (h₂ : F₁ ⊔ F₂ = ⊤)
(h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) :
differentIdeal A B = differentIdeal R₁ B * differentIdeal R₂ B := by
have := differentIdeal_eq_differentIdeal_mul_differentIdeal A R₂ B
rwa [← differentIdeal_eq_map_differentIdeal A B R₁ R₂ h₁ h₂ h₃,
mul_comm] at this
end IsDedekindDomain
variable [Algebra A B] [Module.Finite A B] [NoZeroSMulDivisors A B] [NoZeroSMulDivisors A R₁]
[NoZeroSMulDivisors A R₂] [Module.Finite A R₁] [Module.Finite R₂ B] [IsScalarTower A R₂ B]
[Module.Finite R₁ B] [Algebra.IsSeparable (FractionRing A) (FractionRing B)]
[IsScalarTower A R₁ B]
theorem Submodule.traceDual_eq_span_map_traceDual_of_linearDisjoint [Module.Free A R₂]
[IsLocalization (Algebra.algebraMapSubmonoid R₂ A⁰) F₂] (h₁ : F₁.LinearDisjoint F₂)
(h₂ : F₁ ⊔ F₂ = ⊤) (h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) :
span R₁ (algebraMap F₂ L '' (traceDual A K (1 : Submodule R₂ F₂))) =
(traceDual R₁ F₁ (1 : Submodule B L)).restrictScalars R₁ := by
have : Algebra.IsSeparable (FractionRing A) (FractionRing R₂) := by
refine Algebra.IsSeparable.of_equiv_equiv (FractionRing.algEquiv A K).symm.toRingEquiv
(FractionRing.algEquiv R₂ F₂).symm.toRingEquiv ?_
ext x
exact IsFractionRing.algEquiv_commutes (FractionRing.algEquiv A K).symm
(FractionRing.algEquiv R₂ ↥F₂).symm _
suffices span B (algebraMap F₂ L '' (traceDual A K (1 : Submodule R₂ F₂))) ≤
traceDual R₁ F₁ (1 : Submodule B L) by
apply le_antisymm
· refine SetLike.coe_subset_coe.mp (subset_trans ?_ this)
rw [← Submodule.span_span_of_tower R₁ B]
exact Submodule.subset_span
· exact traceDual_le_span_map_traceDual A B R₁ R₂ h₁ h₂
have := dvd_of_eq <|
(IsDedekindDomain.differentIdeal_eq_map_differentIdeal A B R₁ R₂ h₁ h₂ h₃).symm
rwa [Ideal.dvd_iff_le, ← coeIdeal_le_coeIdeal (K := L), coeIdeal_differentIdeal R₁ F₁,
inv_le_comm, ← extendedHomₐ_coeIdeal_eq_map (K := F₂), coeIdeal_differentIdeal A K, map_inv₀,
inv_inv, ← coe_le_coe, coe_extendedHomₐ_eq_span, coe_dual_one, ← coeToSet_coeToSubmodule,
coe_dual_one] at this
· simp
· rw [← extendedHomₐ_coeIdeal_eq_map (K := F₂), ne_eq, extendedHomₐ_eq_zero_iff]
rw [coeIdeal_eq_zero]
exact differentIdeal_ne_bot
namespace Module.Basis
private theorem ofIsCoprimeDifferentIdeal_aux [Module.Free A R₂]
(h₁ : F₁.LinearDisjoint F₂) (h₂ : F₁.toSubalgebra ⊔ F₂.toSubalgebra = ⊤)
(h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) {ι : Type*} (b : Basis ι K F₂)
(hb : span A (Set.range b) = LinearMap.range (IsScalarTower.toAlgHom A R₂ F₂)) :
span R₁ (Set.range (h₁.basisOfBasisRight h₂ b)) =
Submodule.restrictScalars R₁ (1 : Submodule B L) := by
classical
have h₂' : F₁ ⊔ F₂ = ⊤ := by
rwa [← sup_toSubalgebra_of_isAlgebraic_right, ← top_toSubalgebra, toSubalgebra_inj] at h₂
have : Finite ι := Module.Finite.finite_basis b
have h_main := congr_arg (Submodule.restrictScalars R₁) <|
congr_arg coeToSubmodule <| (1 : FractionalIdeal B⁰ L).dual_dual R₁ F₁
rw [← coe_one, ← h_main, coe_dual _ _ (by simp), coe_dual_one, restrictScalars_traceDual,
← traceDual_eq_span_map_traceDual_of_linearDisjoint A B R₁ R₂ h₁ h₂' h₃,
← coe_restrictScalars A, traceDual_span_of_basis A (1 : Submodule R₂ F₂) b,
← IsScalarTower.coe_toAlgHom' A F₂ L, ← map_coe, map_span, span_span_of_tower,
IsScalarTower.coe_toAlgHom', ← Set.range_comp]
· have : (h₁.basisOfBasisRight h₂ b).traceDual = algebraMap F₂ L ∘ b.traceDual := by
refine Basis.traceDual_eq_iff.mpr fun i j ↦ ?_
rw [Function.comp_apply, h₁.basisOfBasisRight_apply, traceForm_apply, ← map_mul,
h₁.trace_algebraMap h₂', b.trace_traceDual_mul i j, MonoidWithZeroHom.map_ite_one_zero]
rw [← this, (traceForm F₁ L).dualSubmodule_span_of_basis (traceForm_nondegenerate F₁ L),
← Basis.traceDual_def, Basis.traceDual_traceDual]
· rw [hb]
ext; simp
/--
Let `A ⊆ B` be a finite extension of Dedekind domains and assume that `A ⊆ R₁, R₂ ⊆ B` are two
subrings such that `Frac R₁ ⊔ Frac R₂ = Frac B`, `Frac R₁` and `Frac R₂` are linearly disjoint
over `Frac A`, and that `𝓓(R₁/A)` and `𝓓(R₂/A)` are coprime where `𝓓` denotes the different ideal
and `Frac R` denotes the fraction field of a domain `R`.
Construct a `R₁`-basis of `B` by lifting an `A`-basis of `R₂`.
-/
noncomputable def ofIsCoprimeDifferentIdeal (h₁ : F₁.LinearDisjoint F₂)
(h₂ : F₁.toSubalgebra ⊔ F₂.toSubalgebra = ⊤)
(h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) {ι : Type*} (b : Basis ι A R₂) :
Basis ι R₁ B :=
have : Module.Free A R₂ := Free.of_basis b
let v := fun i : ι ↦ algebraMap R₂ B (b i)
let b₂ : Basis ι K F₂ := b.localizationLocalization K A⁰ F₂
have P₁ : LinearIndependent R₁ v := by
rw [← LinearMap.linearIndependent_iff (IsScalarTower.toAlgHom R₁ B L).toLinearMap
(LinearMap.ker_eq_bot.mpr <| FaithfulSMul.algebraMap_injective _ _),
LinearIndependent.iff_fractionRing R₁ F₁, Function.comp_def]
simp_rw [AlgHom.toLinearMap_apply, IsScalarTower.coe_toAlgHom', v,
← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R₂ F₂ L,
← b.localizationLocalization_apply K A⁰ F₂]
exact h₁.linearIndependent_right b₂.linearIndependent
have P₂ : ⊤ ≤ span R₁ (Set.range v) := by
rw [top_le_iff]
apply map_injective_of_injective (by exact FaithfulSMul.algebraMap_injective B L :
Function.Injective (IsScalarTower.toAlgHom R₁ B L))
rw [map_span, ← Set.range_comp]
convert Module.Basis.ofIsCoprimeDifferentIdeal_aux A B R₁ R₂ h₁ h₂ h₃ b₂
(b.localizationLocalization_span K A⁰ F₂)
· ext
simp [b₂, v, ← IsScalarTower.algebraMap_apply]
· ext; simp
Basis.mk P₁ P₂
@[simp]
theorem ofIsCoprimeDifferentIdeal_apply (h₁ : F₁.LinearDisjoint F₂)
(h₂ : F₁.toSubalgebra ⊔ F₂.toSubalgebra = ⊤)
(h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) {ι : Type*} (b : Basis ι A R₂) (i : ι) :
b.ofIsCoprimeDifferentIdeal A B R₁ R₂ h₁ h₂ h₃ i = algebraMap R₂ B (b i) := by
simp [Module.Basis.ofIsCoprimeDifferentIdeal]
end Module.Basis
namespace IsDedekindDomain
/--
Let `A ⊆ B` be a finite extension of Dedekind domains and assume that `A ⊆ R₁, R₂ ⊆ B` are two
subrings such that `Frac R₁ ⊔ Frac R₂ = Frac B`, `Frac R₁` and `Frac R₂` are linearly disjoint
over `Frac A`, and that `𝓓(R₁/A)` and `𝓓(R₂/A)` are coprime where `𝓓` denotes the different ideal
and `Frac R` denotes the fraction field of a domain `R`.
Then `B` is generated (as an `A`-algebra) by `R₁` and `R₂`.
-/
theorem range_sup_range_eq_top_of_isCoprime_differentIdeal
(h₁ : F₁.LinearDisjoint F₂)
(h₂ : F₁.toSubalgebra ⊔ F₂.toSubalgebra = ⊤)
(h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) [Module.Free A R₂] :
(IsScalarTower.toAlgHom A R₁ B).range ⊔
(IsScalarTower.toAlgHom A R₂ B).range = ⊤ := by
let B₁ := (Free.chooseBasis A R₂).ofIsCoprimeDifferentIdeal A B R₁ R₂ h₁ h₂ h₃
refine Algebra.eq_top_iff.mpr fun x ↦ ?_
rw [← B₁.sum_repr x]
refine Subalgebra.sum_mem _ fun i _ ↦ ?_
rw [Algebra.smul_def]
exact Subalgebra.mul_mem _ (Algebra.mem_sup_left (by simp)) (Algebra.mem_sup_right (by simp [B₁]))
theorem adjoin_union_eq_top_of_isCoprime_differentialIdeal [Module.Free A R₂]
(h₁ : F₁.LinearDisjoint F₂) (h₂ : F₁.toSubalgebra ⊔ F₂.toSubalgebra = ⊤)
(h₃ : IsCoprime ((differentIdeal A R₁).map (algebraMap R₁ B))
((differentIdeal A R₂).map (algebraMap R₂ B))) {s : Set R₁} {t : Set R₂}
(hs : Algebra.adjoin A s = ⊤) (ht : Algebra.adjoin A t = ⊤) :
Algebra.adjoin A (algebraMap R₁ B '' s ∪ algebraMap R₂ B '' t) = ⊤ := by
rw [Algebra.adjoin_union, ← IsScalarTower.coe_toAlgHom' A R₁, ← IsScalarTower.coe_toAlgHom' A R₂,
← AlgHom.map_adjoin, hs, ← AlgHom.map_adjoin, ht, Algebra.map_top, Algebra.map_top]
exact range_sup_range_eq_top_of_isCoprime_differentIdeal A B R₁ R₂ h₁ h₂ h₃
end IsDedekindDomain |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/Ideal/Lemmas.lean | import Mathlib.Algebra.Polynomial.FieldDivision
import Mathlib.Algebra.Squarefree.Basic
import Mathlib.RingTheory.ChainOfDivisors
import Mathlib.RingTheory.DedekindDomain.Ideal.Basic
import Mathlib.RingTheory.Spectrum.Maximal.Localization
import Mathlib.Algebra.Order.GroupWithZero.Unbundled.OrderIso
/-!
# Dedekind domains and ideals
In this file, we prove some results on the unique factorization monoid structure of the ideals.
The unique factorization of ideals and invertibility of fractional ideals can be found in
`Mathlib/RingTheory/DedekindDomain/Ideal/Basic.lean`.
## Main definitions
- `IsDedekindDomain.HeightOneSpectrum` defines the type of nonzero prime ideals of `R`.
## Implementation notes
Often, definitions assume that Dedekind domains are not fields. We found it more practical
to add a `(h : ¬ IsField A)` assumption whenever this is explicitly needed.
## References
* [D. Marcus, *Number Fields*][marcus1977number]
* [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring
-/
variable (R A K : Type*) [CommRing R] [CommRing A] [Field K]
open scoped nonZeroDivisors Polynomial
section Inverse
variable [Algebra A K] [IsFractionRing A K]
variable {A K}
namespace FractionalIdeal
open Ideal
theorem exists_notMem_one_of_ne_bot [IsDedekindDomain A] {I : Ideal A} (hI0 : I ≠ ⊥)
(hI1 : I ≠ ⊤) : ∃ x ∈ (I⁻¹ : FractionalIdeal A⁰ K), x ∉ (1 : FractionalIdeal A⁰ K) :=
Set.not_subset.1 <| not_inv_le_one_of_ne_bot hI0 hI1
@[deprecated (since := "2025-05-23")]
alias exists_not_mem_one_of_ne_bot := exists_notMem_one_of_ne_bot
end FractionalIdeal
end Inverse
section IsDedekindDomain
variable {R A}
variable [IsDedekindDomain A] [Algebra A K] [IsFractionRing A K]
open FractionalIdeal
open Ideal
@[simp]
theorem Ideal.dvd_span_singleton {I : Ideal A} {x : A} : I ∣ Ideal.span {x} ↔ x ∈ I :=
Ideal.dvd_iff_le.trans (Ideal.span_le.trans Set.singleton_subset_iff)
theorem Ideal.isPrime_of_prime {P : Ideal A} (h : Prime P) : IsPrime P := by
refine ⟨?_, fun hxy => ?_⟩
· rintro rfl
rw [← Ideal.one_eq_top] at h
exact h.not_unit isUnit_one
· simp only [← Ideal.dvd_span_singleton, ← Ideal.span_singleton_mul_span_singleton] at hxy ⊢
exact h.dvd_or_dvd hxy
theorem Ideal.prime_of_isPrime {P : Ideal A} (hP : P ≠ ⊥) (h : IsPrime P) : Prime P := by
refine ⟨hP, mt Ideal.isUnit_iff.mp h.ne_top, fun I J hIJ => ?_⟩
simpa only [Ideal.dvd_iff_le] using h.mul_le.mp (Ideal.le_of_dvd hIJ)
/-- In a Dedekind domain, the (nonzero) prime elements of the monoid with zero `Ideal A`
are exactly the prime ideals. -/
theorem Ideal.prime_iff_isPrime {P : Ideal A} (hP : P ≠ ⊥) : Prime P ↔ IsPrime P :=
⟨Ideal.isPrime_of_prime, Ideal.prime_of_isPrime hP⟩
/-- In a Dedekind domain, the prime ideals are the zero ideal together with the prime elements
of the monoid with zero `Ideal A`. -/
theorem Ideal.isPrime_iff_bot_or_prime {P : Ideal A} : IsPrime P ↔ P = ⊥ ∨ Prime P :=
⟨fun hp => (eq_or_ne P ⊥).imp_right fun hp0 => Ideal.prime_of_isPrime hp0 hp, fun hp =>
hp.elim (fun h => h.symm ▸ Ideal.bot_prime) Ideal.isPrime_of_prime⟩
@[simp]
theorem Ideal.prime_span_singleton_iff {a : A} : Prime (Ideal.span {a}) ↔ Prime a := by
rcases eq_or_ne a 0 with rfl | ha
· rw [Set.singleton_zero, span_zero, ← Ideal.zero_eq_bot, ← not_iff_not]
simp only [not_prime_zero, not_false_eq_true]
· have ha' : span {a} ≠ ⊥ := by simpa only [ne_eq, span_singleton_eq_bot] using ha
rw [Ideal.prime_iff_isPrime ha', Ideal.span_singleton_prime ha]
open Submodule.IsPrincipal in
theorem Ideal.prime_generator_of_prime {P : Ideal A} (h : Prime P) [P.IsPrincipal] :
Prime (generator P) :=
have : Ideal.IsPrime P := Ideal.isPrime_of_prime h
prime_generator_of_isPrime _ h.ne_zero
open UniqueFactorizationMonoid in
nonrec theorem Ideal.mem_normalizedFactors_iff {p I : Ideal A} (hI : I ≠ ⊥) :
p ∈ normalizedFactors I ↔ p.IsPrime ∧ I ≤ p := by
rw [← Ideal.dvd_iff_le]
by_cases hp : p = 0
· rw [← zero_eq_bot] at hI
simp only [hp, zero_notMem_normalizedFactors, zero_dvd_iff, hI, false_iff, not_and,
not_false_eq_true, implies_true]
· rwa [mem_normalizedFactors_iff hI, prime_iff_isPrime]
variable (A) in
open UniqueFactorizationMonoid in
theorem Ideal.mem_primesOver_iff_mem_normalizedFactors {p : Ideal R} [h : p.IsMaximal]
[Algebra R A] [NoZeroSMulDivisors R A] (hp : p ≠ ⊥) {P : Ideal A} :
P ∈ p.primesOver A ↔ P ∈ normalizedFactors (Ideal.map (algebraMap R A) p) := by
rw [primesOver, Set.mem_setOf_eq, mem_normalizedFactors_iff (map_ne_bot_of_ne_bot hp),
liesOver_iff, under_def, and_congr_right_iff, map_le_iff_le_comap]
intro hP
refine ⟨fun h ↦ le_of_eq h, fun h' ↦ ((IsCoatom.le_iff_eq (isMaximal_def.mp h) ?_).mp h').symm⟩
exact comap_ne_top (algebraMap R A) (IsPrime.ne_top hP)
theorem Ideal.pow_right_strictAnti (I : Ideal A) (hI0 : I ≠ ⊥) (hI1 : I ≠ ⊤) :
StrictAnti (I ^ · : ℕ → Ideal A) :=
strictAnti_nat_of_succ_lt fun e =>
Ideal.dvdNotUnit_iff_lt.mp ⟨pow_ne_zero _ hI0, I, mt isUnit_iff.mp hI1, pow_succ I e⟩
theorem Ideal.pow_lt_self (I : Ideal A) (hI0 : I ≠ ⊥) (hI1 : I ≠ ⊤) (e : ℕ) (he : 2 ≤ e) :
I ^ e < I := by
convert I.pow_right_strictAnti hI0 hI1 he
dsimp only
rw [pow_one]
theorem Ideal.exists_mem_pow_notMem_pow_succ (I : Ideal A) (hI0 : I ≠ ⊥) (hI1 : I ≠ ⊤) (e : ℕ) :
∃ x ∈ I ^ e, x ∉ I ^ (e + 1) :=
SetLike.exists_of_lt (I.pow_right_strictAnti hI0 hI1 e.lt_succ_self)
@[deprecated (since := "2025-05-23")]
alias Ideal.exists_mem_pow_not_mem_pow_succ := Ideal.exists_mem_pow_notMem_pow_succ
open UniqueFactorizationMonoid
theorem Ideal.eq_prime_pow_of_succ_lt_of_le {P I : Ideal A} [P_prime : P.IsPrime] (hP : P ≠ ⊥)
{i : ℕ} (hlt : P ^ (i + 1) < I) (hle : I ≤ P ^ i) : I = P ^ i := by
refine le_antisymm hle ?_
have P_prime' := Ideal.prime_of_isPrime hP P_prime
have h1 : I ≠ ⊥ := (lt_of_le_of_lt bot_le hlt).ne'
have := pow_ne_zero i hP
have h3 := pow_ne_zero (i + 1) hP
rw [← Ideal.dvdNotUnit_iff_lt, dvdNotUnit_iff_normalizedFactors_lt_normalizedFactors h1 h3,
normalizedFactors_pow, normalizedFactors_irreducible P_prime'.irreducible,
Multiset.nsmul_singleton, Multiset.lt_replicate_succ] at hlt
rw [← Ideal.dvd_iff_le, dvd_iff_normalizedFactors_le_normalizedFactors, normalizedFactors_pow,
normalizedFactors_irreducible P_prime'.irreducible, Multiset.nsmul_singleton]
all_goals assumption
theorem Ideal.pow_succ_lt_pow {P : Ideal A} [P_prime : P.IsPrime] (hP : P ≠ ⊥) (i : ℕ) :
P ^ (i + 1) < P ^ i :=
lt_of_le_of_ne (Ideal.pow_le_pow_right (Nat.le_succ _))
(mt (pow_inj_of_not_isUnit (mt Ideal.isUnit_iff.mp P_prime.ne_top) hP).mp i.succ_ne_self)
theorem Associates.le_singleton_iff (x : A) (n : ℕ) (I : Ideal A) :
Associates.mk I ^ n ≤ Associates.mk (Ideal.span {x}) ↔ x ∈ I ^ n := by
simp_rw [← Associates.dvd_eq_le, ← Associates.mk_pow, Associates.mk_dvd_mk,
Ideal.dvd_span_singleton]
variable {K}
lemma FractionalIdeal.le_inv_comm {I J : FractionalIdeal A⁰ K} (hI : I ≠ 0) (hJ : J ≠ 0) :
I ≤ J⁻¹ ↔ J ≤ I⁻¹ := by
rw [inv_eq, inv_eq, le_div_iff_mul_le hI, le_div_iff_mul_le hJ, mul_comm]
lemma FractionalIdeal.inv_le_comm {I J : FractionalIdeal A⁰ K} (hI : I ≠ 0) (hJ : J ≠ 0) :
I⁻¹ ≤ J ↔ J⁻¹ ≤ I := by
simpa using le_inv_comm (A := A) (K := K) (inv_ne_zero hI) (inv_ne_zero hJ)
@[simp]
theorem FractionalIdeal.inv_le_inv_iff {I J : FractionalIdeal A⁰ K} (hI : I ≠ 0) (hJ : J ≠ 0) :
I⁻¹ ≤ J⁻¹ ↔ J ≤ I := by
rw [le_inv_comm (inv_ne_zero hI) hJ, inv_inv]
open FractionalIdeal
/-- Strengthening of `IsLocalization.exist_integer_multiples`:
Let `J ≠ ⊤` be an ideal in a Dedekind domain `A`, and `f ≠ 0` a finite collection
of elements of `K = Frac(A)`, then we can multiply the elements of `f` by some `a : K`
to find a collection of elements of `A` that is not completely contained in `J`. -/
theorem Ideal.exist_integer_multiples_notMem {J : Ideal A} (hJ : J ≠ ⊤) {ι : Type*} (s : Finset ι)
(f : ι → K) {j} (hjs : j ∈ s) (hjf : f j ≠ 0) :
∃ a : K,
(∀ i ∈ s, IsLocalization.IsInteger A (a * f i)) ∧
∃ i ∈ s, a * f i ∉ (J : FractionalIdeal A⁰ K) := by
-- Consider the fractional ideal `I` spanned by the `f`s.
let I : FractionalIdeal A⁰ K := spanFinset A s f
have hI0 : I ≠ 0 := spanFinset_ne_zero.mpr ⟨j, hjs, hjf⟩
-- We claim the multiplier `a` we're looking for is in `I⁻¹ \ (J / I)`.
suffices ↑J / I < I⁻¹ by
obtain ⟨_, a, hI, hpI⟩ := SetLike.lt_iff_le_and_exists.mp this
rw [mem_inv_iff hI0] at hI
refine ⟨a, fun i hi => ?_, ?_⟩
-- By definition, `a ∈ I⁻¹` multiplies elements of `I` into elements of `1`,
-- in other words, `a * f i` is an integer.
· exact (mem_one_iff _).mp (hI (f i) (Submodule.subset_span (Set.mem_image_of_mem f hi)))
· contrapose! hpI
-- And if all `a`-multiples of `I` are an element of `J`,
-- then `a` is actually an element of `J / I`, contradiction.
refine (mem_div_iff_of_ne_zero hI0).mpr fun y hy => Submodule.span_induction ?_ ?_ ?_ ?_ hy
· rintro _ ⟨i, hi, rfl⟩; exact hpI i hi
· rw [mul_zero]; exact Submodule.zero_mem _
· intro x y _ _ hx hy; rw [mul_add]; exact Submodule.add_mem _ hx hy
· intro b x _ hx; rw [mul_smul_comm]; exact Submodule.smul_mem _ b hx
-- To show the inclusion of `J / I` into `I⁻¹ = 1 / I`, note that `J < I`.
rw [div_eq_mul_inv]
refine mul_lt_of_lt_one_left (by simpa [pos_iff_ne_zero]) ?_
rw [← coeIdeal_top]
-- And multiplying by `I⁻¹` is indeed strictly monotone.
exact
strictMono_of_le_iff_le (fun _ _ => (coeIdeal_le_coeIdeal K).symm)
(lt_top_iff_ne_top.mpr hJ)
@[deprecated (since := "2025-05-23")]
alias Ideal.exist_integer_multiples_not_mem := Ideal.exist_integer_multiples_notMem
lemma Ideal.mul_iInf (I : Ideal A) {ι : Type*} [Nonempty ι] (J : ι → Ideal A) :
I * ⨅ i, J i = ⨅ i, I * J i := by
by_cases hI : I = 0
· simp [hI]
refine (le_iInf fun i ↦ Ideal.mul_mono_right (iInf_le _ _)).antisymm ?_
have H : ⨅ i, I * J i ≤ I := (iInf_le _ (Nonempty.some ‹_›)).trans Ideal.mul_le_right
obtain ⟨K, hK⟩ := Ideal.dvd_iff_le.mpr H
grw [hK, le_iInf (a := K) fun i ↦ ?_]
rw [← mul_le_mul_iff_of_pos_left (a := I), ← hK]
· exact iInf_le _ _
· exact bot_lt_iff_ne_bot.mpr hI
lemma Ideal.iInf_mul (I : Ideal A) {ι : Type*} [Nonempty ι] (J : ι → Ideal A) :
(⨅ i, J i) * I = ⨅ i, J i * I := by
simp only [mul_iInf, mul_comm _ I]
lemma Ideal.mul_inf (I J K : Ideal A) : I * (J ⊓ K) = I * J ⊓ I * K := by
rw [inf_eq_iInf, Ideal.mul_iInf, inf_eq_iInf]
congr! 2 with ⟨⟩
lemma Ideal.inf_mul (I J K : Ideal A) : (I ⊓ J) * K = I * K ⊓ J * K := by
simp only [Ideal.mul_inf, mul_comm _ K]
lemma FractionalIdeal.mul_inf (I J K : FractionalIdeal A⁰ K) : I * (J ⊓ K) = I * J ⊓ I * K :=
mul_inf₀ (zero_le _) _ _
lemma FractionalIdeal.inf_mul (I J K : FractionalIdeal A⁰ K) : (I ⊓ J) * K = I * K ⊓ J * K :=
inf_mul₀ (zero_le _) _ _
section Gcd
namespace Ideal
/-! ### GCD and LCM of ideals in a Dedekind domain
We show that the gcd of two ideals in a Dedekind domain is just their supremum,
and the lcm is their infimum, and use this to instantiate `NormalizedGCDMonoid (Ideal A)`.
-/
@[simp]
theorem sup_mul_inf (I J : Ideal A) : (I ⊔ J) * (I ⊓ J) = I * J := by
letI := UniqueFactorizationMonoid.toNormalizedGCDMonoid (Ideal A)
have hgcd : gcd I J = I ⊔ J := by
rw [gcd_eq_normalize _ _, normalize_eq]
· rw [dvd_iff_le, sup_le_iff, ← dvd_iff_le, ← dvd_iff_le]
exact ⟨gcd_dvd_left _ _, gcd_dvd_right _ _⟩
· rw [dvd_gcd_iff, dvd_iff_le, dvd_iff_le]
simp
have hlcm : lcm I J = I ⊓ J := by
rw [lcm_eq_normalize _ _, normalize_eq]
· rw [lcm_dvd_iff, dvd_iff_le, dvd_iff_le]
simp
· rw [dvd_iff_le, le_inf_iff, ← dvd_iff_le, ← dvd_iff_le]
exact ⟨dvd_lcm_left _ _, dvd_lcm_right _ _⟩
rw [← hgcd, ← hlcm, associated_iff_eq.mp (gcd_mul_lcm _ _)]
/-- Ideals in a Dedekind domain have gcd and lcm operators that (trivially) are compatible with
the normalization operator. -/
noncomputable instance : NormalizedGCDMonoid (Ideal A) :=
{ Ideal.normalizationMonoid with
gcd := (· ⊔ ·)
gcd_dvd_left := fun _ _ => by simpa only [dvd_iff_le] using le_sup_left
gcd_dvd_right := fun _ _ => by simpa only [dvd_iff_le] using le_sup_right
dvd_gcd := by
simp only [dvd_iff_le]
exact fun h1 h2 => @sup_le (Ideal A) _ _ _ _ h1 h2
lcm := (· ⊓ ·)
lcm_zero_left := fun _ => by simp only [zero_eq_bot, bot_inf_eq]
lcm_zero_right := fun _ => by simp only [zero_eq_bot, inf_bot_eq]
gcd_mul_lcm := fun _ _ => by rw [associated_iff_eq, sup_mul_inf]
normalize_gcd := fun _ _ => normalize_eq _
normalize_lcm := fun _ _ => normalize_eq _ }
-- In fact, any lawful gcd and lcm would equal sup and inf respectively.
@[simp]
theorem gcd_eq_sup (I J : Ideal A) : gcd I J = I ⊔ J := rfl
@[simp]
theorem lcm_eq_inf (I J : Ideal A) : lcm I J = I ⊓ J := rfl
theorem isCoprime_iff_gcd {I J : Ideal A} : IsCoprime I J ↔ gcd I J = 1 := by
rw [Ideal.isCoprime_iff_codisjoint, codisjoint_iff, one_eq_top, gcd_eq_sup]
theorem factors_span_eq {p : K[X]} : factors (span {p}) = (factors p).map (fun q ↦ span {q}) := by
rcases eq_or_ne p 0 with rfl | hp; · simpa [Set.singleton_zero] using normalizedFactors_zero
have : ∀ q ∈ (factors p).map (fun q ↦ span {q}), Prime q := fun q hq ↦ by
obtain ⟨r, hr, rfl⟩ := Multiset.mem_map.mp hq
exact prime_span_singleton_iff.mpr <| prime_of_factor r hr
rw [← span_singleton_eq_span_singleton.mpr (factors_prod hp), ← multiset_prod_span_singleton,
factors_eq_normalizedFactors, normalizedFactors_prod_of_prime this]
lemma _root_.FractionalIdeal.sup_mul_inf (I J : FractionalIdeal A⁰ K) :
(I ⊓ J) * (I ⊔ J) = I * J := by
apply mul_left_injective₀ (b := spanSingleton A⁰ (algebraMap A K
(I.den.1 * I.den.1 * J.den.1 * J.den.1))) (by simp [spanSingleton_eq_zero_iff])
have := Ideal.sup_mul_inf (Ideal.span {J.den.1} * I.num) (Ideal.span {I.den.1} * J.num)
simp only [← coeIdeal_inj (K := K), coeIdeal_mul, coeIdeal_sup, coeIdeal_inf,
← den_mul_self_eq_num', coeIdeal_span_singleton] at this
rw [mul_left_comm, ← mul_add, ← mul_add, ← mul_inf₀ (FractionalIdeal.zero_le _),
← mul_inf₀ (FractionalIdeal.zero_le _)] at this
simp only [FractionalIdeal.sup_eq_add, _root_.map_mul, ← spanSingleton_mul_spanSingleton]
convert this using 1 <;> ring
end Ideal
end Gcd
end IsDedekindDomain
section IsDedekindDomain
variable {T : Type*} [CommRing T] [IsDedekindDomain T] {I J : Ideal T}
open Multiset UniqueFactorizationMonoid Ideal
theorem prod_normalizedFactors_eq_self (hI : I ≠ ⊥) : (normalizedFactors I).prod = I :=
associated_iff_eq.1 (prod_normalizedFactors hI)
theorem count_le_of_ideal_ge [DecidableEq (Ideal T)]
{I J : Ideal T} (h : I ≤ J) (hI : I ≠ ⊥) (K : Ideal T) :
count K (normalizedFactors J) ≤ count K (normalizedFactors I) :=
le_iff_count.1 ((dvd_iff_normalizedFactors_le_normalizedFactors (ne_bot_of_le_ne_bot hI h) hI).1
(dvd_iff_le.2 h))
_
theorem sup_eq_prod_inf_factors [DecidableEq (Ideal T)] (hI : I ≠ ⊥) (hJ : J ≠ ⊥) :
I ⊔ J = (normalizedFactors I ∩ normalizedFactors J).prod := by
have H : normalizedFactors (normalizedFactors I ∩ normalizedFactors J).prod =
normalizedFactors I ∩ normalizedFactors J := by
apply normalizedFactors_prod_of_prime
intro p hp
rw [mem_inter] at hp
exact prime_of_normalized_factor p hp.left
have := Multiset.prod_ne_zero_of_prime (normalizedFactors I ∩ normalizedFactors J) fun _ h =>
prime_of_normalized_factor _ (Multiset.mem_inter.1 h).1
apply le_antisymm
· rw [sup_le_iff, ← dvd_iff_le, ← dvd_iff_le]
constructor
· rw [dvd_iff_normalizedFactors_le_normalizedFactors this hI, H]
exact inf_le_left
· rw [dvd_iff_normalizedFactors_le_normalizedFactors this hJ, H]
exact inf_le_right
· rw [← dvd_iff_le, dvd_iff_normalizedFactors_le_normalizedFactors,
normalizedFactors_prod_of_prime, le_iff_count]
· intro a
rw [Multiset.count_inter]
exact le_min (count_le_of_ideal_ge le_sup_left hI a) (count_le_of_ideal_ge le_sup_right hJ a)
· intro p hp
rw [mem_inter] at hp
exact prime_of_normalized_factor p hp.left
· exact ne_bot_of_le_ne_bot hI le_sup_left
· exact this
theorem irreducible_pow_sup [DecidableEq (Ideal T)] (hI : I ≠ ⊥) (hJ : Irreducible J) (n : ℕ) :
J ^ n ⊔ I = J ^ min ((normalizedFactors I).count J) n := by
rw [sup_eq_prod_inf_factors (pow_ne_zero n hJ.ne_zero) hI, min_comm,
normalizedFactors_of_irreducible_pow hJ, normalize_eq J, replicate_inter, prod_replicate]
theorem irreducible_pow_sup_of_le (hJ : Irreducible J) (n : ℕ) (hn : n ≤ emultiplicity J I) :
J ^ n ⊔ I = J ^ n := by
classical
by_cases hI : I = ⊥
· simp_all
rw [irreducible_pow_sup hI hJ, min_eq_right]
rw [emultiplicity_eq_count_normalizedFactors hJ hI, normalize_eq J] at hn
exact_mod_cast hn
theorem irreducible_pow_sup_of_ge (hI : I ≠ ⊥) (hJ : Irreducible J) (n : ℕ)
(hn : emultiplicity J I ≤ n) : J ^ n ⊔ I = J ^ multiplicity J I := by
classical
rw [irreducible_pow_sup hI hJ, min_eq_left]
· congr
rw [← Nat.cast_inj (R := ℕ∞), ← FiniteMultiplicity.emultiplicity_eq_multiplicity,
emultiplicity_eq_count_normalizedFactors hJ hI, normalize_eq J]
rw [← emultiplicity_lt_top]
apply hn.trans_lt
simp
· rw [emultiplicity_eq_count_normalizedFactors hJ hI, normalize_eq J] at hn
exact_mod_cast hn
theorem Ideal.eq_prime_pow_mul_coprime [DecidableEq (Ideal T)] {I : Ideal T} (hI : I ≠ ⊥)
(P : Ideal T) [hpm : P.IsMaximal] :
∃ Q : Ideal T, P ⊔ Q = ⊤ ∧ I = P ^ (Multiset.count P (normalizedFactors I)) * Q := by
use (filter (¬ P = ·) (normalizedFactors I)).prod
constructor
· refine P.sup_multiset_prod_eq_top (fun p hpi ↦ ?_)
have hp : Prime p := prime_of_normalized_factor p (filter_subset _ (normalizedFactors I) hpi)
exact hpm.coprime_of_ne ((isPrime_of_prime hp).isMaximal hp.ne_zero) (of_mem_filter hpi)
· nth_rw 1 [← prod_normalizedFactors_eq_self hI, ← filter_add_not (P = ·) (normalizedFactors I)]
rw [prod_add, pow_count]
end IsDedekindDomain
/-!
### Height one spectrum of a Dedekind domain
If `R` is a Dedekind domain of Krull dimension 1, the maximal ideals of `R` are exactly its nonzero
prime ideals.
We define `HeightOneSpectrum` and provide lemmas to recover the facts that prime ideals of height
one are prime and irreducible.
-/
namespace IsDedekindDomain
variable [IsDedekindDomain R]
/-- The height one prime spectrum of a Dedekind domain `R` is the type of nonzero prime ideals of
`R`. Note that this equals the maximal spectrum if `R` has Krull dimension 1. -/
@[ext, nolint unusedArguments]
structure HeightOneSpectrum where
asIdeal : Ideal R
isPrime : asIdeal.IsPrime
ne_bot : asIdeal ≠ ⊥
attribute [instance] HeightOneSpectrum.isPrime
variable (v : HeightOneSpectrum R) {R}
namespace HeightOneSpectrum
instance isMaximal : v.asIdeal.IsMaximal := v.isPrime.isMaximal v.ne_bot
theorem prime : Prime v.asIdeal := Ideal.prime_of_isPrime v.ne_bot v.isPrime
/--
The (nonzero) prime elements of the monoid with zero `Ideal R` correspond
to an element of type `HeightOneSpectrum R`.
See `IsDedekindDomain.HeightOneSpectrum.prime` for the inverse direction. -/
@[simps]
def ofPrime {p : Ideal R} (hp : Prime p) : HeightOneSpectrum R :=
⟨p, Ideal.isPrime_of_prime hp, hp.ne_zero⟩
theorem irreducible : Irreducible v.asIdeal :=
UniqueFactorizationMonoid.irreducible_iff_prime.mpr v.prime
theorem associates_irreducible : Irreducible <| Associates.mk v.asIdeal :=
Associates.irreducible_mk.mpr v.irreducible
/-- An equivalence between the height one and maximal spectra for rings of Krull dimension 1. -/
def equivMaximalSpectrum (hR : ¬IsField R) : HeightOneSpectrum R ≃ MaximalSpectrum R where
toFun v := ⟨v.asIdeal, v.isPrime.isMaximal v.ne_bot⟩
invFun v :=
⟨v.asIdeal, v.isMaximal.isPrime, Ring.ne_bot_of_isMaximal_of_not_isField v.isMaximal hR⟩
/-- An ideal of `R` is not the whole ring if and only if it is contained in an element of
`HeightOneSpectrum R` -/
theorem ideal_ne_top_iff_exists (hR : ¬IsField R) (I : Ideal R) :
I ≠ ⊤ ↔ ∃ P : HeightOneSpectrum R, I ≤ P.asIdeal := by
rw [Ideal.ne_top_iff_exists_maximal]
constructor
· rintro ⟨M, hMmax, hIM⟩
exact ⟨(equivMaximalSpectrum hR).symm ⟨M, hMmax⟩, hIM⟩
· rintro ⟨P, hP⟩
exact ⟨((equivMaximalSpectrum hR) P).asIdeal, ((equivMaximalSpectrum hR) P).isMaximal, hP⟩
variable (R)
/-- A Dedekind domain is equal to the intersection of its localizations at all its height one
non-zero prime ideals viewed as subalgebras of its field of fractions. -/
theorem iInf_localization_eq_bot [Algebra R K] [hK : IsFractionRing R K] :
(⨅ v : HeightOneSpectrum R,
Localization.subalgebra.ofField K _ v.asIdeal.primeCompl_le_nonZeroDivisors) = ⊥ := by
ext x
rw [Algebra.mem_iInf]
constructor
on_goal 1 => by_cases hR : IsField R
· rcases Function.bijective_iff_has_inverse.mp
(IsField.localization_map_bijective (Rₘ := K) (flip nonZeroDivisors.ne_zero rfl : 0 ∉ R⁰) hR)
with ⟨algebra_map_inv, _, algebra_map_right_inv⟩
exact fun _ => Algebra.mem_bot.mpr ⟨algebra_map_inv x, algebra_map_right_inv x⟩
all_goals rw [← MaximalSpectrum.iInf_localization_eq_bot, Algebra.mem_iInf]
· exact fun hx ⟨v, hv⟩ => hx ((equivMaximalSpectrum hR).symm ⟨v, hv⟩)
· exact fun hx ⟨v, hv, hbot⟩ => hx ⟨v, hv.isMaximal hbot⟩
end HeightOneSpectrum
end IsDedekindDomain
section
open Ideal
variable {R A}
variable [IsDedekindDomain A] {I : Ideal R} {J : Ideal A}
/-- The map from ideals of `R` dividing `I` to the ideals of `A` dividing `J` induced by
a homomorphism `f : R/I →+* A/J` -/
@[simps]
def idealFactorsFunOfQuotHom {f : R ⧸ I →+* A ⧸ J} (hf : Function.Surjective f) :
{p : Ideal R // p ∣ I} →o {p : Ideal A // p ∣ J} where
toFun X := ⟨comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) X)), by
have : RingHom.ker (Ideal.Quotient.mk J) ≤
comap (Ideal.Quotient.mk J) (map f (map (Ideal.Quotient.mk I) X)) :=
ker_le_comap (Ideal.Quotient.mk J)
rw [mk_ker] at this
exact dvd_iff_le.mpr this⟩
monotone' := by
rintro ⟨X, hX⟩ ⟨Y, hY⟩ h
rw [← Subtype.coe_le_coe, Subtype.coe_mk, Subtype.coe_mk] at h ⊢
rw [Subtype.coe_mk, comap_le_comap_iff_of_surjective (Ideal.Quotient.mk J)
Ideal.Quotient.mk_surjective, map_le_iff_le_comap, Subtype.coe_mk,
comap_map_of_surjective _ hf (map (Ideal.Quotient.mk I) Y)]
suffices map (Ideal.Quotient.mk I) X ≤ map (Ideal.Quotient.mk I) Y by
exact le_sup_of_le_left this
rwa [map_le_iff_le_comap, comap_map_of_surjective (Ideal.Quotient.mk I)
Ideal.Quotient.mk_surjective, ← RingHom.ker_eq_comap_bot, mk_ker,
sup_eq_left.mpr <| le_of_dvd hY]
@[simp]
theorem idealFactorsFunOfQuotHom_id :
idealFactorsFunOfQuotHom (RingHom.id (A ⧸ J)).surjective = OrderHom.id :=
OrderHom.ext _ _
(funext fun X => by
simp only [idealFactorsFunOfQuotHom, map_id, OrderHom.coe_mk, OrderHom.id_coe, id,
comap_map_of_surjective (Ideal.Quotient.mk J) Ideal.Quotient.mk_surjective, ←
RingHom.ker_eq_comap_bot (Ideal.Quotient.mk J), mk_ker,
sup_eq_left.mpr (dvd_iff_le.mp X.prop), Subtype.coe_eta])
variable {B : Type*} [CommRing B] [IsDedekindDomain B] {L : Ideal B}
theorem idealFactorsFunOfQuotHom_comp {f : R ⧸ I →+* A ⧸ J} {g : A ⧸ J →+* B ⧸ L}
(hf : Function.Surjective f) (hg : Function.Surjective g) :
(idealFactorsFunOfQuotHom hg).comp (idealFactorsFunOfQuotHom hf) =
idealFactorsFunOfQuotHom (show Function.Surjective (g.comp f) from hg.comp hf) := by
refine OrderHom.ext _ _ (funext fun x => ?_)
rw [idealFactorsFunOfQuotHom, idealFactorsFunOfQuotHom, OrderHom.comp_coe, OrderHom.coe_mk,
OrderHom.coe_mk, Function.comp_apply, idealFactorsFunOfQuotHom, OrderHom.coe_mk,
Subtype.mk_eq_mk, Subtype.coe_mk, map_comap_of_surjective (Ideal.Quotient.mk J)
Ideal.Quotient.mk_surjective, map_map]
variable [IsDedekindDomain R] (f : R ⧸ I ≃+* A ⧸ J)
/-- The bijection between ideals of `R` dividing `I` and the ideals of `A` dividing `J` induced by
an isomorphism `f : R/I ≅ A/J`. -/
def idealFactorsEquivOfQuotEquiv : { p : Ideal R | p ∣ I } ≃o { p : Ideal A | p ∣ J } := by
have f_surj : Function.Surjective (f : R ⧸ I →+* A ⧸ J) := f.surjective
have fsym_surj : Function.Surjective (f.symm : A ⧸ J →+* R ⧸ I) := f.symm.surjective
refine OrderIso.ofHomInv (idealFactorsFunOfQuotHom f_surj) (idealFactorsFunOfQuotHom fsym_surj)
?_ ?_
· have := idealFactorsFunOfQuotHom_comp fsym_surj f_surj
simp only [RingEquiv.comp_symm, idealFactorsFunOfQuotHom_id] at this
rw [← this, OrderHom.coe_eq, OrderHom.coe_eq]
· have := idealFactorsFunOfQuotHom_comp f_surj fsym_surj
simp only [RingEquiv.symm_comp, idealFactorsFunOfQuotHom_id] at this
rw [← this, OrderHom.coe_eq, OrderHom.coe_eq]
theorem idealFactorsEquivOfQuotEquiv_symm :
(idealFactorsEquivOfQuotEquiv f).symm = idealFactorsEquivOfQuotEquiv f.symm := rfl
theorem idealFactorsEquivOfQuotEquiv_is_dvd_iso {L M : Ideal R} (hL : L ∣ I) (hM : M ∣ I) :
(idealFactorsEquivOfQuotEquiv f ⟨L, hL⟩ : Ideal A) ∣ idealFactorsEquivOfQuotEquiv f ⟨M, hM⟩ ↔
L ∣ M := by
suffices
idealFactorsEquivOfQuotEquiv f ⟨M, hM⟩ ≤ idealFactorsEquivOfQuotEquiv f ⟨L, hL⟩ ↔
(⟨M, hM⟩ : { p : Ideal R | p ∣ I }) ≤ ⟨L, hL⟩
by rw [dvd_iff_le, dvd_iff_le, Subtype.coe_le_coe, this, Subtype.mk_le_mk]
exact (idealFactorsEquivOfQuotEquiv f).le_iff_le
open UniqueFactorizationMonoid
theorem idealFactorsEquivOfQuotEquiv_mem_normalizedFactors_of_mem_normalizedFactors (hJ : J ≠ ⊥)
{L : Ideal R} (hL : L ∈ normalizedFactors I) :
↑(idealFactorsEquivOfQuotEquiv f ⟨L, dvd_of_mem_normalizedFactors hL⟩)
∈ normalizedFactors J := by
have hI : I ≠ ⊥ := by
intro hI
rw [hI, bot_eq_zero, normalizedFactors_zero, ← Multiset.empty_eq_zero] at hL
exact Finset.notMem_empty _ hL
refine mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors hI hJ hL
(d := (idealFactorsEquivOfQuotEquiv f).toEquiv) ?_
rintro ⟨l, hl⟩ ⟨l', hl'⟩
rw [Subtype.coe_mk, Subtype.coe_mk]
apply idealFactorsEquivOfQuotEquiv_is_dvd_iso f
/-- The bijection between the sets of normalized factors of I and J induced by a ring
isomorphism `f : R/I ≅ A/J`. -/
def normalizedFactorsEquivOfQuotEquiv (hI : I ≠ ⊥) (hJ : J ≠ ⊥) :
{ L : Ideal R | L ∈ normalizedFactors I } ≃ { M : Ideal A | M ∈ normalizedFactors J } where
toFun j :=
⟨idealFactorsEquivOfQuotEquiv f ⟨↑j, dvd_of_mem_normalizedFactors j.prop⟩,
idealFactorsEquivOfQuotEquiv_mem_normalizedFactors_of_mem_normalizedFactors f hJ j.prop⟩
invFun j :=
⟨(idealFactorsEquivOfQuotEquiv f).symm ⟨↑j, dvd_of_mem_normalizedFactors j.prop⟩, by
rw [idealFactorsEquivOfQuotEquiv_symm]
exact
idealFactorsEquivOfQuotEquiv_mem_normalizedFactors_of_mem_normalizedFactors f.symm hI
j.prop⟩
left_inv := fun ⟨j, hj⟩ => by simp
right_inv := fun ⟨j, hj⟩ => by simp [-Set.coe_setOf]
@[simp]
theorem normalizedFactorsEquivOfQuotEquiv_symm (hI : I ≠ ⊥) (hJ : J ≠ ⊥) :
(normalizedFactorsEquivOfQuotEquiv f hI hJ).symm =
normalizedFactorsEquivOfQuotEquiv f.symm hJ hI := rfl
/-- The map `normalizedFactorsEquivOfQuotEquiv` preserves multiplicities. -/
theorem normalizedFactorsEquivOfQuotEquiv_emultiplicity_eq_emultiplicity (hI : I ≠ ⊥) (hJ : J ≠ ⊥)
(L : Ideal R) (hL : L ∈ normalizedFactors I) :
emultiplicity (↑(normalizedFactorsEquivOfQuotEquiv f hI hJ ⟨L, hL⟩)) J = emultiplicity L I := by
rw [normalizedFactorsEquivOfQuotEquiv, Equiv.coe_fn_mk, Subtype.coe_mk]
refine emultiplicity_factor_dvd_iso_eq_emultiplicity_of_mem_normalizedFactors hI hJ hL
(d := (idealFactorsEquivOfQuotEquiv f).toEquiv) ?_
exact fun ⟨l, hl⟩ ⟨l', hl'⟩ => idealFactorsEquivOfQuotEquiv_is_dvd_iso f hl hl'
end
section ChineseRemainder
open Ideal UniqueFactorizationMonoid
variable {R}
theorem Ring.DimensionLeOne.prime_le_prime_iff_eq [Ring.DimensionLEOne R] {P Q : Ideal R}
[hP : P.IsPrime] [hQ : Q.IsPrime] (hP0 : P ≠ ⊥) : P ≤ Q ↔ P = Q :=
⟨(hP.isMaximal hP0).eq_of_le hQ.ne_top, Eq.le⟩
section DedekindDomain
variable [IsDedekindDomain R]
theorem Ideal.IsPrime.mul_mem_pow (I : Ideal R) [hI : I.IsPrime] {a b : R} {n : ℕ}
(h : a * b ∈ I ^ n) : a ∈ I ∨ b ∈ I ^ n := by
cases n; · simp
by_cases hI0 : I = ⊥; · simpa [pow_succ, hI0] using h
simp only [← Submodule.span_singleton_le_iff_mem, Ideal.submodule_span_eq, ← Ideal.dvd_iff_le, ←
Ideal.span_singleton_mul_span_singleton] at h ⊢
by_cases ha : I ∣ span {a}
· exact Or.inl ha
rw [mul_comm] at h
exact Or.inr (Prime.pow_dvd_of_dvd_mul_right ((Ideal.prime_iff_isPrime hI0).mpr hI) _ ha h)
theorem Ideal.IsPrime.mem_pow_mul (I : Ideal R) [hI : I.IsPrime] {a b : R} {n : ℕ}
(h : a * b ∈ I ^ n) : a ∈ I ^ n ∨ b ∈ I := by
rw [mul_comm] at h
rw [or_comm]
exact Ideal.IsPrime.mul_mem_pow _ h
section
theorem Ideal.count_normalizedFactors_eq {p x : Ideal R} [hp : p.IsPrime] {n : ℕ} (hle : x ≤ p ^ n)
[DecidableEq (Ideal R)] (hlt : ¬x ≤ p ^ (n + 1)) : (normalizedFactors x).count p = n :=
count_normalizedFactors_eq' ((Ideal.isPrime_iff_bot_or_prime.mp hp).imp_right Prime.irreducible)
(normalize_eq _) (Ideal.dvd_iff_le.mpr hle) (mt Ideal.le_of_dvd hlt)
/-- The number of times an ideal `I` occurs as normalized factor of another ideal `J` is stable
when regarding these ideals as associated elements of the monoid of ideals. -/
theorem count_associates_factors_eq [DecidableEq (Ideal R)] [DecidableEq <| Associates (Ideal R)]
[∀ (p : Associates <| Ideal R), Decidable (Irreducible p)]
{I J : Ideal R} (hI : I ≠ 0) (hJ : J.IsPrime) (hJ₀ : J ≠ ⊥) :
(Associates.mk J).count (Associates.mk I).factors = Multiset.count J (normalizedFactors I) := by
replace hI : Associates.mk I ≠ 0 := Associates.mk_ne_zero.mpr hI
have hJ' : Irreducible (Associates.mk J) := by
simpa only [Associates.irreducible_mk] using (Ideal.prime_of_isPrime hJ₀ hJ).irreducible
apply (Ideal.count_normalizedFactors_eq (p := J) (x := I) _ _).symm
all_goals
rw [← Ideal.dvd_iff_le, ← Associates.mk_dvd_mk, Associates.mk_pow]
simp only [Associates.dvd_eq_le]
rw [Associates.prime_pow_dvd_iff_le hI hJ']
cutsat
/-- Variant of `UniqueFactorizationMonoid.count_normalizedFactors_eq` for associated Ideals. -/
theorem Ideal.count_associates_eq [DecidableEq (Associates (Ideal R))]
[∀ (p : Associates <| Ideal R), Decidable (Irreducible p)]
{a a₀ x : R} {n : ℕ} (hx : Prime x) (ha : ¬x ∣ a) (heq : a₀ = x ^ n * a) :
(Associates.mk (span {x})).count (Associates.mk (span {a₀})).factors = n := by
have hx0 : x ≠ 0 := Prime.ne_zero hx
classical
rw [count_associates_factors_eq, UniqueFactorizationMonoid.count_normalizedFactors_eq]
· exact (prime_span_singleton_iff.mpr hx).irreducible
· exact normalize_eq _
· simp only [span_singleton_pow, heq, dvd_span_singleton]
exact Ideal.mul_mem_right _ _ (mem_span_singleton_self (x ^ n))
· simp only [span_singleton_pow, heq, dvd_span_singleton, mem_span_singleton]
rw [pow_add, pow_one, mul_dvd_mul_iff_left (pow_ne_zero n hx0)]
exact ha
· simp only [Submodule.zero_eq_bot, ne_eq, span_singleton_eq_bot]
aesop
· exact (span_singleton_prime hx0).mpr hx
· simp only [ne_eq, span_singleton_eq_bot]; exact hx0
/-- Variant of `UniqueFactorizationMonoid.count_normalizedFactors_eq` for associated Ideals. -/
theorem Ideal.count_associates_eq' [DecidableEq (Associates (Ideal R))]
[∀ (p : Associates <| Ideal R), Decidable (Irreducible p)]
{a x : R} (hx : Prime x) {n : ℕ} (hle : x ^ n ∣ a) (hlt : ¬x ^ (n + 1) ∣ a) :
(Associates.mk (span {x})).count (Associates.mk (span {a})).factors = n := by
obtain ⟨q, hq⟩ := hle
apply Ideal.count_associates_eq hx _ hq
contrapose! hlt with hdvd
obtain ⟨q', hq'⟩ := hdvd
use q'
rw [hq, hq']
ring
end
theorem Ideal.le_mul_of_no_prime_factors {I J K : Ideal R}
(coprime : ∀ P, J ≤ P → K ≤ P → ¬IsPrime P) (hJ : I ≤ J) (hK : I ≤ K) : I ≤ J * K := by
simp only [← Ideal.dvd_iff_le] at coprime hJ hK ⊢
by_cases hJ0 : J = 0
· simpa only [hJ0, zero_mul] using hJ
obtain ⟨I', rfl⟩ := hK
rw [mul_comm]
refine mul_dvd_mul_left K
(UniqueFactorizationMonoid.dvd_of_dvd_mul_right_of_no_prime_factors (b := K) hJ0 ?_ hJ)
exact fun hPJ hPK => mt Ideal.isPrime_of_prime (coprime _ hPJ hPK)
/-- The intersection of distinct prime powers in a Dedekind domain is the product of these
prime powers. -/
theorem IsDedekindDomain.inf_prime_pow_eq_prod {ι : Type*} (s : Finset ι) (f : ι → Ideal R)
(e : ι → ℕ) (prime : ∀ i ∈ s, Prime (f i))
(coprime : ∀ᵉ (i ∈ s) (j ∈ s), i ≠ j → f i ≠ f j) :
(s.inf fun i => f i ^ e i) = ∏ i ∈ s, f i ^ e i := by
letI := Classical.decEq ι
revert prime coprime
refine s.induction ?_ ?_
· simp
intro a s ha ih prime coprime
specialize
ih (fun i hi => prime i (Finset.mem_insert_of_mem hi)) fun i hi j hj =>
coprime i (Finset.mem_insert_of_mem hi) j (Finset.mem_insert_of_mem hj)
rw [Finset.inf_insert, Finset.prod_insert ha, ih]
refine le_antisymm (Ideal.le_mul_of_no_prime_factors ?_ inf_le_left inf_le_right) Ideal.mul_le_inf
intro P hPa hPs hPp
obtain ⟨b, hb, hPb⟩ := hPp.prod_le.mp hPs
haveI := Ideal.isPrime_of_prime (prime a (Finset.mem_insert_self a s))
haveI := Ideal.isPrime_of_prime (prime b (Finset.mem_insert_of_mem hb))
refine coprime a (Finset.mem_insert_self a s) b (Finset.mem_insert_of_mem hb) ?_ ?_
· exact (ne_of_mem_of_not_mem hb ha).symm
· refine ((Ring.DimensionLeOne.prime_le_prime_iff_eq ?_).mp (hPp.le_of_pow_le hPa)).trans
((Ring.DimensionLeOne.prime_le_prime_iff_eq ?_).mp (hPp.le_of_pow_le hPb)).symm
· exact (prime a (Finset.mem_insert_self a s)).ne_zero
· exact (prime b (Finset.mem_insert_of_mem hb)).ne_zero
/-- **Chinese remainder theorem** for a Dedekind domain: if the ideal `I` factors as
`∏ i, P i ^ e i`, then `R ⧸ I` factors as `Π i, R ⧸ (P i ^ e i)`. -/
noncomputable def IsDedekindDomain.quotientEquivPiOfProdEq {ι : Type*} [Fintype ι] (I : Ideal R)
(P : ι → Ideal R) (e : ι → ℕ) (prime : ∀ i, Prime (P i))
(coprime : Pairwise fun i j => P i ≠ P j)
(prod_eq : ∏ i, P i ^ e i = I) : R ⧸ I ≃+* ∀ i, R ⧸ P i ^ e i :=
(Ideal.quotEquivOfEq
(by
simp only [← prod_eq, Finset.inf_eq_iInf, Finset.mem_univ, ciInf_pos,
← IsDedekindDomain.inf_prime_pow_eq_prod _ _ _ (fun i _ => prime i)
(coprime.set_pairwise _)])).trans <|
Ideal.quotientInfRingEquivPiQuotient _ fun i j hij => Ideal.coprime_of_no_prime_ge <| by
intro P hPi hPj hPp
haveI := Ideal.isPrime_of_prime (prime i)
haveI := Ideal.isPrime_of_prime (prime j)
exact coprime hij <| ((Ring.DimensionLeOne.prime_le_prime_iff_eq (prime i).ne_zero).mp
(hPp.le_of_pow_le hPi)).trans <| Eq.symm <|
(Ring.DimensionLeOne.prime_le_prime_iff_eq (prime j).ne_zero).mp (hPp.le_of_pow_le hPj)
open scoped Classical in
/-- **Chinese remainder theorem** for a Dedekind domain: `R ⧸ I` factors as `Π i, R ⧸ (P i ^ e i)`,
where `P i` ranges over the prime factors of `I` and `e i` over the multiplicities. -/
noncomputable def IsDedekindDomain.quotientEquivPiFactors {I : Ideal R} (hI : I ≠ ⊥) :
R ⧸ I ≃+* ∀ P : (factors I).toFinset, R ⧸ (P : Ideal R) ^ (Multiset.count ↑P (factors I)) :=
IsDedekindDomain.quotientEquivPiOfProdEq _ _ _
(fun P : (factors I).toFinset => prime_of_factor _ (Multiset.mem_toFinset.mp P.prop))
(fun _ _ hij => Subtype.coe_injective.ne hij)
(calc
(∏ P : (factors I).toFinset, (P : Ideal R) ^ (factors I).count (P : Ideal R)) =
∏ P ∈ (factors I).toFinset, P ^ (factors I).count P :=
(factors I).toFinset.prod_coe_sort fun P => P ^ (factors I).count P
_ = ((factors I).map fun P => P).prod := (Finset.prod_multiset_map_count (factors I) id).symm
_ = (factors I).prod := by rw [Multiset.map_id']
_ = I := associated_iff_eq.mp (factors_prod hI)
)
@[simp]
theorem IsDedekindDomain.quotientEquivPiFactors_mk {I : Ideal R} (hI : I ≠ ⊥) (x : R) :
IsDedekindDomain.quotientEquivPiFactors hI (Ideal.Quotient.mk I x) = fun _P =>
Ideal.Quotient.mk _ x := rfl
/-- **Chinese remainder theorem** for a Dedekind domain: if the ideal `I` factors as
`∏ i ∈ s, P i ^ e i`, then `R ⧸ I` factors as `Π (i : s), R ⧸ (P i ^ e i)`.
This is a version of `IsDedekindDomain.quotientEquivPiOfProdEq` where we restrict
the product to a finite subset `s` of a potentially infinite indexing type `ι`.
-/
noncomputable def IsDedekindDomain.quotientEquivPiOfFinsetProdEq {ι : Type*} {s : Finset ι}
(I : Ideal R) (P : ι → Ideal R) (e : ι → ℕ) (prime : ∀ i ∈ s, Prime (P i))
(coprime : ∀ᵉ (i ∈ s) (j ∈ s), i ≠ j → P i ≠ P j)
(prod_eq : ∏ i ∈ s, P i ^ e i = I) : R ⧸ I ≃+* ∀ i : s, R ⧸ P i ^ e i :=
IsDedekindDomain.quotientEquivPiOfProdEq I (fun i : s => P i) (fun i : s => e i)
(fun i => prime i i.2) (fun i j h => coprime i i.2 j j.2 (Subtype.coe_injective.ne h))
(_root_.trans (Finset.prod_coe_sort s fun i => P i ^ e i) prod_eq)
/-- Corollary of the Chinese remainder theorem: given elements `x i : R / P i ^ e i`,
we can choose a representative `y : R` such that `y ≡ x i (mod P i ^ e i)`. -/
theorem IsDedekindDomain.exists_representative_mod_finset {ι : Type*} {s : Finset ι}
(P : ι → Ideal R) (e : ι → ℕ) (prime : ∀ i ∈ s, Prime (P i))
(coprime : ∀ᵉ (i ∈ s) (j ∈ s), i ≠ j → P i ≠ P j) (x : ∀ i : s, R ⧸ P i ^ e i) :
∃ y, ∀ (i) (hi : i ∈ s), Ideal.Quotient.mk (P i ^ e i) y = x ⟨i, hi⟩ := by
let f := IsDedekindDomain.quotientEquivPiOfFinsetProdEq _ P e prime coprime rfl
obtain ⟨y, rfl⟩ := f.surjective x
obtain ⟨z, rfl⟩ := Ideal.Quotient.mk_surjective y
exact ⟨z, fun i _hi => rfl⟩
/-- Corollary of the Chinese remainder theorem: given elements `x i : R`,
we can choose a representative `y : R` such that `y - x i ∈ P i ^ e i`. -/
theorem IsDedekindDomain.exists_forall_sub_mem_ideal {ι : Type*} {s : Finset ι} (P : ι → Ideal R)
(e : ι → ℕ) (prime : ∀ i ∈ s, Prime (P i))
(coprime : ∀ᵉ (i ∈ s) (j ∈ s), i ≠ j → P i ≠ P j) (x : s → R) :
∃ y, ∀ (i) (hi : i ∈ s), y - x ⟨i, hi⟩ ∈ P i ^ e i := by
obtain ⟨y, hy⟩ :=
IsDedekindDomain.exists_representative_mod_finset P e prime coprime fun i =>
Ideal.Quotient.mk _ (x i)
exact ⟨y, fun i hi => Ideal.Quotient.eq.mp (hy i hi)⟩
end DedekindDomain
end ChineseRemainder
section PID
open UniqueFactorizationMonoid Ideal
variable {R}
variable [IsDomain R] [IsPrincipalIdealRing R]
theorem span_singleton_dvd_span_singleton_iff_dvd {a b : R} :
Ideal.span {a} ∣ Ideal.span ({b} : Set R) ↔ a ∣ b :=
⟨fun h => mem_span_singleton.mp (dvd_iff_le.mp h (mem_span_singleton.mpr (dvd_refl b))), fun h =>
dvd_iff_le.mpr fun _d hd => mem_span_singleton.mpr (dvd_trans h (mem_span_singleton.mp hd))⟩
@[simp]
theorem Ideal.squarefree_span_singleton {a : R} :
Squarefree (span {a}) ↔ Squarefree a := by
refine ⟨fun h x hx ↦ ?_, fun h I hI ↦ ?_⟩
· rw [← span_singleton_dvd_span_singleton_iff_dvd, ← span_singleton_mul_span_singleton] at hx
simpa using h _ hx
· rw [← span_singleton_generator I, span_singleton_mul_span_singleton,
span_singleton_dvd_span_singleton_iff_dvd] at hI
exact isUnit_iff.mpr <| eq_top_of_isUnit_mem _ (Submodule.IsPrincipal.generator_mem I) (h _ hI)
theorem singleton_span_mem_normalizedFactors_of_mem_normalizedFactors [NormalizationMonoid R]
{a b : R} (ha : a ∈ normalizedFactors b) :
Ideal.span ({a} : Set R) ∈ normalizedFactors (Ideal.span ({b} : Set R)) := by
by_cases hb : b = 0
· rw [Ideal.span_singleton_eq_bot.mpr hb, bot_eq_zero, normalizedFactors_zero]
rw [hb, normalizedFactors_zero] at ha
exact absurd ha (Multiset.notMem_zero a)
· suffices Prime (Ideal.span ({a} : Set R)) by
obtain ⟨c, hc, hc'⟩ := exists_mem_normalizedFactors_of_dvd ?_ this.irreducible
(dvd_iff_le.mpr (span_singleton_le_span_singleton.mpr (dvd_of_mem_normalizedFactors ha)))
rwa [associated_iff_eq.mp hc']
· by_contra h
exact hb (span_singleton_eq_bot.mp h)
rw [prime_iff_isPrime]
· exact (span_singleton_prime (prime_of_normalized_factor a ha).ne_zero).mpr
(prime_of_normalized_factor a ha)
· by_contra h
exact (prime_of_normalized_factor a ha).ne_zero (span_singleton_eq_bot.mp h)
theorem emultiplicity_eq_emultiplicity_span {a b : R} :
emultiplicity (Ideal.span {a}) (Ideal.span ({b} : Set R)) = emultiplicity a b := by
by_cases h : FiniteMultiplicity a b
· rw [h.emultiplicity_eq_multiplicity]
apply emultiplicity_eq_of_dvd_of_not_dvd <;>
rw [Ideal.span_singleton_pow, span_singleton_dvd_span_singleton_iff_dvd]
· exact pow_multiplicity_dvd a b
· apply h.not_pow_dvd_of_multiplicity_lt
apply lt_add_one
· suffices ¬FiniteMultiplicity (Ideal.span ({a} : Set R)) (Ideal.span ({b} : Set R)) by
rw [emultiplicity_eq_top.2 h, emultiplicity_eq_top.2 this]
exact FiniteMultiplicity.not_iff_forall.mpr fun n => by
rw [Ideal.span_singleton_pow, span_singleton_dvd_span_singleton_iff_dvd]
exact FiniteMultiplicity.not_iff_forall.mp h n
section NormalizationMonoid
variable [NormalizationMonoid R]
/-- The bijection between the (normalized) prime factors of `r` and the (normalized) prime factors
of `span {r}` -/
noncomputable def normalizedFactorsEquivSpanNormalizedFactors {r : R} (hr : r ≠ 0) :
{ d : R | d ∈ normalizedFactors r } ≃
{ I : Ideal R | I ∈ normalizedFactors (Ideal.span ({r} : Set R)) } := by
refine Equiv.ofBijective ?_ ?_
· exact fun d =>
⟨Ideal.span {↑d}, singleton_span_mem_normalizedFactors_of_mem_normalizedFactors d.prop⟩
· refine ⟨?_, ?_⟩
· rintro ⟨a, ha⟩ ⟨b, hb⟩ h
rw [Subtype.mk_eq_mk, Ideal.span_singleton_eq_span_singleton, Subtype.coe_mk,
Subtype.coe_mk] at h
exact Subtype.mk_eq_mk.mpr (mem_normalizedFactors_eq_of_associated ha hb h)
· rintro ⟨i, hi⟩
have : i.IsPrime := isPrime_of_prime (prime_of_normalized_factor i hi)
have := exists_mem_normalizedFactors_of_dvd hr
(Submodule.IsPrincipal.prime_generator_of_isPrime i
(prime_of_normalized_factor i hi).ne_zero).irreducible ?_
· obtain ⟨a, ha, ha'⟩ := this
use ⟨a, ha⟩
simp only [← span_singleton_eq_span_singleton.mpr ha',
Ideal.span_singleton_generator]
· exact (Submodule.IsPrincipal.mem_iff_generator_dvd i).mp
((show Ideal.span {r} ≤ i from dvd_iff_le.mp (dvd_of_mem_normalizedFactors hi))
(mem_span_singleton.mpr (dvd_refl r)))
/-- The bijection `normalizedFactorsEquivSpanNormalizedFactors` between the set of prime
factors of `r` and the set of prime factors of the ideal `⟨r⟩` preserves multiplicities. See
`count_normalizedFactorsSpan_eq_count` for the version stated in terms of multisets `count`. -/
theorem emultiplicity_normalizedFactorsEquivSpanNormalizedFactors_eq_emultiplicity {r d : R}
(hr : r ≠ 0) (hd : d ∈ normalizedFactors r) :
emultiplicity d r =
emultiplicity (normalizedFactorsEquivSpanNormalizedFactors hr ⟨d, hd⟩ : Ideal R)
(Ideal.span {r}) := by
simp only [normalizedFactorsEquivSpanNormalizedFactors, emultiplicity_eq_emultiplicity_span,
Subtype.coe_mk, Equiv.ofBijective_apply]
/-- The bijection `normalized_factors_equiv_span_normalized_factors.symm` between the set of prime
factors of the ideal `⟨r⟩` and the set of prime factors of `r` preserves multiplicities. -/
theorem emultiplicity_normalizedFactorsEquivSpanNormalizedFactors_symm_eq_emultiplicity {r : R}
(hr : r ≠ 0) (I : { I : Ideal R | I ∈ normalizedFactors (Ideal.span ({r} : Set R)) }) :
emultiplicity ((normalizedFactorsEquivSpanNormalizedFactors hr).symm I : R) r =
emultiplicity (I : Ideal R) (Ideal.span {r}) := by
obtain ⟨x, hx⟩ := (normalizedFactorsEquivSpanNormalizedFactors hr).surjective I
obtain ⟨a, ha⟩ := x
rw [hx.symm, Equiv.symm_apply_apply, Subtype.coe_mk,
emultiplicity_normalizedFactorsEquivSpanNormalizedFactors_eq_emultiplicity hr ha]
variable [DecidableEq R] [DecidableEq (Ideal R)]
/-- The bijection between the set of prime factors of the ideal `⟨r⟩` and the set of prime factors
of `r` preserves `count` of the corresponding multisets. See
`multiplicity_normalizedFactorsEquivSpanNormalizedFactors_eq_multiplicity` for the version
stated in terms of multiplicity. -/
theorem count_span_normalizedFactors_eq {r X : R} (hr : r ≠ 0) (hX : Prime X) :
Multiset.count (Ideal.span {X} : Ideal R) (normalizedFactors (Ideal.span {r})) =
Multiset.count (normalize X) (normalizedFactors r) := by
have := emultiplicity_eq_emultiplicity_span (R := R) (a := X) (b := r)
rw [emultiplicity_eq_count_normalizedFactors (Prime.irreducible hX) hr,
emultiplicity_eq_count_normalizedFactors (Prime.irreducible ?_), normalize_apply,
normUnit_eq_one, Units.val_one, one_eq_top, mul_top, Nat.cast_inj] at this
· simp only [normalize_apply, this]
· simp only [Submodule.zero_eq_bot, ne_eq, span_singleton_eq_bot, hr, not_false_eq_true]
· simpa only [prime_span_singleton_iff]
theorem count_span_normalizedFactors_eq_of_normUnit {r X : R}
(hr : r ≠ 0) (hX₁ : normUnit X = 1) (hX : Prime X) :
Multiset.count (Ideal.span {X} : Ideal R) (normalizedFactors (Ideal.span {r})) =
Multiset.count X (normalizedFactors r) := by
simpa [hX₁, normalize_apply] using count_span_normalizedFactors_eq hr hX
end NormalizationMonoid
end PID
section primesOverFinset
open UniqueFactorizationMonoid Ideal
open scoped Classical in
/-- The finite set of all prime factors of the pushforward of `p`. -/
noncomputable abbrev primesOverFinset {A : Type*} [CommRing A] (p : Ideal A) (B : Type*)
[CommRing B] [IsDedekindDomain B] [Algebra A B] : Finset (Ideal B) :=
(factors (p.map (algebraMap A B))).toFinset
variable {A : Type*} [CommRing A] {p : Ideal A} (hpb : p ≠ ⊥) [hpm : p.IsMaximal]
(B : Type*) [CommRing B] [IsDedekindDomain B] [Algebra A B] [NoZeroSMulDivisors A B]
include hpb in
theorem coe_primesOverFinset : primesOverFinset p B = primesOver p B := by
classical
ext P
rw [primesOverFinset, factors_eq_normalizedFactors, Finset.mem_coe, Multiset.mem_toFinset]
exact (P.mem_normalizedFactors_iff (map_ne_bot_of_ne_bot hpb)).trans <| Iff.intro
(fun ⟨hPp, h⟩ => ⟨hPp, ⟨hpm.eq_of_le (comap_ne_top _ hPp.ne_top) (le_comap_of_map_le h)⟩⟩)
(fun ⟨hPp, h⟩ => ⟨hPp, map_le_of_le_comap h.1.le⟩)
include hpb in
theorem mem_primesOverFinset_iff {P : Ideal B} : P ∈ primesOverFinset p B ↔ P ∈ primesOver p B := by
rw [← Finset.mem_coe, coe_primesOverFinset hpb]
variable {R} (A) in
theorem IsLocalRing.primesOverFinset_eq [IsLocalRing A] [IsDedekindDomain A]
[Algebra R A] [FaithfulSMul R A] [Module.Finite R A] {p : Ideal R} [p.IsMaximal] (hp0 : p ≠ ⊥) :
primesOverFinset p A = {IsLocalRing.maximalIdeal A} := by
rw [← Finset.coe_eq_singleton, coe_primesOverFinset hp0, IsLocalRing.primesOver_eq A hp0]
namespace IsDedekindDomain.HeightOneSpectrum
/--
The bijection between the elements of the height one prime spectrum of `B` that divide the lift
of the maximal ideal `p` in `B` and the primes over `p` in `B`.
-/
noncomputable def equivPrimesOver (hp : p ≠ 0) :
{v : HeightOneSpectrum B // v.asIdeal ∣ map (algebraMap A B) p} ≃ p.primesOver B :=
Set.BijOn.equiv HeightOneSpectrum.asIdeal
⟨fun v hv ↦ ⟨v.isPrime, by rwa [liesOver_iff_dvd_map v.isPrime.ne_top]⟩,
fun _ _ _ _ h ↦ HeightOneSpectrum.ext_iff.mpr h,
fun Q hQ ↦ ⟨⟨Q, hQ.1, ne_bot_of_mem_primesOver hp hQ⟩,
(liesOver_iff_dvd_map hQ.1.ne_top).mp hQ.2, rfl⟩⟩
@[simp]
theorem equivPrimesOver_apply (hp : p ≠ 0)
(v : {v : HeightOneSpectrum B // v.asIdeal ∣ map (algebraMap A B) p}) :
equivPrimesOver B hp v = v.1.asIdeal := rfl
end IsDedekindDomain.HeightOneSpectrum
variable (p) [Algebra.IsIntegral A B]
theorem primesOver_finite : (primesOver p B).Finite := by
by_cases hpb : p = ⊥
· rw [hpb] at hpm ⊢
haveI : IsDomain A := IsDomain.of_bot_isPrime A
rw [primesOver_bot A B]
exact Set.finite_singleton ⊥
· rw [← coe_primesOverFinset hpb B]
exact (primesOverFinset p B).finite_toSet
noncomputable instance : Fintype (p.primesOver B) := Set.Finite.fintype (primesOver_finite p B)
theorem primesOver_ncard_ne_zero : (primesOver p B).ncard ≠ 0 := by
rcases exists_maximal_ideal_liesOver_of_isIntegral (S := B) p with ⟨P, hPm, hp⟩
exact Set.ncard_ne_zero_of_mem ⟨hPm.isPrime, hp⟩ (primesOver_finite p B)
theorem one_le_primesOver_ncard : 1 ≤ (primesOver p B).ncard :=
Nat.one_le_iff_ne_zero.mpr (primesOver_ncard_ne_zero p B)
end primesOverFinset |
.lake/packages/mathlib/Mathlib/RingTheory/DedekindDomain/Ideal/Basic.lean | import Mathlib.Algebra.Algebra.Subalgebra.Pointwise
import Mathlib.RingTheory.DedekindDomain.Basic
import Mathlib.RingTheory.FractionalIdeal.Inverse
import Mathlib.RingTheory.Spectrum.Prime.Basic
/-!
# Dedekind domains and invertible ideals
In this file, we show a ring is a Dedekind domain iff all fractional ideals are invertible,
and prove instances such as the unique factorization of ideals.
Further results on the structure of ideals in a Dedekind domain are found in
`Mathlib/RingTheory/DedekindDomain/Ideal/Lemmas.lean`.
## Main definitions
- `IsDedekindDomainInv` alternatively defines a Dedekind domain as an integral domain where
every nonzero fractional ideal is invertible.
- `isDedekindDomainInv_iff` shows that this does note depend on the choice of field of
fractions.
## Main results:
- `isDedekindDomain_iff_isDedekindDomainInv`
- `Ideal.uniqueFactorizationMonoid`
## Implementation notes
The definitions that involve a field of fractions choose a canonical field of fractions,
but are independent of that choice. The `..._iff` lemmas express this independence.
Often, definitions assume that Dedekind domains are not fields. We found it more practical
to add a `(h : ¬ IsField A)` assumption whenever this is explicitly needed.
## References
* [D. Marcus, *Number Fields*][marcus1977number]
* [J.W.S. Cassels, A. Fröhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring
-/
variable (R A K : Type*) [CommRing R] [CommRing A] [Field K]
open scoped nonZeroDivisors Polynomial
section Inverse
section IsDedekindDomainInv
variable [IsDomain A]
/-- A Dedekind domain is an integral domain such that every fractional ideal has an inverse.
This is equivalent to `IsDedekindDomain`.
In particular we provide a `CommGroupWithZero` instance,
assuming `IsDedekindDomain A`, which implies `IsDedekindDomainInv`. For **integral** domain,
`IsDedekindDomain`(`Inv`) implies only `Ideal.cancelCommMonoidWithZero`.
-/
def IsDedekindDomainInv : Prop :=
∀ I ≠ (⊥ : FractionalIdeal A⁰ (FractionRing A)), I * I⁻¹ = 1
open FractionalIdeal
variable {R A K}
theorem isDedekindDomainInv_iff [Algebra A K] [IsFractionRing A K] :
IsDedekindDomainInv A ↔ ∀ I ≠ (⊥ : FractionalIdeal A⁰ K), I * I⁻¹ = 1 := by
let h : FractionalIdeal A⁰ (FractionRing A) ≃+* FractionalIdeal A⁰ K :=
FractionalIdeal.mapEquiv (FractionRing.algEquiv A K)
refine h.toEquiv.forall_congr (fun {x} => ?_)
rw [← h.toEquiv.apply_eq_iff_eq]
simp [h]
theorem FractionalIdeal.adjoinIntegral_eq_one_of_isUnit [Algebra A K] [IsFractionRing A K] (x : K)
(hx : IsIntegral A x) (hI : IsUnit (adjoinIntegral A⁰ x hx)) : adjoinIntegral A⁰ x hx = 1 := by
set I := adjoinIntegral A⁰ x hx
have mul_self : IsIdempotentElem I := by
apply coeToSubmodule_injective
simp only [coe_mul, adjoinIntegral_coe, I]
rw [(Algebra.adjoin A {x}).isIdempotentElem_toSubmodule]
convert congr_arg (· * I⁻¹) mul_self <;>
simp only [(mul_inv_cancel_iff_isUnit K).mpr hI, mul_assoc, mul_one]
namespace IsDedekindDomainInv
variable [Algebra A K] [IsFractionRing A K] (h : IsDedekindDomainInv A) {I J : FractionalIdeal A⁰ K}
include h
/-- `IsDedekindDomainInv A` implies that fractional ideals over it form a commutative group with
zero. -/
noncomputable abbrev commGroupWithZero : CommGroupWithZero (FractionalIdeal A⁰ K) where
inv_zero := inv_zero' _
mul_inv_cancel := isDedekindDomainInv_iff.mp h
div_eq_mul_inv I J := by
obtain rfl | hJ := eq_or_ne J 0
· simp [inv_zero']
refine le_antisymm ?_ ((FractionalIdeal.le_div_iff_mul_le hJ).2 ?_)
· suffices I / J * J ≤ I by
simpa [mul_assoc, isDedekindDomainInv_iff.mp h _ hJ] using mul_left_mono (a := J⁻¹) this
simp [FractionalIdeal.mul_le, mem_div_iff_of_ne_zero hJ]
· rw [mul_assoc, mul_comm _ J, isDedekindDomainInv_iff.mp h _ hJ, mul_one]
@[deprecated mul_inv_cancel₀ (since := "2025-09-09")]
protected lemma mul_inv_eq_one (hI : I ≠ 0) : I * I⁻¹ = 1 := by
let := h.commGroupWithZero (K := K); simp [*]
@[deprecated inv_mul_cancel₀ (since := "2025-09-09")]
protected lemma inv_mul_eq_one (hI : I ≠ 0) : I⁻¹ * I = 1 := by
let := h.commGroupWithZero (K := K); simp [*]
theorem isNoetherianRing : IsNoetherianRing A := by
let := h.commGroupWithZero (K := FractionRing A)
refine isNoetherianRing_iff.mpr ⟨fun I : Ideal A => ?_⟩
by_cases hI : I = ⊥
· rw [hI]; apply Submodule.fg_bot
have hI : (I : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr hI
exact I.fg_of_isUnit (IsFractionRing.injective A (FractionRing A)) hI.isUnit
theorem integrallyClosed : IsIntegrallyClosed A := by
let := h.commGroupWithZero (K := FractionRing A)
-- It suffices to show that for integral `x`,
-- `A[x]` (which is a fractional ideal) is in fact equal to `A`.
refine (isIntegrallyClosed_iff (FractionRing A)).mpr (fun {x hx} => ?_)
rw [← Set.mem_range, ← Algebra.mem_bot, ← Subalgebra.mem_toSubmodule, Algebra.toSubmodule_bot,
Submodule.one_eq_span, ← coe_spanSingleton A⁰ (1 : FractionRing A), spanSingleton_one, ←
FractionalIdeal.adjoinIntegral_eq_one_of_isUnit x hx (Ne.isUnit _)]
· exact mem_adjoinIntegral_self A⁰ x hx
· exact fun h => one_ne_zero (eq_zero_iff.mp h 1 (Algebra.adjoin A {x}).one_mem)
open Ring
theorem dimensionLEOne : DimensionLEOne A := by
-- We're going to show that `P` is maximal because any (maximal) ideal `M`
-- that is strictly larger would be `⊤`.
let := h.commGroupWithZero (K := FractionRing A)
constructor
rintro P P_ne hP
refine Ideal.isMaximal_def.mpr ⟨hP.ne_top, fun M hM => ?_⟩
-- We may assume `P` and `M` (as fractional ideals) are nonzero.
have P'_ne : (P : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr P_ne
have M'_ne : (M : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr hM.ne_bot
-- In particular, we'll show `M⁻¹ * P ≤ P`
suffices (M⁻¹ : FractionalIdeal A⁰ (FractionRing A)) * P ≤ P by
rw [eq_top_iff, ← coeIdeal_le_coeIdeal (FractionRing A), coeIdeal_top]
calc
(1 : FractionalIdeal A⁰ (FractionRing A)) = (↑M)⁻¹ * P * ((↑P)⁻¹ * M) := by
simp [mul_assoc, *]
_ ≤ P * ((↑P)⁻¹ * M) := by gcongr
_ = M := by simp [*]
-- Suppose we have `x ∈ M⁻¹ * P`, then in fact `x = algebraMap _ _ y` for some `y`.
intro x hx
have le_one : (M⁻¹ : FractionalIdeal A⁰ (FractionRing A)) * P ≤ 1 := by
rw [← inv_mul_cancel₀ M'_ne]; gcongr
obtain ⟨y, _hy, rfl⟩ := (mem_coeIdeal _).mp (le_one hx)
-- Since `M` is strictly greater than `P`, let `z ∈ M \ P`.
obtain ⟨z, hzM, hzp⟩ := SetLike.exists_of_lt hM
-- We have `z * y ∈ M * (M⁻¹ * P) = P`.
have zy_mem := mul_mem_mul (mem_coeIdeal_of_mem A⁰ hzM) hx
rw [← RingHom.map_mul, ← mul_assoc, mul_inv_cancel₀ M'_ne, one_mul] at zy_mem
obtain ⟨zy, hzy, zy_eq⟩ := (mem_coeIdeal A⁰).mp zy_mem
rw [IsFractionRing.injective A (FractionRing A) zy_eq] at hzy
-- But `P` is a prime ideal, so `z ∉ P` implies `y ∈ P`, as desired.
exact mem_coeIdeal_of_mem A⁰ (Or.resolve_left (hP.mem_or_mem hzy) hzp)
/-- Showing one side of the equivalence between the definitions
`IsDedekindDomainInv` and `IsDedekindDomain` of Dedekind domains. -/
theorem isDedekindDomain : IsDedekindDomain A :=
{ h.isNoetherianRing, h.dimensionLEOne, h.integrallyClosed with }
end IsDedekindDomainInv
end IsDedekindDomainInv
variable [Algebra A K] [IsFractionRing A K]
variable {A K}
theorem one_mem_inv_coe_ideal [IsDomain A] {I : Ideal A} (hI : I ≠ ⊥) :
(1 : K) ∈ (I : FractionalIdeal A⁰ K)⁻¹ := by
rw [FractionalIdeal.mem_inv_iff (FractionalIdeal.coeIdeal_ne_zero.mpr hI)]
intro y hy
rw [one_mul]
exact FractionalIdeal.coeIdeal_le_one hy
/-- Specialization of `exists_primeSpectrum_prod_le_and_ne_bot_of_domain` to Dedekind domains:
Let `I : Ideal A` be a nonzero ideal, where `A` is a Dedekind domain that is not a field.
Then `exists_primeSpectrum_prod_le_and_ne_bot_of_domain` states we can find a product of prime
ideals that is contained within `I`. This lemma extends that result by making the product minimal:
let `M` be a maximal ideal that contains `I`, then the product including `M` is contained within `I`
and the product excluding `M` is not contained within `I`. -/
theorem exists_multiset_prod_cons_le_and_prod_not_le [IsDedekindDomain A] (hNF : ¬IsField A)
{I M : Ideal A} (hI0 : I ≠ ⊥) (hIM : I ≤ M) [hM : M.IsMaximal] :
∃ Z : Multiset (PrimeSpectrum A),
(M ::ₘ Z.map PrimeSpectrum.asIdeal).prod ≤ I ∧
¬Multiset.prod (Z.map PrimeSpectrum.asIdeal) ≤ I := by
-- Let `Z` be a minimal set of prime ideals such that their product is contained in `J`.
obtain ⟨Z₀, hZ₀⟩ := PrimeSpectrum.exists_primeSpectrum_prod_le_and_ne_bot_of_domain hNF hI0
obtain ⟨Z, ⟨hZI, hprodZ⟩, h_eraseZ⟩ :=
wellFounded_lt.has_min
{Z | (Z.map PrimeSpectrum.asIdeal).prod ≤ I ∧ (Z.map PrimeSpectrum.asIdeal).prod ≠ ⊥}
⟨Z₀, hZ₀.1, hZ₀.2⟩
obtain ⟨_, hPZ', hPM⟩ := hM.isPrime.multiset_prod_le.mp (hZI.trans hIM)
-- Then in fact there is a `P ∈ Z` with `P ≤ M`.
obtain ⟨P, hPZ, rfl⟩ := Multiset.mem_map.mp hPZ'
classical
have := Multiset.map_erase PrimeSpectrum.asIdeal (fun _ _ => PrimeSpectrum.ext) P Z
obtain ⟨hP0, hZP0⟩ : P.asIdeal ≠ ⊥ ∧ ((Z.erase P).map PrimeSpectrum.asIdeal).prod ≠ ⊥ := by
rwa [Ne, ← Multiset.cons_erase hPZ', Multiset.prod_cons, Ideal.mul_eq_bot, not_or, ←
this] at hprodZ
-- By maximality of `P` and `M`, we have that `P ≤ M` implies `P = M`.
have hPM' := (P.isPrime.isMaximal hP0).eq_of_le hM.ne_top hPM
subst hPM'
-- By minimality of `Z`, erasing `P` from `Z` is exactly what we need.
refine ⟨Z.erase P, ?_, ?_⟩
· convert hZI
rw [this, Multiset.cons_erase hPZ']
· refine fun h => h_eraseZ (Z.erase P) ⟨h, ?_⟩ (Multiset.erase_lt.mpr hPZ)
exact hZP0
namespace FractionalIdeal
variable [IsDedekindDomain A] {I : Ideal A}
open Ideal
lemma not_inv_le_one_of_ne_bot (hI0 : I ≠ ⊥) (hI1 : I ≠ ⊤) :
¬(I⁻¹ : FractionalIdeal A⁰ K) ≤ 1 := by
have hNF : ¬IsField A := fun h ↦ letI := h.toField; (eq_bot_or_eq_top I).elim hI0 hI1
wlog hM : I.IsMaximal generalizing I
· rcases I.exists_le_maximal hI1 with ⟨M, hmax, hIM⟩
have hMbot : M ≠ ⊥ := (M.bot_lt_of_maximal hNF).ne'
refine mt (le_trans <| inv_anti_mono ?_ ?_ ?_) (this hMbot hmax.ne_top hmax) <;>
simpa only [coeIdeal_ne_zero, coeIdeal_le_coeIdeal]
have hI0 : ⊥ < I := I.bot_lt_of_maximal hNF
obtain ⟨⟨a, haI⟩, ha0⟩ := Submodule.nonzero_mem_of_bot_lt hI0
replace ha0 : a ≠ 0 := Subtype.coe_injective.ne ha0
let J : Ideal A := Ideal.span {a}
have hJ0 : J ≠ ⊥ := mt Ideal.span_singleton_eq_bot.mp ha0
have hJI : J ≤ I := I.span_singleton_le_iff_mem.2 haI
-- Then we can find a product of prime (hence maximal) ideals contained in `J`,
-- such that removing element `M` from the product is not contained in `J`.
obtain ⟨Z, hle, hnle⟩ := exists_multiset_prod_cons_le_and_prod_not_le hNF hJ0 hJI
-- Choose an element `b` of the product that is not in `J`.
obtain ⟨b, hbZ, hbJ⟩ := SetLike.not_le_iff_exists.mp hnle
have hnz_fa : algebraMap A K a ≠ 0 :=
mt ((injective_iff_map_eq_zero _).mp (IsFractionRing.injective A K) a) ha0
-- Then `b a⁻¹ : K` is in `M⁻¹` but not in `1`.
refine Set.not_subset.2 ⟨algebraMap A K b * (algebraMap A K a)⁻¹, (mem_inv_iff ?_).mpr ?_, ?_⟩
· exact coeIdeal_ne_zero.mpr hI0.ne'
· rintro y₀ hy₀
obtain ⟨y, h_Iy, rfl⟩ := (mem_coeIdeal _).mp hy₀
rw [mul_comm, ← mul_assoc, ← RingHom.map_mul]
have h_yb : y * b ∈ J := by
apply hle
rw [Multiset.prod_cons]
exact Submodule.smul_mem_smul h_Iy hbZ
rw [Ideal.mem_span_singleton'] at h_yb
rcases h_yb with ⟨c, hc⟩
rw [← hc, RingHom.map_mul, mul_assoc, mul_inv_cancel₀ hnz_fa, mul_one]
apply coe_mem_one
· refine mt (mem_one_iff _).mp ?_
rintro ⟨x', h₂_abs⟩
rw [← div_eq_mul_inv, eq_div_iff_mul_eq hnz_fa, ← RingHom.map_mul] at h₂_abs
have := Ideal.mem_span_singleton'.mpr ⟨x', IsFractionRing.injective A K h₂_abs⟩
contradiction
theorem mul_inv_cancel_of_le_one (hI0 : I ≠ ⊥) (hI : (I * (I : FractionalIdeal A⁰ K)⁻¹)⁻¹ ≤ 1) :
I * (I : FractionalIdeal A⁰ K)⁻¹ = 1 := by
-- We'll show a contradiction with `exists_notMem_one_of_ne_bot`:
-- `J⁻¹ = (I * I⁻¹)⁻¹` cannot have an element `x ∉ 1`, so it must equal `1`.
obtain ⟨J, hJ⟩ : ∃ J : Ideal A, (J : FractionalIdeal A⁰ K) = I * (I : FractionalIdeal A⁰ K)⁻¹ :=
le_one_iff_exists_coeIdeal.mp mul_one_div_le_one
by_cases hJ0 : J = ⊥
· subst hJ0
refine absurd ?_ hI0
rw [eq_bot_iff, ← coeIdeal_le_coeIdeal K, hJ]
exact coe_ideal_le_self_mul_inv K I
by_cases hJ1 : J = ⊤
· rw [← hJ, hJ1, coeIdeal_top]
exact (not_inv_le_one_of_ne_bot (K := K) hJ0 hJ1 (hJ ▸ hI)).elim
/-- Nonzero integral ideals in a Dedekind domain are invertible.
We will use this to show that nonzero fractional ideals are invertible,
and finally conclude that fractional ideals in a Dedekind domain form a group with zero.
-/
theorem coe_ideal_mul_inv (I : Ideal A) (hI0 : I ≠ ⊥) : I * (I : FractionalIdeal A⁰ K)⁻¹ = 1 := by
-- We'll show `1 ≤ J⁻¹ = (I * I⁻¹)⁻¹ ≤ 1`.
apply mul_inv_cancel_of_le_one hI0
by_cases hJ0 : I * (I : FractionalIdeal A⁰ K)⁻¹ = 0
· rw [hJ0, inv_zero']; exact zero_le _
intro x hx
-- In particular, we'll show all `x ∈ J⁻¹` are integral.
suffices x ∈ integralClosure A K by
rwa [IsIntegrallyClosed.integralClosure_eq_bot, Algebra.mem_bot, Set.mem_range,
← mem_one_iff] at this
-- For that, we'll find a subalgebra that is f.g. as a module and contains `x`.
-- `A` is a Noetherian ring, so we just need to find a subalgebra between `{x}` and `I⁻¹`.
rw [mem_integralClosure_iff_mem_fg]
have x_mul_mem : ∀ b ∈ (I⁻¹ : FractionalIdeal A⁰ K), x * b ∈ (I⁻¹ : FractionalIdeal A⁰ K) := by
intro b hb
rw [mem_inv_iff (coeIdeal_ne_zero.mpr hI0)]
dsimp only at hx
rw [val_eq_coe, mem_coe, mem_inv_iff hJ0] at hx
simp only [mul_assoc, mul_comm b] at hx ⊢
intro y hy
exact hx _ (mul_mem_mul hy hb)
-- It turns out the subalgebra consisting of all `p(x)` for `p : A[X]` works.
refine ⟨AlgHom.range (Polynomial.aeval x : A[X] →ₐ[A] K),
isNoetherian_submodule.mp (isNoetherian (I : FractionalIdeal A⁰ K)⁻¹) _ fun y hy => ?_,
⟨Polynomial.X, Polynomial.aeval_X x⟩⟩
obtain ⟨p, rfl⟩ := (AlgHom.mem_range _).mp hy
rw [Polynomial.aeval_eq_sum_range]
refine Submodule.sum_mem _ fun i hi => Submodule.smul_mem _ _ ?_
clear hi
induction i with
| zero => rw [pow_zero]; exact one_mem_inv_coe_ideal hI0
| succ i ih => rw [pow_succ']; exact x_mul_mem _ ih
noncomputable instance semifield : Semifield (FractionalIdeal A⁰ K) where
__ := coeIdeal_injective.nontrivial
__ : CommSemiring (FractionalIdeal A⁰ K) := inferInstance
__ := IsDedekindDomainInv.commGroupWithZero fun I hI ↦ by
obtain ⟨a, J, ha, hJ⟩ := exists_eq_spanSingleton_mul (K := FractionRing A) I
suffices h₂ : I * (spanSingleton A⁰ (algebraMap _ _ a) * (J : FractionalIdeal A⁰ _)⁻¹) = 1 by
rw [mul_inv_cancel_iff]
exact ⟨spanSingleton A⁰ (algebraMap _ _ a) * (J : FractionalIdeal A⁰ _)⁻¹, h₂⟩
subst hJ
rw [mul_assoc, mul_left_comm (J : FractionalIdeal A⁰ _), coe_ideal_mul_inv, mul_one,
spanSingleton_mul_spanSingleton, inv_mul_cancel₀, spanSingleton_one]
· exact mt ((injective_iff_map_eq_zero (algebraMap A _)).mp (IsFractionRing.injective A _) _) ha
· exact coeIdeal_ne_zero.mp (right_ne_zero_of_mul hI)
nnqsmul := _
#adaptation_note /-- 2025-03-29 for https://github.com/leanprover/lean4/issues/7717 had to add `mul_left_cancel_of_ne_zero` field.
TODO(kmill) There is trouble calculating the type of the `IsLeftCancelMulZero` parent. -/
/-- Fractional ideals have cancellative multiplication in a Dedekind domain.
Although this instance is a direct consequence of the instance
`FractionalIdeal.semifield`, we define this instance to provide
a computable alternative.
-/
instance cancelCommMonoidWithZero : CancelCommMonoidWithZero (FractionalIdeal A⁰ K) where
__ : CommSemiring (FractionalIdeal A⁰ K) := inferInstance
mul_left_cancel_of_ne_zero h _ _ := mul_left_cancel₀ h
instance : PosMulStrictMono (FractionalIdeal A⁰ K) := PosMulMono.toPosMulStrictMono
instance : MulPosStrictMono (FractionalIdeal A⁰ K) := MulPosMono.toMulPosStrictMono
instance : PosMulReflectLE (FractionalIdeal A⁰ K) where
elim I J K hJK := by simpa [I.2.ne'] using mul_right_mono (a := I.1⁻¹) hJK
instance : MulPosReflectLE (FractionalIdeal A⁰ K) where
elim I J K hJK := by simpa [I.2.ne'] using mul_left_mono (a := I.1⁻¹) hJK
@[deprecated mul_inv_cancel₀ (since := "2025-09-14")]
protected theorem mul_inv_cancel {I : FractionalIdeal A⁰ K} (hne : I ≠ 0) : I * I⁻¹ = 1 :=
mul_inv_cancel₀ hne
@[deprecated mul_le_mul_iff_left₀ (since := "2025-09-14")]
theorem mul_right_le_iff {J : FractionalIdeal A⁰ K} (hJ : J ≠ 0) {I I'} : I * J ≤ I' * J ↔ I ≤ I' :=
mul_le_mul_iff_left₀ <| pos_iff_ne_zero.2 hJ
@[deprecated mul_le_mul_iff_left₀ (since := "2025-09-14")]
theorem mul_left_le_iff {J : FractionalIdeal A⁰ K} (hJ : J ≠ 0) {I I'} : J * I ≤ J * I' ↔ I ≤ I' :=
mul_le_mul_iff_right₀ <| pos_iff_ne_zero.2 hJ
lemma mul_left_strictMono {I : FractionalIdeal A⁰ K} (hI : I ≠ 0) : StrictMono (· * I) :=
fun _J _K hJK ↦ mul_lt_mul_of_pos_right hJK <| pos_iff_ne_zero.2 hI
lemma mul_right_strictMono {I : FractionalIdeal A⁰ K} (hI : I ≠ 0) : StrictMono (I * ·) :=
fun _J _K hJK ↦ mul_lt_mul_of_pos_left hJK <| pos_iff_ne_zero.2 hI
instance [IsDedekindDomain A] : PosMulReflectLE (Ideal A) where
elim I J K e := by
dsimp
rwa [← FractionalIdeal.coeIdeal_le_coeIdeal (FractionRing A),
← mul_le_mul_iff_right₀ (α := FractionalIdeal A⁰ (FractionRing A)) (a := I.1)
(by simpa [pos_iff_ne_zero] using I.2.ne'),
← FractionalIdeal.coeIdeal_mul, ← FractionalIdeal.coeIdeal_mul,
FractionalIdeal.coeIdeal_le_coeIdeal]
@[deprecated div_eq_mul_inv (since := "2025-09-14")]
protected lemma div_eq_mul_inv (I J : FractionalIdeal A⁰ K) : I / J = I * J⁻¹ := div_eq_mul_inv ..
end FractionalIdeal
/-- `IsDedekindDomain` and `IsDedekindDomainInv` are equivalent ways
to express that an integral domain is a Dedekind domain. -/
theorem isDedekindDomain_iff_isDedekindDomainInv [IsDomain A] :
IsDedekindDomain A ↔ IsDedekindDomainInv A :=
⟨fun _h _I => mul_inv_cancel₀, fun h => h.isDedekindDomain⟩
end Inverse
section IsDedekindDomain
variable {R A}
variable [IsDedekindDomain A] [Algebra A K] [IsFractionRing A K]
open FractionalIdeal Ideal
noncomputable instance Ideal.cancelCommMonoidWithZero : CancelCommMonoidWithZero (Ideal A) :=
{ Function.Injective.cancelCommMonoidWithZero (coeIdealHom A⁰ (FractionRing A)) coeIdeal_injective
(RingHom.map_zero _) (RingHom.map_one _) (RingHom.map_mul _) (RingHom.map_pow _) with }
instance Ideal.isDomain : IsDomain (Ideal A) where
instance : PosMulStrictMono (Ideal A) := PosMulMono.toPosMulStrictMono
instance : MulPosStrictMono (Ideal A) := MulPosMono.toMulPosStrictMono
/-- For ideals in a Dedekind domain, to divide is to contain. -/
theorem Ideal.dvd_iff_le {I J : Ideal A} : I ∣ J ↔ J ≤ I :=
⟨Ideal.le_of_dvd, fun h => by
by_cases hI : I = ⊥
· have hJ : J = ⊥ := by rwa [hI, ← eq_bot_iff] at h
rw [hI, hJ]
have hI' : (I : FractionalIdeal A⁰ (FractionRing A)) ≠ 0 := coeIdeal_ne_zero.mpr hI
have : (I : FractionalIdeal A⁰ (FractionRing A))⁻¹ * J ≤ 1 := by
rw [← inv_mul_cancel₀ hI']; gcongr
obtain ⟨H, hH⟩ := le_one_iff_exists_coeIdeal.mp this
use H
refine coeIdeal_injective (show (J : FractionalIdeal A⁰ (FractionRing A)) = ↑(I * H) from ?_)
rw [coeIdeal_mul, hH, ← mul_assoc, mul_inv_cancel₀ hI', one_mul]⟩
theorem Ideal.liesOver_iff_dvd_map [Algebra R A] {p : Ideal R} {P : Ideal A} (hP : P ≠ ⊤)
[p.IsMaximal] :
P.LiesOver p ↔ P ∣ Ideal.map (algebraMap R A) p := by
rw [liesOver_iff, dvd_iff_le, under_def, map_le_iff_le_comap,
IsCoatom.le_iff_eq (by rwa [← isMaximal_def]) (comap_ne_top _ hP), eq_comm]
theorem Ideal.dvdNotUnit_iff_lt {I J : Ideal A} : DvdNotUnit I J ↔ J < I :=
⟨fun ⟨hI, H, hunit, hmul⟩ =>
lt_of_le_of_ne (Ideal.dvd_iff_le.mp ⟨H, hmul⟩)
(mt
(fun h =>
have : H = 1 := mul_left_cancel₀ hI (by rw [← hmul, h, mul_one])
show IsUnit H from this.symm ▸ isUnit_one)
hunit),
fun h =>
dvdNotUnit_of_dvd_of_not_dvd (Ideal.dvd_iff_le.mpr (le_of_lt h))
(mt Ideal.dvd_iff_le.mp (not_le_of_gt h))⟩
instance : WfDvdMonoid (Ideal A) where
wf := by
have : WellFoundedGT (Ideal A) := inferInstance
convert this.wf
ext
rw [Ideal.dvdNotUnit_iff_lt]
instance Ideal.uniqueFactorizationMonoid : UniqueFactorizationMonoid (Ideal A) :=
{ irreducible_iff_prime := by
intro P
exact ⟨fun hirr => ⟨hirr.ne_zero, hirr.not_isUnit, fun I J => by
have : P.IsMaximal := by
refine ⟨⟨mt Ideal.isUnit_iff.mpr hirr.not_isUnit, ?_⟩⟩
intro J hJ
obtain ⟨_J_ne, H, hunit, P_eq⟩ := Ideal.dvdNotUnit_iff_lt.mpr hJ
exact Ideal.isUnit_iff.mp ((hirr.isUnit_or_isUnit P_eq).resolve_right hunit)
rw [Ideal.dvd_iff_le, Ideal.dvd_iff_le, Ideal.dvd_iff_le, SetLike.le_def, SetLike.le_def,
SetLike.le_def]
contrapose!
rintro ⟨⟨x, x_mem, x_notMem⟩, ⟨y, y_mem, y_notMem⟩⟩
exact
⟨x * y, Ideal.mul_mem_mul x_mem y_mem,
mt this.isPrime.mem_or_mem (not_or_intro x_notMem y_notMem)⟩⟩, Prime.irreducible⟩ }
noncomputable instance Ideal.normalizationMonoid : NormalizationMonoid (Ideal A) := .ofUniqueUnits
end IsDedekindDomain |
.lake/packages/mathlib/Mathlib/RingTheory/PolynomialLaw/Basic.lean | import Mathlib.LinearAlgebra.DFinsupp
import Mathlib.LinearAlgebra.TensorProduct.Associator
/-! # Polynomial laws on modules
Let `M` and `N` be a modules over a commutative ring `R`.
A polynomial law `f : PolynomialLaw R M N`, with notation `f : M →ₚₗₗ[R] N`,
is a “law” that assigns a natural map `PolynomialLaw.toFun' f S : S ⊗[R] M → S ⊗[R] N`
for every `R`-algebra `S`.
For type-theoretic reasons, if `R : Type u`, then the definition of the polynomial map `f`
is restricted to `R`-algebras `S` such that `S : Type u`.
Using the fact that a module is the direct limit of its finitely generated submodules, that a
finitely generated subalgebra is a quotient of a polynomial ring in the universe `u`, plus
the commutation of tensor products with direct limits, we will extend the functor
to all `R`-algebras (TODO).
## Main definitions/lemmas
* Instance : `Module R (M →ₚₗ[R] N)` shows that polynomial laws form a `R`-module.
* `PolynomialLaw.ground f` is the map `M → N` corresponding to `PolynomialLaw.toFun' f R` under
the isomorphisms `R ⊗[R] M ≃ₗ[R] M`, and similarly for `N`.
In further works, we construct the coefficients of a polynomial law and show the relation with
polynomials (when the module `M` is free and finite).
## Implementation notes
In the literature, the theory is written for commutative rings, but this implementation
only assumes `R` is a commutative semiring.
## References
* [Roby, Norbert. 1963. « Lois polynomes et lois formelles en théorie des modules ».
Annales scientifiques de l’École Normale Supérieure 80 (3): 213‑348](Roby-1963)
-/
universe u
noncomputable section PolynomialLaw
open scoped TensorProduct
open LinearMap TensorProduct AlgHom
/-- A polynomial law `M →ₚₗ[R] N` between `R`-modules is a functorial family of maps
`S ⊗[R] M → S ⊗[R] N`, for all `R`-algebras `S`.
For universe reasons, `S` has to be restricted to the same universe as `R`. -/
@[ext]
structure PolynomialLaw (R : Type u) [CommSemiring R]
(M : Type*) [AddCommMonoid M] [Module R M] (N : Type*) [AddCommMonoid N] [Module R N] where
/-- The functions `S ⊗[R] M → S ⊗[R] N` underlying a polynomial law -/
toFun' (S : Type u) [CommSemiring S] [Algebra R S] : S ⊗[R] M → S ⊗[R] N
/-- The compatibility relations between the functions underlying a polynomial law -/
isCompat' {S : Type u} [CommSemiring S] [Algebra R S]
{S' : Type u} [CommSemiring S'] [Algebra R S'] (φ : S →ₐ[R] S') :
φ.toLinearMap.rTensor N ∘ toFun' S = toFun' S' ∘ φ.toLinearMap.rTensor M := by aesop
/-- `M →ₚₗ[R] N` is the type of `R`-polynomial laws from `M` to `N`. -/
notation:25 M " →ₚₗ[" R:25 "] " N:0 => PolynomialLaw R M N
@[local simp]
theorem PolynomialLaw.isCompat_apply'
{R : Type u} [CommSemiring R] {M : Type*} [AddCommMonoid M] [Module R M]
{N : Type*} [AddCommMonoid N] [Module R N] {f : M →ₚₗ[R] N}
{S : Type u} [CommSemiring S] [Algebra R S] {S' : Type u} [CommSemiring S'] [Algebra R S']
(φ : S →ₐ[R] S') (x : S ⊗[R] M) :
(φ.toLinearMap.rTensor N) ((f.toFun' S) x) = (f.toFun' S') (φ.toLinearMap.rTensor M x) := by
simpa only using congr_fun (f.isCompat' φ) x
attribute [local simp] PolynomialLaw.isCompat_apply'
namespace PolynomialLaw
section Module
section CommSemiring
variable {R : Type u} [CommSemiring R] {M : Type*} [AddCommMonoid M] [Module R M]
{N : Type*} [AddCommMonoid N] [Module R N] (r a b : R) (f g : M →ₚₗ[R] N)
instance : Zero (M →ₚₗ[R] N) := ⟨{ toFun' _ := 0 }⟩
@[simp]
theorem zero_def (S : Type u) [CommSemiring S] [Algebra R S] :
(0 : PolynomialLaw R M N).toFun' S = 0 := rfl
instance : Inhabited (PolynomialLaw R M N) := ⟨Zero.zero⟩
/-- The identity as a polynomial law -/
def id : M →ₚₗ[R] M where
toFun' S _ _ := _root_.id
theorem id_apply' {S : Type u} [CommSemiring S] [Algebra R S] :
(id : M →ₚₗ[R] M).toFun' S = _root_.id := rfl
/-- The sum of two polynomial laws -/
noncomputable def add : M →ₚₗ[R] N where
toFun' S _ _ := f.toFun' S + g.toFun' S
instance : Add (PolynomialLaw R M N) := ⟨add⟩
@[simp]
theorem add_def (S : Type u) [CommSemiring S] [Algebra R S] :
(f + g).toFun' S = f.toFun' S + g.toFun' S := rfl
theorem add_def_apply (S : Type u) [CommSemiring S] [Algebra R S] (m : S ⊗[R] M) :
(f + g).toFun' S m = f.toFun' S m + g.toFun' S m := rfl
/-- External multiplication of a `f : M →ₚₗ[R] N` by `r : R` -/
def smul : M →ₚₗ[R] N where
toFun' S _ _ := r • f.toFun' S
instance : SMul R (M →ₚₗ[R] N) := ⟨smul⟩
@[simp]
theorem smul_def (S : Type u) [CommSemiring S] [Algebra R S] :
(r • f).toFun' S = r • f.toFun' S := rfl
theorem smul_def_apply (S : Type u) [CommSemiring S] [Algebra R S] (m : S ⊗[R] M) :
(r • f).toFun' S m = r • f.toFun' S m := rfl
theorem add_smul : (a + b) • f = a • f + b • f := by
ext; simp only [add_def, smul_def, _root_.add_smul]
theorem zero_smul : (0 : R) • f = 0 := by
ext S; simp only [smul_def, _root_.zero_smul, zero_def, Pi.zero_apply]
theorem one_smul : (1 : R) • f = f := by
ext S; simp only [smul_def, Pi.smul_apply, _root_.one_smul]
instance : MulAction R (M →ₚₗ[R] N) where
one_smul := one_smul
mul_smul a b f := by ext; simp only [smul_def, mul_smul]
instance : AddCommMonoid (M →ₚₗ[R] N) where
add_assoc f g h := by ext; simp only [add_def, add_assoc]
zero_add f := by ext; simp only [add_def, zero_add, zero_def]
add_zero f := by ext; simp only [add_def, add_zero, zero_def]
nsmul n f := (n : R) • f
nsmul_zero f := by simp only [Nat.cast_zero, zero_smul f]
nsmul_succ n f := by simp only [Nat.cast_add, Nat.cast_one, add_smul, one_smul]
add_comm f g := by ext; simp only [add_def, add_comm]
instance : Module R (M →ₚₗ[R] N) where
smul_zero a := rfl
smul_add a f g := by ext; simp only [smul_def, add_def, smul_add]
add_smul := add_smul
zero_smul := zero_smul
end CommSemiring
section CommRing
variable {R : Type u} [CommRing R]
{M : Type*} [AddCommGroup M] [Module R M] {N : Type*} [AddCommGroup N] [Module R N]
(f : M →ₚₗ[R] N)
/-- The opposite of a polynomial law -/
noncomputable def neg : M →ₚₗ[R] N where
toFun' S _ _ := (-1 : R) • f.toFun' S
instance : Neg (M →ₚₗ[R] N) := ⟨neg⟩
@[simp]
theorem neg_def (S : Type u) [CommSemiring S] [Algebra R S] :
(-f).toFun' S = (-1 : R) • f.toFun' S := rfl
instance : AddCommGroup (M →ₚₗ[R] N) where
zsmul n f := (n : R) • f
zsmul_zero' f := by simp only [Int.cast_zero, zero_smul]
zsmul_succ' n f := by simp only [Nat.cast_succ, Int.cast_add, Int.cast_natCast,
Int.cast_one, add_smul, _root_.one_smul]
zsmul_neg' n f := by
ext S _ _ m
rw [neg_def]
simp only [Int.cast_negSucc, Nat.cast_add, Nat.cast_one, neg_add_rev, _root_.add_smul,
add_def_apply, smul_def_apply, Nat.succ_eq_add_one, Int.cast_add, Int.cast_natCast,
Int.cast_one, _root_.one_smul, add_def, smul_def, Pi.smul_apply, Pi.add_apply, smul_add,
smul_smul, neg_mul, one_mul]
rw [add_comm]
neg_add_cancel f := by
ext S _ _ m
simp only [add_def_apply, neg_def, Pi.smul_apply, zero_def, Pi.zero_apply]
nth_rewrite 2 [← _root_.one_smul (M := R) (b := f.toFun' S m)]
rw [← _root_.add_smul]
simp only [neg_add_cancel, _root_.zero_smul]
add_comm f g := by ext; simp only [add_def, add_comm]
end CommRing
end Module
section ground
variable {R : Type u} [CommSemiring R] {M : Type*} [AddCommMonoid M] [Module R M]
{N : Type*} [AddCommMonoid N] [Module R N]
variable (f : M →ₚₗ[R] N)
/-- The map `M → N` associated with a `f : M →ₚₗ[R] N` (essentially, `f.toFun' R`) -/
def ground : M → N := (TensorProduct.lid R N) ∘ (f.toFun' R) ∘ (TensorProduct.lid R M).symm
theorem ground_apply (m : M) : f.ground m = TensorProduct.lid R N (f.toFun' R (1 ⊗ₜ[R] m)) := rfl
instance : CoeFun (M →ₚₗ[R] N) (fun _ ↦ M → N) where
coe := ground
theorem one_tmul_ground_apply' {S : Type u} [CommSemiring S] [Algebra R S] (x : M) :
1 ⊗ₜ (f.ground x) = (f.toFun' S) (1 ⊗ₜ x) := by
rw [ground_apply]
convert f.isCompat_apply' (Algebra.algHom R R S) (1 ⊗ₜ[R] x)
· simp only [includeRight_lid]
· rw [rTensor_tmul, toLinearMap_apply, map_one]
/-- The map ground assigning a function `M → N` to a polynomial map `f : M →ₚₗ[R] N` as a
linear map. -/
def lground : (M →ₚₗ[R] N) →ₗ[R] (M → N) where
toFun := ground
map_add' x y := by ext m; simp [ground]
map_smul' r x := by ext m; simp [ground]
theorem ground_id : (id : M →ₚₗ[R] M).ground = _root_.id := by
ext; simp [ground_apply, id_apply']
theorem ground_id_apply (m : M) : (id : M →ₚₗ[R] M).ground m = m := by
rw [ground_id, id_eq]
end ground
section Composition
variable {R : Type u} [CommSemiring R]
variable {M : Type*} [AddCommMonoid M] [Module R M]
variable {N : Type*} [AddCommMonoid N] [Module R N]
variable {P : Type*} [AddCommMonoid P] [Module R P]
variable {Q : Type*} [AddCommMonoid Q] [Module R Q]
variable (f : M →ₚₗ[R] N) (g : N →ₚₗ[R] P) (h : P →ₚₗ[R] Q)
/-- Composition of polynomial maps. -/
def comp (g : N →ₚₗ[R] P) (f : M →ₚₗ[R] N) : M →ₚₗ[R] P where
toFun' S _ _ := (g.toFun' S).comp (f.toFun' S)
isCompat' φ := by ext; simp only [Function.comp_apply, isCompat_apply']
theorem comp_toFun' (S : Type u) [CommSemiring S] [Algebra R S] :
(g.comp f).toFun' S = (g.toFun' S).comp (f.toFun' S) := rfl
theorem comp_assoc : h.comp (g.comp f) = (h.comp g).comp f := rfl
theorem comp_id : g.comp id = g := by ext; rfl
theorem id_comp : id.comp f = f := by ext; rfl
end Composition
end PolynomialLaw |
.lake/packages/mathlib/Mathlib/RingTheory/Jacobson/Ring.lean | import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Ideal.GoingUp
import Mathlib.RingTheory.Jacobson.Polynomial
import Mathlib.RingTheory.Artinian.Module
/-!
# Jacobson Rings
The following conditions are equivalent for a ring `R`:
1. Every radical ideal `I` is equal to its Jacobson radical
2. Every radical ideal `I` can be written as an intersection of maximal ideals
3. Every prime ideal `I` is equal to its Jacobson radical
Any ring satisfying any of these equivalent conditions is said to be Jacobson.
Some particular examples of Jacobson rings are also proven.
`isJacobsonRing_quotient` says that the quotient of a Jacobson ring is Jacobson.
`isJacobsonRing_localization` says the localization of a Jacobson ring
to a single element is Jacobson.
`isJacobsonRing_polynomial_iff_isJacobsonRing` says polynomials over a Jacobson ring
form a Jacobson ring.
## Main definitions
Let `R` be a commutative ring. Jacobson rings are defined using the first of the above conditions
* `IsJacobsonRing R` is the proposition that `R` is a Jacobson ring. It is a class,
implemented as the predicate that for any ideal, `I.isRadical` implies `I.jacobson = I`.
## Main statements
* `isJacobsonRing_iff_prime_eq` is the equivalence between conditions 1 and 3 above.
* `isJacobsonRing_iff_sInf_maximal` is the equivalence between conditions 1 and 2 above.
* `isJacobsonRing_of_surjective` says that if `R` is a Jacobson ring and
`f : R →+* S` is surjective, then `S` is also a Jacobson ring
* `MvPolynomial.isJacobsonRing` says that multi-variate polynomials
over a Jacobson ring are Jacobson.
## Tags
Jacobson, Jacobson Ring
-/
universe u
open Polynomial
open Ideal
section IsJacobsonRing
variable {R S : Type*} [CommRing R] [CommRing S] {I : Ideal R}
/-- A ring is a Jacobson ring if for every radical ideal `I`,
the Jacobson radical of `I` is equal to `I`.
See `isJacobsonRing_iff_prime_eq` and `isJacobsonRing_iff_sInf_maximal`
for equivalent definitions. -/
class IsJacobsonRing (R : Type*) [CommRing R] : Prop where
out' : ∀ I : Ideal R, I.IsRadical → I.jacobson = I
theorem isJacobsonRing_iff {R} [CommRing R] :
IsJacobsonRing R ↔ ∀ I : Ideal R, I.IsRadical → I.jacobson = I :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
theorem IsJacobsonRing.out {R} [CommRing R] :
IsJacobsonRing R → ∀ {I : Ideal R}, I.IsRadical → I.jacobson = I :=
isJacobsonRing_iff.1
/-- A ring is a Jacobson ring if and only if for all prime ideals `P`,
the Jacobson radical of `P` is equal to `P`. -/
theorem isJacobsonRing_iff_prime_eq :
IsJacobsonRing R ↔ ∀ P : Ideal R, IsPrime P → P.jacobson = P := by
refine isJacobsonRing_iff.trans ⟨fun h I hI => h I hI.isRadical, ?_⟩
refine fun h I hI ↦ le_antisymm (fun x hx ↦ ?_) (fun x hx ↦ mem_sInf.mpr fun _ hJ ↦ hJ.left hx)
rw [← hI.radical, radical_eq_sInf I, mem_sInf]
intro P hP
rw [Set.mem_setOf_eq] at hP
rw [jacobson, mem_sInf] at hx
rw [← h P hP.right, jacobson, mem_sInf]
exact fun J hJ => hx ⟨le_trans hP.left hJ.left, hJ.right⟩
/-- A ring `R` is Jacobson if and only if for every prime ideal `I`,
`I` can be written as the infimum of some collection of maximal ideals.
Allowing ⊤ in the set `M` of maximal ideals is equivalent, but makes some proofs cleaner. -/
theorem isJacobsonRing_iff_sInf_maximal : IsJacobsonRing R ↔ ∀ {I : Ideal R}, I.IsPrime →
∃ M : Set (Ideal R), (∀ J ∈ M, IsMaximal J ∨ J = ⊤) ∧ I = sInf M :=
⟨fun H _I h => eq_jacobson_iff_sInf_maximal.1 (H.out h.isRadical), fun H =>
isJacobsonRing_iff_prime_eq.2 fun _P hP => eq_jacobson_iff_sInf_maximal.2 (H hP)⟩
/-- A variant of `isJacobsonRing_iff_sInf_maximal` with a different spelling of "maximal or `⊤`". -/
theorem isJacobsonRing_iff_sInf_maximal' : IsJacobsonRing R ↔ ∀ {I : Ideal R}, I.IsPrime →
∃ M : Set (Ideal R), (∀ J ∈ M, ∀ (K : Ideal R), J < K → K = ⊤) ∧ I = sInf M :=
⟨fun H _I h => eq_jacobson_iff_sInf_maximal'.1 (H.out h.isRadical), fun H =>
isJacobsonRing_iff_prime_eq.2 fun _P hP => eq_jacobson_iff_sInf_maximal'.2 (H hP)⟩
theorem Ideal.radical_eq_jacobson [H : IsJacobsonRing R] (I : Ideal R) : I.radical = I.jacobson :=
le_antisymm (le_sInf fun _J ⟨hJ, hJ_max⟩ => (IsPrime.radical_le_iff hJ_max.isPrime).mpr hJ)
(H.out (radical_isRadical I) ▸ jacobson_mono le_radical)
instance (priority := 100) [IsArtinianRing R] : IsJacobsonRing R :=
isJacobsonRing_iff_prime_eq.mpr fun _ _ ↦ jacobson_eq_self_of_isMaximal
theorem isJacobsonRing_of_surjective [H : IsJacobsonRing R] :
(∃ f : R →+* S, Function.Surjective ↑f) → IsJacobsonRing S := by
rintro ⟨f, hf⟩
rw [isJacobsonRing_iff_sInf_maximal]
intro p hp
use map f '' { J : Ideal R | comap f p ≤ J ∧ J.IsMaximal }
use fun j ⟨J, hJ, hmap⟩ => hmap ▸ (map_eq_top_or_isMaximal_of_surjective f hf hJ.right).symm
have : p = map f (comap f p).jacobson :=
(IsJacobsonRing.out' _ <| hp.isRadical.comap f).symm ▸ (map_comap_of_surjective f hf p).symm
exact this.trans (map_sInf hf fun J ⟨hJ, _⟩ => le_trans (Ideal.ker_le_comap f) hJ)
instance (priority := 100) isJacobsonRing_quotient [IsJacobsonRing R] : IsJacobsonRing (R ⧸ I) :=
isJacobsonRing_of_surjective ⟨Ideal.Quotient.mk I, by
rintro ⟨x⟩
use x
rfl⟩
theorem isJacobsonRing_iso (e : R ≃+* S) : IsJacobsonRing R ↔ IsJacobsonRing S where
mp _ := isJacobsonRing_of_surjective ⟨(e : R →+* S), e.surjective⟩
mpr _ := isJacobsonRing_of_surjective ⟨(e.symm : S →+* R), e.symm.surjective⟩
theorem isJacobsonRing_of_isIntegral [Algebra R S] [Algebra.IsIntegral R S] [IsJacobsonRing R] :
IsJacobsonRing S := by
rw [isJacobsonRing_iff_prime_eq]
intro P hP
by_cases hP_top : comap (algebraMap R S) P = ⊤
· simp [comap_eq_top_iff.1 hP_top]
· have : Nontrivial (R ⧸ comap (algebraMap R S) P) := Quotient.nontrivial hP_top
rw [jacobson_eq_iff_jacobson_quotient_eq_bot]
refine eq_bot_of_comap_eq_bot (R := R ⧸ comap (algebraMap R S) P) ?_
rw [eq_bot_iff, ← jacobson_eq_iff_jacobson_quotient_eq_bot.1
((isJacobsonRing_iff_prime_eq.1 ‹_›) (comap (algebraMap R S) P) (comap_isPrime _ _)),
comap_jacobson]
refine sInf_le_sInf fun J hJ => ?_
simp only [true_and, Set.mem_image, bot_le, Set.mem_setOf_eq]
have : J.IsMaximal := by simpa using hJ
exact exists_ideal_over_maximal_of_isIntegral J
(comap_bot_le_of_injective _ algebraMap_quotient_injective)
/-- A variant of `isJacobsonRing_of_isIntegral` that takes `RingHom.IsIntegral` instead. -/
theorem isJacobsonRing_of_isIntegral' (f : R →+* S) (hf : f.IsIntegral) [IsJacobsonRing R] :
IsJacobsonRing S :=
let _ : Algebra R S := f.toAlgebra
have : Algebra.IsIntegral R S := ⟨hf⟩
isJacobsonRing_of_isIntegral (R := R)
end IsJacobsonRing
section Localization
open IsLocalization Submonoid
variable {R S : Type*} [CommRing R] [CommRing S]
variable (y : R) [Algebra R S] [IsLocalization.Away y S]
variable (S) in
/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`
correspond to maximal ideals in the original ring `R` that don't contain `y`.
This lemma gives the correspondence in the particular case of an ideal and its comap.
See `le_relIso_of_maximal` for the more general relation isomorphism -/
theorem IsLocalization.isMaximal_iff_isMaximal_disjoint [H : IsJacobsonRing R] (J : Ideal S) :
J.IsMaximal ↔ (comap (algebraMap R S) J).IsMaximal ∧ y ∉ Ideal.comap (algebraMap R S) J := by
constructor
· refine fun h => ⟨?_, fun hy =>
h.ne_top (Ideal.eq_top_of_isUnit_mem _ hy (map_units _ ⟨y, Submonoid.mem_powers _⟩))⟩
have hJ : J.IsPrime := IsMaximal.isPrime h
rw [isPrime_iff_isPrime_disjoint (Submonoid.powers y)] at hJ
have : y ∉ (comap (algebraMap R S) J).1 := Set.disjoint_left.1 hJ.right (Submonoid.mem_powers _)
rw [← H.out hJ.left.isRadical, jacobson, Submodule.mem_toAddSubmonoid, Ideal.mem_sInf] at this
push_neg at this
rcases this with ⟨I, hI, hI'⟩
convert hI.right
by_cases hJ : J = I.map (algebraMap R S)
· rw [hJ, comap_map_of_isPrime_disjoint (powers y) S I (IsMaximal.isPrime hI.right)]
rwa [disjoint_powers_iff_notMem y hI.right.isPrime.isRadical]
· have hI_p : (I.map (algebraMap R S)).IsPrime := by
refine isPrime_of_isPrime_disjoint (powers y) _ I hI.right.isPrime ?_
rwa [disjoint_powers_iff_notMem y hI.right.isPrime.isRadical]
have : J ≤ I.map (algebraMap R S) := map_comap (Submonoid.powers y) S J ▸ map_mono hI.left
exact absurd (h.1.2 _ (lt_of_le_of_ne this hJ)) hI_p.1
· refine fun h => ⟨⟨fun hJ => h.1.ne_top (eq_top_iff.2 ?_), fun I hI => ?_⟩⟩
· rwa [eq_top_iff, ← (IsLocalization.orderEmbedding (powers y) S).le_iff_le] at hJ
· have := congr_arg (Ideal.map (algebraMap R S)) (h.1.1.2 _ ⟨comap_mono (le_of_lt hI), ?_⟩)
· rwa [map_comap (powers y) S I, Ideal.map_top] at this
refine fun hI' => hI.right ?_
rw [← map_comap (powers y) S I, ← map_comap (powers y) S J]
exact map_mono hI'
/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`
correspond to maximal ideals in the original ring `R` that don't contain `y`.
This lemma gives the correspondence in the particular case of an ideal and its map.
See `le_relIso_of_maximal` for the more general statement, and the reverse of this implication -/
theorem IsLocalization.isMaximal_of_isMaximal_disjoint
[IsJacobsonRing R] (I : Ideal R) (hI : I.IsMaximal)
(hy : y ∉ I) : (I.map (algebraMap R S)).IsMaximal := by
rw [isMaximal_iff_isMaximal_disjoint S y,
comap_map_of_isPrime_disjoint (powers y) S I (IsMaximal.isPrime hI)
((disjoint_powers_iff_notMem y hI.isPrime.isRadical).2 hy)]
exact ⟨hI, hy⟩
/-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y`
correspond to maximal ideals in the original ring `R` that don't contain `y` -/
def IsLocalization.orderIsoOfMaximal [IsJacobsonRing R] :
{ p : Ideal S // p.IsMaximal } ≃o { p : Ideal R // p.IsMaximal ∧ y ∉ p } where
toFun p := ⟨Ideal.comap (algebraMap R S) p.1, (isMaximal_iff_isMaximal_disjoint S y p.1).1 p.2⟩
invFun p := ⟨Ideal.map (algebraMap R S) p.1, isMaximal_of_isMaximal_disjoint y p.1 p.2.1 p.2.2⟩
left_inv J := Subtype.eq (map_comap (powers y) S J)
right_inv I := Subtype.eq (comap_map_of_isPrime_disjoint _ _ I.1 (IsMaximal.isPrime I.2.1)
((disjoint_powers_iff_notMem y I.2.1.isPrime.isRadical).2 I.2.2))
map_rel_iff' {I I'} := ⟨fun h => show I.val ≤ I'.val from
map_comap (powers y) S I.val ▸ map_comap (powers y) S I'.val ▸ Ideal.map_mono h,
fun h _ hx => h hx⟩
include y in
/-- If `S` is the localization of the Jacobson ring `R` at the submonoid generated by `y : R`, then
`S` is Jacobson. -/
theorem isJacobsonRing_localization [H : IsJacobsonRing R] : IsJacobsonRing S := by
rw [isJacobsonRing_iff_prime_eq]
refine fun P' hP' => le_antisymm ?_ le_jacobson
obtain ⟨hP', hPM⟩ := (IsLocalization.isPrime_iff_isPrime_disjoint (powers y) S P').mp hP'
have hP := H.out hP'.isRadical
refine (IsLocalization.map_comap (powers y) S P'.jacobson).ge.trans
((map_mono ?_).trans (IsLocalization.map_comap (powers y) S P').le)
have : sInf { I : Ideal R | comap (algebraMap R S) P' ≤ I ∧ I.IsMaximal ∧ y ∉ I } ≤
comap (algebraMap R S) P' := by
intro x hx
have hxy : x * y ∈ (comap (algebraMap R S) P').jacobson := by
rw [Ideal.jacobson, Ideal.mem_sInf]
intro J hJ
by_cases h : y ∈ J
· exact J.mul_mem_left x h
· exact J.mul_mem_right y ((mem_sInf.1 hx) ⟨hJ.left, ⟨hJ.right, h⟩⟩)
rw [hP] at hxy
rcases hP'.mem_or_mem hxy with hxy | hxy
· exact hxy
· exact (hPM.le_bot ⟨Submonoid.mem_powers _, hxy⟩).elim
refine le_trans ?_ this
rw [Ideal.jacobson, comap_sInf', sInf_eq_iInf]
refine iInf_le_iInf_of_subset fun I hI => ⟨map (algebraMap R S) I, ⟨?_, ?_⟩⟩
· exact ⟨le_trans (le_of_eq (IsLocalization.map_comap (powers y) S P').symm) (map_mono hI.1),
isMaximal_of_isMaximal_disjoint y _ hI.2.1 hI.2.2⟩
· exact IsLocalization.comap_map_of_isPrime_disjoint _ S I (IsMaximal.isPrime hI.2.1)
((disjoint_powers_iff_notMem y hI.2.1.isPrime.isRadical).2 hI.2.2)
end Localization
namespace Polynomial
section CommRing
-- Porting note: move to better place
lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) :
p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by
refine Polynomial.induction_on p ?_ ?_ ?_
· intro r
apply Subring.subset_closure
apply Set.mem_insert_of_mem
exact degree_C_le
· intro p1 p2 h1 h2
exact Subring.add_mem _ h1 h2
· intro n r hr
rw [pow_succ, ← mul_assoc]
apply Subring.mul_mem _ hr
apply Subring.subset_closure
apply Set.mem_insert
variable {R S : Type*} [CommRing R] [CommRing S] [IsDomain S]
variable {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ]
/-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial,
then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`.
In particular `X` is integral because it satisfies `pX`, and constants are trivially integral,
so integrality of the entire extension follows by closure under addition and multiplication. -/
theorem isIntegral_isLocalization_polynomial_quotient
(P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ]
[IsLocalization.Away (pX.map (Ideal.Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ]
[Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Ideal.Quotient.mk (P.comap
(C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] :
(IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Ideal.Quotient.mk
(P.comap (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by
let P' : Ideal R := P.comap C
let M : Submonoid (R ⧸ P') :=
Submonoid.powers (pX.map (Ideal.Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff
let M' : Submonoid (R[X] ⧸ P) :=
(Submonoid.powers (pX.map (Ideal.Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map
(quotientMap P C le_rfl)
let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl
let φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ M.le_comap_map
have hφ' : φ.comp (Ideal.Quotient.mk P') = (Ideal.Quotient.mk P).comp C := rfl
intro p
obtain ⟨⟨p', ⟨q, hq⟩⟩, hp⟩ := IsLocalization.surj M' p
suffices φ'.IsIntegralElem (algebraMap (R[X] ⧸ P) Sₘ p') by
obtain ⟨q', hq', rfl⟩ := hq
obtain ⟨q'', hq''⟩ := isUnit_iff_exists_inv'.1 (IsLocalization.map_units Rₘ (⟨q', hq'⟩ : M))
refine (hp.symm ▸ this).of_mul_unit φ' p (algebraMap (R[X] ⧸ P) Sₘ (φ q')) q'' ?_
rw [← φ'.map_one, ← congr_arg φ' hq'', φ'.map_mul, ← φ'.comp_apply]
simp only [φ', IsLocalization.map_comp _, RingHom.comp_apply]
dsimp at hp
refine @IsIntegral.of_mem_closure'' Rₘ _ Sₘ _ φ'
((algebraMap (R[X] ⧸ P) Sₘ).comp (Ideal.Quotient.mk P) '' insert X { p | p.degree ≤ 0 }) ?_
((algebraMap (R[X] ⧸ P) Sₘ) p') ?_
· rintro x ⟨p, hp, rfl⟩
simp only [Set.mem_insert_iff] at hp
rcases hp with hy | hy
· rw [hy]
refine φ.isIntegralElem_localization_at_leadingCoeff ((Ideal.Quotient.mk P) X)
(pX.map (Ideal.Quotient.mk P')) ?_ M ?_
· rwa [eval₂_map, hφ', ← hom_eval₂, Quotient.eq_zero_iff_mem, eval₂_C_X]
· use 1
simp only [P', pow_one]
· rw [Set.mem_setOf_eq, degree_le_zero_iff] at hy
rw [hy]
refine ⟨X - C (algebraMap _ _ ((Ideal.Quotient.mk P') (p.coeff 0))), monic_X_sub_C _, ?_⟩
simp only [eval₂_sub, eval₂_X, eval₂_C]
rw [sub_eq_zero, ← φ'.comp_apply]
simp [φ', IsLocalization.map_comp _, P', φ]
· obtain ⟨p, rfl⟩ := Ideal.Quotient.mk_surjective p'
rw [← RingHom.comp_apply]
apply Subring.mem_closure_image_of
apply Polynomial.mem_closure_X_union_C
/-- If `f : R → S` descends to an integral map in the localization at `x`,
and `R` is a Jacobson ring, then the intersection of all maximal ideals in `S` is trivial -/
theorem jacobson_bot_of_integral_localization
{R : Type*} [CommRing R] [IsDomain R] [IsJacobsonRing R]
(Rₘ Sₘ : Type*) [CommRing Rₘ] [CommRing Sₘ] (φ : R →+* S) (hφ : Function.Injective ↑φ) (x : R)
(hx : x ≠ 0) [Algebra R Rₘ] [IsLocalization.Away x Rₘ] [Algebra S Sₘ]
[IsLocalization ((Submonoid.powers x).map φ : Submonoid S) Sₘ]
(hφ' :
RingHom.IsIntegral (IsLocalization.map Sₘ φ (Submonoid.powers x).le_comap_map : Rₘ →+* Sₘ)) :
(⊥ : Ideal S).jacobson = (⊥ : Ideal S) := by
have hM : ((Submonoid.powers x).map φ : Submonoid S) ≤ nonZeroDivisors S :=
map_le_nonZeroDivisors_of_injective φ hφ (powers_le_nonZeroDivisors_of_noZeroDivisors hx)
letI : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors _ hM
let φ' : Rₘ →+* Sₘ := IsLocalization.map _ φ (Submonoid.powers x).le_comap_map
suffices ∀ I : Ideal Sₘ, I.IsMaximal → (I.comap (algebraMap S Sₘ)).IsMaximal by
have hϕ' : comap (algebraMap S Sₘ) (⊥ : Ideal Sₘ) = (⊥ : Ideal S) := by
rw [← RingHom.ker_eq_comap_bot, ← RingHom.injective_iff_ker_eq_bot]
exact IsLocalization.injective Sₘ hM
have hRₘ : IsJacobsonRing Rₘ := isJacobsonRing_localization x
have hSₘ : IsJacobsonRing Sₘ := isJacobsonRing_of_isIntegral' φ' hφ'
refine eq_bot_iff.mpr (le_trans ?_ (le_of_eq hϕ'))
rw [← hSₘ.out isRadical_bot_of_noZeroDivisors, comap_jacobson]
exact sInf_le_sInf fun j hj => ⟨bot_le,
let ⟨J, hJ⟩ := hj
hJ.2 ▸ this J hJ.1.2⟩
intro I hI
-- Remainder of the proof is pulling and pushing ideals around the square and the quotient square
have : (I.comap (algebraMap S Sₘ)).IsPrime := comap_isPrime _ I
have : (I.comap φ').IsPrime := comap_isPrime φ' I
have : (⊥ : Ideal (S ⧸ I.comap (algebraMap S Sₘ))).IsPrime := bot_prime
have hcomm : φ'.comp (algebraMap R Rₘ) = (algebraMap S Sₘ).comp φ := IsLocalization.map_comp _
let f := quotientMap (I.comap (algebraMap S Sₘ)) φ le_rfl
let g := quotientMap I (algebraMap S Sₘ) le_rfl
have := isMaximal_comap_of_isIntegral_of_isMaximal' φ' hφ' I
have := ((IsLocalization.isMaximal_iff_isMaximal_disjoint Rₘ x _).1 this).left
have : ((I.comap (algebraMap S Sₘ)).comap φ).IsMaximal := by
rwa [comap_comap, hcomm, ← comap_comap] at this
rw [← bot_quotient_isMaximal_iff] at this ⊢
refine isMaximal_of_isIntegral_of_isMaximal_comap' f ?_ ⊥
((eq_bot_iff.2 (comap_bot_le_of_injective f quotientMap_injective)).symm ▸ this)
exact RingHom.IsIntegral.tower_bot f g quotientMap_injective
((comp_quotientMap_eq_of_comp_eq hcomm I).symm ▸
(RingHom.isIntegral_of_surjective _
(IsLocalization.surjective_quotientMap_of_maximal_of_localization (Submonoid.powers x) Rₘ
(by rwa [comap_comap, hcomm, ← bot_quotient_isMaximal_iff]))).trans _ _ (hφ'.quotient _))
/-- Used to bootstrap the proof of `isJacobsonRing_polynomial_iff_isJacobsonRing`.
That theorem is more general and should be used instead of this one. -/
private theorem isJacobsonRing_polynomial_of_domain (R : Type*) [CommRing R] [IsDomain R]
[hR : IsJacobsonRing R] (P : Ideal R[X]) [IsPrime P] (hP : ∀ x : R, C x ∈ P → x = 0) :
P.jacobson = P := by
by_cases Pb : P = ⊥
· exact Pb.symm ▸
jacobson_bot_polynomial_of_jacobson_bot (hR.out isRadical_bot_of_noZeroDivisors)
· rw [jacobson_eq_iff_jacobson_quotient_eq_bot]
let P' := P.comap (C : R →+* R[X])
have : P'.IsPrime := comap_isPrime C P
have hR' : IsJacobsonRing (R ⧸ P') := by infer_instance
obtain ⟨p, pP, p0⟩ := exists_nonzero_mem_of_ne_bot Pb hP
let x := (Polynomial.map (Ideal.Quotient.mk P') p).leadingCoeff
have hx : x ≠ 0 := by rwa [Ne, leadingCoeff_eq_zero]
let φ : R ⧸ P' →+* R[X] ⧸ P := Ideal.quotientMap P (C : R →+* R[X]) le_rfl
let hφ : Function.Injective ↑φ := quotientMap_injective
let Rₘ := Localization.Away x
let Sₘ := (Localization ((Submonoid.powers x).map φ : Submonoid (R[X] ⧸ P)))
refine jacobson_bot_of_integral_localization (S := R[X] ⧸ P) (R := R ⧸ P') Rₘ Sₘ _ hφ _ hx ?_
exact isIntegral_isLocalization_polynomial_quotient P p pP
theorem isJacobsonRing_polynomial_of_isJacobsonRing (hR : IsJacobsonRing R) :
IsJacobsonRing R[X] := by
rw [isJacobsonRing_iff_prime_eq]
intro I hI
let R' : Subring (R[X] ⧸ I) := ((Ideal.Quotient.mk I).comp C).range
let i : R →+* R' := ((Ideal.Quotient.mk I).comp C).rangeRestrict
have hi : Function.Surjective ↑i := ((Ideal.Quotient.mk I).comp C).rangeRestrict_surjective
have hi' : RingHom.ker (mapRingHom i) ≤ I := by
intro f hf
apply polynomial_mem_ideal_of_coeff_mem_ideal I f
intro n
replace hf := congrArg (fun g : Polynomial ((Ideal.Quotient.mk I).comp C).range => g.coeff n) hf
change (Polynomial.map ((Ideal.Quotient.mk I).comp C).rangeRestrict f).coeff n = 0 at hf
rw [coeff_map, Subtype.ext_iff] at hf
rwa [mem_comap, ← Quotient.eq_zero_iff_mem, ← RingHom.comp_apply]
have R'_jacob : IsJacobsonRing R' := isJacobsonRing_of_surjective ⟨i, hi⟩
let J := I.map (mapRingHom i)
have h_surj : Function.Surjective (mapRingHom i) := Polynomial.map_surjective i hi
have : IsPrime J := map_isPrime_of_surjective h_surj hi'
suffices h : J.jacobson = J by
replace h := congrArg (comap (Polynomial.mapRingHom i)) h
rw [← map_jacobson_of_surjective h_surj hi', comap_map_of_surjective _ h_surj,
comap_map_of_surjective _ h_surj] at h
refine le_antisymm ?_ le_jacobson
exact le_trans (le_sup_of_le_left le_rfl) (le_trans (le_of_eq h) (sup_le le_rfl hi'))
apply isJacobsonRing_polynomial_of_domain R' J
exact eq_zero_of_polynomial_mem_map_range I
theorem isJacobsonRing_polynomial_iff_isJacobsonRing : IsJacobsonRing R[X] ↔ IsJacobsonRing R := by
refine ⟨?_, isJacobsonRing_polynomial_of_isJacobsonRing⟩
intro H
exact isJacobsonRing_of_surjective ⟨eval₂RingHom (RingHom.id _) 1, fun x =>
⟨C x, by simp only [coe_eval₂RingHom, RingHom.id_apply, eval₂_C]⟩⟩
instance [IsJacobsonRing R] : IsJacobsonRing R[X] :=
isJacobsonRing_polynomial_iff_isJacobsonRing.mpr ‹IsJacobsonRing R›
end CommRing
section
variable {R : Type*} [CommRing R]
variable (P : Ideal R[X]) [hP : P.IsMaximal]
theorem isMaximal_comap_C_of_isMaximal [IsJacobsonRing R] [Nontrivial R]
(hP' : ∀ x : R, C x ∈ P → x = 0) :
IsMaximal (comap (C : R →+* R[X]) P : Ideal R) := by
let P' := comap (C : R →+* R[X]) P
have hP'_prime : P'.IsPrime := comap_isPrime C P
obtain ⟨⟨m, hmem_P⟩, hm⟩ :=
Submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_isField)
have hm' : m ≠ 0 := by
simpa [Submodule.coe_eq_zero] using hm
let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P (C : R →+* R[X]) le_rfl
let a : R ⧸ P' := (m.map (Ideal.Quotient.mk P')).leadingCoeff
let M : Submonoid (R ⧸ P') := Submonoid.powers a
rw [← bot_quotient_isMaximal_iff]
have hp0 : a ≠ 0 := fun hp0' =>
hm' <| map_injective (Ideal.Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R))
((injective_iff_map_eq_zero (Ideal.Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R))).2
fun x hx => by
rwa [Quotient.eq_zero_iff_mem, (by rwa [eq_bot_iff] : (P.comap C : Ideal R) = ⊥)] at hx)
(by simpa only [a, leadingCoeff_eq_zero, Polynomial.map_zero] using hp0')
have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ => hp0 (eq_zero_of_pow_eq_zero hn)
suffices (⊥ : Ideal (Localization M)).IsMaximal by
rw [← IsLocalization.comap_map_of_isPrime_disjoint M (Localization M) ⊥ bot_prime
(disjoint_iff_inf_le.mpr fun x hx => hM (hx.2 ▸ hx.1))]
exact ((IsLocalization.isMaximal_iff_isMaximal_disjoint (Localization M) a _).mp
(by rwa [Ideal.map_bot])).1
let M' : Submonoid (R[X] ⧸ P) := M.map φ
have hM' : (0 : R[X] ⧸ P) ∉ M' := fun ⟨z, hz⟩ =>
hM (quotientMap_injective (_root_.trans hz.2 φ.map_zero.symm) ▸ hz.1)
suffices (⊥ : Ideal (Localization M')).IsMaximal by
rw [le_antisymm bot_le (comap_bot_le_of_injective _
(IsLocalization.map_injective_of_injective M (Localization M) (Localization M')
quotientMap_injective))]
refine isMaximal_comap_of_isIntegral_of_isMaximal' _ ?_ ⊥
have isloc : IsLocalization (Submonoid.map φ M) (Localization M') := by infer_instance
exact @isIntegral_isLocalization_polynomial_quotient R _
(Localization M) (Localization M') _ _ P m hmem_P _ _ _ isloc
rw [(map_bot.symm :
(⊥ : Ideal (Localization M')) = Ideal.map (algebraMap (R[X] ⧸ P) (Localization M')) ⊥)]
let bot_maximal := (bot_quotient_isMaximal_iff _).mpr hP
refine bot_maximal.map_bijective (algebraMap (R[X] ⧸ P) (Localization M')) ?_
apply IsField.localization_map_bijective hM'
rwa [← Quotient.maximal_ideal_iff_isField_quotient, ← bot_quotient_isMaximal_iff]
/-- Used to bootstrap the more general `quotient_mk_comp_C_isIntegral_of_jacobson` -/
private theorem quotient_mk_comp_C_isIntegral_of_jacobson' [Nontrivial R] (hR : IsJacobsonRing R)
(hP' : ∀ x : R, C x ∈ P → x = 0) :
((Ideal.Quotient.mk P).comp C : R →+* R[X] ⧸ P).IsIntegral := by
refine (isIntegral_quotientMap_iff _).mp ?_
let P' : Ideal R := P.comap C
obtain ⟨pX, hpX, hp0⟩ :=
exists_nonzero_mem_of_ne_bot (ne_of_lt (bot_lt_of_maximal P polynomial_not_isField)).symm hP'
let a : R ⧸ P' := (pX.map (Ideal.Quotient.mk P')).leadingCoeff
let M : Submonoid (R ⧸ P') := Submonoid.powers a
let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl
have hP'_prime : P'.IsPrime := comap_isPrime C P
have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ =>
hp0 <| leadingCoeff_eq_zero.mp (eq_zero_of_pow_eq_zero hn)
let M' : Submonoid (R[X] ⧸ P) := M.map φ
refine RingHom.IsIntegral.tower_bot φ (algebraMap _ (Localization M')) ?_ ?_
· refine IsLocalization.injective (Localization M')
(show M' ≤ _ from le_nonZeroDivisors_of_noZeroDivisors fun hM' => hM ?_)
exact
let ⟨z, zM, z0⟩ := hM'
quotientMap_injective (_root_.trans z0 φ.map_zero.symm) ▸ zM
· suffices RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ =
(IsLocalization.map (Localization M') φ M.le_comap_map).comp
(algebraMap (R ⧸ P') (Localization M)) by
rw [this]
refine RingHom.IsIntegral.trans (algebraMap (R ⧸ P') (Localization M))
(IsLocalization.map (Localization M') φ M.le_comap_map) ?_ ?_
· exact (algebraMap (R ⧸ P') (Localization M)).isIntegral_of_surjective
(IsField.localization_map_bijective hM ((Quotient.maximal_ideal_iff_isField_quotient _).mp
(isMaximal_comap_C_of_isMaximal P hP'))).2
· -- `convert` here is faster than `exact`, and this proof is near the time limit.
-- convert isIntegral_isLocalization_polynomial_quotient P pX hpX
have isloc : IsLocalization M' (Localization M') := by infer_instance
exact @isIntegral_isLocalization_polynomial_quotient R _
(Localization M) (Localization M') _ _ P pX hpX _ _ _ isloc
rw [IsLocalization.map_comp M.le_comap_map]
variable [IsJacobsonRing R]
/-- If `R` is a Jacobson ring, and `P` is a maximal ideal of `R[X]`,
then `R → R[X]/P` is an integral map. -/
theorem quotient_mk_comp_C_isIntegral_of_isJacobsonRing :
((Ideal.Quotient.mk P).comp C : R →+* R[X] ⧸ P).IsIntegral := by
let P' : Ideal R := P.comap C
have : P'.IsPrime := comap_isPrime C P
let f : R[X] →+* Polynomial (R ⧸ P') := Polynomial.mapRingHom (Ideal.Quotient.mk P')
have hf : Function.Surjective ↑f := map_surjective (Ideal.Quotient.mk P') Quotient.mk_surjective
have hPJ : P = (P.map f).comap f := by
rw [comap_map_of_surjective _ hf]
refine le_antisymm (le_sup_of_le_left le_rfl) (sup_le le_rfl ?_)
refine fun p hp =>
polynomial_mem_ideal_of_coeff_mem_ideal P p fun n => Quotient.eq_zero_iff_mem.mp ?_
simpa only [f, coeff_map, coe_mapRingHom] using (Polynomial.ext_iff.mp hp) n
refine RingHom.IsIntegral.tower_bot
(T := (R ⧸ comap C P)[X] ⧸ _) _ _ (injective_quotient_le_comap_map P) ?_
rw [← quotient_mk_maps_eq]
refine ((Ideal.Quotient.mk P').isIntegral_of_surjective Quotient.mk_surjective).trans _ _ ?_
have : IsMaximal (Ideal.map (mapRingHom (Ideal.Quotient.mk (comap C P))) P) :=
Or.recOn (map_eq_top_or_isMaximal_of_surjective f hf hP)
(fun h => absurd (_root_.trans (h ▸ hPJ : P = comap f ⊤) comap_top : P = ⊤) hP.ne_top) id
apply quotient_mk_comp_C_isIntegral_of_jacobson' _ ?_ (fun x hx => ?_)
any_goals exact isJacobsonRing_quotient
obtain ⟨z, rfl⟩ := Ideal.Quotient.mk_surjective x
rwa [Quotient.eq_zero_iff_mem, mem_comap, hPJ, mem_comap, coe_mapRingHom, map_C]
theorem isMaximal_comap_C_of_isJacobsonRing : (P.comap (C : R →+* R[X])).IsMaximal := by
rw [← @mk_ker _ _ P, RingHom.ker_eq_comap_bot, comap_comap]
have := (bot_quotient_isMaximal_iff _).mpr hP
exact isMaximal_comap_of_isIntegral_of_isMaximal' _
(quotient_mk_comp_C_isIntegral_of_isJacobsonRing P) ⊥
theorem comp_C_integral_of_surjective_of_isJacobsonRing {S : Type*} [Field S] (f : R[X] →+* S)
(hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
have : (RingHom.ker f).IsMaximal := RingHom.ker_isMaximal_of_surjective f hf
let g : R[X] ⧸ (RingHom.ker f) →+* S := Ideal.Quotient.lift (RingHom.ker f) f fun _ h => h
have hfg : g.comp (Ideal.Quotient.mk (RingHom.ker f)) = f := ringHom_ext' rfl rfl
rw [← hfg, RingHom.comp_assoc]
refine (quotient_mk_comp_C_isIntegral_of_isJacobsonRing (RingHom.ker f)).trans _ g
(g.isIntegral_of_surjective ?_)
rw [← hfg] at hf
norm_num at hf
exact Function.Surjective.of_comp hf
end
end Polynomial
open MvPolynomial RingHom
namespace MvPolynomial
theorem isJacobsonRing_MvPolynomial_fin {R : Type u} [CommRing R] [H : IsJacobsonRing R] :
∀ n : ℕ, IsJacobsonRing (MvPolynomial (Fin n) R)
| 0 => (isJacobsonRing_iso ((renameEquiv R (Equiv.equivPEmpty (Fin 0))).toRingEquiv.trans
(isEmptyRingEquiv R PEmpty.{u+1}))).mpr H
| n + 1 => (isJacobsonRing_iso (finSuccEquiv R n).toRingEquiv).2
(Polynomial.isJacobsonRing_polynomial_iff_isJacobsonRing.2 (isJacobsonRing_MvPolynomial_fin n))
/-- General form of the Nullstellensatz for Jacobson rings, since in a Jacobson ring we have
`Inf {P maximal | P ≥ I} = Inf {P prime | P ≥ I} = I.radical`. Fields are always Jacobson,
and in that special case this is (most of) the classical Nullstellensatz,
since `I(V(I))` is the intersection of maximal ideals containing `I`, which is then `I.radical` -/
instance isJacobsonRing {R : Type*} [CommRing R] {ι : Type*} [Finite ι] [IsJacobsonRing R] :
IsJacobsonRing (MvPolynomial ι R) := by
cases nonempty_fintype ι
let e := Fintype.equivFin ι
rw [isJacobsonRing_iso (renameEquiv R e).toRingEquiv]
exact isJacobsonRing_MvPolynomial_fin _
variable {n : ℕ}
universe v w
/-- The constant coefficient as an R-linear morphism -/
private noncomputable def Cₐ (R : Type u) (S : Type v)
[CommRing R] [CommRing S] [Algebra R S] : S →ₐ[R] S[X] :=
{ Polynomial.C with commutes' := fun r => by rfl }
private lemma aux_IH {R : Type u} {S : Type v} {T : Type w}
[CommRing R] [CommRing S] [CommRing T] [IsJacobsonRing S] [Algebra R S] [Algebra R T]
(IH : ∀ (Q : Ideal S), (IsMaximal Q) → RingHom.IsIntegral (algebraMap R (S ⧸ Q)))
(v : S[X] ≃ₐ[R] T) (P : Ideal T) (hP : P.IsMaximal) :
RingHom.IsIntegral (algebraMap R (T ⧸ P)) := by
let Q := P.comap v.toAlgHom.toRingHom
have hw : Ideal.map v Q = P := map_comap_of_surjective v v.surjective P
have hQ : IsMaximal Q := comap_isMaximal_of_surjective _ v.surjective
let w : (S[X] ⧸ Q) ≃ₐ[R] (T ⧸ P) := Ideal.quotientEquivAlg Q P v hw.symm
let Q' := Q.comap (Polynomial.C)
let w' : (S ⧸ Q') →ₐ[R] (S[X] ⧸ Q) := Ideal.quotientMapₐ Q (Cₐ R S) le_rfl
have h_eq : algebraMap R (T ⧸ P) =
w.toRingEquiv.toRingHom.comp (w'.toRingHom.comp (algebraMap R (S ⧸ Q'))) := by
ext r
simp only [AlgHom.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe,
RingEquiv.toRingHom_eq_coe, AlgHom.comp_algebraMap_of_tower, coe_comp, coe_coe,
AlgEquiv.coe_ringEquiv, Function.comp_apply, AlgEquiv.commutes]
rw [h_eq]
apply RingHom.IsIntegral.trans
· apply RingHom.IsIntegral.trans
· apply IH
apply Polynomial.isMaximal_comap_C_of_isJacobsonRing
· suffices w'.toRingHom = Ideal.quotientMap Q (Polynomial.C) le_rfl by
rw [this]
rw [isIntegral_quotientMap_iff _]
apply Polynomial.quotient_mk_comp_C_isIntegral_of_isJacobsonRing
rfl
· apply RingHom.isIntegral_of_surjective
exact w.surjective
private theorem quotient_mk_comp_C_isIntegral_of_isJacobsonRing'
{R : Type*} [CommRing R] [IsJacobsonRing R]
(P : Ideal (MvPolynomial (Fin n) R)) (hP : P.IsMaximal) :
RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P)) := by
induction n with
| zero =>
apply RingHom.isIntegral_of_surjective
apply Function.Surjective.comp Quotient.mk_surjective
exact C_surjective (Fin 0)
| succ n IH => apply aux_IH IH (finSuccEquiv R n).symm P hP
theorem quotient_mk_comp_C_isIntegral_of_isJacobsonRing {R : Type*} [CommRing R] [IsJacobsonRing R]
(P : Ideal (MvPolynomial (Fin n) R)) [hP : P.IsMaximal] :
RingHom.IsIntegral (RingHom.comp (Ideal.Quotient.mk P) (MvPolynomial.C)) := by
change RingHom.IsIntegral (algebraMap R (MvPolynomial (Fin n) R ⧸ P))
apply quotient_mk_comp_C_isIntegral_of_isJacobsonRing'
infer_instance
theorem comp_C_integral_of_surjective_of_isJacobsonRing {R : Type*} [CommRing R] [IsJacobsonRing R]
{σ : Type*} [Finite σ] {S : Type*} [Field S] (f : MvPolynomial σ R →+* S)
(hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
cases nonempty_fintype σ
have e := (Fintype.equivFin σ).symm
let f' : MvPolynomial (Fin _) R →+* S := f.comp (renameEquiv R e).toRingEquiv.toRingHom
have hf' := Function.Surjective.comp hf (renameEquiv R e).surjective
change Function.Surjective ↑f' at hf'
have : (f'.comp C).IsIntegral := by
have : (RingHom.ker f').IsMaximal := ker_isMaximal_of_surjective f' hf'
let g : MvPolynomial _ R ⧸ (RingHom.ker f') →+* S :=
Ideal.Quotient.lift (RingHom.ker f') f' fun _ h => h
have hfg : g.comp (Ideal.Quotient.mk (RingHom.ker f')) = f' :=
ringHom_ext (fun r => rfl) fun i => rfl
rw [← hfg, RingHom.comp_assoc]
refine (quotient_mk_comp_C_isIntegral_of_isJacobsonRing (RingHom.ker f')).trans _ g
(g.isIntegral_of_surjective ?_)
rw [← hfg] at hf'
norm_num at hf'
exact Function.Surjective.of_comp hf'
rw [RingHom.comp_assoc] at this
convert this
refine RingHom.ext fun x => ?_
exact ((renameEquiv R e).commutes' x).symm
end MvPolynomial
lemma isJacobsonRing_of_finiteType {A B : Type*} [CommRing A] [CommRing B]
[Algebra A B] [IsJacobsonRing A] [Algebra.FiniteType A B] : IsJacobsonRing B := by
obtain ⟨ι, hι, f, hf⟩ := Algebra.FiniteType.iff_quotient_mvPolynomial'.mp ‹_›
exact isJacobsonRing_of_surjective ⟨f.toRingHom, hf⟩
lemma RingHom.FiniteType.isJacobsonRing {A B : Type*} [CommRing A] [CommRing B]
{f : A →+* B} [IsJacobsonRing A] (H : f.FiniteType) : IsJacobsonRing B :=
@isJacobsonRing_of_finiteType A B _ _ f.toAlgebra _ H
@[stacks 0CY7 "See also https://en.wikipedia.org/wiki/Zariski%27s_lemma."]
lemma finite_of_finite_type_of_isJacobsonRing (R S : Type*) [CommRing R] [Field S]
[Algebra R S] [IsJacobsonRing R] [Algebra.FiniteType R S] :
Module.Finite R S := by
obtain ⟨ι, hι, f, hf⟩ := Algebra.FiniteType.iff_quotient_mvPolynomial'.mp ‹_›
have : (algebraMap R S).IsIntegral := by
rw [← f.comp_algebraMap]
-- We need to write `f.toRingHom` instead of just `f`, to avoid unification issues.
exact MvPolynomial.comp_C_integral_of_surjective_of_isJacobsonRing f.toRingHom hf
have : Algebra.IsIntegral R S := Algebra.isIntegral_def.mpr this
exact Algebra.IsIntegral.finite
/--
If `f : R →+* S` is a ring homomorphism from a Jacobson ring to a field,
then it is finite if and only if it is finite type.
-/
lemma RingHom.finite_iff_finiteType_of_isJacobsonRing
{R S : Type*} [CommRing R] [IsJacobsonRing R] [Field S]
{f : R →+* S} : f.Finite ↔ f.FiniteType :=
⟨RingHom.FiniteType.of_finite,
by intro; algebraize [f]; exact finite_of_finite_type_of_isJacobsonRing R S⟩
/-- If `K` is a Jacobson Noetherian ring, `A` a nontrivial `K`-algebra of finite type,
then any `K`-subfield of `A` is finite over `K`. -/
theorem finite_of_algHom_finiteType_of_isJacobsonRing
{K L A : Type*} [CommRing K] [DivisionRing L] [CommRing A]
[IsJacobsonRing K] [IsNoetherianRing K] [Nontrivial A]
[Algebra K L] [Algebra K A]
[Algebra.FiniteType K A] (f : L →ₐ[K] A) :
Module.Finite K L := by
obtain ⟨m, hm⟩ := Ideal.exists_maximal A
letI := Ideal.Quotient.field m
have := finite_of_finite_type_of_isJacobsonRing K (A ⧸ m)
exact Module.Finite.of_injective ((Ideal.Quotient.mkₐ K m).comp f).toLinearMap
(RingHom.injective _)
/-- If `K` is a Jacobson Noetherian ring, `A` a nontrivial `K`-algebra of finite type,
then any `K`-subfield of `A` is finite over `K`. -/
nonrec theorem RingHom.finite_of_algHom_finiteType_of_isJacobsonRing
{K L A : Type*} [CommRing K] [Field L] [CommRing A]
[IsJacobsonRing K] [IsNoetherianRing K] [Nontrivial A]
(f : K →+* L) (g : L →+* A) (hfg : (g.comp f).FiniteType) :
f.Finite := by
algebraize [f, (g.comp f)]
exact finite_of_algHom_finiteType_of_isJacobsonRing ⟨g, fun _ ↦ rfl⟩ |
.lake/packages/mathlib/Mathlib/RingTheory/Jacobson/Semiprimary.lean | import Mathlib.RingTheory.Jacobson.Radical
import Mathlib.RingTheory.Nilpotent.Defs
import Mathlib.RingTheory.SimpleModule.Basic
/-!
# Semiprimary rings
## Main definition
* `IsSemiprimaryRing R`: a ring `R` is semiprimary if
`Ring.jacobson R` is nilpotent and `R ⧸ Ring.jacobson R` is semisimple.
-/
variable (R R₂ M M₂ : Type*) [Ring R] [Ring R₂]
variable [AddCommGroup M] [Module R M] [AddCommGroup M₂] [Module R₂ M₂]
variable {τ₁₂ : R →+* R₂} [RingHomSurjective τ₁₂]
variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂] (f : F)
theorem IsSimpleModule.jacobson_eq_bot [IsSimpleModule R M] : Module.jacobson R M = ⊥ :=
le_bot_iff.mp <| sInf_le isCoatom_bot
theorem IsSemisimpleModule.jacobson_eq_bot [IsSemisimpleModule R M] :
Module.jacobson R M = ⊥ :=
have ⟨s, e, simple⟩ := isSemisimpleModule_iff_exists_linearEquiv_dfinsupp.mp ‹_›
let f : M →ₗ[R] ∀ m : s, m.1 := (LinearMap.pi DFinsupp.lapply).comp e.toLinearMap
Module.jacobson_eq_bot_of_injective f (DFinsupp.injective_pi_lapply (R := R).comp e.injective)
(Module.jacobson_pi_eq_bot _ _ fun i ↦ IsSimpleModule.jacobson_eq_bot R _)
theorem IsSemisimpleRing.jacobson_eq_bot [IsSemisimpleRing R] : Ring.jacobson R = ⊥ :=
IsSemisimpleModule.jacobson_eq_bot R R
theorem IsSemisimpleModule.jacobson_le_ker [IsSemisimpleModule R₂ M₂] :
Module.jacobson R M ≤ LinearMap.ker f :=
(Module.le_comap_jacobson f).trans <| by simp_rw [jacobson_eq_bot, LinearMap.ker, le_rfl]
/-- The Jacobson radical of a ring annihilates every semisimple module. -/
theorem IsSemisimpleModule.jacobson_le_annihilator [IsSemisimpleModule R M] :
Ring.jacobson R ≤ Module.annihilator R M :=
fun r hr ↦ Module.mem_annihilator.mpr fun m ↦ by
have := Module.le_comap_jacobson (LinearMap.toSpanSingleton R M m) hr
rwa [jacobson_eq_bot] at this
instance (priority := low) (R) [CommRing R] [IsSemisimpleRing R] : IsReduced R where
eq_zero _ := fun ⟨n, eq⟩ ↦ (IsSemisimpleRing.jacobson_eq_bot R).le <| Ideal.mem_sInf.mpr
fun I hI ↦ (Ideal.isMaximal_def.mpr hI).isPrime.mem_of_pow_mem n (eq ▸ I.zero_mem)
/-- A ring is semiprimary if its Jacobson radical is nilpotent and its quotient by the
Jacobson radical is semisimple. -/
@[mk_iff] class IsSemiprimaryRing : Prop where
isSemisimpleRing : IsSemisimpleRing (R ⧸ Ring.jacobson R)
isNilpotent : IsNilpotent (Ring.jacobson R)
attribute [instance] IsSemiprimaryRing.isSemisimpleRing |
.lake/packages/mathlib/Mathlib/RingTheory/Jacobson/Ideal.lean | import Mathlib.RingTheory.Ideal.IsPrimary
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.TwoSidedIdeal.Operations
import Mathlib.RingTheory.Jacobson.Radical
/-!
# Jacobson radical
The Jacobson radical of a ring `R` is defined to be the intersection of all maximal ideals of `R`.
This is similar to how the nilradical is equal to the intersection of all prime ideals of `R`.
We can extend the idea of the nilradical of `R` to ideals of `R`,
by letting the nilradical of an ideal `I` be the intersection of prime ideals containing `I`.
Under this extension, the original nilradical is the radical of the zero ideal `⊥`.
Here we define the Jacobson radical of an ideal `I` in a similar way,
as the intersection of maximal ideals containing `I`.
## Main definitions
Let `R` be a ring, and `I` be a left ideal of `R`
* `Ideal.jacobson I` is the Jacobson radical, i.e. the infimum of all maximal ideals containing `I`.
* `Ideal.IsLocal I` is the proposition that the Jacobson radical of `I` is itself a maximal ideal
Furthermore when `I` is a two-sided ideal of `R`
* `TwoSidedIdeal.jacobson I` is the Jacobson radical as a two-sided ideal
## Main statements
* `mem_jacobson_iff` gives a characterization of members of the Jacobson of I
* `Ideal.isLocal_of_isMaximal_radical`: if the radical of I is maximal then so is the Jacobson
radical
## Tags
Jacobson, Jacobson radical, Local Ideal
-/
universe u v
namespace Ideal
variable {R : Type u} {S : Type v}
section Jacobson
section Ring
variable [Ring R] [Ring S] {I : Ideal R}
/-- The Jacobson radical of `I` is the infimum of all maximal (left) ideals containing `I`. -/
def jacobson (I : Ideal R) : Ideal R :=
sInf { J : Ideal R | I ≤ J ∧ IsMaximal J }
theorem le_jacobson : I ≤ jacobson I := fun _ hx => mem_sInf.mpr fun _ hJ => hJ.left hx
@[simp]
theorem jacobson_idem : jacobson (jacobson I) = jacobson I :=
le_antisymm (sInf_le_sInf fun _ hJ => ⟨sInf_le hJ, hJ.2⟩) le_jacobson
@[simp]
theorem jacobson_top : jacobson (⊤ : Ideal R) = ⊤ :=
eq_top_iff.2 le_jacobson
theorem jacobson_bot : jacobson (⊥ : Ideal R) = Ring.jacobson R := by
simp_rw [jacobson, Ring.jacobson, Module.jacobson, bot_le, true_and, isMaximal_def]
@[simp]
theorem jacobson_eq_top_iff : jacobson I = ⊤ ↔ I = ⊤ :=
⟨fun H =>
by_contradiction fun hi => let ⟨M, hm, him⟩ := exists_le_maximal I hi
lt_top_iff_ne_top.1
(lt_of_le_of_lt (show jacobson I ≤ M from sInf_le ⟨him, hm⟩) <|
lt_top_iff_ne_top.2 hm.ne_top) H,
fun H => eq_top_iff.2 <| le_sInf fun _ ⟨hij, _⟩ => H ▸ hij⟩
theorem jacobson_eq_bot : jacobson I = ⊥ → I = ⊥ := fun h => eq_bot_iff.mpr (h ▸ le_jacobson)
theorem jacobson_eq_self_of_isMaximal [H : IsMaximal I] : I.jacobson = I :=
le_antisymm (sInf_le ⟨le_of_eq rfl, H⟩) le_jacobson
instance (priority := 100) jacobson.isMaximal [H : IsMaximal I] : IsMaximal (jacobson I) :=
⟨⟨fun htop => H.1.1 (jacobson_eq_top_iff.1 htop), fun _ hJ =>
H.1.2 _ (lt_of_le_of_lt le_jacobson hJ)⟩⟩
theorem mem_jacobson_iff {x : R} : x ∈ jacobson I ↔ ∀ y, ∃ z, z * y * x + z - 1 ∈ I :=
⟨fun hx y =>
by_cases
(fun hxy : I ⊔ span {y * x + 1} = ⊤ =>
let ⟨p, hpi, q, hq, hpq⟩ := Submodule.mem_sup.1 ((eq_top_iff_one _).1 hxy)
let ⟨r, hr⟩ := mem_span_singleton'.1 hq
⟨r, by
rw [mul_assoc, ← mul_add_one, hr, ← hpq, ← neg_sub, add_sub_cancel_right]
exact I.neg_mem hpi⟩)
fun hxy : I ⊔ span {y * x + 1} ≠ ⊤ => let ⟨M, hm1, hm2⟩ := exists_le_maximal _ hxy
suffices x ∉ M from (this <| mem_sInf.1 hx ⟨le_trans le_sup_left hm2, hm1⟩).elim
fun hxm => hm1.1.1 <| (eq_top_iff_one _).2 <| add_sub_cancel_left (y * x) 1 ▸
M.sub_mem (le_sup_right.trans hm2 <| subset_span rfl) (M.mul_mem_left _ hxm),
fun hx => mem_sInf.2 fun M ⟨him, hm⟩ => by_contradiction fun hxm =>
let ⟨y, i, hi, df⟩ := hm.exists_inv hxm
let ⟨z, hz⟩ := hx (-y)
hm.1.1 <| (eq_top_iff_one _).2 <| sub_sub_cancel (z * -y * x + z) 1 ▸
M.sub_mem (by
rw [mul_assoc, ← mul_add_one, neg_mul, ← sub_eq_iff_eq_add.mpr df.symm, neg_sub,
sub_add_cancel]
exact M.mul_mem_left _ hi) <| him hz⟩
theorem exists_mul_add_sub_mem_of_mem_jacobson {I : Ideal R} (r : R) (h : r ∈ jacobson I) :
∃ s, s * (r + 1) - 1 ∈ I := by
obtain ⟨s, hs⟩ := mem_jacobson_iff.1 h 1
use s
rw [mul_add, mul_one]
simpa using hs
theorem exists_mul_sub_mem_of_sub_one_mem_jacobson {I : Ideal R} (r : R) (h : r - 1 ∈ jacobson I) :
∃ s, s * r - 1 ∈ I := by
convert exists_mul_add_sub_mem_of_mem_jacobson _ h
simp
/-- An ideal equals its Jacobson radical iff it is the intersection of a set of maximal ideals.
Allowing the set to include ⊤ is equivalent, and is included only to simplify some proofs. -/
theorem eq_jacobson_iff_sInf_maximal :
I.jacobson = I ↔ ∃ M : Set (Ideal R), (∀ J ∈ M, IsMaximal J ∨ J = ⊤) ∧ I = sInf M := by
use fun hI => ⟨{ J : Ideal R | I ≤ J ∧ J.IsMaximal }, ⟨fun _ hJ => Or.inl hJ.right, hI.symm⟩⟩
rintro ⟨M, hM, hInf⟩
refine le_antisymm (fun x hx => ?_) le_jacobson
rw [hInf, mem_sInf]
intro I hI
rcases hM I hI with is_max | is_top
· exact (mem_sInf.1 hx) ⟨le_sInf_iff.1 (le_of_eq hInf) I hI, is_max⟩
· exact is_top.symm ▸ Submodule.mem_top
theorem eq_jacobson_iff_sInf_maximal' :
I.jacobson = I ↔ ∃ M : Set (Ideal R), (∀ J ∈ M, ∀ (K : Ideal R), J < K → K = ⊤) ∧ I = sInf M :=
eq_jacobson_iff_sInf_maximal.trans
⟨fun h =>
let ⟨M, hM⟩ := h
⟨M,
⟨fun J hJ K hK =>
Or.recOn (hM.1 J hJ) (fun h => h.1.2 K hK) fun h => eq_top_iff.2 (le_of_lt (h ▸ hK)),
hM.2⟩⟩,
fun h =>
let ⟨M, hM⟩ := h
⟨M,
⟨fun J hJ =>
Or.recOn (Classical.em (J = ⊤)) (fun h => Or.inr h) fun h => Or.inl ⟨⟨h, hM.1 J hJ⟩⟩,
hM.2⟩⟩⟩
/-- An ideal `I` equals its Jacobson radical if and only if every element outside `I`
also lies outside of a maximal ideal containing `I`. -/
theorem eq_jacobson_iff_notMem :
I.jacobson = I ↔ ∀ x ∉ I, ∃ M : Ideal R, (I ≤ M ∧ M.IsMaximal) ∧ x ∉ M := by
constructor
· intro h x hx
rw [← h, Ideal.jacobson, mem_sInf] at hx
push_neg at hx
exact hx
· refine fun h => le_antisymm (fun x hx => ?_) le_jacobson
contrapose hx
rw [Ideal.jacobson, mem_sInf]
push_neg
exact h x hx
@[deprecated (since := "2025-05-23")] alias eq_jacobson_iff_not_mem := eq_jacobson_iff_notMem
theorem map_jacobson_of_surjective {f : R →+* S} (hf : Function.Surjective f) :
RingHom.ker f ≤ I → map f I.jacobson = (map f I).jacobson := by
intro h
unfold Ideal.jacobson
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11036): dot notation for `RingHom.ker` does not work
have : ∀ J ∈ { J : Ideal R | I ≤ J ∧ J.IsMaximal }, RingHom.ker f ≤ J :=
fun J hJ => le_trans h hJ.left
refine Trans.trans (map_sInf hf this) (le_antisymm ?_ ?_)
· refine
sInf_le_sInf fun J hJ =>
⟨comap f J, ⟨⟨le_comap_of_map_le hJ.1, ?_⟩, map_comap_of_surjective f hf J⟩⟩
haveI : J.IsMaximal := hJ.right
exact comap_isMaximal_of_surjective f hf
· refine sInf_le_sInf_of_subset_insert_top fun j hj => hj.recOn fun J hJ => ?_
rw [← hJ.2]
rcases map_eq_top_or_isMaximal_of_surjective f hf hJ.left.right with htop | hmax
· exact htop.symm ▸ Set.mem_insert ⊤ _
· exact Set.mem_insert_of_mem ⊤ ⟨map_mono hJ.1.1, hmax⟩
theorem map_jacobson_of_bijective {f : R →+* S} (hf : Function.Bijective f) :
map f I.jacobson = (map f I).jacobson :=
map_jacobson_of_surjective hf.right
(le_trans (le_of_eq ((RingHom.injective_iff_ker_eq_bot f).1 hf.left)) bot_le)
theorem comap_jacobson {f : R →+* S} {K : Ideal S} :
comap f K.jacobson = sInf (comap f '' { J : Ideal S | K ≤ J ∧ J.IsMaximal }) :=
Trans.trans (comap_sInf' f _) sInf_eq_iInf.symm
theorem comap_jacobson_of_surjective {f : R →+* S} (hf : Function.Surjective f) {K : Ideal S} :
comap f K.jacobson = (comap f K).jacobson := by
unfold Ideal.jacobson
refine le_antisymm ?_ ?_
· rw [← top_inf_eq (sInf _), ← sInf_insert, comap_sInf', sInf_eq_iInf]
refine iInf_le_iInf_of_subset fun J hJ => ?_
have : comap f (map f J) = J :=
Trans.trans (comap_map_of_surjective f hf J)
(le_antisymm (sup_le_iff.2 ⟨le_of_eq rfl, le_trans (comap_mono bot_le) hJ.left⟩)
le_sup_left)
rcases map_eq_top_or_isMaximal_of_surjective _ hf hJ.right with htop | hmax
· exact ⟨⊤, Set.mem_insert ⊤ _, htop ▸ this⟩
· exact ⟨map f J, Set.mem_insert_of_mem _ ⟨le_map_of_comap_le_of_surjective f hf hJ.1, hmax⟩,
this⟩
· simp_rw [comap_sInf, le_iInf_iff]
intro J hJ
haveI : J.IsMaximal := hJ.right
exact sInf_le ⟨comap_mono hJ.left, comap_isMaximal_of_surjective _ hf⟩
@[mono]
theorem jacobson_mono {I J : Ideal R} : I ≤ J → I.jacobson ≤ J.jacobson := by
intro h x hx
rw [jacobson, mem_sInf] at hx ⊢
exact fun K ⟨hK, hK_max⟩ => hx ⟨Trans.trans h hK, hK_max⟩
theorem ringJacobson_le_jacobson {I : Ideal R} : Ring.jacobson R ≤ I.jacobson :=
jacobson_bot.symm.trans_le (jacobson_mono bot_le)
/-- The Jacobson radical of a two-sided ideal is two-sided. -/
instance {I : Ideal R} [I.IsTwoSided] : I.jacobson.IsTwoSided where
-- Proof generalized from
-- https://ysharifi.wordpress.com/2022/08/16/the-jacobson-radical-definition-and-basic-results/
mul_mem_of_left {x} r xJ := by
apply mem_sInf.mpr
intro 𝔪 𝔪_mem
by_cases r𝔪 : r ∈ 𝔪
· apply 𝔪.smul_mem _ r𝔪
-- 𝔪₀ := { a : R | a*r ∈ 𝔪 }
let 𝔪₀ : Ideal R := Submodule.comap (DistribMulAction.toLinearMap R (S := Rᵐᵒᵖ) R (.op r)) 𝔪
suffices x ∈ 𝔪₀ by simpa [𝔪₀] using this
have I𝔪₀ : I ≤ 𝔪₀ := fun i iI =>
𝔪_mem.left (I.mul_mem_right _ iI)
have 𝔪₀_maximal : IsMaximal 𝔪₀ := by
refine isMaximal_iff.mpr ⟨
fun h => r𝔪 (by simpa [𝔪₀] using h),
fun J b 𝔪₀J b𝔪₀ bJ => ?_⟩
let K : Ideal R := Ideal.span {b*r} ⊔ 𝔪
have ⟨s, y, y𝔪, sbyr⟩ :=
mem_span_singleton_sup.mp <|
mul_mem_left _ r <|
(isMaximal_iff.mp 𝔪_mem.right).right K (b*r)
le_sup_right b𝔪₀
(mem_sup_left <| mem_span_singleton_self _)
have : 1 - s*b ∈ 𝔪₀ := by
rw [mul_one, add_comm, ← eq_sub_iff_add_eq] at sbyr
rw [sbyr, ← mul_assoc] at y𝔪
simp [𝔪₀, sub_mul, y𝔪]
have : 1 - s*b + s*b ∈ J := by
apply add_mem (𝔪₀J this) (J.mul_mem_left _ bJ)
simpa using this
exact mem_sInf.mp xJ ⟨I𝔪₀, 𝔪₀_maximal⟩
end Ring
section CommRing
variable [CommRing R] [CommRing S] {I : Ideal R}
theorem radical_le_jacobson : radical I ≤ jacobson I :=
le_sInf fun _ hJ => (radical_eq_sInf I).symm ▸ sInf_le ⟨hJ.left, IsMaximal.isPrime hJ.right⟩
theorem isRadical_of_eq_jacobson (h : jacobson I = I) : I.IsRadical :=
radical_le_jacobson.trans h.le
lemma isRadical_jacobson (I : Ideal R) : I.jacobson.IsRadical :=
isRadical_of_eq_jacobson jacobson_idem
theorem isUnit_of_sub_one_mem_jacobson_bot (r : R) (h : r - 1 ∈ jacobson (⊥ : Ideal R)) :
IsUnit r := by
obtain ⟨s, hs⟩ := exists_mul_sub_mem_of_sub_one_mem_jacobson r h
rw [mem_bot, sub_eq_zero, mul_comm] at hs
exact .of_mul_eq_one _ hs
theorem mem_jacobson_bot {x : R} : x ∈ jacobson (⊥ : Ideal R) ↔ ∀ y, IsUnit (x * y + 1) :=
⟨fun hx y =>
let ⟨z, hz⟩ := (mem_jacobson_iff.1 hx) y
isUnit_iff_exists_inv.2
⟨z, by rwa [add_mul, one_mul, ← sub_eq_zero, mul_right_comm, mul_comm _ z, mul_right_comm]⟩,
fun h =>
mem_jacobson_iff.mpr fun y =>
let ⟨b, hb⟩ := isUnit_iff_exists_inv.1 (h y)
⟨b, (Submodule.mem_bot R).2 (hb ▸ by ring)⟩⟩
/-- An ideal `I` of `R` is equal to its Jacobson radical if and only if
the Jacobson radical of the quotient ring `R/I` is the zero ideal -/
theorem jacobson_eq_iff_jacobson_quotient_eq_bot :
I.jacobson = I ↔ jacobson (⊥ : Ideal (R ⧸ I)) = ⊥ := by
have hf : Function.Surjective (Ideal.Quotient.mk I) := Submodule.Quotient.mk_surjective I
constructor
· intro h
replace h := congr_arg (Ideal.map (Ideal.Quotient.mk I)) h
rw [map_jacobson_of_surjective hf (le_of_eq mk_ker)] at h
simpa using h
· intro h
replace h := congr_arg (comap (Ideal.Quotient.mk I)) h
rw [comap_jacobson_of_surjective hf, ← RingHom.ker_eq_comap_bot (Ideal.Quotient.mk I)] at h
simpa using h
/-- The standard radical and Jacobson radical of an ideal `I` of `R` are equal if and only if
the nilradical and Jacobson radical of the quotient ring `R/I` coincide -/
theorem radical_eq_jacobson_iff_radical_quotient_eq_jacobson_bot :
I.radical = I.jacobson ↔ radical (⊥ : Ideal (R ⧸ I)) = jacobson ⊥ := by
have hf : Function.Surjective (Ideal.Quotient.mk I) := Submodule.Quotient.mk_surjective I
constructor
· intro h
have := congr_arg (map (Ideal.Quotient.mk I)) h
rw [map_radical_of_surjective hf (le_of_eq mk_ker),
map_jacobson_of_surjective hf (le_of_eq mk_ker)] at this
simpa using this
· intro h
have := congr_arg (comap (Ideal.Quotient.mk I)) h
rw [comap_radical, comap_jacobson_of_surjective hf,
← RingHom.ker_eq_comap_bot (Ideal.Quotient.mk I)] at this
simpa using this
theorem jacobson_radical_eq_jacobson : I.radical.jacobson = I.jacobson :=
le_antisymm
(le_trans (le_of_eq (congr_arg jacobson (radical_eq_sInf I)))
(sInf_le_sInf fun _ hJ => ⟨sInf_le ⟨hJ.1, hJ.2.isPrime⟩, hJ.2⟩))
(jacobson_mono le_radical)
end CommRing
end Jacobson
section IsLocal
variable [CommRing R]
/-- An ideal `I` is local iff its Jacobson radical is maximal. -/
class IsLocal (I : Ideal R) : Prop where
/-- A ring `R` is local if and only if its Jacobson radical is maximal -/
out : IsMaximal (jacobson I)
theorem isLocal_iff {I : Ideal R} : IsLocal I ↔ IsMaximal (jacobson I) :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
theorem isLocal_of_isMaximal_radical {I : Ideal R} (hi : IsMaximal (radical I)) : IsLocal I :=
⟨have : radical I = jacobson I :=
le_antisymm (le_sInf fun _ ⟨him, hm⟩ => hm.isPrime.radical_le_iff.2 him)
(sInf_le ⟨le_radical, hi⟩)
show IsMaximal (jacobson I) from this ▸ hi⟩
theorem IsLocal.le_jacobson {I J : Ideal R} (hi : IsLocal I) (hij : I ≤ J) (hj : J ≠ ⊤) :
J ≤ jacobson I :=
let ⟨_, hm, hjm⟩ := exists_le_maximal J hj
le_trans hjm <| le_of_eq <| Eq.symm <| hi.1.eq_of_le hm.1.1 <| sInf_le ⟨le_trans hij hjm, hm⟩
theorem IsLocal.mem_jacobson_or_exists_inv {I : Ideal R} (hi : IsLocal I) (x : R) :
x ∈ jacobson I ∨ ∃ y, y * x - 1 ∈ I :=
by_cases
(fun h : I ⊔ span {x} = ⊤ =>
let ⟨p, hpi, q, hq, hpq⟩ := Submodule.mem_sup.1 ((eq_top_iff_one _).1 h)
let ⟨r, hr⟩ := mem_span_singleton.1 hq
Or.inr ⟨r, by
rw [← hpq, mul_comm, ← hr, ← neg_sub, add_sub_cancel_right]; exact I.neg_mem hpi⟩)
fun h : I ⊔ span {x} ≠ ⊤ =>
Or.inl <|
le_trans le_sup_right (hi.le_jacobson le_sup_left h) <| mem_span_singleton.2 <| dvd_refl x
end IsLocal
theorem isPrimary_of_isMaximal_radical [CommRing R] {I : Ideal R} (hi : IsMaximal (radical I)) :
I.IsPrimary :=
have : radical I = jacobson I :=
le_antisymm (le_sInf fun _ ⟨him, hm⟩ => hm.isPrime.radical_le_iff.2 him)
(sInf_le ⟨le_radical, hi⟩)
isPrimary_iff.mpr
⟨ne_top_of_lt <| lt_of_le_of_lt le_radical (lt_top_iff_ne_top.2 hi.1.1), fun {x y} hxy =>
((isLocal_of_isMaximal_radical hi).mem_jacobson_or_exists_inv y).symm.imp
(fun ⟨z, hz⟩ => by
rw [← mul_one x, ← sub_sub_cancel (z * y) 1, mul_sub, mul_left_comm]
exact I.sub_mem (I.mul_mem_left _ hxy) (I.mul_mem_left _ hz))
(this ▸ id)⟩
end Ideal
namespace TwoSidedIdeal
variable {R : Type u} [Ring R]
/-- The Jacobson radical of `I` is the infimum of all maximal (left) ideals containing `I`. -/
def jacobson (I : TwoSidedIdeal R) : TwoSidedIdeal R :=
(asIdeal I).jacobson.toTwoSided
lemma asIdeal_jacobson (I : TwoSidedIdeal R) : asIdeal I.jacobson = (asIdeal I).jacobson := by
ext; simp [jacobson]
theorem mem_jacobson_iff {x : R} {I : TwoSidedIdeal R} :
x ∈ jacobson I ↔ ∀ y, ∃ z, z * y * x + z - 1 ∈ I := by
simp [jacobson, Ideal.mem_jacobson_iff]
end TwoSidedIdeal |
.lake/packages/mathlib/Mathlib/RingTheory/Jacobson/Polynomial.lean | import Mathlib.RingTheory.Jacobson.Ideal
import Mathlib.RingTheory.Polynomial.Quotient
/-!
# Jacobson radical of polynomial ring
-/
namespace Ideal
section Polynomial
open Polynomial
variable {R : Type*} [CommRing R]
theorem jacobson_bot_polynomial_le_sInf_map_maximal :
jacobson (⊥ : Ideal R[X]) ≤ sInf (map (C : R →+* R[X]) '' { J : Ideal R | J.IsMaximal }) := by
refine le_sInf fun J => exists_imp.2 fun j hj => ?_
haveI : j.IsMaximal := hj.1
refine Trans.trans (jacobson_mono bot_le) (le_of_eq ?_ : J.jacobson ≤ J)
suffices t : (⊥ : Ideal (Polynomial (R ⧸ j))).jacobson = ⊥ by
rw [← hj.2, jacobson_eq_iff_jacobson_quotient_eq_bot]
replace t := congr_arg (map (polynomialQuotientEquivQuotientPolynomial j).toRingHom) t
rwa [map_jacobson_of_bijective _, map_bot] at t
exact RingEquiv.bijective (polynomialQuotientEquivQuotientPolynomial j)
refine eq_bot_iff.2 fun f hf => ?_
have r1 : (X : (R ⧸ j)[X]) ≠ 0 := ne_of_apply_ne (coeff · 1) <| by simp
simpa [r1] using eq_C_of_degree_eq_zero (degree_eq_zero_of_isUnit ((mem_jacobson_bot.1 hf) X))
theorem jacobson_bot_polynomial_of_jacobson_bot (h : jacobson (⊥ : Ideal R) = ⊥) :
jacobson (⊥ : Ideal R[X]) = ⊥ := by
refine eq_bot_iff.2 (le_trans jacobson_bot_polynomial_le_sInf_map_maximal ?_)
refine fun f hf => (Submodule.mem_bot R[X]).2 <| Polynomial.ext fun n =>
Trans.trans (?_ : coeff f n = 0) (coeff_zero n).symm
suffices f.coeff n ∈ Ideal.jacobson ⊥ by rwa [h, Submodule.mem_bot] at this
exact mem_sInf.2 fun j hj => (mem_map_C_iff.1 ((mem_sInf.1 hf) ⟨j, ⟨hj.2, rfl⟩⟩)) n
end Polynomial
end Ideal |
.lake/packages/mathlib/Mathlib/RingTheory/Jacobson/Artinian.lean | import Mathlib.RingTheory.HopkinsLevitzki
import Mathlib.RingTheory.Jacobson.Ring
/-!
# Artinian rings over Jacobson rings
## Main results
- `Module.finite_iff_isArtinianRing`: If `A` is a finite type algebra over an Artinian ring `R`,
then `A` is finite over `R` if and only if `A` is an Artinian ring.
-/
variable (R A : Type*) [CommRing R] [CommRing A] [Algebra R A] [Algebra.FiniteType R A]
attribute [local instance] IsArtinianRing.fieldOfSubtypeIsMaximal in
lemma Module.finite_of_isSemisimpleRing [IsJacobsonRing R] [IsSemisimpleRing A] :
Module.Finite R A :=
(Finite.equiv_iff <|
(AlgEquiv.ofRingEquiv (f := IsArtinianRing.equivPi A) fun _ ↦ rfl).toLinearEquiv).mpr <|
have (I : MaximalSpectrum A) := finite_of_finite_type_of_isJacobsonRing R (A ⧸ I.asIdeal)
Finite.pi
/-- If `A` is a finite type algebra over `R`, then `A` is an Artinian ring and `R` is Jacobson
implies `A` is finite over `R`. -/
/- If made an instance, causes timeouts synthesizing `FaithfulSMul R I.ResidueField` at
`Ideal.algebraMap_residueField_eq_zero` and `Ideal.ker_algebraMap_residueField` during
simpNF linting. -/
lemma Module.finite_of_isArtinianRing [IsJacobsonRing R] [IsArtinianRing A] :
Module.Finite R A :=
have := finite_of_isSemisimpleRing R (A ⧸ Ring.jacobson A)
IsSemiprimaryRing.finite_of_isArtinian R A A
/-- If `A` is a finite type algebra over an Artinian ring `R`,
then `A` is finite over `R` if and only if `A` is an Artinian ring. -/
lemma Module.finite_iff_isArtinianRing [IsArtinianRing R] :
Module.Finite R A ↔ IsArtinianRing A :=
⟨isArtinian_of_tower _ ∘ ((IsArtinianRing.tfae R A).out 0 2).mp,
fun _ ↦ finite_of_isArtinianRing R A⟩
/-- If `A` is a finite type algebra over an Artinian ring `R`,
then `A` is finite over `R` if and only if `dim A = 0`. -/
lemma Module.finite_iff_krullDimLE_zero [IsArtinianRing R] :
Module.Finite R A ↔ Ring.KrullDimLE 0 A := by
have : IsNoetherianRing A := Algebra.FiniteType.isNoetherianRing R A
rw [finite_iff_isArtinianRing, isArtinianRing_iff_isNoetherianRing_krullDimLE_zero,
and_iff_right this] |
.lake/packages/mathlib/Mathlib/RingTheory/Jacobson/Radical.lean | import Mathlib.LinearAlgebra.Quotient.Basic
import Mathlib.RingTheory.Finiteness.Basic
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Ideal.Quotient.Defs
/-!
# Jacobson radical of modules and rings
## Main definitions
`Module.jacobson R M`: the Jacobson radical of a module `M` over a ring `R` is defined to be the
intersection of all maximal submodules of `M`.
`Ring.jacobson R`: the Jacobson radical of a ring `R` is the Jacobson radical of `R` as
an `R`-module, which is equal to the intersection of all maximal left ideals of `R`. It turns out
it is in fact a two-sided ideal, and equals the intersection of all maximal right ideals of `R`.
## Reference
* [F. Lorenz, *Algebra: Volume II: Fields with Structure, Algebras and Advanced Topics*][Lorenz2008]
-/
assert_not_exists Cardinal
namespace Module
open Submodule
variable (R R₂ M M₂ : Type*) [Ring R] [Ring R₂]
variable [AddCommGroup M] [Module R M] [AddCommGroup M₂] [Module R₂ M₂]
variable {τ₁₂ : R →+* R₂} [RingHomSurjective τ₁₂]
variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F τ₁₂ M M₂] (f : F)
/-- The Jacobson radical of an `R`-module `M` is the infimum of all maximal submodules in `M`. -/
def jacobson : Submodule R M :=
sInf { m : Submodule R M | IsCoatom m }
variable {R R₂ M M₂}
theorem le_comap_jacobson : jacobson R M ≤ comap f (jacobson R₂ M₂) := by
conv_rhs => rw [jacobson, sInf_eq_iInf', comap_iInf]
refine le_iInf_iff.mpr fun S m hm ↦ ?_
obtain h | h := isCoatom_comap_or_eq_top f S.2
· exact mem_sInf.mp hm _ h
· simpa only [h] using mem_top
theorem map_jacobson_le : map f (jacobson R M) ≤ jacobson R₂ M₂ :=
map_le_iff_le_comap.mpr (le_comap_jacobson f)
include τ₁₂ in
theorem jacobson_eq_bot_of_injective (inj : Function.Injective f) (h : jacobson R₂ M₂ = ⊥) :
jacobson R M = ⊥ :=
le_bot_iff.mp <| (le_comap_jacobson f).trans <| by
simp_rw [h, comap_bot, ((LinearMapClass.ker_eq_bot _).mpr inj).le]
variable {f}
theorem map_jacobson_of_ker_le (surj : Function.Surjective f)
(le : LinearMap.ker f ≤ jacobson R M) :
map f (jacobson R M) = jacobson R₂ M₂ :=
le_antisymm (map_jacobson_le f) <| by
rw [jacobson, sInf_eq_iInf'] at le
conv_rhs => rw [jacobson, sInf_eq_iInf', map_iInf_of_ker_le surj le]
exact le_iInf fun m ↦ sInf_le (isCoatom_map_of_ker_le surj (le_iInf_iff.mp le m) m.2)
theorem comap_jacobson_of_ker_le (surj : Function.Surjective f)
(le : LinearMap.ker f ≤ jacobson R M) :
comap f (jacobson R₂ M₂) = jacobson R M := by
rw [← map_jacobson_of_ker_le surj le, comap_map_eq_self le]
theorem map_jacobson_of_bijective (hf : Function.Bijective f) :
map f (jacobson R M) = jacobson R₂ M₂ :=
map_jacobson_of_ker_le hf.2 <| by simp_rw [(LinearMapClass.ker_eq_bot _).mpr hf.1, bot_le]
theorem comap_jacobson_of_bijective (hf : Function.Bijective f) :
comap f (jacobson R₂ M₂) = jacobson R M :=
comap_jacobson_of_ker_le hf.2 <| by simp_rw [(LinearMapClass.ker_eq_bot _).mpr hf.1, bot_le]
theorem jacobson_quotient_of_le {N : Submodule R M} (le : N ≤ jacobson R M) :
jacobson R (M ⧸ N) = map N.mkQ (jacobson R M) :=
(map_jacobson_of_ker_le N.mkQ_surjective <| by rwa [ker_mkQ]).symm
theorem jacobson_le_of_eq_bot {N : Submodule R M} (h : jacobson R (M ⧸ N) = ⊥) :
jacobson R M ≤ N := by
simp_rw [← N.ker_mkQ, ← comap_bot, ← h, le_comap_jacobson]
variable (R M)
@[simp]
theorem jacobson_quotient_jacobson : jacobson R (M ⧸ jacobson R M) = ⊥ := by
rw [jacobson_quotient_of_le le_rfl, mkQ_map_self]
theorem jacobson_lt_top [Nontrivial M] [IsCoatomic (Submodule R M)] : jacobson R M < ⊤ := by
obtain ⟨m, hm, -⟩ := (eq_top_or_exists_le_coatom (⊥ : Submodule R M)).resolve_left bot_ne_top
exact (sInf_le <| Set.mem_setOf.mpr hm).trans_lt hm.1.lt_top
example [Nontrivial M] [Module.Finite R M] : jacobson R M < ⊤ := jacobson_lt_top R M
variable {ι} (M : ι → Type*) [∀ i, AddCommGroup (M i)] [∀ i, Module R (M i)]
theorem jacobson_pi_le : jacobson R (Π i, M i) ≤ Submodule.pi Set.univ (jacobson R <| M ·) := by
simp_rw [← iInf_comap_proj, jacobson, sInf_eq_iInf', comap_iInf, le_iInf_iff]
intro i m
exact iInf_le_of_le ⟨_, (isCoatom_comap_iff <| LinearMap.proj_surjective i).mpr m.2⟩ le_rfl
/-- A product of modules with trivial Jacobson radical (e.g. simple modules) also has trivial
Jacobson radical. -/
theorem jacobson_pi_eq_bot (h : ∀ i, jacobson R (M i) = ⊥) : jacobson R (Π i, M i) = ⊥ :=
le_bot_iff.mp <| (jacobson_pi_le R M).trans <| by simp_rw [h, pi_univ_bot, le_rfl]
end Module
section
variable (R R₂ : Type*) [Ring R] [Ring R₂] (f : R →+* R₂) [RingHomSurjective f]
variable (M : Type*) [AddCommGroup M] [Module R M]
namespace Ring
/-- The Jacobson radical of a ring `R` is the Jacobson radical of `R` as an `R`-module. -/
-- TODO: replace all `Ideal.jacobson ⊥` by this.
abbrev jacobson : Ideal R := Module.jacobson R R
theorem jacobson_eq_sInf_isMaximal : jacobson R = sInf {I : Ideal R | I.IsMaximal} := by
simp_rw [jacobson, Module.jacobson, Ideal.isMaximal_def]
instance : (jacobson R).IsTwoSided :=
⟨fun b ha ↦ Module.le_comap_jacobson (f := LinearMap.toSpanSingleton R R b) ha⟩
variable {R R₂}
theorem le_comap_jacobson : jacobson R ≤ Ideal.comap f (jacobson R₂) :=
Module.le_comap_jacobson f.toSemilinearMap
theorem map_jacobson_le : Submodule.map f.toSemilinearMap (jacobson R) ≤ jacobson R₂ :=
Module.map_jacobson_le f.toSemilinearMap
variable {f} in
theorem map_jacobson_of_ker_le (le : RingHom.ker f ≤ jacobson R) :
Submodule.map f.toSemilinearMap (jacobson R) = jacobson R₂ :=
Module.map_jacobson_of_ker_le f.surjective le
theorem coe_jacobson_quotient (I : Ideal R) [I.IsTwoSided] :
(jacobson (R ⧸ I) : Set (R ⧸ I)) = Module.jacobson R (R ⧸ I) := by
let f : R ⧸ I →ₛₗ[Ideal.Quotient.mk I] R ⧸ I := ⟨AddHom.id _, fun _ _ ↦ rfl⟩
rw [jacobson, ← Module.map_jacobson_of_ker_le (f := f) Function.surjective_id]
· apply Set.image_id
· rintro _ rfl; exact zero_mem _
theorem jacobson_quotient_of_le {I : Ideal R} [I.IsTwoSided] (le : I ≤ jacobson R) :
jacobson (R ⧸ I) = Submodule.map (Ideal.Quotient.mk I).toSemilinearMap (jacobson R) :=
.symm <| Module.map_jacobson_of_ker_le (by exact Ideal.Quotient.mk_surjective) <| by
rwa [← I.ker_mkQ] at le
theorem jacobson_le_of_eq_bot {I : Ideal R} [I.IsTwoSided] (h : jacobson (R ⧸ I) = ⊥) :
jacobson R ≤ I :=
Module.jacobson_le_of_eq_bot <| by
rw [← le_bot_iff, ← SetLike.coe_subset_coe] at h ⊢
rwa [← coe_jacobson_quotient]
variable (R)
@[simp]
theorem jacobson_quotient_jacobson : jacobson (R ⧸ jacobson R) = ⊥ :=
(jacobson_quotient_of_le le_rfl).trans <| SetLike.ext' <| by
apply SetLike.ext'_iff.mp (jacobson R).mkQ_map_self
theorem jacobson_lt_top [Nontrivial R] : jacobson R < ⊤ := Module.jacobson_lt_top R R
theorem jacobson_smul_top_le : jacobson R • (⊤ : Submodule R M) ≤ Module.jacobson R M :=
Submodule.smul_le.mpr fun _ hr m _ ↦ Module.le_comap_jacobson (LinearMap.toSpanSingleton R M m) hr
end Ring
namespace Submodule
variable {R M}
theorem jacobson_smul_lt_top [Nontrivial M] [IsCoatomic (Submodule R M)] (N : Submodule R M) :
Ring.jacobson R • N < ⊤ :=
((smul_mono_right _ le_top).trans <| Ring.jacobson_smul_top_le R M).trans_lt
(Module.jacobson_lt_top R M)
theorem FG.jacobson_smul_lt {N : Submodule R M} (ne_bot : N ≠ ⊥) (fg : N.FG) :
Ring.jacobson R • N < N := by
rw [← Module.Finite.iff_fg] at fg
rw [← nontrivial_iff_ne_bot] at ne_bot
convert map_strictMono_of_injective N.injective_subtype (jacobson_smul_lt_top ⊤)
on_goal 1 => rw [map_smul'']
all_goals rw [Submodule.map_top, range_subtype]
/-- A form of Nakayama's lemma for modules over noncommutative rings. -/
theorem FG.eq_bot_of_le_jacobson_smul {N : Submodule R M} (fg : N.FG)
(le : N ≤ Ring.jacobson R • N) : N = ⊥ := by
contrapose! le; exact (jacobson_smul_lt le fg).not_ge
end Submodule
end |
.lake/packages/mathlib/Mathlib/RingTheory/Bialgebra/GroupLike.lean | import Mathlib.RingTheory.Bialgebra.Basic
import Mathlib.RingTheory.Coalgebra.GroupLike
/-!
# Group-like elements in a bialgebra
This file proves that group-like elements in a bialgebra form a monoid.
-/
open Coalgebra Bialgebra
variable {R A : Type*}
section Semiring
variable [CommSemiring R] [Semiring A] [Bialgebra R A] {a b : A}
/-- In a bialgebra, `1` is a group-like element. -/
lemma IsGroupLikeElem.one : IsGroupLikeElem R (1 : A) where
counit_eq_one := counit_one
comul_eq_tmul_self := comul_one
/-- Group-like elements in a bialgebra are stable under multiplication. -/
lemma IsGroupLikeElem.mul (ha : IsGroupLikeElem R a) (hb : IsGroupLikeElem R b) :
IsGroupLikeElem R (a * b) where
counit_eq_one := by simp [ha, hb]
comul_eq_tmul_self := by simp [ha, hb]
variable (R A) in
/-- The group-like elements form a submonoid. -/
def groupLikeSubmonoid : Submonoid A where
carrier := {a | IsGroupLikeElem R a}
one_mem' := .one
mul_mem' := .mul
/-- Group-like elements in a bialgebra are stable under power. -/
lemma IsGroupLikeElem.pow {n : ℕ} (ha : IsGroupLikeElem R a) : IsGroupLikeElem R (a ^ n) :=
(groupLikeSubmonoid R A).pow_mem ha _
/-- Group-like elements in a bialgebra are stable under inverses, when they exist. -/
lemma IsGroupLikeElem.of_mul_eq_one (hab : a * b = 1) (hba : b * a = 1) (ha : IsGroupLikeElem R a) :
IsGroupLikeElem R b where
counit_eq_one :=
left_inv_eq_right_inv (a := counit a) (by simp [← counit_mul, hba]) (by simp [ha])
comul_eq_tmul_self := left_inv_eq_right_inv (a := comul a) (by simp [← comul_mul, hba])
(by simp [ha, hab, Algebra.TensorProduct.one_def])
/-- Group-like elements in a bialgebra are stable under inverses, when they exist. -/
lemma isGroupLikeElem_iff_of_mul_eq_one (hab : a * b = 1) (hba : b * a = 1) :
IsGroupLikeElem R a ↔ IsGroupLikeElem R b := ⟨.of_mul_eq_one hab hba, .of_mul_eq_one hba hab⟩
@[simp] lemma isGroupLikeElem_unitsInv {u : Aˣ} :
IsGroupLikeElem R u⁻¹.val ↔ IsGroupLikeElem R u.val :=
isGroupLikeElem_iff_of_mul_eq_one (by simp) (by simp)
alias ⟨IsGroupLikeElem.of_unitsInv, IsGroupLikeElem.unitsInv⟩ := isGroupLikeElem_unitsInv
namespace GroupLike
instance : One (GroupLike R A) where one := ⟨1, .one⟩
instance : Mul (GroupLike R A) where mul a b := ⟨a * b, a.2.mul b.2⟩
instance : Pow (GroupLike R A) ℕ where pow a n := ⟨a ^ n, a.2.pow⟩
@[simp] lemma val_one : (1 : GroupLike R A) = (1 : A) := rfl
@[simp] lemma val_mul (a b : GroupLike R A) : ↑(a * b) = (a * b : A) := rfl
@[simp] lemma val_pow (a : GroupLike R A) (n : ℕ) : ↑(a ^ n) = (a ^ n : A) := rfl
instance : Monoid (GroupLike R A) := val_injective.monoid val val_one val_mul val_pow
variable (R A) in
/-- `GroupLike.val` as a monoid hom. -/
@[simps] def valMonoidHom : GroupLike R A →* A where
toFun := val
map_one' := val_one
map_mul' := val_mul
end GroupLike
end Semiring
variable [CommSemiring R] [CommSemiring A] [Bialgebra R A] {a b : A}
instance GroupLike.instCommMonoid : CommMonoid (GroupLike R A) :=
val_injective.commMonoid val val_one val_mul val_pow |
.lake/packages/mathlib/Mathlib/RingTheory/Bialgebra/TensorProduct.lean | import Mathlib.RingTheory.Bialgebra.Equiv
import Mathlib.RingTheory.Coalgebra.TensorProduct
import Mathlib.RingTheory.TensorProduct.Basic
/-!
# Tensor products of bialgebras
We define the data in the monoidal structure on the category of bialgebras - e.g. the bialgebra
instance on a tensor product of bialgebras, and the tensor product of two `BialgHom`s as a
`BialgHom`. This is done by combining the corresponding API for coalgebras and algebras.
-/
open scoped TensorProduct
namespace Bialgebra.TensorProduct
open Coalgebra.TensorProduct
variable (R S A B C D : Type*) [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]
[Bialgebra S A] [Bialgebra R B] [Algebra R A] [Algebra R S] [IsScalarTower R S A]
lemma counit_eq_algHom_toLinearMap :
Coalgebra.counit (R := S) (A := A ⊗[R] B) =
((Algebra.TensorProduct.rid _ _ _).toAlgHom.comp (Algebra.TensorProduct.map
(Bialgebra.counitAlgHom S A) (Bialgebra.counitAlgHom R B))).toLinearMap :=
rfl
lemma comul_eq_algHom_toLinearMap :
Coalgebra.comul (R := S) (A := A ⊗[R] B) =
((Algebra.TensorProduct.tensorTensorTensorComm R S R S A A B B).toAlgHom.comp
(Algebra.TensorProduct.map (Bialgebra.comulAlgHom S A)
(Bialgebra.comulAlgHom R B))).toLinearMap :=
rfl
noncomputable instance _root_.TensorProduct.instBialgebra : Bialgebra S (A ⊗[R] B) := by
have hcounit := congr(DFunLike.coe $(counit_eq_algHom_toLinearMap R S A B))
have hcomul := congr(DFunLike.coe $(comul_eq_algHom_toLinearMap R S A B))
refine Bialgebra.mk' S (A ⊗[R] B) ?_ (fun {x y} => ?_) ?_ (fun {x y} => ?_) <;>
simp_all only [AlgHom.toLinearMap_apply] <;>
simp only [map_one, map_mul]
lemma counitAlgHom_def :
counitAlgHom (R := S) (A := A ⊗[R] B) =
(Algebra.TensorProduct.rid _ _ _).toAlgHom.comp (Algebra.TensorProduct.map
(Bialgebra.counitAlgHom S A) (Bialgebra.counitAlgHom R B)) := rfl
lemma comulAlgHom_def :
comulAlgHom (R := S) (A := A ⊗[R] B) =
(Algebra.TensorProduct.tensorTensorTensorComm R S R S A A B B).toAlgHom.comp
(Algebra.TensorProduct.map (Bialgebra.comulAlgHom S A)
(Bialgebra.comulAlgHom R B)) := rfl
variable {R S A B C D}
variable [Semiring C] [Semiring D] [Bialgebra S C]
[Bialgebra R D] [Algebra R C] [IsScalarTower R S C]
/-- The tensor product of two bialgebra morphisms as a bialgebra morphism. -/
noncomputable def map (f : A →ₐc[S] C) (g : B →ₐc[R] D) :
A ⊗[R] B →ₐc[S] C ⊗[R] D :=
{ Coalgebra.TensorProduct.map (f : A →ₗc[S] C) (g : B →ₗc[R] D),
Algebra.TensorProduct.map (f : A →ₐ[S] C) (g : B →ₐ[R] D) with }
@[simp]
theorem map_tmul (f : A →ₐc[S] C) (g : B →ₐc[R] D) (x : A) (y : B) :
map f g (x ⊗ₜ y) = f x ⊗ₜ g y :=
rfl
@[simp]
theorem map_toCoalgHom (f : A →ₐc[S] C) (g : B →ₐc[R] D) :
map f g = Coalgebra.TensorProduct.map (f : A →ₗc[S] C) (g : B →ₗc[R] D) := rfl
@[simp]
theorem map_toAlgHom (f : A →ₐc[S] C) (g : B →ₐc[R] D) :
(map f g : A ⊗[R] B →ₐ[S] C ⊗[R] D) =
Algebra.TensorProduct.map (f : A →ₐ[S] C) (g : B →ₐ[R] D) :=
rfl
variable (R S A C D) in
/-- The associator for tensor products of R-bialgebras, as a bialgebra equivalence. -/
protected noncomputable def assoc :
(A ⊗[S] C) ⊗[R] D ≃ₐc[S] A ⊗[S] (C ⊗[R] D) :=
{ Coalgebra.TensorProduct.assoc R S A C D, Algebra.TensorProduct.assoc R S A C D with }
@[simp]
theorem assoc_tmul (x : A) (y : C) (z : D) :
Bialgebra.TensorProduct.assoc R S A C D ((x ⊗ₜ y) ⊗ₜ z) = x ⊗ₜ (y ⊗ₜ z) :=
rfl
@[simp]
theorem assoc_symm_tmul (x : A) (y : C) (z : D) :
(Bialgebra.TensorProduct.assoc R S A C D).symm (x ⊗ₜ (y ⊗ₜ z)) = (x ⊗ₜ y) ⊗ₜ z :=
rfl
@[simp]
theorem assoc_toCoalgEquiv :
(Bialgebra.TensorProduct.assoc R S A C D : _ ≃ₗc[S] _) =
Coalgebra.TensorProduct.assoc R S A C D := rfl
@[simp]
theorem assoc_toAlgEquiv :
(Bialgebra.TensorProduct.assoc R S A C D : _ ≃ₐ[S] _) =
Algebra.TensorProduct.assoc R S A C D := rfl
variable (R B) in
/-- The base ring is a left identity for the tensor product of bialgebras, up to
bialgebra equivalence. -/
protected noncomputable def lid : R ⊗[R] B ≃ₐc[R] B :=
{ Coalgebra.TensorProduct.lid R B, Algebra.TensorProduct.lid R B with }
@[simp]
theorem lid_toCoalgEquiv :
(Bialgebra.TensorProduct.lid R B : R ⊗[R] B ≃ₗc[R] B) = Coalgebra.TensorProduct.lid R B := rfl
@[simp]
theorem lid_toAlgEquiv :
(Bialgebra.TensorProduct.lid R B : R ⊗[R] B ≃ₐ[R] B) = Algebra.TensorProduct.lid R B := rfl
@[simp]
theorem lid_tmul (r : R) (a : B) : Bialgebra.TensorProduct.lid R B (r ⊗ₜ a) = r • a := rfl
@[simp]
theorem lid_symm_apply (a : B) : (Bialgebra.TensorProduct.lid R B).symm a = 1 ⊗ₜ a := rfl
theorem coalgebra_rid_eq_algebra_rid_apply (x : A ⊗[R] R) :
Coalgebra.TensorProduct.rid R S A x = Algebra.TensorProduct.rid R R A x := rfl
variable (R S A) in
/-- The base ring is a right identity for the tensor product of bialgebras, up to
bialgebra equivalence. -/
protected noncomputable def rid : A ⊗[R] R ≃ₐc[S] A where
toCoalgEquiv := Coalgebra.TensorProduct.rid R S A
map_mul' x y := by
simp only [CoalgEquiv.toCoalgHom_eq_coe, CoalgHom.toLinearMap_eq_coe, AddHom.toFun_eq_coe,
LinearMap.coe_toAddHom, CoalgHom.coe_toLinearMap, CoalgHom.coe_coe,
coalgebra_rid_eq_algebra_rid_apply, map_mul]
@[simp]
theorem rid_toCoalgEquiv :
(TensorProduct.rid R S A : A ⊗[R] R ≃ₗc[S] A) = Coalgebra.TensorProduct.rid R S A := rfl
@[simp]
theorem rid_toAlgEquiv :
(Bialgebra.TensorProduct.rid R S A : A ⊗[R] R ≃ₐ[S] A) = Algebra.TensorProduct.rid R S A := by
ext x
exact coalgebra_rid_eq_algebra_rid_apply x
@[simp]
theorem rid_tmul (r : R) (a : A) : Bialgebra.TensorProduct.rid R S A (a ⊗ₜ r) = r • a := rfl
@[simp]
theorem rid_symm_apply (a : A) : (Bialgebra.TensorProduct.rid R S A).symm a = a ⊗ₜ 1 := rfl
end Bialgebra.TensorProduct
namespace BialgHom
variable {R A B C : Type*} [CommRing R] [Ring A] [Ring B] [Ring C]
[Bialgebra R A] [Bialgebra R B] [Bialgebra R C]
variable (A)
/-- `lTensor A f : A ⊗ B →ₐc A ⊗ C` is the natural bialgebra morphism induced by `f : B →ₐc C`. -/
noncomputable abbrev lTensor (f : B →ₐc[R] C) : A ⊗[R] B →ₐc[R] A ⊗[R] C :=
Bialgebra.TensorProduct.map (BialgHom.id R A) f
/-- `rTensor A f : B ⊗ A →ₐc C ⊗ A` is the natural bialgebra morphism induced by `f : B →ₐc C`. -/
noncomputable abbrev rTensor (f : B →ₐc[R] C) : B ⊗[R] A →ₐc[R] C ⊗[R] A :=
Bialgebra.TensorProduct.map f (BialgHom.id R A)
end BialgHom |
.lake/packages/mathlib/Mathlib/RingTheory/Bialgebra/Basic.lean | import Mathlib.RingTheory.Coalgebra.Basic
import Mathlib.RingTheory.TensorProduct.Maps
/-!
# Bialgebras
In this file we define `Bialgebra`s.
## Main definitions
* `Bialgebra R A`: the structure of a bialgebra on the `R`-algebra `A`;
* `CommSemiring.toBialgebra`: a commutative semiring is a bialgebra over itself.
## Implementation notes
Rather than the "obvious" axiom `∀ a b, counit (a * b) = counit a * counit b`, the far
more convoluted `mul_compr₂_counit` is used as a structure field; this says that
the corresponding two maps `A →ₗ[R] A →ₗ[R] R` are equal; a similar trick is
used for comultiplication as well. An alternative constructor `Bialgebra.mk'` is provided
with the more easily-readable axioms. The argument for using the more convoluted axioms
is that in practice there is evidence that they will be easier to prove (especially
when dealing with things like tensor products of bialgebras). This does make the definition
more surprising to mathematicians, however mathlib is no stranger to definitions which
are surprising to mathematicians -- see for example its definition of a group.
Note that this design decision is also compatible with that of `Coalgebra`. The lengthy
docstring for these convoluted fields attempts to explain what is going on.
The constructor `Bialgebra.ofAlgHom` is dual to the default constructor: For `R` is a commutative
semiring and `A` a `R`-algebra, it consumes the counit and comultiplication as algebra homomorphisms
that satisfy the coalgebra axioms to define a bialgebra structure on `A`.
## References
* <https://en.wikipedia.org/wiki/Bialgebra>
## Tags
bialgebra
-/
universe u v w
open Function
open scoped TensorProduct
/-- A bialgebra over a commutative (semi)ring `R` is both an algebra and a coalgebra over `R`, such
that the counit and comultiplication are algebra morphisms. -/
class Bialgebra (R : Type u) (A : Type v) [CommSemiring R] [Semiring A] extends
Algebra R A, Coalgebra R A where
-- The counit is an algebra morphism
/-- The counit on a bialgebra preserves 1. -/
counit_one : counit 1 = 1
/-- The counit on a bialgebra preserves multiplication. Note that this is written
in a rather obscure way: it says that two bilinear maps `A →ₗ[R] A →ₗ[R]` are equal.
The two corresponding equal linear maps `A ⊗[R] A →ₗ[R]`
are the following: the first factors through `A` and is multiplication on `A` followed
by `counit`. The second factors through `R ⊗[R] R`, and is `counit ⊗ counit` followed by
multiplication on `R`.
See `Bialgebra.mk'` for a constructor for bialgebras which uses
the more familiar but mathematically equivalent `counit (a * b) = counit a * counit b`. -/
mul_compr₂_counit : (LinearMap.mul R A).compr₂ counit = (LinearMap.mul R R).compl₁₂ counit counit
-- The comultiplication is an algebra morphism
/-- The comultiplication on a bialgebra preserves `1`. -/
comul_one : comul 1 = 1
/-- The comultiplication on a bialgebra preserves multiplication. This is written in
a rather obscure way: it says that two bilinear maps `A →ₗ[R] A →ₗ[R] (A ⊗[R] A)`
are equal. The corresponding equal linear maps `A ⊗[R] A →ₗ[R] A ⊗[R] A`
are firstly multiplication followed by `comul`, and secondly `comul ⊗ comul` followed
by multiplication on `A ⊗[R] A`.
See `Bialgebra.mk'` for a constructor for bialgebras which uses the more familiar
but mathematically equivalent `comul (a * b) = comul a * comul b`. -/
mul_compr₂_comul :
(LinearMap.mul R A).compr₂ comul = (LinearMap.mul R (A ⊗[R] A)).compl₁₂ comul comul
namespace Bialgebra
open Coalgebra
variable {R : Type u} {A : Type v}
variable [CommSemiring R] [Semiring A] [Bialgebra R A]
lemma counit_mul (a b : A) : counit (R := R) (a * b) = counit a * counit b :=
DFunLike.congr_fun (DFunLike.congr_fun mul_compr₂_counit a) b
lemma comul_mul (a b : A) : comul (R := R) (a * b) = comul a * comul b :=
DFunLike.congr_fun (DFunLike.congr_fun mul_compr₂_comul a) b
attribute [simp] counit_one comul_one counit_mul comul_mul
/-- If `R` is a field (or even a commutative semiring) and `A`
is an `R`-algebra with a coalgebra structure, then `Bialgebra.mk'`
consumes proofs that the counit and comultiplication preserve
the identity and multiplication, and produces a bialgebra
structure on `A`. -/
def mk' (R : Type u) (A : Type v) [CommSemiring R] [Semiring A]
[Algebra R A] [C : Coalgebra R A] (counit_one : C.counit 1 = 1)
(counit_mul : ∀ {a b}, C.counit (a * b) = C.counit a * C.counit b)
(comul_one : C.comul 1 = 1)
(comul_mul : ∀ {a b}, C.comul (a * b) = C.comul a * C.comul b) :
Bialgebra R A where
counit_one := counit_one
mul_compr₂_counit := by ext; exact counit_mul
comul_one := comul_one
mul_compr₂_comul := by ext; exact comul_mul
variable (R A)
/-- `counitAlgHom R A` is the counit of the `R`-bialgebra `A`, as an `R`-algebra map. -/
@[simps!]
def counitAlgHom : A →ₐ[R] R :=
.ofLinearMap counit counit_one counit_mul
/-- `comulAlgHom R A` is the comultiplication of the `R`-bialgebra `A`, as an `R`-algebra map. -/
@[simps!]
def comulAlgHom : A →ₐ[R] A ⊗[R] A :=
.ofLinearMap comul comul_one comul_mul
variable {R A}
@[simp] lemma toLinearMap_counitAlgHom : (counitAlgHom R A).toLinearMap = counit := rfl
@[simp] lemma toLinearMap_comulAlgHom : (comulAlgHom R A).toLinearMap = comul := rfl
@[simp] lemma counit_algebraMap (r : R) : counit (R := R) (algebraMap R A r) = r :=
(counitAlgHom R A).commutes r
@[simp] lemma comul_algebraMap (r : R) :
comul (R := R) (algebraMap R A r) = algebraMap R (A ⊗[R] A) r :=
(comulAlgHom R A).commutes r
@[simp] lemma counit_natCast (n : ℕ) : counit (R := R) (n : A) = n :=
map_natCast (counitAlgHom R A) _
@[simp] lemma comul_natCast (n : ℕ) : comul (R := R) (n : A) = n :=
map_natCast (comulAlgHom R A) _
@[simp] lemma counit_pow (a : A) (n : ℕ) : counit (R := R) (a ^ n) = counit a ^ n :=
map_pow (counitAlgHom R A) a n
@[simp] lemma comul_pow (a : A) (n : ℕ) : comul (R := R) (a ^ n) = comul a ^ n :=
map_pow (comulAlgHom R A) a n
end Bialgebra
namespace CommSemiring
variable (R : Type u) [CommSemiring R]
open Bialgebra
/-- Every commutative (semi)ring is a bialgebra over itself -/
instance toBialgebra : Bialgebra R R where
mul_compr₂_counit := by ext; simp
counit_one := rfl
mul_compr₂_comul := by ext; simp
comul_one := rfl
end CommSemiring
namespace Bialgebra
variable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]
@[simp] lemma counitAlgHom_self : counitAlgHom R R = .id R R := rfl
/-- If `R` is a commutative semiring and `A` is an `R`-algebra,
then `Bialgebra.ofAlgHom` consumes the counit and comultiplication
as algebra homomorphisms that satisfy the coalgebra axioms to define
a bialgebra structure on `A`. -/
abbrev ofAlgHom (comul : A →ₐ[R] (A ⊗[R] A)) (counit : A →ₐ[R] R)
(h_coassoc : (Algebra.TensorProduct.assoc R R A A A).toAlgHom.comp
((Algebra.TensorProduct.map comul (.id R A)).comp comul)
= (Algebra.TensorProduct.map (.id R A) comul).comp comul)
(h_rTensor : (Algebra.TensorProduct.map counit (.id R A)).comp comul
= (Algebra.TensorProduct.lid R A).symm)
(h_lTensor : (Algebra.TensorProduct.map (.id R A) counit).comp comul
= (Algebra.TensorProduct.rid R R A).symm) :
Bialgebra R A :=
letI : Coalgebra R A := {
comul := comul
counit := counit
coassoc := congr(($h_coassoc).toLinearMap)
rTensor_counit_comp_comul := congr(($h_rTensor).toLinearMap)
lTensor_counit_comp_comul := congr(($h_lTensor).toLinearMap)
}
.mk' _ _ (map_one counit) (map_mul counit _ _) (map_one comul) (map_mul comul _ _)
end Bialgebra
namespace Bialgebra
variable {R A : Type*} [CommSemiring R] [Semiring A] [Bialgebra R A]
variable (A) in
lemma algebraMap_injective : Injective (algebraMap R A) := RightInverse.injective counit_algebraMap
lemma counit_surjective : Surjective (Coalgebra.counit : A →ₗ[R] R) :=
RightInverse.surjective counit_algebraMap
include R in
variable (R) in
/-- A bialgebra over a nontrivial ring is nontrivial. -/
lemma nontrivial [Nontrivial R] : Nontrivial A := (algebraMap_injective (R := R) _).nontrivial
end Bialgebra |
.lake/packages/mathlib/Mathlib/RingTheory/Bialgebra/MonoidAlgebra.lean | import Mathlib.RingTheory.Bialgebra.Hom
import Mathlib.RingTheory.Coalgebra.MonoidAlgebra
/-!
# The bialgebra structure on monoid algebras
Given a monoid `M`, a commutative semiring `R` and an `R`-bialgebra `A`, this file collects results
about the `R`-bialgebra instance on `A[M]` inherited from the corresponding structure on its
coefficients, building upon results in `Mathlib/RingTheory/Coalgebra/MonoidAlgebra.lean` about the
coalgebra structure.
## Main definitions
* `(Add)MonoidAlgebra.instBialgebra`: the `R`-bialgebra structure on `A[M]` when `M` is an (add)
monoid and `A` is an `R`-bialgebra.
* `LaurentPolynomial.instBialgebra`: the `R`-bialgebra structure on the Laurent polynomials
`A[T;T⁻¹]` when `A` is an `R`-bialgebra.
-/
noncomputable section
open Bialgebra
variable {R A M N O : Type*}
namespace MonoidAlgebra
variable [CommSemiring R] [Semiring A] [Bialgebra R A] [Monoid M] [Monoid N] [Monoid O]
variable (R A M) in
instance instBialgebra : Bialgebra R (MonoidAlgebra A M) where
counit_one := by simp only [one_def, counit_single, Bialgebra.counit_one]
mul_compr₂_counit := by ext; simp
comul_one := by
simp only [one_def, comul_single, Bialgebra.comul_one, Algebra.TensorProduct.one_def,
TensorProduct.map_tmul, lsingle_apply]
mul_compr₂_comul := by
ext a b c d
simp only [Function.comp_apply, LinearMap.coe_comp, LinearMap.compr₂_apply,
LinearMap.mul_apply', single_mul_single, comul_single, Bialgebra.comul_mul,
← (Coalgebra.Repr.arbitrary R b).eq, ← (Coalgebra.Repr.arbitrary R d).eq, Finset.sum_mul_sum,
Algebra.TensorProduct.tmul_mul_tmul, map_sum, TensorProduct.map_tmul, lsingle_apply,
LinearMap.compl₁₂_apply, LinearMap.coeFn_sum, Finset.sum_apply,
Finset.sum_comm (s := (Coalgebra.Repr.arbitrary R b).index)]
-- TODO: Generalise to `MonoidAlgebra A M →ₐc[R] MonoidAlgebra A N` under `Bialgebra R A`
variable (R) in
/-- If `f : M → N` is a monoid hom, then `MonoidAlgebra.mapDomain f` is a bialgebra hom between
their monoid algebras. -/
@[simps!]
noncomputable def mapDomainBialgHom (f : M →* N) : MonoidAlgebra R M →ₐc[R] MonoidAlgebra R N :=
.ofAlgHom (mapDomainAlgHom R R f) (by ext; simp) (by ext; simp)
@[simp] lemma mapDomainBialgHom_id : mapDomainBialgHom R (.id M) = .id _ _ := by ext; simp
@[simp]
lemma mapDomainBialgHom_comp (f : N →* O) (g : M →* N) :
mapDomainBialgHom R (f.comp g) = (mapDomainBialgHom R f).comp (mapDomainBialgHom R g) := by
ext; simp [Finsupp.mapDomain_comp]
lemma mapDomainBialgHom_mapDomainBialgHom (f : N →* O) (g : M →* N) (x : MonoidAlgebra R M) :
mapDomainBialgHom R f (mapDomainBialgHom R g x) = mapDomainBialgHom R (f.comp g) x := by
ext; simp
end MonoidAlgebra
namespace AddMonoidAlgebra
variable [CommSemiring R] [Semiring A] [Bialgebra R A] [AddMonoid M] [AddMonoid N] [AddMonoid O]
variable (R A M) in
instance instBialgebra : Bialgebra R A[M] where
counit_one := by simp only [one_def, counit_single, Bialgebra.counit_one]
mul_compr₂_counit := by ext; simp [single_mul_single]
comul_one := by
simp only [one_def, comul_single, Bialgebra.comul_one, Algebra.TensorProduct.one_def,
TensorProduct.map_tmul, lsingle_apply]
mul_compr₂_comul := by
ext a b c d
simp only [Function.comp_apply, LinearMap.coe_comp, LinearMap.compr₂_apply,
LinearMap.mul_apply', single_mul_single, comul_single, Bialgebra.comul_mul,
← (Coalgebra.Repr.arbitrary R b).eq, ← (Coalgebra.Repr.arbitrary R d).eq, Finset.sum_mul_sum,
Algebra.TensorProduct.tmul_mul_tmul, map_sum, TensorProduct.map_tmul, lsingle_apply,
LinearMap.compl₁₂_apply, LinearMap.coeFn_sum, Finset.sum_apply,
Finset.sum_comm (s := (Coalgebra.Repr.arbitrary R b).index)]
-- TODO: Generalise to `A[M] →ₐc[R] A[N]` under `Bialgebra R A`
variable (R) in
/-- If `f : M → N` is a monoid hom, then `AddMonoidAlgebra.mapDomain f` is a bialgebra hom between
their monoid algebras. -/
@[simps]
noncomputable def mapDomainBialgHom (f : M →+ N) : R[M] →ₐc[R] R[N] where
__ := mapDomainAlgHom R R f
map_smul' m x := by simp
counit_comp := by ext; simp
map_comp_comul := by ext; simp
@[simp] lemma mapDomainBialgHom_id : mapDomainBialgHom R (.id M) = .id _ _ := by ext; simp
@[simp]
lemma mapDomainBialgHom_comp (f : N →+ O) (g : M →+ N) :
mapDomainBialgHom R (f.comp g) = (mapDomainBialgHom R f).comp (mapDomainBialgHom R g) := by
ext; simp
lemma mapDomainBialgHom_mapDomainBialgHom (f : N →+ O) (g : M →+ N) (x : R[M]) :
mapDomainBialgHom R f (mapDomainBialgHom R g x) = mapDomainBialgHom R (f.comp g) x := by
ext; simp
end AddMonoidAlgebra
namespace LaurentPolynomial
open AddMonoidAlgebra
variable {R : Type*} [CommSemiring R] {A : Type*} [Semiring A] [Bialgebra R A]
instance instBialgebra : Bialgebra R A[T;T⁻¹] :=
inferInstanceAs <| Bialgebra R A[ℤ]
@[simp]
theorem comul_T (n : ℤ) :
Coalgebra.comul (R := R) (T n : A[T;T⁻¹]) = T n ⊗ₜ[R] T n := by
simp [T, -single_eq_C_mul_T, Algebra.TensorProduct.one_def]
@[simp]
theorem counit_T (n : ℤ) :
Coalgebra.counit (R := R) (T n : A[T;T⁻¹]) = 1 := by
simp [T, -single_eq_C_mul_T]
end LaurentPolynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Bialgebra/Equiv.lean | import Mathlib.RingTheory.Coalgebra.Equiv
import Mathlib.RingTheory.Bialgebra.Hom
/-!
# Isomorphisms of `R`-bialgebras
This file defines bundled isomorphisms of `R`-bialgebras. We simply mimic the early parts of
`Mathlib/Algebra/Algebra/Equiv.lean`.
## Main definitions
* `BialgEquiv R A B`: the type of `R`-bialgebra isomorphisms between `A` and `B`.
## Notation
* `A ≃ₐc[R] B` : `R`-bialgebra equivalence from `A` to `B`.
-/
universe u v w u₁
variable {R : Type u} {A : Type v} {B : Type w} {C : Type u₁}
open TensorProduct Coalgebra Bialgebra Function
/-- An equivalence of bialgebras is an invertible bialgebra homomorphism. -/
structure BialgEquiv (R : Type u) [CommSemiring R] (A : Type v) (B : Type w)
[Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
[CoalgebraStruct R A] [CoalgebraStruct R B] extends A ≃ₗc[R] B, A ≃* B where
attribute [nolint docBlame] BialgEquiv.toMulEquiv
attribute [nolint docBlame] BialgEquiv.toCoalgEquiv
@[inherit_doc BialgEquiv]
notation:50 A " ≃ₐc[" R "] " B => BialgEquiv R A B
/-- `BialgEquivClass F R A B` asserts `F` is a type of bundled bialgebra equivalences
from `A` to `B`. -/
class BialgEquivClass (F : Type*) (R A B : outParam Type*) [CommSemiring R]
[Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
[CoalgebraStruct R A] [CoalgebraStruct R B] [EquivLike F A B] : Prop
extends CoalgEquivClass F R A B, MulEquivClass F A B
namespace BialgEquivClass
variable {F R A B : Type*} [CommSemiring R] [Semiring A] [Semiring B]
[Algebra R A] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B]
[EquivLike F A B] [BialgEquivClass F R A B]
instance (priority := 100) toBialgHomClass : BialgHomClass F R A B where
map_add := map_add
map_smulₛₗ := map_smul
counit_comp := CoalgHomClass.counit_comp
map_comp_comul := CoalgHomClass.map_comp_comul
map_mul := map_mul
map_one := map_one
/-- Reinterpret an element of a type of bialgebra equivalences as a bialgebra equivalence. -/
@[coe]
def toBialgEquiv (f : F) : A ≃ₐc[R] B :=
{ (f : A ≃ₗc[R] B), (f : A →ₐc[R] B) with }
/-- Reinterpret an element of a type of bialgebra equivalences as a bialgebra equivalence. -/
instance instCoeToBialgEquiv : CoeHead F (A ≃ₐc[R] B) where
coe f := toBialgEquiv f
instance (priority := 100) toAlgEquivClass : AlgEquivClass F R A B where
map_mul := map_mul
map_add := map_add
commutes := AlgHomClass.commutes
end BialgEquivClass
namespace BialgEquiv
variable [CommSemiring R]
section
variable [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
[CoalgebraStruct R A] [CoalgebraStruct R B]
/-- The bialgebra morphism underlying a bialgebra equivalence. -/
def toBialgHom (f : A ≃ₐc[R] B) : A →ₐc[R] B :=
{ f.toCoalgEquiv with
map_one' := map_one f.toMulEquiv
map_mul' := map_mul f.toMulEquiv }
/-- The algebra equivalence underlying a bialgebra equivalence. -/
def toAlgEquiv (f : A ≃ₐc[R] B) : A ≃ₐ[R] B :=
{ f.toCoalgEquiv with
map_mul' := map_mul f.toMulEquiv
map_add' := map_add f.toCoalgEquiv
commutes' := AlgHomClass.commutes f.toBialgHom }
/-- The equivalence of types underlying a bialgebra equivalence. -/
def toEquiv : (A ≃ₐc[R] B) → A ≃ B := fun f => f.toCoalgEquiv.toEquiv
theorem toEquiv_injective : Function.Injective (toEquiv : (A ≃ₐc[R] B) → A ≃ B) :=
fun ⟨_, _⟩ ⟨_, _⟩ h =>
(BialgEquiv.mk.injEq _ _ _ _).mpr (CoalgEquiv.toEquiv_injective h)
@[simp]
theorem toEquiv_inj {e₁ e₂ : A ≃ₐc[R] B} : e₁.toEquiv = e₂.toEquiv ↔ e₁ = e₂ :=
toEquiv_injective.eq_iff
theorem toBialgHom_injective : Function.Injective (toBialgHom : (A ≃ₐc[R] B) → A →ₐc[R] B) :=
fun _ _ H => toEquiv_injective <| Equiv.ext <| BialgHom.congr_fun H
instance : EquivLike (A ≃ₐc[R] B) A B where
coe f := f.toFun
inv := fun f => f.invFun
coe_injective' _ _ h _ := toBialgHom_injective (DFunLike.coe_injective h)
left_inv := fun f => f.left_inv
right_inv := fun f => f.right_inv
instance : FunLike (A ≃ₐc[R] B) A B where
coe := DFunLike.coe
coe_injective' := DFunLike.coe_injective
instance : BialgEquivClass (A ≃ₐc[R] B) R A B where
map_add := (·.map_add')
map_smulₛₗ := (·.map_smul')
counit_comp := (·.counit_comp)
map_comp_comul := (·.map_comp_comul)
map_mul := (·.map_mul')
@[simp, norm_cast]
theorem toBialgHom_inj {e₁ e₂ : A ≃ₐc[R] B} : (↑e₁ : A →ₐc[R] B) = e₂ ↔ e₁ = e₂ :=
toBialgHom_injective.eq_iff
@[simp] lemma coe_mk (e : A ≃ₗc[R] B) (h) : mk e h = e := rfl
end
section
variable [Semiring A] [Semiring B] [Semiring C] [Algebra R A] [Algebra R B]
[Algebra R C] [CoalgebraStruct R A] [CoalgebraStruct R B] [CoalgebraStruct R C]
variable (e e' : A ≃ₐc[R] B)
@[simp, norm_cast]
theorem coe_coe : ⇑(e : A →ₐc[R] B) = e :=
rfl
@[simp]
theorem toCoalgEquiv_eq_coe (f : A ≃ₐc[R] B) : f.toCoalgEquiv = f :=
rfl
@[simp]
theorem toBialgHom_eq_coe (f : A ≃ₐc[R] B) : f.toBialgHom = f :=
rfl
@[simp]
theorem toAlgEquiv_eq_coe (f : A ≃ₐc[R] B) : f.toAlgEquiv = f :=
rfl
@[simp]
theorem coe_toCoalgEquiv : ⇑(e : A ≃ₐ[R] B) = e :=
rfl
@[simp]
theorem coe_toBialgHom : ⇑(e : A →ₐc[R] B) = e :=
rfl
@[simp]
theorem coe_toAlgEquiv : ⇑(e : A ≃ₐ[R] B) = e :=
rfl
theorem toCoalgEquiv_toCoalgHom : ((e : A ≃ₐc[R] B) : A →ₗc[R] B) = (e : A →ₐc[R] B) :=
rfl
theorem toBialgHom_toAlgHom : ((e : A →ₐc[R] B) : A →ₐ[R] B) = e := rfl
section
variable {e e'}
@[ext]
theorem ext (h : ∀ x, e x = e' x) : e = e' :=
DFunLike.ext _ _ h
protected theorem congr_arg {x x'} : x = x' → e x = e x' :=
DFunLike.congr_arg e
protected theorem congr_fun (h : e = e') (x : A) : e x = e' x :=
DFunLike.congr_fun h x
end
/-- See Note [custom simps projection] -/
def Simps.apply {R : Type u} [CommSemiring R] {α : Type v} {β : Type w}
[Semiring α] [Semiring β] [Algebra R α]
[Algebra R β] [CoalgebraStruct R α] [CoalgebraStruct R β]
(f : α ≃ₐc[R] β) : α → β := f
/-- See Note [custom simps projection] -/
def Simps.symm_apply {R : Type*} [CommSemiring R]
{A : Type*} {B : Type*} [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]
[CoalgebraStruct R A] [CoalgebraStruct R B]
(e : A ≃ₐc[R] B) : B → A :=
e.symm
initialize_simps_projections BialgEquiv (toFun → apply, invFun → symm_apply)
variable (A R) in
/-- The identity map is a bialgebra equivalence. -/
@[refl, simps!]
def refl : A ≃ₐc[R] A :=
{ CoalgEquiv.refl R A, BialgHom.id R A with }
@[simp]
theorem refl_toCoalgEquiv : refl R A = CoalgEquiv.refl R A := rfl
@[simp]
theorem refl_toBialgHom : refl R A = BialgHom.id R A :=
rfl
/-- Bialgebra equivalences are symmetric. -/
@[symm]
def symm (e : A ≃ₐc[R] B) : B ≃ₐc[R] A :=
{ (e : A ≃ₗc[R] B).symm, (e : A ≃* B).symm with }
@[simp]
theorem symm_toCoalgEquiv (e : A ≃ₐc[R] B) :
e.symm = (e : A ≃ₗc[R] B).symm := rfl
theorem invFun_eq_symm : e.invFun = e.symm :=
rfl
theorem coe_toEquiv_symm : e.toEquiv.symm = e.symm := rfl
@[simp]
theorem toEquiv_symm : e.symm.toEquiv = e.toEquiv.symm :=
rfl
@[simp]
theorem coe_toEquiv : ⇑e.toEquiv = e :=
rfl
@[simp]
theorem coe_symm_toEquiv : ⇑e.toEquiv.symm = e.symm :=
rfl
variable {e₁₂ : A ≃ₐc[R] B} {e₂₃ : B ≃ₐc[R] C}
/-- Bialgebra equivalences are transitive. -/
@[trans, simps!]
def trans (e₁₂ : A ≃ₐc[R] B) (e₂₃ : B ≃ₐc[R] C) : A ≃ₐc[R] C :=
{ (e₁₂ : A ≃ₗc[R] B).trans (e₂₃ : B ≃ₗc[R] C), (e₁₂ : A ≃* B).trans (e₂₃ : B ≃* C) with }
@[simp]
theorem trans_toCoalgEquiv :
(e₁₂.trans e₂₃ : A ≃ₗc[R] C) = (e₁₂ : A ≃ₗc[R] B).trans (e₂₃ : B ≃ₗc[R] C) := rfl
@[simp]
theorem trans_toBialgHom :
(e₁₂.trans e₂₃ : A →ₐc[R] C) = (e₂₃ : B →ₐc[R] C).comp e₁₂ := rfl
@[simp]
theorem coe_toEquiv_trans : (e₁₂ : A ≃ B).trans e₂₃ = (e₁₂.trans e₂₃ : A ≃ C) :=
rfl
@[simp]
lemma apply_symm_apply (e : A ≃ₐc[R] B) : ∀ x, e (e.symm x) = x := e.toEquiv.apply_symm_apply
@[simp]
lemma symm_apply_apply (e : A ≃ₐc[R] B) : ∀ x, e.symm (e x) = x := e.toEquiv.symm_apply_apply
@[simp] lemma comp_symm (e : A ≃ₐc[R] B) : (e : A →ₐc[R] B).comp e.symm = .id R B :=
BialgHom.coe_algHom_injective e.toAlgEquiv.comp_symm
@[simp] lemma symm_comp (e : A ≃ₐc[R] B) : (e.symm : B →ₐc[R] A).comp e = .id R A :=
BialgHom.coe_algHom_injective e.toAlgEquiv.symm_comp
@[simp] lemma toRingEquiv_toRingHom (e : A ≃ₐc[R] B) : ((e : A ≃+* B) : A →+* B) = e := rfl
@[simp] lemma toAlgEquiv_toRingHom (e : A ≃ₐc[R] B) : ((e : A ≃ₐ[R] B) : A →+* B) = e := rfl
/-- If an coalgebra morphism has an inverse, it is an coalgebra isomorphism. -/
def ofBialgHom (f : A →ₐc[R] B) (g : B →ₐc[R] A) (h₁ : f.comp g = BialgHom.id R B)
(h₂ : g.comp f = BialgHom.id R A) : A ≃ₐc[R] B where
__ := f
toFun := f
invFun := g
left_inv := BialgHom.ext_iff.1 h₂
right_inv := BialgHom.ext_iff.1 h₁
@[simp]
theorem coe_ofBialgHom (f : A →ₐc[R] B) (g : B →ₐc[R] A) (h₁ h₂) :
ofBialgHom f g h₁ h₂ = f :=
rfl
theorem ofBialgHom_symm (f : A →ₐc[R] B) (g : B →ₐc[R] A) (h₁ h₂) :
(ofBialgHom f g h₁ h₂).symm = ofBialgHom g f h₂ h₁ :=
rfl
end
variable [Semiring A] [Semiring B] [Bialgebra R A] [Bialgebra R B]
/-- Construct a bialgebra equiv from an algebra equiv respecting counit and comultiplication. -/
@[simps apply] def ofAlgEquiv (f : A ≃ₐ[R] B)
(counit_comp : (Bialgebra.counitAlgHom R B).comp f = Bialgebra.counitAlgHom R A)
(map_comp_comul : (Algebra.TensorProduct.map f f).comp (Bialgebra.comulAlgHom R A) =
(Bialgebra.comulAlgHom R B).comp f) : A ≃ₐc[R] B where
__ := f
map_smul' := map_smul f
counit_comp := congr($(counit_comp).toLinearMap)
map_comp_comul := congr($(map_comp_comul).toLinearMap)
@[simp]
lemma toLinearMap_ofAlgEquiv (f : A ≃ₐ[R] B) (counit_comp map_comp_comul) :
(ofAlgEquiv f counit_comp map_comp_comul : A →ₗ[R] B) = f := rfl
/-- Promotes a bijective bialgebra homomorphism to a bialgebra equivalence. -/
@[simps! apply]
noncomputable def ofBijective (f : A →ₐc[R] B) (hf : Bijective f) : A ≃ₐc[R] B :=
.ofAlgEquiv (.ofBijective (f : A →ₐ[R] B) hf) (by ext; simp) (by ext; simp)
@[simp]
lemma coe_ofBijective (f : A →ₐc[R] B) (hf : Bijective f) : (ofBijective f hf : A → B) = f := rfl
end BialgEquiv |
.lake/packages/mathlib/Mathlib/RingTheory/Bialgebra/Hom.lean | import Mathlib.RingTheory.Coalgebra.Hom
import Mathlib.RingTheory.Bialgebra.Basic
/-!
# Homomorphisms of `R`-bialgebras
This file defines bundled homomorphisms of `R`-bialgebras. We simply mimic
`Mathlib/Algebra/Algebra/Hom.lean`.
## Main definitions
* `BialgHom R A B`: the type of `R`-bialgebra morphisms from `A` to `B`.
* `Bialgebra.counitBialgHom R A : A →ₐc[R] R`: the counit of a bialgebra as a bialgebra
homomorphism.
## Notation
* `A →ₐc[R] B` : `R`-bialgebra homomorphism from `A` to `B`.
-/
open TensorProduct Bialgebra Coalgebra Function
universe u v w
/-- Given `R`-algebras `A, B` with comultiplication maps `Δ_A, Δ_B` and counit maps
`ε_A, ε_B`, an `R`-bialgebra homomorphism `A →ₐc[R] B` is an `R`-algebra map `f` such that
`ε_B ∘ f = ε_A` and `(f ⊗ f) ∘ Δ_A = Δ_B ∘ f`. -/
structure BialgHom (R A B : Type*) [CommSemiring R]
[Semiring A] [Algebra R A] [Semiring B] [Algebra R B]
[CoalgebraStruct R A] [CoalgebraStruct R B] extends A →ₗc[R] B, A →* B
/-- Reinterpret a `BialgHom` as a `MonoidHom` -/
add_decl_doc BialgHom.toMonoidHom
@[inherit_doc BialgHom]
infixr:25 " →ₐc " => BialgHom _
@[inherit_doc]
notation:25 A " →ₐc[" R "] " B => BialgHom R A B
/-- `BialgHomClass F R A B` asserts `F` is a type of bundled bialgebra homomorphisms
from `A` to `B`. -/
class BialgHomClass (F : Type*) (R A B : outParam Type*)
[CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B]
[CoalgebraStruct R A] [CoalgebraStruct R B] [FunLike F A B] : Prop
extends CoalgHomClass F R A B, MonoidHomClass F A B
namespace BialgHomClass
variable {R A B F : Type*}
section
variable [CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B]
[CoalgebraStruct R A] [CoalgebraStruct R B] [FunLike F A B]
[BialgHomClass F R A B]
instance (priority := 100) toAlgHomClass : AlgHomClass F R A B where
map_mul := map_mul
map_one := map_one
map_add := map_add
map_zero := map_zero
commutes := fun c r => by
simp only [Algebra.algebraMap_eq_smul_one, map_smul, map_one]
/-- Turn an element of a type `F` satisfying `BialgHomClass F R A B` into an actual
`BialgHom`. This is declared as the default coercion from `F` to `A →ₐc[R] B`. -/
@[coe]
def toBialgHom (f : F) : A →ₐc[R] B :=
{ CoalgHomClass.toCoalgHom f, AlgHomClass.toAlgHom f with
toFun := f }
instance instCoeToBialgHom :
CoeHead F (A →ₐc[R] B) :=
⟨BialgHomClass.toBialgHom⟩
end
section
variable [CommSemiring R] [Semiring A] [Bialgebra R A] [Semiring B] [Bialgebra R B]
[FunLike F A B] [BialgHomClass F R A B]
@[simp]
theorem counitAlgHom_comp (f : F) :
(counitAlgHom R B).comp (f : A →ₐ[R] B) = counitAlgHom R A :=
AlgHom.toLinearMap_injective (CoalgHomClass.counit_comp f)
@[simp]
theorem map_comp_comulAlgHom (f : F) :
(Algebra.TensorProduct.map f f).comp (comulAlgHom R A) = (comulAlgHom R B).comp f :=
AlgHom.toLinearMap_injective (CoalgHomClass.map_comp_comul f)
end
end BialgHomClass
namespace BialgHom
variable {R A B C D : Type*} [CommSemiring R] [Semiring A] [Semiring B] [Semiring C] [Semiring D]
section AlgebraCoalgebra
variable [Algebra R A] [Algebra R B] [Algebra R C] [Algebra R D]
[CoalgebraStruct R A] [CoalgebraStruct R B] [CoalgebraStruct R C] [CoalgebraStruct R D]
instance funLike : FunLike (A →ₐc[R] B) A B where
coe f := f.toFun
coe_injective' f g h := by
rcases f with ⟨_, _⟩
rcases g with ⟨_, _⟩
simp_all
instance bialgHomClass : BialgHomClass (A →ₐc[R] B) R A B where
map_add := fun f => f.map_add'
map_smulₛₗ := fun f => f.map_smul'
counit_comp := fun f => f.counit_comp
map_comp_comul := fun f => f.map_comp_comul
map_mul := fun f => f.map_mul'
map_one := fun f => f.map_one'
/-- See Note [custom simps projection] -/
def Simps.apply {R α β : Type*} [CommSemiring R]
[Semiring α] [Algebra R α] [Semiring β]
[Algebra R β] [CoalgebraStruct R α] [CoalgebraStruct R β]
(f : α →ₐc[R] β) : α → β := f
initialize_simps_projections BialgHom (toFun → apply)
@[simp]
protected theorem coe_coe {F : Type*} [FunLike F A B] [BialgHomClass F R A B] (f : F) :
⇑(f : A →ₐc[R] B) = f :=
rfl
@[simp]
theorem coe_mk {f : A →ₗc[R] B} (h h₁) : ((⟨f, h, h₁⟩ : A →ₐc[R] B) : A → B) = f :=
rfl
@[norm_cast]
theorem coe_mks {f : A → B} (h₀ h₁ h₂ h₃ h₄ h₅) :
⇑(⟨⟨⟨⟨f, h₀⟩, h₁⟩, h₂, h₃⟩, h₄, h₅⟩ : A →ₐc[R] B) = f :=
rfl
@[simp, norm_cast]
theorem coe_coalgHom_mk {f : A →ₗc[R] B} (h h₁) :
((⟨f, h, h₁⟩ : A →ₐc[R] B) : A →ₗc[R] B) = f := by
rfl
@[simp, norm_cast]
theorem coe_toCoalgHom (f : A →ₐc[R] B) : ⇑(f : A →ₗc[R] B) = f :=
rfl
lemma toCoalgHom_apply (f : A →ₐc[R] B) (a : A) : f.toCoalgHom a = f a := rfl
@[simp, norm_cast]
theorem coe_toLinearMap (f : A →ₐc[R] B) : ⇑(f : A →ₗ[R] B) = f :=
rfl
@[norm_cast]
theorem coe_toAlgHom (f : A →ₐc[R] B) : ⇑(f : A →ₐ[R] B) = f :=
rfl
theorem toAlgHom_toLinearMap (f : A →ₐc[R] B) :
((f : A →ₐ[R] B) : A →ₗ[R] B) = f := by
rfl
variable (φ : A →ₐc[R] B)
theorem coe_fn_injective : @Function.Injective (A →ₐc[R] B) (A → B) (↑) :=
DFunLike.coe_injective
theorem coe_fn_inj {φ₁ φ₂ : A →ₐc[R] B} : (φ₁ : A → B) = φ₂ ↔ φ₁ = φ₂ :=
DFunLike.coe_fn_eq
theorem coe_coalgHom_injective : Function.Injective ((↑) : (A →ₐc[R] B) → A →ₗc[R] B) :=
fun φ₁ φ₂ H => coe_fn_injective <|
show ((φ₁ : A →ₗc[R] B) : A → B) = ((φ₂ : A →ₗc[R] B) : A → B) from congr_arg _ H
theorem coe_algHom_injective : Function.Injective ((↑) : (A →ₐc[R] B) → A →ₐ[R] B) :=
fun φ₁ φ₂ H => coe_fn_injective <|
show ((φ₁ : A →ₐ[R] B) : A → B) = ((φ₂ : A →ₐ[R] B) : A → B) from congr_arg _ H
theorem coe_linearMap_injective : Function.Injective ((↑) : (A →ₐc[R] B) → A →ₗ[R] B) :=
CoalgHom.coe_linearMap_injective.comp coe_coalgHom_injective
protected theorem congr_fun {φ₁ φ₂ : A →ₐc[R] B} (H : φ₁ = φ₂) (x : A) : φ₁ x = φ₂ x :=
DFunLike.congr_fun H x
protected theorem congr_arg (φ : A →ₐc[R] B) {x y : A} (h : x = y) : φ x = φ y :=
DFunLike.congr_arg φ h
@[ext]
theorem ext {φ₁ φ₂ : A →ₐc[R] B} (H : ∀ x, φ₁ x = φ₂ x) : φ₁ = φ₂ :=
DFunLike.ext _ _ H
@[ext high]
theorem ext_of_ring {f g : R →ₐc[R] A} (h : f 1 = g 1) : f = g :=
coe_linearMap_injective (by ext; assumption)
@[simp]
theorem mk_coe {f : A →ₐc[R] B} (h₀ h₁ h₂ h₃ h₄ h₅) :
(⟨⟨⟨⟨f, h₀⟩, h₁⟩, h₂, h₃⟩, h₄, h₅⟩ : A →ₐc[R] B) = f :=
rfl
/-- Copy of a `BialgHom` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : A →ₐc[R] B) (f' : A → B) (h : f' = ⇑f) : A →ₐc[R] B :=
{ toCoalgHom := (f : A →ₗc[R] B).copy f' h
map_one' := by simp_all
map_mul' := by intros; simp_all }
@[simp]
theorem coe_copy (f : A →ₗc[R] B) (f' : A → B) (h : f' = ⇑f) : ⇑(f.copy f' h) = f' :=
rfl
theorem copy_eq (f : A →ₗc[R] B) (f' : A → B) (h : f' = ⇑f) : f.copy f' h = f :=
DFunLike.ext' h
section
variable (R A)
/-- Identity map as a `BialgHom`. -/
@[simps!] protected def id : A →ₐc[R] A :=
{ CoalgHom.id R A, AlgHom.id R A with }
variable {R A}
@[simp, norm_cast]
theorem coe_id : ⇑(BialgHom.id R A) = id :=
rfl
@[simp]
theorem id_toCoalgHom : BialgHom.id R A = CoalgHom.id R A :=
rfl
@[simp]
theorem id_toAlgHom : BialgHom.id R A = AlgHom.id R A :=
rfl
end
/-- Composition of bialgebra homomorphisms. -/
@[simps!] def comp (φ₁ : B →ₐc[R] C) (φ₂ : A →ₐc[R] B) : A →ₐc[R] C :=
{ (φ₁ : B →ₗc[R] C).comp (φ₂ : A →ₗc[R] B), (φ₁ : B →ₐ[R] C).comp (φ₂ : A →ₐ[R] B) with }
@[simp]
theorem coe_comp (φ₁ : B →ₐc[R] C) (φ₂ : A →ₐc[R] B) : ⇑(φ₁.comp φ₂) = φ₁ ∘ φ₂ :=
rfl
@[simp]
theorem comp_toCoalgHom (φ₁ : B →ₐc[R] C) (φ₂ : A →ₐc[R] B) :
φ₁.comp φ₂ = (φ₁ : B →ₗc[R] C).comp (φ₂ : A →ₗc[R] B) :=
rfl
@[simp]
theorem comp_toAlgHom (φ₁ : B →ₐc[R] C) (φ₂ : A →ₐc[R] B) :
φ₁.comp φ₂ = (φ₁ : B →ₐ[R] C).comp (φ₂ : A →ₐ[R] B) :=
rfl
@[simp]
theorem comp_id : φ.comp (BialgHom.id R A) = φ :=
ext fun _x => rfl
@[simp]
theorem id_comp : (BialgHom.id R B).comp φ = φ :=
ext fun _x => rfl
theorem comp_assoc (φ₁ : C →ₐc[R] D) (φ₂ : B →ₐc[R] C) (φ₃ : A →ₐc[R] B) :
(φ₁.comp φ₂).comp φ₃ = φ₁.comp (φ₂.comp φ₃) :=
ext fun _x => rfl
theorem map_smul_of_tower {R'} [SMul R' A] [SMul R' B] [LinearMap.CompatibleSMul A B R' R] (r : R')
(x : A) : φ (r • x) = r • φ x :=
φ.toLinearMap.map_smul_of_tower r x
@[simps -isSimp toSemigroup_toMul_mul toOne_one]
instance End : Monoid (A →ₐc[R] A) where
mul := comp
mul_assoc _ _ _ := rfl
one := BialgHom.id R A
one_mul _ := ext fun _ => rfl
mul_one _ := ext fun _ => rfl
@[simp]
theorem one_apply (x : A) : (1 : A →ₐc[R] A) x = x :=
rfl
@[simp]
theorem mul_apply (φ ψ : A →ₐc[R] A) (x : A) : (φ * ψ) x = φ (ψ x) :=
rfl
end AlgebraCoalgebra
variable [Bialgebra R A] [Bialgebra R B]
/-- Construct a bialgebra hom from an algebra hom respecting counit and comultiplication. -/
@[simps!]
def ofAlgHom (f : A →ₐ[R] B) (counit_comp : (counitAlgHom R B).comp f = counitAlgHom R A)
(map_comp_comul :
(Algebra.TensorProduct.map f f).comp (comulAlgHom _ _) = (comulAlgHom _ _).comp f) :
A →ₐc[R] B where
__ := f
map_smul' := map_smul f
counit_comp := congr(($counit_comp).toLinearMap)
map_comp_comul := congr(($map_comp_comul).toLinearMap)
end BialgHom
namespace Bialgebra
variable {R A : Type*} [CommSemiring R] [Semiring A] [Bialgebra R A]
variable (R A) in
/-- The unit of a bialgebra as a `BialgHom`. -/
noncomputable def unitBialgHom : R →ₐc[R] A :=
.ofAlgHom (Algebra.ofId R A) (by ext) (by ext)
variable (R A) in
/-- The counit of a bialgebra as a `BialgHom`. -/
noncomputable def counitBialgHom : A →ₐc[R] R :=
{ Coalgebra.counitCoalgHom R A, counitAlgHom R A with }
@[simp]
theorem counitBialgHom_apply (x : A) :
counitBialgHom R A x = Coalgebra.counit x := rfl
@[simp]
theorem counitBialgHom_toCoalgHom :
counitBialgHom R A = Coalgebra.counitCoalgHom R A := rfl
@[simp] lemma counitBialgHom_self : counitBialgHom R R = .id R R := rfl
instance subsingleton_to_ring : Subsingleton (A →ₐc[R] R) :=
⟨fun _ _ => BialgHom.coe_coalgHom_injective (Subsingleton.elim _ _)⟩
@[ext high]
theorem ext_to_ring (f g : A →ₐc[R] R) : f = g := Subsingleton.elim _ _
end Bialgebra |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Integers.lean | import Mathlib.RingTheory.Valuation.Basic
/-!
# Ring of integers under a given valuation
The elements with valuation less than or equal to 1.
TODO: Define characteristic predicate.
-/
open Set
universe u v w
namespace Valuation
section Ring
variable {R : Type u} {Γ₀ : Type v} [Ring R] [LinearOrderedCommGroupWithZero Γ₀]
variable (v : Valuation R Γ₀)
/-- The ring of integers under a given valuation is the subring of elements with valuation ≤ 1. -/
def integer : Subring R where
carrier := { x | v x ≤ 1 }
one_mem' := le_of_eq v.map_one
mul_mem' {x y} hx hy := by simp only [Set.mem_setOf_eq, map_mul, mul_le_one' hx hy]
zero_mem' := by simp only [Set.mem_setOf_eq, map_zero, zero_le']
add_mem' {x y} hx hy := le_trans (v.map_add x y) (max_le hx hy)
neg_mem' {x} hx := by simp only [Set.mem_setOf_eq] at hx; simpa only [Set.mem_setOf_eq, map_neg]
lemma mem_integer_iff (r : R) : r ∈ v.integer ↔ v r ≤ 1 := by rfl
end Ring
section CommRing
variable {R : Type u} {Γ₀ : Type v} [CommRing R] [LinearOrderedCommGroupWithZero Γ₀]
variable (v : Valuation R Γ₀)
variable (O : Type w) [CommRing O] [Algebra O R]
/-- Given a valuation v : R → Γ₀ and a ring homomorphism O →+* R, we say that O is the integers of v
if f is injective, and its range is exactly `v.integer`. -/
structure Integers : Prop where
hom_inj : Function.Injective (algebraMap O R)
map_le_one : ∀ x, v (algebraMap O R x) ≤ 1
exists_of_le_one : ∀ ⦃r⦄, v r ≤ 1 → ∃ x, algebraMap O R x = r
-- typeclass shortcut
instance : Algebra v.integer R :=
Algebra.ofSubring v.integer
theorem integer.integers : v.Integers v.integer :=
{ hom_inj := Subtype.coe_injective
map_le_one := fun r => r.2
exists_of_le_one := fun r hr => ⟨⟨r, hr⟩, rfl⟩ }
namespace Integers
variable {v O}
theorem one_of_isUnit' {x : O} (hx : IsUnit x) (H : ∀ x, v (algebraMap O R x) ≤ 1) :
v (algebraMap O R x) = 1 :=
let ⟨u, hu⟩ := hx
le_antisymm (H _) <| by
grw [← v.map_one, ← (algebraMap O R).map_one, ← u.mul_inv, ← mul_one (v (algebraMap O R x)), hu,
(algebraMap O R).map_mul, v.map_mul, H (u⁻¹ : Units O)]
theorem one_of_isUnit (hv : Integers v O) {x : O} (hx : IsUnit x) : v (algebraMap O R x) = 1 :=
one_of_isUnit' hx hv.map_le_one
/--
Let `O` be the integers of the valuation `v` on some commutative ring `R`. For every element `x` in
`O`, `x` is a unit in `O` if and only if the image of `x` in `R` is a unit and has valuation 1.
-/
theorem isUnit_of_one (hv : Integers v O) {x : O} (hx : IsUnit (algebraMap O R x))
(hvx : v (algebraMap O R x) = 1) : IsUnit x :=
let ⟨u, hu⟩ := hx
have h1 : v u ≤ 1 := hu.symm ▸ hv.2 x
have h2 : v (u⁻¹ : Rˣ) ≤ 1 := by
rw [← one_mul (v _), ← hvx, ← v.map_mul, ← hu, u.mul_inv, hu, hvx, v.map_one]
let ⟨r1, hr1⟩ := hv.3 h1
let ⟨r2, hr2⟩ := hv.3 h2
⟨⟨r1, r2, hv.1 <| by rw [RingHom.map_mul, RingHom.map_one, hr1, hr2, Units.mul_inv],
hv.1 <| by rw [RingHom.map_mul, RingHom.map_one, hr1, hr2, Units.inv_mul]⟩,
hv.1 <| hr1.trans hu⟩
theorem le_of_dvd (hv : Integers v O) {x y : O} (h : x ∣ y) :
v (algebraMap O R y) ≤ v (algebraMap O R x) := by
obtain ⟨z, rfl⟩ := h
grw [← mul_one (v (algebraMap O R x)), RingHom.map_mul, v.map_mul, hv.2 z]
lemma nontrivial_iff (hv : v.Integers O) : Nontrivial O ↔ Nontrivial R := by
constructor <;> intro h
· exact hv.hom_inj.nontrivial
· obtain ⟨o0, ho0⟩ := hv.exists_of_le_one (r := 0) (by simp)
obtain ⟨o1, ho1⟩ := hv.exists_of_le_one (r := 1) (by simp)
refine ⟨o0, o1, ?_⟩
rintro rfl
simp [ho1] at ho0
end Integers
lemma integers_nontrivial (v : Valuation R Γ₀) :
Nontrivial v.integer ↔ Nontrivial R :=
(Valuation.integer.integers v).nontrivial_iff
end CommRing
section Field
variable {F : Type u} {Γ₀ : Type v} [Field F] [LinearOrderedCommGroupWithZero Γ₀]
variable {v : Valuation F Γ₀} {O : Type w} [CommRing O] [Algebra O F]
namespace Integers
theorem dvd_of_le (hv : Integers v O) {x y : O}
(h : v (algebraMap O F x) ≤ v (algebraMap O F y)) : y ∣ x :=
by_cases
(fun hy : algebraMap O F y = 0 =>
have hx : x = 0 :=
hv.1 <|
(algebraMap O F).map_zero.symm ▸ (v.zero_iff.1 <| le_zero_iff.1 (v.map_zero ▸ hy ▸ h))
hx.symm ▸ dvd_zero y)
fun hy : algebraMap O F y ≠ 0 =>
have : v ((algebraMap O F y)⁻¹ * algebraMap O F x) ≤ 1 := by
grw [← v.map_one, ← inv_mul_cancel₀ hy, v.map_mul, v.map_mul, h]
let ⟨z, hz⟩ := hv.3 this
⟨z, hv.1 <| ((algebraMap O F).map_mul y z).symm ▸ hz.symm ▸ (mul_inv_cancel_left₀ hy _).symm⟩
theorem dvd_iff_le (hv : Integers v O) {x y : O} :
x ∣ y ↔ v (algebraMap O F y) ≤ v (algebraMap O F x) :=
⟨hv.le_of_dvd, hv.dvd_of_le⟩
theorem le_iff_dvd (hv : Integers v O) {x y : O} :
v (algebraMap O F x) ≤ v (algebraMap O F y) ↔ y ∣ x :=
⟨hv.dvd_of_le, hv.le_of_dvd⟩
/--
This is the special case of `Valuation.Integers.isUnit_of_one` when the valuation is defined
over a field. Let `v` be a valuation on some field `F` and `O` be its integers. For every element
`x` in `O`, `x` is a unit in `O` if and only if the image of `x` in `F` has valuation 1.
-/
theorem isUnit_of_one' (hv : Integers v O) {x : O} (hvx : v (algebraMap O F x) = 1) : IsUnit x := by
refine isUnit_of_one hv (IsUnit.mk0 _ ?_) hvx
simp only [← v.ne_zero_iff, hvx, ne_eq, one_ne_zero, not_false_eq_true]
lemma isUnit_iff_valuation_eq_one (hv : Integers v O) {x : O} :
IsUnit x ↔ v (algebraMap O F x) = 1 :=
⟨hv.one_of_isUnit, hv.isUnit_of_one'⟩
lemma valuation_irreducible_lt_one (hv : Integers v O) {ϖ : O} (h : Irreducible ϖ) :
v (algebraMap O F ϖ) < 1 :=
lt_of_le_of_ne (hv.map_le_one ϖ) (mt hv.isUnit_iff_valuation_eq_one.mpr h.not_isUnit)
lemma valuation_unit (hv : Integers v O) (x : Oˣ) :
v (algebraMap O F x) = 1 := by
simp [← hv.isUnit_iff_valuation_eq_one]
lemma valuation_pos_iff_ne_zero (hv : Integers v O) {x : O} :
0 < v (algebraMap O F x) ↔ x ≠ 0 := by
rw [← not_le]
refine not_congr ?_
simp [map_eq_zero_iff _ hv.hom_inj]
lemma valuation_irreducible_pos (hv : Integers v O) {ϖ : O} (h : Irreducible ϖ) :
0 < v (algebraMap O F ϖ) :=
hv.valuation_pos_iff_ne_zero.mpr h.ne_zero
theorem dvdNotUnit_iff_lt (hv : Integers v O) {x y : O} :
DvdNotUnit x y ↔ v (algebraMap O F y) < v (algebraMap O F x) := by
rw [lt_iff_le_not_ge, hv.le_iff_dvd, hv.le_iff_dvd]
refine ⟨?_, And.elim dvdNotUnit_of_dvd_of_not_dvd⟩
rintro ⟨hx0, d, hdu, rfl⟩
refine ⟨⟨d, rfl⟩, ?_⟩
rw [hv.isUnit_iff_valuation_eq_one, ← ne_eq, ne_iff_lt_iff_le.mpr (hv.map_le_one d)] at hdu
rw [dvd_iff_le hv]
simp only [map_mul, not_le]
contrapose! hdu
refine one_le_of_le_mul_left₀ ?_ hdu
simp [hv.valuation_pos_iff_ne_zero, hx0]
theorem eq_algebraMap_or_inv_eq_algebraMap (hv : Integers v O) (x : F) :
∃ a : O, x = algebraMap O F a ∨ x⁻¹ = algebraMap O F a := by
rcases val_le_one_or_val_inv_le_one v x with h | h <;>
obtain ⟨a, ha⟩ := exists_of_le_one hv h
exacts [⟨a, Or.inl ha.symm⟩, ⟨a, Or.inr ha.symm⟩]
lemma coe_span_singleton_eq_setOf_le_v_algebraMap (hv : Integers v O) (x : O) :
(Ideal.span {x} : Set O) = {y : O | v (algebraMap O F y) ≤ v (algebraMap O F x)} := by
rcases eq_or_ne x 0 with rfl | hx
· simp [Set.singleton_zero, Ideal.span_zero, map_eq_zero_iff _ hv.hom_inj]
ext
simp [SetLike.mem_coe, Ideal.mem_span_singleton, hv.dvd_iff_le]
lemma bijective_algebraMap_of_subsingleton_units_mrange (hv : Integers v O)
[Subsingleton (MonoidHom.mrange v)ˣ] :
Function.Bijective (algebraMap O F) := by
refine ⟨hv.hom_inj, fun x ↦ hv.exists_of_le_one ?_⟩
rcases eq_or_ne x 0 with rfl | hx
· simp
· exact (congr_arg Units.val (Subsingleton.elim (α := (MonoidHom.mrange v)ˣ)
((isUnit_iff_ne_zero.mpr hx).unit.map v.toMonoidHom.mrangeRestrict) 1)).le
lemma isPrincipal_iff_exists_isGreatest (hv : Integers v O) {I : Ideal O} :
I.IsPrincipal ↔ ∃ x, IsGreatest (v ∘ algebraMap O F '' I) x := by
constructor <;> rintro ⟨x, hx⟩
· refine ⟨(v ∘ algebraMap O F) x, ?_, ?_⟩
· refine Set.mem_image_of_mem _ ?_
simp [hx, Ideal.mem_span_singleton_self]
· intro y hy
simp only [Function.comp_apply, hx, Ideal.submodule_span_eq, Set.mem_image,
SetLike.mem_coe, Ideal.mem_span_singleton] at hy
obtain ⟨y, hy, rfl⟩ := hy
exact le_of_dvd hv hy
· obtain ⟨a, ha, rfl⟩ : ∃ a ∈ I, (v ∘ algebraMap O F) a = x := by simpa using hx.left
refine ⟨a, ?_⟩
ext b
simp only [Ideal.submodule_span_eq, Ideal.mem_span_singleton]
exact ⟨fun hb ↦ dvd_of_le hv (hx.2 <| mem_image_of_mem _ hb), fun hb ↦ I.mem_of_dvd hb ha⟩
lemma isPrincipal_iff_exists_eq_setOf_valuation_le (hv : Integers v O) {I : Ideal O} :
I.IsPrincipal ↔ ∃ x, (I : Set O) = {y | v (algebraMap O F y) ≤ v (algebraMap O F x)} := by
rw [isPrincipal_iff_exists_isGreatest hv]
constructor <;> rintro ⟨x, hx⟩
· obtain ⟨a, ha, rfl⟩ : ∃ a ∈ I, (v ∘ algebraMap O F) a = x := by simpa using hx.left
refine ⟨a, ?_⟩
ext b
simp only [SetLike.mem_coe, mem_setOf_eq]
constructor <;> intro h
· exact hx.right (Set.mem_image_of_mem _ h)
· rw [le_iff_dvd hv] at h
exact Ideal.mem_of_dvd I h ha
· refine ⟨v (algebraMap O F x), Set.mem_image_of_mem _ ?_, ?_⟩
· simp [hx]
· simp [hx, mem_upperBounds]
lemma not_denselyOrdered_of_isPrincipalIdealRing [IsPrincipalIdealRing O] (hv : Integers v O) :
¬ DenselyOrdered (range v) := by
intro H
-- nonunits as an ideal isn't defined here, nor shown to be equivalent to `v x < 1`
set I : Ideal O := {
carrier := v ∘ algebraMap O F ⁻¹' Iio (1 : Γ₀)
add_mem' := fun {a b} ha hb ↦ by simpa using map_add_lt v ha hb
zero_mem' := by simp
smul_mem' := by
intro c x
simp only [mem_preimage, Function.comp_apply, mem_Iio, smul_eq_mul, map_mul]
intro hx
exact Right.mul_lt_one_of_le_of_lt (hv.map_le_one c) hx
}
obtain ⟨x, hx₁, hx⟩ :
∃ x, v (algebraMap O F x) < 1 ∧
v (algebraMap O F x) ∈ upperBounds (Iio 1 ∩ range (v ∘ algebraMap O F)) := by
simpa [I, IsGreatest, hv.isPrincipal_iff_exists_isGreatest, ← image_preimage_eq_inter_range]
using IsPrincipalIdealRing.principal I
obtain ⟨y, hy, hy₁⟩ : ∃ y, v (algebraMap O F x) < v y ∧ v y < 1 := by
simpa only [Subtype.exists, Subtype.mk_lt_mk, exists_range_iff, exists_prop]
using H.dense ⟨v (algebraMap O F x), mem_range_self _⟩ ⟨1, 1, v.map_one⟩ hx₁
obtain ⟨z, rfl⟩ := hv.exists_of_le_one hy₁.le
exact hy.not_ge <| hx ⟨hy₁, mem_range_self _⟩
end Integers
open Integers in
theorem Integer.not_isUnit_iff_valuation_lt_one {x : v.integer} : ¬IsUnit x ↔ v x < 1 := by
rw [← not_le, not_iff_not, isUnit_iff_valuation_eq_one (F := F) (Γ₀ := Γ₀),
le_antisymm_iff]
exacts [and_iff_right x.2, integer.integers v]
namespace integer
lemma v_irreducible_lt_one {ϖ : v.integer} (h : Irreducible ϖ) :
v ϖ < 1 :=
(Valuation.integer.integers v).valuation_irreducible_lt_one h
lemma v_irreducible_pos {ϖ : v.integer} (h : Irreducible ϖ) : 0 < v ϖ :=
(Valuation.integer.integers v).valuation_irreducible_pos h
lemma coe_span_singleton_eq_setOf_le_v_coe (x : v.integer) :
(Ideal.span {x} : Set v.integer) = {y : v.integer | v y ≤ v x} :=
(Valuation.integer.integers v).coe_span_singleton_eq_setOf_le_v_algebraMap x
end integer
end Field
section Ideal
variable {R : Type u} {Γ₀ : Type v} [Ring R] [LinearOrderedCommGroupWithZero Γ₀]
variable (v : Valuation R Γ₀)
local notation "𝓞" => v.integer
/-- The `v.integer`-submodule of `R` of elements whose valuation is less than or equal to a
certain value. -/
def leSubmodule (γ : Γ₀) : Submodule 𝓞 R where
__ := leAddSubgroup v γ
smul_mem' r x h := by
simpa [Subring.smul_def] using mul_le_of_le_one_of_le r.prop h
/-- The `v.integer`-submodule of `R` of elements whose valuation is less than a certain unit. -/
def ltSubmodule (γ : Γ₀ˣ) : Submodule 𝓞 R where
__ := ltAddSubgroup v γ
smul_mem' r x h := by
simpa [Subring.smul_def] using mul_lt_of_le_one_of_lt r.prop h
lemma leSubmodule_monotone : Monotone (leSubmodule v) :=
leAddSubgroup_monotone v
lemma ltSubmodule_monotone : Monotone (ltSubmodule v) :=
ltAddSubgroup_monotone v
lemma ltSubmodule_le_leSubmodule (γ : Γ₀ˣ) :
ltSubmodule v γ ≤ leSubmodule v (γ : Γ₀) :=
ltAddSubgroup_le_leAddSubgroup v γ
variable {v} in
@[simp]
lemma mem_leSubmodule_iff {γ : Γ₀} {x : R} :
x ∈ leSubmodule v γ ↔ v x ≤ γ :=
Iff.rfl
variable {v} in
@[simp]
lemma mem_ltSubmodule_iff {γ : Γ₀ˣ} {x : R} :
x ∈ ltSubmodule v γ ↔ v x < γ :=
Iff.rfl
@[simp]
lemma leSubmodule_zero (K : Type*) [Field K] (v : Valuation K Γ₀) :
leSubmodule v (0 : Γ₀) = ⊥ := by
ext; simp
lemma leSubmodule_v_le_of_mem {K : Type*} [Field K] (v : Valuation K Γ₀)
{S : Submodule v.integer K} {x : K} (hx : x ∈ S) :
leSubmodule v (v x) ≤ S := by
rcases eq_or_ne x 0 with rfl | hx0
· simp
intro y hy
have : v ((y : K) / x) ≤ 1 := by simp [div_le_one_of_le₀ hy]
simpa [Subring.smul_def, div_mul_cancel₀ _ hx0] using S.smul_mem ⟨_, this⟩ hx
lemma ltSubmodule_v_le_of_mem {K : Type*} [Field K] {v : Valuation K Γ₀}
{S : Submodule v.integer K} {x : K} (hx : x ∈ S) (hxv : v x ≠ 0) :
ltSubmodule v (Units.mk0 _ hxv) ≤ S :=
(leSubmodule_v_le_of_mem v hx).trans' (ltSubmodule_le_leSubmodule _ _)
-- the ideals do not use the submodules due to `Submodule.comap _ (Algebra.linearMap _ _)`
-- requiring commutativity
/-- The ideal of elements of the valuation subring whose valuation is less than or equal to a
certain value. -/
def leIdeal (γ : Γ₀) : Ideal 𝓞 where
__ := AddSubgroup.addSubgroupOf (leAddSubgroup v γ) v.integer.toAddSubgroup
smul_mem' r x h :=
-- need to specify the subgroup, it is not inferred otherwise
(AddSubgroup.mem_addSubgroupOf (K := v.integer.toAddSubgroup)).mpr <| by
simpa using mul_le_of_le_one_of_le r.prop h
/-- The ideal of elements of the valuation subring whose valuation is less than a certain unit. -/
def ltIdeal (γ : Γ₀ˣ) : Ideal 𝓞 where
__ := AddSubgroup.addSubgroupOf (ltAddSubgroup v γ) v.integer.toAddSubgroup
smul_mem' r x h := by
change v ((r : R) * x) < γ -- not sure why simp can't get us to here
simpa [Subring.smul_def] using mul_lt_of_le_one_of_lt r.prop h
-- Can't use `leAddSubgroup` because `addSubgroupOf` is a dependent function
lemma leIdeal_mono : Monotone (leIdeal v) :=
fun _ _ h _ ↦ h.trans'
lemma ltIdeal_mono : Monotone (ltIdeal v) :=
fun _ _ h _ ↦ (Units.val_le_val.mpr h).trans_lt'
lemma ltIdeal_le_leIdeal (γ : Γ₀ˣ) :
ltIdeal v γ ≤ leIdeal v (γ : Γ₀) :=
fun _ h ↦ h.le
variable {v} in
@[simp]
lemma mem_leIdeal_iff {γ : Γ₀} {x : 𝓞} :
x ∈ leIdeal v γ ↔ v (x : R) ≤ γ :=
Iff.rfl
variable {v} in
@[simp]
lemma mem_ltIdeal_iff {γ : Γ₀ˣ} {x : 𝓞} :
x ∈ ltIdeal v γ ↔ v (x : R) < γ :=
Iff.rfl
@[simp]
lemma leIdeal_zero (K : Type*) [Field K] (v : Valuation K Γ₀) :
leIdeal v (0 : Γ₀) = ⊥ := by
ext; simp
lemma leSubmodule_comap_algebraMap_eq_leIdeal {K : Type*} [Field K] (v : Valuation K Γ₀) (γ : Γ₀) :
(leSubmodule v γ).comap (Algebra.linearMap _ _) = leIdeal v γ :=
Submodule.ext fun _ ↦ Iff.rfl
lemma leIdeal_map_algebraMap_eq_leSubmodule_min {K : Type*} [Field K] (v : Valuation K Γ₀)
(γ : Γ₀) :
Submodule.map (Algebra.linearMap _ _) (leIdeal v γ) = leSubmodule v (min 1 γ) := by
ext x
simp only [Submodule.mem_map, mem_leIdeal_iff, Algebra.linearMap_apply, mem_leSubmodule_iff]
constructor
· rintro ⟨y, hy, rfl⟩
rcases min_cases 1 γ with ⟨h, _⟩ | ⟨h, _⟩
· rw [h]
exact y.prop
· rw [h]
exact hy
· intro hx
rcases min_cases 1 γ with ⟨h, h'⟩ | ⟨h, h'⟩ <;> rw [h] at hx
· exact ⟨⟨x, hx⟩, hx.trans h', rfl⟩
· exact ⟨⟨x, hx.trans h'.le⟩, hx, rfl⟩
-- Ideally, this would follow from `leSubmodule_v_le_of_mem`
lemma leIdeal_v_le_of_mem {K : Type*} [Field K] (v : Valuation K Γ₀)
{I : Ideal v.integer} {x : v.integer} (hx : x ∈ I) :
leIdeal v (v (x : K)) ≤ I := by
rcases eq_or_ne x 0 with rfl | hx0
· simp
intro y hy
have : v ((y : K) / x) ≤ 1 := by simpa using div_le_one_of_le₀ hy zero_le'
convert I.smul_mem ⟨_, this⟩ hx using 1
simp [Subtype.ext_iff, div_mul_cancel₀ _ (ZeroMemClass.coe_eq_zero.not.mpr hx0)]
lemma ltIdeal_v_le_of_mem {K : Type*} [Field K] {v : Valuation K Γ₀}
{I : Ideal v.integer} {x : v.integer} (hx : x ∈ I) (hxv : v (x : K) ≠ 0) :
ltIdeal v (Units.mk0 _ hxv) ≤ I :=
(leIdeal_v_le_of_mem v hx).trans' (ltIdeal_le_leIdeal _ _)
end Ideal
end Valuation |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/PrimeMultiplicity.lean | import Mathlib.RingTheory.Multiplicity
import Mathlib.RingTheory.Valuation.Basic
/-!
# `multiplicity` of a prime in an integral domain as an additive valuation
-/
variable {R : Type*} [CommRing R] [IsDomain R] {p : R}
/-- `multiplicity` of a prime in an integral domain as an additive valuation to `ℕ∞`. -/
noncomputable def multiplicity_addValuation (hp : Prime p) : AddValuation R ℕ∞ :=
AddValuation.of (emultiplicity p) (emultiplicity_zero _) (emultiplicity_of_one_right hp.not_unit)
(fun _ _ => min_le_emultiplicity_add) fun _ _ => emultiplicity_mul hp
@[simp]
theorem multiplicity_addValuation_apply {hp : Prime p} {r : R} :
multiplicity_addValuation hp r = emultiplicity p r :=
rfl |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/RamificationGroup.lean | import Mathlib.RingTheory.LocalRing.ResidueField.Basic
import Mathlib.RingTheory.Valuation.ValuationSubring
/-!
# Ramification groups
The decomposition subgroup and inertia subgroups.
TODO: Define higher ramification groups in lower numbering
-/
namespace ValuationSubring
open scoped Pointwise
variable (K : Type*) {L : Type*} [Field K] [Field L] [Algebra K L]
/-- The decomposition subgroup defined as the stabilizer of the action
on the type of all valuation subrings of the field. -/
abbrev decompositionSubgroup (A : ValuationSubring L) : Subgroup (L ≃ₐ[K] L) :=
MulAction.stabilizer (L ≃ₐ[K] L) A
/-- The valuation subring `A` (considered as a subset of `L`)
is stable under the action of the decomposition group. -/
def subMulAction (A : ValuationSubring L) : SubMulAction (A.decompositionSubgroup K) L where
carrier := A
smul_mem' g _ h := Set.mem_of_mem_of_subset (Set.smul_mem_smul_set h) g.prop.le
/-- The multiplicative action of the decomposition subgroup on `A`. -/
instance decompositionSubgroupMulSemiringAction (A : ValuationSubring L) :
MulSemiringAction (A.decompositionSubgroup K) A :=
{ SubMulAction.mulAction (A.subMulAction K) with
smul_add := fun g k l => Subtype.ext <| smul_add (A := L) g k l
smul_zero := fun g => Subtype.ext <| smul_zero g
smul_one := fun g => Subtype.ext <| smul_one g
smul_mul := fun g k l => Subtype.ext <| smul_mul' (N := L) g k l }
/-- The inertia subgroup defined as the kernel of the group homomorphism from
the decomposition subgroup to the group of automorphisms of the residue field of `A`. -/
noncomputable def inertiaSubgroup (A : ValuationSubring L) : Subgroup (A.decompositionSubgroup K) :=
MonoidHom.ker <|
MulSemiringAction.toRingAut (A.decompositionSubgroup K) (IsLocalRing.ResidueField A)
end ValuationSubring |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/ValuationRing.lean | import Mathlib.RingTheory.Bezout
import Mathlib.RingTheory.LocalRing.Basic
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Integer
import Mathlib.RingTheory.Valuation.Integers
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.FieldSimp
/-!
# Valuation Rings
A valuation ring is a domain such that for every pair of elements `a b`, either `a` divides
`b` or vice-versa.
Any valuation ring induces a natural valuation on its fraction field, as we show in this file.
Namely, given the following instances:
`[CommRing A] [IsDomain A] [ValuationRing A] [Field K] [Algebra A K] [IsFractionRing A K]`,
there is a natural valuation `Valuation A K` on `K` with values in `value_group A K` where
the image of `A` under `algebraMap A K` agrees with `(Valuation A K).integer`.
We also provide the equivalence of the following notions for a domain `R` in `ValuationRing.TFAE`.
1. `R` is a valuation ring.
2. For each `x : FractionRing K`, either `x` or `x⁻¹` is in `R`.
3. "divides" is a total relation on the elements of `R`.
4. "contains" is a total relation on the ideals of `R`.
5. `R` is a local bezout domain.
We also show that, given a valuation `v` on a field `K`, the ring of valuation integers is a
valuation ring and `K` is the fraction field of this ring.
## Implementation details
The Mathlib definition of a valuation ring requires `IsDomain A` even though the condition
does not mention zero divisors. Thus, there is a technical `PreValuationRing A` that
is defined in further generality that can be used in places where the ring cannot be a domain.
The `ValuationRing` class is kept to be in sync with the literature.
-/
assert_not_exists IsDiscreteValuationRing
universe u v w
/-- A magma is called a `PreValuationRing` provided that for any pair
of elements `a b : A`, either `a` divides `b` or vice versa. -/
class PreValuationRing (A : Type u) [Mul A] : Prop where
cond' : ∀ a b : A, ∃ c : A, a * c = b ∨ b * c = a
lemma PreValuationRing.cond {A : Type u} [Mul A] [PreValuationRing A] (a b : A) :
∃ c : A, a * c = b ∨ b * c = a := @PreValuationRing.cond' A _ _ _ _
/-- An integral domain is called a `ValuationRing` provided that for any pair
of elements `a b : A`, either `a` divides `b` or vice versa. -/
class ValuationRing (A : Type u) [CommRing A] [IsDomain A] : Prop extends PreValuationRing A
/-- An abbreviation for `PreValuationRing.cond` which should save some writing. -/
alias ValuationRing.cond := PreValuationRing.cond
namespace ValuationRing
section
variable (A : Type u) [CommRing A]
variable (K : Type v) [Field K] [Algebra A K]
/-- The value group of the valuation ring `A`. Note: this is actually a group with zero. -/
def ValueGroup : Type v := Quotient (MulAction.orbitRel Aˣ K)
instance : Inhabited (ValueGroup A K) := ⟨Quotient.mk'' 0⟩
instance : LE (ValueGroup A K) :=
LE.mk fun x y =>
Quotient.liftOn₂' x y (fun a b => ∃ c : A, c • b = a)
(by
rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩; ext
constructor
· rintro ⟨e, he⟩; use (c⁻¹ : Aˣ) * e * d
apply_fun fun t => c⁻¹ • t at he
simpa [mul_smul] using he
· rintro ⟨e, he⟩; dsimp
use c * e * (d⁻¹ : Aˣ)
simp_rw [Units.smul_def, ← he, mul_smul]
rw [← mul_smul _ _ b, Units.inv_mul, one_smul])
instance : Zero (ValueGroup A K) := ⟨Quotient.mk'' 0⟩
instance : One (ValueGroup A K) := ⟨Quotient.mk'' 1⟩
instance : Mul (ValueGroup A K) :=
Mul.mk fun x y =>
Quotient.liftOn₂' x y (fun a b => Quotient.mk'' <| a * b)
(by
rintro _ _ a b ⟨c, rfl⟩ ⟨d, rfl⟩
apply Quotient.sound'
dsimp
use c * d
simp only [mul_smul, Algebra.smul_def, Units.smul_def]
ring)
instance : Inv (ValueGroup A K) :=
Inv.mk fun x =>
Quotient.liftOn' x (fun a => Quotient.mk'' a⁻¹)
(by
rintro _ a ⟨b, rfl⟩
apply Quotient.sound'
use b⁻¹
dsimp
rw [Units.smul_def, Units.smul_def, Algebra.smul_def, Algebra.smul_def, mul_inv,
map_units_inv])
instance : Nontrivial (ValueGroup A K) where
exists_pair_ne := ⟨0, 1, fun c => by
obtain ⟨d, hd⟩ := Quotient.exact' c
apply_fun fun t => d⁻¹ • t at hd
dsimp at hd
simp only [inv_smul_smul, smul_zero, one_ne_zero] at hd⟩
variable [IsDomain A] [ValuationRing A] [IsFractionRing A K]
protected theorem le_total (a b : ValueGroup A K) : a ≤ b ∨ b ≤ a := by
rcases a with ⟨a⟩; rcases b with ⟨b⟩
obtain ⟨xa, ya, hya, rfl⟩ : ∃ a b : A, _ := IsFractionRing.div_surjective a
obtain ⟨xb, yb, hyb, rfl⟩ : ∃ a b : A, _ := IsFractionRing.div_surjective b
have : (algebraMap A K) ya ≠ 0 := IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors hya
have : (algebraMap A K) yb ≠ 0 := IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors hyb
obtain ⟨c, h | h⟩ := ValuationRing.cond (xa * yb) (xb * ya)
· right
use c
rw [Algebra.smul_def]
field_simp
simp only [← RingHom.map_mul]; congr 1; linear_combination h
· left
use c
rw [Algebra.smul_def]
field_simp
simp only [← RingHom.map_mul]; congr 1; linear_combination h
noncomputable instance linearOrder : LinearOrder (ValueGroup A K) where
le_refl := by rintro ⟨⟩; use 1; rw [one_smul]
le_trans := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ ⟨e, rfl⟩ ⟨f, rfl⟩; use e * f; rw [mul_smul]
le_antisymm := by
rintro ⟨a⟩ ⟨b⟩ ⟨e, rfl⟩ ⟨f, hf⟩
by_cases hb : b = 0; · simp [hb]
have : IsUnit e := by
apply isUnit_of_dvd_one
use f
rw [mul_comm]
rw [← mul_smul, Algebra.smul_def] at hf
nth_rw 2 [← one_mul b] at hf
rw [← (algebraMap A K).map_one] at hf
exact IsFractionRing.injective _ _ (mul_right_cancel₀ hb hf).symm
apply Quotient.sound'
exact ⟨this.unit, rfl⟩
le_total := ValuationRing.le_total _ _
toDecidableLE := Classical.decRel _
instance commGroupWithZero :
CommGroupWithZero (ValueGroup A K) :=
{ mul_assoc := by rintro ⟨a⟩ ⟨b⟩ ⟨c⟩; apply Quotient.sound'; rw [mul_assoc]
one_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [one_mul]
mul_one := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_one]
mul_comm := by rintro ⟨a⟩ ⟨b⟩; apply Quotient.sound'; rw [mul_comm]
zero_mul := by rintro ⟨a⟩; apply Quotient.sound'; rw [zero_mul]
mul_zero := by rintro ⟨a⟩; apply Quotient.sound'; rw [mul_zero]
inv_zero := by apply Quotient.sound'; rw [inv_zero]
mul_inv_cancel := by
rintro ⟨a⟩ ha
apply Quotient.sound'
use 1
simp only [one_smul]
apply (mul_inv_cancel₀ _).symm
contrapose ha
simp only [Classical.not_not] at ha ⊢
rw [ha]
rfl }
noncomputable instance linearOrderedCommGroupWithZero :
LinearOrderedCommGroupWithZero (ValueGroup A K) :=
{ linearOrder .., commGroupWithZero .. with
mul_le_mul_left := by
rintro ⟨a⟩ ⟨b⟩ ⟨c, rfl⟩ ⟨d⟩
use c; simp only [Algebra.smul_def]; ring
zero_le_one := ⟨0, by rw [zero_smul]⟩
bot := 0
bot_le := by rintro ⟨a⟩; exact ⟨0, zero_smul ..⟩ }
/-- Any valuation ring induces a valuation on its fraction field. -/
noncomputable def valuation : Valuation K (ValueGroup A K) where
toFun := Quotient.mk''
map_zero' := rfl
map_one' := rfl
map_mul' _ _ := rfl
map_add_le_max' := by
intro a b
obtain ⟨xa, ya, hya, rfl⟩ : ∃ a b : A, _ := IsFractionRing.div_surjective a
obtain ⟨xb, yb, hyb, rfl⟩ : ∃ a b : A, _ := IsFractionRing.div_surjective b
have : (algebraMap A K) ya ≠ 0 := IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors hya
have : (algebraMap A K) yb ≠ 0 := IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors hyb
obtain ⟨c, h | h⟩ := ValuationRing.cond (xa * yb) (xb * ya)
· apply le_trans _ (le_max_left _ _)
use c + 1
rw [Algebra.smul_def]
field_simp
simp only [← RingHom.map_mul, ← RingHom.map_add]
congr 1; linear_combination h
· apply le_trans _ (le_max_right _ _)
use c + 1
rw [Algebra.smul_def]
field_simp
simp only [← RingHom.map_mul, ← RingHom.map_add]
congr 1; linear_combination h
theorem mem_integer_iff (x : K) : x ∈ (valuation A K).integer ↔ ∃ a : A, algebraMap A K a = x := by
constructor
· rintro ⟨c, rfl⟩
use c
rw [Algebra.smul_def, mul_one]
· rintro ⟨c, rfl⟩
use c
rw [Algebra.smul_def, mul_one]
/-- The valuation ring `A` is isomorphic to the ring of integers of its associated valuation. -/
noncomputable def equivInteger : A ≃+* (valuation A K).integer :=
RingEquiv.ofBijective
(show A →ₙ+* (valuation A K).integer from
{ toFun := fun a => ⟨algebraMap A K a, (mem_integer_iff _ _ _).mpr ⟨a, rfl⟩⟩
map_mul' := fun _ _ => by ext1; exact (algebraMap A K).map_mul _ _
map_zero' := by ext1; exact (algebraMap A K).map_zero
map_add' := fun _ _ => by ext1; exact (algebraMap A K).map_add _ _ })
(by
constructor
· intro x y h
apply_fun (algebraMap (valuation A K).integer K) at h
exact IsFractionRing.injective _ _ h
· rintro ⟨-, ha⟩
rw [mem_integer_iff] at ha
obtain ⟨a, rfl⟩ := ha
exact ⟨a, rfl⟩)
@[simp]
theorem coe_equivInteger_apply (a : A) : (equivInteger A K a : K) = algebraMap A K a := rfl
theorem range_algebraMap_eq : (valuation A K).integer = (algebraMap A K).range := by
ext; exact mem_integer_iff _ _ _
end
section
variable (A : Type u) [CommRing A] [Nontrivial A] [PreValuationRing A]
instance (priority := 100) isLocalRing : IsLocalRing A :=
IsLocalRing.of_isUnit_or_isUnit_one_sub_self fun a ↦ by
obtain ⟨c, h | h⟩ := PreValuationRing.cond a (1 - a)
· left
refine .of_mul_eq_one (c + 1) ?_
simp [mul_add, h]
· right
refine .of_mul_eq_one (c + 1) ?_
simp [mul_add, h]
instance le_total_ideal : IsTotal (Ideal A) LE.le := by
constructor; intro α β
by_cases! h : ∀ x : A, x ∈ α → x ∈ β
· exact Or.inl h
obtain ⟨a, h₁, h₂⟩ := h
right
intro b hb
obtain ⟨c, h | h⟩ := PreValuationRing.cond a b
· rw [← h]
exact Ideal.mul_mem_right _ _ h₁
· exfalso; apply h₂; rw [← h]
apply Ideal.mul_mem_right _ _ hb
instance [DecidableLE (Ideal A)] : LinearOrder (Ideal A) :=
have := decidableEqOfDecidableLE (α := Ideal A)
have := decidableLTOfDecidableLE (α := Ideal A)
Lattice.toLinearOrder (Ideal A)
end
section
section dvd
variable {R : Type*}
theorem _root_.PreValuationRing.iff_dvd_total [Semigroup R] :
PreValuationRing R ↔ IsTotal R (· ∣ ·) := by
classical
refine ⟨fun H => ⟨fun a b => ?_⟩, fun H => ⟨fun a b => ?_⟩⟩
· obtain ⟨c, rfl | rfl⟩ := PreValuationRing.cond a b <;> simp
· obtain ⟨c, rfl⟩ | ⟨c, rfl⟩ := @IsTotal.total _ _ H a b <;> use c <;> simp
theorem _root_.PreValuationRing.iff_ideal_total [CommRing R] :
PreValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) := by
classical
refine ⟨fun _ => ⟨le_total⟩, fun H => PreValuationRing.iff_dvd_total.mpr ⟨fun a b => ?_⟩⟩
have := @IsTotal.total _ _ H (Ideal.span {a}) (Ideal.span {b})
simp_rw [Ideal.span_singleton_le_span_singleton] at this
exact this.symm
variable (K)
theorem dvd_total [Semigroup R] [h : PreValuationRing R] (x y : R) : x ∣ y ∨ y ∣ x :=
@IsTotal.total _ _ (PreValuationRing.iff_dvd_total.mp h) x y
end dvd
variable {R : Type*} [CommRing R] [IsDomain R] (K : Type*)
variable [Field K] [Algebra R K] [IsFractionRing R K]
theorem iff_dvd_total : ValuationRing R ↔ IsTotal R (· ∣ ·) :=
Iff.trans (⟨fun inst ↦ inst.toPreValuationRing, fun _ ↦ .mk⟩)
PreValuationRing.iff_dvd_total
theorem iff_ideal_total : ValuationRing R ↔ IsTotal (Ideal R) (· ≤ ·) :=
Iff.trans (⟨fun inst ↦ inst.toPreValuationRing, fun _ ↦ .mk⟩)
PreValuationRing.iff_ideal_total
theorem unique_irreducible [PreValuationRing R] ⦃p q : R⦄ (hp : Irreducible p)
(hq : Irreducible q) : Associated p q := by
have := dvd_total p q
rw [Irreducible.dvd_comm hp hq, or_self_iff] at this
exact associated_of_dvd_dvd (Irreducible.dvd_symm hq hp this) this
variable (R)
theorem iff_isInteger_or_isInteger :
ValuationRing R ↔ ∀ x : K, IsLocalization.IsInteger R x ∨ IsLocalization.IsInteger R x⁻¹ := by
constructor
· intro H x
obtain ⟨x : R, y, hy, rfl⟩ := IsFractionRing.div_surjective (A := R) x
have := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr (nonZeroDivisors.ne_zero hy)
obtain ⟨s, rfl | rfl⟩ := ValuationRing.cond x y
· exact Or.inr
⟨s, eq_inv_of_mul_eq_one_left <| by rwa [mul_div, div_eq_one_iff_eq, map_mul, mul_comm]⟩
· exact Or.inl ⟨s, by rwa [eq_div_iff, map_mul, mul_comm]⟩
· intro H
suffices PreValuationRing R from mk
constructor
intro a b
by_cases ha : a = 0; · subst ha; exact ⟨0, Or.inr <| mul_zero b⟩
by_cases hb : b = 0; · subst hb; exact ⟨0, Or.inl <| mul_zero a⟩
replace ha := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr ha
replace hb := (map_ne_zero_iff _ (IsFractionRing.injective R K)).mpr hb
obtain ⟨c, e⟩ | ⟨c, e⟩ := H (algebraMap R K a / algebraMap R K b)
· rw [eq_div_iff hb, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm] at e
exact ⟨c, Or.inr e⟩
· rw [inv_div, eq_div_iff ha, ← map_mul, (IsFractionRing.injective R K).eq_iff, mul_comm c] at e
exact ⟨c, Or.inl e⟩
variable {K}
theorem isInteger_or_isInteger [h : ValuationRing R] (x : K) :
IsLocalization.IsInteger R x ∨ IsLocalization.IsInteger R x⁻¹ :=
(iff_isInteger_or_isInteger R K).mp h x
variable {R}
-- This implies that valuation rings are integrally closed through typeclass search.
instance (priority := 100) [ValuationRing R] : IsBezout R := by
classical
rw [IsBezout.iff_span_pair_isPrincipal]
intro x y
rw [Ideal.span_insert]
rcases le_total (Ideal.span {x} : Ideal R) (Ideal.span {y}) with h | h
· rw [sup_eq_right.mpr h]; exact ⟨⟨_, rfl⟩⟩
· rw [sup_eq_left.mpr h]; exact ⟨⟨_, rfl⟩⟩
instance (priority := 100) [IsLocalRing R] [IsBezout R] : ValuationRing R := by
classical
refine iff_dvd_total.mpr ⟨fun a b => ?_⟩
obtain ⟨g, e : _ = Ideal.span _⟩ := IsBezout.span_pair_isPrincipal a b
obtain ⟨a, rfl⟩ := Ideal.mem_span_singleton'.mp
(show a ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
obtain ⟨b, rfl⟩ := Ideal.mem_span_singleton'.mp
(show b ∈ Ideal.span {g} by rw [← e]; exact Ideal.subset_span (by simp))
obtain ⟨x, y, e'⟩ := Ideal.mem_span_pair.mp
(show g ∈ Ideal.span {a * g, b * g} by rw [e]; exact Ideal.subset_span (by simp))
rcases eq_or_ne g 0 with h | h
· simp [h]
have : x * a + y * b = 1 := by
apply mul_left_injective₀ h; convert e' using 1 <;> ring
rcases IsLocalRing.isUnit_or_isUnit_of_add_one this with h' | h' <;> [left; right]
all_goals exact mul_dvd_mul_right (isUnit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _
theorem iff_local_bezout_domain : ValuationRing R ↔ IsLocalRing R ∧ IsBezout R :=
⟨fun _ ↦ ⟨inferInstance, inferInstance⟩, fun ⟨_, _⟩ ↦ inferInstance⟩
protected theorem TFAE (R : Type u) [CommRing R] [IsDomain R] :
List.TFAE
[ValuationRing R,
∀ x : FractionRing R, IsLocalization.IsInteger R x ∨ IsLocalization.IsInteger R x⁻¹,
IsTotal R (· ∣ ·), IsTotal (Ideal R) (· ≤ ·), IsLocalRing R ∧ IsBezout R] := by
tfae_have 1 ↔ 2 := iff_isInteger_or_isInteger R _
tfae_have 1 ↔ 3 := iff_dvd_total
tfae_have 1 ↔ 4 := iff_ideal_total
tfae_have 1 ↔ 5 := iff_local_bezout_domain
tfae_finish
end
theorem _root_.Function.Surjective.preValuationRing {R S : Type*} [Mul R] [PreValuationRing R]
[Mul S] (f : R →ₙ* S) (hf : Function.Surjective f) :
PreValuationRing S :=
⟨fun a b => by
obtain ⟨⟨a, rfl⟩, ⟨b, rfl⟩⟩ := hf a, hf b
obtain ⟨c, rfl | rfl⟩ := PreValuationRing.cond a b
exacts [⟨f c, Or.inl <| (map_mul _ _ _).symm⟩, ⟨f c, Or.inr <| (map_mul _ _ _).symm⟩]⟩
theorem _root_.Function.Surjective.valuationRing {R S : Type*} [NonAssocSemiring R]
[PreValuationRing R] [CommRing S] [IsDomain S] (f : R →+* S) (hf : Function.Surjective f) :
ValuationRing S :=
have : PreValuationRing S := Function.Surjective.preValuationRing (R := R) f hf
.mk
section
variable {𝒪 : Type u} {K : Type v} {Γ : Type w} [CommRing 𝒪] [Field K] [Algebra 𝒪 K]
[LinearOrderedCommGroupWithZero Γ]
lemma _root_.isFractionRing_of_exists_eq_algebraMap_or_inv_eq_algebraMap_of_injective
(h : ∀ (x : K), ∃ a : 𝒪, x = algebraMap 𝒪 K a ∨ x⁻¹ = algebraMap 𝒪 K a)
(hinj : Function.Injective (algebraMap 𝒪 K)) :
IsFractionRing 𝒪 K := by
have : IsDomain 𝒪 := hinj.isDomain
constructor
· intro a
simpa using hinj.ne_iff.mpr (nonZeroDivisors.ne_zero a.2)
· intro x
obtain ⟨a, ha⟩ := h x
by_cases h0 : a = 0
· refine ⟨⟨0, 1⟩, by simpa [h0, eq_comm] using ha⟩
· have : algebraMap 𝒪 K a ≠ 0 := by simpa using hinj.ne_iff.mpr h0
rw [inv_eq_iff_eq_inv, ← one_div, eq_div_iff this] at ha
cases ha with
| inl ha => exact ⟨⟨a, 1⟩, by simpa⟩
| inr ha => exact ⟨⟨1, ⟨a, mem_nonZeroDivisors_of_ne_zero h0⟩⟩, by simpa using ha⟩
· intro _ _ hab
exact ⟨1, by simp only [OneMemClass.coe_one, hinj hab, one_mul]⟩
lemma _root_.Valuation.Integers.isFractionRing {v : Valuation K Γ} (hv : v.Integers 𝒪) :
IsFractionRing 𝒪 K :=
isFractionRing_of_exists_eq_algebraMap_or_inv_eq_algebraMap_of_injective
hv.eq_algebraMap_or_inv_eq_algebraMap hv.hom_inj
instance instIsFractionRingInteger (v : Valuation K Γ) : IsFractionRing v.integer K :=
(Valuation.integer.integers v).isFractionRing
/-- If `𝒪` satisfies `v.integers 𝒪` where `v` is a valuation on a field, then `𝒪`
is a valuation ring. -/
theorem of_integers (v : Valuation K Γ) (hh : v.Integers 𝒪) :
haveI := hh.hom_inj.isDomain
ValuationRing 𝒪 := by
haveI := hh.hom_inj.isDomain
suffices PreValuationRing 𝒪 from .mk
constructor
intro a b
rcases le_total (v (algebraMap 𝒪 K a)) (v (algebraMap 𝒪 K b)) with h | h
· obtain ⟨c, hc⟩ := Valuation.Integers.dvd_of_le hh h
use c; exact Or.inr hc.symm
· obtain ⟨c, hc⟩ := Valuation.Integers.dvd_of_le hh h
use c; exact Or.inl hc.symm
instance instValuationRingInteger (v : Valuation K Γ) : ValuationRing v.integer :=
of_integers (v := v) (Valuation.integer.integers v)
theorem isFractionRing_iff [IsDomain 𝒪] [ValuationRing 𝒪] :
IsFractionRing 𝒪 K ↔
(∀ (x : K), ∃ a : 𝒪, x = algebraMap 𝒪 K a ∨ x⁻¹ = algebraMap 𝒪 K a) ∧
Function.Injective (algebraMap 𝒪 K) := by
refine ⟨fun h ↦ ⟨fun x ↦ ?_, IsFractionRing.injective _ _⟩, fun h ↦ ?_⟩
· obtain (⟨a, e⟩ | ⟨a, e⟩) := isInteger_or_isInteger 𝒪 x
exacts [⟨a, .inl e.symm⟩, ⟨a, .inr e.symm⟩]
· exact isFractionRing_of_exists_eq_algebraMap_or_inv_eq_algebraMap_of_injective h.1 h.2
end
section
variable (K : Type u) [Field K]
/-- A field is a valuation ring. -/
instance (priority := 100) of_field : ValuationRing K := inferInstance
end
end ValuationRing |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Integral.lean | import Mathlib.RingTheory.IntegralClosure.IntegrallyClosed
import Mathlib.RingTheory.Valuation.ValuationRing
/-!
# Integral elements over the ring of integers of a valuation
The ring of integers is integrally closed inside the original ring.
-/
universe u v w
namespace Valuation
namespace Integers
section CommRing
variable {R : Type u} {Γ₀ : Type v} [CommRing R] [LinearOrderedCommGroupWithZero Γ₀]
variable {v : Valuation R Γ₀} {O : Type w} [CommRing O] [Algebra O R] (hv : Integers v O)
include hv
open Polynomial
lemma isIntegral_iff_v_le_one {x : R} :
IsIntegral O x ↔ v x ≤ 1 := by
nontriviality R
have : Nontrivial O := hv.nontrivial_iff.mpr inferInstance
constructor
· rintro ⟨f, hm, hf⟩
by_cases hn : f.natDegree = 0
· rw [Polynomial.natDegree_eq_zero] at hn
obtain ⟨c, rfl⟩ := hn
simp [map_eq_zero_iff _ hv.hom_inj, hm.ne_zero_of_C] at hf
simp only [Polynomial.eval₂_eq_sum_range, Finset.sum_range_succ, hm.coeff_natDegree, map_one,
one_mul, add_eq_zero_iff_eq_neg] at hf
apply_fun v at hf
simp only [map_neg, map_pow] at hf
contrapose! hf
refine ne_of_lt (v.map_sum_lt ?_ ?_)
· simp [hn, (hf.trans' (zero_lt_one)).ne']
· simp only [Finset.mem_range, map_mul, map_pow]
intro _ hi
exact mul_lt_of_le_one_of_lt (hv.map_le_one _) <| pow_lt_pow_right₀ hf hi
· intro h
obtain ⟨y, rfl⟩ := hv.exists_of_le_one h
exact ⟨Polynomial.X - .C y, by monicity, by simp⟩
theorem mem_of_integral {x : R} (hx : IsIntegral O x) : x ∈ v.integer :=
hv.isIntegral_iff_v_le_one.mp hx
protected theorem integralClosure : integralClosure O R = ⊥ :=
bot_unique fun _ hr =>
let ⟨x, hx⟩ := hv.3 (hv.mem_of_integral hr)
Algebra.mem_bot.2 ⟨x, hx⟩
end CommRing
section FractionField
variable {K : Type u} {Γ₀ : Type v} [Field K] [LinearOrderedCommGroupWithZero Γ₀]
variable {v : Valuation K Γ₀} {O : Type w} [CommRing O]
variable [Algebra O K]
variable (hv : Integers v O)
include hv in
theorem isIntegrallyClosed : IsIntegrallyClosed O := by
have : IsFractionRing O K := hv.isFractionRing
exact
(IsIntegrallyClosed.integralClosure_eq_bot_iff K).mp (Valuation.Integers.integralClosure hv)
@[deprecated (since := "2025-09-04")] alias integrallyClosed := isIntegrallyClosed
instance isIntegrallyClosed_integers (v : Valuation K Γ₀) :
IsIntegrallyClosed v.integer :=
(Valuation.integer.integers v).isIntegrallyClosed
end FractionField
end Integers
end Valuation |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/ExtendToLocalization.lean | import Mathlib.RingTheory.Localization.Defs
import Mathlib.RingTheory.Valuation.Basic
/-!
# Extending valuations to a localization
We show that, given a valuation `v` taking values in a linearly ordered commutative *group*
with zero `Γ`, and a submonoid `S` of `v.supp.primeCompl`, the valuation `v` can be naturally
extended to the localization `S⁻¹A`.
-/
variable {A : Type*} [CommRing A] {Γ : Type*} [LinearOrderedCommGroupWithZero Γ]
(v : Valuation A Γ) {S : Submonoid A} (hS : S ≤ v.supp.primeCompl) (B : Type*) [CommRing B]
[Algebra A B] [IsLocalization S B]
/-- We can extend a valuation `v` on a ring to a localization at a submonoid of
the complement of `v.supp`. -/
noncomputable def Valuation.extendToLocalization : Valuation B Γ :=
let f := IsLocalization.toLocalizationMap S B
let h : ∀ s : S, IsUnit (v.1.toMonoidHom s) := fun s => isUnit_iff_ne_zero.2 (hS s.2)
{ f.lift h with
map_zero' := by convert f.lift_eq (P := Γ) _ 0 <;> simp [f]
map_add_le_max' := fun x y => by
obtain ⟨a, b, s, rfl, rfl⟩ : ∃ (a b : A) (s : S), f.mk' a s = x ∧ f.mk' b s = y := by
obtain ⟨a, s, rfl⟩ := f.mk'_surjective x
obtain ⟨b, t, rfl⟩ := f.mk'_surjective y
use a * t, b * s, s * t
constructor <;>
· rw [f.mk'_eq_iff_eq, Submonoid.coe_mul]
ring_nf
convert_to f.lift h (f.mk' (a + b) s) ≤ max (f.lift h _) (f.lift h _)
· refine congr_arg (f.lift h) (IsLocalization.eq_mk'_iff_mul_eq.2 ?_)
rw [add_mul, map_add]
rw [← IsLocalization.toLocalizationMap_apply S B, f.mk'_spec, f.mk'_spec,
IsLocalization.toLocalizationMap_apply,
IsLocalization.toLocalizationMap_apply]
iterate 3 rw [f.lift_mk']
dsimp
grw [max_mul_mul_right, v.map_add a b] }
@[simp]
theorem Valuation.extendToLocalization_mk' (x : A) (y : S) :
(v.extendToLocalization hS B) (IsLocalization.mk' _ x y) =
v x * (v y)⁻¹ :=
(Submonoid.LocalizationMap.lift_mk' _ _ _ _).trans (by simp [IsUnit.coe_liftRight])
@[simp]
theorem Valuation.extendToLocalization_apply_map_apply (a : A) :
v.extendToLocalization hS B (algebraMap A B a) = v a :=
Submonoid.LocalizationMap.lift_eq _ _ a |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Archimedean.lean | import Mathlib.GroupTheory.ArchimedeanDensely
import Mathlib.RingTheory.Valuation.ValuationRing
/-!
# Ring of integers under a given valuation in an multiplicatively archimedean codomain
-/
section Field
variable {F Γ₀ O : Type*} [Field F] [LinearOrderedCommGroupWithZero Γ₀]
[CommRing O] [Algebra O F] {v : Valuation F Γ₀}
instance MonoidWithZeroHom.instLinearOrderedCommGroupWithZeroMrange (v : F →*₀ Γ₀) :
LinearOrderedCommGroupWithZero (MonoidHom.mrange v) where
__ : CommGroupWithZero (MonoidHom.mrange v) := inferInstance
__ : LinearOrder (MonoidHom.mrange v) := inferInstance
bot := ⟨⊥, by simp [bot_eq_zero'']⟩
bot_le a := by simp [bot_eq_zero'', ← Subtype.coe_le_coe]
zero_le_one := Subtype.coe_le_coe.mp zero_le_one
mul_le_mul_left := by
simp only [Subtype.forall, MonoidHom.mem_mrange, forall_exists_index, Submonoid.mk_mul_mk,
Subtype.mk_le_mk, forall_apply_eq_imp_iff]
intro a b hab c
gcongr
instance Valuation.instLinearOrderedCommGroupWithZeroMrange :
LinearOrderedCommGroupWithZero (MonoidHom.mrange v) :=
inferInstanceAs (LinearOrderedCommGroupWithZero (MonoidHom.mrange (v : F →*₀ Γ₀)))
namespace Valuation.Integers
open scoped Function in
lemma wfDvdMonoid_iff_wellFounded_gt_on_v (hv : Integers v O) :
WfDvdMonoid O ↔ WellFounded ((· > ·) on (v ∘ algebraMap O F)) := by
refine ⟨fun _ ↦ wellFounded_dvdNotUnit.mono ?_, fun h ↦ ⟨h.mono ?_⟩⟩ <;>
simp [Function.onFun, hv.dvdNotUnit_iff_lt]
open scoped Function WithZero in
lemma wellFounded_gt_on_v_iff_discrete_mrange [Nontrivial (MonoidHom.mrange v)ˣ]
(hv : Integers v O) :
WellFounded ((· > ·) on (v ∘ algebraMap O F)) ↔
Nonempty (MonoidHom.mrange v ≃*o ℤᵐ⁰) := by
rw [← LinearOrderedCommGroupWithZero.wellFoundedOn_setOf_ge_gt_iff_nonempty_discrete_of_ne_zero
one_ne_zero, ← Set.wellFoundedOn_range]
classical
refine ⟨fun h ↦ (h.mapsTo Subtype.val ?_).mono' (by simp), fun h ↦ (h.mapsTo ?_ ?_).mono' ?_⟩
· rintro ⟨_, x, rfl⟩
simp only [← Subtype.coe_le_coe, OneMemClass.coe_one, Set.mem_setOf_eq, Set.mem_range,
Function.comp_apply]
intro hx
obtain ⟨y, rfl⟩ := hv.exists_of_le_one hx
exact ⟨y, by simp⟩
· exact fun x ↦ if hx : x ∈ MonoidHom.mrange v then ⟨x, hx⟩ else 1
· intro
simp only [Set.mem_range, Function.comp_apply, MonoidHom.mem_mrange, Set.mem_setOf_eq,
forall_exists_index]
rintro x rfl
simp [← Subtype.coe_le_coe, hv.map_le_one]
· simp [Function.onFun]
lemma isPrincipalIdealRing_iff_not_denselyOrdered [MulArchimedean (MonoidHom.mrange v)]
(hv : Integers v O) :
IsPrincipalIdealRing O ↔ ¬ DenselyOrdered (Set.range v) := by
refine ⟨fun _ ↦ not_denselyOrdered_of_isPrincipalIdealRing hv, fun H ↦ ?_⟩
rcases subsingleton_or_nontrivial (MonoidHom.mrange v)ˣ with hs|_
· have := bijective_algebraMap_of_subsingleton_units_mrange hv
exact .of_surjective _ (RingEquiv.ofBijective _ this).symm.surjective
have : IsDomain O := hv.hom_inj.isDomain
have : ValuationRing O := ValuationRing.of_integers v hv
have : IsBezout O := ValuationRing.instIsBezout
have := ((IsBezout.TFAE (R := O)).out 1 3)
rw [this, hv.wfDvdMonoid_iff_wellFounded_gt_on_v, hv.wellFounded_gt_on_v_iff_discrete_mrange,
LinearOrderedCommGroupWithZero.discrete_iff_not_denselyOrdered]
exact H
lemma isPrincipalIdealRing_iff_not_denselyOrdered_mrange [MulArchimedean (MonoidHom.mrange v)]
(hv : Integers v O) :
IsPrincipalIdealRing O ↔ ¬ DenselyOrdered (MonoidHom.mrange v) :=
isPrincipalIdealRing_iff_not_denselyOrdered hv
end Valuation.Integers
end Field |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/IntegrallyClosed.lean | import Mathlib.RingTheory.Valuation.Integral
deprecated_module (since := "2025-09-07") |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/LocalSubring.lean | import Mathlib.RingTheory.Ideal.GoingUp
import Mathlib.RingTheory.LocalRing.LocalSubring
import Mathlib.RingTheory.Polynomial.Ideal
import Mathlib.RingTheory.Valuation.ValuationSubring
/-!
# Valuation subrings are exactly the maximal local subrings
See `LocalSubring.isMax_iff`.
Note that the order on local subrings is not merely inclusion but domination.
-/
open IsLocalRing
variable {R S K : Type*} [CommRing R] [CommRing S] [Field K]
/-- Cast a valuation subring to a local subring. -/
def ValuationSubring.toLocalSubring (A : ValuationSubring K) : LocalSubring K where
toSubring := A.toSubring
isLocalRing := A.isLocalRing
lemma ValuationSubring.toLocalSubring_injective :
Function.Injective (ValuationSubring.toLocalSubring (K := K)) :=
fun _ _ h ↦ ValuationSubring.toSubring_injective congr(($h).toSubring)
lemma LocalSubring.map_maximalIdeal_eq_top_of_isMax {R : LocalSubring K}
(hR : IsMax R) {S : Subring K} (hS : R.toSubring < S) :
(maximalIdeal R.toSubring).map (Subring.inclusion hS.le) = ⊤ := by
let mR := (maximalIdeal R.toSubring).map (Subring.inclusion hS.le)
by_contra h_is_not_top
obtain ⟨M, h_is_max, h_incl⟩ := Ideal.exists_le_maximal _ h_is_not_top
let fSₘ : LocalSubring K := LocalSubring.ofPrime S M
have h_RleSₘ : R ≤ fSₘ := by
refine ⟨hS.le.trans (LocalSubring.le_ofPrime _ _), ⟨?_⟩⟩
rintro ⟨a, h_a_inR⟩ h_fa_isUnit
apply (IsLocalization.AtPrime.isUnit_to_map_iff _ M ⟨a, hS.le h_a_inR⟩).mp at h_fa_isUnit
by_contra h
rw [← mem_nonunits_iff, ← mem_maximalIdeal] at h
apply Ideal.mem_map_of_mem (Subring.inclusion hS.le) at h
exact h_fa_isUnit (h_incl h)
have h_RneSₘ : R ≠ fSₘ :=
fun e ↦ (hS.trans_le (LocalSubring.le_ofPrime S M)).ne congr(($e).toSubring)
exact h_RneSₘ (hR.eq_of_le h_RleSₘ)
@[stacks 00IC]
lemma LocalSubring.mem_of_isMax_of_isIntegral {R : LocalSubring K}
(hR : IsMax R) {x : K} (hx : IsIntegral R.toSubring x) : x ∈ R.toSubring := by
let S := Algebra.adjoin R.toSubring {x}
have : Algebra.IsIntegral R.toSubring S := Algebra.IsIntegral.adjoin (by simpa)
have : FaithfulSMul R.toSubring S := NoZeroSMulDivisors.instFaithfulSMulOfNontrivial
obtain ⟨Q : Ideal S.toSubring, hQ, e⟩ := Ideal.exists_ideal_over_maximal_of_isIntegral
(R := R.toSubring) (S := S) (maximalIdeal _) (le_maximalIdeal (by simp))
have : R = .ofPrime S.toSubring Q := by
have hRS : R.toSubring ≤ S.toSubring := fun r hr ↦ algebraMap_mem S ⟨r, hr⟩
apply hR.eq_of_le ⟨hRS.trans (LocalSubring.le_ofPrime _ _), ⟨?_⟩⟩
intro r hr
have := (IsLocalization.AtPrime.isUnit_to_map_iff (R := S.toSubring) _ Q ⟨_, hRS r.2⟩).mp hr
by_contra h
rw [← mem_nonunits_iff, ← mem_maximalIdeal, ← e] at h
exact this h
rw [this]
exact LocalSubring.le_ofPrime _ _ (Algebra.self_mem_adjoin_singleton _ _)
@[stacks 052K]
lemma ValuationSubring.isMax_toLocalSubring (R : ValuationSubring K) :
IsMax R.toLocalSubring := by
intro S hS
suffices R.toLocalSubring = S from this.ge
refine LocalSubring.toSubring_injective (le_antisymm hS.1 ?_)
intro x hx
refine (R.2 x).elim id fun h ↦ ?_
by_contra h'
have hx0 : x ≠ 0 := by rintro rfl; exact h' (zero_mem R)
have : IsUnit (Subring.inclusion hS.1 ⟨x⁻¹, h⟩) :=
isUnit_iff_exists_inv.mpr ⟨⟨x, hx⟩, Subtype.ext (inv_mul_cancel₀ hx0)⟩
obtain ⟨x', hx'⟩ := isUnit_iff_exists_inv.mp (hS.2.1 _ this)
have : x'.1 = x := by simpa [Subtype.ext_iff, inv_mul_eq_iff_eq_mul₀ hx0] using hx'
exact h' (this ▸ x'.2)
@[stacks 00IB]
lemma LocalSubring.exists_valuationRing_of_isMax {R : LocalSubring K} (hR : IsMax R) :
∃ R' : ValuationSubring K, R'.toLocalSubring = R := by
suffices ∀ x ∉ R.toSubring, x⁻¹ ∈ R.toSubring from
⟨⟨R.toSubring, fun x ↦ or_iff_not_imp_left.mpr (this x)⟩, rfl⟩
intro x hx
have hx0 : x ≠ 0 := fun e ↦ hx (e ▸ zero_mem _)
apply mem_of_isMax_of_isIntegral hR
let S := Algebra.adjoin R.toSubring {x}
have : R.toSubring < S.toSubring := SetLike.lt_iff_le_and_exists.mpr
⟨fun r hr ↦ algebraMap_mem S ⟨r, hr⟩, ⟨x, Algebra.self_mem_adjoin_singleton _ _, hx⟩⟩
have := map_maximalIdeal_eq_top_of_isMax hR this
rw [Ideal.eq_top_iff_one] at this
obtain ⟨p, hp, hp'⟩ := (Algebra.mem_ideal_map_adjoin _ _).mp this
have := IsUnit.invertible (isUnit_iff_ne_zero.mpr hx0)
have : Polynomial.aeval (⅟x) (p - 1).reverse = 0 := by
simpa [← Polynomial.aeval_def, hp'] using
Polynomial.eval₂_reverse_eq_zero_iff (algebraMap R.toSubring K) x (p - 1)
rw [invOf_eq_right_inv (mul_inv_cancel₀ hx0)] at this
have H : IsUnit ((p - 1).coeff 0) := by
by_contra h
simpa using sub_mem (hp 0) h
refine ⟨.C (H.unit⁻¹).1 * (p - 1).reverse, ?_, ?_⟩
· have : (p - 1).natTrailingDegree = 0 := by
simp only [Polynomial.natTrailingDegree_eq_zero,
Polynomial.coeff_sub, Polynomial.coeff_one_zero, ne_eq, sub_eq_zero]
exact .inr fun h ↦ (IsLocalRing.notMem_maximalIdeal.mpr isUnit_one (h ▸ hp 0))
rw [Polynomial.Monic.def, Polynomial.leadingCoeff_mul', Polynomial.reverse_leadingCoeff,
Polynomial.trailingCoeff, this]
· simp
· have : p - 1 ≠ 0 := fun e ↦ by simp [e] at H
simpa
· simp [← Polynomial.aeval_def, this]
/-- A local subring is maximal with respect to the domination order
if and only if it is a valuation ring. -/
lemma LocalSubring.isMax_iff {A : LocalSubring K} :
IsMax A ↔ ∃ B : ValuationSubring K, B.toLocalSubring = A :=
⟨exists_valuationRing_of_isMax, fun ⟨B, e⟩ ↦ e ▸ B.isMax_toLocalSubring⟩
@[stacks 00IA]
lemma LocalSubring.exists_le_valuationSubring (A : LocalSubring K) :
∃ B : ValuationSubring K, A ≤ B.toLocalSubring := by
suffices ∃ B, A ≤ B ∧ IsMax B by
obtain ⟨B, hB, hB'⟩ := this
obtain ⟨B, rfl⟩ := B.exists_valuationRing_of_isMax hB'
exact ⟨B, hB⟩
refine zorn_le_nonempty_Ici₀ _ ?_ _ le_rfl
intro s hs H y hys
have inst : Nonempty s := ⟨⟨y, hys⟩⟩
have hdir := H.directed.mono_comp _ LocalSubring.toSubring_mono
refine ⟨@LocalSubring.mk _ _ (⨆ i : s, i.1.toSubring) ⟨?_⟩, ?_⟩
· intro ⟨a, ha⟩ ⟨b, hb⟩ e
obtain ⟨A, haA : a ∈ A.1.toSubring⟩ := (Subring.mem_iSup_of_directed hdir).mp ha
obtain ⟨B, hbB : b ∈ B.1.toSubring⟩ := (Subring.mem_iSup_of_directed hdir).mp hb
obtain ⟨C, hCA, hCB⟩ := hdir A B
refine (C.1.2.2 (a := ⟨a, hCA haA⟩) (b := ⟨b, hCB hbB⟩) (Subtype.ext congr(($e).1))).imp ?_ ?_
· exact fun h ↦ h.map (Subring.inclusion (le_iSup (fun i : s ↦ i.1.toSubring) C))
· exact fun h ↦ h.map (Subring.inclusion (le_iSup (fun i : s ↦ i.1.toSubring) C))
· intro A hA
refine ⟨le_iSup (fun i : s ↦ i.1.toSubring) ⟨A, hA⟩, ⟨?_⟩⟩
rintro ⟨a, haA⟩ h
obtain ⟨⟨b, hb⟩, e⟩ := isUnit_iff_exists_inv.mp h
obtain ⟨B, hbB : b ∈ B.1.toSubring⟩ := (Subring.mem_iSup_of_directed hdir).mp hb
obtain ⟨C, hCA, hCB⟩ := H.directed ⟨A, hA⟩ B
apply hCA.2.1
exact isUnit_iff_exists_inv.mpr ⟨⟨b, hCB.1 hbB⟩, Subtype.ext congr(($e).1)⟩
lemma bijective_rangeRestrict_comp_of_valuationRing [IsDomain R] [ValuationRing R]
[IsLocalRing S] [Algebra R K] [IsFractionRing R K]
(f : R →+* S) (g : S →+* K) (h : g.comp f = algebraMap R K) [IsLocalHom f] :
Function.Bijective (g.rangeRestrict.comp f) := by
refine ⟨?_, ?_⟩
· exact .of_comp (f := Subtype.val) (by convert (IsFractionRing.injective R K); rw [← h]; rfl)
· let V : ValuationSubring K :=
⟨(algebraMap R K).range, ValuationRing.isInteger_or_isInteger R⟩
suffices LocalSubring.range g ≤ V.toLocalSubring by
rintro ⟨_, x, rfl⟩
obtain ⟨y, hy⟩ := this.1 ⟨x, rfl⟩
exact ⟨y, Subtype.ext (by simpa [← h] using hy)⟩
apply V.isMax_toLocalSubring
have H : (algebraMap R K).range ≤ g.range := fun x ⟨a, ha⟩ ↦ ⟨f a, by simp [← ha, ← h]⟩
refine ⟨H, ⟨?_⟩⟩
rintro ⟨_, a, rfl⟩ (ha : IsUnit (M := g.range) ⟨algebraMap R K a, _⟩)
suffices IsUnit a from this.map (algebraMap R K).rangeRestrict
apply IsUnit.of_map f
apply (IsLocalHom.of_surjective g.rangeRestrict g.rangeRestrict_surjective).1
convert ha
simp [← h]
lemma IsLocalRing.exists_factor_valuationRing [IsLocalRing R] (f : R →+* K) :
∃ (A : ValuationSubring K) (h : _), IsLocalHom (f.codRestrict A.toSubring h) := by
obtain ⟨B, hB⟩ := (LocalSubring.range f).exists_le_valuationSubring
refine ⟨B, fun x ↦ hB.1 ⟨x, rfl⟩, ?_⟩
exact @RingHom.isLocalHom_comp _ _ _ _ _ _ _ _
hB.2 (.of_surjective _ f.rangeRestrict_surjective) |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Extension.lean | import Mathlib.RingTheory.Valuation.ValuationSubring
/-!
# Extension of Valuations
In this file, we define the typeclass for valuation extensions and prove basic facts about the
extension of valuations. Let `A` be an `R` algebra, equipped with valuations `vA` and `vR`
respectively. Here, the extension of a valuation means that the pullback of valuation `vA` to `R`
is equivalent to the valuation `vR` on `R`. We only require equivalence, not equality, of
valuations here.
Note that we do not require the ring map from `R` to `A` to be injective. This holds automatically
when `R` is a division ring and `A` is nontrivial.
A motivation for choosing the more flexible `Valuation.Equiv` rather than strict equality here is
to allow for possible normalization. As an example, consider a finite extension `K` of `ℚ_[p]`,
which is a discretely valued field. We may choose the valuation on `K` to be either:
1. the valuation where the uniformizer is mapped to one (more precisely, `-1` in `ℤᵐ⁰`) or
2. the valuation where `p` is mapped to one.
For the algebraic closure of `ℚ_[p]`, if we choose the valuation of `p` to be one, then the
restriction of this valuation to `K` equals the second valuation, but is only equivalent to the
first valuation. The flexibility of equivalence here allows us to develop theory for both cases
without first determining the normalizations once and for all.
## Main Definition
* `Valuation.HasExtension vR vA` : The valuation `vA` on `A` is an extension of the valuation
`vR` on `R`.
## References
* [Bourbaki, Nicolas. *Commutative algebra*] Chapter VI §3, Valuations.
* <https://en.wikipedia.org/wiki/Valuation_(algebra)#Extension_of_valuations>
## Tags
Valuation, Extension of Valuations
-/
namespace Valuation
variable {R A ΓR ΓA : Type*} [CommRing R] [Ring A]
[LinearOrderedCommMonoidWithZero ΓR] [LinearOrderedCommMonoidWithZero ΓA] [Algebra R A]
(vR : Valuation R ΓR) (vA : Valuation A ΓA)
/--
The class `Valuation.HasExtension vR vA` states that the valuation `vA` on `A` is an extension of
the valuation `vR` on `R`. More precisely, `vR` is equivalent to the comap of the valuation `vA`.
-/
class HasExtension : Prop where
/-- The valuation `vR` on `R` is equivalent to the comap of the valuation `vA` on `A` -/
val_isEquiv_comap : vR.IsEquiv <| vA.comap (algebraMap R A)
namespace HasExtension
section algebraMap
variable [vR.HasExtension vA]
-- @[simp] does not work because `vR` cannot be inferred from `R`.
theorem val_map_le_iff (x y : R) : vA (algebraMap R A x) ≤ vA (algebraMap R A y) ↔ vR x ≤ vR y :=
val_isEquiv_comap.symm x y
theorem val_map_lt_iff (x y : R) : vA (algebraMap R A x) < vA (algebraMap R A y) ↔ vR x < vR y := by
simpa only [not_le] using ((val_map_le_iff vR vA _ _).not)
theorem val_map_eq_iff (x y : R) : vA (algebraMap R A x) = vA (algebraMap R A y) ↔ vR x = vR y :=
(IsEquiv.val_eq val_isEquiv_comap).symm
theorem val_map_le_one_iff (x : R) : vA (algebraMap R A x) ≤ 1 ↔ vR x ≤ 1 := by
simpa only [map_one] using val_map_le_iff vR vA x 1
theorem val_map_lt_one_iff (x : R) : vA (algebraMap R A x) < 1 ↔ vR x < 1 := by
simpa only [map_one, not_le] using (val_map_le_iff vR vA 1 x).not
theorem val_map_eq_one_iff (x : R) : vA (algebraMap R A x) = 1 ↔ vR x = 1 := by
simpa only [le_antisymm_iff, map_one] using
and_congr (val_map_le_iff vR vA x 1) (val_map_le_iff vR vA 1 x)
end algebraMap
instance id : vR.HasExtension vR where
val_isEquiv_comap := by
simp only [Algebra.algebraMap_self, comap_id, IsEquiv.refl]
section integer
variable {K : Type*} [Field K] [Algebra K A] {ΓR ΓA ΓK : Type*}
[LinearOrderedCommGroupWithZero ΓR] [LinearOrderedCommGroupWithZero ΓK]
[LinearOrderedCommGroupWithZero ΓA] {vR : Valuation R ΓR} {vK : Valuation K ΓK}
{vA : Valuation A ΓA} [vR.HasExtension vA]
/--
When `K` is a field, if the preimage of the valuation integers of `A` equals to the valuation
integers of `K`, then the valuation on `A` is an extension of the valuation on `K`.
-/
theorem ofComapInteger (h : vA.integer.comap (algebraMap K A) = vK.integer) :
vK.HasExtension vA where
val_isEquiv_comap := by
rw [isEquiv_iff_val_le_one]
intro x
simp_rw [← Valuation.mem_integer_iff, ← h, Subring.mem_comap, mem_integer_iff, comap_apply]
instance instAlgebraInteger : Algebra vR.integer vA.integer where
smul r a := ⟨r • a,
Algebra.smul_def r (a : A) ▸ mul_mem ((val_map_le_one_iff vR vA _).mpr r.2) a.2⟩
algebraMap := (algebraMap R A).restrict vR.integer vA.integer
(by simp [Valuation.mem_integer_iff, val_map_le_one_iff vR vA])
commutes' _ _ := Subtype.ext (Algebra.commutes _ _)
smul_def' _ _ := Subtype.ext (Algebra.smul_def _ _)
@[simp, norm_cast]
theorem val_smul (r : vR.integer) (a : vA.integer) : ↑(r • a : vA.integer) = (r : R) • (a : A) := by
rfl
@[simp, norm_cast]
theorem val_algebraMap (r : vR.integer) :
((algebraMap vR.integer vA.integer) r : A) = (algebraMap R A) (r : R) := by
rfl
instance instIsScalarTowerInteger : IsScalarTower vR.integer vA.integer A where
smul_assoc x y z := by
simp only [Algebra.smul_def]
exact mul_assoc _ _ _
instance instNoZeroSMulDivisorsInteger [NoZeroSMulDivisors R A] :
NoZeroSMulDivisors vR.integer vA.integer := by
refine ⟨fun {x y} e ↦ ?_⟩
have : (x : R) • (y : A) = 0 := by simpa [Subtype.ext_iff, Algebra.smul_def] using e
simpa only [Subtype.ext_iff, smul_eq_zero] using this
theorem algebraMap_injective [vK.HasExtension vA] [Nontrivial A] :
Function.Injective (algebraMap vK.integer vA.integer) :=
FaithfulSMul.algebraMap_injective _ _
@[instance]
theorem instIsLocalHomValuationInteger {S ΓS : Type*} [CommRing S]
[LinearOrderedCommGroupWithZero ΓS]
[Algebra R S] [IsLocalHom (algebraMap R S)] {vS : Valuation S ΓS}
[vR.HasExtension vS] : IsLocalHom (algebraMap vR.integer vS.integer) where
map_nonunit r hr := by
apply (Valuation.integer.integers (v := vR)).isUnit_of_one
· exact (isUnit_map_iff (algebraMap R S) _).mp (hr.map (algebraMap _ S))
· apply (Valuation.integer.integers (v := vS)).one_of_isUnit at hr
exact (val_map_eq_one_iff vR vS _).mp hr
end integer
section AlgebraInstances
open IsLocalRing Valuation ValuationSubring
variable {K L Γ₀ Γ₁ : outParam Type*} [Field K] [Field L] [Algebra K L]
[LinearOrderedCommGroupWithZero Γ₀] [LinearOrderedCommGroupWithZero Γ₁] (vK : Valuation K Γ₀)
(vL : Valuation L Γ₁) [vK.HasExtension vL]
local notation "K₀" => Valuation.valuationSubring vK
local notation "L₀" => Valuation.valuationSubring vL
lemma algebraMap_mem_valuationSubring (x : K₀) : algebraMap K L x ∈ L₀ := by
rw [mem_valuationSubring_iff, ← _root_.map_one vL, ← _root_.map_one (algebraMap K L),
val_map_le_iff (vR := vK), _root_.map_one]
exact x.2
instance instAlgebra_valuationSubring : Algebra K₀ L₀ :=
inferInstanceAs (Algebra vK.integer vL.integer)
@[simp]
lemma coe_algebraMap_valuationSubring_eq (x : K₀) :
(algebraMap K₀ L₀ x : L) = algebraMap K L (x : K) := rfl
instance instIsScalarTower_valuationSubring : IsScalarTower K₀ K L :=
inferInstanceAs (IsScalarTower vK.integer K L)
instance instIsScalarTower_valuationSubring' : IsScalarTower K₀ L₀ L :=
instIsScalarTowerInteger
instance : IsLocalHom (algebraMap K₀ L₀) := instIsLocalHomValuationInteger
lemma algebraMap_mem_maximalIdeal_iff {x : K₀} :
algebraMap K₀ L₀ x ∈ (maximalIdeal L₀) ↔ x ∈ maximalIdeal K₀ := by
simp [mem_maximalIdeal, map_mem_nonunits_iff, _root_.mem_nonunits_iff]
lemma maximalIdeal_comap_algebraMap_eq_maximalIdeal :
(maximalIdeal L₀).comap (algebraMap K₀ L₀) = maximalIdeal K₀ :=
Ideal.ext fun _ ↦ by rw [Ideal.mem_comap, algebraMap_mem_maximalIdeal_iff]
instance : Ideal.LiesOver (maximalIdeal L₀) (maximalIdeal K₀) :=
⟨(maximalIdeal_comap_algebraMap_eq_maximalIdeal _ _).symm⟩
lemma algebraMap_residue_eq_residue_algebraMap (x : K₀) :
(algebraMap (ResidueField K₀) (ResidueField L₀)) (IsLocalRing.residue K₀ x) =
IsLocalRing.residue L₀ (algebraMap K₀ L₀ x) :=
rfl
end AlgebraInstances
end HasExtension
end Valuation |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/ValuationSubring.lean | import Mathlib.RingTheory.Valuation.ValuationRing
import Mathlib.RingTheory.Localization.AsSubring
import Mathlib.Algebra.Algebra.Subalgebra.Tower
import Mathlib.Algebra.Ring.Subring.Pointwise
import Mathlib.Algebra.Ring.Action.Field
import Mathlib.RingTheory.LocalRing.ResidueField.Basic
/-!
# Valuation subrings of a field
## Projects
The order structure on `ValuationSubring K`.
-/
universe u
noncomputable section
variable (K : Type u) [Field K]
/-- A valuation subring of a field `K` is a subring `A` such that for every `x : K`,
either `x ∈ A` or `x⁻¹ ∈ A`.
This is equivalent to being maximal in the domination order
of local subrings (the stacks project definition). See `LocalSubring.isMax_iff`.
-/
structure ValuationSubring extends Subring K where
mem_or_inv_mem' : ∀ x : K, x ∈ carrier ∨ x⁻¹ ∈ carrier
namespace ValuationSubring
variable {K}
variable (A : ValuationSubring K)
instance : SetLike (ValuationSubring K) K where
coe A := A.toSubring
coe_injective' := by
intro ⟨_, _⟩ ⟨_, _⟩ h
replace h := SetLike.coe_injective' h
congr
theorem mem_carrier (x : K) : x ∈ A.carrier ↔ x ∈ A := Iff.refl _
@[simp]
theorem mem_toSubring (x : K) : x ∈ A.toSubring ↔ x ∈ A := Iff.refl _
@[ext]
theorem ext (A B : ValuationSubring K) (h : ∀ x, x ∈ A ↔ x ∈ B) : A = B := SetLike.ext h
theorem zero_mem : (0 : K) ∈ A := A.toSubring.zero_mem
theorem one_mem : (1 : K) ∈ A := A.toSubring.one_mem
theorem add_mem (x y : K) : x ∈ A → y ∈ A → x + y ∈ A := A.toSubring.add_mem
theorem mul_mem (x y : K) : x ∈ A → y ∈ A → x * y ∈ A := A.toSubring.mul_mem
theorem neg_mem (x : K) : x ∈ A → -x ∈ A := A.toSubring.neg_mem
theorem mem_or_inv_mem (x : K) : x ∈ A ∨ x⁻¹ ∈ A := A.mem_or_inv_mem' _
instance : SubringClass (ValuationSubring K) K where
zero_mem := zero_mem
add_mem {_} a b := add_mem _ a b
one_mem := one_mem
mul_mem {_} a b := mul_mem _ a b
neg_mem {_} x := neg_mem _ x
theorem toSubring_injective : Function.Injective (toSubring : ValuationSubring K → Subring K) :=
fun x y h => by cases x; cases y; congr
instance : CommRing A := inferInstanceAs <| CommRing A.toSubring
instance : IsDomain A := inferInstanceAs <| IsDomain A.toSubring
instance : Top (ValuationSubring K) :=
Top.mk <| { (⊤ : Subring K) with mem_or_inv_mem' := fun _ => Or.inl trivial }
theorem mem_top (x : K) : x ∈ (⊤ : ValuationSubring K) :=
trivial
theorem le_top : A ≤ ⊤ := fun _a _ha => mem_top _
instance : OrderTop (ValuationSubring K) where
le_top := le_top
instance : Inhabited (ValuationSubring K) :=
⟨⊤⟩
instance : ValuationRing A where
cond' a b := by
by_cases h : (b : K) = 0
· use 0
left
ext
simp [h]
by_cases h : (a : K) = 0
· use 0; right
ext
simp [h]
rcases A.mem_or_inv_mem (a / b) with hh | hh
· use ⟨a / b, hh⟩
right
ext
simp [field]
· rw [show (a / b : K)⁻¹ = b / a by simp] at hh
use ⟨b / a, hh⟩
left
ext
simp [field]
instance : Algebra A K := inferInstanceAs <| Algebra A.toSubring K
instance isLocalRing : IsLocalRing A := inferInstance
@[simp]
theorem algebraMap_apply (a : A) : algebraMap A K a = a := rfl
instance : IsFractionRing A K where
map_units := fun ⟨y, hy⟩ =>
(Units.mk0 (y : K) fun c => nonZeroDivisors.ne_zero hy <| Subtype.ext c).isUnit
surj z := by
by_cases h : z = 0; · use (0, 1); simp [h]
rcases A.mem_or_inv_mem z with hh | hh
· use (⟨z, hh⟩, 1); simp
· refine ⟨⟨1, ⟨⟨_, hh⟩, ?_⟩⟩, mul_inv_cancel₀ h⟩
exact mem_nonZeroDivisors_iff_ne_zero.2 fun c => h (inv_eq_zero.mp (congr_arg Subtype.val c))
exists_of_eq {a b} h := ⟨1, by ext; simpa using h⟩
/-- The value group of the valuation associated to `A`. Note: it is actually a group with zero. -/
def ValueGroup :=
ValuationRing.ValueGroup A K
deriving LinearOrderedCommGroupWithZero
/-- Any valuation subring of `K` induces a natural valuation on `K`. -/
def valuation : Valuation K A.ValueGroup :=
ValuationRing.valuation A K
instance inhabitedValueGroup : Inhabited A.ValueGroup := ⟨A.valuation 0⟩
theorem valuation_le_one (a : A) : A.valuation a ≤ 1 :=
(ValuationRing.mem_integer_iff A K _).2 ⟨a, rfl⟩
theorem mem_of_valuation_le_one (x : K) (h : A.valuation x ≤ 1) : x ∈ A :=
let ⟨a, ha⟩ := (ValuationRing.mem_integer_iff A K x).1 h
ha ▸ a.2
theorem valuation_le_one_iff (x : K) : A.valuation x ≤ 1 ↔ x ∈ A :=
⟨mem_of_valuation_le_one _ _, fun ha => A.valuation_le_one ⟨x, ha⟩⟩
theorem valuation_eq_iff (x y : K) : A.valuation x = A.valuation y ↔ ∃ a : Aˣ, (a : K) * y = x :=
Quotient.eq''
theorem valuation_le_iff (x y : K) : A.valuation x ≤ A.valuation y ↔ ∃ a : A, (a : K) * y = x :=
Iff.rfl
theorem valuation_surjective : Function.Surjective A.valuation := Quot.mk_surjective
theorem valuation_unit (a : Aˣ) : A.valuation a = 1 := by
rw [← A.valuation.map_one, valuation_eq_iff]; use a; simp
theorem valuation_eq_one_iff (a : A) : IsUnit a ↔ A.valuation a = 1 where
mp h := A.valuation_unit h.unit
mpr h := by
have ha : (a : K) ≠ 0 := by
intro c
rw [c, A.valuation.map_zero] at h
exact zero_ne_one h
have ha' : (a : K)⁻¹ ∈ A := by rw [← valuation_le_one_iff, map_inv₀, h, inv_one]
refine .of_mul_eq_one ⟨a⁻¹, ha'⟩ ?_
ext
simp [field]
theorem valuation_lt_one_or_eq_one (a : A) : A.valuation a < 1 ∨ A.valuation a = 1 :=
lt_or_eq_of_le (A.valuation_le_one a)
theorem valuation_lt_one_iff (a : A) : a ∈ IsLocalRing.maximalIdeal A ↔ A.valuation a < 1 := by
rw [IsLocalRing.mem_maximalIdeal]
dsimp [nonunits]; rw [valuation_eq_one_iff]
exact (A.valuation_le_one a).lt_iff_ne.symm
/-- A subring `R` of `K` such that for all `x : K` either `x ∈ R` or `x⁻¹ ∈ R` is
a valuation subring of `K`. -/
def ofSubring (R : Subring K) (hR : ∀ x : K, x ∈ R ∨ x⁻¹ ∈ R) : ValuationSubring K :=
{ R with mem_or_inv_mem' := hR }
@[simp]
theorem mem_ofSubring (R : Subring K) (hR : ∀ x : K, x ∈ R ∨ x⁻¹ ∈ R) (x : K) :
x ∈ ofSubring R hR ↔ x ∈ R :=
Iff.refl _
/-- An overring of a valuation ring is a valuation ring. -/
def ofLE (R : ValuationSubring K) (S : Subring K) (h : R.toSubring ≤ S) : ValuationSubring K :=
{ S with mem_or_inv_mem' := fun x => (R.mem_or_inv_mem x).imp (@h x) (@h _) }
section Order
instance : SemilatticeSup (ValuationSubring K) :=
{ (inferInstance : PartialOrder (ValuationSubring K)) with
sup := fun R S => ofLE R (R.toSubring ⊔ S.toSubring) <| le_sup_left
le_sup_left := fun R S _ hx => (le_sup_left : R.toSubring ≤ R.toSubring ⊔ S.toSubring) hx
le_sup_right := fun R S _ hx => (le_sup_right : S.toSubring ≤ R.toSubring ⊔ S.toSubring) hx
sup_le := fun R S T hR hT _ hx => (sup_le hR hT : R.toSubring ⊔ S.toSubring ≤ T.toSubring) hx }
/-- The ring homomorphism induced by the partial order. -/
def inclusion (R S : ValuationSubring K) (h : R ≤ S) : R →+* S :=
Subring.inclusion h
/-- The canonical ring homomorphism from a valuation ring to its field of fractions. -/
def subtype (R : ValuationSubring K) : R →+* K :=
Subring.subtype R.toSubring
@[simp]
lemma subtype_apply {R : ValuationSubring K} (x : R) :
R.subtype x = x := rfl
lemma subtype_injective (R : ValuationSubring K) :
Function.Injective R.subtype :=
R.toSubring.subtype_injective
@[simp]
theorem coe_subtype (R : ValuationSubring K) : ⇑(subtype R) = Subtype.val :=
rfl
/-- The canonical map on value groups induced by a coarsening of valuation rings. -/
def mapOfLE (R S : ValuationSubring K) (h : R ≤ S) : R.ValueGroup →*₀ S.ValueGroup where
toFun := Quotient.map' id fun _ _ ⟨u, hu⟩ => ⟨Units.map (R.inclusion S h).toMonoidHom u, hu⟩
map_zero' := rfl
map_one' := rfl
map_mul' := by rintro ⟨⟩ ⟨⟩; rfl
@[mono]
theorem monotone_mapOfLE (R S : ValuationSubring K) (h : R ≤ S) : Monotone (R.mapOfLE S h) := by
rintro ⟨⟩ ⟨⟩ ⟨a, ha⟩; exact ⟨R.inclusion S h a, ha⟩
@[simp]
theorem mapOfLE_comp_valuation (R S : ValuationSubring K) (h : R ≤ S) :
R.mapOfLE S h ∘ R.valuation = S.valuation := by ext; rfl
@[simp]
theorem mapOfLE_valuation_apply (R S : ValuationSubring K) (h : R ≤ S) (x : K) :
R.mapOfLE S h (R.valuation x) = S.valuation x := rfl
/-- The ideal corresponding to a coarsening of a valuation ring. -/
def idealOfLE (R S : ValuationSubring K) (h : R ≤ S) : Ideal R :=
(IsLocalRing.maximalIdeal S).comap (R.inclusion S h)
instance prime_idealOfLE (R S : ValuationSubring K) (h : R ≤ S) : (idealOfLE R S h).IsPrime :=
(IsLocalRing.maximalIdeal S).comap_isPrime _
/-- The coarsening of a valuation ring associated to a prime ideal. -/
def ofPrime (A : ValuationSubring K) (P : Ideal A) [P.IsPrime] : ValuationSubring K :=
ofLE A (Localization.subalgebra.ofField K _ P.primeCompl_le_nonZeroDivisors).toSubring
fun a ha => Subalgebra.mem_toSubring.mpr <|
Subalgebra.algebraMap_mem
(Localization.subalgebra.ofField K _ P.primeCompl_le_nonZeroDivisors) (⟨a, ha⟩ : A)
instance ofPrimeAlgebra (A : ValuationSubring K) (P : Ideal A) [P.IsPrime] :
Algebra A (A.ofPrime P) :=
Subalgebra.algebra (Localization.subalgebra.ofField K _ P.primeCompl_le_nonZeroDivisors)
instance ofPrime_scalar_tower (A : ValuationSubring K) (P : Ideal A) [P.IsPrime] :
letI : SMul A (A.ofPrime P) := SMulZeroClass.toSMul
IsScalarTower A (A.ofPrime P) K :=
IsScalarTower.subalgebra' A K K
(Localization.subalgebra.ofField K _ P.primeCompl_le_nonZeroDivisors)
instance ofPrime_localization (A : ValuationSubring K) (P : Ideal A) [P.IsPrime] :
IsLocalization.AtPrime (A.ofPrime P) P := by
apply
Localization.subalgebra.isLocalization_ofField K P.primeCompl
P.primeCompl_le_nonZeroDivisors
theorem le_ofPrime (A : ValuationSubring K) (P : Ideal A) [P.IsPrime] : A ≤ ofPrime A P :=
fun a ha => Subalgebra.mem_toSubring.mpr <| Subalgebra.algebraMap_mem _ (⟨a, ha⟩ : A)
theorem ofPrime_valuation_eq_one_iff_mem_primeCompl (A : ValuationSubring K) (P : Ideal A)
[P.IsPrime] (x : A) : (ofPrime A P).valuation x = 1 ↔ x ∈ P.primeCompl := by
rw [← IsLocalization.AtPrime.isUnit_to_map_iff (A.ofPrime P) P x, valuation_eq_one_iff]; rfl
@[simp]
theorem idealOfLE_ofPrime (A : ValuationSubring K) (P : Ideal A) [P.IsPrime] :
idealOfLE A (ofPrime A P) (le_ofPrime A P) = P := by
refine Ideal.ext (fun x => ?_)
apply IsLocalization.AtPrime.to_map_mem_maximal_iff
exact isLocalRing (ofPrime A P)
@[simp]
theorem ofPrime_idealOfLE (R S : ValuationSubring K) (h : R ≤ S) :
ofPrime R (idealOfLE R S h) = S := by
ext x; constructor
· rintro ⟨a, r, hr, rfl⟩; apply mul_mem; · exact h a.2
· rw [← valuation_le_one_iff, map_inv₀, ← inv_one, inv_le_inv₀]
· exact not_lt.1 ((not_iff_not.2 <| valuation_lt_one_iff S _).1 hr)
· simpa [Valuation.pos_iff] using fun hr₀ ↦ hr₀ ▸ hr <| Ideal.zero_mem (R.idealOfLE S h)
· exact zero_lt_one
· intro hx; by_cases hr : x ∈ R; · exact R.le_ofPrime _ hr
have : x ≠ 0 := fun h => hr (by rw [h]; exact R.zero_mem)
replace hr := (R.mem_or_inv_mem x).resolve_left hr
refine ⟨1, ⟨x⁻¹, hr⟩, ?_, ?_⟩
· simp only [Ideal.primeCompl, Submonoid.mem_mk, Subsemigroup.mem_mk, Set.mem_compl_iff,
SetLike.mem_coe, idealOfLE, Ideal.mem_comap, IsLocalRing.mem_maximalIdeal, mem_nonunits_iff,
not_not]
change IsUnit (⟨x⁻¹, h hr⟩ : S)
refine .of_mul_eq_one (⟨x, hx⟩ : S) ?_
ext
simp [field]
· simp
theorem ofPrime_le_of_le (P Q : Ideal A) [P.IsPrime] [Q.IsPrime] (h : P ≤ Q) :
ofPrime A Q ≤ ofPrime A P := fun _x ⟨a, s, hs, he⟩ => ⟨a, s, fun c => hs (h c), he⟩
theorem idealOfLE_le_of_le (R S : ValuationSubring K) (hR : A ≤ R) (hS : A ≤ S) (h : R ≤ S) :
idealOfLE A S hS ≤ idealOfLE A R hR := fun x hx =>
(valuation_lt_one_iff R _).2
(by
by_contra! c; replace c := monotone_mapOfLE R S h c
rw [(mapOfLE _ _ _).map_one, mapOfLE_valuation_apply] at c
apply not_le_of_gt ((valuation_lt_one_iff S _).1 hx) c)
/-- The equivalence between coarsenings of a valuation ring and its prime ideals. -/
@[simps apply]
def primeSpectrumEquiv : PrimeSpectrum A ≃ {S // A ≤ S} where
toFun P := ⟨ofPrime A P.asIdeal, le_ofPrime _ _⟩
invFun S := ⟨idealOfLE _ S S.2, inferInstance⟩
left_inv P := by ext1; simp
right_inv S := by ext1; simp
/-- An ordered variant of `primeSpectrumEquiv`. -/
@[simps!]
def primeSpectrumOrderEquiv : (PrimeSpectrum A)ᵒᵈ ≃o {S // A ≤ S} :=
{ OrderDual.ofDual.trans (primeSpectrumEquiv A) with
map_rel_iff' {a b} :=
⟨a.rec <| fun a => b.rec <| fun b => fun h => by
simp only [OrderDual.toDual_le_toDual]
dsimp at h
have := idealOfLE_le_of_le A _ _ ?_ ?_ h
· rwa [idealOfLE_ofPrime, idealOfLE_ofPrime] at this
all_goals exact le_ofPrime A (PrimeSpectrum.asIdeal _),
fun h => by apply ofPrime_le_of_le; exact h⟩ }
instance le_total_ideal : IsTotal {S // A ≤ S} LE.le := by
classical
let _ : IsTotal (PrimeSpectrum A) (· ≤ ·) := ⟨fun ⟨x, _⟩ ⟨y, _⟩ => LE.isTotal.total x y⟩
exact ⟨(primeSpectrumOrderEquiv A).symm.toRelEmbedding.isTotal.total⟩
open scoped Classical in
instance linearOrderOverring : LinearOrder {S // A ≤ S} where
le_total := (le_total_ideal A).1
max_def a b := congr_fun₂ sup_eq_maxDefault a b
toDecidableLE := _
end Order
end ValuationSubring
namespace Valuation
variable {K}
variable {Γ Γ₁ Γ₂ : Type*} [LinearOrderedCommGroupWithZero Γ]
[LinearOrderedCommGroupWithZero Γ₁] [LinearOrderedCommGroupWithZero Γ₂] (v : Valuation K Γ)
(v₁ : Valuation K Γ₁) (v₂ : Valuation K Γ₂)
/-- The valuation subring associated to a valuation. -/
def valuationSubring : ValuationSubring K :=
{ v.integer with
mem_or_inv_mem' := by
intro x
rcases val_le_one_or_val_inv_le_one v x with h | h
exacts [Or.inl h, Or.inr h] }
@[simp]
theorem mem_valuationSubring_iff (x : K) : x ∈ v.valuationSubring ↔ v x ≤ 1 := Iff.refl _
theorem isEquiv_iff_valuationSubring :
v₁.IsEquiv v₂ ↔ v₁.valuationSubring = v₂.valuationSubring := by
constructor
· intro h; ext x; specialize h x 1; simpa using h
· intro h; apply isEquiv_of_val_le_one
intro x
have : x ∈ v₁.valuationSubring ↔ x ∈ v₂.valuationSubring := by rw [h]
simpa using this
theorem isEquiv_valuation_valuationSubring : v.IsEquiv v.valuationSubring.valuation := by
rw [isEquiv_iff_val_le_one]
intro x
rw [ValuationSubring.valuation_le_one_iff, mem_valuationSubring_iff]
lemma valuationSubring.integers : v.Integers v.valuationSubring :=
Valuation.integer.integers _
end Valuation
namespace ValuationSubring
variable {K}
variable (A : ValuationSubring K)
@[simp]
theorem valuationSubring_valuation : A.valuation.valuationSubring = A := by
ext; rw [← A.valuation_le_one_iff]; rfl
section UnitGroup
/-- The unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def unitGroup : Subgroup Kˣ :=
(A.valuation.toMonoidWithZeroHom.toMonoidHom.comp (Units.coeHom K)).ker
@[simp]
theorem mem_unitGroup_iff (x : Kˣ) : x ∈ A.unitGroup ↔ A.valuation x = 1 := Iff.rfl
/-- For a valuation subring `A`, `A.unitGroup` agrees with the units of `A`. -/
def unitGroupMulEquiv : A.unitGroup ≃* Aˣ where
toFun x :=
{ val := ⟨(x : Kˣ), mem_of_valuation_le_one A _ x.prop.le⟩
inv := ⟨((x⁻¹ : A.unitGroup) : Kˣ), mem_of_valuation_le_one _ _ x⁻¹.prop.le⟩
val_inv := Subtype.ext (by simp)
inv_val := Subtype.ext (by simp) }
invFun x := ⟨Units.map A.subtype.toMonoidHom x, A.valuation_unit x⟩
map_mul' a b := by ext; rfl
@[simp]
theorem coe_unitGroupMulEquiv_apply (a : A.unitGroup) :
((A.unitGroupMulEquiv a : A) : K) = ((a : Kˣ) : K) := rfl
@[simp]
theorem coe_unitGroupMulEquiv_symm_apply (a : Aˣ) : ((A.unitGroupMulEquiv.symm a : Kˣ) : K) = a :=
rfl
theorem unitGroup_le_unitGroup {A B : ValuationSubring K} : A.unitGroup ≤ B.unitGroup ↔ A ≤ B := by
constructor
· intro h x hx
rw [← A.valuation_le_one_iff x, le_iff_lt_or_eq] at hx
by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
by_cases h_2 : 1 + x = 0
· simp only [← add_eq_zero_iff_neg_eq.1 h_2, neg_mem _ _ (one_mem _)]
rcases hx with hx | hx
· have := h (show Units.mk0 _ h_2 ∈ A.unitGroup from A.valuation.map_one_add_of_lt hx)
simpa using
B.add_mem _ _ (show 1 + x ∈ B from SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B))
(B.neg_mem _ B.one_mem)
· have := h (show Units.mk0 x h_1 ∈ A.unitGroup from hx)
exact SetLike.coe_mem (B.unitGroupMulEquiv ⟨_, this⟩ : B)
· rintro h x (hx : A.valuation x = 1)
apply_fun A.mapOfLE B h at hx
simpa using hx
theorem unitGroup_injective : Function.Injective (unitGroup : ValuationSubring K → Subgroup _) :=
fun A B h => by simpa only [le_antisymm_iff, unitGroup_le_unitGroup] using h
theorem eq_iff_unitGroup {A B : ValuationSubring K} : A = B ↔ A.unitGroup = B.unitGroup :=
unitGroup_injective.eq_iff.symm
/-- The map on valuation subrings to their unit groups is an order embedding. -/
def unitGroupOrderEmbedding : ValuationSubring K ↪o Subgroup Kˣ where
toFun A := A.unitGroup
inj' := unitGroup_injective
map_rel_iff' {_A _B} := unitGroup_le_unitGroup
theorem unitGroup_strictMono : StrictMono (unitGroup : ValuationSubring K → Subgroup _) :=
unitGroupOrderEmbedding.strictMono
end UnitGroup
section nonunits
/-- The nonunits of a valuation subring of `K`, as a subsemigroup of `K` -/
def nonunits : Subsemigroup K where
carrier := {x | A.valuation x < 1}
mul_mem' ha hb := (mul_lt_mul'' (Set.mem_setOf.mp ha) (Set.mem_setOf.mp hb)
zero_le' zero_le').trans_eq <| mul_one _
theorem mem_nonunits_iff {x : K} : x ∈ A.nonunits ↔ A.valuation x < 1 :=
Iff.rfl
theorem nonunits_le_nonunits {A B : ValuationSubring K} : B.nonunits ≤ A.nonunits ↔ A ≤ B := by
constructor
· intro h x hx
by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1] at hx ⊢
by_contra h_2; exact hx (h h_2)
· intro h x hx
by_contra h_1; exact not_lt.2 (monotone_mapOfLE _ _ h (not_lt.1 h_1)) hx
theorem nonunits_injective : Function.Injective (nonunits : ValuationSubring K → Subsemigroup _) :=
fun A B h => by simpa only [le_antisymm_iff, nonunits_le_nonunits] using h.symm
theorem nonunits_inj {A B : ValuationSubring K} : A.nonunits = B.nonunits ↔ A = B :=
nonunits_injective.eq_iff
/-- The map on valuation subrings to their nonunits is a dual order embedding. -/
def nonunitsOrderEmbedding : ValuationSubring K ↪o (Subsemigroup K)ᵒᵈ where
toFun A := A.nonunits
inj' := nonunits_injective
map_rel_iff' {_A _B} := nonunits_le_nonunits
variable {A}
/-- The elements of `A.nonunits` are those of the maximal ideal of `A` after coercion to `K`.
See also `mem_nonunits_iff_exists_mem_maximalIdeal`, which gets rid of the coercion to `K`,
at the expense of a more complicated right-hand side.
-/
theorem coe_mem_nonunits_iff {a : A} : (a : K) ∈ A.nonunits ↔ a ∈ IsLocalRing.maximalIdeal A :=
(valuation_lt_one_iff _ _).symm
theorem nonunits_le : A.nonunits ≤ A.toSubring.toSubmonoid.toSubsemigroup := fun _a ha =>
(A.valuation_le_one_iff _).mp (A.mem_nonunits_iff.mp ha).le
theorem nonunits_subset : (A.nonunits : Set K) ⊆ A :=
nonunits_le
/-- The elements of `A.nonunits` are those of the maximal ideal of `A`.
See also `coe_mem_nonunits_iff`, which has a simpler right-hand side but requires the element
to be in `A` already.
-/
theorem mem_nonunits_iff_exists_mem_maximalIdeal {a : K} :
a ∈ A.nonunits ↔ ∃ ha, (⟨a, ha⟩ : A) ∈ IsLocalRing.maximalIdeal A :=
⟨fun h => ⟨nonunits_subset h, coe_mem_nonunits_iff.mp h⟩, fun ⟨_, h⟩ =>
coe_mem_nonunits_iff.mpr h⟩
/-- `A.nonunits` agrees with the maximal ideal of `A`, after taking its image in `K`. -/
theorem image_maximalIdeal : ((↑) : A → K) '' IsLocalRing.maximalIdeal A = A.nonunits := by
ext a
simp only [Set.mem_image, SetLike.mem_coe, mem_nonunits_iff_exists_mem_maximalIdeal]
rw [Subtype.exists]
simp_rw [exists_and_right, exists_eq_right]
end nonunits
section PrincipalUnitGroup
/-- The principal unit group of a valuation subring, as a subgroup of `Kˣ`. -/
def principalUnitGroup : Subgroup Kˣ where
carrier := {x | A.valuation (x - 1) < 1}
mul_mem' := by
intro a b ha hb
rw [Set.mem_setOf] at ha hb ⊢
refine lt_of_le_of_lt ?_ (max_lt hb ha)
rw [← one_mul (A.valuation (b - 1)), ← A.valuation.map_one_add_of_lt ha, add_sub_cancel,
← Valuation.map_mul, mul_sub_one, ← sub_add_sub_cancel]
exact A.valuation.map_add _ _
one_mem' := by simp
inv_mem' := by
dsimp
intro a ha
conv =>
lhs
rw [← mul_one (A.valuation _), ← A.valuation.map_one_add_of_lt ha]
rwa [add_sub_cancel, ← Valuation.map_mul, sub_mul, Units.inv_mul, ← neg_sub, one_mul,
Valuation.map_neg]
theorem principal_units_le_units : A.principalUnitGroup ≤ A.unitGroup := fun a h => by
simpa only [add_sub_cancel] using A.valuation.map_one_add_of_lt h
theorem mem_principalUnitGroup_iff (x : Kˣ) :
x ∈ A.principalUnitGroup ↔ A.valuation ((x : K) - 1) < 1 :=
Iff.rfl
theorem principalUnitGroup_le_principalUnitGroup {A B : ValuationSubring K} :
B.principalUnitGroup ≤ A.principalUnitGroup ↔ A ≤ B := by
constructor
· intro h x hx
by_cases h_1 : x = 0; · simp only [h_1, zero_mem]
by_cases h_2 : x⁻¹ + 1 = 0
· rw [add_eq_zero_iff_eq_neg, inv_eq_iff_eq_inv, inv_neg, inv_one] at h_2
simpa only [h_2] using B.neg_mem _ B.one_mem
· rw [← valuation_le_one_iff, ← not_lt, Valuation.one_lt_val_iff _ h_1,
← add_sub_cancel_right x⁻¹, ← Units.val_mk0 h_2, ← mem_principalUnitGroup_iff] at hx ⊢
simpa only [hx] using @h (Units.mk0 (x⁻¹ + 1) h_2)
· intro h x hx
by_contra h_1; exact not_lt.2 (monotone_mapOfLE _ _ h (not_lt.1 h_1)) hx
theorem principalUnitGroup_injective :
Function.Injective (principalUnitGroup : ValuationSubring K → Subgroup _) := fun A B h => by
simpa [le_antisymm_iff, principalUnitGroup_le_principalUnitGroup] using h.symm
theorem eq_iff_principalUnitGroup {A B : ValuationSubring K} :
A = B ↔ A.principalUnitGroup = B.principalUnitGroup :=
principalUnitGroup_injective.eq_iff.symm
/-- The map on valuation subrings to their principal unit groups is an order embedding. -/
def principalUnitGroupOrderEmbedding : ValuationSubring K ↪o (Subgroup Kˣ)ᵒᵈ where
toFun A := A.principalUnitGroup
inj' := principalUnitGroup_injective
map_rel_iff' {_A _B} := principalUnitGroup_le_principalUnitGroup
theorem coe_mem_principalUnitGroup_iff {x : A.unitGroup} :
(x : Kˣ) ∈ A.principalUnitGroup ↔
A.unitGroupMulEquiv x ∈ (Units.map (IsLocalRing.residue A).toMonoidHom).ker := by
rw [MonoidHom.mem_ker, Units.ext_iff]
let π := Ideal.Quotient.mk (IsLocalRing.maximalIdeal A); convert_to _ ↔ π _ = 1
rw [← π.map_one, ← sub_eq_zero, ← π.map_sub, Ideal.Quotient.eq_zero_iff_mem, valuation_lt_one_iff]
simp [mem_principalUnitGroup_iff]
/-- The principal unit group agrees with the kernel of the canonical map from
the units of `A` to the units of the residue field of `A`. -/
def principalUnitGroupEquiv :
A.principalUnitGroup ≃* (Units.map (IsLocalRing.residue A).toMonoidHom).ker where
toFun x :=
⟨A.unitGroupMulEquiv ⟨_, A.principal_units_le_units x.2⟩,
A.coe_mem_principalUnitGroup_iff.1 x.2⟩
invFun x :=
⟨A.unitGroupMulEquiv.symm x, by
rw [A.coe_mem_principalUnitGroup_iff]; simp⟩
left_inv x := by simp
right_inv x := by simp
map_mul' _ _ := rfl
theorem principalUnitGroupEquiv_apply (a : A.principalUnitGroup) :
(((principalUnitGroupEquiv A a : Aˣ) : A) : K) = (a : Kˣ) :=
rfl
theorem principalUnitGroup_symm_apply (a : (Units.map (IsLocalRing.residue A).toMonoidHom).ker) :
((A.principalUnitGroupEquiv.symm a : Kˣ) : K) = ((a : Aˣ) : A) :=
rfl
/-- The canonical map from the unit group of `A` to the units of the residue field of `A`. -/
def unitGroupToResidueFieldUnits : A.unitGroup →* (IsLocalRing.ResidueField A)ˣ :=
MonoidHom.comp (Units.map <| (Ideal.Quotient.mk _).toMonoidHom) A.unitGroupMulEquiv.toMonoidHom
@[simp]
theorem coe_unitGroupToResidueFieldUnits_apply (x : A.unitGroup) :
(A.unitGroupToResidueFieldUnits x : IsLocalRing.ResidueField A) =
Ideal.Quotient.mk _ (A.unitGroupMulEquiv x : A) :=
rfl
theorem ker_unitGroupToResidueFieldUnits :
A.unitGroupToResidueFieldUnits.ker = A.principalUnitGroup.comap A.unitGroup.subtype := by
ext
simp_rw [Subgroup.mem_comap, Subgroup.coe_subtype, coe_mem_principalUnitGroup_iff,
unitGroupToResidueFieldUnits, IsLocalRing.residue, RingHom.toMonoidHom_eq_coe,
MulEquiv.toMonoidHom_eq_coe, MonoidHom.mem_ker, MonoidHom.coe_comp, MonoidHom.coe_coe,
Function.comp_apply]
theorem surjective_unitGroupToResidueFieldUnits :
Function.Surjective A.unitGroupToResidueFieldUnits :=
IsLocalRing.surjective_units_map_of_local_ringHom _ Ideal.Quotient.mk_surjective
(inferInstanceAs (IsLocalHom (IsLocalRing.residue A))) |>.comp (MulEquiv.surjective _)
/-- The quotient of the unit group of `A` by the principal unit group of `A` agrees with
the units of the residue field of `A`. -/
def unitsModPrincipalUnitsEquivResidueFieldUnits :
A.unitGroup ⧸ A.principalUnitGroup.comap A.unitGroup.subtype ≃* (IsLocalRing.ResidueField A)ˣ :=
(QuotientGroup.quotientMulEquivOfEq A.ker_unitGroupToResidueFieldUnits.symm).trans
(QuotientGroup.quotientKerEquivOfSurjective _ A.surjective_unitGroupToResidueFieldUnits)
theorem unitsModPrincipalUnitsEquivResidueFieldUnits_comp_quotientGroup_mk :
(A.unitsModPrincipalUnitsEquivResidueFieldUnits : _ ⧸ Subgroup.comap _ _ →* _).comp
(QuotientGroup.mk' (A.principalUnitGroup.subgroupOf A.unitGroup)) =
A.unitGroupToResidueFieldUnits := rfl
theorem unitsModPrincipalUnitsEquivResidueFieldUnits_comp_quotientGroup_mk_apply
(x : A.unitGroup) :
A.unitsModPrincipalUnitsEquivResidueFieldUnits.toMonoidHom (QuotientGroup.mk x) =
A.unitGroupToResidueFieldUnits x := rfl
end PrincipalUnitGroup
/-! ### Pointwise actions
This transfers the action from `Subring.pointwiseMulAction`, noting that it only applies when
the action is by a group. Notably this provides an instances when `G` is `K ≃+* K`.
These instances are in the `Pointwise` locale.
The lemmas in this section are copied from the file `Mathlib/Algebra/Ring/Subring/Pointwise.lean`;
try to keep these in sync.
-/
section PointwiseActions
open scoped Pointwise
variable {G : Type*} [Group G] [MulSemiringAction G K]
/-- The action on a valuation subring corresponding to applying the action to every element.
This is available as an instance in the `Pointwise` locale. -/
def pointwiseHasSMul : SMul G (ValuationSubring K) where
smul g S :=-- TODO: if we add `ValuationSubring.map` at a later date, we should use it here
{ g • S.toSubring with
mem_or_inv_mem' := fun x =>
(mem_or_inv_mem S (g⁻¹ • x)).imp Subring.mem_pointwise_smul_iff_inv_smul_mem.mpr fun h =>
Subring.mem_pointwise_smul_iff_inv_smul_mem.mpr <| by rwa [smul_inv''] }
scoped[Pointwise] attribute [instance] ValuationSubring.pointwiseHasSMul
open scoped Pointwise
@[simp]
theorem coe_pointwise_smul (g : G) (S : ValuationSubring K) : ↑(g • S) = g • (S : Set K) := rfl
@[simp]
theorem pointwise_smul_toSubring (g : G) (S : ValuationSubring K) :
(g • S).toSubring = g • S.toSubring := rfl
/-- The action on a valuation subring corresponding to applying the action to every element.
This is available as an instance in the `Pointwise` locale.
This is a stronger version of `ValuationSubring.pointwiseSMul`. -/
def pointwiseMulAction : MulAction G (ValuationSubring K) :=
toSubring_injective.mulAction toSubring pointwise_smul_toSubring
scoped[Pointwise] attribute [instance] ValuationSubring.pointwiseMulAction
open scoped Pointwise
theorem smul_mem_pointwise_smul (g : G) (x : K) (S : ValuationSubring K) : x ∈ S → g • x ∈ g • S :=
(Set.smul_mem_smul_set : _ → _ ∈ g • (S : Set K))
instance : CovariantClass G (ValuationSubring K) HSMul.hSMul LE.le :=
⟨fun _ _ _ => Set.image_mono⟩
theorem mem_smul_pointwise_iff_exists (g : G) (x : K) (S : ValuationSubring K) :
x ∈ g • S ↔ ∃ s : K, s ∈ S ∧ g • s = x :=
(Set.mem_smul_set : x ∈ g • (S : Set K) ↔ _)
instance pointwise_central_scalar [MulSemiringAction Gᵐᵒᵖ K] [IsCentralScalar G K] :
IsCentralScalar G (ValuationSubring K) :=
⟨fun g S => toSubring_injective <| op_smul_eq_smul g S.toSubring⟩
@[simp]
theorem smul_mem_pointwise_smul_iff {g : G} {S : ValuationSubring K} {x : K} :
g • x ∈ g • S ↔ x ∈ S := Set.smul_mem_smul_set_iff
theorem mem_pointwise_smul_iff_inv_smul_mem {g : G} {S : ValuationSubring K} {x : K} :
x ∈ g • S ↔ g⁻¹ • x ∈ S := Set.mem_smul_set_iff_inv_smul_mem
theorem mem_inv_pointwise_smul_iff {g : G} {S : ValuationSubring K} {x : K} :
x ∈ g⁻¹ • S ↔ g • x ∈ S := Set.mem_inv_smul_set_iff
@[simp]
theorem pointwise_smul_le_pointwise_smul_iff {g : G} {S T : ValuationSubring K} :
g • S ≤ g • T ↔ S ≤ T := Set.smul_set_subset_smul_set_iff
theorem pointwise_smul_subset_iff {g : G} {S T : ValuationSubring K} : g • S ≤ T ↔ S ≤ g⁻¹ • T :=
Set.smul_set_subset_iff_subset_inv_smul_set
theorem subset_pointwise_smul_iff {g : G} {S T : ValuationSubring K} : S ≤ g • T ↔ g⁻¹ • S ≤ T :=
Set.subset_smul_set_iff
end PointwiseActions
section
variable {L J : Type*} [Field L] [Field J]
/-- The pullback of a valuation subring `A` along a ring homomorphism `K →+* L`. -/
def comap (A : ValuationSubring L) (f : K →+* L) : ValuationSubring K :=
{ A.toSubring.comap f with mem_or_inv_mem' := fun k => by simp [ValuationSubring.mem_or_inv_mem] }
@[simp]
theorem coe_comap (A : ValuationSubring L) (f : K →+* L) : (A.comap f : Set K) = f ⁻¹' A := rfl
@[simp]
theorem mem_comap {A : ValuationSubring L} {f : K →+* L} {x : K} : x ∈ A.comap f ↔ f x ∈ A :=
Iff.rfl
theorem comap_comap (A : ValuationSubring J) (g : L →+* J) (f : K →+* L) :
(A.comap g).comap f = A.comap (g.comp f) := rfl
end
end ValuationSubring
namespace Valuation
variable {Γ : Type*} [LinearOrderedCommGroupWithZero Γ] (v : Valuation K Γ) (x : Kˣ)
theorem mem_unitGroup_iff : x ∈ v.valuationSubring.unitGroup ↔ v x = 1 :=
IsEquiv.eq_one_iff_eq_one (Valuation.isEquiv_valuation_valuationSubring _).symm
theorem mem_maximalIdeal_iff {a : v.valuationSubring} :
a ∈ IsLocalRing.maximalIdeal (v.valuationSubring) ↔ v a < 1 :=
Integer.not_isUnit_iff_valuation_lt_one
end Valuation |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Basic.lean | import Mathlib.Algebra.GroupWithZero.Submonoid.Instances
import Mathlib.Algebra.Order.Hom.Monoid
import Mathlib.Algebra.Order.Ring.Basic
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.Tactic.TFAE
/-!
# The basics of valuation theory.
The basic theory of valuations (non-archimedean norms) on a commutative ring,
following T. Wedhorn's unpublished notes “Adic Spaces” ([wedhorn_adic]).
The definition of a valuation we use here is Definition 1.22 of [wedhorn_adic].
A valuation on a ring `R` is a monoid homomorphism `v` to a linearly ordered
commutative monoid with zero, that in addition satisfies the following two axioms:
* `v 0 = 0`
* `∀ x y, v (x + y) ≤ max (v x) (v y)`
`Valuation R Γ₀` is the type of valuations `R → Γ₀`, with a coercion to the underlying
function. If `v` is a valuation from `R` to `Γ₀` then the induced group
homomorphism `Units(R) → Γ₀` is called `unit_map v`.
The equivalence "relation" `IsEquiv v₁ v₂ : Prop` defined in 1.27 of [wedhorn_adic] is not strictly
speaking a relation, because `v₁ : Valuation R Γ₁` and `v₂ : Valuation R Γ₂` might
not have the same type. This corresponds in ZFC to the set-theoretic difficulty
that the class of all valuations (as `Γ₀` varies) on a ring `R` is not a set.
The "relation" is however reflexive, symmetric and transitive in the obvious
sense. Note that we use 1.27(iii) of [wedhorn_adic] as the definition of equivalence.
## Main definitions
* `Valuation R Γ₀`, the type of valuations on `R` with values in `Γ₀`
* `Valuation.IsNontrivial` is the class of non-trivial valuations, namely those for which there
is an element in the ring whose valuation is `≠ 0` and `≠ 1`.
* `Valuation.IsEquiv`, the heterogeneous equivalence relation on valuations
* `Valuation.supp`, the support of a valuation
* `AddValuation R Γ₀`, the type of additive valuations on `R` with values in a
linearly ordered additive commutative group with a top element, `Γ₀`.
## Implementation Details
`AddValuation R Γ₀` is implemented as `Valuation R (Multiplicative Γ₀)ᵒᵈ`.
## Notation
In the `WithZero` locale, `Mᵐ⁰` is a shorthand for `WithZero (Multiplicative M)`.
## TODO
If ever someone extends `Valuation`, we should fully comply to the `DFunLike` by migrating the
boilerplate lemmas to `ValuationClass`.
-/
open Function Ideal
noncomputable section
variable {K F R : Type*} [DivisionRing K]
section
variable (F R) (Γ₀ : Type*) [LinearOrderedCommMonoidWithZero Γ₀] [Ring R]
/-- The type of `Γ₀`-valued valuations on `R`.
When you extend this structure, make sure to extend `ValuationClass`. -/
structure Valuation extends R →*₀ Γ₀ where
/-- The valuation of a sum is less than or equal to the maximum of the valuations. -/
map_add_le_max' : ∀ x y, toFun (x + y) ≤ max (toFun x) (toFun y)
/-- `ValuationClass F α β` states that `F` is a type of valuations.
You should also extend this typeclass when you extend `Valuation`. -/
class ValuationClass (F) (R Γ₀ : outParam Type*) [LinearOrderedCommMonoidWithZero Γ₀] [Ring R]
[FunLike F R Γ₀] : Prop
extends MonoidWithZeroHomClass F R Γ₀ where
/-- The valuation of a sum is less than or equal to the maximum of the valuations. -/
map_add_le_max (f : F) (x y : R) : f (x + y) ≤ max (f x) (f y)
export ValuationClass (map_add_le_max)
instance [FunLike F R Γ₀] [ValuationClass F R Γ₀] : CoeTC F (Valuation R Γ₀) :=
⟨fun f =>
{ toFun := f
map_one' := map_one f
map_zero' := map_zero f
map_mul' := map_mul f
map_add_le_max' := map_add_le_max f }⟩
end
namespace Valuation
variable {Γ₀ : Type*}
variable {Γ'₀ : Type*}
variable {Γ''₀ : Type*} [LinearOrderedCommMonoidWithZero Γ''₀]
section Basic
variable [Ring R]
section Monoid
variable [LinearOrderedCommMonoidWithZero Γ₀] [LinearOrderedCommMonoidWithZero Γ'₀]
instance : FunLike (Valuation R Γ₀) R Γ₀ where
coe f := f.toFun
coe_injective' f g h := by
obtain ⟨⟨⟨_,_⟩, _⟩, _⟩ := f
congr
instance : ValuationClass (Valuation R Γ₀) R Γ₀ where
map_mul f := f.map_mul'
map_one f := f.map_one'
map_zero f := f.map_zero'
map_add_le_max f := f.map_add_le_max'
@[simp]
theorem coe_mk (f : R →*₀ Γ₀) (h) : ⇑(Valuation.mk f h) = f := rfl
theorem toFun_eq_coe (v : Valuation R Γ₀) : v.toFun = v := rfl
@[simp]
theorem toMonoidWithZeroHom_coe_eq_coe (v : Valuation R Γ₀) :
(v.toMonoidWithZeroHom : R → Γ₀) = v := rfl
@[ext]
theorem ext {v₁ v₂ : Valuation R Γ₀} (h : ∀ r, v₁ r = v₂ r) : v₁ = v₂ :=
DFunLike.ext _ _ h
variable (v : Valuation R Γ₀)
@[simp, norm_cast]
theorem coe_coe : ⇑(v : R →*₀ Γ₀) = v := rfl
protected theorem map_zero : v 0 = 0 :=
v.map_zero'
protected theorem map_one : v 1 = 1 :=
v.map_one'
protected theorem map_mul : ∀ x y, v (x * y) = v x * v y :=
v.map_mul'
-- `simp`-normal form is `map_add'`
protected theorem map_add : ∀ x y, v (x + y) ≤ max (v x) (v y) :=
v.map_add_le_max'
@[simp]
theorem map_add' : ∀ x y, v (x + y) ≤ v x ∨ v (x + y) ≤ v y := by
intro x y
rw [← le_max_iff, ← ge_iff_le]
apply v.map_add
theorem map_add_le {x y g} (hx : v x ≤ g) (hy : v y ≤ g) : v (x + y) ≤ g :=
le_trans (v.map_add x y) <| max_le hx hy
theorem map_add_lt {x y g} (hx : v x < g) (hy : v y < g) : v (x + y) < g :=
lt_of_le_of_lt (v.map_add x y) <| max_lt hx hy
theorem map_sum_le {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hf : ∀ i ∈ s, v (f i) ≤ g) :
v (∑ i ∈ s, f i) ≤ g := by
classical
refine
Finset.induction_on s (fun _ => v.map_zero ▸ zero_le')
(fun a s has ih hf => ?_) hf
rw [Finset.forall_mem_insert] at hf; rw [Finset.sum_insert has]
exact v.map_add_le hf.1 (ih hf.2)
theorem map_sum_lt {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hg : g ≠ 0)
(hf : ∀ i ∈ s, v (f i) < g) : v (∑ i ∈ s, f i) < g := by
classical
refine
Finset.induction_on s (fun _ => v.map_zero ▸ (zero_lt_iff.2 hg))
(fun a s has ih hf => ?_) hf
rw [Finset.forall_mem_insert] at hf; rw [Finset.sum_insert has]
exact v.map_add_lt hf.1 (ih hf.2)
theorem map_sum_lt' {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hg : 0 < g)
(hf : ∀ i ∈ s, v (f i) < g) : v (∑ i ∈ s, f i) < g :=
v.map_sum_lt (ne_of_gt hg) hf
protected theorem map_pow : ∀ (x) (n : ℕ), v (x ^ n) = v x ^ n :=
v.toMonoidWithZeroHom.toMonoidHom.map_pow
-- The following definition is not an instance, because we have more than one `v` on a given `R`.
-- In addition, type class inference would not be able to infer `v`.
/-- A valuation gives a preorder on the underlying ring. -/
def toPreorder : Preorder R :=
Preorder.lift v
/-- If `v` is a valuation on a division ring then `v(x) = 0` iff `x = 0`. -/
theorem zero_iff [Nontrivial Γ₀] (v : Valuation K Γ₀) {x : K} : v x = 0 ↔ x = 0 :=
map_eq_zero v
theorem ne_zero_iff [Nontrivial Γ₀] (v : Valuation K Γ₀) {x : K} : v x ≠ 0 ↔ x ≠ 0 :=
map_ne_zero v
lemma pos_iff [Nontrivial Γ₀] (v : Valuation K Γ₀) {x : K} : 0 < v x ↔ x ≠ 0 := by
rw [zero_lt_iff, ne_zero_iff]
theorem unit_map_eq (u : Rˣ) : (Units.map (v : R →* Γ₀) u : Γ₀) = v u :=
rfl
theorem ne_zero_of_unit [Nontrivial Γ₀] (v : Valuation K Γ₀) (x : Kˣ) : v x ≠ (0 : Γ₀) := by
simp only [ne_eq, Valuation.zero_iff, Units.ne_zero x, not_false_iff]
theorem ne_zero_of_isUnit [Nontrivial Γ₀] (v : Valuation K Γ₀) (x : K) (hx : IsUnit x) :
v x ≠ (0 : Γ₀) := by
simpa [hx.choose_spec] using ne_zero_of_unit v hx.choose
/-- A ring homomorphism `S → R` induces a map `Valuation R Γ₀ → Valuation S Γ₀`. -/
def comap {S : Type*} [Ring S] (f : S →+* R) (v : Valuation R Γ₀) : Valuation S Γ₀ :=
{ v.toMonoidWithZeroHom.comp f.toMonoidWithZeroHom with
toFun := v ∘ f
map_add_le_max' := fun x y => by simp only [comp_apply, v.map_add, map_add] }
@[simp]
theorem comap_apply {S : Type*} [Ring S] (f : S →+* R) (v : Valuation R Γ₀) (s : S) :
v.comap f s = v (f s) := rfl
@[simp]
theorem comap_id : v.comap (RingHom.id R) = v :=
ext fun _r => rfl
theorem comap_comp {S₁ : Type*} {S₂ : Type*} [Ring S₁] [Ring S₂] (f : S₁ →+* S₂) (g : S₂ →+* R) :
v.comap (g.comp f) = (v.comap g).comap f :=
ext fun _r => rfl
/-- A `≤`-preserving group homomorphism `Γ₀ → Γ'₀` induces a map `Valuation R Γ₀ → Valuation R Γ'₀`.
-/
def map (f : Γ₀ →*₀ Γ'₀) (hf : Monotone f) (v : Valuation R Γ₀) : Valuation R Γ'₀ :=
{ MonoidWithZeroHom.comp f v.toMonoidWithZeroHom with
toFun := f ∘ v
map_add_le_max' := fun r s =>
calc
f (v (r + s)) ≤ f (max (v r) (v s)) := hf (v.map_add r s)
_ = max (f (v r)) (f (v s)) := hf.map_max
}
@[simp]
lemma map_apply (f : Γ₀ →*₀ Γ'₀) (hf : Monotone f) (v : Valuation R Γ₀) (r : R) :
v.map f hf r = f (v r) := rfl
/-- Two valuations on `R` are defined to be equivalent if they induce the same preorder on `R`. -/
def IsEquiv (v₁ : Valuation R Γ₀) (v₂ : Valuation R Γ'₀) : Prop :=
∀ r s, v₁ r ≤ v₁ s ↔ v₂ r ≤ v₂ s
@[simp]
theorem map_neg (x : R) : v (-x) = v x :=
v.toMonoidWithZeroHom.toMonoidHom.map_neg x
theorem map_sub_swap (x y : R) : v (x - y) = v (y - x) :=
v.toMonoidWithZeroHom.toMonoidHom.map_sub_swap x y
theorem map_sub (x y : R) : v (x - y) ≤ max (v x) (v y) :=
calc
v (x - y) = v (x + -y) := by rw [sub_eq_add_neg]
_ ≤ max (v x) (v <| -y) := v.map_add _ _
_ = max (v x) (v y) := by rw [map_neg]
theorem map_sub_le {x y g} (hx : v x ≤ g) (hy : v y ≤ g) : v (x - y) ≤ g := by
rw [sub_eq_add_neg]
exact v.map_add_le hx <| (v.map_neg y).trans_le hy
theorem map_sub_lt {x y : R} {g : Γ₀} (hx : v x < g) (hy : v y < g) : v (x - y) < g := by
rw [sub_eq_add_neg]
exact v.map_add_lt hx <| (v.map_neg y).trans_lt hy
variable {x y : R}
@[simp]
lemma le_one_of_subsingleton [Subsingleton R] (v : Valuation R Γ₀) {x : R} :
v x ≤ 1 := by
rw [Subsingleton.elim x 1, Valuation.map_one]
theorem map_add_of_distinct_val (h : v x ≠ v y) : v (x + y) = max (v x) (v y) := by
suffices ¬v (x + y) < max (v x) (v y) from
or_iff_not_imp_right.1 (le_iff_eq_or_lt.1 (v.map_add x y)) this
intro h'
wlog vyx : v y < v x generalizing x y
· refine this h.symm ?_ (h.lt_or_gt.resolve_right vyx)
rwa [add_comm, max_comm]
rw [max_eq_left_of_lt vyx] at h'
apply lt_irrefl (v x)
calc
v x = v (x + y - y) := by simp
_ ≤ max (v <| x + y) (v y) := map_sub _ _ _
_ < v x := max_lt h' vyx
theorem map_add_eq_of_lt_right (h : v x < v y) : v (x + y) = v y :=
(v.map_add_of_distinct_val h.ne).trans (max_eq_right_iff.mpr h.le)
theorem map_add_eq_of_lt_left (h : v y < v x) : v (x + y) = v x := by
rw [add_comm]; exact map_add_eq_of_lt_right _ h
theorem map_sub_eq_of_lt_right (h : v x < v y) : v (x - y) = v y := by
rw [sub_eq_add_neg, map_add_eq_of_lt_right, map_neg]
rwa [map_neg]
theorem map_sum_eq_of_lt {ι : Type*} [DecidableEq ι] {s : Finset ι} {f : ι → R} {j : ι}
(hj : j ∈ s) (hf : ∀ i ∈ s \ {j}, v (f i) < v (f j)) :
v (∑ i ∈ s, f i) = v (f j) := by
rcases eq_or_ne (v (f j)) 0 with h0 | h0
· aesop
rw [Finset.sum_eq_add_sum_diff_singleton hj]
exact map_add_eq_of_lt_left _ (map_sum_lt _ h0 hf)
theorem map_sub_eq_of_lt_left (h : v y < v x) : v (x - y) = v x := by
rw [sub_eq_add_neg, map_add_eq_of_lt_left]
rwa [map_neg]
theorem map_eq_of_sub_lt (h : v (y - x) < v x) : v y = v x := by
have := Valuation.map_add_of_distinct_val v (ne_of_gt h).symm
rw [max_eq_right (le_of_lt h)] at this
simpa using this
lemma map_sub_of_left_eq_zero (hx : v x = 0) : v (x - y) = v y := by
by_cases hy : v y = 0
· simpa [*] using map_sub v x y
· simp [*, map_sub_eq_of_lt_right, zero_lt_iff]
lemma map_sub_of_right_eq_zero (hy : v y = 0) : v (x - y) = v x := by
rw [map_sub_swap, map_sub_of_left_eq_zero v hy]
lemma map_add_of_left_eq_zero (hx : v x = 0) : v (x + y) = v y := by
rw [← sub_neg_eq_add, map_sub_of_left_eq_zero v hx, map_neg]
lemma map_add_of_right_eq_zero (hy : v y = 0) : v (x + y) = v x := by
rw [add_comm, map_add_of_left_eq_zero v hy]
theorem map_one_add_of_lt (h : v x < 1) : v (1 + x) = 1 := by
rw [← v.map_one] at h
simpa only [v.map_one] using v.map_add_eq_of_lt_left h
theorem map_one_sub_of_lt (h : v x < 1) : v (1 - x) = 1 := by
rw [← v.map_one, ← v.map_neg] at h
rw [sub_eq_add_neg 1 x]
simpa only [v.map_one, v.map_neg] using v.map_add_eq_of_lt_left h
/-- An ordered monoid isomorphism `Γ₀ ≃ Γ'₀` induces an equivalence
`Valuation R Γ₀ ≃ Valuation R Γ'₀`. -/
def congr (f : Γ₀ ≃*o Γ'₀) : Valuation R Γ₀ ≃ Valuation R Γ'₀ where
toFun := map f f.toOrderIso.monotone
invFun := map f.symm f.toOrderIso.symm.monotone
left_inv ν := by ext; simp
right_inv ν := by ext; simp
section One
variable [Nontrivial R] [NoZeroDivisors R] [DecidablePred fun x : R ↦ x = 0]
variable (R Γ₀) in
/-- The trivial valuation, sending everything to 1 other than 0. -/
protected instance one : One (Valuation R Γ₀) where
one :=
{ __ : R →*₀ Γ₀ := 1
map_add_le_max' x y := by
simp only [ZeroHom.toFun_eq_coe, MonoidWithZeroHom.toZeroHom_coe,
MonoidWithZeroHom.one_apply_def, le_sup_iff]
split_ifs <;> simp_all }
lemma one_apply_def (x : R) : (1 : Valuation R Γ₀) x = if x = 0 then 0 else 1 := rfl
@[simp] lemma toMonoidWithZeroHom_one : (1 : Valuation R Γ₀).toMonoidWithZeroHom = 1 := rfl
lemma one_apply_of_ne_zero {x : R} (hx : x ≠ 0) : (1 : Valuation R Γ₀) x = 1 := if_neg hx
@[simp]
lemma one_apply_eq_zero_iff [Nontrivial Γ₀] {x : R} : (1 : Valuation R Γ₀) x = 0 ↔ x = 0 :=
MonoidWithZeroHom.one_apply_eq_zero_iff
lemma one_apply_le_one (x : R) : (1 : Valuation R Γ₀) x ≤ 1 := by
rw [one_apply_def]
split_ifs <;> simp_all
@[simp]
lemma one_apply_lt_one_iff [Nontrivial Γ₀] {x : R} : (1 : Valuation R Γ₀) x < 1 ↔ x = 0 := by
rw [one_apply_def]
split_ifs <;> simp_all
@[simp]
lemma one_apply_eq_one_iff [Nontrivial Γ₀] {x : R} : (1 : Valuation R Γ₀) x = 1 ↔ x ≠ 0 :=
MonoidWithZeroHom.one_apply_eq_one_iff
end One
end Monoid
section Group
variable [LinearOrderedCommGroupWithZero Γ₀] (v : Valuation R Γ₀) {x y : R}
theorem map_inv {R : Type*} [DivisionRing R] (v : Valuation R Γ₀) : ∀ x, v x⁻¹ = (v x)⁻¹ :=
map_inv₀ _
theorem map_div {R : Type*} [DivisionRing R] (v : Valuation R Γ₀) : ∀ x y, v (x / y) = v x / v y :=
map_div₀ _
theorem one_lt_val_iff (v : Valuation K Γ₀) {x : K} (h : x ≠ 0) : 1 < v x ↔ v x⁻¹ < 1 := by
simp [inv_lt_one₀ (v.pos_iff.2 h)]
theorem one_le_val_iff (v : Valuation K Γ₀) {x : K} (h : x ≠ 0) : 1 ≤ v x ↔ v x⁻¹ ≤ 1 := by
simp [inv_le_one₀ (v.pos_iff.2 h)]
theorem val_lt_one_iff (v : Valuation K Γ₀) {x : K} (h : x ≠ 0) : v x < 1 ↔ 1 < v x⁻¹ := by
simp [one_lt_inv₀ (v.pos_iff.2 h)]
theorem val_le_one_iff (v : Valuation K Γ₀) {x : K} (h : x ≠ 0) : v x ≤ 1 ↔ 1 ≤ v x⁻¹ := by
simp [one_le_inv₀ (v.pos_iff.2 h)]
theorem val_eq_one_iff (v : Valuation K Γ₀) {x : K} : v x = 1 ↔ v x⁻¹ = 1 := by
simp
theorem val_le_one_or_val_inv_lt_one (v : Valuation K Γ₀) (x : K) : v x ≤ 1 ∨ v x⁻¹ < 1 := by
by_cases h : x = 0
· simp only [h, map_zero, zero_le', inv_zero, zero_lt_one, or_self]
· simp only [← one_lt_val_iff v h, le_or_gt]
/--
This theorem is a weaker version of `Valuation.val_le_one_or_val_inv_lt_one`, but more symmetric
in `x` and `x⁻¹`.
-/
theorem val_le_one_or_val_inv_le_one (v : Valuation K Γ₀) (x : K) : v x ≤ 1 ∨ v x⁻¹ ≤ 1 := by
by_cases h : x = 0
· simp only [h, map_zero, zero_le', inv_zero, or_self]
· simp only [← one_le_val_iff v h, le_total]
/-- The subgroup of elements whose valuation is less than or equal to a certain value. -/
def leAddSubgroup (v : Valuation R Γ₀) (γ : Γ₀) : AddSubgroup R where
carrier := { x | v x ≤ γ }
zero_mem' := by simp
add_mem' {x y} x_in y_in := (v.map_add x y).trans (max_le x_in y_in)
neg_mem' x_in := by rwa [Set.mem_setOf, map_neg]
@[simp]
lemma mem_leAddSubgroup_iff {v : Valuation R Γ₀} {γ : Γ₀} {x : R} :
x ∈ v.leAddSubgroup γ ↔ v x ≤ γ :=
Iff.rfl
lemma leAddSubgroup_monotone (v : Valuation R Γ₀) : Monotone v.leAddSubgroup :=
fun _ _ h _ ↦ h.trans'
/-- The subgroup of elements whose valuation is less than a certain unit. -/
@[simps] def ltAddSubgroup (v : Valuation R Γ₀) (γ : Γ₀ˣ) : AddSubgroup R where
carrier := { x | v x < γ }
zero_mem' := by simp
add_mem' {x y} x_in y_in := lt_of_le_of_lt (v.map_add x y) (max_lt x_in y_in)
neg_mem' x_in := by rwa [Set.mem_setOf, map_neg]
@[simp] lemma mem_ltAddSubgroup_iff {v : Valuation R Γ₀} {γ x} :
x ∈ ltAddSubgroup v γ ↔ v x < γ :=
Iff.rfl
lemma ltAddSubgroup_monotone (v : Valuation R Γ₀) : Monotone v.ltAddSubgroup :=
fun _ _ h _ ↦ (Units.val_le_val.mpr h).trans_lt'
lemma ltAddSubgroup_le_leAddSubgroup (v : Valuation R Γ₀) (γ : Γ₀ˣ) :
v.ltAddSubgroup γ ≤ v.leAddSubgroup γ :=
fun _ h ↦ h.le
@[simp]
lemma leAddSubgroup_zero {K : Type*} [Field K] (v : Valuation K Γ₀) :
v.leAddSubgroup 0 = ⊥ := by
ext; simp
end Group
end Basic
section IsNontrivial
variable [Ring R] [LinearOrderedCommMonoidWithZero Γ₀] (v : Valuation R Γ₀)
/-- A valuation on a ring is nontrivial if there exists an element with valuation
not equal to `0` or `1`. -/
class IsNontrivial : Prop where
exists_val_nontrivial : ∃ x : R, v x ≠ 0 ∧ v x ≠ 1
lemma IsNontrivial.nontrivial_codomain [hv : IsNontrivial v] :
Nontrivial Γ₀ := by
obtain ⟨x, hx0, hx1⟩ := hv.exists_val_nontrivial
exact ⟨v x, 1, hx1⟩
lemma not_isNontrivial_one [IsDomain R] [DecidablePred fun x : R ↦ x = 0] :
¬(1 : Valuation R Γ₀).IsNontrivial := by
rintro ⟨⟨x, hx, hx'⟩⟩
rcases eq_or_ne x 0 with rfl | hx0 <;>
simp_all [one_apply_of_ne_zero]
section Field
variable {K : Type*} [Field K] {w : Valuation K Γ₀}
/-- For fields, being nontrivial is equivalent to the existence of a unit with valuation
not equal to `1`. -/
lemma isNontrivial_iff_exists_unit :
w.IsNontrivial ↔ ∃ x : Kˣ, w x ≠ 1 :=
⟨fun ⟨x, hx0, hx1⟩ ↦
have : Nontrivial Γ₀ := ⟨w x, 0, hx0⟩
⟨Units.mk0 x (w.ne_zero_iff.mp hx0), hx1⟩,
fun ⟨x, hx⟩ ↦
have : Nontrivial Γ₀ := ⟨w x, 1, hx⟩
⟨x, w.ne_zero_iff.mpr (Units.ne_zero x), hx⟩⟩
lemma IsNontrivial.exists_lt_one {Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀]
{v : Valuation K Γ₀} [hv : v.IsNontrivial] :
∃ x : K, v x ≠ 0 ∧ v x < 1 := by
obtain ⟨x, hx⟩ := isNontrivial_iff_exists_unit.mp hv
rw [ne_iff_lt_or_gt] at hx
rcases hx with hx | hx
· use x
simp [hx]
· use x⁻¹
simp [- map_inv₀, ← one_lt_val_iff, hx]
theorem isNontrivial_iff_exists_lt_one {Γ₀ : Type*}
[LinearOrderedCommGroupWithZero Γ₀] (v : Valuation K Γ₀) :
v.IsNontrivial ↔ ∃ x, x ≠ 0 ∧ v x < 1 :=
⟨fun h ↦ by simpa using h.exists_lt_one (v := v), fun ⟨x, hx0, hx1⟩ ↦ ⟨x, by simp [hx0, hx1.ne]⟩⟩
lemma IsNontrivial.exists_one_lt {Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀]
{v : Valuation K Γ₀} [hv : v.IsNontrivial] :
∃ x : K, v x ≠ 0 ∧ 1 < v x := by
obtain ⟨x, h0, h1⟩ := hv.exists_lt_one
use x⁻¹
simp [one_lt_inv₀ (zero_lt_iff.mpr h0), h0, h1]
end Field
end IsNontrivial
namespace IsEquiv
variable [Ring R] [LinearOrderedCommMonoidWithZero Γ₀] [LinearOrderedCommMonoidWithZero Γ'₀]
{v : Valuation R Γ₀} {v₁ : Valuation R Γ₀} {v₂ : Valuation R Γ'₀} {v₃ : Valuation R Γ''₀}
@[refl]
theorem refl : v.IsEquiv v := fun _ _ => Iff.refl _
@[symm]
theorem symm (h : v₁.IsEquiv v₂) : v₂.IsEquiv v₁ := fun _ _ => Iff.symm (h _ _)
@[trans]
theorem trans (h₁₂ : v₁.IsEquiv v₂) (h₂₃ : v₂.IsEquiv v₃) : v₁.IsEquiv v₃ := fun _ _ =>
Iff.trans (h₁₂ _ _) (h₂₃ _ _)
theorem of_eq {v' : Valuation R Γ₀} (h : v = v') : v.IsEquiv v' := by subst h; rfl
theorem map {v' : Valuation R Γ₀} (f : Γ₀ →*₀ Γ'₀) (hf : Monotone f) (inf : Injective f)
(h : v.IsEquiv v') : (v.map f hf).IsEquiv (v'.map f hf) :=
let H : StrictMono f := hf.strictMono_of_injective inf
fun r s =>
calc
f (v r) ≤ f (v s) ↔ v r ≤ v s := by rw [H.le_iff_le]
_ ↔ v' r ≤ v' s := h r s
_ ↔ f (v' r) ≤ f (v' s) := by rw [H.le_iff_le]
/-- `comap` preserves equivalence. -/
theorem comap {S : Type*} [Ring S] (f : S →+* R) (h : v₁.IsEquiv v₂) :
(v₁.comap f).IsEquiv (v₂.comap f) := fun r s => h (f r) (f s)
theorem val_eq (h : v₁.IsEquiv v₂) {r s : R} : v₁ r = v₁ s ↔ v₂ r = v₂ s := by
simpa only [le_antisymm_iff] using and_congr (h r s) (h s r)
theorem ne_zero (h : v₁.IsEquiv v₂) {r : R} : v₁ r ≠ 0 ↔ v₂ r ≠ 0 := by
have : v₁ r ≠ v₁ 0 ↔ v₂ r ≠ v₂ 0 := not_congr h.val_eq
rwa [v₁.map_zero, v₂.map_zero] at this
lemma lt_iff_lt (h : v₁.IsEquiv v₂) {x y : R} :
v₁ x < v₁ y ↔ v₂ x < v₂ y := by
rw [← le_iff_le_iff_lt_iff_lt, h]
lemma le_one_iff_le_one (h : v₁.IsEquiv v₂) {x : R} :
v₁ x ≤ 1 ↔ v₂ x ≤ 1 := by
rw [← v₁.map_one, h, map_one]
lemma eq_one_iff_eq_one (h : v₁.IsEquiv v₂) {x : R} :
v₁ x = 1 ↔ v₂ x = 1 := by
rw [← v₁.map_one, h.val_eq, map_one]
lemma lt_one_iff_lt_one (h : v₁.IsEquiv v₂) {x : R} :
v₁ x < 1 ↔ v₂ x < 1 := by
rw [← v₁.map_one, h.lt_iff_lt, map_one]
end IsEquiv
-- end of namespace
section
theorem isEquiv_of_map_strictMono [LinearOrderedCommMonoidWithZero Γ₀]
[LinearOrderedCommMonoidWithZero Γ'₀] [Ring R] {v : Valuation R Γ₀} (f : Γ₀ →*₀ Γ'₀)
(H : StrictMono f) : IsEquiv (v.map f H.monotone) v := fun _x _y =>
⟨H.le_iff_le.mp, fun h => H.monotone h⟩
theorem isEquiv_iff_val_lt_val [LinearOrderedCommMonoidWithZero Γ₀]
[LinearOrderedCommMonoidWithZero Γ'₀] {v : Valuation K Γ₀} {v' : Valuation K Γ'₀} :
v.IsEquiv v' ↔ ∀ {x y : K}, v x < v y ↔ v' x < v' y := by
simp only [IsEquiv, le_iff_le_iff_lt_iff_lt]
exact forall_comm
theorem isEquiv_of_val_le_one [LinearOrderedCommGroupWithZero Γ₀]
[LinearOrderedCommGroupWithZero Γ'₀] {v : Valuation K Γ₀} {v' : Valuation K Γ'₀}
(h : ∀ {x : K}, v x ≤ 1 ↔ v' x ≤ 1) : v.IsEquiv v' := by
intro x y
obtain rfl | hy := eq_or_ne y 0
· simp
· rw [← div_le_one₀, ← v.map_div, h, v'.map_div, div_le_one₀] <;>
rwa [zero_lt_iff, ne_zero_iff]
theorem isEquiv_iff_val_le_one [LinearOrderedCommGroupWithZero Γ₀]
[LinearOrderedCommGroupWithZero Γ'₀] {v : Valuation K Γ₀} {v' : Valuation K Γ'₀} :
v.IsEquiv v' ↔ ∀ {x : K}, v x ≤ 1 ↔ v' x ≤ 1 :=
⟨IsEquiv.le_one_iff_le_one, isEquiv_of_val_le_one⟩
theorem isEquiv_iff_val_eq_one [LinearOrderedCommGroupWithZero Γ₀]
[LinearOrderedCommGroupWithZero Γ'₀] {v : Valuation K Γ₀} {v' : Valuation K Γ'₀} :
v.IsEquiv v' ↔ ∀ {x : K}, v x = 1 ↔ v' x = 1 := by
constructor
· intro h x
rw [h.eq_one_iff_eq_one]
· intro h
apply isEquiv_of_val_le_one
intro x
constructor
· intro hx
rcases lt_or_eq_of_le hx with hx' | hx'
· have : v (1 + x) = 1 := by
rw [← v.map_one]
apply map_add_eq_of_lt_left
simpa
rw [h] at this
rw [show x = -1 + (1 + x) by simp]
refine le_trans (v'.map_add _ _) ?_
simp [this]
· rw [h] at hx'
exact le_of_eq hx'
· intro hx
rcases lt_or_eq_of_le hx with hx' | hx'
· have : v' (1 + x) = 1 := by
rw [← v'.map_one]
apply map_add_eq_of_lt_left
simpa
rw [← h] at this
rw [show x = -1 + (1 + x) by simp]
refine le_trans (v.map_add _ _) ?_
simp [this]
· rw [← h] at hx'
exact le_of_eq hx'
theorem isEquiv_iff_val_lt_one [LinearOrderedCommGroupWithZero Γ₀]
[LinearOrderedCommGroupWithZero Γ'₀] {v : Valuation K Γ₀} {v' : Valuation K Γ'₀} :
v.IsEquiv v' ↔ ∀ {x : K}, v x < 1 ↔ v' x < 1 := by
constructor
· intro h x
rw [h.lt_one_iff_lt_one]
· rw [isEquiv_iff_val_eq_one]
intro h x
by_cases hx : x = 0
· simp only [(zero_iff _).2 hx, zero_ne_one]
constructor
· intro hh
by_contra h_1
cases ne_iff_lt_or_gt.1 h_1 with
| inl h_2 => simpa [hh, lt_self_iff_false] using h.2 h_2
| inr h_2 =>
rw [← inv_one, ← inv_eq_iff_eq_inv, ← map_inv₀] at hh
exact hh.not_lt (h.2 ((one_lt_val_iff v' hx).1 h_2))
· intro hh
by_contra h_1
cases ne_iff_lt_or_gt.1 h_1 with
| inl h_2 => simpa [hh, lt_self_iff_false] using h.1 h_2
| inr h_2 =>
rw [← inv_one, ← inv_eq_iff_eq_inv, ← map_inv₀] at hh
exact hh.not_lt (h.1 ((one_lt_val_iff v hx).1 h_2))
theorem isEquiv_iff_val_sub_one_lt_one [LinearOrderedCommGroupWithZero Γ₀]
[LinearOrderedCommGroupWithZero Γ'₀] {v : Valuation K Γ₀} {v' : Valuation K Γ'₀} :
v.IsEquiv v' ↔ ∀ {x : K}, v (x - 1) < 1 ↔ v' (x - 1) < 1 := by
rw [isEquiv_iff_val_lt_one]
exact (Equiv.subRight 1).surjective.forall
alias ⟨IsEquiv.val_sub_one_lt_one_iff, _⟩ := isEquiv_iff_val_sub_one_lt_one
theorem isEquiv_tfae [LinearOrderedCommGroupWithZero Γ₀] [LinearOrderedCommGroupWithZero Γ'₀]
(v : Valuation K Γ₀) (v' : Valuation K Γ'₀) :
[ v.IsEquiv v',
∀ {x y}, v x < v y ↔ v' x < v' y,
∀ {x}, v x ≤ 1 ↔ v' x ≤ 1,
∀ {x}, v x = 1 ↔ v' x = 1,
∀ {x}, v x < 1 ↔ v' x < 1,
∀ {x}, v (x - 1) < 1 ↔ v' (x - 1) < 1 ].TFAE := by
tfae_have 1 ↔ 2 := isEquiv_iff_val_lt_val
tfae_have 1 ↔ 3 := isEquiv_iff_val_le_one
tfae_have 1 ↔ 4 := isEquiv_iff_val_eq_one
tfae_have 1 ↔ 5 := isEquiv_iff_val_lt_one
tfae_have 1 ↔ 6 := isEquiv_iff_val_sub_one_lt_one
tfae_finish
end
section Supp
variable [CommRing R] [LinearOrderedCommMonoidWithZero Γ₀] (v : Valuation R Γ₀)
/-- The support of a valuation `v : R → Γ₀` is the ideal of `R` where `v` vanishes. -/
def supp : Ideal R where
carrier := { x | v x = 0 }
zero_mem' := map_zero v
add_mem' {x y} hx hy := le_zero_iff.mp <|
calc
v (x + y) ≤ max (v x) (v y) := v.map_add x y
_ ≤ 0 := max_le (le_zero_iff.mpr hx) (le_zero_iff.mpr hy)
smul_mem' c x hx :=
calc
v (c * x) = v c * v x := map_mul v c x
_ = v c * 0 := congr_arg _ hx
_ = 0 := mul_zero _
@[simp]
theorem mem_supp_iff (x : R) : x ∈ supp v ↔ v x = 0 :=
Iff.rfl
/-- The support of a valuation is a prime ideal. -/
instance [Nontrivial Γ₀] [NoZeroDivisors Γ₀] : Ideal.IsPrime (supp v) :=
⟨fun h =>
one_ne_zero (α := Γ₀) <|
calc
1 = v 1 := v.map_one.symm
_ = 0 := by rw [← mem_supp_iff, h]; exact Submodule.mem_top,
fun {x y} hxy => by
simp only [mem_supp_iff] at hxy ⊢
rw [v.map_mul x y] at hxy
exact eq_zero_or_eq_zero_of_mul_eq_zero hxy⟩
theorem map_add_supp (a : R) {s : R} (h : s ∈ supp v) : v (a + s) = v a := by
have aux : ∀ a s, v s = 0 → v (a + s) ≤ v a := by
intro a' s' h'
refine le_trans (v.map_add a' s') (max_le le_rfl ?_)
simp [h']
apply le_antisymm (aux a s h)
calc
v a = v (a + s + -s) := by simp
_ ≤ v (a + s) := aux (a + s) (-s) (by rwa [← Ideal.neg_mem_iff] at h)
theorem comap_supp {S : Type*} [CommRing S] (f : S →+* R) :
supp (v.comap f) = Ideal.comap f v.supp :=
Ideal.ext fun x => by rw [mem_supp_iff, Ideal.mem_comap, mem_supp_iff, comap_apply]
end Supp
-- end of section
end Valuation
section AddMonoid
variable (R) [Ring R] (Γ₀ : Type*) [LinearOrderedAddCommMonoidWithTop Γ₀]
/-- The type of `Γ₀`-valued additive valuations on `R`. -/
def AddValuation :=
Valuation R (Multiplicative Γ₀ᵒᵈ)
end AddMonoid
namespace AddValuation
variable {Γ₀ : Type*} {Γ'₀ : Type*}
section Basic
section Monoid
/-- A valuation is coerced to the underlying function `R → Γ₀`. -/
instance (R) (Γ₀) [Ring R] [LinearOrderedAddCommMonoidWithTop Γ₀] :
FunLike (AddValuation R Γ₀) R Γ₀ where
coe v := v.toMonoidWithZeroHom.toFun
coe_injective' f g := by cases f; cases g; simp +contextual
variable [Ring R] [LinearOrderedAddCommMonoidWithTop Γ₀] [LinearOrderedAddCommMonoidWithTop Γ'₀]
(v : AddValuation R Γ₀)
section
variable (f : R → Γ₀) (h0 : f 0 = ⊤) (h1 : f 1 = 0)
variable (hadd : ∀ x y, min (f x) (f y) ≤ f (x + y)) (hmul : ∀ x y, f (x * y) = f x + f y)
/-- An alternate constructor of `AddValuation`, that doesn't reference `Multiplicative Γ₀ᵒᵈ` -/
def of : AddValuation R Γ₀ where
toFun := f
map_one' := h1
map_zero' := h0
map_add_le_max' := hadd
map_mul' := hmul
variable {h0} {h1} {hadd} {hmul} {r : R}
@[simp]
theorem of_apply : (of f h0 h1 hadd hmul) r = f r := rfl
/-- The `Valuation` associated to an `AddValuation` (useful if the latter is constructed using
`AddValuation.of`). -/
def toValuation : AddValuation R Γ₀ ≃ Valuation R (Multiplicative Γ₀ᵒᵈ) :=
Equiv.refl _
/-- The `AddValuation` associated to a `Valuation`.
-/
def ofValuation : Valuation R (Multiplicative Γ₀ᵒᵈ) ≃ AddValuation R Γ₀ :=
Equiv.refl _
@[simp]
lemma ofValuation_symm_eq : ofValuation.symm = toValuation (R := R) (Γ₀ := Γ₀) := rfl
@[simp]
lemma toValuation_symm_eq : toValuation.symm = ofValuation (R := R) (Γ₀ := Γ₀) := rfl
@[simp]
lemma ofValuation_toValuation : ofValuation (toValuation v) = v := rfl
@[simp]
lemma toValuation_ofValuation (v : Valuation R (Multiplicative Γ₀ᵒᵈ)) :
toValuation (ofValuation v) = v := rfl
@[simp]
theorem toValuation_apply (r : R) :
toValuation v r = Multiplicative.ofAdd (OrderDual.toDual (v r)) :=
rfl
@[simp]
theorem ofValuation_apply (v : Valuation R (Multiplicative Γ₀ᵒᵈ)) (r : R) :
ofValuation v r = OrderDual.ofDual (Multiplicative.toAdd (v r)) :=
rfl
end
@[simp]
theorem map_zero : v 0 = (⊤ : Γ₀) :=
Valuation.map_zero v
@[simp]
theorem map_one : v 1 = (0 : Γ₀) :=
Valuation.map_one v
/-- A helper function for Lean to inferring types correctly.
Deprecated since it is unused.
-/
@[deprecated "Use `⇑v` instead" (since := "2025-09-04")] def asFun : R → Γ₀ := v
@[simp]
theorem map_mul : ∀ (x y : R), v (x * y) = v x + v y :=
Valuation.map_mul v
-- `simp`-normal form is `map_add'`
theorem map_add : ∀ (x y : R), min (v x) (v y) ≤ v (x + y) :=
Valuation.map_add v
@[simp]
theorem map_add' : ∀ (x y : R), v x ≤ v (x + y) ∨ v y ≤ v (x + y) := by
intro x y
rw [← @min_le_iff _ _ (v x) (v y) (v (x+y)), ← ge_iff_le]
apply map_add
theorem map_le_add {x y : R} {g : Γ₀} (hx : g ≤ v x) (hy : g ≤ v y) : g ≤ v (x + y) :=
Valuation.map_add_le v hx hy
theorem map_lt_add {x y : R} {g : Γ₀} (hx : g < v x) (hy : g < v y) : g < v (x + y) :=
Valuation.map_add_lt v hx hy
theorem map_le_sum {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hf : ∀ i ∈ s, g ≤ v (f i)) :
g ≤ v (∑ i ∈ s, f i) :=
v.map_sum_le hf
theorem map_lt_sum {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hg : g ≠ ⊤)
(hf : ∀ i ∈ s, g < v (f i)) : g < v (∑ i ∈ s, f i) :=
v.map_sum_lt hg hf
theorem map_lt_sum' {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hg : g < ⊤)
(hf : ∀ i ∈ s, g < v (f i)) : g < v (∑ i ∈ s, f i) :=
v.map_sum_lt' hg hf
@[simp]
theorem map_pow : ∀ (x : R) (n : ℕ), v (x ^ n) = n • (v x) :=
Valuation.map_pow v
@[ext]
theorem ext {v₁ v₂ : AddValuation R Γ₀} (h : ∀ r, v₁ r = v₂ r) : v₁ = v₂ :=
Valuation.ext h
-- The following definition is not an instance, because we have more than one `v` on a given `R`.
-- In addition, type class inference would not be able to infer `v`.
/-- A valuation gives a preorder on the underlying ring. -/
def toPreorder : Preorder R :=
Preorder.lift v
/-- If `v` is an additive valuation on a division ring then `v(x) = ⊤` iff `x = 0`. -/
@[simp]
theorem top_iff [Nontrivial Γ₀] (v : AddValuation K Γ₀) {x : K} : v x = (⊤ : Γ₀) ↔ x = 0 :=
v.zero_iff
theorem ne_top_iff [Nontrivial Γ₀] (v : AddValuation K Γ₀) {x : K} : v x ≠ (⊤ : Γ₀) ↔ x ≠ 0 :=
v.ne_zero_iff
/-- A ring homomorphism `S → R` induces a map `AddValuation R Γ₀ → AddValuation S Γ₀`. -/
def comap {S : Type*} [Ring S] (f : S →+* R) (v : AddValuation R Γ₀) : AddValuation S Γ₀ :=
Valuation.comap f v
@[simp]
theorem comap_id : v.comap (RingHom.id R) = v :=
Valuation.comap_id v
theorem comap_comp {S₁ : Type*} {S₂ : Type*} [Ring S₁] [Ring S₂] (f : S₁ →+* S₂) (g : S₂ →+* R) :
v.comap (g.comp f) = (v.comap g).comap f :=
Valuation.comap_comp v f g
/-- A `≤`-preserving, `⊤`-preserving group homomorphism `Γ₀ → Γ'₀` induces a map
`AddValuation R Γ₀ → AddValuation R Γ'₀`.
-/
def map (f : Γ₀ →+ Γ'₀) (ht : f ⊤ = ⊤) (hf : Monotone f) (v : AddValuation R Γ₀) :
AddValuation R Γ'₀ :=
@Valuation.map R (Multiplicative Γ₀ᵒᵈ) (Multiplicative Γ'₀ᵒᵈ) _ _ _
{ toFun := f
map_mul' := f.map_add
map_one' := f.map_zero
map_zero' := ht } (fun _ _ h => hf h) v
@[simp]
lemma map_apply (f : Γ₀ →+ Γ'₀) (ht : f ⊤ = ⊤) (hf : Monotone f) (v : AddValuation R Γ₀) (r : R) :
v.map f ht hf r = f (v r) := rfl
/-- Two additive valuations on `R` are defined to be equivalent if they induce the same
preorder on `R`. -/
def IsEquiv (v₁ : AddValuation R Γ₀) (v₂ : AddValuation R Γ'₀) : Prop :=
Valuation.IsEquiv v₁ v₂
@[simp]
theorem map_neg (x : R) : v (-x) = v x :=
Valuation.map_neg v x
theorem map_sub_swap (x y : R) : v (x - y) = v (y - x) :=
Valuation.map_sub_swap v x y
theorem map_sub (x y : R) : min (v x) (v y) ≤ v (x - y) :=
Valuation.map_sub v x y
theorem map_le_sub {x y : R} {g : Γ₀} (hx : g ≤ v x) (hy : g ≤ v y) : g ≤ v (x - y) :=
Valuation.map_sub_le v hx hy
variable {x y : R}
theorem map_add_of_distinct_val (h : v x ≠ v y) : v (x + y) = @Min.min Γ₀ _ (v x) (v y) :=
Valuation.map_add_of_distinct_val v h
theorem map_add_eq_of_lt_left {x y : R} (h : v x < v y) :
v (x + y) = v x := by
rw [map_add_of_distinct_val _ h.ne, min_eq_left h.le]
theorem map_add_eq_of_lt_right {x y : R} (hx : v y < v x) :
v (x + y) = v y := add_comm y x ▸ map_add_eq_of_lt_left v hx
theorem map_sub_eq_of_lt_left {x y : R} (hx : v x < v y) :
v (x - y) = v x := by
rw [sub_eq_add_neg]
apply map_add_eq_of_lt_left
rwa [map_neg]
theorem map_sub_eq_of_lt_right {x y : R} (hx : v y < v x) :
v (x - y) = v y := map_sub_swap v x y ▸ map_sub_eq_of_lt_left v hx
theorem map_eq_of_lt_sub (h : v x < v (y - x)) : v y = v x :=
Valuation.map_eq_of_sub_lt v h
end Monoid
section Group
variable [LinearOrderedAddCommGroupWithTop Γ₀] [Ring R] (v : AddValuation R Γ₀) {x y : R}
@[simp]
theorem map_inv (v : AddValuation K Γ₀) {x : K} : v x⁻¹ = - (v x) :=
map_inv₀ (toValuation v) x
@[simp]
theorem map_div (v : AddValuation K Γ₀) {x y : K} : v (x / y) = v x - v y :=
map_div₀ (toValuation v) x y
end Group
end Basic
namespace IsEquiv
variable [LinearOrderedAddCommMonoidWithTop Γ₀] [LinearOrderedAddCommMonoidWithTop Γ'₀]
[Ring R]
{Γ''₀ : Type*} [LinearOrderedAddCommMonoidWithTop Γ''₀]
{v : AddValuation R Γ₀} {v₁ : AddValuation R Γ₀}
{v₂ : AddValuation R Γ'₀} {v₃ : AddValuation R Γ''₀}
@[refl]
theorem refl : v.IsEquiv v :=
Valuation.IsEquiv.refl
@[symm]
theorem symm (h : v₁.IsEquiv v₂) : v₂.IsEquiv v₁ :=
Valuation.IsEquiv.symm h
@[trans]
theorem trans (h₁₂ : v₁.IsEquiv v₂) (h₂₃ : v₂.IsEquiv v₃) : v₁.IsEquiv v₃ :=
Valuation.IsEquiv.trans h₁₂ h₂₃
theorem of_eq {v' : AddValuation R Γ₀} (h : v = v') : v.IsEquiv v' :=
Valuation.IsEquiv.of_eq h
theorem map {v' : AddValuation R Γ₀} (f : Γ₀ →+ Γ'₀) (ht : f ⊤ = ⊤) (hf : Monotone f)
(inf : Injective f) (h : v.IsEquiv v') : (v.map f ht hf).IsEquiv (v'.map f ht hf) :=
@Valuation.IsEquiv.map R (Multiplicative Γ₀ᵒᵈ) (Multiplicative Γ'₀ᵒᵈ) _ _ _ _ _
{ toFun := f
map_mul' := f.map_add
map_one' := f.map_zero
map_zero' := ht } (fun _x _y h => hf h) inf h
/-- `comap` preserves equivalence. -/
theorem comap {S : Type*} [Ring S] (f : S →+* R) (h : v₁.IsEquiv v₂) :
(v₁.comap f).IsEquiv (v₂.comap f) :=
Valuation.IsEquiv.comap f h
theorem val_eq (h : v₁.IsEquiv v₂) {r s : R} : v₁ r = v₁ s ↔ v₂ r = v₂ s :=
Valuation.IsEquiv.val_eq h
theorem ne_top (h : v₁.IsEquiv v₂) {r : R} : v₁ r ≠ (⊤ : Γ₀) ↔ v₂ r ≠ (⊤ : Γ'₀) :=
Valuation.IsEquiv.ne_zero h
end IsEquiv
section Supp
variable [LinearOrderedAddCommMonoidWithTop Γ₀] [CommRing R] (v : AddValuation R Γ₀)
/-- The support of an additive valuation `v : R → Γ₀` is the ideal of `R` where `v x = ⊤` -/
def supp : Ideal R :=
Valuation.supp v
@[simp]
theorem mem_supp_iff (x : R) : x ∈ supp v ↔ v x = (⊤ : Γ₀) :=
Valuation.mem_supp_iff v x
theorem map_add_supp (a : R) {s : R} (h : s ∈ supp v) : v (a + s) = v a :=
Valuation.map_add_supp v a h
end Supp
-- end of section
end AddValuation
namespace Valuation
variable {K Γ₀ : Type*} [Ring R] [LinearOrderedCommMonoidWithZero Γ₀]
/-- The `AddValuation` associated to a `Valuation`. -/
def toAddValuation : Valuation R Γ₀ ≃ AddValuation R (Additive Γ₀)ᵒᵈ :=
.trans (congr
{ toFun := fun x ↦ .ofAdd <| .toDual <| .toDual <| .ofMul x
invFun := fun x ↦ x.toAdd.ofDual.ofDual.toMul
map_mul' := fun _x _y ↦ rfl
map_le_map_iff' := .rfl }) (AddValuation.ofValuation (R := R) (Γ₀ := (Additive Γ₀)ᵒᵈ))
/-- The `Valuation` associated to a `AddValuation`.
-/
def ofAddValuation : AddValuation R (Additive Γ₀)ᵒᵈ ≃ Valuation R Γ₀ :=
AddValuation.toValuation.trans <| congr <|
{ toFun := fun x ↦ x.toAdd.ofDual.ofDual.toMul
invFun := fun x ↦ .ofAdd <| .toDual <| .toDual <| .ofMul x
map_mul' := fun _x _y ↦ rfl
map_le_map_iff' := .rfl }
@[simp]
lemma ofAddValuation_symm_eq : ofAddValuation.symm = toAddValuation (R := R) (Γ₀ := Γ₀) := rfl
@[simp]
lemma toAddValuation_symm_eq : toAddValuation.symm = ofAddValuation (R := R) (Γ₀ := Γ₀) := rfl
@[simp]
lemma ofAddValuation_toAddValuation (v : Valuation R Γ₀) : ofAddValuation (toAddValuation v) = v :=
rfl
@[simp]
lemma toValuation_ofValuation (v : AddValuation R (Additive Γ₀)ᵒᵈ) :
toAddValuation (ofAddValuation v) = v := rfl
@[simp]
theorem toAddValuation_apply (v : Valuation R Γ₀) (r : R) :
toAddValuation v r = OrderDual.toDual (Additive.ofMul (v r)) :=
rfl
@[simp]
theorem ofAddValuation_apply (v : AddValuation R (Additive Γ₀)ᵒᵈ) (r : R) :
ofAddValuation v r = Additive.toMul (OrderDual.ofDual (v r)) :=
rfl
instance (v : Valuation R Γ₀) : CommMonoidWithZero (MonoidHom.mrange v) :=
inferInstanceAs (CommMonoidWithZero (MonoidHom.mrange (v : R →*₀ Γ₀)))
@[simp]
lemma val_mrange_zero (v : Valuation R Γ₀) : ((0 : MonoidHom.mrange v) : Γ₀) = 0 := by
rfl
instance {Γ₀} [LinearOrderedCommGroupWithZero Γ₀] [DivisionRing K] (v : Valuation K Γ₀) :
CommGroupWithZero (MonoidHom.mrange v) :=
inferInstanceAs (CommGroupWithZero (MonoidHom.mrange (v : K →*₀ Γ₀)))
end Valuation |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Quotient.lean | import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Valuation.Basic
/-!
# The valuation on a quotient ring
The support of a valuation `v : Valuation R Γ₀` is `supp v`. If `J` is an ideal of `R`
with `h : J ⊆ supp v` then the induced valuation
on `R / J` = `Ideal.Quotient J` is `onQuot v h`.
-/
namespace Valuation
variable {R Γ₀ : Type*} [CommRing R] [LinearOrderedCommMonoidWithZero Γ₀]
variable (v : Valuation R Γ₀)
/-- If `hJ : J ⊆ supp v` then `onQuotVal hJ` is the induced function on `R / J` as a function.
Note: it's just the function; the valuation is `onQuot hJ`. -/
def onQuotVal {J : Ideal R} (hJ : J ≤ supp v) : R ⧸ J → Γ₀ := fun q =>
Quotient.liftOn' q v fun a b h =>
calc
v a = v (b + -(-a + b)) := by simp
_ = v b :=
v.map_add_supp b <| (Ideal.neg_mem_iff _).2 <| hJ <| QuotientAddGroup.leftRel_apply.mp h
/-- The extension of valuation `v` on `R` to valuation on `R / J` if `J ⊆ supp v`. -/
def onQuot {J : Ideal R} (hJ : J ≤ supp v) : Valuation (R ⧸ J) Γ₀ where
toFun := v.onQuotVal hJ
map_zero' := v.map_zero
map_one' := v.map_one
map_mul' xbar ybar := Quotient.ind₂' v.map_mul xbar ybar
map_add_le_max' xbar ybar := Quotient.ind₂' v.map_add xbar ybar
@[simp]
theorem onQuot_comap_eq {J : Ideal R} (hJ : J ≤ supp v) :
(v.onQuot hJ).comap (Ideal.Quotient.mk J) = v :=
ext fun _ => rfl
theorem self_le_supp_comap (J : Ideal R) (v : Valuation (R ⧸ J) Γ₀) :
J ≤ (v.comap (Ideal.Quotient.mk J)).supp := by
rw [comap_supp, ← Ideal.map_le_iff_le_comap]
simp
@[simp]
theorem comap_onQuot_eq (J : Ideal R) (v : Valuation (R ⧸ J) Γ₀) :
(v.comap (Ideal.Quotient.mk J)).onQuot (v.self_le_supp_comap J) = v :=
ext <| by
rintro ⟨x⟩
rfl
/-- The quotient valuation on `R / J` has support `(supp v) / J` if `J ⊆ supp v`. -/
theorem supp_quot {J : Ideal R} (hJ : J ≤ supp v) :
supp (v.onQuot hJ) = (supp v).map (Ideal.Quotient.mk J) := by
apply le_antisymm
· rintro ⟨x⟩ hx
apply Ideal.subset_span
exact ⟨x, hx, rfl⟩
· rw [Ideal.map_le_iff_le_comap]
intro x hx
exact hx
theorem supp_quot_supp : supp (v.onQuot le_rfl) = 0 := by
rw [supp_quot]
exact Ideal.map_quotient_self _
end Valuation
namespace AddValuation
variable {R Γ₀ : Type*}
variable [CommRing R] [LinearOrderedAddCommMonoidWithTop Γ₀]
variable (v : AddValuation R Γ₀)
/-- If `hJ : J ⊆ supp v` then `onQuotVal hJ` is the induced function on `R / J` as a function.
Note: it's just the function; the valuation is `onQuot hJ`. -/
def onQuotVal {J : Ideal R} (hJ : J ≤ supp v) : R ⧸ J → Γ₀ :=
Valuation.onQuotVal v hJ
/-- The extension of valuation `v` on `R` to valuation on `R / J` if `J ⊆ supp v`. -/
def onQuot {J : Ideal R} (hJ : J ≤ supp v) : AddValuation (R ⧸ J) Γ₀ :=
Valuation.onQuot v hJ
@[simp]
theorem onQuot_comap_eq {J : Ideal R} (hJ : J ≤ supp v) :
(v.onQuot hJ).comap (Ideal.Quotient.mk J) = v :=
Valuation.onQuot_comap_eq v hJ
theorem comap_supp {S : Type*} [CommRing S] (f : S →+* R) :
supp (v.comap f) = Ideal.comap f v.supp :=
Valuation.comap_supp v f
theorem self_le_supp_comap (J : Ideal R) (v : AddValuation (R ⧸ J) Γ₀) :
J ≤ (v.comap (Ideal.Quotient.mk J)).supp :=
Valuation.self_le_supp_comap J v
@[simp]
theorem comap_onQuot_eq (J : Ideal R) (v : AddValuation (R ⧸ J) Γ₀) :
(v.comap (Ideal.Quotient.mk J)).onQuot (v.self_le_supp_comap J) = v :=
Valuation.comap_onQuot_eq J v
/-- The quotient valuation on `R / J` has support `(supp v) / J` if `J ⊆ supp v`. -/
theorem supp_quot {J : Ideal R} (hJ : J ≤ supp v) :
supp (v.onQuot hJ) = (supp v).map (Ideal.Quotient.mk J) :=
Valuation.supp_quot v hJ
theorem supp_quot_supp : supp ((Valuation.onQuot v) le_rfl) = 0 :=
Valuation.supp_quot_supp v
end AddValuation |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/RankOne.lean | import Mathlib.Algebra.Order.Group.Units
import Mathlib.Algebra.Order.GroupWithZero.WithZero
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Data.Real.Embedding
import Mathlib.RingTheory.Valuation.ValuativeRel.Basic
/-!
# Rank one valuations
We define rank one valuations.
## Main Definitions
* `RankOne` : A valuation `v` has rank one if it is nontrivial and its image is contained in `ℝ≥0`.
Note that this class contains the data of the inclusion of the codomain of `v` into `ℝ≥0`.
## Tags
valuation, rank one
-/
noncomputable section
open Function Multiplicative
open scoped NNReal
variable {R : Type*} [Ring R] {Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀]
namespace Valuation
/-- A valuation has rank one if it is nontrivial and its image is contained in `ℝ≥0`.
Note that this class includes the data of an inclusion morphism `Γ₀ → ℝ≥0`. -/
class RankOne (v : Valuation R Γ₀) extends Valuation.IsNontrivial v where
/-- The inclusion morphism from `Γ₀` to `ℝ≥0`. -/
hom : Γ₀ →*₀ ℝ≥0
strictMono' : StrictMono hom
open WithZero
lemma nonempty_rankOne_iff_mulArchimedean {v : Valuation R Γ₀} [v.IsNontrivial] :
Nonempty v.RankOne ↔ MulArchimedean Γ₀ := by
constructor
· rintro ⟨⟨f, hf⟩⟩
exact .comap f.toMonoidHom hf
· intro _
obtain ⟨f, hf⟩ := Archimedean.exists_orderAddMonoidHom_real_injective (Additive Γ₀ˣ)
let e := AddMonoidHom.toMultiplicativeRight (α := Γ₀ˣ) (β := ℝ) f
have he : StrictMono e := by
simp only [AddMonoidHom.coe_toMultiplicativeRight, AddMonoidHom.coe_coe, e]
-- toAdd_strictMono is already in an applied form, do defeq abuse instead
exact StrictMono.comp strictMono_id (f.monotone'.strictMono_of_injective hf)
let rf : Multiplicative ℝ →* ℝ≥0ˣ := {
toFun x := Units.mk0 ⟨(2 : ℝ) ^ (log (M := ℝ) x), by positivity⟩ <| by
rw [ne_eq, Subtype.ext_iff]
positivity
map_one' := by simp
map_mul' _ _ := by
rw [Units.ext_iff, Subtype.ext_iff]
simp [log_mul, Real.rpow_add]
}
have H : StrictMono (map' (rf.comp e)) := by
refine map'_strictMono ?_
intro a b h
simpa [← Units.val_lt_val, ← NNReal.coe_lt_coe, rf] using he h
exact ⟨{
hom := withZeroUnitsEquiv.toMonoidWithZeroHom.comp <| (map' (rf.comp e)).comp
withZeroUnitsEquiv.symm.toMonoidWithZeroHom
strictMono' := withZeroUnitsEquiv_strictMono.comp <| H.comp
withZeroUnitsEquiv_symm_strictMono
}⟩
namespace RankOne
variable (v : Valuation R Γ₀) [RankOne v]
lemma strictMono : StrictMono (hom v) := strictMono'
lemma nontrivial : ∃ r : R, v r ≠ 0 ∧ v r ≠ 1 := IsNontrivial.exists_val_nontrivial
/-- If `v` is a rank one valuation and `x : Γ₀` has image `0` under `RankOne.hom v`, then
`x = 0`. -/
theorem zero_of_hom_zero {x : Γ₀} (hx : hom v x = 0) : x = 0 := by
refine (eq_of_le_of_not_lt (zero_le' (a := x)) fun h_lt ↦ ?_).symm
have hs := strictMono v h_lt
rw [map_zero, hx] at hs
exact hs.false
/-- If `v` is a rank one valuation, then`x : Γ₀` has image `0` under `RankOne.hom v` if and
only if `x = 0`. -/
theorem hom_eq_zero_iff {x : Γ₀} : RankOne.hom v x = 0 ↔ x = 0 :=
⟨fun h ↦ zero_of_hom_zero v h, fun h ↦ by rw [h, map_zero]⟩
/-- A nontrivial unit of `Γ₀`, given that there exists a rank one `v : Valuation R Γ₀`. -/
def unit : Γ₀ˣ :=
Units.mk0 (v (nontrivial v).choose) ((nontrivial v).choose_spec).1
/-- A proof that `RankOne.unit v ≠ 1`. -/
theorem unit_ne_one : unit v ≠ 1 := by
rw [Ne, ← Units.val_inj, Units.val_one]
exact ((nontrivial v).choose_spec).2
instance [RankOne v] : IsNontrivial v where
exists_val_nontrivial := RankOne.nontrivial v
end RankOne
end Valuation
section ValuativeRel
open ValuativeRel
variable {R : Type*} [CommRing R] [ValuativeRel R]
/-- A valuative relation has a rank one valuation when it is both nontrivial
and the rank is at most one. -/
def Valuation.RankOne.ofRankLeOneStruct [ValuativeRel.IsNontrivial R] (e : RankLeOneStruct R) :
Valuation.RankOne (valuation R) where
hom := e.emb
strictMono' := e.strictMono
instance [IsNontrivial R] [IsRankLeOne R] :
Valuation.RankOne (valuation R) :=
Valuation.RankOne.ofRankLeOneStruct IsRankLeOne.nonempty.some
/-- Convert between the rank one statement on valuative relation's induced valuation. -/
def Valuation.RankOne.rankLeOneStruct (e : Valuation.RankOne (valuation R)) :
RankLeOneStruct R where
emb := e.hom
strictMono := e.strictMono
lemma ValuativeRel.isRankLeOne_of_rankOne [h : (valuation R).RankOne] :
IsRankLeOne R :=
⟨⟨h.rankLeOneStruct⟩⟩
lemma ValuativeRel.isNontrivial_of_rankOne [h : (valuation R).RankOne] :
ValuativeRel.IsNontrivial R :=
(isNontrivial_iff_isNontrivial _).mpr h.toIsNontrivial
open WithZero
lemma ValuativeRel.isRankLeOne_iff_mulArchimedean :
IsRankLeOne R ↔ MulArchimedean (ValueGroupWithZero R) := by
constructor
· rintro ⟨⟨f, hf⟩⟩
exact .comap f.toMonoidHom hf
· intro h
by_cases H : IsNontrivial R
· rw [isNontrivial_iff_isNontrivial (valuation R)] at H
rw [← (valuation R).nonempty_rankOne_iff_mulArchimedean] at h
obtain ⟨f⟩ := h
exact isRankLeOne_of_rankOne
· refine ⟨⟨{ emb := 1, strictMono := ?_ }⟩⟩
intro a b
contrapose! H
obtain ⟨H, H'⟩ := H
rcases eq_or_ne a 0 with rfl | ha
· simp_all
rcases eq_or_ne a 1 with rfl | ha'
· exact ⟨⟨b, (H.trans' zero_lt_one).ne', H.ne'⟩⟩
· exact ⟨⟨a, ha, ha'⟩⟩
lemma ValuativeRel.IsRankLeOne.of_compatible_mulArchimedean [MulArchimedean Γ₀]
(v : Valuation R Γ₀) [v.Compatible] :
ValuativeRel.IsRankLeOne R := by
rw [isRankLeOne_iff_mulArchimedean]
exact .comap (ValueGroupWithZero.embed v).toMonoidHom (ValueGroupWithZero.embed_strictMono v)
end ValuativeRel |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/DiscreteValuativeRel.lean | import Mathlib.Algebra.GroupWithZero.Range
import Mathlib.GroupTheory.ArchimedeanDensely
import Mathlib.RingTheory.Valuation.RankOne
/-!
# Discrete Valuative Relations
Discrete valuative relations have a maximal element less than one in the value group.
In the rank-one case, this is equivalent to the value group being isomorphic to `ℤᵐ⁰`.
-/
namespace ValuativeRel
variable {R : Type*} [CommRing R] [ValuativeRel R]
open WithZero
lemma nonempty_orderIso_withZeroMul_int_iff :
Nonempty (ValueGroupWithZero R ≃*o ℤᵐ⁰) ↔
IsDiscrete R ∧ IsNontrivial R ∧ MulArchimedean (ValueGroupWithZero R) := by
constructor
· rintro ⟨e⟩
let x := e.symm (exp (-1))
have hx0 : x ≠ 0 := by simp [x]
have hx1 : x < 1 := by simp [- exp_neg, x, ← lt_map_inv_iff, ← exp_zero]
refine ⟨⟨x, hx1, fun y hy ↦ ?_⟩, ⟨x, hx0, hx1.ne⟩, .comap e.toMonoidHom e.strictMono⟩
rcases eq_or_ne y 0 with rfl | hy0
· simp
· rw [← map_one e.symm, ← map_inv_lt_iff, ← log_lt_log (by simp [hy0]) (by simp)] at hy
rw [← map_inv_le_iff, ← log_le_log (by simp [hy0]) (by simp)]
simp only [OrderMonoidIso.equivLike_inv_eq_symm, OrderMonoidIso.symm_symm, log_one,
log_exp] at hy ⊢
linarith
· rintro ⟨hD, hN, hM⟩
rw [isNontrivial_iff_nontrivial_units] at hN
rw [LinearOrderedCommGroupWithZero.discrete_iff_not_denselyOrdered]
intro H
obtain ⟨x, hx, hx'⟩ := hD.has_maximal_element
obtain ⟨y, hy, hy'⟩ := exists_between hx
exact hy.not_ge (hx' y hy')
lemma IsDiscrete.of_compatible_withZeroMulInt (v : Valuation R ℤᵐ⁰) [v.Compatible] :
IsDiscrete R := by
have : IsRankLeOne R := .of_compatible_mulArchimedean v
by_cases h : IsNontrivial R
· by_cases H : DenselyOrdered (ValueGroupWithZero R)
· exfalso
refine (MonoidWithZeroHom.range_nontrivial (ValueGroupWithZero.embed v)).not_subsingleton ?_
rw [← WithZero.denselyOrdered_set_iff_subsingleton]
exact (ValueGroupWithZero.embed_strictMono v).denselyOrdered_range
· rw [isNontrivial_iff_nontrivial_units] at h
rw [← LinearOrderedCommGroupWithZero.discrete_iff_not_denselyOrdered] at H
rw [nonempty_orderIso_withZeroMul_int_iff] at H
exact H.left
· rw [isNontrivial_iff_nontrivial_units] at h; push_neg at h
refine ⟨⟨0, zero_lt_one, fun y hy ↦ ?_⟩⟩
contrapose! hy
have : 1 = Units.mk0 y hy.ne' := Subsingleton.elim _ _
exact Units.val_le_val.mpr this.le
end ValuativeRel |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/AlgebraInstances.lean | import Mathlib.RingTheory.IntegralClosure.IsIntegralClosure.Basic
import Mathlib.RingTheory.Valuation.ValuationSubring
/-!
# Algebra instances
This file contains several `Algebra` and `IsScalarTower` instances related to extensions
of a field with a valuation, as well as their unit balls.
## Main definitions
* `ValuationSubring.algebra` : Given an algebra between two field extensions `L` and `E` of a
field `K` with a valuation, create an algebra between their two rings of integers.
## Main statements
* `integralClosure_algebraMap_injective` : the unit ball of a field `K` with respect to a
valuation injects into its integral closure in a field extension `L` of `K`.
-/
open Function Valuation
open scoped WithZero
variable {K : Type*} [Field K] (v : Valuation K ℤᵐ⁰) (L : Type*) [Field L] [Algebra K L]
namespace ValuationSubring
-- Implementation note : this instance was automatic in Lean3
instance : Algebra v.valuationSubring L := Algebra.ofSubring v.valuationSubring.toSubring
theorem algebraMap_injective : Injective (algebraMap v.valuationSubring L) :=
(FaithfulSMul.algebraMap_injective K L).comp (IsFractionRing.injective _ _)
theorem isIntegral_of_mem_ringOfIntegers {x : L} (hx : x ∈ integralClosure v.valuationSubring L) :
IsIntegral v.valuationSubring (⟨x, hx⟩ : integralClosure v.valuationSubring L) :=
integralClosure.isIntegral ⟨x, hx⟩
theorem isIntegral_of_mem_ringOfIntegers' {x : (integralClosure v.valuationSubring L)} :
IsIntegral v.valuationSubring (x : integralClosure v.valuationSubring L) := by
apply isIntegral_of_mem_ringOfIntegers
variable (E : Type _) [Field E] [Algebra K E] [Algebra L E] [IsScalarTower K L E]
instance : IsScalarTower v.valuationSubring L E := Subring.instIsScalarTowerSubtypeMem _
/-- Given an algebra between two field extensions `L` and `E` of a field `K` with a valuation `v`,
create an algebra between their two rings of integers. -/
instance algebra :
Algebra (integralClosure v.valuationSubring L) (integralClosure v.valuationSubring E) :=
RingHom.toAlgebra
{ toFun := fun k => ⟨algebraMap L E k, IsIntegral.algebraMap k.2⟩
map_zero' :=
Subtype.ext <| by simp only [Subalgebra.coe_zero, map_zero]
map_one' := Subtype.ext <| by simp only [Subalgebra.coe_one, map_one]
map_add' := fun x y =>
Subtype.ext <| by simp only [map_add, Subalgebra.coe_add]
map_mul' := fun x y =>
Subtype.ext <| by simp only [Subalgebra.coe_mul, map_mul] }
/-- A ring equivalence between the integral closure of the valuation subring of `K` in `L`
and a ring `R` satisfying `isIntegralClosure R v.valuationSubring L`. -/
protected noncomputable def equiv (R : Type*) [CommRing R] [Algebra v.valuationSubring R]
[Algebra R L] [IsScalarTower v.valuationSubring R L]
[IsIntegralClosure R v.valuationSubring L] : integralClosure v.valuationSubring L ≃+* R := by
have := IsScalarTower.subalgebra' (valuationSubring v) L L
(integralClosure (valuationSubring v) L)
exact (IsIntegralClosure.equiv v.valuationSubring R L
(integralClosure v.valuationSubring L)).symm.toRingEquiv
theorem integralClosure_algebraMap_injective :
Injective (algebraMap v.valuationSubring (integralClosure v.valuationSubring L)) :=
FaithfulSMul.algebraMap_injective ↥v.valuationSubring ↥(integralClosure (↥v.valuationSubring) L)
end ValuationSubring |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/ValuativeRel.lean | import Mathlib.RingTheory.Valuation.ValuativeRel.Basic
deprecated_module (since := "2025-08-14") |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/ValExtension.lean | import Mathlib.RingTheory.Valuation.Extension
deprecated_module (since := "2025-05-06") |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Minpoly.lean | import Mathlib.FieldTheory.IntermediateField.Adjoin.Basic
import Mathlib.RingTheory.Valuation.Basic
/-!
# Minimal polynomials.
We prove some results about valuations of zero coefficients of minimal polynomials.
Let `K` be a field with a valuation `v` and let `L` be a field extension of `K`.
## Main statements
* `coeff_zero_minpoly` : for `x ∈ K` the valuation of the zeroth coefficient of the minimal
polynomial of `algebraMap K L x` over `K` is equal to the valuation of `x`.
* `pow_coeff_zero_ne_zero_of_unit` : for any unit `x : Lˣ`, we prove that a certain power of the
valuation of zeroth coefficient of the minimal polynomial of `x` over `K` is nonzero. This lemma
is helpful for defining the valuation on `L` inducing `v`.
-/
open Module minpoly Polynomial
variable {K : Type*} [Field K] {Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀]
(v : Valuation K Γ₀) (L : Type*) [Field L] [Algebra K L]
namespace Valuation
/-- For `x ∈ K` the valuation of the zeroth coefficient of the minimal polynomial
of `algebraMap K L x` over `K` is equal to the valuation of `x`. -/
@[simp]
theorem coeff_zero_minpoly (x : K) : v ((minpoly K (algebraMap K L x)).coeff 0) = v x := by
rw [minpoly.eq_X_sub_C, coeff_sub, coeff_X_zero, coeff_C_zero, zero_sub, Valuation.map_neg]
variable {L}
/- For any unit `x : Lˣ`, we prove that a certain power of the valuation of zeroth coefficient of
the minimal polynomial of `x` over `K` is nonzero. This lemma is helpful for defining the valuation
on `L` inducing `v`. -/
theorem pow_coeff_zero_ne_zero_of_unit [FiniteDimensional K L] (x : L) (hx : IsUnit x) :
v ((minpoly K x).coeff 0) ^ (finrank K L / (minpoly K x).natDegree) ≠ (0 : Γ₀) := by
have h_alg : Algebra.IsAlgebraic K L := Algebra.IsAlgebraic.of_finite K L
have hx₀ : IsIntegral K x := (Algebra.IsAlgebraic.isAlgebraic x).isIntegral
have hdeg := Nat.div_pos (natDegree_le x) (natDegree_pos hx₀)
rw [ne_eq, pow_eq_zero_iff hdeg.ne.symm, Valuation.zero_iff]
exact coeff_zero_ne_zero hx₀ hx.ne_zero
end Valuation |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/Discrete/Basic.lean | import Mathlib.Algebra.GroupWithZero.Range
import Mathlib.Algebra.Order.Group.Cyclic
import Mathlib.RingTheory.DedekindDomain.AdicValuation
import Mathlib.RingTheory.DiscreteValuationRing.Basic
import Mathlib.RingTheory.PrincipalIdealDomainOfPrime
/-!
# Discrete Valuations
Given a linearly ordered commutative group with zero `Γ`, a valuation `v : A → Γ` on a ring `A` is
*discrete*, if there is an element `γ : Γˣ` that is `< 1` and generated the range of `v`,
implemented as `MonoidWithZeroHom.valueGroup v`. When `Γ := ℤₘ₀` (defined in
`Multiplicative.termℤₘ₀`), `γ` = ofAdd (-1)` and the condition of being discrete is
equivalent to asking that `ofAdd (-1 : ℤ)` belongs to the image, in turn equivalent to asking that
`1 : ℤ` belongs to the image of the corresponding *additive* valuation.
Note that this definition of discrete implies that the valuation is nontrivial and of rank one, as
is commonly assumed in number theory. To avoid potential confusion with other definitions of
discrete, we use the name `IsRankOneDiscrete` to refer to discrete valuations in this setting.
## Main Definitions
* `Valuation.IsRankOneDiscrete`: We define a `Γ`-valued valuation `v` to be discrete if there is
an element `γ : Γˣ` that is `< 1` and generates the range of `v`.
* `Valuation.IsUniformizer`: Given a `Γ`-valued valuation `v` on a ring `R`, an element `π : R` is
a uniformizer if `v π` is a generator of the value group that is `<1`.
* `Valuation.Uniformizer`: A structure bundling an element of a ring and a proof that it is a
uniformizer.
## Main Results
* `Valuation.IsUniformizer.of_associated`: An element associated to a uniformizer is itself a
uniformizer.
* `Valuation.associated_of_isUniformizer`: If two elements are uniformizers, they are associated.
* `Valuation.IsUniformizer.is_generator` A generator of the maximal ideal is a uniformizer when
the valuation is discrete.
* `Valuation.IsRankOneDiscrete.mk'`: if the `valueGroup` of the valuation `v` is cyclic and
nontrivial, then `v` is discrete.
* `Valuation.exists_isUniformizer_of_isCyclic_of_nontrivial`: If `v` is a valuation on a field `K`
whose value group is cyclic and nontrivial, then there exists a uniformizer for `v`.
* `Valuation.isUniformizer_of_maximalIdeal_eq_span`: Given a discrete valuation `v` on a field `K`,
a generator of the maximal ideal of `v.valuationSubring` is a uniformizer for `v`.
* `Valuation.valuationSubring_isDiscreteValuationRing` : If `v` is a valuation on a field `K`
whose value group is cyclic and nontrivial, then `v.valuationSubring` is a discrete
valuation ring. This instance is the formalization of Chapter I, Section 1, Proposition 1 in
[serre1968].
* `IsDiscreteValuationRing.isRankOneDiscrete`: Given a DVR `A` and a field `K` satisfying
`IsFractionRing A K`, the valuation induced on `K` is discrete.
* `IsDiscreteValuationRing.equivValuationSubring` The ring isomorphism between a DVR and the
unit ball in its field of fractions endowed with the adic valuation of the maximal ideal.
## TODO
* Relate discrete valuations and discrete valuation rings (contained in the project
<https://github.com/mariainesdff/LocalClassFieldTheory>)
-/
namespace Valuation
open LinearOrderedCommGroup MonoidWithZeroHom Set Subgroup
variable {Γ : Type*} [LinearOrderedCommGroupWithZero Γ]
section Ring
variable {A : Type*} [Ring A] (v : Valuation A Γ)
/-- Given a linearly ordered commutative group with zero `Γ` such that `Γˣ` is
nontrivial cyclic, a valuation `v : A → Γ` on a ring `A` is *discrete*, if
`genLTOne Γˣ` belongs to the image. Note that the latter is equivalent to
asking that `1 : ℤ` belongs to the image of the corresponding additive valuation. -/
class IsRankOneDiscrete : Prop where
exists_generator_lt_one' : ∃ (γ : Γˣ), zpowers γ = (valueGroup v) ∧ γ < 1
namespace IsRankOneDiscrete
variable [IsRankOneDiscrete v]
lemma exists_generator_lt_one : ∃ (γ : Γˣ), zpowers γ = valueGroup v ∧ γ < 1 :=
exists_generator_lt_one'
/-- Given a discrete valuation `v`, `Valuation.IsRankOneDiscrete.generator` is a generator of
the value group that is `< 1`. -/
noncomputable def generator : Γˣ := (exists_generator_lt_one v).choose
lemma generator_zpowers_eq_valueGroup :
zpowers (generator v) = valueGroup v :=
(exists_generator_lt_one v).choose_spec.1
lemma generator_mem_valueGroup :
(IsRankOneDiscrete.generator v) ∈ valueGroup v := by
rw [← IsRankOneDiscrete.generator_zpowers_eq_valueGroup]
exact mem_zpowers (IsRankOneDiscrete.generator v)
lemma generator_lt_one : generator v < 1 :=
(exists_generator_lt_one v).choose_spec.2
lemma generator_ne_one : generator v ≠ 1 :=
ne_of_lt <| generator_lt_one v
lemma generator_zpowers_eq_range (K : Type*) [Field K] (w : Valuation K Γ) [IsRankOneDiscrete w] :
Units.val '' (zpowers (generator w)) = range w \ {0} := by
rw [generator_zpowers_eq_valueGroup, valueGroup_eq_range]
lemma generator_mem_range (K : Type*) [Field K] (w : Valuation K Γ) [IsRankOneDiscrete w] :
↑(generator w) ∈ range w := by
apply diff_subset
rw [← generator_zpowers_eq_range]
exact ⟨generator w, by simp⟩
lemma generator_ne_zero : (generator v : Γ) ≠ 0 := by simp
instance : IsCyclic <| valueGroup v := by
rw [isCyclic_iff_exists_zpowers_eq_top, ← generator_zpowers_eq_valueGroup]
use ⟨generator v, by simp⟩
rw [eq_top_iff]
rintro ⟨g, k, hk⟩
simp only [mem_top, forall_const]
use k
ext
simp [← hk]
instance : Nontrivial (valueGroup v) :=
⟨1, ⟨generator v, by simp [← generator_zpowers_eq_valueGroup]⟩, ne_of_gt <| generator_lt_one v⟩
instance [IsRankOneDiscrete v] : Nontrivial (valueMonoid v) := by
by_contra! H
apply ((valueGroup v).nontrivial_iff_ne_bot).mp (by infer_instance)
apply closure_eq_bot_iff.mpr
rw [subsingleton_iff] at H
intro x hx
specialize H ⟨x, hx⟩ ⟨1, one_mem_valueMonoid v⟩
simpa using H
instance [IsRankOneDiscrete v] : v.IsNontrivial := by
constructor
obtain ⟨⟨γ, π, hπ⟩, hγ⟩ := (nontrivial_iff_exists_ne (1 : valueMonoid v)).mp (by infer_instance)
use π
constructor
· simp [hπ]
· rw [hπ]
simp only [← MonoidWithZeroHom.coe_one, ne_eq, Subtype.mk.injEq] at hγ
simp [hγ, Units.val_eq_one]
lemma valueGroup_genLTOne_eq_generator : (valueGroup v).genLTOne = generator v :=
((valueGroup v).genLTOne_unique (generator_lt_one v) (generator_zpowers_eq_valueGroup v)).symm
end IsRankOneDiscrete
section IsRankOneDiscrete
variable [hv : IsRankOneDiscrete v]
/-- An element `π : A` is a uniformizer if `v π` is a generator of the value group that is `< 1`. -/
def IsUniformizer (π : A) : Prop := v π = hv.generator
variable {v} {π : A}
namespace IsUniformizer
theorem iff : v.IsUniformizer π ↔ v π = hv.generator := refl _
theorem ne_zero (hπ : IsUniformizer v π) : π ≠ 0 := by
intro h0
rw [h0, IsUniformizer, map_zero] at hπ
exact (Units.ne_zero _).symm hπ
@[simp]
lemma val (hπ : v.IsUniformizer π) : v π = hv.generator := hπ
lemma val_lt_one (hπ : v.IsUniformizer π) : v π < 1 := hπ ▸ hv.generator_lt_one
lemma val_ne_zero (hπ : v.IsUniformizer π) : v π ≠ 0 := by
by_contra h0
simp only [IsUniformizer, h0] at hπ
exact (Units.ne_zero _).symm hπ
theorem val_pos (hπ : IsUniformizer v π) : 0 < v π := by
rw [IsUniformizer.iff] at hπ; simp [zero_lt_iff, ne_eq, hπ]
lemma zpowers_eq_valueGroup (hπ : v.IsUniformizer π) :
valueGroup v = zpowers (Units.mk0 (v π) hπ.val_ne_zero) := by
rw [← (valueGroup v).genLTOne_zpowers_eq_top]
congr
simp only [val, Units.mk0_val, hπ]
exact IsRankOneDiscrete.valueGroup_genLTOne_eq_generator v
end IsUniformizer
variable (v) in
/-- The structure `Uniformizer` bundles together the term in the ring and a proof that it is a
uniformizer. -/
@[ext]
structure Uniformizer where
/-- The integer underlying a `Uniformizer` -/
val : v.integer
valuation_gt_one : v.IsUniformizer val
namespace Uniformizer
/-- A constructor for `Uniformizer`. -/
def mk' {x : A} (hx : v.IsUniformizer x) : v.Uniformizer where
val := ⟨x, le_of_lt hx.val_lt_one⟩
valuation_gt_one := hx
@[simp]
instance : Coe v.Uniformizer v.integer := ⟨fun π ↦ π.val⟩
theorem ne_zero (π : Uniformizer v) : π.1.1 ≠ 0 := π.2.ne_zero
end Uniformizer
end IsRankOneDiscrete
end Ring
section CommRing
variable {R : Type*} [CommRing R] {v : Valuation R Γ} [hv : IsRankOneDiscrete v]
theorem IsUniformizer.not_isUnit {π : v.integer} (hπ : IsUniformizer v π) : ¬ IsUnit π :=
fun h ↦ ne_of_gt hπ.val_lt_one (Integers.one_of_isUnit (integer.integers v) h).symm
end CommRing
section Ring
variable {R : Type*} [Ring R] (v : Valuation R Γ) [IsCyclic (valueGroup v)]
[Nontrivial (valueGroup v)]
instance IsRankOneDiscrete.mk' : IsRankOneDiscrete v :=
⟨(valueGroup v).genLTOne,
⟨(valueGroup v).genLTOne_zpowers_eq_top, (valueGroup v).genLTOne_lt_one⟩⟩
end Ring
section Field
open Ideal IsLocalRing Valuation.IsRankOneDiscrete
variable {K : Type*} [Field K] (v : Valuation K Γ)
/- When the valuation is defined over a field instead that simply on a (commutative) ring, we use
the notion of `valuationSubring` instead of the weaker one of `integer` to access the
corresponding API. -/
local notation "K₀" => v.valuationSubring
section IsNontrivial
variable [IsCyclic (valueGroup v)] [Nontrivial (valueGroup v)]
theorem exists_isUniformizer_of_isCyclic_of_nontrivial : ∃ π : K₀, IsUniformizer v (π : K) := by
simp only [IsUniformizer.iff, Subtype.exists, mem_valuationSubring_iff, exists_prop]
set g := (valueGroup v).genLTOne with hg
obtain ⟨⟨π, hπ⟩, hγ0⟩ : g.1 ∈ ((range v) \ {0}) := by
rw [← valueGroup_eq_range, hg]
exact mem_image_of_mem Units.val (valueGroup v).genLTOne_mem
use π
rw [hπ, hg]
exact ⟨le_of_lt (valueGroup v).genLTOne_lt_one, by rw [valueGroup_genLTOne_eq_generator]⟩
instance : Nonempty (Uniformizer v) :=
⟨⟨(exists_isUniformizer_of_isCyclic_of_nontrivial v).choose,
(exists_isUniformizer_of_isCyclic_of_nontrivial v).choose_spec⟩⟩
end IsNontrivial
section IsRankOneDiscrete
section Uniformizer
variable {v} [hv : v.IsRankOneDiscrete]
/-- An element associated to a uniformizer is itself a uniformizer. -/
theorem IsUniformizer.of_associated {π₁ π₂ : K₀} (h1 : IsUniformizer v π₁)
(H : Associated π₁ π₂) : IsUniformizer v π₂ := by
obtain ⟨u, hu⟩ := H
have : v (u.1 : K) = 1 := (Integers.isUnit_iff_valuation_eq_one <|integer.integers v).mp u.isUnit
rwa [IsUniformizer.iff, ← hu, Subring.coe_mul, map_mul, this, mul_one, ← IsUniformizer.iff]
/-- If two elements of `K₀` are uniformizers, then they are associated. -/
theorem associated_of_isUniformizer {π₁ π₂ : K₀} (h1 : IsUniformizer v π₁)
(h2 : IsUniformizer v π₂) : Associated π₁ π₂ := by
have hval : v ((π₁ : K)⁻¹ * π₂) = 1 := by
simp [IsUniformizer.iff.mp h1, IsUniformizer.iff.mp h2]
set p : v.integer := ⟨(π₁.1 : K)⁻¹ * π₂.1, (v.mem_integer_iff _).mpr (le_of_eq hval)⟩ with hp
use ((Integers.isUnit_iff_valuation_eq_one (x := p) <| integer.integers v).mpr hval).unit
apply_fun ((↑) : K₀ → K) using Subtype.val_injective
simp [hp, ← mul_assoc, mul_inv_cancel₀ h1.ne_zero]
theorem exists_pow_Uniformizer {r : K₀} (hr : r ≠ 0) (π : Uniformizer v) :
∃ n : ℕ, ∃ u : K₀ˣ, r = (π.1 ^ n).1 * u.1 := by
have hr₀ : v r ≠ 0 := by rw [ne_eq, zero_iff, Subring.coe_eq_zero_iff]; exact hr
set vr : Γˣ := Units.mk0 (v r) hr₀ with hvr_def
have hvr : vr ∈ (valueGroup v) := by
apply mem_valueGroup
rw [hvr_def, Units.val_mk0 hr₀]
exact mem_range_self _
rw [π.2.zpowers_eq_valueGroup, mem_zpowers_iff] at hvr
obtain ⟨m, hm⟩ := hvr
have hm' : v π.val ^ m = v r := by
rw [hvr_def] at hm
rw [← Units.val_mk0 hr₀, ← hm]
simp [Units.val_zpow_eq_zpow_val, Units.val_mk0]
have hm₀ : 0 ≤ m := by
rw [← zpow_le_one_iff_right_of_lt_one₀ π.2.val_pos π.2.val_lt_one, hm']
exact r.2
obtain ⟨n, hn⟩ := Int.eq_ofNat_of_zero_le hm₀
use n
have hpow : v (π.1.1 ^ (-m) * r) = 1 := by
rw [map_mul, map_zpow₀, ← hm', zpow_neg, hm', inv_mul_cancel₀ hr₀]
set a : K₀ := ⟨π.1.1 ^ (-m) * r, by apply le_of_eq hpow⟩ with ha
have ha₀ : (↑a : K) ≠ 0 := by
simp only [zpow_neg, ne_eq, mul_eq_zero, inv_eq_zero, ZeroMemClass.coe_eq_zero, not_or, ha]
refine ⟨?_, hr⟩
rw [hn, zpow_natCast, pow_eq_zero_iff', not_and_or]
exact Or.inl π.ne_zero
have h_unit_a : IsUnit a :=
Integers.isUnit_of_one (integer.integers v) (isUnit_iff_ne_zero.mpr ha₀) hpow
use h_unit_a.unit
rw [IsUnit.unit_spec, Subring.coe_pow, ha, ← mul_assoc, zpow_neg, hn, zpow_natCast,
mul_inv_cancel₀ (pow_ne_zero _ π.ne_zero), one_mul]
theorem Uniformizer.is_generator (π : Uniformizer v) :
maximalIdeal v.valuationSubring = Ideal.span {π.1} := by
apply (maximalIdeal.isMaximal _).eq_of_le
· intro h
rw [Ideal.span_singleton_eq_top] at h
apply π.2.not_isUnit h
· intro x hx
by_cases hx₀ : x = 0
· simp [hx₀]
· obtain ⟨n, ⟨u, hu⟩⟩ := exists_pow_Uniformizer hx₀ π
rw [← Subring.coe_mul, Subtype.coe_inj] at hu
have hn : Not (IsUnit x) := fun h ↦
(maximalIdeal.isMaximal _).ne_top (eq_top_of_isUnit_mem _ hx h)
replace hn : n ≠ 0 := fun h ↦ by
simp only [hu, h, pow_zero, one_mul, Units.isUnit, not_true] at hn
simp [Ideal.mem_span_singleton, hu, dvd_pow_self _ hn]
theorem IsUniformizer.is_generator {π : v.valuationSubring} (hπ : IsUniformizer v π) :
maximalIdeal v.valuationSubring = Ideal.span {π} :=
Uniformizer.is_generator ⟨π, hπ⟩
theorem pow_Uniformizer_is_pow_generator (π : Uniformizer v) (n : ℕ) :
maximalIdeal v.valuationSubring ^ n = Ideal.span {π.1 ^ n} := by
rw [← Ideal.span_singleton_pow, Uniformizer.is_generator]
end Uniformizer
end IsRankOneDiscrete
theorem valuationSubring_not_isField [Nontrivial ↥(valueGroup v)] [IsCyclic (valueGroup v)] :
¬ IsField K₀ := by
obtain ⟨π, hπ⟩ := exists_isUniformizer_of_isCyclic_of_nontrivial v
rintro ⟨-, -, h⟩
have := hπ.ne_zero
simp only [ne_eq, Subring.coe_eq_zero_iff] at this
specialize h this
rw [← isUnit_iff_exists_inv] at h
exact hπ.not_isUnit h
theorem isUniformizer_of_maximalIdeal_eq_span [v.IsRankOneDiscrete] {r : K₀}
(hr : maximalIdeal v.valuationSubring = Ideal.span {r}) :
IsUniformizer v r := by
have hr₀ : r ≠ 0 := by
intro h
rw [h, Set.singleton_zero, span_zero] at hr
exact Ring.ne_bot_of_isMaximal_of_not_isField (maximalIdeal.isMaximal v.valuationSubring)
(valuationSubring_not_isField v) hr
obtain ⟨π, hπ⟩ := exists_isUniformizer_of_isCyclic_of_nontrivial v
obtain ⟨n, u, hu⟩ := exists_pow_Uniformizer hr₀ ⟨π, hπ⟩
rw [Uniformizer.is_generator ⟨π, hπ⟩, span_singleton_eq_span_singleton] at hr
exact hπ.of_associated hr
theorem ideal_isPrincipal [IsCyclic (valueGroup v)] [Nontrivial (valueGroup v)] (I : Ideal K₀) :
I.IsPrincipal := by
suffices ∀ P : Ideal K₀, P.IsPrime → Submodule.IsPrincipal P by
exact (IsPrincipalIdealRing.of_prime this).principal I
intro P hP
by_cases h_ne_bot : P = ⊥
· rw [h_ne_bot]; exact bot_isPrincipal
· let π : Uniformizer v := Nonempty.some (by infer_instance)
obtain ⟨x, ⟨hx_mem, hx₀⟩⟩ := Submodule.exists_mem_ne_zero_of_ne_bot h_ne_bot
obtain ⟨n, ⟨u, hu⟩⟩ := exists_pow_Uniformizer hx₀ π
by_cases hn : n = 0
· rw [← Subring.coe_mul, hn, pow_zero, one_mul, SetLike.coe_eq_coe] at hu
refine (hP.ne_top (Ideal.eq_top_of_isUnit_mem P hx_mem ?_)).elim
simp only [hu, Units.isUnit]
· rw [← Subring.coe_mul, SetLike.coe_eq_coe] at hu
rw [hu, Ideal.mul_unit_mem_iff_mem P u.isUnit,
IsPrime.pow_mem_iff_mem hP _ (pos_iff_ne_zero.mpr hn), ← Ideal.span_singleton_le_iff_mem,
← π.is_generator ] at hx_mem
rw [← Ideal.IsMaximal.eq_of_le (IsLocalRing.maximalIdeal.isMaximal K₀) hP.ne_top hx_mem]
exact ⟨π.1, π.is_generator⟩
theorem valuationSubring_isPrincipalIdealRing [IsCyclic (valueGroup v)]
[Nontrivial (valueGroup v)] : IsPrincipalIdealRing K₀ := ⟨fun I ↦ ideal_isPrincipal v I⟩
/-- This is Chapter I, Section 1, Proposition 1 in Serre's Local Fields -/
instance valuationSubring_isDiscreteValuationRing [IsCyclic (valueGroup v)]
[Nontrivial (valueGroup v)] : IsDiscreteValuationRing K₀ where
toIsPrincipalIdealRing := valuationSubring_isPrincipalIdealRing v
toIsLocalRing := inferInstance
not_a_field' := by rw [ne_eq, ← isField_iff_maximalIdeal_eq]; exact valuationSubring_not_isField v
end Field
end Valuation
namespace IsDiscreteValuationRing
open IsDedekindDomain IsDedekindDomain.HeightOneSpectrum IsDiscreteValuationRing
IsLocalRing MonoidWithZeroHom Multiplicative Subring Valuation
variable (A K : Type*) [CommRing A] [IsDomain A] [IsDiscreteValuationRing A] [Field K]
[Algebra A K] [IsFractionRing A K]
/-- The maximal ideal of a discrete valuation ring. -/
def maximalIdeal : HeightOneSpectrum A where
asIdeal := IsLocalRing.maximalIdeal A
isPrime := Ideal.IsMaximal.isPrime (maximalIdeal.isMaximal A)
ne_bot := by simpa [ne_eq, ← isField_iff_maximalIdeal_eq] using not_isField A
instance isRankOneDiscrete :
IsRankOneDiscrete ((maximalIdeal A).valuation K) := by
have : Nontrivial ↥(valueGroup (valuation K (maximalIdeal A))) := by
let v := (maximalIdeal A).valuation K
let π := valuation_exists_uniformizer K (maximalIdeal A)|>.choose
have hπ : v π = ↑(ofAdd (-1 : ℤ)) :=
valuation_exists_uniformizer K (maximalIdeal A)|>.choose_spec
rw [Subgroup.nontrivial_iff_exists_ne_one]
use Units.mk0 (v π) (by simp [hπ])
constructor
· apply mem_valueGroup
simp only [Units.val_mk0, Set.mem_range]
use π
· simpa [hπ] using not_eq_of_beq_eq_false rfl
infer_instance
variable {A K}
open scoped WithZero
theorem exists_lift_of_le_one {x : K} (H : ((maximalIdeal A).valuation K) x ≤ (1 : ℤᵐ⁰)) :
∃ a : A, algebraMap A K a = x := by
obtain ⟨π, hπ⟩ := exists_irreducible A
obtain ⟨a, b, hb, h_frac⟩ := IsFractionRing.div_surjective (A := A) x
by_cases ha : a = 0
· rw [← h_frac]
use 0
rw [ha, map_zero, zero_div]
· rw [← h_frac] at H
obtain ⟨n, u, rfl⟩ := eq_unit_mul_pow_irreducible ha hπ
obtain ⟨m, w, rfl⟩ := eq_unit_mul_pow_irreducible (nonZeroDivisors.ne_zero hb) hπ
replace hb := (mul_mem_nonZeroDivisors.mp hb).2
rw [mul_comm (w : A) _, map_mul _ (u : A) _, map_mul _ _ (w : A), div_eq_mul_inv, mul_assoc,
Valuation.map_mul, Integers.one_of_isUnit' u.isUnit (valuation_le_one _), one_mul,
mul_inv, ← mul_assoc, Valuation.map_mul, map_mul, map_inv₀, map_inv₀,
Integers.one_of_isUnit' w.isUnit (valuation_le_one _), inv_one, mul_one, ← div_eq_mul_inv,
← map_div₀, ← IsFractionRing.mk'_mk_eq_div hb,
valuation_of_mk', map_pow, map_pow] at H
have h_mn : m ≤ n := by
have v_π_lt_one := (intValuation_lt_one_iff_dvd (maximalIdeal A) π).mpr
(dvd_of_eq ((irreducible_iff_uniformizer _).mp hπ))
have v_π_ne_zero : (maximalIdeal A).intValuation π ≠ 0 := intValuation_ne_zero _ _ hπ.ne_zero
zify
rw [← WithZero.coe_one, div_eq_mul_inv, ← zpow_natCast, ← zpow_natCast, ← ofAdd_zero,
← zpow_neg, ← zpow_add₀ v_π_ne_zero, ← sub_eq_add_neg] at H
rwa [← sub_nonneg, ← zpow_le_one_iff_right_of_lt_one₀ (zero_lt_iff.mpr v_π_ne_zero)
v_π_lt_one]
use u * π ^ (n - m) * w.2
simp only [← h_frac, Units.inv_eq_val_inv, _root_.map_mul, _root_.map_pow, map_units_inv,
mul_assoc, mul_div_assoc ((algebraMap A _) ↑u) _ _]
congr 1
rw [div_eq_mul_inv, mul_inv, mul_comm ((algebraMap A _) ↑w)⁻¹ _, ←
mul_assoc _ _ ((algebraMap A _) ↑w)⁻¹]
congr
rw [pow_sub₀ _ _ h_mn]
apply IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors
rw [mem_nonZeroDivisors_iff_ne_zero]
exact hπ.ne_zero
theorem map_algebraMap_eq_valuationSubring : Subring.map (algebraMap A K) ⊤ =
((maximalIdeal A).valuation K).valuationSubring.toSubring := by
ext
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· obtain ⟨_, _, rfl⟩ := Subring.mem_map.mp h
apply valuation_le_one
· obtain ⟨y, rfl⟩ := exists_lift_of_le_one h
rw [Subring.mem_map]
exact ⟨y, mem_top _, rfl⟩
/-- The ring isomorphism between a DVR `A` and the valuation subring of a field of fractions
of `A` endowed with the adic valuation of the maximal ideal. -/
noncomputable def equivValuationSubring :
A ≃+* ((maximalIdeal A).valuation K).valuationSubring :=
(topEquiv.symm.trans (equivMapOfInjective ⊤ (algebraMap A K)
(IsFractionRing.injective A _))).trans
(RingEquiv.subringCongr map_algebraMap_eq_valuationSubring)
end IsDiscreteValuationRing |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/ValuativeRel/Trivial.lean | import Mathlib.RingTheory.Valuation.ValuativeRel.Basic
/-!
# Trivial Valuative Relations
Trivial valuative relations relate all non-zero elements to each other. Equivalently,
all elements are related to `1`: the relation is equal to the relation induced
by the trivial valuation which sends all non-zero elements to `1`.
## TODO
A trivial valuative relation is equivalent to the value group being isomorphic to `WithZero Unit`.
-/
namespace ValuativeRel
variable {R Γ : Type} [CommRing R] [DecidableEq R] [IsDomain R]
[LinearOrderedCommGroupWithZero Γ]
open WithZero
/-- The trivial valuative relation on a domain `R`, such that all non-zero elements are related.
The domain condition is necessary so that the relation is closed when multiplying.
-/
def trivialRel : ValuativeRel R where
rel x y := if y = 0 then x = 0 else True
rel_total _ _ := by split_ifs <;> simp_all
rel_trans _ _ := by split_ifs; simp_all
rel_add _ _ := by split_ifs; simp_all
rel_mul_right _ := by split_ifs <;> simp_all
rel_mul_cancel _ := by split_ifs <;> simp_all
not_rel_one_zero := by split_ifs <;> simp_all
lemma eq_trivialRel_of_compatible_one [h : ValuativeRel R]
[hv : Valuation.Compatible (1 : Valuation R Γ)] : h = trivialRel := by
ext
change _ ↔ if _ = 0 then _ else _
rw [hv.rel_iff_le]
split_ifs <;>
simp_all [Valuation.one_apply_of_ne_zero, Valuation.one_apply_le_one]
lemma trivialRel_eq_ofValuation_one :
trivialRel = ValuativeRel.ofValuation (1 : Valuation R Γ) := by
convert (eq_trivialRel_of_compatible_one (Γ := Γ)).symm
exact Valuation.Compatible.ofValuation 1
variable (R Γ) in
lemma subsingleton_units_valueGroupWithZero_of_trivialRel [ValuativeRel R]
[Valuation.Compatible (1 : Valuation R Γ)] :
Subsingleton (ValueGroupWithZero R)ˣ := by
constructor
intro a b
have : (valuation R).IsEquiv (1 : Valuation R Γ) := isEquiv _ _
obtain ⟨r, s, hr⟩ := exists_valuation_posSubmonoid_div_valuation_posSubmonoid_eq a
obtain ⟨t, u, ht⟩ := exists_valuation_posSubmonoid_div_valuation_posSubmonoid_eq b
rw [Units.ext_iff, ← hr, ← ht, div_eq_div_iff, ← map_mul, ← map_mul, this.val_eq] <;>
simp [one_apply_posSubmonoid]
lemma not_isNontrivial_of_trivialRel [ValuativeRel R] [Valuation.Compatible (1 : Valuation R Γ)] :
¬ IsNontrivial R := by
rintro ⟨⟨x, hx, hx'⟩⟩
have := subsingleton_units_valueGroupWithZero_of_trivialRel R Γ
rcases GroupWithZero.eq_zero_or_unit x with rfl | ⟨u, rfl⟩
· simp_all
· simp_all [Subsingleton.elim u 1]
lemma isDiscrete_trivialRel [ValuativeRel R] [Valuation.Compatible (1 : Valuation R Γ)] :
IsDiscrete R := by
refine ⟨⟨0, zero_lt_one, fun x ↦ ?_⟩⟩
have := subsingleton_units_valueGroupWithZero_of_trivialRel R Γ
rcases GroupWithZero.eq_zero_or_unit x with rfl | ⟨u, rfl⟩
· simp_all
· rw [← Units.val_one, Units.val_lt_val]
simp
end ValuativeRel |
.lake/packages/mathlib/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean | import Mathlib.RingTheory.Valuation.Basic
import Mathlib.Data.NNReal.Defs
import Mathlib.Topology.Defs.Filter
/-!
# Valuative Relations
In this file we introduce a class called `ValuativeRel R` for a ring `R`.
This bundles a relation `rel : R → R → Prop` on `R` which mimics a
preorder on `R` arising from a valuation.
We introduce the notation `x ≤ᵥ y` for this relation.
Recall that the equivalence class of a valuation is *completely* characterized by
such a preorder. Thus, we can think of `ValuativeRel R` as a way of
saying that `R` is endowed with an equivalence class of valuations.
## Main Definitions
- `ValuativeRel R` endows a commutative ring `R` with a relation arising from a valuation.
This is equivalent to fixing an equivalence class of valuations on `R`.
Use the notation `x ≤ᵥ y` for this relation.
- `ValuativeRel.valuation R` is the "canonical" valuation associated to `ValuativeRel R`,
taking values in `ValuativeRel.ValueGroupWithZero R`.
- Given a valuation `v` on `R` and an instance `[ValuativeRel R]`, writing `[v.Compatible]`
ensures that the relation `x ≤ᵥ y` is equivalent to `v x ≤ v y`. Note that
it is possible to have `[v.Compatible]` and `[w.Compatible]` for two different valuations on `R`.
- If we have both `[ValuativeRel R]` and `[TopologicalSpace R]`, then writing
`[IsValuativeTopology R]` ensures that the topology on `R` agrees with the one induced by the
valuation.
- Given `[ValuativeRel A]`, `[ValuativeRel B]` and `[Algebra A B]`, the class
`[ValuativeExtension A B]` ensures that the algebra map `A → B` is compatible with the valuations
on `A` and `B`. For example, this can be used to talk about extensions of valued fields.
## Remark
The last two axioms in `ValuativeRel`, namely `rel_mul_cancel` and `not_rel_one_zero`, are
used to ensure that we have a well-behaved valuation taking values in a *value group* (with zero).
In principle, it should be possible to drop these two axioms and obtain a value monoid,
however, such a value monoid would not necessarily embed into an ordered abelian group with zero.
Similarly, without these axioms, the support of the valuation need not be a prime ideal.
We have thus opted to include these two axioms and obtain a `ValueGroupWithZero` associated to
a `ValuativeRel` in order to best align with the literature about valuations on commutative rings.
Future work could refactor `ValuativeRel` by dropping the `rel_mul_cancel` and `not_rel_one_zero`
axioms, opting to make these mixins instead.
## Projects
The `ValuativeRel` class should eventually replace the existing `Valued` typeclass.
Once such a refactor happens, `ValuativeRel` could be renamed to `Valued`.
-/
noncomputable section
/-- The class `[ValuativeRel R]` class introduces an operator `x ≤ᵥ y : Prop` for `x y : R`
which is the natural relation arising from (the equivalence class of) a valuation on `R`.
More precisely, if v is a valuation on R then the associated relation is `x ≤ᵥ y ↔ v x ≤ v y`.
Use this class to talk about the case where `R` is equipped with an equivalence class
of valuations. -/
@[ext]
class ValuativeRel (R : Type*) [CommRing R] where
/-- The relation operator arising from `ValuativeRel`. -/
rel : R → R → Prop
rel_total (x y) : rel x y ∨ rel y x
rel_trans {z y x} : rel x y → rel y z → rel x z
rel_add {x y z} : rel x z → rel y z → rel (x + y) z
rel_mul_right {x y} (z) : rel x y → rel (x * z) (y * z)
rel_mul_cancel {x y z} : ¬ rel z 0 → rel (x * z) (y * z) → rel x y
not_rel_one_zero : ¬ rel 1 0
@[inherit_doc] infix:50 " ≤ᵥ " => ValuativeRel.rel
macro_rules | `($a ≤ᵥ $b) => `(binrel% ValuativeRel.rel $a $b)
namespace Valuation
variable {R Γ : Type*} [CommRing R] [LinearOrderedCommMonoidWithZero Γ]
(v : Valuation R Γ)
/-- We say that a valuation `v` is `Compatible` if the relation `x ≤ᵥ y`
is equivalent to `v x ≤ x y`. -/
class Compatible [ValuativeRel R] where
rel_iff_le (x y : R) : x ≤ᵥ y ↔ v x ≤ v y
end Valuation
/-- A preorder on a ring is said to be "valuative" if it agrees with the
valuative relation. -/
class ValuativePreorder (R : Type*) [CommRing R] [ValuativeRel R] [Preorder R] where
rel_iff_le (x y : R) : x ≤ᵥ y ↔ x ≤ y
namespace ValuativeRel
variable {R : Type*} [CommRing R] [ValuativeRel R]
/-- The strict version of the valuative relation. -/
def srel (x y : R) : Prop := ¬ y ≤ᵥ x
@[inherit_doc] infix:50 " <ᵥ " => ValuativeRel.srel
macro_rules | `($a <ᵥ $b) => `(binrel% ValuativeRel.srel $a $b)
lemma srel_iff (x y : R) : x <ᵥ y ↔ ¬ y ≤ᵥ x := Iff.rfl
@[simp]
lemma not_srel_iff {x y : R} : ¬ x <ᵥ y ↔ y ≤ᵥ x := Iff.rfl.not_left
@[simp]
lemma rel_refl (x : R) : x ≤ᵥ x := by
cases rel_total x x <;> assumption
lemma rel_rfl {x : R} : x ≤ᵥ x :=
rel_refl x
protected alias rel.refl := rel_refl
protected alias rel.rfl := rel_rfl
@[simp]
theorem zero_rel (x : R) : 0 ≤ᵥ x := by
simpa using rel_mul_right x ((rel_total 0 1).resolve_right not_rel_one_zero)
@[simp]
lemma zero_srel_one : (0 : R) <ᵥ 1 :=
not_rel_one_zero
lemma rel_mul_left {x y : R} (z) : x ≤ᵥ y → (z * x) ≤ᵥ (z * y) := by
rw [mul_comm z x, mul_comm z y]
apply rel_mul_right
instance : Trans (rel (R := R)) (rel (R := R)) (rel (R := R)) where
trans h1 h2 := rel_trans h1 h2
protected alias rel.trans := rel_trans
lemma rel_trans' {x y z : R} (h1 : y ≤ᵥ z) (h2 : x ≤ᵥ y) : x ≤ᵥ z :=
h2.trans h1
protected alias rel.trans' := rel_trans'
lemma rel_mul {x x' y y' : R} (h1 : x ≤ᵥ y) (h2 : x' ≤ᵥ y') : (x * x') ≤ᵥ y * y' := by
calc x * x' ≤ᵥ x * y' := rel_mul_left _ h2
_ ≤ᵥ y * y' := rel_mul_right _ h1
theorem rel_add_cases (x y : R) : x + y ≤ᵥ x ∨ x + y ≤ᵥ y :=
(rel_total y x).imp (fun h => rel_add .rfl h) (fun h => rel_add h .rfl)
lemma zero_srel_mul {x y : R} (hx : 0 <ᵥ x) (hy : 0 <ᵥ y) : 0 <ᵥ x * y := by
contrapose! hy
rw [not_srel_iff] at hy ⊢
rw [show (0 : R) = x * 0 by simp, mul_comm x y, mul_comm x 0] at hy
exact rel_mul_cancel hx hy
variable (R) in
/-- The submonoid of elements `x : R` whose valuation is positive. -/
def posSubmonoid : Submonoid R where
carrier := { x | 0 <ᵥ x }
mul_mem' := zero_srel_mul
one_mem' := zero_srel_one
@[simp]
lemma posSubmonoid_def (x : R) : x ∈ posSubmonoid R ↔ 0 <ᵥ x := Iff.rfl
@[simp]
lemma right_cancel_posSubmonoid (x y : R) (u : posSubmonoid R) :
x * u ≤ᵥ y * u ↔ x ≤ᵥ y := ⟨rel_mul_cancel u.prop, rel_mul_right _⟩
@[simp]
lemma left_cancel_posSubmonoid (x y : R) (u : posSubmonoid R) :
u * x ≤ᵥ u * y ↔ x ≤ᵥ y := by
simp only [← right_cancel_posSubmonoid x y u, mul_comm]
@[simp]
lemma val_posSubmonoid_ne_zero (x : posSubmonoid R) :
(x : R) ≠ 0 := by
have := x.prop
rw [posSubmonoid_def] at this
contrapose! this
simp [this]
variable (R) in
/-- The setoid used to construct `ValueGroupWithZero R`. -/
def valueSetoid : Setoid (R × posSubmonoid R) where
r := fun (x, s) (y, t) => x * t ≤ᵥ y * s ∧ y * s ≤ᵥ x * t
iseqv := {
refl ru := ⟨rel_refl _, rel_refl _⟩
symm h := ⟨h.2, h.1⟩
trans := by
rintro ⟨r, u⟩ ⟨s, v⟩ ⟨t, w⟩ ⟨h1, h2⟩ ⟨h3, h4⟩
constructor
· have := rel_mul h1 (rel_refl ↑w)
rw [mul_right_comm s] at this
have := rel_trans this (rel_mul h3 (rel_refl _))
rw [mul_right_comm r, mul_right_comm t] at this
simpa using this
· have := rel_mul h4 (rel_refl ↑u)
rw [mul_right_comm s] at this
have := rel_trans this (rel_mul h2 (rel_refl _))
rw [mul_right_comm t, mul_right_comm r] at this
simpa using this
}
variable (R) in
/-- The "canonical" value group-with-zero of a ring with a valuative relation. -/
def ValueGroupWithZero := Quotient (valueSetoid R)
/-- Construct an element of the value group-with-zero from an element `r : R` and
`y : posSubmonoid R`. This should be thought of as `v r / v y`. -/
protected
def ValueGroupWithZero.mk (x : R) (y : posSubmonoid R) : ValueGroupWithZero R :=
Quotient.mk _ (x, y)
protected
theorem ValueGroupWithZero.sound {x y : R} {t s : posSubmonoid R}
(h₁ : x * s ≤ᵥ y * t) (h₂ : y * t ≤ᵥ x * s) :
ValueGroupWithZero.mk x t = ValueGroupWithZero.mk y s :=
Quotient.sound ⟨h₁, h₂⟩
protected
theorem ValueGroupWithZero.exact {x y : R} {t s : posSubmonoid R}
(h : ValueGroupWithZero.mk x t = ValueGroupWithZero.mk y s) :
x * s ≤ᵥ y * t ∧ y * t ≤ᵥ x * s :=
Quotient.exact h
protected
theorem ValueGroupWithZero.ind {motive : ValueGroupWithZero R → Prop} (mk : ∀ x y, motive (.mk x y))
(t : ValueGroupWithZero R) : motive t :=
Quotient.ind (fun (x, y) => mk x y) t
/-- Lifts a function `R → posSubmonoid R → α` to the value group-with-zero of `R`. -/
protected
def ValueGroupWithZero.lift {α : Sort*} (f : R → posSubmonoid R → α)
(hf : ∀ (x y : R) (t s : posSubmonoid R), x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → f x s = f y t)
(t : ValueGroupWithZero R) : α :=
Quotient.lift (fun (x, y) => f x y) (fun (x, t) (y, s) ⟨h₁, h₂⟩ => hf x y s t h₁ h₂) t
@[simp] protected
theorem ValueGroupWithZero.lift_mk {α : Sort*} (f : R → posSubmonoid R → α)
(hf : ∀ (x y : R) (t s : posSubmonoid R), x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → f x s = f y t)
(x : R) (y : posSubmonoid R) : ValueGroupWithZero.lift f hf (.mk x y) = f x y := rfl
/-- Lifts a function `R → posSubmonoid R → R → posSubmonoid R → α` to
the value group-with-zero of `R`. -/
protected
def ValueGroupWithZero.lift₂ {α : Sort*} (f : R → posSubmonoid R → R → posSubmonoid R → α)
(hf : ∀ (x y z w : R) (t s u v : posSubmonoid R),
x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → z * u ≤ᵥ w * v → w * v ≤ᵥ z * u →
f x s z v = f y t w u)
(t₁ : ValueGroupWithZero R) (t₂ : ValueGroupWithZero R) : α :=
Quotient.lift₂ (fun (x, t) (y, s) => f x t y s)
(fun (x, t) (z, v) (y, s) (w, u) ⟨h₁, h₂⟩ ⟨h₃, h₄⟩ => hf x y z w s t u v h₁ h₂ h₃ h₄) t₁ t₂
@[simp] protected
lemma ValueGroupWithZero.lift₂_mk {α : Sort*} (f : R → posSubmonoid R → R → posSubmonoid R → α)
(hf : ∀ (x y z w : R) (t s u v : posSubmonoid R),
x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → z * u ≤ᵥ w * v → w * v ≤ᵥ z * u →
f x s z v = f y t w u)
(x y : R) (z w : posSubmonoid R) :
ValueGroupWithZero.lift₂ f hf (.mk x z) (.mk y w) = f x z y w := rfl
theorem ValueGroupWithZero.mk_eq_mk {x y : R} {t s : posSubmonoid R} :
ValueGroupWithZero.mk x t = ValueGroupWithZero.mk y s ↔ x * s ≤ᵥ y * t ∧ y * t ≤ᵥ x * s :=
Quotient.eq
instance : Zero (ValueGroupWithZero R) where
zero := .mk 0 1
@[simp]
theorem ValueGroupWithZero.mk_eq_zero (x : R) (y : posSubmonoid R) :
ValueGroupWithZero.mk x y = 0 ↔ x ≤ᵥ 0 :=
⟨fun h => by simpa using ValueGroupWithZero.mk_eq_mk.mp h,
fun h => ValueGroupWithZero.sound (by simpa using h) (by simp)⟩
@[simp]
theorem ValueGroupWithZero.mk_zero (x : posSubmonoid R) : ValueGroupWithZero.mk 0 x = 0 :=
(ValueGroupWithZero.mk_eq_zero 0 x).mpr .rfl
instance : One (ValueGroupWithZero R) where
one := .mk 1 1
@[simp]
theorem ValueGroupWithZero.mk_self (x : posSubmonoid R) : ValueGroupWithZero.mk (x : R) x = 1 :=
ValueGroupWithZero.sound (by simp) (by simp)
@[simp]
theorem ValueGroupWithZero.mk_one_one : ValueGroupWithZero.mk (1 : R) 1 = 1 :=
ValueGroupWithZero.sound (by simp) (by simp)
@[simp]
theorem ValueGroupWithZero.mk_eq_one (x : R) (y : posSubmonoid R) :
ValueGroupWithZero.mk x y = 1 ↔ x ≤ᵥ y ∧ y ≤ᵥ x := by
simp [← mk_one_one, mk_eq_mk]
theorem ValueGroupWithZero.lift_zero {α : Sort*} (f : R → posSubmonoid R → α)
(hf : ∀ (x y : R) (t s : posSubmonoid R), x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → f x s = f y t) :
ValueGroupWithZero.lift f hf 0 = f 0 1 :=
rfl
@[simp]
theorem ValueGroupWithZero.lift_one {α : Sort*} (f : R → posSubmonoid R → α)
(hf : ∀ (x y : R) (t s : posSubmonoid R), x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → f x s = f y t) :
ValueGroupWithZero.lift f hf 1 = f 1 1 :=
rfl
instance : Mul (ValueGroupWithZero R) where
mul := ValueGroupWithZero.lift₂ (fun a b c d => .mk (a * c) (b * d)) <| by
intro x y z w t s u v h₁ h₂ h₃ h₄
apply ValueGroupWithZero.sound
· rw [Submonoid.coe_mul, Submonoid.coe_mul,
mul_mul_mul_comm x, mul_mul_mul_comm y]
exact rel_mul h₁ h₃
· rw [Submonoid.coe_mul, Submonoid.coe_mul,
mul_mul_mul_comm x, mul_mul_mul_comm y]
exact rel_mul h₂ h₄
@[simp]
theorem ValueGroupWithZero.mk_mul_mk (a b : R) (c d : posSubmonoid R) :
ValueGroupWithZero.mk a c * ValueGroupWithZero.mk b d = ValueGroupWithZero.mk (a * b) (c * d) :=
rfl
theorem ValueGroupWithZero.lift_mul {α : Type*} [Mul α] (f : R → posSubmonoid R → α)
(hf : ∀ (x y : R) (t s : posSubmonoid R), x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → f x s = f y t)
(hdist : ∀ (a b r s), f (a * b) (r * s) = f a r * f b s)
(a b : ValueGroupWithZero R) :
ValueGroupWithZero.lift f hf (a * b) =
ValueGroupWithZero.lift f hf a * ValueGroupWithZero.lift f hf b := by
induction a using ValueGroupWithZero.ind
induction b using ValueGroupWithZero.ind
simpa using hdist _ _ _ _
instance : CommMonoidWithZero (ValueGroupWithZero R) where
mul_assoc a b c := by
induction a using ValueGroupWithZero.ind
induction b using ValueGroupWithZero.ind
induction c using ValueGroupWithZero.ind
simp [mul_assoc]
one_mul := ValueGroupWithZero.ind <| by simp [← ValueGroupWithZero.mk_one_one]
mul_one := ValueGroupWithZero.ind <| by simp [← ValueGroupWithZero.mk_one_one]
zero_mul := ValueGroupWithZero.ind <| fun _ _ => by
rw [← ValueGroupWithZero.mk_zero 1, ValueGroupWithZero.mk_mul_mk]
simp
mul_zero := ValueGroupWithZero.ind <| fun _ _ => by
rw [← ValueGroupWithZero.mk_zero 1, ValueGroupWithZero.mk_mul_mk]
simp
mul_comm a b := by
induction a using ValueGroupWithZero.ind
induction b using ValueGroupWithZero.ind
simp [mul_comm]
npow n := ValueGroupWithZero.lift (fun a b => ValueGroupWithZero.mk (a ^ n) (b ^ n)) <| by
intro x y t s h₁ h₂
induction n with
| zero => simp
| succ n ih =>
simp only [pow_succ, ← ValueGroupWithZero.mk_mul_mk, ih]
apply congrArg (_ * ·)
exact ValueGroupWithZero.sound h₁ h₂
npow_zero := ValueGroupWithZero.ind (by simp)
npow_succ n := ValueGroupWithZero.ind (by simp [pow_succ])
instance : LE (ValueGroupWithZero R) where
le := ValueGroupWithZero.lift₂ (fun a s b t => a * t ≤ᵥ b * s) <| by
intro x y z w t s u v h₁ h₂ h₃ h₄
by_cases hw : w ≤ᵥ 0 <;> by_cases hz : z ≤ᵥ 0
· refine propext ⟨fun h => rel_trans ?_ (zero_rel _), fun h => rel_trans ?_ (zero_rel _)⟩
· apply rel_mul_cancel (s * v).prop
rw [mul_right_comm, Submonoid.coe_mul, ← mul_assoc]
apply rel_trans (rel_mul_right (u : R) (rel_mul_right (v : R) h₂))
rw [mul_right_comm x]
apply rel_trans (rel_mul_right (u : R) (rel_mul_right (t : R) h))
apply rel_trans (rel_mul_right (u : R) (rel_mul_right (t : R) (rel_mul_right (s : R) hz)))
simp
· apply rel_mul_cancel (t * u).prop
rw [mul_right_comm, Submonoid.coe_mul, ← mul_assoc]
apply rel_trans (rel_mul_right (v : R) (rel_mul_right (u : R) h₁))
rw [mul_right_comm y]
apply rel_trans (rel_mul_right (v : R) (rel_mul_right (s : R) h))
apply rel_trans (rel_mul_right (v : R) (rel_mul_right (s : R) (rel_mul_right (t : R) hw)))
simp
· absurd hz
apply rel_mul_cancel u.prop
simpa using rel_trans h₃ (rel_mul_right (v : R) hw)
· absurd hw
apply rel_mul_cancel v.prop
simpa using rel_trans h₄ (rel_mul_right (u : R) hz)
· refine propext ⟨fun h => ?_, fun h => ?_⟩
· apply rel_mul_cancel s.prop
apply rel_mul_cancel hz
calc y * u * s * z
_ = y * s * (z * u) := by ring
_ ≤ᵥ x * t * (w * v) := rel_mul h₂ h₃
_ = x * v * (t * w) := by ring
_ ≤ᵥ z * s * (t * w) := rel_mul_right (t * w) h
_ = w * t * s * z := by ring
· apply rel_mul_cancel t.prop
apply rel_mul_cancel hw
calc x * v * t * w
_ = x * t * (w * v) := by ring
_ ≤ᵥ y * s * (z * u) := rel_mul h₁ h₄
_ = y * u * (s * z) := by ring
_ ≤ᵥ w * t * (s * z) := rel_mul_right (s * z) h
_ = z * s * t * w := by ring
@[simp]
theorem ValueGroupWithZero.mk_le_mk (x y : R) (t s : posSubmonoid R) :
ValueGroupWithZero.mk x t ≤ ValueGroupWithZero.mk y s ↔ x * s ≤ᵥ y * t := Iff.rfl
instance : LinearOrder (ValueGroupWithZero R) where
le_refl := ValueGroupWithZero.ind fun _ _ => .rfl
le_trans a b c hab hbc := by
induction a using ValueGroupWithZero.ind with | mk a₁ a₂
induction b using ValueGroupWithZero.ind with | mk b₁ b₂
induction c using ValueGroupWithZero.ind with | mk c₁ c₂
rw [ValueGroupWithZero.mk_le_mk] at hab hbc ⊢
apply rel_mul_cancel b₂.prop
calc a₁ * c₂ * b₂
_ = a₁ * b₂ * c₂ := by rw [mul_right_comm]
_ ≤ᵥ b₁ * a₂ * c₂ := rel_mul_right (c₂ : R) hab
_ = b₁ * c₂ * a₂ := by rw [mul_right_comm]
_ ≤ᵥ c₁ * b₂ * a₂ := rel_mul_right (a₂ : R) hbc
_ = c₁ * a₂ * b₂ := by rw [mul_right_comm]
le_antisymm a b hab hba := by
induction a using ValueGroupWithZero.ind
induction b using ValueGroupWithZero.ind
exact ValueGroupWithZero.sound hab hba
le_total a b := by
induction a using ValueGroupWithZero.ind
induction b using ValueGroupWithZero.ind
rw [ValueGroupWithZero.mk_le_mk, ValueGroupWithZero.mk_le_mk]
apply rel_total
toDecidableLE := Classical.decRel LE.le
@[simp]
theorem ValueGroupWithZero.mk_lt_mk (x y : R) (t s : posSubmonoid R) :
ValueGroupWithZero.mk x t < ValueGroupWithZero.mk y s ↔ x * s <ᵥ y * t := by
rw [lt_iff_not_ge, srel_iff, mk_le_mk]
instance : Bot (ValueGroupWithZero R) where
bot := 0
theorem ValueGroupWithZero.bot_eq_zero : (⊥ : ValueGroupWithZero R) = 0 := rfl
instance : OrderBot (ValueGroupWithZero R) where
bot_le := ValueGroupWithZero.ind fun x y => by
rw [ValueGroupWithZero.bot_eq_zero, ← ValueGroupWithZero.mk_zero 1, ValueGroupWithZero.mk_le_mk]
simp
instance : IsOrderedMonoid (ValueGroupWithZero R) where
mul_le_mul_left a b hab c := by
induction a using ValueGroupWithZero.ind
induction b using ValueGroupWithZero.ind
induction c using ValueGroupWithZero.ind
simp only [ValueGroupWithZero.mk_mul_mk, ValueGroupWithZero.mk_le_mk, Submonoid.coe_mul]
conv_lhs => apply mul_mul_mul_comm
conv_rhs => apply mul_mul_mul_comm
exact rel_mul_left _ hab
instance : Inv (ValueGroupWithZero R) where
inv := ValueGroupWithZero.lift (fun x s => by
classical exact if h : x ≤ᵥ 0 then 0 else .mk s ⟨x, h⟩) <| by
intro x y t s h₁ h₂
by_cases hx : x ≤ᵥ 0 <;> by_cases hy : y ≤ᵥ 0
· simp [hx, hy]
· absurd hy
apply rel_mul_cancel s.prop
simpa using rel_trans h₂ (rel_mul_right (t : R) hx)
· absurd hx
apply rel_mul_cancel t.prop
simpa using rel_trans h₁ (rel_mul_right (s : R) hy)
· simp only [dif_neg hx, dif_neg hy]
apply ValueGroupWithZero.sound
· simpa [mul_comm] using h₂
· simpa [mul_comm] using h₁
@[simp]
theorem ValueGroupWithZero.inv_mk (x : R) (y : posSubmonoid R) (hx : ¬x ≤ᵥ 0) :
(ValueGroupWithZero.mk x y)⁻¹ = ValueGroupWithZero.mk (y : R) ⟨x, hx⟩ := dif_neg hx
/-- The value group-with-zero is a linearly ordered commutative group with zero. -/
instance : LinearOrderedCommGroupWithZero (ValueGroupWithZero R) where
zero_le_one := bot_le
exists_pair_ne := by
refine ⟨0, 1, fun h => ?_⟩
apply ge_of_eq at h
rw [← ValueGroupWithZero.mk_zero 1, ← ValueGroupWithZero.mk_one_one,
ValueGroupWithZero.mk_le_mk] at h
simp [not_rel_one_zero] at h
inv_zero := dif_pos .rfl
mul_inv_cancel := ValueGroupWithZero.ind fun x y h => by
rw [ne_eq, ← ValueGroupWithZero.mk_zero 1, ValueGroupWithZero.mk_eq_mk] at h
simp only [Submonoid.coe_one, mul_one, zero_mul, zero_rel, and_true] at h
rw [ValueGroupWithZero.inv_mk x y h, ← ValueGroupWithZero.mk_one_one,
ValueGroupWithZero.mk_mul_mk, ValueGroupWithZero.mk_eq_mk]
simp [mul_comm]
variable (R) in
/-- The "canonical" valuation associated to a valuative relation. -/
def valuation : Valuation R (ValueGroupWithZero R) where
toFun r := ValueGroupWithZero.mk r 1
map_zero' := rfl
map_one' := rfl
map_mul' _ _ := by simp
map_add_le_max' := by simp [rel_add_cases]
instance : (valuation R).Compatible where
rel_iff_le _ _ := by simp [valuation]
@[simp]
lemma ValueGroupWithZero.lift_valuation {α : Sort*} (f : R → posSubmonoid R → α)
(hf : ∀ (x y : R) (t s : posSubmonoid R), x * t ≤ᵥ y * s → y * s ≤ᵥ x * t → f x s = f y t)
(x : R) :
ValueGroupWithZero.lift f hf (valuation R x) = f x 1 :=
rfl
lemma valuation_eq_zero_iff {x : R} :
valuation R x = 0 ↔ x ≤ᵥ 0 :=
ValueGroupWithZero.mk_eq_zero _ _
lemma valuation_posSubmonoid_ne_zero (x : posSubmonoid R) :
valuation R (x : R) ≠ 0 := by
rw [ne_eq, valuation_eq_zero_iff]
exact x.prop
lemma ValueGroupWithZero.mk_eq_div (r : R) (s : posSubmonoid R) :
ValueGroupWithZero.mk r s = valuation R r / valuation R (s : R) := by
rw [eq_div_iff (valuation_posSubmonoid_ne_zero _)]
simp [valuation, mk_eq_mk]
/-- Construct a valuative relation on a ring using a valuation. -/
def ofValuation
{S Γ : Type*} [CommRing S]
[LinearOrderedCommGroupWithZero Γ]
(v : Valuation S Γ) : ValuativeRel S where
rel x y := v x ≤ v y
rel_total x y := le_total (v x) (v y)
rel_trans := le_trans
rel_add hab hbc := (map_add_le_max v _ _).trans (sup_le hab hbc)
rel_mul_right _ h := by simp [map_mul]; gcongr
rel_mul_cancel h0 h := by
rw [map_zero, le_zero_iff] at h0
simp only [map_mul] at h
exact le_of_mul_le_mul_right h (lt_of_le_of_ne' zero_le' h0)
not_rel_one_zero := by simp
lemma _root_.Valuation.Compatible.ofValuation
{S Γ : Type*} [CommRing S]
[LinearOrderedCommGroupWithZero Γ]
(v : Valuation S Γ) :
letI := ValuativeRel.ofValuation v -- letI so that instance is inlined directly in declaration
Valuation.Compatible v :=
letI := ValuativeRel.ofValuation v
⟨fun _ _ ↦ Iff.rfl⟩
lemma isEquiv {Γ₁ Γ₂ : Type*}
[LinearOrderedCommMonoidWithZero Γ₁]
[LinearOrderedCommMonoidWithZero Γ₂]
(v₁ : Valuation R Γ₁)
(v₂ : Valuation R Γ₂)
[v₁.Compatible] [v₂.Compatible] :
v₁.IsEquiv v₂ := by
intro x y
simp_rw [← Valuation.Compatible.rel_iff_le]
lemma _root_.Valuation.Compatible.srel_iff_lt {Γ₀ : Type*}
[LinearOrderedCommMonoidWithZero Γ₀] {v : Valuation R Γ₀} [v.Compatible] {x y : R} :
x <ᵥ y ↔ v x < v y := by
simp [lt_iff_not_ge, ← Valuation.Compatible.rel_iff_le, srel_iff]
@[simp]
lemma _root_.Valuation.apply_posSubmonoid_ne_zero {Γ : Type*} [LinearOrderedCommMonoidWithZero Γ]
(v : Valuation R Γ) [v.Compatible] (x : posSubmonoid R) :
v (x : R) ≠ 0 := by
simp [(isEquiv v (valuation R)).ne_zero, valuation_posSubmonoid_ne_zero]
@[deprecated (since := "2025-08-06")]
alias valuation_posSubmonoid_ne_zero_of_compatible := _root_.Valuation.apply_posSubmonoid_ne_zero
@[simp]
lemma _root_.Valuation.apply_posSubmonoid_pos {Γ : Type*} [LinearOrderedCommMonoidWithZero Γ]
(v : Valuation R Γ) [v.Compatible] (x : posSubmonoid R) :
0 < v x :=
zero_lt_iff.mpr <| v.apply_posSubmonoid_ne_zero x
variable (R) in
/-- An alias for endowing a ring with a preorder defined as the valuative relation. -/
def WithPreorder := R
/-- The ring instance on `WithPreorder R` arising from the ring structure on `R`. -/
instance : CommRing (WithPreorder R) := inferInstanceAs (CommRing R)
/-- The preorder on `WithPreorder R` arising from the valuative relation on `R`. -/
instance : Preorder (WithPreorder R) where
le (x y : R) := x ≤ᵥ y
le_refl _ := rel_refl _
le_trans _ _ _ := rel_trans
/-- The valuative relation on `WithPreorder R` arising from the valuative relation on `R`.
This is defined as the preorder itself. -/
instance : ValuativeRel (WithPreorder R) where
rel := (· ≤ ·)
rel_total := rel_total (R := R)
rel_trans := rel_trans (R := R)
rel_add := rel_add (R := R)
rel_mul_right := rel_mul_right (R := R)
rel_mul_cancel := rel_mul_cancel (R := R)
not_rel_one_zero := not_rel_one_zero (R := R)
instance : ValuativePreorder (WithPreorder R) where
rel_iff_le _ _ := Iff.rfl
variable (R) in
/-- The support of the valuation on `R`. -/
def supp : Ideal R where
carrier := { x | x ≤ᵥ 0 }
add_mem' ha hb := rel_add ha hb
zero_mem' := rel_refl _
smul_mem' x _ h := by simpa using rel_mul_left _ h
@[simp]
lemma supp_def (x : R) : x ∈ supp R ↔ x ≤ᵥ 0 := Iff.refl _
lemma supp_eq_valuation_supp : supp R = (valuation R).supp := by
ext x
constructor
· intro h
simp only [supp_def, Valuation.mem_supp_iff] at h ⊢
apply ValueGroupWithZero.sound
· simpa
· simp
· intro h
have := ValueGroupWithZero.exact h
simpa using this.left
instance : (supp R).IsPrime := by
rw [supp_eq_valuation_supp]
infer_instance
open NNReal in variable (R) in
/-- An auxiliary structure used to define `IsRankLeOne`. -/
structure RankLeOneStruct where
/-- The embedding of the value group-with-zero into the nonnegative reals. -/
emb : ValueGroupWithZero R →*₀ ℝ≥0
strictMono : StrictMono emb
variable (R) in
/-- We say that a ring with a valuative relation is of rank one if
there exists a strictly monotone embedding of the "canonical" value group-with-zero into
the nonnegative reals, and the image of this embedding contains some element different
from `0` and `1`. -/
class IsRankLeOne where
nonempty : Nonempty (RankLeOneStruct R)
variable (R) in
/-- We say that a valuative relation on a ring is *nontrivial* if the
value group-with-zero is nontrivial, meaning that it has an element
which is different from 0 and 1. -/
class IsNontrivial where
condition : ∃ γ : ValueGroupWithZero R, γ ≠ 0 ∧ γ ≠ 1
lemma isNontrivial_iff_nontrivial_units :
IsNontrivial R ↔ Nontrivial (ValueGroupWithZero R)ˣ := by
constructor
· rintro ⟨γ, hγ, hγ'⟩
refine ⟨Units.mk0 _ hγ, 1, ?_⟩
simp [← Units.val_eq_one, hγ']
· rintro ⟨r, s, h⟩
rcases eq_or_ne r 1 with rfl | hr
· exact ⟨s.val, by simp, by simpa using h.symm⟩
· exact ⟨r.val, by simp, by simpa using hr⟩
lemma isNontrivial_iff_isNontrivial
{Γ₀ : Type*} [LinearOrderedCommMonoidWithZero Γ₀] (v : Valuation R Γ₀) [v.Compatible] :
IsNontrivial R ↔ v.IsNontrivial := by
constructor
· rintro ⟨r, hr, hr'⟩
induction r using ValueGroupWithZero.ind with | mk r s
have hγ : v r ≠ 0 := by simpa [Valuation.Compatible.rel_iff_le (v := v)] using hr
have hγ' : v r ≤ v s → v r < v s := by
simpa [Valuation.Compatible.rel_iff_le (v := v)] using hr'
by_cases hr : v r = 1
· exact ⟨s, by simp, fun h ↦ by simp [h, hr] at hγ'⟩
· exact ⟨r, by simpa using hγ, hr⟩
· rintro ⟨r, hr, hr'⟩
exact ⟨valuation R r, (isEquiv v (valuation R)).ne_zero.mp hr,
by simpa [(isEquiv v (valuation R)).eq_one_iff_eq_one] using hr'⟩
instance {Γ₀ : Type*} [LinearOrderedCommMonoidWithZero Γ₀]
[IsNontrivial R] (v : Valuation R Γ₀) [v.Compatible] :
v.IsNontrivial := by rwa [← isNontrivial_iff_isNontrivial]
lemma ValueGroupWithZero.mk_eq_valuation {K : Type*} [Field K] [ValuativeRel K]
(x : K) (y : posSubmonoid K) :
ValueGroupWithZero.mk x y = valuation K (x / y) := by
rw [Valuation.map_div, ValueGroupWithZero.mk_eq_div]
lemma exists_valuation_div_valuation_eq (γ : ValueGroupWithZero R) :
∃ (a : R) (b : posSubmonoid R), valuation _ a / valuation _ (b : R) = γ := by
induction γ using ValueGroupWithZero.ind with | mk a b
use a, b
simp [valuation, div_eq_mul_inv, ValueGroupWithZero.inv_mk (b : R) 1 b.prop]
lemma exists_valuation_posSubmonoid_div_valuation_posSubmonoid_eq (γ : (ValueGroupWithZero R)ˣ) :
∃ (a b : posSubmonoid R), valuation R a / valuation _ (b : R) = γ := by
obtain ⟨a, b, hab⟩ := exists_valuation_div_valuation_eq γ.val
lift a to posSubmonoid R using by
contrapose! hab
rw [posSubmonoid_def, not_srel_iff, ← valuation_eq_zero_iff] at hab
simp [hab, eq_comm]
use a, b
-- See `exists_valuation_div_valuation_eq` for the version that works for all rings.
theorem valuation_surjective {K : Type*} [Field K] [ValuativeRel K] :
Function.Surjective (valuation K) :=
ValueGroupWithZero.ind (ValueGroupWithZero.mk_eq_valuation · · ▸ ⟨_, rfl⟩)
variable (R) in
/-- A ring with a valuative relation is discrete if its value group-with-zero
has a maximal element `< 1`. -/
class IsDiscrete where
has_maximal_element :
∃ γ : ValueGroupWithZero R, γ < 1 ∧ (∀ δ : ValueGroupWithZero R, δ < 1 → δ ≤ γ)
end ValuativeRel
open Topology ValuativeRel in
/-- We say that a topology on `R` is valuative if the neighborhoods of `0` in `R`
are determined by the relation `· ≤ᵥ ·`. -/
class IsValuativeTopology (R : Type*) [CommRing R] [ValuativeRel R] [TopologicalSpace R] where
mem_nhds_iff {s : Set R} {x : R} : s ∈ 𝓝 (x : R) ↔
∃ γ : (ValueGroupWithZero R)ˣ, (x + ·) '' { z | valuation _ z < γ } ⊆ s
@[deprecated (since := "2025-08-01")] alias ValuativeTopology := IsValuativeTopology
namespace ValuativeRel
variable {R Γ : Type*} [CommRing R] [ValuativeRel R] [LinearOrderedCommGroupWithZero Γ]
(v : Valuation R Γ)
/-- Any valuation compatible with the valuative relation can be factored through
the value group. -/
noncomputable
def ValueGroupWithZero.embed [h : v.Compatible] : ValueGroupWithZero R →*₀ Γ where
toFun := ValuativeRel.ValueGroupWithZero.lift (fun r s ↦ v r / v (s : R)) <| by
intro x y r s
simp only [h.rel_iff_le, map_mul, ← and_imp, ← le_antisymm_iff]
rw [div_eq_div_iff] <;> simp
map_zero' := by simp [ValueGroupWithZero.lift_zero]
map_one' := by simp
map_mul' _ _ := by
apply ValuativeRel.ValueGroupWithZero.lift_mul
simp [field]
@[simp]
lemma ValueGroupWithZero.embed_mk [v.Compatible] (x : R) (s : posSubmonoid R) :
embed v (.mk x s) = v x / v (s : R) :=
rfl
@[simp]
lemma ValueGroupWithZero.embed_valuation (γ : ValueGroupWithZero R) :
embed (valuation R) γ = γ := by
induction γ using ValueGroupWithZero.ind
simp [embed_mk, ← mk_eq_div]
lemma ValueGroupWithZero.embed_strictMono [v.Compatible] : StrictMono (embed v) := by
intro a b h
obtain ⟨a, r, rfl⟩ := exists_valuation_div_valuation_eq a
obtain ⟨b, s, rfl⟩ := exists_valuation_div_valuation_eq b
simp only [map_div₀]
rw [div_lt_div_iff₀] at h ⊢
any_goals simp [zero_lt_iff]
rw [← map_mul, ← map_mul, (isEquiv (valuation R) v).lt_iff_lt] at h
simpa [embed] using h
/-- For any `x ∈ posSubmonoid R`, the trivial valuation `1 : Valuation R Γ` sends `x` to `1`.
In fact, this is true for any `x ≠ 0`. This lemma is a special case useful for shorthand of
`x ∈ posSubmonoid R → x ≠ 0`. -/
lemma one_apply_posSubmonoid [Nontrivial R] [NoZeroDivisors R] [DecidablePred fun x : R ↦ x = 0]
(x : posSubmonoid R) : (1 : Valuation R Γ) x = 1 :=
Valuation.one_apply_of_ne_zero (by simp)
end ValuativeRel
/-- If `B` is an `A` algebra and both `A` and `B` have valuative relations,
we say that `B|A` is a valuative extension if the valuative relation on `A` is
induced by the one on `B`. -/
class ValuativeExtension
(A B : Type*)
[CommRing A] [CommRing B]
[ValuativeRel A] [ValuativeRel B]
[Algebra A B] where
rel_iff_rel (a b : A) : algebraMap A B a ≤ᵥ algebraMap A B b ↔ a ≤ᵥ b
namespace ValuativeExtension
open ValuativeRel
variable {A B : Type*} [CommRing A] [CommRing B]
[ValuativeRel A] [ValuativeRel B] [Algebra A B]
[ValuativeExtension A B]
lemma srel_iff_srel (a b : A) :
algebraMap A B a <ᵥ algebraMap A B b ↔ a <ᵥ b := by
rw [srel_iff, rel_iff_rel, srel_iff]
variable (A B) in
/-- The morphism of `posSubmonoid`s associated to an algebra map.
This is used in constructing `ValuativeExtension.mapValueGroupWithZero`. -/
@[simps]
def mapPosSubmonoid : posSubmonoid A →* posSubmonoid B where
toFun := fun ⟨a,ha⟩ => ⟨algebraMap _ _ a,
by simpa only [posSubmonoid_def, ← (algebraMap A B).map_zero, srel_iff_srel] using ha⟩
map_one' := by simp
map_mul' := by simp
variable (A) in
instance compatible_comap {Γ : Type*}
[LinearOrderedCommMonoidWithZero Γ] (w : Valuation B Γ) [w.Compatible] :
(w.comap (algebraMap A B)).Compatible := by
constructor
simp [← rel_iff_rel (A := A) (B := B), Valuation.Compatible.rel_iff_le (v := w)]
variable (A B) in
/-- The map on value groups-with-zero associated to the structure morphism of an algebra. -/
def mapValueGroupWithZero : ValueGroupWithZero A →*₀ ValueGroupWithZero B :=
have := compatible_comap A (valuation B)
ValueGroupWithZero.embed ((valuation B).comap (algebraMap A B))
@[simp]
lemma mapValueGroupWithZero_mk (r : A) (s : posSubmonoid A) :
mapValueGroupWithZero A B (.mk r s) = .mk (algebraMap A B r) (mapPosSubmonoid A B s) := by
simp [mapValueGroupWithZero, ValueGroupWithZero.mk_eq_div (R := B)]
@[simp]
lemma mapValueGroupWithZero_valuation (a : A) :
mapValueGroupWithZero A B (valuation _ a) = valuation _ (algebraMap _ _ a) := by
simp [valuation]
end ValuativeExtension
namespace ValuativeRel
variable {R : Type*} [CommRing R] [ValuativeRel R]
/-- Any rank-at-most-one valuation has a mul-archimedean value group.
The converse (for any compatible valuation) is `ValuativeRel.isRankLeOne_iff_mulArchimedean`
which is in a later file since it requires a larger theory of reals. -/
instance [IsRankLeOne R] : MulArchimedean (ValueGroupWithZero R) := by
obtain ⟨⟨f, hf⟩⟩ := IsRankLeOne.nonempty (R := R)
exact .comap f.toMonoidHom hf
end ValuativeRel |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Pochhammer.lean | import Mathlib.Algebra.Algebra.Basic
import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.Eval.Algebra
import Mathlib.Tactic.Abel
/-!
# The Pochhammer polynomials
We define and prove some basic relations about
`ascPochhammer S n : S[X] := X * (X + 1) * ... * (X + n - 1)`
which is also known as the rising factorial and about
`descPochhammer R n : R[X] := X * (X - 1) * ... * (X - n + 1)`
which is also known as the falling factorial. Versions of this definition
that are focused on `Nat` can be found in `Data.Nat.Factorial` as `Nat.ascFactorial` and
`Nat.descFactorial`.
## Implementation
As with many other families of polynomials, even though the coefficients are always in `ℕ` or `ℤ`,
we define the polynomial with coefficients in any `[Semiring S]` or `[Ring R]`.
In an integral domain `S`, we show that `ascPochhammer S n` is zero iff
`n` is a sufficiently large non-positive integer.
## TODO
There is lots more in this direction:
* q-factorials, q-binomials, q-Pochhammer.
-/
universe u v
open Polynomial
section Semiring
variable (S : Type u) [Semiring S]
/-- `ascPochhammer S n` is the polynomial `X * (X + 1) * ... * (X + n - 1)`,
with coefficients in the semiring `S`.
-/
noncomputable def ascPochhammer : ℕ → S[X]
| 0 => 1
| n + 1 => X * (ascPochhammer n).comp (X + 1)
@[simp]
theorem ascPochhammer_zero : ascPochhammer S 0 = 1 :=
rfl
@[simp]
theorem ascPochhammer_one : ascPochhammer S 1 = X := by simp [ascPochhammer]
theorem ascPochhammer_succ_left (n : ℕ) :
ascPochhammer S (n + 1) = X * (ascPochhammer S n).comp (X + 1) := by
rw [ascPochhammer]
theorem monic_ascPochhammer (n : ℕ) [Nontrivial S] [NoZeroDivisors S] :
Monic <| ascPochhammer S n := by
induction n with
| zero => simp
| succ n hn =>
have : leadingCoeff (X + 1 : S[X]) = 1 := leadingCoeff_X_add_C 1
rw [ascPochhammer_succ_left, Monic.def, leadingCoeff_mul,
leadingCoeff_comp (ne_zero_of_eq_one <| natDegree_X_add_C 1 : natDegree (X + 1) ≠ 0), hn,
monic_X, one_mul, one_mul, this, one_pow]
section
variable {S} {T : Type v} [Semiring T]
@[simp]
theorem ascPochhammer_map (f : S →+* T) (n : ℕ) :
(ascPochhammer S n).map f = ascPochhammer T n := by
induction n with
| zero => simp
| succ n ih => simp [ih, ascPochhammer_succ_left, map_comp]
theorem ascPochhammer_eval₂ (f : S →+* T) (n : ℕ) (t : T) :
(ascPochhammer T n).eval t = (ascPochhammer S n).eval₂ f t := by
rw [← ascPochhammer_map f]
exact eval_map f t
theorem ascPochhammer_eval_comp {R : Type*} [CommSemiring R] (n : ℕ) (p : R[X]) [Algebra R S]
(x : S) : ((ascPochhammer S n).comp (p.map (algebraMap R S))).eval x =
(ascPochhammer S n).eval (p.eval₂ (algebraMap R S) x) := by
rw [ascPochhammer_eval₂ (algebraMap R S), ← eval₂_comp', ← ascPochhammer_map (algebraMap R S),
← map_comp, eval_map]
end
@[simp, norm_cast]
theorem ascPochhammer_eval_cast (n k : ℕ) :
(((ascPochhammer ℕ n).eval k : ℕ) : S) = ((ascPochhammer S n).eval k : S) := by
rw [← ascPochhammer_map (algebraMap ℕ S), eval_map, ← eq_natCast (algebraMap ℕ S),
eval₂_at_natCast, Nat.cast_id]
theorem ascPochhammer_eval_zero {n : ℕ} : (ascPochhammer S n).eval 0 = if n = 0 then 1 else 0 := by
cases n
· simp
· simp [X_mul, ascPochhammer_succ_left]
theorem ascPochhammer_zero_eval_zero : (ascPochhammer S 0).eval 0 = 1 := by simp
@[simp]
theorem ascPochhammer_ne_zero_eval_zero {n : ℕ} (h : n ≠ 0) : (ascPochhammer S n).eval 0 = 0 := by
simp [ascPochhammer_eval_zero, h]
theorem ascPochhammer_succ_right (n : ℕ) :
ascPochhammer S (n + 1) = ascPochhammer S n * (X + (n : S[X])) := by
suffices h : ascPochhammer ℕ (n + 1) = ascPochhammer ℕ n * (X + (n : ℕ[X])) by
apply_fun Polynomial.map (algebraMap ℕ S) at h
simpa only [ascPochhammer_map, Polynomial.map_mul, Polynomial.map_add, map_X,
Polynomial.map_natCast] using h
induction n with
| zero => simp
| succ n ih =>
conv_lhs =>
rw [ascPochhammer_succ_left, ih, mul_comp, ← mul_assoc, ← ascPochhammer_succ_left, add_comp,
X_comp, natCast_comp, add_assoc, add_comm (1 : ℕ[X]), ← Nat.cast_succ]
theorem ascPochhammer_succ_eval {S : Type*} [Semiring S] (n : ℕ) (k : S) :
(ascPochhammer S (n + 1)).eval k = (ascPochhammer S n).eval k * (k + n) := by
rw [ascPochhammer_succ_right, mul_add, eval_add, eval_mul_X, ← Nat.cast_comm, ← C_eq_natCast,
eval_C_mul, Nat.cast_comm, ← mul_add]
theorem ascPochhammer_succ_comp_X_add_one (n : ℕ) :
(ascPochhammer S (n + 1)).comp (X + 1) =
ascPochhammer S (n + 1) + (n + 1) • (ascPochhammer S n).comp (X + 1) := by
suffices (ascPochhammer ℕ (n + 1)).comp (X + 1) =
ascPochhammer ℕ (n + 1) + (n + 1) * (ascPochhammer ℕ n).comp (X + 1)
by simpa [map_comp] using congr_arg (Polynomial.map (Nat.castRingHom S)) this
nth_rw 2 [ascPochhammer_succ_left]
rw [← add_mul, ascPochhammer_succ_right ℕ n, mul_comp, mul_comm, add_comp, X_comp, natCast_comp,
add_comm, ← add_assoc]
ring
theorem ascPochhammer_mul (n m : ℕ) :
ascPochhammer S n * (ascPochhammer S m).comp (X + (n : S[X])) = ascPochhammer S (n + m) := by
induction m with
| zero => simp
| succ m ih =>
rw [ascPochhammer_succ_right, Polynomial.mul_X_add_natCast_comp, ← mul_assoc, ih,
← add_assoc, ascPochhammer_succ_right, Nat.cast_add, add_assoc]
theorem ascPochhammer_nat_eq_ascFactorial (n : ℕ) :
∀ k, (ascPochhammer ℕ k).eval n = n.ascFactorial k
| 0 => by rw [ascPochhammer_zero, eval_one, Nat.ascFactorial_zero]
| t + 1 => by
rw [ascPochhammer_succ_right, eval_mul, ascPochhammer_nat_eq_ascFactorial n t, eval_add, eval_X,
eval_natCast, Nat.cast_id, Nat.ascFactorial_succ, mul_comm]
theorem ascPochhammer_nat_eq_natCast_ascFactorial (S : Type*) [Semiring S] (n k : ℕ) :
(ascPochhammer S k).eval (n : S) = n.ascFactorial k := by
norm_cast
rw [ascPochhammer_nat_eq_ascFactorial]
theorem ascPochhammer_nat_eq_descFactorial (a b : ℕ) :
(ascPochhammer ℕ b).eval a = (a + b - 1).descFactorial b := by
rw [ascPochhammer_nat_eq_ascFactorial, Nat.add_descFactorial_eq_ascFactorial']
theorem ascPochhammer_nat_eq_natCast_descFactorial (S : Type*) [Semiring S] (a b : ℕ) :
(ascPochhammer S b).eval (a : S) = (a + b - 1).descFactorial b := by
norm_cast
rw [ascPochhammer_nat_eq_descFactorial]
@[simp]
theorem ascPochhammer_natDegree (n : ℕ) [NoZeroDivisors S] [Nontrivial S] :
(ascPochhammer S n).natDegree = n := by
induction n with
| zero => simp
| succ n hn =>
have : natDegree (X + (n : S[X])) = 1 := natDegree_X_add_C (n : S)
rw [ascPochhammer_succ_right,
natDegree_mul _ (ne_zero_of_natDegree_gt <| this.symm ▸ Nat.zero_lt_one), hn, this]
cases n
· simp
· refine ne_zero_of_natDegree_gt <| hn.symm ▸ Nat.add_one_pos _
end Semiring
section StrictOrderedSemiring
variable {S : Type*} [Semiring S] [PartialOrder S] [IsStrictOrderedRing S]
theorem ascPochhammer_pos (n : ℕ) (s : S) (h : 0 < s) : 0 < (ascPochhammer S n).eval s := by
induction n with
| zero =>
simp only [ascPochhammer_zero, eval_one]
exact zero_lt_one
| succ n ih =>
rw [ascPochhammer_succ_right, mul_add, eval_add, ← Nat.cast_comm, eval_natCast_mul, eval_mul_X,
Nat.cast_comm, ← mul_add]
exact mul_pos ih (lt_of_lt_of_le h (le_add_of_nonneg_right (Nat.cast_nonneg n)))
end StrictOrderedSemiring
section Factorial
open Nat
variable (S : Type*) [Semiring S] (r n : ℕ)
@[simp]
theorem ascPochhammer_eval_one (S : Type*) [Semiring S] (n : ℕ) :
(ascPochhammer S n).eval (1 : S) = (n ! : S) := by
rw_mod_cast [ascPochhammer_nat_eq_ascFactorial, Nat.one_ascFactorial]
theorem factorial_mul_ascPochhammer (S : Type*) [Semiring S] (r n : ℕ) :
(r ! : S) * (ascPochhammer S n).eval (r + 1 : S) = (r + n)! := by
rw_mod_cast [ascPochhammer_nat_eq_ascFactorial, Nat.factorial_mul_ascFactorial]
theorem ascPochhammer_nat_eval_succ (r : ℕ) :
∀ n : ℕ, n * (ascPochhammer ℕ r).eval (n + 1) = (n + r) * (ascPochhammer ℕ r).eval n
| 0 => by
by_cases h : r = 0
· simp only [h, zero_mul, zero_add]
· simp only [ascPochhammer_eval_zero, zero_mul, if_neg h, mul_zero]
| k + 1 => by simp only [ascPochhammer_nat_eq_ascFactorial, Nat.succ_ascFactorial, add_right_comm]
theorem ascPochhammer_eval_succ (r n : ℕ) :
(n : S) * (ascPochhammer S r).eval (n + 1 : S) =
(n + r) * (ascPochhammer S r).eval (n : S) :=
mod_cast congr_arg Nat.cast (ascPochhammer_nat_eval_succ r n)
namespace Nat
variable (a b : ℕ)
theorem cast_ascFactorial : a.ascFactorial b = (ascPochhammer S b).eval (a : S) := by
rw [← ascPochhammer_nat_eq_ascFactorial, ascPochhammer_eval_cast]
theorem cast_descFactorial :
a.descFactorial b = (ascPochhammer S b).eval (a - (b - 1) : S) := by
rw [← ascPochhammer_eval_cast, ascPochhammer_nat_eq_descFactorial]
induction b with
| zero => simp
| succ b =>
simp_rw [add_succ, Nat.add_one_sub_one]
obtain h | h := le_total a b
· rw [descFactorial_of_lt (lt_succ_of_le h), descFactorial_of_lt (lt_succ_of_le _)]
rw [tsub_eq_zero_iff_le.mpr h, zero_add]
· rw [tsub_add_cancel_of_le h]
theorem cast_factorial : (a ! : S) = (ascPochhammer S a).eval 1 := by
rw [← one_ascFactorial, cast_ascFactorial, cast_one]
end Nat
end Factorial
section Ring
variable (R : Type u) [Ring R]
/-- `descPochhammer R n` is the polynomial `X * (X - 1) * ... * (X - n + 1)`,
with coefficients in the ring `R`.
-/
noncomputable def descPochhammer : ℕ → R[X]
| 0 => 1
| n + 1 => X * (descPochhammer n).comp (X - 1)
@[simp]
theorem descPochhammer_zero : descPochhammer R 0 = 1 :=
rfl
@[simp]
theorem descPochhammer_one : descPochhammer R 1 = X := by simp [descPochhammer]
theorem descPochhammer_succ_left (n : ℕ) :
descPochhammer R (n + 1) = X * (descPochhammer R n).comp (X - 1) := by
rw [descPochhammer]
theorem monic_descPochhammer (n : ℕ) [Nontrivial R] [NoZeroDivisors R] :
Monic <| descPochhammer R n := by
induction n with
| zero => simp
| succ n hn =>
have h : leadingCoeff (X - 1 : R[X]) = 1 := leadingCoeff_X_sub_C 1
have : natDegree (X - (1 : R[X])) ≠ 0 := ne_zero_of_eq_one <| natDegree_X_sub_C (1 : R)
rw [descPochhammer_succ_left, Monic.def, leadingCoeff_mul, leadingCoeff_comp this, hn, monic_X,
one_mul, one_mul, h, one_pow]
section
variable {R} {T : Type v} [Ring T]
@[simp]
theorem descPochhammer_map (f : R →+* T) (n : ℕ) :
(descPochhammer R n).map f = descPochhammer T n := by
induction n with
| zero => simp
| succ n ih => simp [ih, descPochhammer_succ_left, map_comp]
end
@[simp, norm_cast]
theorem descPochhammer_eval_cast (n : ℕ) (k : ℤ) :
(((descPochhammer ℤ n).eval k : ℤ) : R) = ((descPochhammer R n).eval k : R) := by
rw [← descPochhammer_map (algebraMap ℤ R), eval_map, ← eq_intCast (algebraMap ℤ R)]
simp only [algebraMap_int_eq, eq_intCast, eval₂_at_intCast, Int.cast_id]
theorem descPochhammer_eval_zero {n : ℕ} :
(descPochhammer R n).eval 0 = if n = 0 then 1 else 0 := by
cases n
· simp
· simp [X_mul, descPochhammer_succ_left]
theorem descPochhammer_zero_eval_zero : (descPochhammer R 0).eval 0 = 1 := by simp
@[simp]
theorem descPochhammer_ne_zero_eval_zero {n : ℕ} (h : n ≠ 0) : (descPochhammer R n).eval 0 = 0 := by
simp [descPochhammer_eval_zero, h]
theorem descPochhammer_succ_right (n : ℕ) :
descPochhammer R (n + 1) = descPochhammer R n * (X - (n : R[X])) := by
suffices h : descPochhammer ℤ (n + 1) = descPochhammer ℤ n * (X - (n : ℤ[X])) by
apply_fun Polynomial.map (algebraMap ℤ R) at h
simpa [descPochhammer_map, Polynomial.map_mul, Polynomial.map_add, map_X,
Polynomial.map_intCast] using h
induction n with
| zero => simp [descPochhammer]
| succ n ih =>
conv_lhs =>
rw [descPochhammer_succ_left, ih, mul_comp, ← mul_assoc, ← descPochhammer_succ_left, sub_comp,
X_comp, natCast_comp]
rw [Nat.cast_add, Nat.cast_one, sub_add_eq_sub_sub_swap]
@[simp]
theorem descPochhammer_natDegree (n : ℕ) [NoZeroDivisors R] [Nontrivial R] :
(descPochhammer R n).natDegree = n := by
induction n with
| zero => simp
| succ n hn =>
have : natDegree (X - (n : R[X])) = 1 := natDegree_X_sub_C (n : R)
rw [descPochhammer_succ_right,
natDegree_mul _ (ne_zero_of_natDegree_gt <| this.symm ▸ Nat.zero_lt_one), hn, this]
cases n
· simp
· refine ne_zero_of_natDegree_gt <| hn.symm ▸ Nat.add_one_pos _
theorem descPochhammer_succ_eval {S : Type*} [Ring S] (n : ℕ) (k : S) :
(descPochhammer S (n + 1)).eval k = (descPochhammer S n).eval k * (k - n) := by
rw [descPochhammer_succ_right, mul_sub, eval_sub, eval_mul_X, ← Nat.cast_comm, ← C_eq_natCast,
eval_C_mul, Nat.cast_comm, ← mul_sub]
theorem descPochhammer_succ_comp_X_sub_one (n : ℕ) :
(descPochhammer R (n + 1)).comp (X - 1) =
descPochhammer R (n + 1) - (n + (1 : R[X])) • (descPochhammer R n).comp (X - 1) := by
suffices (descPochhammer ℤ (n + 1)).comp (X - 1) =
descPochhammer ℤ (n + 1) - (n + 1) * (descPochhammer ℤ n).comp (X - 1)
by simpa [map_comp] using congr_arg (Polynomial.map (Int.castRingHom R)) this
nth_rw 2 [descPochhammer_succ_left]
rw [← sub_mul, descPochhammer_succ_right ℤ n, mul_comp, mul_comm, sub_comp, X_comp, natCast_comp]
ring
theorem descPochhammer_eq_ascPochhammer (n : ℕ) :
descPochhammer ℤ n = (ascPochhammer ℤ n).comp ((X : ℤ[X]) - n + 1) := by
induction n with
| zero => rw [descPochhammer_zero, ascPochhammer_zero, one_comp]
| succ n ih =>
rw [Nat.cast_succ, sub_add, add_sub_cancel_right, descPochhammer_succ_right,
ascPochhammer_succ_left, ih, X_mul, mul_X_comp, comp_assoc, add_comp, X_comp, one_comp]
theorem descPochhammer_eval_eq_ascPochhammer (r : R) (n : ℕ) :
(descPochhammer R n).eval r = (ascPochhammer R n).eval (r - n + 1) := by
induction n with
| zero => rw [descPochhammer_zero, eval_one, ascPochhammer_zero, eval_one]
| succ n ih =>
rw [Nat.cast_succ, sub_add, add_sub_cancel_right, descPochhammer_succ_eval, ih,
ascPochhammer_succ_left, X_mul, eval_mul_X, show (X + 1 : R[X]) =
(X + 1 : ℕ[X]).map (algebraMap ℕ R) by simp only [Polynomial.map_add, map_X,
Polynomial.map_one], ascPochhammer_eval_comp, eval₂_add, eval₂_X, eval₂_one]
theorem descPochhammer_mul (n m : ℕ) :
descPochhammer R n * (descPochhammer R m).comp (X - (n : R[X])) = descPochhammer R (n + m) := by
induction m with
| zero => simp
| succ m ih =>
rw [descPochhammer_succ_right, Polynomial.mul_X_sub_intCast_comp, ← mul_assoc, ih,
← add_assoc, descPochhammer_succ_right, Nat.cast_add, sub_add_eq_sub_sub]
theorem ascPochhammer_eval_neg_eq_descPochhammer (r : R) : ∀ (k : ℕ),
(ascPochhammer R k).eval (-r) = (-1) ^ k * (descPochhammer R k).eval r
| 0 => by
rw [ascPochhammer_zero, descPochhammer_zero]
simp only [eval_one, pow_zero, mul_one]
| (k + 1) => by
rw [ascPochhammer_succ_right, mul_add, eval_add, eval_mul_X, ← Nat.cast_comm, eval_natCast_mul,
Nat.cast_comm, ← mul_add, ascPochhammer_eval_neg_eq_descPochhammer r k, mul_assoc,
descPochhammer_succ_right, mul_sub, eval_sub, eval_mul_X, ← Nat.cast_comm, eval_natCast_mul,
pow_add, pow_one, mul_assoc ((-1) ^ k) (-1), mul_sub, neg_one_mul, neg_mul_eq_mul_neg,
Nat.cast_comm, sub_eq_add_neg, neg_one_mul, neg_neg, ← mul_add]
theorem descPochhammer_eval_eq_descFactorial (n k : ℕ) :
(descPochhammer R k).eval (n : R) = n.descFactorial k := by
induction k with
| zero => rw [descPochhammer_zero, eval_one, Nat.descFactorial_zero, Nat.cast_one]
| succ k ih =>
rw [descPochhammer_succ_right, Nat.descFactorial_succ, mul_sub, eval_sub, eval_mul_X,
← Nat.cast_comm k, eval_natCast_mul, ← Nat.cast_comm n, ← sub_mul, ih]
by_cases! h : n < k
· rw [Nat.descFactorial_eq_zero_iff_lt.mpr h, Nat.cast_zero, mul_zero, mul_zero, Nat.cast_zero]
· rw [Nat.cast_mul, Nat.cast_sub h]
theorem descPochhammer_int_eq_ascFactorial (a b : ℕ) :
(descPochhammer ℤ b).eval (a + b : ℤ) = (a + 1).ascFactorial b := by
rw [← Nat.cast_add, descPochhammer_eval_eq_descFactorial ℤ (a + b) b,
Nat.add_descFactorial_eq_ascFactorial]
variable {R}
/-- The Pochhammer polynomial of degree `n` has roots at `0`, `-1`, ..., `-(n - 1)`. -/
theorem ascPochhammer_eval_neg_coe_nat_of_lt {n k : ℕ} (h : k < n) :
(ascPochhammer R n).eval (-(k : R)) = 0 := by
induction n with
| zero => contradiction
| succ n ih =>
rw [ascPochhammer_succ_eval]
rcases lt_trichotomy k n with hkn | rfl | hkn
· simp [ih hkn]
· simp
· cutsat
/-- Over an integral domain, the Pochhammer polynomial of degree `n` has roots *only* at
`0`, `-1`, ..., `-(n - 1)`. -/
@[simp]
theorem ascPochhammer_eval_eq_zero_iff [IsDomain R]
(n : ℕ) (r : R) : (ascPochhammer R n).eval r = 0 ↔ ∃ k < n, k = -r := by
refine ⟨fun zero' ↦ ?_, fun hrn ↦ ?_⟩
· induction n with
| zero => simp only [ascPochhammer_zero, Polynomial.eval_one, one_ne_zero] at zero'
| succ n ih =>
rw [ascPochhammer_succ_eval, mul_eq_zero] at zero'
cases zero' with
| inl h =>
obtain ⟨rn, hrn, rrn⟩ := ih h
exact ⟨rn, by cutsat, rrn⟩
| inr h =>
exact ⟨n, lt_add_one n, eq_neg_of_add_eq_zero_right h⟩
· obtain ⟨rn, hrn, rnn⟩ := hrn
convert ascPochhammer_eval_neg_coe_nat_of_lt hrn
simp [rnn]
/-- `descPochhammer R n` is `0` for `0, 1, …, n-1`. -/
theorem descPochhammer_eval_coe_nat_of_lt {k n : ℕ} (h : k < n) :
(descPochhammer R n).eval (k : R) = 0 := by
rw [descPochhammer_eval_eq_ascPochhammer, sub_add_eq_add_sub,
← Nat.cast_add_one, ← neg_sub, ← Nat.cast_sub h]
exact ascPochhammer_eval_neg_coe_nat_of_lt (Nat.sub_lt_of_pos_le k.succ_pos h)
lemma descPochhammer_eval_eq_prod_range {R : Type*} [CommRing R] (n : ℕ) (r : R) :
(descPochhammer R n).eval r = ∏ j ∈ Finset.range n, (r - j) := by
induction n with
| zero => simp
| succ n ih => simp [descPochhammer_succ_right, ih, ← Finset.prod_range_succ]
end Ring
section StrictOrderedRing
variable {S : Type*} [Ring S] [PartialOrder S] [IsStrictOrderedRing S]
/-- `descPochhammer S n` is positive on `(n-1, ∞)`. -/
theorem descPochhammer_pos {n : ℕ} {s : S} (h : n - 1 < s) :
0 < (descPochhammer S n).eval s := by
rw [← sub_pos, ← sub_add] at h
rw [descPochhammer_eval_eq_ascPochhammer]
exact ascPochhammer_pos n (s - n + 1) h
/-- `descPochhammer S n` is nonnegative on `[n-1, ∞)`. -/
theorem descPochhammer_nonneg {n : ℕ} {s : S} (h : n - 1 ≤ s) :
0 ≤ (descPochhammer S n).eval s := by
rcases eq_or_lt_of_le h with heq | h
· rw [← heq, descPochhammer_eval_eq_ascPochhammer,
sub_sub_cancel_left, neg_add_cancel, ascPochhammer_eval_zero]
positivity
· exact (descPochhammer_pos h).le
/-- `descPochhammer S n` is at least `(s-n+1)^n` on `[n-1, ∞)`. -/
theorem pow_le_descPochhammer_eval {n : ℕ} {s : S} (h : n - 1 ≤ s) :
(s - n + 1) ^ n ≤ (descPochhammer S n).eval s := by
induction n with
| zero => simp
| succ n ih =>
rw [Nat.cast_add_one, add_sub_cancel_right, ← sub_nonneg] at h
have hsub1 : n - 1 ≤ s := (sub_le_self (n : S) zero_le_one).trans (le_of_sub_nonneg h)
rw [pow_succ, descPochhammer_succ_eval, Nat.cast_add_one, sub_add, add_sub_cancel_right]
apply mul_le_mul _ le_rfl h (descPochhammer_nonneg hsub1)
exact (ih hsub1).trans' <| pow_le_pow_left₀ h (le_add_of_nonneg_right zero_le_one) n
/-- `descPochhammer S n` is monotone on `[n-1, ∞)`. -/
theorem monotoneOn_descPochhammer_eval (n : ℕ) :
MonotoneOn (descPochhammer S n).eval (Set.Ici (n - 1 : S)) := by
induction n with
| zero => simp [monotoneOn_const]
| succ n ih =>
intro a ha b hb hab
rw [Set.mem_Ici, Nat.cast_add_one, add_sub_cancel_right] at ha hb
have ha_sub1 : n - 1 ≤ a := (sub_le_self (n : S) zero_le_one).trans ha
have hb_sub1 : n - 1 ≤ b := (sub_le_self (n : S) zero_le_one).trans hb
simp_rw [descPochhammer_succ_eval]
exact mul_le_mul (ih ha_sub1 hb_sub1 hab) (sub_le_sub_right hab (n : S))
(sub_nonneg_of_le ha) (descPochhammer_nonneg hb_sub1)
end StrictOrderedRing
variable (K : Type*)
namespace Nat
section DivisionSemiring
variable [DivisionSemiring K] [CharZero K]
theorem cast_choose_eq_ascPochhammer_div (a b : ℕ) :
(a.choose b : K) = (ascPochhammer K b).eval ↑(a - (b - 1)) / b ! := by
rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul,
mul_comm, ← descFactorial_eq_factorial_mul_choose, ← cast_descFactorial]
end DivisionSemiring
section DivisionRing
variable [DivisionRing K] [CharZero K]
theorem cast_choose_eq_descPochhammer_div (a b : ℕ) :
(a.choose b : K) = (descPochhammer K b).eval ↑a / b ! := by
rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul,
mul_comm, ← descFactorial_eq_factorial_mul_choose, descPochhammer_eval_eq_descFactorial]
end DivisionRing
end Nat |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/UniqueFactorization.lean | import Mathlib.RingTheory.Polynomial.Basic
import Mathlib.RingTheory.Polynomial.Content
import Mathlib.RingTheory.UniqueFactorizationDomain.Basic
import Mathlib.RingTheory.UniqueFactorizationDomain.Finite
import Mathlib.RingTheory.UniqueFactorizationDomain.GCDMonoid
/-!
# Unique factorization for univariate and multivariate polynomials
## Main results
* `Polynomial.wfDvdMonoid`:
If an integral domain is a `WFDvdMonoid`, then so is its polynomial ring.
* `Polynomial.uniqueFactorizationMonoid`, `MvPolynomial.uniqueFactorizationMonoid`:
If an integral domain is a `UniqueFactorizationMonoid`, then so is its polynomial ring (of any
number of variables).
-/
noncomputable section
open Polynomial
universe u v
namespace Polynomial
variable {R : Type*} [CommRing R] [IsDomain R] [WfDvdMonoid R] {f : R[X]}
instance (priority := 100) wfDvdMonoid : WfDvdMonoid R[X] where
wf := by
classical
refine
RelHomClass.wellFounded
(⟨fun p : R[X] =>
((if p = 0 then ⊤ else ↑p.degree : WithTop (WithBot ℕ)), p.leadingCoeff), ?_⟩ :
DvdNotUnit →r Prod.Lex (· < ·) DvdNotUnit)
(wellFounded_lt.prod_lex ‹WfDvdMonoid R›.wf)
rintro a b ⟨ane0, ⟨c, ⟨not_unit_c, rfl⟩⟩⟩
dsimp
rw [Polynomial.degree_mul, if_neg ane0]
split_ifs with hac
· rw [hac, Polynomial.leadingCoeff_zero]
apply Prod.Lex.left
exact WithTop.coe_lt_top _
have cne0 : c ≠ 0 := right_ne_zero_of_mul hac
simp only [Polynomial.leadingCoeff_mul]
by_cases hdeg : c.degree = (0 : ℕ)
· simp only [hdeg, Nat.cast_zero, add_zero]
refine Prod.Lex.right _ ⟨?_, ⟨c.leadingCoeff, fun unit_c => not_unit_c ?_, rfl⟩⟩
· rwa [Ne, Polynomial.leadingCoeff_eq_zero]
rw [Polynomial.isUnit_iff, Polynomial.eq_C_of_degree_eq_zero hdeg]
use c.leadingCoeff, unit_c
rw [Polynomial.leadingCoeff, Polynomial.natDegree_eq_of_degree_eq_some hdeg]
· apply Prod.Lex.left
rw [Polynomial.degree_eq_natDegree cne0] at *
simp only [Nat.cast_inj] at hdeg
rw [WithTop.coe_lt_coe, Polynomial.degree_eq_natDegree ane0, ← Nat.cast_add, Nat.cast_lt]
exact lt_add_of_pos_right _ (Nat.pos_of_ne_zero hdeg)
theorem exists_irreducible_of_degree_pos (hf : 0 < f.degree) : ∃ g, Irreducible g ∧ g ∣ f :=
WfDvdMonoid.exists_irreducible_factor (fun huf => ne_of_gt hf <| degree_eq_zero_of_isUnit huf)
fun hf0 => not_lt_of_gt hf <| hf0.symm ▸ (@degree_zero R _).symm ▸ WithBot.bot_lt_coe _
theorem exists_irreducible_of_natDegree_pos (hf : 0 < f.natDegree) : ∃ g, Irreducible g ∧ g ∣ f :=
exists_irreducible_of_degree_pos <| by
contrapose! hf
exact natDegree_le_of_degree_le hf
theorem exists_irreducible_of_natDegree_ne_zero (hf : f.natDegree ≠ 0) :
∃ g, Irreducible g ∧ g ∣ f :=
exists_irreducible_of_natDegree_pos <| Nat.pos_of_ne_zero hf
end Polynomial
section UniqueFactorizationDomain
variable (σ : Type v) {D : Type u} [CommRing D] [IsDomain D] [UniqueFactorizationMonoid D]
open UniqueFactorizationMonoid
namespace Polynomial
instance (priority := 100) uniqueFactorizationMonoid : UniqueFactorizationMonoid D[X] := by
letI := Classical.arbitrary (NormalizedGCDMonoid D)
exact ufm_of_decomposition_of_wfDvdMonoid
/-- If `D` is a unique factorization domain, `f` is a non-zero polynomial in `D[X]`, then `f` has
only finitely many monic factors.
(Note that its factors up to unit may be more than monic factors.)
See also `UniqueFactorizationMonoid.fintypeSubtypeDvd`. -/
noncomputable def fintypeSubtypeMonicDvd (f : D[X]) (hf : f ≠ 0) :
Fintype { g : D[X] // g.Monic ∧ g ∣ f } := by
set G := { g : D[X] // g.Monic ∧ g ∣ f }
let y : Associates D[X] := Associates.mk f
have hy : y ≠ 0 := Associates.mk_ne_zero.mpr hf
let H := { x : Associates D[X] // x ∣ y }
let hfin : Fintype H := UniqueFactorizationMonoid.fintypeSubtypeDvd y hy
let i : G → H := fun x ↦ ⟨Associates.mk x.1, Associates.mk_dvd_mk.2 x.2.2⟩
refine Fintype.ofInjective i fun x y heq ↦ ?_
rw [Subtype.mk.injEq] at heq ⊢
exact eq_of_monic_of_associated x.2.1 y.2.1 (Associates.mk_eq_mk_iff_associated.mp heq)
end Polynomial
namespace MvPolynomial
variable (d : ℕ)
private theorem uniqueFactorizationMonoid_of_fintype [Fintype σ] :
UniqueFactorizationMonoid (MvPolynomial σ D) :=
(renameEquiv D (Fintype.equivFin σ)).toMulEquiv.symm.uniqueFactorizationMonoid <| by
induction Fintype.card σ with
| zero =>
apply (isEmptyAlgEquiv D (Fin 0)).toMulEquiv.symm.uniqueFactorizationMonoid
infer_instance
| succ d hd =>
apply (finSuccEquiv D d).toMulEquiv.symm.uniqueFactorizationMonoid
exact Polynomial.uniqueFactorizationMonoid
instance (priority := 100) uniqueFactorizationMonoid :
UniqueFactorizationMonoid (MvPolynomial σ D) := by
rw [iff_exists_prime_factors]
intro a ha; obtain ⟨s, a', rfl⟩ := exists_finset_rename a
obtain ⟨w, h, u, hw⟩ :=
iff_exists_prime_factors.1 (uniqueFactorizationMonoid_of_fintype s) a' fun h =>
ha <| by simp [h]
exact
⟨w.map (rename (↑)), fun b hb =>
let ⟨b', hb', he⟩ := Multiset.mem_map.1 hb
he ▸ (prime_rename_iff (σ := σ) ↑s).2 (h b' hb'),
Units.map (@rename s σ D _ (↑)).toRingHom.toMonoidHom u, by
rw [Multiset.prod_hom, Units.coe_map, AlgHom.toRingHom_eq_coe, RingHom.toMonoidHom_eq_coe,
AlgHom.toRingHom_toMonoidHom, MonoidHom.coe_coe, ← map_mul, hw]⟩
end MvPolynomial
end UniqueFactorizationDomain
/-- A polynomial over a field which is not a unit must have a monic irreducible factor.
See also `WfDvdMonoid.exists_irreducible_factor`. -/
theorem Polynomial.exists_monic_irreducible_factor {F : Type*} [Field F] (f : F[X])
(hu : ¬IsUnit f) : ∃ g : F[X], g.Monic ∧ Irreducible g ∧ g ∣ f := by
by_cases hf : f = 0
· exact ⟨X, monic_X, irreducible_X, hf ▸ dvd_zero X⟩
obtain ⟨g, hi, hf⟩ := WfDvdMonoid.exists_irreducible_factor hu hf
have ha : Associated g (g * C g.leadingCoeff⁻¹) := associated_mul_unit_right _ _ <|
isUnit_C.2 (leadingCoeff_ne_zero.2 hi.ne_zero).isUnit.inv
exact ⟨_, monic_mul_leadingCoeff_inv hi.ne_zero, ha.irreducible hi, ha.dvd_iff_dvd_left.1 hf⟩ |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/ShiftedLegendre.lean | import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Derivative
/-!
# shifted Legendre Polynomials
In this file, we define the shifted Legendre polynomials `shiftedLegendre n` for `n : ℕ` as a
polynomial in `ℤ[X]`. We prove some basic properties of the Legendre polynomials.
* `factorial_mul_shiftedLegendre_eq`: The analogue of Rodrigues' formula for the shifted Legendre
polynomials;
* `shiftedLegendre_eval_symm`: The values of the shifted Legendre polynomial at `x` and `1 - x`
differ by a factor `(-1)ⁿ`.
## Reference
* <https://en.wikipedia.org/wiki/Legendre_polynomials>
## Tags
shifted Legendre polynomials, derivative
-/
open Nat BigOperators Finset
namespace Polynomial
/-- `shiftedLegendre n` is an integer polynomial for each `n : ℕ`, defined by:
`Pₙ(x) = ∑ k ∈ Finset.range (n + 1), (-1)ᵏ * choose n k * choose (n + k) n * xᵏ`
These polynomials appear in combinatorics and the theory of orthogonal polynomials. -/
noncomputable def shiftedLegendre (n : ℕ) : ℤ[X] :=
∑ k ∈ Finset.range (n + 1), C ((-1 : ℤ) ^ k * n.choose k * (n + k).choose n) * X ^ k
/-- The shifted Legendre polynomial multiplied by a factorial equals the higher-order derivative of
the combinatorial function `X ^ n * (1 - X) ^ n`. This is the analogue of Rodrigues' formula for
the shifted Legendre polynomials. -/
theorem factorial_mul_shiftedLegendre_eq (n : ℕ) : (n ! : ℤ[X]) * (shiftedLegendre n) =
derivative^[n] (X ^ n * (1 - (X : ℤ[X])) ^ n) := by
symm
calc
_ = derivative^[n] (((X : ℤ[X]) - X ^ 2) ^ n) := by
rw [← mul_pow, mul_one_sub, ← pow_two]
_ = derivative^[n] (∑ m ∈ range (n + 1), n.choose m • (-1) ^ m * X ^ (n + m)) := by
congr
rw [sub_eq_add_neg, add_comm, add_pow]
congr! 1 with m hm
rw [neg_pow, pow_two, mul_pow, ← mul_assoc, mul_comm, mul_assoc, pow_mul_pow_sub, mul_assoc,
← pow_add, ← mul_assoc, nsmul_eq_mul, add_comm]
rw [Finset.mem_range] at hm
linarith
_ = ∑ x ∈ range (n + 1), ↑((n + x)! / x !) * C (↑(n.choose x) * (-1) ^ x) * X ^ x := by
rw [iterate_derivative_sum]
congr! 1 with x _
rw [show (n.choose x • (-1) ^ x : ℤ[X]) = C (n.choose x • (-1) ^ x) by simp,
iterate_derivative_C_mul, iterate_derivative_X_pow_eq_smul,
descFactorial_eq_div (by cutsat), show n + x - n = x by cutsat]
simp only [Int.reduceNeg, nsmul_eq_mul, eq_intCast, Int.cast_mul, Int.cast_natCast,
Int.cast_pow, Int.cast_neg, Int.cast_one, zsmul_eq_mul]
ring
_ = ∑ i ∈ range (n + 1), ↑n ! * C ((-1) ^ i * ↑(n.choose i) * ↑((n + i).choose n)) * X ^ i := by
congr! 2 with x _
rw [C_mul (b := ((n + x).choose n : ℤ)), mul_comm, mul_comm (n ! : ℤ[X]), mul_comm _ ((-1) ^ x),
mul_assoc]
congr 1
rw [add_comm, add_choose]
simp only [Int.natCast_ediv, cast_mul, eq_intCast]
norm_cast
rw [mul_comm, ← Nat.mul_div_assoc]
· rw [mul_comm, Nat.mul_div_mul_right _ _ (by positivity)]
· simp only [factorial_mul_factorial_dvd_factorial_add]
_ = (n ! : ℤ[X]) * (shiftedLegendre n) := by simp [← mul_assoc, shiftedLegendre, mul_sum]
/-- The coefficient of the shifted Legendre polynomial at `k` is
`(-1) ^ k * (n.choose k) * (n + k).choose n`. -/
theorem coeff_shiftedLegendre (n k : ℕ) :
(shiftedLegendre n).coeff k = (-1) ^ k * n.choose k * (n + k).choose n := by
rw [shiftedLegendre, finset_sum_coeff]
simp_rw [coeff_C_mul_X_pow]
simp +contextual [choose_eq_zero_of_lt, add_one_le_iff]
/-- The degree of `shiftedLegendre n` is `n`. -/
@[simp] theorem degree_shiftedLegendre (n : ℕ) : (shiftedLegendre n).degree = n := by
refine le_antisymm ?_ (le_degree_of_ne_zero ?_)
· rw [degree_le_iff_coeff_zero]
intro k h
norm_cast at h
simp [coeff_shiftedLegendre, choose_eq_zero_of_lt h]
· simp [coeff_shiftedLegendre, (choose_pos (show n ≤ n + n by simp)).ne']
@[simp] theorem natDegree_shiftedLegendre (n : ℕ) : (shiftedLegendre n).natDegree = n :=
natDegree_eq_of_degree_eq_some (degree_shiftedLegendre n)
theorem neg_one_pow_mul_shiftedLegendre_comp_one_sub_X_eq (n : ℕ) :
(-1) ^ n * (shiftedLegendre n).comp (1 - X) = shiftedLegendre n := by
refine nat_mul_inj' ?_ (factorial_ne_zero n)
rw [← mul_assoc, mul_comm (n ! : ℤ[X]), mul_assoc, ← natCast_mul_comp,
factorial_mul_shiftedLegendre_eq, ← iterate_derivative_comp_one_sub_X]
simp [mul_comm]
/-- The values of the Legendre polynomial at `x` and `1 - x` differ by a factor `(-1)ⁿ`. -/
lemma shiftedLegendre_eval_symm (n : ℕ) {R : Type*} [Ring R] (x : R) :
aeval x (shiftedLegendre n) = (-1) ^ n * aeval (1 - x) (shiftedLegendre n) := by
have := congr(aeval x $(neg_one_pow_mul_shiftedLegendre_comp_one_sub_X_eq n))
simpa [aeval_comp] using this.symm
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Nilpotent.lean | import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Div
import Mathlib.Algebra.Polynomial.Identities
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Nilpotent.Basic
import Mathlib.RingTheory.Nilpotent.Lemmas
/-!
# Nilpotency in polynomial rings.
This file is a place for results related to nilpotency in (single-variable) polynomial rings.
## Main results:
* `Polynomial.isNilpotent_iff`
* `Polynomial.isUnit_iff_coeff_isUnit_isNilpotent`
-/
namespace Polynomial
variable {R : Type*} {r : R}
section Semiring
variable [Semiring R] {P : R[X]}
lemma isNilpotent_C_mul_pow_X_of_isNilpotent (n : ℕ) (hnil : IsNilpotent r) :
IsNilpotent ((C r) * X ^ n) := by
refine Commute.isNilpotent_mul_right (commute_X_pow _ _).symm ?_
obtain ⟨m, hm⟩ := hnil
refine ⟨m, ?_⟩
rw [← C_pow, hm, C_0]
lemma isNilpotent_pow_X_mul_C_of_isNilpotent (n : ℕ) (hnil : IsNilpotent r) :
IsNilpotent (X ^ n * (C r)) := by
rw [commute_X_pow]
exact isNilpotent_C_mul_pow_X_of_isNilpotent n hnil
@[simp] lemma isNilpotent_monomial_iff {n : ℕ} :
IsNilpotent (monomial (R := R) n r) ↔ IsNilpotent r :=
exists_congr fun k ↦ by simp
@[simp] lemma isNilpotent_C_iff :
IsNilpotent (C r) ↔ IsNilpotent r :=
exists_congr fun k ↦ by simpa only [← C_pow] using C_eq_zero
@[simp] lemma isNilpotent_X_mul_iff :
IsNilpotent (X * P) ↔ IsNilpotent P := by
refine ⟨fun h ↦ ?_, ?_⟩
· rwa [Commute.isNilpotent_mul_left_iff (commute_X P) (by simp)] at h
· rintro ⟨k, hk⟩
exact ⟨k, by simp [(commute_X P).mul_pow, hk]⟩
@[simp] lemma isNilpotent_mul_X_iff :
IsNilpotent (P * X) ↔ IsNilpotent P := by
rw [← commute_X P]
exact isNilpotent_X_mul_iff
end Semiring
section CommRing
variable [CommRing R] {P : R[X]}
protected lemma isNilpotent_iff :
IsNilpotent P ↔ ∀ i, IsNilpotent (coeff P i) := by
refine
⟨P.recOnHorner (by simp) (fun p r hp₀ _ hp hpr i ↦ ?_) (fun p _ hnp hpX i ↦ ?_), fun h ↦ ?_⟩
· rw [← sum_monomial_eq P]
exact isNilpotent_sum (fun i _ ↦ by simpa only [isNilpotent_monomial_iff] using h i)
· have hr : IsNilpotent (C r) := by
obtain ⟨k, hk⟩ := hpr
replace hp : eval 0 p = 0 := by rwa [coeff_zero_eq_aeval_zero] at hp₀
refine isNilpotent_C_iff.mpr ⟨k, ?_⟩
simpa [coeff_zero_eq_aeval_zero, hp] using congr_arg (fun q ↦ coeff q 0) hk
rcases i with - | i
· simpa [hp₀] using hr
simp only [coeff_add, coeff_C_succ, add_zero]
apply hp
simpa using Commute.isNilpotent_sub (Commute.all _ _) hpr hr
· rcases i with - | i
· simp
simpa using hnp (isNilpotent_mul_X_iff.mp hpX) i
@[simp] lemma isNilpotent_reflect_iff {P : R[X]} {N : ℕ} (hN : P.natDegree ≤ N) :
IsNilpotent (reflect N P) ↔ IsNilpotent P := by
simp only [Polynomial.isNilpotent_iff]
refine ⟨fun h i ↦ ?_, fun h i ↦ ?_⟩ <;> rcases le_or_gt i N with hi | hi
· simpa [tsub_tsub_cancel_of_le hi] using h (N - i)
· simp [coeff_eq_zero_of_natDegree_lt <| lt_of_le_of_lt hN hi]
· simpa [hi, revAt_le] using h (N - i)
· simpa [revAt_eq_self_of_lt hi] using h i
@[simp] lemma isNilpotent_reverse_iff :
IsNilpotent P.reverse ↔ IsNilpotent P :=
isNilpotent_reflect_iff (le_refl _)
/-- Let `P` be a polynomial over `R`. If its constant term is a unit and its other coefficients are
nilpotent, then `P` is a unit.
See also `Polynomial.isUnit_iff_coeff_isUnit_isNilpotent`. -/
theorem isUnit_of_coeff_isUnit_isNilpotent (hunit : IsUnit (P.coeff 0))
(hnil : ∀ i, i ≠ 0 → IsNilpotent (P.coeff i)) : IsUnit P := by
induction h : P.natDegree using Nat.strong_induction_on generalizing P with | _ k hind
by_cases hdeg : P.natDegree = 0
· rw [eq_C_of_natDegree_eq_zero hdeg]
exact hunit.map C
set P₁ := P.eraseLead with hP₁
suffices IsUnit P₁ by
rw [← eraseLead_add_monomial_natDegree_leadingCoeff P, ← C_mul_X_pow_eq_monomial, ← hP₁]
refine IsNilpotent.isUnit_add_left_of_commute ?_ this (Commute.all _ _)
exact isNilpotent_C_mul_pow_X_of_isNilpotent _ (hnil _ hdeg)
have hdeg₂ := lt_of_le_of_lt P.eraseLead_natDegree_le (Nat.sub_lt
(Nat.pos_of_ne_zero hdeg) zero_lt_one)
refine hind P₁.natDegree ?_ ?_ (fun i hi => ?_) rfl
· simp_rw [P₁, ← h, hdeg₂]
· simp_rw [P₁, eraseLead_coeff_of_ne _ (Ne.symm hdeg), hunit]
· by_cases! H : i ≤ P₁.natDegree
· simp_rw [P₁, eraseLead_coeff_of_ne _ (ne_of_lt (lt_of_le_of_lt H hdeg₂)), hnil i hi]
· simp_rw [coeff_eq_zero_of_natDegree_lt H, IsNilpotent.zero]
/-- Let `P` be a polynomial over `R`. If `P` is a unit, then all its coefficients are nilpotent,
except its constant term which is a unit.
See also `Polynomial.isUnit_iff_coeff_isUnit_isNilpotent`. -/
theorem coeff_isUnit_isNilpotent_of_isUnit (hunit : IsUnit P) :
IsUnit (P.coeff 0) ∧ (∀ i, i ≠ 0 → IsNilpotent (P.coeff i)) := by
obtain ⟨Q, hQ⟩ := IsUnit.exists_right_inv hunit
constructor
· refine .of_mul_eq_one (Q.coeff 0) ?_
have h := (mul_coeff_zero P Q).symm
rwa [hQ, coeff_one_zero] at h
· intro n hn
rw [nilpotent_iff_mem_prime]
intro I hI
let f := mapRingHom (Ideal.Quotient.mk I)
have hPQ : degree (f P) = 0 ∧ degree (f Q) = 0 := by
rw [← Nat.WithBot.add_eq_zero_iff, ← degree_mul, ← map_mul, hQ, map_one, degree_one]
have hcoeff : (f P).coeff n = 0 := by
refine coeff_eq_zero_of_degree_lt ?_
rw [hPQ.1]
exact WithBot.coe_pos.2 hn.bot_lt
rw [coe_mapRingHom, coeff_map, ← RingHom.mem_ker, Ideal.mk_ker] at hcoeff
exact hcoeff
/-- Let `P` be a polynomial over `R`. `P` is a unit if and only if all its coefficients are
nilpotent, except its constant term which is a unit.
See also `Polynomial.isUnit_iff'`. -/
theorem isUnit_iff_coeff_isUnit_isNilpotent :
IsUnit P ↔ IsUnit (P.coeff 0) ∧ (∀ i, i ≠ 0 → IsNilpotent (P.coeff i)) :=
⟨coeff_isUnit_isNilpotent_of_isUnit, fun H => isUnit_of_coeff_isUnit_isNilpotent H.1 H.2⟩
@[simp] lemma isUnit_C_add_X_mul_iff :
IsUnit (C r + X * P) ↔ IsUnit r ∧ IsNilpotent P := by
have : ∀ i, coeff (C r + X * P) (i + 1) = coeff P i := by simp
simp_rw [isUnit_iff_coeff_isUnit_isNilpotent, Nat.forall_ne_zero_iff, this]
simp only [coeff_add, coeff_C_zero, mul_coeff_zero, coeff_X_zero, zero_mul, add_zero,
← Polynomial.isNilpotent_iff]
lemma isUnit_iff' :
IsUnit P ↔ IsUnit (eval 0 P) ∧ IsNilpotent (P /ₘ X) := by
suffices P = C (eval 0 P) + X * (P /ₘ X) by
conv_lhs => rw [this]; simp
conv_lhs => rw [← modByMonic_add_div P monic_X]
simp [modByMonic_X]
theorem not_isUnit_of_natDegree_pos_of_isReduced [IsReduced R] (p : R[X])
(hpl : 0 < p.natDegree) : ¬ IsUnit p := by
simp only [ne_eq, isNilpotent_iff_eq_zero, not_and, not_forall, exists_prop,
Polynomial.isUnit_iff_coeff_isUnit_isNilpotent]
intro _
refine ⟨p.natDegree, hpl.ne', ?_⟩
contrapose! hpl
simp only [coeff_natDegree, leadingCoeff_eq_zero] at hpl
simp [hpl]
theorem not_isUnit_of_degree_pos_of_isReduced [IsReduced R] (p : R[X])
(hpl : 0 < p.degree) : ¬ IsUnit p :=
not_isUnit_of_natDegree_pos_of_isReduced _ (natDegree_pos_iff_degree_pos.mpr hpl)
end CommRing
section CommAlgebra
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] (P : R[X]) {a b : S}
lemma isNilpotent_aeval_sub_of_isNilpotent_sub (h : IsNilpotent (a - b)) :
IsNilpotent (aeval a P - aeval b P) := by
simp only [← eval_map_algebraMap]
have ⟨c, hc⟩ := evalSubFactor (map (algebraMap R S) P) a b
exact hc ▸ (Commute.all _ _).isNilpotent_mul_left h
variable {P}
lemma isUnit_aeval_of_isUnit_aeval_of_isNilpotent_sub
(hb : IsUnit (aeval b P)) (hab : IsNilpotent (a - b)) :
IsUnit (aeval a P) := by
rw [← add_sub_cancel (aeval b P) (aeval a P)]
refine IsNilpotent.isUnit_add_left_of_commute ?_ hb (Commute.all _ _)
exact isNilpotent_aeval_sub_of_isNilpotent_sub P hab
end CommAlgebra
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/IntegralNormalization.lean | import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.RingTheory.Polynomial.ScaleRoots
/-!
# Theory of monic polynomials
We define `integralNormalization`, which relate arbitrary polynomials to monic ones.
-/
open Polynomial
namespace Polynomial
universe u v y
variable {R : Type u} {S : Type v} {a b : R} {m n : ℕ} {ι : Type y}
section IntegralNormalization
section Semiring
variable [Semiring R]
/-- If `p : R[X]` is a nonzero polynomial with root `z`, `integralNormalization p` is
a monic polynomial with root `leadingCoeff f * z`.
Moreover, `integralNormalization 0 = 0`.
-/
noncomputable def integralNormalization (p : R[X]) : R[X] :=
p.sum fun i a ↦
monomial i (if p.degree = i then 1 else a * p.leadingCoeff ^ (p.natDegree - 1 - i))
@[simp]
theorem integralNormalization_zero : integralNormalization (0 : R[X]) = 0 := by
simp [integralNormalization]
@[simp]
theorem integralNormalization_C {x : R} (hx : x ≠ 0) : integralNormalization (C x) = 1 := by
simp [integralNormalization, sum_def, support_C hx, degree_C hx]
variable {p : R[X]}
theorem integralNormalization_coeff {i : ℕ} :
(integralNormalization p).coeff i =
if p.degree = i then 1 else coeff p i * p.leadingCoeff ^ (p.natDegree - 1 - i) := by
have : p.coeff i = 0 → p.degree ≠ i := fun hc hd => coeff_ne_zero_of_eq_degree hd hc
simp +contextual [sum_def, integralNormalization, coeff_monomial, this,
mem_support_iff]
theorem support_integralNormalization_subset :
(integralNormalization p).support ⊆ p.support := by
intro
simp +contextual [sum_def, integralNormalization, coeff_monomial, mem_support_iff]
theorem integralNormalization_coeff_degree {i : ℕ} (hi : p.degree = i) :
(integralNormalization p).coeff i = 1 := by rw [integralNormalization_coeff, if_pos hi]
theorem integralNormalization_coeff_natDegree (hp : p ≠ 0) :
(integralNormalization p).coeff (natDegree p) = 1 :=
integralNormalization_coeff_degree (degree_eq_natDegree hp)
theorem integralNormalization_coeff_degree_ne {i : ℕ} (hi : p.degree ≠ i) :
coeff (integralNormalization p) i = coeff p i * p.leadingCoeff ^ (p.natDegree - 1 - i) := by
rw [integralNormalization_coeff, if_neg hi]
theorem integralNormalization_coeff_ne_natDegree {i : ℕ} (hi : i ≠ natDegree p) :
coeff (integralNormalization p) i = coeff p i * p.leadingCoeff ^ (p.natDegree - 1 - i) :=
integralNormalization_coeff_degree_ne (degree_ne_of_natDegree_ne hi.symm)
theorem monic_integralNormalization (hp : p ≠ 0) : Monic (integralNormalization p) :=
monic_of_degree_le p.natDegree
(Finset.sup_le fun i h =>
WithBot.coe_le_coe.2 <| le_natDegree_of_mem_supp i <| support_integralNormalization_subset h)
(integralNormalization_coeff_natDegree hp)
theorem integralNormalization_coeff_mul_leadingCoeff_pow (i : ℕ) (hp : 1 ≤ natDegree p) :
(integralNormalization p).coeff i * p.leadingCoeff ^ i =
p.coeff i * p.leadingCoeff ^ (p.natDegree - 1) := by
rw [integralNormalization_coeff]
split_ifs with h
· simp [natDegree_eq_of_degree_eq_some h, leadingCoeff,
← pow_succ', tsub_add_cancel_of_le (natDegree_eq_of_degree_eq_some h ▸ hp)]
· simp only [mul_assoc, ← pow_add]
by_cases h' : i < p.degree
· rw [tsub_add_cancel_of_le]
rw [le_tsub_iff_right hp, Nat.succ_le_iff]
exact coe_lt_degree.mp h'
· simp [coeff_eq_zero_of_degree_lt (lt_of_le_of_ne (le_of_not_gt h') h)]
theorem integralNormalization_mul_C_leadingCoeff (p : R[X]) :
integralNormalization p * C p.leadingCoeff = scaleRoots p p.leadingCoeff := by
ext i
rw [coeff_mul_C, integralNormalization_coeff]
split_ifs with h
· simp [natDegree_eq_of_degree_eq_some h, leadingCoeff]
· simp only [coeff_scaleRoots]
by_cases h' : i < p.degree
· rw [mul_assoc, ← pow_succ, tsub_right_comm, tsub_add_cancel_of_le]
rw [le_tsub_iff_left (coe_lt_degree.mp h').le, Nat.succ_le_iff]
exact coe_lt_degree.mp h'
· simp [coeff_eq_zero_of_degree_lt (lt_of_le_of_ne (le_of_not_gt h') h)]
theorem integralNormalization_degree : (integralNormalization p).degree = p.degree := by
apply le_antisymm
· exact Finset.sup_mono p.support_integralNormalization_subset
· rw [← degree_scaleRoots, ← integralNormalization_mul_C_leadingCoeff]
exact (degree_mul_le _ _).trans (add_le_of_nonpos_right degree_C_le)
variable {A : Type*} [CommSemiring S] [Semiring A]
theorem leadingCoeff_smul_integralNormalization (p : S[X]) :
p.leadingCoeff • integralNormalization p = scaleRoots p p.leadingCoeff := by
rw [Algebra.smul_def, algebraMap_eq, mul_comm, integralNormalization_mul_C_leadingCoeff]
theorem integralNormalization_eval₂_leadingCoeff_mul_of_commute (h : 1 ≤ p.natDegree) (f : R →+* A)
(x : A) (h₁ : Commute (f p.leadingCoeff) x) (h₂ : ∀ {r r'}, Commute (f r) (f r')) :
(integralNormalization p).eval₂ f (f p.leadingCoeff * x) =
f p.leadingCoeff ^ (p.natDegree - 1) * p.eval₂ f x := by
rw [eval₂_eq_sum_range, eval₂_eq_sum_range, Finset.mul_sum]
apply Finset.sum_congr
· rw [natDegree_eq_of_degree_eq p.integralNormalization_degree]
intro n _hn
rw [h₁.mul_pow, ← mul_assoc, ← f.map_pow, ← f.map_mul,
integralNormalization_coeff_mul_leadingCoeff_pow _ h, f.map_mul, h₂.eq, f.map_pow, mul_assoc]
theorem integralNormalization_eval₂_leadingCoeff_mul (h : 1 ≤ p.natDegree) (f : R →+* S) (x : S) :
(integralNormalization p).eval₂ f (f p.leadingCoeff * x) =
f p.leadingCoeff ^ (p.natDegree - 1) * p.eval₂ f x :=
integralNormalization_eval₂_leadingCoeff_mul_of_commute h _ _ (.all _ _) (.all _ _)
theorem integralNormalization_eval₂_eq_zero_of_commute {p : R[X]} (f : R →+* A) {z : A}
(hz : eval₂ f z p = 0) (h₁ : Commute (f p.leadingCoeff) z) (h₂ : ∀ {r r'}, Commute (f r) (f r'))
(inj : ∀ x : R, f x = 0 → x = 0) :
eval₂ f (f p.leadingCoeff * z) (integralNormalization p) = 0 := by
obtain (h | h) := p.natDegree.eq_zero_or_pos
· by_cases h0 : coeff p 0 = 0
· rw [eq_C_of_natDegree_eq_zero h]
simp [h0]
· rw [eq_C_of_natDegree_eq_zero h, eval₂_C] at hz
exact absurd (inj _ hz) h0
· rw [integralNormalization_eval₂_leadingCoeff_mul_of_commute h _ _ h₁ h₂, hz, mul_zero]
theorem integralNormalization_eval₂_eq_zero {p : R[X]} (f : R →+* S) {z : S} (hz : eval₂ f z p = 0)
(inj : ∀ x : R, f x = 0 → x = 0) :
eval₂ f (f p.leadingCoeff * z) (integralNormalization p) = 0 :=
integralNormalization_eval₂_eq_zero_of_commute _ hz (.all _ _) (.all _ _) inj
theorem integralNormalization_aeval_eq_zero [Algebra S A] {f : S[X]} {z : A} (hz : aeval z f = 0)
(inj : ∀ x : S, algebraMap S A x = 0 → x = 0) :
aeval (algebraMap S A f.leadingCoeff * z) (integralNormalization f) = 0 :=
integralNormalization_eval₂_eq_zero_of_commute (algebraMap S A) hz
(Algebra.commute_algebraMap_left _ _) (.map (.all _ _) _) inj
end Semiring
section IsCancelMulZero
variable [Semiring R] [IsCancelMulZero R]
@[simp]
theorem support_integralNormalization {f : R[X]} :
(integralNormalization f).support = f.support := by
nontriviality R using Subsingleton.eq_zero
have : IsDomain R := {}
by_cases hf : f = 0; · simp [hf]
ext i
refine ⟨fun h => support_integralNormalization_subset h, ?_⟩
simp only [integralNormalization_coeff, mem_support_iff]
intro hfi
split_ifs with hi <;> simp [hf, hfi]
end IsCancelMulZero
end IntegralNormalization
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/GaussLemma.lean | import Mathlib.FieldTheory.SplittingField.Construction
import Mathlib.RingTheory.Localization.Integral
import Mathlib.RingTheory.IntegralClosure.IntegrallyClosed
import Mathlib.RingTheory.Polynomial.Content
/-!
# Gauss's Lemma
Gauss's Lemma is one of a few results pertaining to irreducibility of primitive polynomials.
## Main Results
- `IsIntegrallyClosed.eq_map_mul_C_of_dvd`: if `R` is integrally closed, `K = Frac(R)` and
`g : K[X]` divides a monic polynomial with coefficients in `R`, then `g * (C g.leadingCoeff⁻¹)`
has coefficients in `R`
- `Polynomial.Monic.irreducible_iff_irreducible_map_fraction_map`:
A monic polynomial over an integrally closed domain is irreducible iff it is irreducible in a
fraction field
- `isIntegrallyClosed_iff'`:
Integrally closed domains are precisely the domains for in which Gauss's lemma holds
for monic polynomials
- `Polynomial.IsPrimitive.irreducible_iff_irreducible_map_fraction_map`:
A primitive polynomial over a GCD domain is irreducible iff it is irreducible in a fraction field
- `Polynomial.IsPrimitive.Int.irreducible_iff_irreducible_map_cast`:
A primitive polynomial over `ℤ` is irreducible iff it is irreducible over `ℚ`.
- `Polynomial.IsPrimitive.dvd_iff_fraction_map_dvd_fraction_map`:
Two primitive polynomials over a GCD domain divide each other iff they do in a fraction field.
- `Polynomial.IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast`:
Two primitive polynomials over `ℤ` divide each other if they do in `ℚ`.
-/
open scoped nonZeroDivisors Polynomial
variable {R : Type*} [CommRing R]
section IsIntegrallyClosed
open Polynomial
open integralClosure
open IsIntegrallyClosed
variable (K : Type*) [Field K] [Algebra R K]
theorem integralClosure.mem_lifts_of_monic_of_dvd_map {f : R[X]} (hf : f.Monic) {g : K[X]}
(hg : g.Monic) (hd : g ∣ f.map (algebraMap R K)) :
g ∈ lifts (algebraMap (integralClosure R K) K) := by
have := mem_lift_of_splits_of_roots_mem_range (integralClosure R g.SplittingField)
((splits_id_iff_splits _).2 <| SplittingField.splits g) (hg.map _) fun a ha =>
(SetLike.ext_iff.mp (integralClosure R g.SplittingField).range_algebraMap _).mpr <|
roots_mem_integralClosure hf ?_
· rw [lifts_iff_coeff_lifts, ← RingHom.coe_range, Subalgebra.range_algebraMap] at this
refine (lifts_iff_coeff_lifts _).2 fun n => ?_
rw [← RingHom.coe_range, Subalgebra.range_algebraMap]
obtain ⟨p, hp, he⟩ := SetLike.mem_coe.mp (this n); use p, hp
rw [IsScalarTower.algebraMap_eq R K, coeff_map, ← eval₂_map, eval₂_at_apply] at he
rw [eval₂_eq_eval_map]; apply (injective_iff_map_eq_zero _).1 _ _ he
apply RingHom.injective
rw [aroots_def, IsScalarTower.algebraMap_eq R K _, ← map_map]
refine Multiset.mem_of_le (roots.le_of_dvd ((hf.map _).map _).ne_zero ?_) ha
exact map_dvd (algebraMap K g.SplittingField) hd
variable [IsFractionRing R K]
/-- If `K = Frac(R)` and `g : K[X]` divides a monic polynomial with coefficients in `R`, then
`g * (C g.leadingCoeff⁻¹)` has coefficients in `R` -/
theorem IsIntegrallyClosed.eq_map_mul_C_of_dvd [IsIntegrallyClosed R] {f : R[X]} (hf : f.Monic)
{g : K[X]} (hg : g ∣ f.map (algebraMap R K)) :
∃ g' : R[X], g'.map (algebraMap R K) * (C <| leadingCoeff g) = g := by
have g_ne_0 : g ≠ 0 := ne_zero_of_dvd_ne_zero (Monic.ne_zero <| hf.map (algebraMap R K)) hg
suffices lem : ∃ g' : R[X], g'.map (algebraMap R K) = g * C g.leadingCoeff⁻¹ by
obtain ⟨g', hg'⟩ := lem
use g'
rw [hg', mul_assoc, ← C_mul, inv_mul_cancel₀ (leadingCoeff_ne_zero.mpr g_ne_0), C_1, mul_one]
have g_mul_dvd : g * C g.leadingCoeff⁻¹ ∣ f.map (algebraMap R K) := by
rwa [Associated.dvd_iff_dvd_left (show Associated (g * C g.leadingCoeff⁻¹) g from _)]
rw [associated_mul_isUnit_left_iff]
exact isUnit_C.mpr (inv_ne_zero <| leadingCoeff_ne_zero.mpr g_ne_0).isUnit
let algeq :=
(Subalgebra.equivOfEq _ _ <| integralClosure_eq_bot R _).trans
(Algebra.botEquivOfInjective <| IsFractionRing.injective R <| K)
have :
(algebraMap R _).comp algeq.toAlgHom.toRingHom = (integralClosure R _).toSubring.subtype := by
ext x; (conv_rhs => rw [← algeq.symm_apply_apply x]); rfl
have H :=
(mem_lifts _).1
(integralClosure.mem_lifts_of_monic_of_dvd_map K hf (monic_mul_leadingCoeff_inv g_ne_0)
g_mul_dvd)
refine ⟨map algeq.toAlgHom.toRingHom ?_, ?_⟩
· use! Classical.choose H
· rw [map_map, this]
exact Classical.choose_spec H
end IsIntegrallyClosed
namespace Polynomial
section
variable {S : Type*} [CommRing S] [IsDomain S]
variable {φ : R →+* S} (hinj : Function.Injective φ) {f : R[X]} (hf : f.IsPrimitive)
include hinj hf
theorem IsPrimitive.isUnit_iff_isUnit_map_of_injective : IsUnit f ↔ IsUnit (map φ f) := by
refine ⟨(mapRingHom φ).isUnit_map, fun h => ?_⟩
rcases isUnit_iff.1 h with ⟨_, ⟨u, rfl⟩, hu⟩
have hdeg := degree_C u.ne_zero
rw [hu, degree_map_eq_of_injective hinj] at hdeg
rw [eq_C_of_degree_eq_zero hdeg] at hf ⊢
exact isUnit_C.mpr (isPrimitive_iff_isUnit_of_C_dvd.mp hf (f.coeff 0) dvd_rfl)
theorem IsPrimitive.irreducible_of_irreducible_map_of_injective (h_irr : Irreducible (map φ f)) :
Irreducible f := by
refine
⟨fun h => h_irr.not_isUnit (IsUnit.map (mapRingHom φ) h), fun a b h =>
(h_irr.isUnit_or_isUnit <| by rw [h, Polynomial.map_mul]).imp ?_ ?_⟩
all_goals apply ((isPrimitive_of_dvd hf _).isUnit_iff_isUnit_map_of_injective hinj).mpr
exacts [Dvd.intro _ h.symm, Dvd.intro_left _ h.symm]
end
section FractionMap
variable {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
theorem IsPrimitive.isUnit_iff_isUnit_map {p : R[X]} (hp : p.IsPrimitive) :
IsUnit p ↔ IsUnit (p.map (algebraMap R K)) :=
hp.isUnit_iff_isUnit_map_of_injective (IsFractionRing.injective _ _)
section IsIntegrallyClosed
open IsIntegrallyClosed
/-- **Gauss's Lemma** for integrally closed domains states that a monic polynomial is irreducible
iff it is irreducible in the fraction field. -/
theorem Monic.irreducible_iff_irreducible_map_fraction_map [IsIntegrallyClosed R] {p : R[X]}
(h : p.Monic) : Irreducible p ↔ Irreducible (p.map <| algebraMap R K) := by
/- The ← direction follows from `IsPrimitive.irreducible_of_irreducible_map_of_injective`.
For the → direction, it is enough to show that if `(p.map <| algebraMap R K) = a * b` and
`a` is not a unit then `b` is a unit -/
refine
⟨fun hp =>
irreducible_iff.mpr
⟨hp.not_isUnit.imp h.isPrimitive.isUnit_iff_isUnit_map.mpr, fun a b H =>
or_iff_not_imp_left.mpr fun hₐ => ?_⟩,
fun hp =>
h.isPrimitive.irreducible_of_irreducible_map_of_injective (IsFractionRing.injective R K) hp⟩
obtain ⟨a', ha⟩ := eq_map_mul_C_of_dvd K h (dvd_of_mul_right_eq b H.symm)
obtain ⟨b', hb⟩ := eq_map_mul_C_of_dvd K h (dvd_of_mul_left_eq a H.symm)
have : a.leadingCoeff * b.leadingCoeff = 1 := by
rw [← leadingCoeff_mul, ← H, Monic.leadingCoeff (h.map <| algebraMap R K)]
rw [← ha, ← hb, mul_comm _ (C b.leadingCoeff), mul_assoc, ← mul_assoc (C a.leadingCoeff), ←
C_mul, this, C_1, one_mul, ← Polynomial.map_mul] at H
rw [← hb, ← Polynomial.coe_mapRingHom]
refine
IsUnit.mul (IsUnit.map _ (Or.resolve_left (hp.isUnit_or_isUnit ?_) (show ¬IsUnit a' from ?_)))
(isUnit_iff_exists_inv'.mpr
(Exists.intro (C a.leadingCoeff) <| by rw [← C_mul, this, C_1]))
· exact Polynomial.map_injective _ (IsFractionRing.injective R K) H
· by_contra h_contra
refine hₐ ?_
rw [← ha, ← Polynomial.coe_mapRingHom]
exact
IsUnit.mul (IsUnit.map _ h_contra)
(isUnit_iff_exists_inv.mpr
(Exists.intro (C b.leadingCoeff) <| by rw [← C_mul, this, C_1]))
/-- Integrally closed domains are precisely the domains for in which Gauss's lemma holds
for monic polynomials -/
theorem isIntegrallyClosed_iff' [IsDomain R] :
IsIntegrallyClosed R ↔
∀ p : R[X], p.Monic → (Irreducible p ↔ Irreducible (p.map <| algebraMap R K)) := by
constructor
· intro hR p hp; exact Monic.irreducible_iff_irreducible_map_fraction_map hp
· intro H
refine
(isIntegrallyClosed_iff K).mpr fun {x} hx =>
RingHom.mem_range.mp <| minpoly.mem_range_of_degree_eq_one R x ?_
rw [← Monic.degree_map (minpoly.monic hx) (algebraMap R K)]
apply
degree_eq_one_of_irreducible_of_root ((H _ <| minpoly.monic hx).mp (minpoly.irreducible hx))
rw [IsRoot, eval_map, ← aeval_def, minpoly.aeval R x]
theorem Monic.dvd_of_fraction_map_dvd_fraction_map [IsIntegrallyClosed R] {p q : R[X]}
(hp : p.Monic) (hq : q.Monic)
(h : q.map (algebraMap R K) ∣ p.map (algebraMap R K)) : q ∣ p := by
obtain ⟨r, hr⟩ := h
obtain ⟨d', hr'⟩ := IsIntegrallyClosed.eq_map_mul_C_of_dvd K hp (dvd_of_mul_left_eq _ hr.symm)
rw [Monic.leadingCoeff, C_1, mul_one] at hr'
· rw [← hr', ← Polynomial.map_mul] at hr
exact dvd_of_mul_right_eq _ (Polynomial.map_injective _ (IsFractionRing.injective R K) hr.symm)
· exact Monic.of_mul_monic_left (hq.map (algebraMap R K)) (by simpa [← hr] using hp.map _)
theorem Monic.dvd_iff_fraction_map_dvd_fraction_map [IsIntegrallyClosed R] {p q : R[X]}
(hp : p.Monic) (hq : q.Monic) : q.map (algebraMap R K) ∣ p.map (algebraMap R K) ↔ q ∣ p :=
⟨fun h => hp.dvd_of_fraction_map_dvd_fraction_map hq h, fun ⟨a, b⟩ =>
⟨a.map (algebraMap R K), b.symm ▸ Polynomial.map_mul (algebraMap R K)⟩⟩
end IsIntegrallyClosed
open IsLocalization
section NormalizedGCDMonoid
variable [IsDomain R] [NormalizedGCDMonoid R]
theorem isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart {p : K[X]} (h0 : p ≠ 0)
(h : IsUnit (integerNormalization R⁰ p).primPart) : IsUnit p := by
rcases isUnit_iff.1 h with ⟨_, ⟨u, rfl⟩, hu⟩
obtain ⟨⟨c, c0⟩, hc⟩ := integerNormalization_map_to_map R⁰ p
rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hc
apply isUnit_of_mul_isUnit_right
rw [← hc, (integerNormalization R⁰ p).eq_C_content_mul_primPart, ← hu, ← RingHom.map_mul,
isUnit_iff]
refine
⟨algebraMap R K ((integerNormalization R⁰ p).content * ↑u), isUnit_iff_ne_zero.2 fun con => ?_,
by simp⟩
replace con := (injective_iff_map_eq_zero (algebraMap R K)).1 (IsFractionRing.injective _ _) _ con
rw [mul_eq_zero, content_eq_zero_iff, IsFractionRing.integerNormalization_eq_zero_iff] at con
rcases con with (con | con)
· apply h0 con
· apply Units.ne_zero _ con
/-- **Gauss's Lemma** for GCD domains states that a primitive polynomial is irreducible iff it is
irreducible in the fraction field. -/
theorem IsPrimitive.irreducible_iff_irreducible_map_fraction_map {p : R[X]} (hp : p.IsPrimitive) :
Irreducible p ↔ Irreducible (p.map (algebraMap R K)) := by
refine
⟨fun hi => ⟨fun h => hi.not_isUnit (hp.isUnit_iff_isUnit_map.2 h), fun a b hab => ?_⟩,
hp.irreducible_of_irreducible_map_of_injective (IsFractionRing.injective _ _)⟩
obtain ⟨⟨c, c0⟩, hc⟩ := integerNormalization_map_to_map R⁰ a
obtain ⟨⟨d, d0⟩, hd⟩ := integerNormalization_map_to_map R⁰ b
rw [Algebra.smul_def, algebraMap_apply, Subtype.coe_mk] at hc hd
rw [mem_nonZeroDivisors_iff_ne_zero] at c0 d0
have hcd0 : c * d ≠ 0 := mul_ne_zero c0 d0
rw [Ne, ← C_eq_zero] at hcd0
have h1 : C c * C d * p = integerNormalization R⁰ a * integerNormalization R⁰ b := by
apply map_injective (algebraMap R K) (IsFractionRing.injective _ _) _
rw [Polynomial.map_mul, Polynomial.map_mul, Polynomial.map_mul, hc, hd, map_C, map_C, hab]
ring
obtain ⟨u, hu⟩ :
Associated (c * d)
(content (integerNormalization R⁰ a) * content (integerNormalization R⁰ b)) := by
rw [← dvd_dvd_iff_associated, ← normalize_eq_normalize_iff, normalize.map_mul,
normalize.map_mul, normalize_content, normalize_content, ←
mul_one (normalize c * normalize d), ← hp.content_eq_one, ← content_C, ← content_C, ←
content_mul, ← content_mul, ← content_mul, h1]
rw [← RingHom.map_mul, eq_comm, (integerNormalization R⁰ a).eq_C_content_mul_primPart,
(integerNormalization R⁰ b).eq_C_content_mul_primPart, mul_assoc, mul_comm _ (C _ * _), ←
mul_assoc, ← mul_assoc, ← RingHom.map_mul, ← hu, RingHom.map_mul, mul_assoc, mul_assoc, ←
mul_assoc (C (u : R))] at h1
have h0 : a ≠ 0 ∧ b ≠ 0 := by
classical
rw [Ne, Ne, ← not_or, ← mul_eq_zero, ← hab]
intro con
apply hp.ne_zero (map_injective (algebraMap R K) (IsFractionRing.injective _ _) _)
simp [con]
rcases hi.isUnit_or_isUnit (mul_left_cancel₀ hcd0 h1).symm with (h | h)
· right
apply
isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart h0.2
(isUnit_of_mul_isUnit_right h)
· left
apply isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart h0.1 h
theorem IsPrimitive.dvd_of_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.IsPrimitive)
(hq : q.IsPrimitive) (h_dvd : p.map (algebraMap R K) ∣ q.map (algebraMap R K)) : p ∣ q := by
rcases h_dvd with ⟨r, hr⟩
obtain ⟨⟨s, s0⟩, hs⟩ := integerNormalization_map_to_map R⁰ r
rw [Subtype.coe_mk, Algebra.smul_def, algebraMap_apply] at hs
have h : p ∣ q * C s := by
use integerNormalization R⁰ r
apply map_injective (algebraMap R K) (IsFractionRing.injective _ _)
rw [Polynomial.map_mul, Polynomial.map_mul, hs, hr, mul_assoc, mul_comm r]
simp
rw [← hp.dvd_primPart_iff_dvd, primPart_mul, hq.primPart_eq, Associated.dvd_iff_dvd_right] at h
· exact h
· symm
rcases isUnit_primPart_C s with ⟨u, hu⟩
use u
rw [hu]
iterate 2
apply mul_ne_zero hq.ne_zero
rw [Ne, C_eq_zero]
contrapose! s0
simp [s0, mem_nonZeroDivisors_iff_ne_zero]
variable (K)
theorem IsPrimitive.dvd_iff_fraction_map_dvd_fraction_map {p q : R[X]} (hp : p.IsPrimitive)
(hq : q.IsPrimitive) : p ∣ q ↔ p.map (algebraMap R K) ∣ q.map (algebraMap R K) :=
⟨fun ⟨a, b⟩ => ⟨a.map (algebraMap R K), b.symm ▸ Polynomial.map_mul (algebraMap R K)⟩, fun h =>
hp.dvd_of_fraction_map_dvd_fraction_map hq h⟩
end NormalizedGCDMonoid
end FractionMap
/-- **Gauss's Lemma** for `ℤ` states that a primitive integer polynomial is irreducible iff it is
irreducible over `ℚ`. -/
theorem IsPrimitive.Int.irreducible_iff_irreducible_map_cast {p : ℤ[X]} (hp : p.IsPrimitive) :
Irreducible p ↔ Irreducible (p.map (Int.castRingHom ℚ)) :=
hp.irreducible_iff_irreducible_map_fraction_map
theorem IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast (p q : ℤ[X]) (hp : p.IsPrimitive)
(hq : q.IsPrimitive) : p ∣ q ↔ p.map (Int.castRingHom ℚ) ∣ q.map (Int.castRingHom ℚ) :=
hp.dvd_iff_fraction_map_dvd_fraction_map ℚ hq
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/SeparableDegree.lean | import Mathlib.Algebra.Algebra.Defs
import Mathlib.FieldTheory.Separable
/-!
# Separable degree
This file contains basics about the separable degree of a polynomial.
## Main results
- `IsSeparableContraction`: is the condition that, for `g` a separable polynomial, we have that
`g(x^(q^m)) = f(x)` for some `m : ℕ`.
- `HasSeparableContraction`: the condition of having a separable contraction
- `HasSeparableContraction.degree`: the separable degree, defined as the degree of some
separable contraction
- `Irreducible.hasSeparableContraction`: any irreducible polynomial can be contracted
to a separable polynomial
- `HasSeparableContraction.dvd_degree'`: the degree of a separable contraction divides the degree,
in function of the exponential characteristic of the field
- `HasSeparableContraction.dvd_degree` and `HasSeparableContraction.eq_degree` specialize the
statement of `separable_degree_dvd_degree`
- `IsSeparableContraction.degree_eq`: the separable degree is well-defined, implemented as the
statement that the degree of any separable contraction equals `HasSeparableContraction.degree`
## Tags
separable degree, degree, polynomial
-/
noncomputable section
namespace Polynomial
open Polynomial
section CommSemiring
variable {F : Type*} [CommSemiring F] (q : ℕ)
/-- A separable contraction of a polynomial `f` is a separable polynomial `g` such that
`g(x^(q^m)) = f(x)` for some `m : ℕ`. -/
def IsSeparableContraction (f : F[X]) (g : F[X]) : Prop :=
g.Separable ∧ ∃ m : ℕ, expand F (q ^ m) g = f
/-- The condition of having a separable contraction. -/
def HasSeparableContraction (f : F[X]) : Prop :=
∃ g : F[X], IsSeparableContraction q f g
variable {q} {f : F[X]} (hf : HasSeparableContraction q f)
/-- A choice of a separable contraction. -/
def HasSeparableContraction.contraction : F[X] :=
Classical.choose hf
/-- The separable degree of a polynomial is the degree of a given separable contraction. -/
def HasSeparableContraction.degree : ℕ :=
hf.contraction.natDegree
/-- The `HasSeparableContraction.contraction` is indeed a separable contraction. -/
theorem HasSeparableContraction.isSeparableContraction :
IsSeparableContraction q f hf.contraction := Classical.choose_spec hf
/-- The separable degree divides the degree, in function of the exponential characteristic of F. -/
theorem IsSeparableContraction.dvd_degree' {g} (hf : IsSeparableContraction q f g) :
∃ m : ℕ, g.natDegree * q ^ m = f.natDegree := by
obtain ⟨m, rfl⟩ := hf.2
use m
rw [natDegree_expand]
theorem HasSeparableContraction.dvd_degree' : ∃ m : ℕ, hf.degree * q ^ m = f.natDegree :=
(Classical.choose_spec hf).dvd_degree'
/-- The separable degree divides the degree. -/
theorem HasSeparableContraction.dvd_degree : hf.degree ∣ f.natDegree :=
let ⟨a, ha⟩ := hf.dvd_degree'
Dvd.intro (q ^ a) ha
/-- In exponential characteristic one, the separable degree equals the degree. -/
theorem HasSeparableContraction.eq_degree {f : F[X]} (hf : HasSeparableContraction 1 f) :
hf.degree = f.natDegree := by
let ⟨a, ha⟩ := hf.dvd_degree'
rw [← ha, one_pow a, mul_one]
end CommSemiring
section Field
variable {F : Type*} [Field F]
variable (q : ℕ) {f : F[X]} (hf : HasSeparableContraction q f)
/-- Every irreducible polynomial can be contracted to a separable polynomial. -/
@[stacks 09H0]
theorem _root_.Irreducible.hasSeparableContraction (q : ℕ) [hF : ExpChar F q] {f : F[X]}
(irred : Irreducible f) : HasSeparableContraction q f := by
cases hF
· exact ⟨f, irred.separable, ⟨0, by rw [pow_zero, expand_one]⟩⟩
· rcases exists_separable_of_irreducible q irred ‹q.Prime›.ne_zero with ⟨n, g, hgs, hge⟩
exact ⟨g, hgs, n, hge⟩
/-- If two expansions (along the positive characteristic) of two separable polynomials `g` and `g'`
agree, then they have the same degree. -/
theorem contraction_degree_eq_or_insep [hq : NeZero q] [CharP F q] (g g' : F[X]) (m m' : ℕ)
(h_expand : expand F (q ^ m) g = expand F (q ^ m') g') (hg : g.Separable) (hg' : g'.Separable) :
g.natDegree = g'.natDegree := by
wlog hm : m ≤ m'
· exact (this q g' g m' m h_expand.symm hg' hg (le_of_not_ge hm)).symm
obtain ⟨s, rfl⟩ := exists_add_of_le hm
rw [pow_add, expand_mul, expand_inj (pow_pos (NeZero.pos q) m)] at h_expand
subst h_expand
rcases isUnit_or_eq_zero_of_separable_expand q s (NeZero.pos q) hg with (h | rfl)
· rw [natDegree_expand, natDegree_eq_zero_of_isUnit h, zero_mul]
· rw [natDegree_expand, pow_zero, mul_one]
/-- The separable degree equals the degree of any separable contraction, i.e., it is unique. -/
theorem IsSeparableContraction.degree_eq [hF : ExpChar F q] (g : F[X])
(hg : IsSeparableContraction q f g) : g.natDegree = hf.degree := by
cases hF
· rcases hg with ⟨_, m, hm⟩
rw [one_pow, expand_one] at hm
rw [hf.eq_degree, hm]
· rcases hg with ⟨hg, m, hm⟩
let g' := Classical.choose hf
obtain ⟨hg', m', hm'⟩ := Classical.choose_spec hf
haveI : Fact q.Prime := ⟨by assumption⟩
refine contraction_degree_eq_or_insep q g g' m m' ?_ hg hg'
rw [hm, hm']
end Field
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Tower.lean | import Mathlib.Algebra.Algebra.Tower
import Mathlib.Algebra.Polynomial.AlgebraMap
/-!
# Algebra towers for polynomial
This file proves some basic results about the algebra tower structure for the type `R[X]`.
This structure itself is provided elsewhere as `Polynomial.isScalarTower`
When you update this file, you can also try to make a corresponding update in
`RingTheory.MvPolynomial.Tower`.
-/
open Polynomial
variable (R A B : Type*)
namespace Polynomial
section Semiring
variable [CommSemiring R] [CommSemiring A] [Semiring B]
variable [Algebra R A] [Algebra A B] [Algebra R B]
variable [IsScalarTower R A B]
variable {R B}
@[simp]
theorem aeval_map_algebraMap (x : B) (p : R[X]) : aeval x (map (algebraMap R A) p) = aeval x p := by
rw [aeval_def, aeval_def, eval₂_map, IsScalarTower.algebraMap_eq R A B]
end Semiring
section CommSemiring
variable [CommSemiring R] [CommSemiring A] [Semiring B]
variable [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B]
variable {R A}
theorem aeval_algebraMap_apply (x : A) (p : R[X]) :
aeval (algebraMap A B x) p = algebraMap A B (aeval x p) := by
rw [aeval_def, aeval_def, hom_eval₂, ← IsScalarTower.algebraMap_eq]
@[simp]
theorem aeval_algebraMap_eq_zero_iff [NoZeroSMulDivisors A B] [Nontrivial B] (x : A) (p : R[X]) :
aeval (algebraMap A B x) p = 0 ↔ aeval x p = 0 := by
rw [aeval_algebraMap_apply, Algebra.algebraMap_eq_smul_one, smul_eq_zero,
iff_false_intro (one_ne_zero' B), or_false]
variable {B}
theorem aeval_algebraMap_eq_zero_iff_of_injective {x : A} {p : R[X]}
(h : Function.Injective (algebraMap A B)) : aeval (algebraMap A B x) p = 0 ↔ aeval x p = 0 := by
rw [aeval_algebraMap_apply, ← (algebraMap A B).map_zero, h.eq_iff]
end CommSemiring
end Polynomial
namespace Subalgebra
open Polynomial
section CommSemiring
variable {R A} [CommSemiring R] [CommSemiring A] [Algebra R A]
@[simp]
theorem aeval_coe (S : Subalgebra R A) (x : S) (p : R[X]) : aeval (x : A) p = aeval x p :=
aeval_algebraMap_apply A x p
end CommSemiring
end Subalgebra |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Dickson.lean | import Mathlib.Algebra.CharP.Algebra
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Algebra.CharP.Lemmas
import Mathlib.Algebra.EuclideanDomain.Field
import Mathlib.Algebra.Field.ZMod
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.RingTheory.Polynomial.Chebyshev
/-!
# Dickson polynomials
The (generalised) Dickson polynomials are a family of polynomials indexed by `ℕ × ℕ`,
with coefficients in a commutative ring `R` depending on an element `a∈R`. More precisely, the
they satisfy the recursion `dickson k a (n + 2) = X * (dickson k a n + 1) - a * (dickson k a n)`
with starting values `dickson k a 0 = 3 - k` and `dickson k a 1 = X`. In the literature,
`dickson k a n` is called the `n`-th Dickson polynomial of the `k`-th kind associated to the
parameter `a : R`. They are closely related to the Chebyshev polynomials in the case that `a=1`.
When `a=0` they are just the family of monomials `X ^ n`.
## Main definition
* `Polynomial.dickson`: the generalised Dickson polynomials.
## Main statements
* `Polynomial.dickson_one_one_mul`, the `(m * n)`-th Dickson polynomial of the first kind for
parameter `1 : R` is the composition of the `m`-th and `n`-th Dickson polynomials of the first
kind for `1 : R`.
* `Polynomial.dickson_one_one_charP`, for a prime number `p`, the `p`-th Dickson polynomial of the
first kind associated to parameter `1 : R` is congruent to `X ^ p` modulo `p`.
## References
* [R. Lidl, G. L. Mullen and G. Turnwald, _Dickson polynomials_][MR1237403]
## TODO
* Redefine `dickson` in terms of `LinearRecurrence`.
* Show that `dickson 2 1` is equal to the characteristic polynomial of the adjacency matrix of a
type A Dynkin diagram.
* Prove that the adjacency matrices of simply laced Dynkin diagrams are precisely the adjacency
matrices of simple connected graphs which annihilate `dickson 2 1`.
-/
noncomputable section
namespace Polynomial
variable {R S : Type*} [CommRing R] [CommRing S] (k : ℕ) (a : R)
/-- `dickson` is the `n`-th (generalised) Dickson polynomial of the `k`-th kind associated to the
element `a ∈ R`. -/
noncomputable def dickson : ℕ → R[X]
| 0 => 3 - k
| 1 => X
| n + 2 => X * dickson (n + 1) - C a * dickson n
@[simp]
theorem dickson_zero : dickson k a 0 = 3 - k :=
rfl
@[simp]
theorem dickson_one : dickson k a 1 = X :=
rfl
theorem dickson_two : dickson k a 2 = X ^ 2 - C a * (3 - k : R[X]) := by
simp only [dickson, sq]
@[simp]
theorem dickson_add_two (n : ℕ) :
dickson k a (n + 2) = X * dickson k a (n + 1) - C a * dickson k a n := by rw [dickson]
theorem dickson_of_two_le {n : ℕ} (h : 2 ≤ n) :
dickson k a n = X * dickson k a (n - 1) - C a * dickson k a (n - 2) := by
obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le h
rw [add_comm]
exact dickson_add_two k a n
variable {k a}
theorem map_dickson (f : R →+* S) : ∀ n : ℕ, map f (dickson k a n) = dickson k (f a) n
| 0 => by
simp_rw [dickson_zero, Polynomial.map_sub, Polynomial.map_natCast, Polynomial.map_ofNat]
| 1 => by simp only [dickson_one, map_X]
| n + 2 => by
simp only [dickson_add_two, Polynomial.map_sub, Polynomial.map_mul, map_X, map_C]
rw [map_dickson f n, map_dickson f (n + 1)]
@[simp]
theorem dickson_two_zero : ∀ n : ℕ, dickson 2 (0 : R) n = X ^ n
| 0 => by
simp only [dickson_zero, pow_zero]
norm_num
| 1 => by simp only [dickson_one, pow_one]
| n + 2 => by
simp only [dickson_add_two, C_0, zero_mul, sub_zero]
rw [dickson_two_zero (n + 1), pow_add X (n + 1) 1, mul_comm, pow_one]
section Dickson
/-!
### A Lambda structure on `ℤ[X]`
Mathlib doesn't currently know what a Lambda ring is.
But once it does, we can endow `ℤ[X]` with a Lambda structure
in terms of the `dickson 1 1` polynomials defined below.
There is exactly one other Lambda structure on `ℤ[X]` in terms of binomial polynomials.
-/
theorem dickson_one_one_eval_add_inv (x y : R) (h : x * y = 1) :
∀ n, (dickson 1 (1 : R) n).eval (x + y) = x ^ n + y ^ n
| 0 => by
simp only [pow_zero, dickson_zero]; norm_num
| 1 => by simp only [eval_X, dickson_one, pow_one]
| n + 2 => by
simp only [eval_sub, eval_mul, dickson_one_one_eval_add_inv x y h _, eval_X, dickson_add_two,
C_1, eval_one]
conv_lhs => simp only [pow_succ', add_mul, mul_add, h, ← mul_assoc, mul_comm y x, one_mul]
ring
variable (R)
private theorem two_mul_C_half_eq_one [Invertible (2 : R)] : 2 * C (⅟2 : R) = 1 := by
rw [two_mul, ← C_add, invOf_two_add_invOf_two, C_1]
private theorem C_half_mul_two_eq_one [Invertible (2 : R)] : C (⅟2 : R) * 2 = 1 := by
rw [mul_comm, two_mul_C_half_eq_one]
theorem dickson_one_one_eq_chebyshev_C : ∀ n, dickson 1 (1 : R) n = Chebyshev.C R n
| 0 => by
simp only [dickson_zero]
norm_num
| 1 => by
rw [dickson_one, Nat.cast_one, Chebyshev.C_one]
| n + 2 => by
rw [dickson_add_two, C_1, Nat.cast_add, Nat.cast_two, Chebyshev.C_add_two,
dickson_one_one_eq_chebyshev_C (n + 1), dickson_one_one_eq_chebyshev_C n]
push_cast
ring
theorem dickson_one_one_eq_chebyshev_T [Invertible (2 : R)] (n : ℕ) :
dickson 1 (1 : R) n = 2 * (Chebyshev.T R n).comp (C (⅟2) * X) :=
(dickson_one_one_eq_chebyshev_C R n).trans (Chebyshev.C_eq_two_mul_T_comp_half_mul_X R n)
theorem chebyshev_T_eq_dickson_one_one [Invertible (2 : R)] (n : ℕ) :
Chebyshev.T R n = C (⅟2) * (dickson 1 1 n).comp (2 * X) :=
dickson_one_one_eq_chebyshev_C R n ▸ Chebyshev.T_eq_half_mul_C_comp_two_mul_X R n
theorem dickson_two_one_eq_chebyshev_S : ∀ n, dickson 2 (1 : R) n = Chebyshev.S R n
| 0 => by
simp only [dickson_zero]
norm_num
| 1 => by
rw [dickson_one, Nat.cast_one, Chebyshev.S_one]
| n + 2 => by
rw [dickson_add_two, C_1, Nat.cast_add, Nat.cast_two, Chebyshev.S_add_two,
dickson_two_one_eq_chebyshev_S (n + 1), dickson_two_one_eq_chebyshev_S n]
push_cast
ring
theorem dickson_two_one_eq_chebyshev_U [Invertible (2 : R)] (n : ℕ) :
dickson 2 (1 : R) n = (Chebyshev.U R n).comp (C (⅟2) * X) :=
(dickson_two_one_eq_chebyshev_S R n).trans (Chebyshev.S_eq_U_comp_half_mul_X R n)
theorem chebyshev_U_eq_dickson_two_one (n : ℕ) :
Chebyshev.U R n = (dickson 2 (1 : R) n).comp (2 * X) :=
dickson_two_one_eq_chebyshev_S R n ▸ (Chebyshev.S_comp_two_mul_X R n).symm
/-- The `(m * n)`-th Dickson polynomial of the first kind is the composition of the `m`-th and
`n`-th. -/
theorem dickson_one_one_mul (m n : ℕ) :
dickson 1 (1 : R) (m * n) = (dickson 1 1 m).comp (dickson 1 1 n) := by
have h : (1 : R) = Int.castRingHom R 1 := by simp only [eq_intCast, Int.cast_one]
rw [h]
simp only [← map_dickson (Int.castRingHom R), ← map_comp]
congr 1
apply map_injective (Int.castRingHom ℚ) Int.cast_injective
simp only [map_dickson, map_comp, eq_intCast, Int.cast_one, dickson_one_one_eq_chebyshev_T,
Nat.cast_mul, Chebyshev.T_mul, two_mul, ← add_comp]
simp only [← two_mul, ← comp_assoc]
apply eval₂_congr rfl rfl
rw [comp_assoc]
apply eval₂_congr rfl _ rfl
rw [mul_comp, C_comp, X_comp, ← mul_assoc, C_half_mul_two_eq_one, one_mul]
theorem dickson_one_one_comp_comm (m n : ℕ) :
(dickson 1 (1 : R) m).comp (dickson 1 1 n) = (dickson 1 1 n).comp (dickson 1 1 m) := by
rw [← dickson_one_one_mul, mul_comm, dickson_one_one_mul]
theorem dickson_one_one_zmod_p (p : ℕ) [Fact p.Prime] : dickson 1 (1 : ZMod p) p = X ^ p := by
-- Recall that `dickson_one_one_eval_add_inv` characterises `dickson 1 1 p`
-- as a polynomial that maps `x + x⁻¹` to `x ^ p + (x⁻¹) ^ p`.
-- Since `X ^ p` also satisfies this property in characteristic `p`,
-- we can use a variant on `Polynomial.funext` to conclude that these polynomials are equal.
-- For this argument, we need an arbitrary infinite field of characteristic `p`.
obtain ⟨K, _, _, H⟩ : ∃ (K : Type) (_ : Field K), ∃ _ : CharP K p, Infinite K := by
let K := FractionRing (Polynomial (ZMod p))
let f : ZMod p →+* K := (algebraMap _ (FractionRing _)).comp C
have : CharP K p := by
rw [← f.charP_iff_charP]
infer_instance
haveI : Infinite K :=
Infinite.of_injective (algebraMap (Polynomial (ZMod p)) (FractionRing (Polynomial (ZMod p))))
(IsFractionRing.injective _ _)
refine ⟨K, ?_, ?_, ?_⟩ <;> infer_instance
apply map_injective (ZMod.castHom (dvd_refl p) K) (RingHom.injective _)
rw [map_dickson, Polynomial.map_pow, map_X]
apply eq_of_infinite_eval_eq
-- The two polynomials agree on all `x` of the form `x = y + y⁻¹`.
apply @Set.Infinite.mono _ { x : K | ∃ y, x = y + y⁻¹ ∧ y ≠ 0 }
· rintro _ ⟨x, rfl, hx⟩
simp only [eval_X, eval_pow, Set.mem_setOf_eq, ZMod.cast_one', add_pow_char,
dickson_one_one_eval_add_inv _ _ (mul_inv_cancel₀ hx), ZMod.castHom_apply]
-- Now we need to show that the set of such `x` is infinite.
-- If the set is finite, then we will show that `K` is also finite.
· intro h
rw [← Set.infinite_univ_iff] at H
apply H
-- To each `x` of the form `x = y + y⁻¹`
-- we `bind` the set of `y` that solve the equation `x = y + y⁻¹`.
-- For every `x`, that set is finite (since it is governed by a quadratic equation).
-- For the moment, we claim that all these sets together cover `K`.
suffices (Set.univ : Set K) =
⋃ x ∈ { x : K | ∃ y : K, x = y + y⁻¹ ∧ y ≠ 0 }, { y | x = y + y⁻¹ ∨ y = 0 } by
rw [this]
clear this
refine h.biUnion fun x _ => ?_
-- The following quadratic polynomial has as solutions the `y` for which `x = y + y⁻¹`.
let φ : K[X] := X ^ 2 - C x * X + 1
have hφ : φ ≠ 0 := by
intro H
have : φ.eval 0 = 0 := by rw [H, eval_zero]
simpa [φ, eval_X, eval_one, eval_pow, eval_sub, sub_zero, eval_add, eval_mul,
mul_zero, sq, zero_add, one_ne_zero]
classical
convert (φ.roots ∪ {0}).toFinset.finite_toSet using 1
ext1 y
simp only [φ, Multiset.mem_toFinset, Set.mem_setOf_eq, Finset.mem_coe, Multiset.mem_union,
mem_roots hφ, IsRoot, eval_add, eval_sub, eval_pow, eval_mul, eval_X, eval_C, eval_one,
Multiset.mem_singleton]
by_cases hy : y = 0
· simp only [hy, or_true]
apply or_congr _ Iff.rfl
rw [← mul_left_inj' hy, eq_comm, ← sub_eq_zero, add_mul, inv_mul_cancel₀ hy]
apply eq_iff_eq_cancel_right.mpr
ring
-- Finally, we prove the claim that our finite union of finite sets covers all of `K`.
apply (Set.eq_univ_of_forall _).symm
intro x
simp only [exists_prop, Set.mem_iUnion, Ne, Set.mem_setOf_eq]
by_cases hx : x = 0
· simp only [hx, and_true, inv_zero, or_true]
exact ⟨_, 1, rfl, one_ne_zero⟩
· simp only [hx, or_false, exists_eq_right]
exact ⟨_, rfl, hx⟩
theorem dickson_one_one_charP (p : ℕ) [Fact p.Prime] [CharP R p] : dickson 1 (1 : R) p = X ^ p := by
have h : (1 : R) = ZMod.castHom (dvd_refl p) R 1 := by
simp only [ZMod.castHom_apply, ZMod.cast_one']
rw [h, ← map_dickson (ZMod.castHom (dvd_refl p) R), dickson_one_one_zmod_p, Polynomial.map_pow,
map_X]
end Dickson
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/ContentIdeal.lean | import Mathlib.Order.CompletePartialOrder
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Polynomial.Content
/-!
# The content ideal of a polynomial
In this file we introduce the content ideal of a polynomial `p : R[X]` as the ideal generated by its
coefficients, and we prove some basic properties about it.
## Main Definitions
Let `p : R[X]`.
- `p.contentIdeal` is the `Ideal R` generated by the coefficients of `p`.
## Main Results
- `Polynomial.contentIdeal_mul_le_mul_contentIdeal`: the content ideal of the product of two
polynomials is contained in the product of their content ideals.
- `Polynomial.isPrimitive_of_contentIdeal_eq_top`: if the content ideal of `p` is the whole ring,
then `p` is primitive.
- `Submodule.IsPrincipal.isPrimitive_iff_contentIdeal_eq_top`: in case the content ideal of `p` is
principal, `p` is primitive if and only if its content ideal is the whole ring.
- `Polynomial.mul_contentIdeal_le_radical_contentIdeal_mul`: the product of the content ideals of
two polynomials is contained in the radical of the content ideal of their product.
- `Submodule.IsPrincipal.contentIdeal_eq_span_content_of_isPrincipal`: if the content ideal of `p`
is principal, then it is equal to the ideal generated by the content of `p`.
- `contentIdeal_mul_eq_top_of_contentIdeal_eq_top`: if the content ideals of two
polynomials are the whole ring, then the content ideal of their product is the whole ring. This
is also often called Gauss' Lemma.
## TODO
- Prove the Dedekind-Mertens lemma, see https://www.cse.chalmers.se/~coquand/mertens.pdf
-/
namespace Polynomial
open Ideal
variable {R S : Type*} [Semiring R] [Semiring S] (p : R[X])
/-- The content ideal of a polynomial `p` is the ideal generated by its coefficients. -/
def contentIdeal := span (p.coeffs : Set R)
theorem contentIdeal_def : p.contentIdeal = span (p.coeffs : Set R) := rfl
@[simp]
theorem contentIdeal_zero : (0 : R[X]).contentIdeal = ⊥ := by
simp [contentIdeal_def]
@[deprecated (since := "2025-07-01")]
alias contenIdeal_zero := contentIdeal_zero
@[simp]
theorem contentIdeal_eq_bot_iff : p.contentIdeal = ⊥ ↔ p = 0 := by
simp only [contentIdeal_def, span_eq_bot]
refine ⟨?_, fun h ↦ by simp [h]⟩
contrapose!
exact fun h ↦ ⟨p.leadingCoeff, coeff_mem_coeffs (leadingCoeff_ne_zero.mpr h),
leadingCoeff_ne_zero.mpr h⟩
theorem coeff_mem_contentIdeal (n : ℕ) : p.coeff n ∈ p.contentIdeal := by
by_cases h : p.coeff n = 0
· simp [h]
· apply subset_span
simpa using coeff_mem_coeffs h
@[simp]
theorem contentIdeal_monomial (n : ℕ) (r : R) : (monomial n r).contentIdeal = span {r} := by
by_cases h : r = 0 <;>
simp [h, Set.singleton_zero, contentIdeal_def, coeffs_monomial]
@[simp]
theorem contentIdeal_C (r : R) : (C r).contentIdeal = span {r} := by
rw [← monomial_zero_left]
exact contentIdeal_monomial 0 r
@[simp]
theorem contentIdeal_one : (1 : R[X]).contentIdeal = ⊤ := by
rw [← span_singleton_one, ← contentIdeal_C 1, C_1]
theorem contentIdeal_FG : p.contentIdeal.FG := ⟨p.coeffs, rfl⟩
theorem contentIdeal_map_eq_map_contentIdeal (f : R →+* S) :
(p.map f).contentIdeal = p.contentIdeal.map f := by
suffices span ((map f p).coeffs ∪ {0}) = span (f '' p.coeffs ∪ {0}) by
simpa [contentIdeal_def, map_span]
congr 1
ext s
by_cases hs : s = 0
· simp [hs]
· aesop (add simp mem_coeffs_iff)
theorem contentIdeal_mul_le_mul_contentIdeal (q : R[X]) :
(p * q).contentIdeal ≤ p.contentIdeal * q.contentIdeal := by
rw [contentIdeal_def, span_le]
simp only [Set.subset_def, Finset.mem_coe, mem_coeffs_iff]
rintro r ⟨n, _, rfl⟩
simp [coeff_mul, _root_.sum_mem, Submodule.mul_mem_mul, coeff_mem_contentIdeal]
section CommSemiring
variable {R : Type*} [CommSemiring R] {p q : R[X]}
theorem contentIdeal_le_contentIdeal_of_dvd (hpq : p ∣ q) : q.contentIdeal ≤ p.contentIdeal := by
obtain ⟨p', rfl⟩ := hpq
exact le_trans (p.contentIdeal_mul_le_mul_contentIdeal p') mul_le_right
theorem _root_.Submodule.IsPrincipal.contentIdeal_generator_dvd_coeff
(h_prin : p.contentIdeal.IsPrincipal) (n : ℕ) : h_prin.generator ∣ p.coeff n := by
have := p.coeff_mem_contentIdeal n
rw [Submodule.IsPrincipal.mem_iff_eq_smul_generator] at this
obtain ⟨_, ha⟩ := this
simp [ha]
theorem _root_.Submodule.IsPrincipal.contentIdeal_generator_dvd
(h_prin : p.contentIdeal.IsPrincipal) : C h_prin.generator ∣ p := by
rw [C_dvd_iff_dvd_coeff]
exact fun i ↦ h_prin.contentIdeal_generator_dvd_coeff i
theorem _root_.Submodule.IsPrincipal.contentIdeal_le_span_iff_dvd
(h_prin : p.contentIdeal.IsPrincipal) (r : R) :
p.contentIdeal ≤ span {r} ↔ C r ∣ p := by
constructor
· rw [← p.contentIdeal.span_singleton_generator]
intro _
calc
C r ∣ C h_prin.generator := by
apply _root_.map_dvd C
rwa [← span_singleton_le_span_singleton]
_ ∣ p := h_prin.contentIdeal_generator_dvd
· rw [← contentIdeal_C r]
exact fun h ↦ contentIdeal_le_contentIdeal_of_dvd h
/-- If the coefficients of `p` generate the whole ring, then `p` is primitive. -/
theorem isPrimitive_of_contentIdeal_eq_top (h : p.contentIdeal = ⊤) : p.IsPrimitive := by
have h_prin : p.contentIdeal.IsPrincipal := by
rw [h]
exact top_isPrincipal
intro r
simp [← h_prin.contentIdeal_le_span_iff_dvd r, h]
theorem _root_.Submodule.IsPrincipal.isPrimitive_iff_contentIdeal_eq_top
(h_prin : p.contentIdeal.IsPrincipal) : p.IsPrimitive ↔ p.contentIdeal = ⊤ := by
refine ⟨?_, fun h ↦ isPrimitive_of_contentIdeal_eq_top h⟩
contrapose!
simp only [IsPrimitive, not_forall]
intro _
use h_prin.generator, h_prin.contentIdeal_generator_dvd
simp_all [← Ideal.span_singleton_eq_top]
theorem contentIdeal_eq_top_of_contentIdeal_mul_eq_top
(h : (p * q).contentIdeal = ⊤) : p.contentIdeal = ⊤ := by
apply le_antisymm le_top
calc
⊤ = (p * q).contentIdeal := h.symm
_ ≤ p.contentIdeal * q.contentIdeal := contentIdeal_mul_le_mul_contentIdeal p q
_ ≤ p.contentIdeal := mul_le_right
end CommSemiring
section Ring
variable {R : Type*} [CommRing R] {p q : R[X]}
theorem mul_contentIdeal_le_radical_contentIdeal_mul :
p.contentIdeal * q.contentIdeal ≤ ((p * q).contentIdeal).radical := by
rw [radical_eq_sInf, le_sInf_iff]
intro P ⟨hpq, hPprime⟩
rw [hPprime.mul_le]
rw [← Ideal.mk_ker (I := P)] at hpq ⊢
simpa only [← map_eq_bot_iff_le_ker, ← contentIdeal_map_eq_map_contentIdeal, Polynomial.map_mul,
contentIdeal_eq_bot_iff, mul_eq_zero] using hpq
theorem contentIdeal_mul_eq_top_of_contentIdeal_eq_top (hp : p.contentIdeal = ⊤)
(hq : q.contentIdeal = ⊤) : (p * q).contentIdeal = ⊤ := by
rw [← Ideal.radical_eq_top]
apply le_antisymm le_top
calc
⊤ = p.contentIdeal * q.contentIdeal := by simp [hp, hq]
_ ≤ ((p * q).contentIdeal).radical := mul_contentIdeal_le_radical_contentIdeal_mul
end Ring
section NormalizedGCDMonoid
variable {R : Type*} [CommRing R] [IsDomain R] [NormalizedGCDMonoid R] {p : R[X]}
theorem contentIdeal_le_span_content : p.contentIdeal ≤ span {p.content} := by
rw [contentIdeal_def, span_le]
intro _ h1
rw [Finset.mem_coe, mem_coeffs_iff] at h1
obtain ⟨n, _, h2⟩ := h1
rw [SetLike.mem_coe, h2, mem_span_singleton]
exact content_dvd_coeff n
theorem _root_.Submodule.IsPrincipal.contentIdeal_eq_span_content_of_isPrincipal
(h_prin : p.contentIdeal.IsPrincipal) : p.contentIdeal = span {p.content} := by
apply le_antisymm contentIdeal_le_span_content
rw [← p.contentIdeal.span_singleton_generator, span_singleton_le_span_singleton, content,
Finset.dvd_gcd_iff]
exact fun n _ ↦ h_prin.contentIdeal_generator_dvd_coeff n
end NormalizedGCDMonoid
section IsBezout
variable {R : Type*} [CommSemiring R] [IsBezout R] (p : R[X])
/-- The polynomial `p` is primitive if and only if the coefficients of `p` generate the whole ring.
-/
theorem isPrimitive_iff_contentIdeal_eq_top : p.IsPrimitive ↔ p.contentIdeal = ⊤ :=
(IsBezout.isPrincipal_of_FG _ p.contentIdeal_FG).isPrimitive_iff_contentIdeal_eq_top
end IsBezout
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Selmer.lean | import Mathlib.Analysis.Complex.Polynomial.UnitTrinomial
import Mathlib.RingTheory.Polynomial.GaussLemma
import Mathlib.Tactic.LinearCombination
/-!
# Irreducibility of Selmer Polynomials
This file proves irreducibility of the Selmer polynomials `X ^ n - X - 1`.
## Main results
- `X_pow_sub_X_sub_one_irreducible`: The Selmer polynomials `X ^ n - X - 1` are irreducible.
TODO: Show that the Selmer polynomials have full Galois group.
-/
namespace Polynomial
open scoped Polynomial
variable {n : ℕ}
theorem X_pow_sub_X_sub_one_irreducible_aux (z : ℂ) : ¬(z ^ n = z + 1 ∧ z ^ n + z ^ 2 = 0) := by
rintro ⟨h1, h2⟩
replace h3 : z ^ 3 = 1 := by
linear_combination (1 - z - z ^ 2 - z ^ n) * h1 + (z ^ n - 2) * h2
have key : z ^ n = 1 ∨ z ^ n = z ∨ z ^ n = z ^ 2 := by
rw [← Nat.mod_add_div n 3, pow_add, pow_mul, h3, one_pow, mul_one]
have : n % 3 < 3 := Nat.mod_lt n zero_lt_three
interval_cases n % 3 <;>
simp only [pow_zero, pow_one, or_true, true_or]
have z_ne_zero : z ≠ 0 := fun h =>
zero_ne_one ((zero_pow three_ne_zero).symm.trans (show (0 : ℂ) ^ 3 = 1 from h ▸ h3))
rcases key with (key | key | key)
· exact z_ne_zero (by rwa [key, right_eq_add] at h1)
· exact one_ne_zero (by rwa [key, left_eq_add] at h1)
· exact z_ne_zero (eq_zero_of_pow_eq_zero (by rwa [key, add_self_eq_zero] at h2))
theorem X_pow_sub_X_sub_one_irreducible (hn1 : n ≠ 1) : Irreducible (X ^ n - X - 1 : ℤ[X]) := by
by_cases hn0 : n = 0
· rw [hn0, pow_zero, sub_sub, add_comm, ← sub_sub, sub_self, zero_sub]
exact Associated.irreducible ⟨-1, mul_neg_one X⟩ irreducible_X
have hn : 1 < n := Nat.one_lt_iff_ne_zero_and_ne_one.mpr ⟨hn0, hn1⟩
have hp : (X ^ n - X - 1 : ℤ[X]) = trinomial 0 1 n (-1) (-1) 1 := by
simp only [trinomial, C_neg, C_1]; ring
rw [hp]
apply IsUnitTrinomial.irreducible_of_coprime' ⟨0, 1, n, zero_lt_one, hn, -1, -1, 1, rfl⟩
rintro z ⟨h1, h2⟩
apply X_pow_sub_X_sub_one_irreducible_aux (n := n) z
rw [trinomial_mirror zero_lt_one hn (-1 : ℤˣ).ne_zero (1 : ℤˣ).ne_zero] at h2
simp_rw [trinomial, aeval_add, aeval_mul, aeval_X_pow, aeval_C,
Units.val_neg, Units.val_one, map_neg, map_one] at h1 h2
replace h1 : z ^ n = z + 1 := by linear_combination h1
replace h2 := mul_eq_zero_of_left h2 z
rw [add_mul, add_mul, add_zero, mul_assoc (-1 : ℂ), ← pow_succ, Nat.sub_add_cancel hn.le] at h2
rw [h1] at h2 ⊢
exact ⟨rfl, by linear_combination -h2⟩
theorem X_pow_sub_X_sub_one_irreducible_rat (hn1 : n ≠ 1) : Irreducible (X ^ n - X - 1 : ℚ[X]) := by
by_cases hn0 : n = 0
· rw [hn0, pow_zero, sub_sub, add_comm, ← sub_sub, sub_self, zero_sub]
exact Associated.irreducible ⟨-1, mul_neg_one X⟩ irreducible_X
have hp : (X ^ n - X - 1 : ℤ[X]) = trinomial 0 1 n (-1) (-1) 1 := by
simp only [trinomial, C_neg, C_1]; ring
have hn : 1 < n := Nat.one_lt_iff_ne_zero_and_ne_one.mpr ⟨hn0, hn1⟩
have h := (IsPrimitive.Int.irreducible_iff_irreducible_map_cast ?_).mp
(X_pow_sub_X_sub_one_irreducible hn1)
· rwa [Polynomial.map_sub, Polynomial.map_sub, Polynomial.map_pow, Polynomial.map_one,
Polynomial.map_X] at h
· exact hp.symm ▸ (trinomial_monic zero_lt_one hn).isPrimitive
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Basic.lean | import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.MvPolynomial.Equiv
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Ring.GeomSum
import Mathlib.RingTheory.Noetherian.Basic
/-!
# Ring-theoretic supplement of Algebra.Polynomial.
## Main results
* `MvPolynomial.isDomain`:
If a ring is an integral domain, then so is its polynomial ring over finitely many variables.
* `Polynomial.isNoetherianRing`:
Hilbert basis theorem, that if a ring is Noetherian then so is its polynomial ring.
-/
noncomputable section
open Polynomial
open Finset
universe u v w
variable {R : Type u} {S : Type*}
namespace Polynomial
section Semiring
variable [Semiring R]
instance instCharP (p : ℕ) [h : CharP R p] : CharP R[X] p :=
let ⟨h⟩ := h
⟨fun n => by rw [← map_natCast C, ← C_0, C_inj, h]⟩
instance instExpChar (p : ℕ) [h : ExpChar R p] : ExpChar R[X] p := by
cases h; exacts [ExpChar.zero, ExpChar.prime ‹_›]
variable (R)
/-- The `R`-submodule of `R[X]` consisting of polynomials of degree ≤ `n`. -/
def degreeLE (n : WithBot ℕ) : Submodule R R[X] :=
⨅ k : ℕ, ⨅ _ : ↑k > n, LinearMap.ker (lcoeff R k)
/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/
def degreeLT (n : ℕ) : Submodule R R[X] :=
⨅ k : ℕ, ⨅ (_ : k ≥ n), LinearMap.ker (lcoeff R k)
variable {R}
theorem mem_degreeLE {n : WithBot ℕ} {f : R[X]} : f ∈ degreeLE R n ↔ degree f ≤ n := by
simp only [degreeLE, Submodule.mem_iInf, degree_le_iff_coeff_zero, LinearMap.mem_ker]; rfl
@[mono]
theorem degreeLE_mono {m n : WithBot ℕ} (H : m ≤ n) : degreeLE R m ≤ degreeLE R n := fun _ hf =>
mem_degreeLE.2 (le_trans (mem_degreeLE.1 hf) H)
theorem degreeLE_eq_span_X_pow [DecidableEq R] {n : ℕ} :
degreeLE R n = Submodule.span R ↑((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n) := by
apply le_antisymm
· intro p hp
replace hp := mem_degreeLE.1 hp
rw [← Polynomial.sum_monomial_eq p, Polynomial.sum]
refine Submodule.sum_mem _ fun k hk => ?_
have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk)
rw [← C_mul_X_pow_eq_monomial, C_mul']
refine
Submodule.smul_mem _ _
(Submodule.subset_span <|
Finset.mem_coe.2 <|
Finset.mem_image.2 ⟨_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl⟩)
rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff]
intro k hk
apply mem_degreeLE.2
exact
(degree_X_pow_le _).trans (WithBot.coe_le_coe.2 <| Nat.le_of_lt_succ <| Finset.mem_range.1 hk)
theorem mem_degreeLT {n : ℕ} {f : R[X]} : f ∈ degreeLT R n ↔ degree f < n := by
rw [degreeLT, Submodule.mem_iInf]
conv_lhs => intro i; rw [Submodule.mem_iInf]
rw [degree, Finset.max_eq_sup_coe]
rw [Finset.sup_lt_iff ?_]
rotate_left
· apply WithBot.bot_lt_coe
conv_rhs =>
simp only [mem_support_iff]
intro b
rw [Nat.cast_withBot, WithBot.coe_lt_coe, lt_iff_not_ge, Ne, not_imp_not]
rfl
@[mono]
theorem degreeLT_mono {m n : ℕ} (H : m ≤ n) : degreeLT R m ≤ degreeLT R n := fun _ hf =>
mem_degreeLT.2 (lt_of_lt_of_le (mem_degreeLT.1 hf) <| WithBot.coe_le_coe.2 H)
theorem degreeLT_eq_span_X_pow [DecidableEq R] {n : ℕ} :
degreeLT R n = Submodule.span R ↑((Finset.range n).image fun n => X ^ n : Finset R[X]) := by
apply le_antisymm
· intro p hp
replace hp := mem_degreeLT.1 hp
rw [← Polynomial.sum_monomial_eq p, Polynomial.sum]
refine Submodule.sum_mem _ fun k hk => ?_
have := WithBot.coe_lt_coe.1 ((Finset.sup_lt_iff <| WithBot.bot_lt_coe n).1 hp k hk)
rw [← C_mul_X_pow_eq_monomial, C_mul']
refine Submodule.smul_mem _ _ (Submodule.subset_span <| by grind)
rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff]
intro k hk
apply mem_degreeLT.2
exact lt_of_le_of_lt (degree_X_pow_le _) (WithBot.coe_lt_coe.2 <| Finset.mem_range.1 hk)
/-- The first `n` coefficients on `degreeLT n` form a linear equivalence with `Fin n → R`. -/
def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where
toFun p n := (↑p : R[X]).coeff n
invFun f :=
⟨∑ i : Fin n, monomial i (f i),
(degreeLT R n).sum_mem fun i _ =>
mem_degreeLT.mpr
(lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩
map_add' p q := by
ext
dsimp
rw [coeff_add]
map_smul' x p := by
ext
dsimp
rw [coeff_smul]
rfl
left_inv := by
rintro ⟨p, hp⟩
ext1
simp only
by_cases hp0 : p = 0
· subst hp0
simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero]
rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp
conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range]
right_inv f := by
ext i
simp only [finset_sum_coeff]
rw [Finset.sum_eq_single i, coeff_monomial, if_pos rfl]
· rintro j - hji
rw [coeff_monomial, if_neg]
rwa [← Fin.ext_iff]
· intro h
exact (h (Finset.mem_univ _)).elim
theorem degreeLTEquiv_eq_zero_iff_eq_zero {n : ℕ} {p : R[X]} (hp : p ∈ degreeLT R n) :
degreeLTEquiv _ _ ⟨p, hp⟩ = 0 ↔ p = 0 := by simp
theorem eval_eq_sum_degreeLTEquiv {n : ℕ} {p : R[X]} (hp : p ∈ degreeLT R n) (x : R) :
p.eval x = ∑ i, degreeLTEquiv _ _ ⟨p, hp⟩ i * x ^ (i : ℕ) := by
simp_rw [eval_eq_sum]
exact (sum_fin _ (by simp_rw [zero_mul, forall_const]) (mem_degreeLT.mp hp)).symm
theorem degreeLT_succ_eq_degreeLE {n : ℕ} : degreeLT R (n + 1) = degreeLE R n := by
ext x
by_cases x_zero : x = 0
· simp_rw [x_zero, Submodule.zero_mem]
· rw [mem_degreeLT, mem_degreeLE, ← natDegree_lt_iff_degree_lt (by rwa [ne_eq]),
← natDegree_le_iff_degree_le, Nat.lt_succ]
/-- The equivalence between monic polynomials of degree `n` and polynomials of degree less than
`n`, formed by adding a term `X ^ n`. -/
def monicEquivDegreeLT [Nontrivial R] (n : ℕ) :
{ p : R[X] // p.Monic ∧ p.natDegree = n } ≃ degreeLT R n where
toFun p := ⟨p.1.eraseLead, by
rcases p with ⟨p, hp, rfl⟩
simp only [mem_degreeLT]
refine lt_of_lt_of_le ?_ degree_le_natDegree
exact degree_eraseLead_lt (Polynomial.Monic.ne_zero_of_polynomial_ne hp one_ne_zero)⟩
invFun := fun p =>
⟨X^n + p.1, monic_X_pow_add (mem_degreeLT.1 p.2), by
rw [natDegree_add_eq_left_of_degree_lt]
· simp
· simp [mem_degreeLT.1 p.2]⟩
left_inv := by
rintro ⟨p, hp, rfl⟩
ext1
simp only
conv_rhs => rw [← eraseLead_add_C_mul_X_pow p]
simp [Monic.def.1 hp, add_comm]
right_inv := by
rintro ⟨p, hp⟩
ext1
simp only
rw [eraseLead_add_of_degree_lt_left]
· simp
· simp [mem_degreeLT.1 hp]
/-- For every polynomial `p` in the span of a set `s : Set R[X]`, there exists a polynomial of
`p' ∈ s` with higher degree. See also `Polynomial.exists_degree_le_of_mem_span_of_finite`. -/
theorem exists_degree_le_of_mem_span {s : Set R[X]} {p : R[X]}
(hs : s.Nonempty) (hp : p ∈ Submodule.span R s) :
∃ p' ∈ s, degree p ≤ degree p' := by
by_contra! h
by_cases hp_zero : p = 0
· rw [hp_zero, degree_zero] at h
rcases hs with ⟨x, hx⟩
exact not_lt_bot (h x hx)
· have : p ∈ degreeLT R (natDegree p) := by
refine (Submodule.span_le.mpr fun p' p'_mem => ?_) hp
rw [SetLike.mem_coe, mem_degreeLT, Nat.cast_withBot]
exact lt_of_lt_of_le (h p' p'_mem) degree_le_natDegree
rwa [mem_degreeLT, Nat.cast_withBot, degree_eq_natDegree hp_zero,
Nat.cast_withBot, lt_self_iff_false] at this
/-- A stronger version of `Polynomial.exists_degree_le_of_mem_span` under the assumption that the
set `s : R[X]` is finite. There exists a polynomial `p' ∈ s` whose degree dominates the degree of
every element of `p ∈ span R s`. -/
theorem exists_degree_le_of_mem_span_of_finite {s : Set R[X]} (s_fin : s.Finite) (hs : s.Nonempty) :
∃ p' ∈ s, ∀ (p : R[X]), p ∈ Submodule.span R s → degree p ≤ degree p' := by
obtain ⟨a, has, hmax⟩ := s_fin.exists_maximalFor degree s hs
refine ⟨a, has, fun p hp => ?_⟩
obtain ⟨p', hp', hpp'⟩ := exists_degree_le_of_mem_span hs hp
exact hpp'.trans <| not_lt.1 <| not_lt_iff_le_imp_ge.2 <| hmax hp'
/-- The span of every finite set of polynomials is contained in a `degreeLE n` for some `n`. -/
theorem span_le_degreeLE_of_finite {s : Set R[X]} (s_fin : s.Finite) :
∃ n : ℕ, Submodule.span R s ≤ degreeLE R n := by
by_cases s_emp : s.Nonempty
· rcases exists_degree_le_of_mem_span_of_finite s_fin s_emp with ⟨p', _, hp'max⟩
exact ⟨natDegree p', fun p hp => mem_degreeLE.mpr ((hp'max _ hp).trans degree_le_natDegree)⟩
· rw [Set.not_nonempty_iff_eq_empty] at s_emp
rw [s_emp, Submodule.span_empty]
exact ⟨0, bot_le⟩
/-- The span of every finite set of polynomials is contained in a `degreeLT n` for some `n`. -/
theorem span_of_finite_le_degreeLT {s : Set R[X]} (s_fin : s.Finite) :
∃ n : ℕ, Submodule.span R s ≤ degreeLT R n := by
rcases span_le_degreeLE_of_finite s_fin with ⟨n, _⟩
exact ⟨n + 1, by rwa [degreeLT_succ_eq_degreeLE]⟩
/-- If `R` is a nontrivial ring, the polynomials `R[X]` are not finite as an `R`-module. When `R` is
a field, this is equivalent to `R[X]` being an infinite-dimensional vector space over `R`. -/
theorem not_finite [Nontrivial R] : ¬ Module.Finite R R[X] := by
rw [Module.finite_def, Submodule.fg_def]
push_neg
intro s hs contra
rcases span_le_degreeLE_of_finite hs with ⟨n,hn⟩
have : ((X : R[X]) ^ (n + 1)) ∈ Polynomial.degreeLE R ↑n := by
rw [contra] at hn
exact hn Submodule.mem_top
rw [mem_degreeLE, degree_X_pow, Nat.cast_le, add_le_iff_nonpos_right, nonpos_iff_eq_zero] at this
exact one_ne_zero this
theorem geom_sum_X_comp_X_add_one_eq_sum (n : ℕ) :
(∑ i ∈ range n, (X : R[X]) ^ i).comp (X + 1) =
(Finset.range n).sum fun i : ℕ => (n.choose (i + 1) : R[X]) * X ^ i := by
ext i
trans (n.choose (i + 1) : R); swap
· simp only [finset_sum_coeff, ← C_eq_natCast, coeff_C_mul_X_pow]
rw [Finset.sum_eq_single i, if_pos rfl]
· simp +contextual only [@eq_comm _ i, if_false,
imp_true_iff]
· simp +contextual only [Nat.lt_add_one_iff, Nat.choose_eq_zero_of_lt,
Nat.cast_zero, Finset.mem_range, not_lt, if_true, imp_true_iff]
induction n generalizing i with
| zero => dsimp; simp only [zero_comp, coeff_zero, Nat.cast_zero]
| succ n ih =>
simp only [geom_sum_succ', ih, add_comp, X_pow_comp, coeff_add, Nat.choose_succ_succ,
Nat.cast_add, coeff_X_add_one_pow]
theorem Monic.geom_sum {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.natDegree) {n : ℕ} (hn : n ≠ 0) :
(∑ i ∈ range n, P ^ i).Monic := by
nontriviality R
obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn
rw [geom_sum_succ']
refine (hP.pow _).add_of_left ?_
refine lt_of_le_of_lt (degree_sum_le _ _) ?_
rw [Finset.sup_lt_iff]
· simp only [Finset.mem_range, degree_eq_natDegree (hP.pow _).ne_zero]
simp only [Nat.cast_lt, hP.natDegree_pow]
intro k
exact nsmul_lt_nsmul_left hdeg
· rw [bot_lt_iff_ne_bot, Ne, degree_eq_bot]
exact (hP.pow _).ne_zero
theorem Monic.geom_sum' {P : R[X]} (hP : P.Monic) (hdeg : 0 < P.degree) {n : ℕ} (hn : n ≠ 0) :
(∑ i ∈ range n, P ^ i).Monic :=
hP.geom_sum (natDegree_pos_iff_degree_pos.2 hdeg) hn
theorem monic_geom_sum_X {n : ℕ} (hn : n ≠ 0) : (∑ i ∈ range n, (X : R[X]) ^ i).Monic := by
nontriviality R
apply monic_X.geom_sum _ hn
simp only [natDegree_X, zero_lt_one]
end Semiring
section Ring
variable [Ring R]
/-- Given a polynomial, return the polynomial whose coefficients are in
the ring closure of the original coefficients. -/
def restriction (p : R[X]) : Polynomial (Subring.closure (↑p.coeffs : Set R)) :=
∑ i ∈ p.support,
monomial i
(⟨p.coeff i,
letI := Classical.decEq R
if H : p.coeff i = 0 then H.symm ▸ (Subring.closure _).zero_mem
else Subring.subset_closure (p.coeff_mem_coeffs H)⟩ :
Subring.closure (↑p.coeffs : Set R))
@[simp]
theorem coeff_restriction {p : R[X]} {n : ℕ} : ↑(coeff (restriction p) n) = coeff p n := by
classical
simp only [restriction, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
Ne, ite_not]
split_ifs with h
· rw [h]
rfl
· rfl
theorem coeff_restriction' {p : R[X]} {n : ℕ} : (coeff (restriction p) n).1 = coeff p n := by
simp
@[simp]
theorem support_restriction (p : R[X]) : support (restriction p) = support p := by
ext i
simp only [mem_support_iff, not_iff_not, Ne]
conv_rhs => rw [← coeff_restriction]
exact ⟨fun H => by rw [H, ZeroMemClass.coe_zero], fun H => Subtype.coe_injective H⟩
@[simp]
theorem map_restriction {R : Type u} [CommRing R] (p : R[X]) :
p.restriction.map (algebraMap _ _) = p :=
ext fun n => by rw [coeff_map, Algebra.algebraMap_ofSubring_apply, coeff_restriction]
@[simp]
theorem degree_restriction {p : R[X]} : (restriction p).degree = p.degree := by simp [degree]
@[simp]
theorem natDegree_restriction {p : R[X]} : (restriction p).natDegree = p.natDegree := by
simp [natDegree]
@[simp]
theorem monic_restriction {p : R[X]} : Monic (restriction p) ↔ Monic p := by
simp only [Monic, leadingCoeff, natDegree_restriction]
rw [← @coeff_restriction _ _ p]
exact ⟨fun H => by rw [H, OneMemClass.coe_one], fun H => Subtype.coe_injective H⟩
@[simp]
theorem restriction_zero : restriction (0 : R[X]) = 0 := by
simp only [restriction, Finset.sum_empty, support_zero]
@[simp]
theorem restriction_one : restriction (1 : R[X]) = 1 :=
ext fun i => Subtype.eq <| by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs <;> rfl
variable [Semiring S] {f : R →+* S} {x : S}
theorem eval₂_restriction {p : R[X]} :
eval₂ f x p =
eval₂ (f.comp (Subring.subtype (Subring.closure (p.coeffs : Set R)))) x p.restriction := by
simp only [eval₂_eq_sum, sum, support_restriction, ← @coeff_restriction _ _ p, RingHom.comp_apply,
Subring.coe_subtype]
section ToSubring
variable (p : R[X]) (T : Subring R)
/-- Given a polynomial `p` and a subring `T` that contains the coefficients of `p`,
return the corresponding polynomial whose coefficients are in `T`. -/
def toSubring (hp : (↑p.coeffs : Set R) ⊆ T) : T[X] :=
∑ i ∈ p.support,
monomial i
(⟨p.coeff i,
letI := Classical.decEq R
if H : p.coeff i = 0 then H.symm ▸ T.zero_mem else hp (p.coeff_mem_coeffs H)⟩ : T)
variable (hp : (↑p.coeffs : Set R) ⊆ T)
@[simp]
theorem coeff_toSubring {n : ℕ} : ↑(coeff (toSubring p T hp) n) = coeff p n := by
classical
simp only [toSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
Ne, ite_not]
split_ifs with h
· rw [h]
rfl
· rfl
theorem coeff_toSubring' {n : ℕ} : (coeff (toSubring p T hp) n).1 = coeff p n := by
simp
@[simp]
theorem support_toSubring : support (toSubring p T hp) = support p := by
ext i
simp only [mem_support_iff, not_iff_not, Ne]
conv_rhs => rw [← coeff_toSubring p T hp]
exact ⟨fun H => by rw [H, ZeroMemClass.coe_zero], fun H => Subtype.coe_injective H⟩
@[simp]
theorem degree_toSubring : (toSubring p T hp).degree = p.degree := by simp [degree]
@[simp]
theorem natDegree_toSubring : (toSubring p T hp).natDegree = p.natDegree := by simp [natDegree]
@[simp]
theorem monic_toSubring : Monic (toSubring p T hp) ↔ Monic p := by
simp_rw [Monic, leadingCoeff, natDegree_toSubring, ← coeff_toSubring p T hp]
exact ⟨fun H => by rw [H, OneMemClass.coe_one], fun H => Subtype.coe_injective H⟩
@[simp]
theorem toSubring_zero : toSubring (0 : R[X]) T (by simp [coeffs]) = 0 := by
ext i
simp
@[simp]
theorem toSubring_one :
toSubring (1 : R[X]) T
(Set.Subset.trans coeffs_one <| Finset.singleton_subset_set_iff.2 T.one_mem) =
1 :=
ext fun i => Subtype.eq <| by
rw [coeff_toSubring', coeff_one, coeff_one, apply_ite Subtype.val, ZeroMemClass.coe_zero,
OneMemClass.coe_one]
@[simp]
theorem map_toSubring : (p.toSubring T hp).map (Subring.subtype T) = p := by
ext n
simp [coeff_map]
end ToSubring
variable (T : Subring R)
/-- Given a polynomial whose coefficients are in some subring, return
the corresponding polynomial whose coefficients are in the ambient ring. -/
def ofSubring (p : T[X]) : R[X] :=
∑ i ∈ p.support, monomial i (p.coeff i : R)
theorem coeff_ofSubring (p : T[X]) (n : ℕ) : coeff (ofSubring T p) n = (coeff p n : T) := by
simp only [ofSubring, coeff_monomial, finset_sum_coeff, mem_support_iff, Finset.sum_ite_eq',
Ne, Classical.not_not, ite_eq_left_iff]
intro h
rw [h, ZeroMemClass.coe_zero]
@[simp]
theorem coeffs_ofSubring {p : T[X]} : (↑(p.ofSubring T).coeffs : Set R) ⊆ T := by
classical
intro i hi
simp only [coeffs, Set.mem_image, mem_support_iff, Ne, Finset.mem_coe,
(Finset.coe_image)] at hi
rcases hi with ⟨n, _, h'n⟩
rw [← h'n, coeff_ofSubring]
exact Subtype.mem (coeff p n : T)
end Ring
end Polynomial
namespace Ideal
open Polynomial
section Semiring
variable [Semiring R]
/-- Transport an ideal of `R[X]` to an `R`-submodule of `R[X]`. -/
def ofPolynomial (I : Ideal R[X]) : Submodule R R[X] where
carrier := I.carrier
zero_mem' := I.zero_mem
add_mem' := I.add_mem
smul_mem' c x H := by
rw [← C_mul']
exact I.mul_mem_left _ H
variable {I : Ideal R[X]}
theorem mem_ofPolynomial (x) : x ∈ I.ofPolynomial ↔ x ∈ I :=
Iff.rfl
variable (I)
/-- Given an ideal `I` of `R[X]`, make the `R`-submodule of `I`
consisting of polynomials of degree ≤ `n`. -/
def degreeLE (n : WithBot ℕ) : Submodule R R[X] :=
Polynomial.degreeLE R n ⊓ I.ofPolynomial
/-- Given an ideal `I` of `R[X]`, make the ideal in `R` of
leading coefficients of polynomials in `I` with degree ≤ `n`. -/
def leadingCoeffNth (n : ℕ) : Ideal R :=
(I.degreeLE n).map <| lcoeff R n
/-- Given an ideal `I` in `R[X]`, make the ideal in `R` of the
leading coefficients in `I`. -/
def leadingCoeff : Ideal R :=
⨆ n : ℕ, I.leadingCoeffNth n
end Semiring
section CommSemiring
variable [CommSemiring R] [Semiring S]
/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself -/
theorem polynomial_mem_ideal_of_coeff_mem_ideal (I : Ideal R[X]) (p : R[X])
(hp : ∀ n : ℕ, p.coeff n ∈ I.comap (C : R →+* R[X])) : p ∈ I :=
sum_C_mul_X_pow_eq p ▸ Submodule.sum_mem I fun n _ => I.mul_mem_right _ (hp n)
/-- The push-forward of an ideal `I` of `R` to `R[X]` via inclusion
is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : R[X]} :
f ∈ (Ideal.map (C : R →+* R[X]) I : Ideal R[X]) ↔ ∀ n : ℕ, f.coeff n ∈ I := by
constructor
· intro hf
refine Submodule.span_induction ?_ ?_ ?_ ?_ hf
· intro f hf n
obtain ⟨x, hx⟩ := (Set.mem_image _ _ _).mp hf
rw [← hx.right, coeff_C]
by_cases h : n = 0
· simpa [h] using hx.left
· simp [h]
· simp
· exact fun f g _ _ hf hg n => by simp [I.add_mem (hf n) (hg n)]
· refine fun f g _ hg n => ?_
rw [smul_eq_mul, coeff_mul]
exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
· intro hf
rw [← sum_monomial_eq f]
refine (I.map C : Ideal R[X]).sum_mem fun n _ => ?_
simp only [← C_mul_X_pow_eq_monomial]
rw [mul_comm]
exact (I.map C : Ideal R[X]).mul_mem_left _ (mem_map_of_mem _ (hf n))
theorem _root_.Polynomial.ker_mapRingHom (f : R →+* S) :
RingHom.ker (Polynomial.mapRingHom f) = (RingHom.ker f).map (C : R →+* R[X]) := by
ext
simp only [RingHom.mem_ker, coe_mapRingHom]
rw [mem_map_C_iff, Polynomial.ext_iff]
simp [RingHom.mem_ker]
variable (I : Ideal R[X])
theorem mem_leadingCoeffNth (n : ℕ) (x) :
x ∈ I.leadingCoeffNth n ↔ ∃ p ∈ I, degree p ≤ n ∧ p.leadingCoeff = x := by
simp only [leadingCoeffNth, degreeLE, Submodule.mem_map, lcoeff_apply, Submodule.mem_inf,
mem_degreeLE]
constructor
· rintro ⟨p, ⟨hpdeg, hpI⟩, rfl⟩
rcases lt_or_eq_of_le hpdeg with hpdeg | hpdeg
· refine ⟨0, I.zero_mem, bot_le, ?_⟩
rw [leadingCoeff_zero, eq_comm]
exact coeff_eq_zero_of_degree_lt hpdeg
· refine ⟨p, hpI, le_of_eq hpdeg, ?_⟩
rw [Polynomial.leadingCoeff, natDegree, hpdeg, Nat.cast_withBot, WithBot.unbotD_coe]
· rintro ⟨p, hpI, hpdeg, rfl⟩
have : natDegree p + (n - natDegree p) = n :=
add_tsub_cancel_of_le (natDegree_le_of_degree_le hpdeg)
refine ⟨p * X ^ (n - natDegree p), ⟨?_, I.mul_mem_right _ hpI⟩, ?_⟩
· apply le_trans (degree_mul_le _ _) _
apply le_trans (add_le_add degree_le_natDegree (degree_X_pow_le _)) _
rw [← Nat.cast_add, this]
· rw [Polynomial.leadingCoeff, ← coeff_mul_X_pow p (n - natDegree p), this]
theorem mem_leadingCoeffNth_zero (x) : x ∈ I.leadingCoeffNth 0 ↔ C x ∈ I :=
(mem_leadingCoeffNth _ _ _).trans
⟨fun ⟨p, hpI, hpdeg, hpx⟩ => by
rwa [← hpx, Polynomial.leadingCoeff,
Nat.eq_zero_of_le_zero (natDegree_le_of_degree_le hpdeg), ← eq_C_of_degree_le_zero hpdeg],
fun hx => ⟨C x, hx, degree_C_le, leadingCoeff_C x⟩⟩
theorem leadingCoeffNth_mono {m n : ℕ} (H : m ≤ n) : I.leadingCoeffNth m ≤ I.leadingCoeffNth n := by
intro r hr
simp only [mem_leadingCoeffNth] at hr ⊢
rcases hr with ⟨p, hpI, hpdeg, rfl⟩
refine ⟨p * X ^ (n - m), I.mul_mem_right _ hpI, ?_, leadingCoeff_mul_X_pow⟩
refine le_trans (degree_mul_le _ _) ?_
grw [hpdeg, degree_X_pow_le]
rw [← Nat.cast_add, add_tsub_cancel_of_le H]
theorem mem_leadingCoeff (x) : x ∈ I.leadingCoeff ↔ ∃ p ∈ I, Polynomial.leadingCoeff p = x := by
rw [leadingCoeff, Submodule.mem_iSup_of_directed]
· simp only [mem_leadingCoeffNth]
constructor
· rintro ⟨i, p, hpI, _, rfl⟩
exact ⟨p, hpI, rfl⟩
rintro ⟨p, hpI, rfl⟩
exact ⟨natDegree p, p, hpI, degree_le_natDegree, rfl⟩
intro i j
exact
⟨i + j, I.leadingCoeffNth_mono (Nat.le_add_right _ _),
I.leadingCoeffNth_mono (Nat.le_add_left _ _)⟩
/-- If `I` is an ideal, and `pᵢ` is a finite family of polynomials each satisfying
`∀ k, (pᵢ)ₖ ∈ Iⁿⁱ⁻ᵏ` for some `nᵢ`, then `p = ∏ pᵢ` also satisfies `∀ k, pₖ ∈ Iⁿ⁻ᵏ` with `n = ∑ nᵢ`.
-/
theorem _root_.Polynomial.coeff_prod_mem_ideal_pow_tsub {ι : Type*} (s : Finset ι) (f : ι → R[X])
(I : Ideal R) (n : ι → ℕ) (h : ∀ i ∈ s, ∀ (k), (f i).coeff k ∈ I ^ (n i - k)) (k : ℕ) :
(s.prod f).coeff k ∈ I ^ (s.sum n - k) := by
classical
induction s using Finset.induction generalizing k with
| empty =>
rw [sum_empty, prod_empty, coeff_one, zero_tsub, pow_zero, Ideal.one_eq_top]
exact Submodule.mem_top
| insert a s ha hs =>
rw [sum_insert ha, prod_insert ha, coeff_mul]
apply sum_mem
rintro ⟨i, j⟩ e
obtain rfl : i + j = k := mem_antidiagonal.mp e
apply Ideal.pow_le_pow_right add_tsub_add_le_tsub_add_tsub
rw [pow_add]
exact Ideal.mul_mem_mul (by grind) (by grind)
end CommSemiring
section Ring
variable [Ring R]
/-- `R[X]` is never a field for any ring `R`. -/
theorem polynomial_not_isField : ¬IsField R[X] := by
nontriviality R
intro hR
obtain ⟨p, hp⟩ := hR.mul_inv_cancel X_ne_zero
have hp0 : p ≠ 0 := right_ne_zero_of_mul_eq_one hp
have := degree_lt_degree_mul_X hp0
rw [← X_mul, congr_arg degree hp, degree_one, Nat.WithBot.lt_zero_iff, degree_eq_bot] at this
exact hp0 this
/-- The only constant in a maximal ideal over a field is `0`. -/
theorem eq_zero_of_constant_mem_of_maximal (hR : IsField R) (I : Ideal R[X]) [hI : I.IsMaximal]
(x : R) (hx : C x ∈ I) : x = 0 := by
refine Classical.by_contradiction fun hx0 => hI.ne_top ((eq_top_iff_one I).2 ?_)
obtain ⟨y, hy⟩ := hR.mul_inv_cancel hx0
convert I.mul_mem_left (C y) hx
rw [← C.map_mul, hR.mul_comm y x, hy, RingHom.map_one]
end Ring
section CommRing
variable [CommRing R]
/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/
theorem isPrime_map_C_iff_isPrime (P : Ideal R) :
IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) ↔ IsPrime P := by
-- Note: the following proof avoids quotient rings
-- It can be golfed substantially by using something like
-- `(Quotient.isDomain_iff_prime (map C P : Ideal R[X]))`
constructor
· intro H
have := comap_isPrime C (map C P)
convert this using 1
ext x
simp only [mem_comap, mem_map_C_iff]
constructor
· rintro h (- | n)
· rwa [coeff_C_zero]
· simp only [coeff_C_ne_zero (Nat.succ_ne_zero _), Submodule.zero_mem]
· intro h
simpa only [coeff_C_zero] using h 0
· intro h
constructor
· rw [Ne, eq_top_iff_one, mem_map_C_iff, not_forall]
use 0
rw [coeff_one_zero, ← eq_top_iff_one]
exact h.1
· intro f g
simp only [mem_map_C_iff]
contrapose!
rintro ⟨hf, hg⟩
classical
let m := Nat.find hf
let n := Nat.find hg
refine ⟨m + n, ?_⟩
rw [coeff_mul, ← Finset.insert_erase ((Finset.mem_antidiagonal (a := (m,n))).mpr rfl),
Finset.sum_insert (Finset.notMem_erase _ _), (P.add_mem_iff_left _).not]
· apply mt h.2
rw [not_or]
exact ⟨Nat.find_spec hf, Nat.find_spec hg⟩
apply P.sum_mem
rintro ⟨i, j⟩ hij
rw [Finset.mem_erase, Finset.mem_antidiagonal] at hij
simp only [Ne, Prod.mk_inj, not_and_or] at hij
obtain hi | hj : i < m ∨ j < n := by
cutsat
· rw [mul_comm]
apply P.mul_mem_left
exact Classical.not_not.1 (Nat.find_min hf hi)
· apply P.mul_mem_left
exact Classical.not_not.1 (Nat.find_min hg hj)
/-- If `P` is a prime ideal of `R`, then `P.R[x]` is a prime ideal of `R[x]`. -/
theorem isPrime_map_C_of_isPrime {P : Ideal R} (H : IsPrime P) :
IsPrime (map (C : R →+* R[X]) P : Ideal R[X]) :=
(isPrime_map_C_iff_isPrime P).mpr H
theorem is_fg_degreeLE [IsNoetherianRing R] (I : Ideal R[X]) (n : ℕ) :
Submodule.FG (I.degreeLE n) :=
letI := Classical.decEq R
isNoetherian_submodule_left.1
(isNoetherian_of_fg_of_noetherian _ ⟨_, degreeLE_eq_span_X_pow.symm⟩) _
end CommRing
end Ideal
section Ideal
open Submodule Set
variable [Semiring R] {f : R[X]} {I : Ideal R[X]}
/-- If the coefficients of a polynomial belong to an ideal, then that ideal contains
the ideal spanned by the coefficients of the polynomial. -/
theorem span_le_of_C_coeff_mem (cf : ∀ i : ℕ, C (f.coeff i) ∈ I) :
Ideal.span { g | ∃ i, g = C (f.coeff i) } ≤ I := by
simp only [@eq_comm _ _ (C _)]
exact (Ideal.span_le.trans range_subset_iff).mpr cf
theorem mem_span_C_coeff : f ∈ Ideal.span { g : R[X] | ∃ i : ℕ, g = C (coeff f i) } := by
let p := Ideal.span { g : R[X] | ∃ i : ℕ, g = C (coeff f i) }
nth_rw 2 [(sum_C_mul_X_pow_eq f).symm]
refine Submodule.sum_mem _ fun n _hn => ?_
dsimp
have : C (coeff f n) ∈ p := by
apply subset_span
rw [mem_setOf_eq]
use n
have : monomial n (1 : R) • C (coeff f n) ∈ p := p.smul_mem _ this
convert this using 1
simp only [monomial_mul_C, one_mul, smul_eq_mul]
rw [← C_mul_X_pow_eq_monomial]
theorem exists_C_coeff_notMem : f ∉ I → ∃ i : ℕ, C (coeff f i) ∉ I :=
Not.imp_symm fun cf => span_le_of_C_coeff_mem (not_exists_not.mp cf) mem_span_C_coeff
@[deprecated (since := "2025-05-23")] alias exists_C_coeff_not_mem := exists_C_coeff_notMem
end Ideal
variable {σ : Type v} {M : Type w}
variable [CommRing R] [CommRing S] [AddCommGroup M] [Module R M]
section Prime
variable (σ) {r : R}
namespace Polynomial
theorem prime_C_iff : Prime (C r) ↔ Prime r :=
⟨comap_prime C (evalRingHom (0 : R)) fun _ => eval_C, fun hr => by
have := hr.1
rw [← Ideal.span_singleton_prime] at hr ⊢
· rw [← Set.image_singleton, ← Ideal.map_span]
apply Ideal.isPrime_map_C_of_isPrime hr
· intro h; apply (this (C_eq_zero.mp h))
· assumption⟩
end Polynomial
namespace MvPolynomial
instance {ι R : Type*} [CommSemiring R] [IsEmpty ι] : Module.Finite R (MvPolynomial ι R) :=
Module.Finite.equiv (MvPolynomial.isEmptyAlgEquiv R ι).toLinearEquiv.symm
private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommRing R] [Fintype σ] :
Prime (C r : MvPolynomial σ R) ↔ Prime r := by
rw [← MulEquiv.prime_iff (renameEquiv R (Fintype.equivFin σ))]
convert_to Prime (C r) ↔ _
· congr!
simp only [renameEquiv_apply, algHom_C, algebraMap_eq]
· induction Fintype.card σ with
| zero => exact MulEquiv.prime_iff (isEmptyAlgEquiv R (Fin 0)).symm (p := r)
| succ d hd =>
convert MulEquiv.prime_iff (finSuccEquiv R d).symm (p := Polynomial.C (C r))
· simp [← finSuccEquiv_comp_C_eq_C]
· simp [← hd, Polynomial.prime_C_iff]
theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r :=
⟨comap_prime C constantCoeff (constantCoeff_C _), fun hr =>
⟨fun h => hr.1 <| by
rw [← C_inj, h]
simp,
fun h =>
hr.2.1 <| by
rw [← constantCoeff_C _ r]
exact h.map _,
fun a b hd => by
obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b
rw [← algebraMap_eq] at hd
have : algebraMap R _ r ∣ a' * b' := by
convert _root_.map_dvd (killCompl Subtype.val_injective) hd
· simp
· simp
rw [← rename_C ((↑) : s → σ)]
let f := (rename (R := R) ((↑) : s → σ)).toRingHom
exact (((prime_C_iff_of_fintype s).2 hr).2.2 a' b' this).imp (map_dvd f) (map_dvd f)⟩⟩
variable {σ}
theorem prime_rename_iff (s : Set σ) {p : MvPolynomial s R} :
Prime (rename ((↑) : s → σ) p) ↔ Prime (p : MvPolynomial s R) := by
classical
symm
let eqv :=
(sumAlgEquiv R (↥sᶜ) s).symm.trans
(renameEquiv R <| (Equiv.sumComm (↥sᶜ) s).trans <| Equiv.Set.sumCompl s)
have : (rename (↑)).toRingHom = eqv.toAlgHom.toRingHom.comp C := by
apply ringHom_ext
· intro
simp only [eqv, AlgHom.toRingHom_eq_coe, RingHom.coe_coe, rename_C,
AlgEquiv.toAlgHom_eq_coe, AlgEquiv.toAlgHom_toRingHom, RingHom.coe_comp,
AlgEquiv.coe_trans, Function.comp_apply, MvPolynomial.sumAlgEquiv_symm_apply,
iterToSum_C_C, renameEquiv_apply, Equiv.coe_trans, Equiv.sumComm_apply]
· intro
simp only [eqv, AlgHom.toRingHom_eq_coe, RingHom.coe_coe, rename_X,
AlgEquiv.toAlgHom_eq_coe, AlgEquiv.toAlgHom_toRingHom, RingHom.coe_comp,
AlgEquiv.coe_trans, Function.comp_apply, MvPolynomial.sumAlgEquiv_symm_apply,
iterToSum_C_X, renameEquiv_apply, Equiv.coe_trans, Equiv.sumComm_apply, Sum.swap_inr,
Equiv.Set.sumCompl_apply_inl]
apply_fun (· p) at this
simp only [AlgHom.toRingHom_eq_coe, RingHom.coe_coe, AlgEquiv.toAlgHom_eq_coe,
AlgEquiv.toAlgHom_toRingHom, RingHom.coe_comp, Function.comp_apply] at this
rw [this, MulEquiv.prime_iff, prime_C_iff]
end MvPolynomial
end Prime
/-- **Hilbert basis theorem**: a polynomial ring over a Noetherian ring is a Noetherian ring. -/
protected theorem Polynomial.isNoetherianRing [inst : IsNoetherianRing R] : IsNoetherianRing R[X] :=
isNoetherianRing_iff.2
⟨fun I : Ideal R[X] =>
let M := inst.wf.min (Set.range I.leadingCoeffNth) ⟨_, ⟨0, rfl⟩⟩
have hm : M ∈ Set.range I.leadingCoeffNth := WellFounded.min_mem _ _ _
let ⟨N, HN⟩ := hm
let ⟨s, hs⟩ := I.is_fg_degreeLE N
have hm2 : ∀ k, I.leadingCoeffNth k ≤ M := fun k =>
Or.casesOn (le_or_gt k N) (fun h => HN ▸ I.leadingCoeffNth_mono h) fun h _ hx =>
Classical.by_contradiction fun hxm =>
haveI : IsNoetherian R R := inst
have : ¬M < I.leadingCoeffNth k := by
refine WellFounded.not_lt_min inst.wf _ _ ?_; exact ⟨k, rfl⟩
this ⟨HN ▸ I.leadingCoeffNth_mono (le_of_lt h), fun H => hxm (H hx)⟩
have hs2 : ∀ {x}, x ∈ I.degreeLE N → x ∈ Ideal.span (↑s : Set R[X]) :=
hs ▸ fun hx =>
Submodule.span_induction (hx := hx) (fun _ hx => Ideal.subset_span hx) (Ideal.zero_mem _)
(fun _ _ _ _ => Ideal.add_mem _) fun c f _ hf => f.C_mul' c ▸ Ideal.mul_mem_left _ _ hf
⟨s, le_antisymm (Ideal.span_le.2 fun x hx =>
have : x ∈ I.degreeLE N := hs ▸ Submodule.subset_span hx
this.2) <| by
have : Submodule.span R[X] ↑s = Ideal.span ↑s := rfl
rw [this]
intro p hp
generalize hn : p.natDegree = k
induction k using Nat.strong_induction_on generalizing p with | _ k ih
rcases le_or_gt k N with h | h
· subst k
refine hs2 ⟨Polynomial.mem_degreeLE.2
(le_trans Polynomial.degree_le_natDegree <| WithBot.coe_le_coe.2 h), hp⟩
· have hp0 : p ≠ 0 := by
rintro rfl
cases hn
exact Nat.not_lt_zero _ h
have : (0 : R) ≠ 1 := by
intro h
apply hp0
ext i
refine (mul_one _).symm.trans ?_
rw [← h, mul_zero]
rfl
haveI : Nontrivial R := ⟨⟨0, 1, this⟩⟩
have : p.leadingCoeff ∈ I.leadingCoeffNth N := by
rw [HN]
exact hm2 k ((I.mem_leadingCoeffNth _ _).2
⟨_, hp, hn ▸ Polynomial.degree_le_natDegree, rfl⟩)
rw [I.mem_leadingCoeffNth] at this
rcases this with ⟨q, hq, hdq, hlqp⟩
have hq0 : q ≠ 0 := by
intro H
rw [← Polynomial.leadingCoeff_eq_zero] at H
rw [hlqp, Polynomial.leadingCoeff_eq_zero] at H
exact hp0 H
have h1 : p.degree = (q * Polynomial.X ^ (k - q.natDegree)).degree := by
rw [Polynomial.degree_mul', Polynomial.degree_X_pow]
· rw [Polynomial.degree_eq_natDegree hp0, Polynomial.degree_eq_natDegree hq0]
rw [← Nat.cast_add, add_tsub_cancel_of_le, hn]
· refine le_trans (Polynomial.natDegree_le_of_degree_le hdq) (le_of_lt h)
rw [Polynomial.leadingCoeff_X_pow, mul_one]
exact mt Polynomial.leadingCoeff_eq_zero.1 hq0
have h2 : p.leadingCoeff = (q * Polynomial.X ^ (k - q.natDegree)).leadingCoeff := by
rw [← hlqp, Polynomial.leadingCoeff_mul_X_pow]
have := Polynomial.degree_sub_lt h1 hp0 h2
rw [Polynomial.degree_eq_natDegree hp0] at this
rw [← sub_add_cancel p (q * Polynomial.X ^ (k - q.natDegree))]
convert (Ideal.span ↑s).add_mem _ ((Ideal.span (s : Set R[X])).mul_mem_right _ _)
· by_cases hpq : p - q * Polynomial.X ^ (k - q.natDegree) = 0
· rw [hpq]
exact Ideal.zero_mem _
refine ih _ ?_ (I.sub_mem hp (I.mul_mem_right _ hq)) rfl
rwa [Polynomial.degree_eq_natDegree hpq, Nat.cast_lt, hn] at this
exact hs2 ⟨Polynomial.mem_degreeLE.2 hdq, hq⟩⟩⟩
attribute [instance] Polynomial.isNoetherianRing
namespace Polynomial
theorem linearIndependent_powers_iff_aeval (f : M →ₗ[R] M) (v : M) :
(LinearIndependent R fun n : ℕ => (f ^ n) v) ↔ ∀ p : R[X], aeval f p v = 0 → p = 0 := by
rw [linearIndependent_iff]
simp only [Finsupp.linearCombination_apply, aeval_endomorphism, forall_iff_forall_finsupp,
ofFinsupp_eq_zero]
exact Iff.rfl
theorem disjoint_ker_aeval_of_isCoprime (f : M →ₗ[R] M) {p q : R[X]} (hpq : IsCoprime p q) :
Disjoint (LinearMap.ker (aeval f p)) (LinearMap.ker (aeval f q)) := by
rw [disjoint_iff_inf_le]
intro v hv
rcases hpq with ⟨p', q', hpq'⟩
simpa [LinearMap.mem_ker.1 (Submodule.mem_inf.1 hv).1,
LinearMap.mem_ker.1 (Submodule.mem_inf.1 hv).2] using
congr_arg (fun p : R[X] => aeval f p v) hpq'.symm
theorem sup_aeval_range_eq_top_of_isCoprime (f : M →ₗ[R] M) {p q : R[X]} (hpq : IsCoprime p q) :
LinearMap.range (aeval f p) ⊔ LinearMap.range (aeval f q) = ⊤ := by
rw [eq_top_iff]
intro v _
rw [Submodule.mem_sup]
rcases hpq with ⟨p', q', hpq'⟩
use aeval f (p * p') v
use LinearMap.mem_range.2 ⟨aeval f p' v, by simp only [Module.End.mul_apply, aeval_mul]⟩
use aeval f (q * q') v
use LinearMap.mem_range.2 ⟨aeval f q' v, by simp only [Module.End.mul_apply, aeval_mul]⟩
simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add] using
congr_arg (fun p : R[X] => aeval f p v) hpq'
theorem sup_ker_aeval_le_ker_aeval_mul {f : M →ₗ[R] M} {p q : R[X]} :
LinearMap.ker (aeval f p) ⊔ LinearMap.ker (aeval f q) ≤ LinearMap.ker (aeval f (p * q)) := by
intro v hv
rcases Submodule.mem_sup.1 hv with ⟨x, hx, y, hy, hxy⟩
have h_eval_x : aeval f (p * q) x = 0 := by
rw [mul_comm, aeval_mul, Module.End.mul_apply, LinearMap.mem_ker.1 hx, LinearMap.map_zero]
have h_eval_y : aeval f (p * q) y = 0 := by
rw [aeval_mul, Module.End.mul_apply, LinearMap.mem_ker.1 hy, LinearMap.map_zero]
rw [LinearMap.mem_ker, ← hxy, LinearMap.map_add, h_eval_x, h_eval_y, add_zero]
theorem sup_ker_aeval_eq_ker_aeval_mul_of_coprime (f : M →ₗ[R] M) {p q : R[X]}
(hpq : IsCoprime p q) :
LinearMap.ker (aeval f p) ⊔ LinearMap.ker (aeval f q) = LinearMap.ker (aeval f (p * q)) := by
apply le_antisymm sup_ker_aeval_le_ker_aeval_mul
intro v hv
rw [Submodule.mem_sup]
rcases hpq with ⟨p', q', hpq'⟩
have h_eval₂_qpp' :=
calc
aeval f (q * (p * p')) v = aeval f (p' * (p * q)) v := by
rw [mul_comm, mul_assoc, mul_comm, mul_assoc, mul_comm q p]
_ = 0 := by rw [aeval_mul, Module.End.mul_apply, LinearMap.mem_ker.1 hv, LinearMap.map_zero]
have h_eval₂_pqq' :=
calc
aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v := by rw [← mul_assoc, mul_comm]
_ = 0 := by rw [aeval_mul, Module.End.mul_apply, LinearMap.mem_ker.1 hv, LinearMap.map_zero]
rw [aeval_mul] at h_eval₂_qpp' h_eval₂_pqq'
refine
⟨aeval f (q * q') v, LinearMap.mem_ker.1 h_eval₂_pqq', aeval f (p * p') v,
LinearMap.mem_ker.1 h_eval₂_qpp', ?_⟩
rw [add_comm, mul_comm p p', mul_comm q q']
simpa only [map_add, map_mul, aeval_one] using congr_arg (fun p : R[X] => aeval f p v) hpq'
end Polynomial
namespace MvPolynomial
lemma aeval_natDegree_le {R : Type*} [CommSemiring R] {m n : ℕ}
(F : MvPolynomial σ R) (hF : F.totalDegree ≤ m)
(f : σ → Polynomial R) (hf : ∀ i, (f i).natDegree ≤ n) :
(MvPolynomial.aeval f F).natDegree ≤ m * n := by
rw [MvPolynomial.aeval_def, MvPolynomial.eval₂]
apply (Polynomial.natDegree_sum_le _ _).trans
apply Finset.sup_le
intro d hd
simp_rw [Function.comp_apply, ← C_eq_algebraMap]
apply (Polynomial.natDegree_C_mul_le _ _).trans
apply (Polynomial.natDegree_prod_le _ _).trans
have : ∑ i ∈ d.support, (d i) * n ≤ m * n := by
rw [← Finset.sum_mul]
apply mul_le_mul' (.trans _ hF) le_rfl
rw [MvPolynomial.totalDegree]
exact Finset.le_sup_of_le hd le_rfl
apply (Finset.sum_le_sum _).trans this
rintro i -
apply Polynomial.natDegree_pow_le.trans
exact mul_le_mul' le_rfl (hf i)
theorem isNoetherianRing_fin_0 [IsNoetherianRing R] :
IsNoetherianRing (MvPolynomial (Fin 0) R) := by
apply isNoetherianRing_of_ringEquiv R
symm; apply MvPolynomial.isEmptyRingEquiv R (Fin 0)
theorem isNoetherianRing_fin [IsNoetherianRing R] :
∀ {n : ℕ}, IsNoetherianRing (MvPolynomial (Fin n) R)
| 0 => isNoetherianRing_fin_0
| n + 1 =>
@isNoetherianRing_of_ringEquiv (Polynomial (MvPolynomial (Fin n) R)) _ _ _
(MvPolynomial.finSuccEquiv _ n).toRingEquiv.symm
(@Polynomial.isNoetherianRing (MvPolynomial (Fin n) R) _ isNoetherianRing_fin)
/-- The multivariate polynomial ring in finitely many variables over a Noetherian ring
is itself a Noetherian ring. -/
instance isNoetherianRing [Finite σ] [IsNoetherianRing R] :
IsNoetherianRing (MvPolynomial σ R) := by
cases nonempty_fintype σ
exact
@isNoetherianRing_of_ringEquiv (MvPolynomial (Fin (Fintype.card σ)) R) _ _ _
(renameEquiv R (Fintype.equivFin σ).symm).toRingEquiv isNoetherianRing_fin
/-- Auxiliary lemma:
Multivariate polynomials over an integral domain
with variables indexed by `Fin n` form an integral domain.
This fact is proven inductively,
and then used to prove the general case without any finiteness hypotheses.
See `MvPolynomial.noZeroDivisors` for the general case. -/
@[deprecated "MvPolynomial.noZeroDivisors" (since := "2025-07-18")]
theorem noZeroDivisors_fin (R : Type u) [CommSemiring R] [NoZeroDivisors R] :
∀ n : ℕ, NoZeroDivisors (MvPolynomial (Fin n) R) := fun _ ↦ inferInstance
/-- Auxiliary lemma:
Multivariate polynomials in finitely many variables over an integral domain form an integral domain.
This fact is proven by transport of structure from the `MvPolynomial.noZeroDivisors_fin`,
and then used to prove the general case without finiteness hypotheses.
See `MvPolynomial.noZeroDivisors` for the general case. -/
@[deprecated "MvPolynomial.noZeroDivisors" (since := "2025-07-18")]
theorem noZeroDivisors_of_finite (R : Type u) (σ : Type v) [CommSemiring R]
[NoZeroDivisors R] : NoZeroDivisors (MvPolynomial σ R) := inferInstance
theorem map_mvPolynomial_eq_eval₂ {S : Type*} [CommSemiring S] [Finite σ]
(ϕ : MvPolynomial σ R →+* S) (p : MvPolynomial σ R) :
ϕ p = MvPolynomial.eval₂ (ϕ.comp MvPolynomial.C) (fun s => ϕ (MvPolynomial.X s)) p := by
cases nonempty_fintype σ
refine Trans.trans (congr_arg ϕ (MvPolynomial.as_sum p)) ?_
rw [MvPolynomial.eval₂_eq', map_sum ϕ]
congr
ext
simp only [monomial_eq, ϕ.map_pow, map_prod ϕ, ϕ.comp_apply, ϕ.map_mul, Finsupp.prod_pow]
/-- If every coefficient of a polynomial is in an ideal `I`, then so is the polynomial itself,
multivariate version. -/
theorem mem_ideal_of_coeff_mem_ideal (I : Ideal (MvPolynomial σ R)) (p : MvPolynomial σ R)
(hcoe : ∀ m : σ →₀ ℕ, p.coeff m ∈ I.comap (C : R →+* MvPolynomial σ R)) : p ∈ I := by
rw [as_sum p]
suffices ∀ m ∈ p.support, monomial m (MvPolynomial.coeff m p) ∈ I by
exact Submodule.sum_mem I this
intro m _
rw [← mul_one (coeff m p), ← C_mul_monomial]
suffices C (coeff m p) ∈ I by exact I.mul_mem_right (monomial m 1) this
simpa [Ideal.mem_comap] using hcoe m
/-- The push-forward of an ideal `I` of `R` to `MvPolynomial σ R` via inclusion
is exactly the set of polynomials whose coefficients are in `I` -/
theorem mem_map_C_iff {I : Ideal R} {f : MvPolynomial σ R} :
f ∈ (Ideal.map (C : R →+* MvPolynomial σ R) I : Ideal (MvPolynomial σ R)) ↔
∀ m : σ →₀ ℕ, f.coeff m ∈ I := by
classical
constructor
· intro hf
refine Submodule.span_induction ?_ ?_ ?_ ?_ hf
· intro f hf n
obtain ⟨x, hx⟩ := (Set.mem_image _ _ _).mp hf
rw [← hx.right, coeff_C]
by_cases h : n = 0
· simpa [h] using hx.left
· simp [Ne.symm h]
· simp
· exact fun f g _ _ hf hg n => by simp [I.add_mem (hf n) (hg n)]
· refine fun f g _ hg n => ?_
rw [smul_eq_mul, coeff_mul]
exact I.sum_mem fun c _ => I.mul_mem_left (f.coeff c.fst) (hg c.snd)
· intro hf
rw [as_sum f]
suffices ∀ m ∈ f.support, monomial m (coeff m f) ∈ (Ideal.map C I : Ideal (MvPolynomial σ R)) by
exact Submodule.sum_mem _ this
intro m _
rw [← mul_one (coeff m f), ← C_mul_monomial]
suffices C (coeff m f) ∈ (Ideal.map C I : Ideal (MvPolynomial σ R)) by
exact Ideal.mul_mem_right _ _ this
apply Ideal.mem_map_of_mem _
exact hf m
theorem ker_map (f : R →+* S) :
RingHom.ker (map f : MvPolynomial σ R →+* MvPolynomial σ S) =
Ideal.map (C : R →+* MvPolynomial σ R) (RingHom.ker f) := by
ext
rw [MvPolynomial.mem_map_C_iff, RingHom.mem_ker, MvPolynomial.ext_iff]
simp_rw [coeff_map, coeff_zero, RingHom.mem_ker]
lemma ker_mapAlgHom {S₁ S₂ σ : Type*} [CommRing S₁] [CommRing S₂] [Algebra R S₁]
[Algebra R S₂] (f : S₁ →ₐ[R] S₂) :
RingHom.ker (MvPolynomial.mapAlgHom (σ := σ) f) = Ideal.map MvPolynomial.C (RingHom.ker f) :=
MvPolynomial.ker_map (f.toRingHom : S₁ →+* S₂)
end MvPolynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Bernstein.lean | import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Algebra.Polynomial.Eval.SMul
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.LinearAlgebra.LinearIndependent.Lemmas
import Mathlib.RingTheory.Polynomial.Pochhammer
/-!
# Bernstein polynomials
The definition of the Bernstein polynomials
```
bernsteinPolynomial (R : Type*) [CommRing R] (n ν : ℕ) : R[X] :=
(choose n ν) * X^ν * (1 - X)^(n - ν)
```
and the fact that for `ν : Fin (n+1)` these are linearly independent over `ℚ`.
We prove the basic identities
* `(Finset.range (n + 1)).sum (fun ν ↦ bernsteinPolynomial R n ν) = 1`
* `(Finset.range (n + 1)).sum (fun ν ↦ ν • bernsteinPolynomial R n ν) = n • X`
* `(Finset.range (n + 1)).sum (fun ν ↦ (ν * (ν-1)) • bernsteinPolynomial R n ν) = (n * (n-1)) • X^2`
## Notes
See also `Mathlib/Analysis/SpecialFunctions/Bernstein.lean`, which defines the Bernstein
approximations of a continuous function `f : C([0,1], ℝ)`, and shows that these converge uniformly
to `f`.
-/
noncomputable section
open Nat (choose)
open Polynomial (X)
open scoped Polynomial
variable (R : Type*) [CommRing R]
/-- `bernsteinPolynomial R n ν` is `(choose n ν) * X^ν * (1 - X)^(n - ν)`.
Although the coefficients are integers, it is convenient to work over an arbitrary commutative ring.
-/
def bernsteinPolynomial (n ν : ℕ) : R[X] :=
(choose n ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν)
example : bernsteinPolynomial ℤ 3 2 = 3 * X ^ 2 - 3 * X ^ 3 := by
norm_num [bernsteinPolynomial, choose]
ring
namespace bernsteinPolynomial
theorem eq_zero_of_lt {n ν : ℕ} (h : n < ν) : bernsteinPolynomial R n ν = 0 := by
simp [bernsteinPolynomial, Nat.choose_eq_zero_of_lt h]
section
variable {R} {S : Type*} [CommRing S]
@[simp]
theorem map (f : R →+* S) (n ν : ℕ) :
(bernsteinPolynomial R n ν).map f = bernsteinPolynomial S n ν := by simp [bernsteinPolynomial]
end
theorem flip (n ν : ℕ) (h : ν ≤ n) :
(bernsteinPolynomial R n ν).comp (1 - X) = bernsteinPolynomial R n (n - ν) := by
simp [bernsteinPolynomial, h, tsub_tsub_assoc, mul_right_comm]
theorem flip' (n ν : ℕ) (h : ν ≤ n) :
bernsteinPolynomial R n ν = (bernsteinPolynomial R n (n - ν)).comp (1 - X) := by
simp [← flip _ _ _ h, Polynomial.comp_assoc]
theorem eval_at_0 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 0 = if ν = 0 then 1 else 0 := by
rw [bernsteinPolynomial]
split_ifs with h
· subst h; simp
· simp [zero_pow h]
theorem eval_at_1 (n ν : ℕ) : (bernsteinPolynomial R n ν).eval 1 = if ν = n then 1 else 0 := by
rw [bernsteinPolynomial]
split_ifs with h
· subst h; simp
· obtain hνn | hnν := Ne.lt_or_gt h
· simp [zero_pow <| Nat.sub_ne_zero_of_lt hνn]
· simp [Nat.choose_eq_zero_of_lt hnν]
theorem derivative_succ_aux (n ν : ℕ) :
Polynomial.derivative (bernsteinPolynomial R (n + 1) (ν + 1)) =
(n + 1) * (bernsteinPolynomial R n ν - bernsteinPolynomial R n (ν + 1)) := by
rw [bernsteinPolynomial]
suffices ((n + 1).choose (ν + 1) : R[X]) * ((↑(ν + 1 : ℕ) : R[X]) * X ^ ν) * (1 - X) ^ (n - ν) -
((n + 1).choose (ν + 1) : R[X]) * X ^ (ν + 1) * ((↑(n - ν) : R[X]) * (1 - X) ^ (n - ν - 1)) =
(↑(n + 1) : R[X]) * ((n.choose ν : R[X]) * X ^ ν * (1 - X) ^ (n - ν) -
(n.choose (ν + 1) : R[X]) * X ^ (ν + 1) * (1 - X) ^ (n - (ν + 1))) by
simpa [Polynomial.derivative_pow, ← sub_eq_add_neg, Nat.succ_sub_succ_eq_sub,
Polynomial.derivative_mul, Polynomial.derivative_natCast, zero_mul,
Nat.cast_add, algebraMap.coe_one, Polynomial.derivative_X, mul_one, zero_add,
Polynomial.derivative_sub, Polynomial.derivative_one, zero_sub, mul_neg, Nat.sub_zero,
bernsteinPolynomial, map_add, map_natCast, Nat.cast_one]
conv_rhs => rw [mul_sub]
-- We'll prove the two terms match up separately.
refine congr (congr_arg Sub.sub ?_) ?_
· simp only [← mul_assoc]
apply congr (congr_arg (· * ·) (congr (congr_arg (· * ·) _) rfl)) rfl
-- Now it's just about binomial coefficients
exact mod_cast congr_arg (fun m : ℕ => (m : R[X])) (Nat.succ_mul_choose_eq n ν).symm
· rw [← tsub_add_eq_tsub_tsub, ← mul_assoc, ← mul_assoc]; congr 1
rw [mul_comm, ← mul_assoc, ← mul_assoc]; congr 1
norm_cast
congr 1
convert (Nat.choose_mul_succ_eq n (ν + 1)).symm using 1
· convert mul_comm _ _ using 2
simp
· apply mul_comm
theorem derivative_succ (n ν : ℕ) : Polynomial.derivative (bernsteinPolynomial R n (ν + 1)) =
n * (bernsteinPolynomial R (n - 1) ν - bernsteinPolynomial R (n - 1) (ν + 1)) := by
cases n
· simp [bernsteinPolynomial]
· rw [Nat.cast_succ]; apply derivative_succ_aux
theorem derivative_zero (n : ℕ) :
Polynomial.derivative (bernsteinPolynomial R n 0) = -n * bernsteinPolynomial R (n - 1) 0 := by
simp [bernsteinPolynomial, Polynomial.derivative_pow]
theorem iterate_derivative_at_0_eq_zero_of_lt (n : ℕ) {ν k : ℕ} :
k < ν → (Polynomial.derivative^[k] (bernsteinPolynomial R n ν)).eval 0 = 0 := by
rcases ν with - | ν
· rintro ⟨⟩
· rw [Nat.lt_succ_iff]
induction k generalizing n ν with
| zero => simp [eval_at_0]
| succ k ih =>
simp only [derivative_succ, Function.comp_apply,
Function.iterate_succ, Polynomial.iterate_derivative_sub,
Polynomial.iterate_derivative_natCast_mul, Polynomial.eval_mul, Polynomial.eval_natCast,
Polynomial.eval_sub]
intro h
apply mul_eq_zero_of_right
rw [ih _ _ (Nat.le_of_succ_le h), sub_zero]
convert ih _ _ (Nat.pred_le_pred h)
exact (Nat.succ_pred_eq_of_pos (k.succ_pos.trans_le h)).symm
@[simp]
theorem iterate_derivative_succ_at_0_eq_zero (n ν : ℕ) :
(Polynomial.derivative^[ν] (bernsteinPolynomial R n (ν + 1))).eval 0 = 0 :=
iterate_derivative_at_0_eq_zero_of_lt R n (lt_add_one ν)
open Polynomial
@[simp]
theorem iterate_derivative_at_0 (n ν : ℕ) :
(Polynomial.derivative^[ν] (bernsteinPolynomial R n ν)).eval 0 =
(ascPochhammer R ν).eval ((n - (ν - 1) : ℕ) : R) := by
by_cases! h : ν ≤ n
· induction ν generalizing n with
| zero => simp [eval_at_0]
| succ ν ih =>
have h' : ν ≤ n - 1 := le_tsub_of_add_le_right h
simp only [derivative_succ, ih (n - 1) h', iterate_derivative_succ_at_0_eq_zero,
Nat.succ_sub_succ_eq_sub, tsub_zero, sub_zero, iterate_derivative_sub,
iterate_derivative_natCast_mul, eval_one, eval_mul, eval_add, eval_sub, eval_X, eval_comp,
eval_natCast, Function.comp_apply, Function.iterate_succ, ascPochhammer_succ_left]
obtain rfl | h'' := ν.eq_zero_or_pos
· simp
· have : n - 1 - (ν - 1) = n - ν := by omega
rw [this, ascPochhammer_eval_succ]
rw_mod_cast [tsub_add_cancel_of_le (h'.trans n.pred_le)]
· rw [tsub_eq_zero_iff_le.mpr (Nat.le_sub_one_of_lt h), eq_zero_of_lt R h]
simp [pos_iff_ne_zero.mp (pos_of_gt h)]
theorem iterate_derivative_at_0_ne_zero [CharZero R] (n ν : ℕ) (h : ν ≤ n) :
(Polynomial.derivative^[ν] (bernsteinPolynomial R n ν)).eval 0 ≠ 0 := by
simp only [bernsteinPolynomial.iterate_derivative_at_0, Ne]
simp only [← ascPochhammer_eval_cast]
norm_cast
apply ne_of_gt
obtain rfl | h' := Nat.eq_zero_or_pos ν
· simp
· rw [← Nat.succ_pred_eq_of_pos h'] at h
exact ascPochhammer_pos _ _ (tsub_pos_of_lt (Nat.lt_of_succ_le h))
/-!
Rather than redoing the work of evaluating the derivatives at 1,
we use the symmetry of the Bernstein polynomials.
-/
theorem iterate_derivative_at_1_eq_zero_of_lt (n : ℕ) {ν k : ℕ} :
k < n - ν → (Polynomial.derivative^[k] (bernsteinPolynomial R n ν)).eval 1 = 0 := by
intro w
rw [flip' _ _ _ (tsub_pos_iff_lt.mp (pos_of_gt w)).le]
simp [Polynomial.eval_comp, iterate_derivative_at_0_eq_zero_of_lt R n w]
@[simp]
theorem iterate_derivative_at_1 (n ν : ℕ) (h : ν ≤ n) :
(Polynomial.derivative^[n - ν] (bernsteinPolynomial R n ν)).eval 1 =
(-1) ^ (n - ν) * (ascPochhammer R (n - ν)).eval (ν + 1 : R) := by
rw [flip' _ _ _ h]
simp only [iterate_derivative_comp_one_sub_X, eval_mul, eval_pow, eval_neg, eval_one, eval_comp,
eval_sub, eval_X, sub_self, iterate_derivative_at_0]
obtain rfl | h' := h.eq_or_lt
· simp
· norm_cast
congr
cutsat
theorem iterate_derivative_at_1_ne_zero [CharZero R] (n ν : ℕ) (h : ν ≤ n) :
(Polynomial.derivative^[n - ν] (bernsteinPolynomial R n ν)).eval 1 ≠ 0 := by
rw [bernsteinPolynomial.iterate_derivative_at_1 _ _ _ h, Ne, neg_one_pow_mul_eq_zero_iff, ←
Nat.cast_succ, ← ascPochhammer_eval_cast, ← Nat.cast_zero, Nat.cast_inj]
exact (ascPochhammer_pos _ _ (Nat.succ_pos ν)).ne'
open Submodule
theorem linearIndependent_aux (n k : ℕ) (h : k ≤ n + 1) :
LinearIndependent ℚ fun ν : Fin k => bernsteinPolynomial ℚ n ν := by
induction k with
| zero => apply linearIndependent_empty_type
| succ k ih =>
apply linearIndependent_fin_succ'.mpr
fconstructor
· exact ih (le_of_lt h)
· -- The actual work!
-- We show that the (n-k)-th derivative at 1 doesn't vanish,
-- but vanishes for everything in the span.
clear ih
simp only [add_le_add_iff_right] at h
simp only [Fin.val_last, Fin.init_def]
dsimp
apply notMem_span_of_apply_notMem_span_image (@Polynomial.derivative ℚ _ ^ (n - k))
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `span_image` into `span_image _`
simp only [not_exists, not_and, Submodule.mem_map, Submodule.span_image _]
intro p m
apply_fun Polynomial.eval (1 : ℚ)
simp only [Module.End.pow_apply]
-- The right-hand side is nonzero,
-- so it will suffice to show the left-hand side is always zero.
suffices (Polynomial.derivative^[n - k] p).eval 1 = 0 by
rw [this]
exact (iterate_derivative_at_1_ne_zero ℚ n k h).symm
refine span_induction ?_ ?_ ?_ ?_ m
· simp only [Set.mem_range, forall_exists_index, forall_apply_eq_imp_iff]
rintro ⟨a, w⟩; simp only
rw [iterate_derivative_at_1_eq_zero_of_lt ℚ n ((tsub_lt_tsub_iff_left_of_le h).mpr w)]
· simp
· intro x y _ _ hx hy; simp [hx, hy]
· intro a x _ h; simp [h]
/-- The Bernstein polynomials are linearly independent.
We prove by induction that the collection of `bernsteinPolynomial n ν` for `ν = 0, ..., k`
are linearly independent.
The inductive step relies on the observation that the `(n-k)`-th derivative, evaluated at 1,
annihilates `bernsteinPolynomial n ν` for `ν < k`, but has a nonzero value at `ν = k`.
-/
theorem linearIndependent (n : ℕ) :
LinearIndependent ℚ fun ν : Fin (n + 1) => bernsteinPolynomial ℚ n ν :=
linearIndependent_aux n (n + 1) le_rfl
theorem sum (n : ℕ) : (∑ ν ∈ Finset.range (n + 1), bernsteinPolynomial R n ν) = 1 :=
calc
(∑ ν ∈ Finset.range (n + 1), bernsteinPolynomial R n ν) = (X + (1 - X)) ^ n := by
rw [add_pow]
simp only [bernsteinPolynomial, mul_comm, mul_assoc]
_ = 1 := by simp
open Polynomial
open MvPolynomial hiding X
theorem sum_smul (n : ℕ) :
(∑ ν ∈ Finset.range (n + 1), ν • bernsteinPolynomial R n ν) = n • X := by
-- We calculate the `x`-derivative of `(x+y)^n`, evaluated at `y=(1-x)`,
-- either directly or by using the binomial theorem.
-- We'll work in `MvPolynomial Bool R`.
let x : MvPolynomial Bool R := MvPolynomial.X true
let y : MvPolynomial Bool R := MvPolynomial.X false
have pderiv_true_x : pderiv true x = 1 := by rw [pderiv_X]; rfl
have pderiv_true_y : pderiv true y = 0 := by rw [pderiv_X]; rfl
let e : Bool → R[X] := fun i => cond i X (1 - X)
-- Start with `(x+y)^n = (x+y)^n`,
-- take the `x`-derivative, evaluate at `x=X, y=1-X`, and multiply by `X`:
trans MvPolynomial.aeval e (pderiv true ((x + y) ^ n)) * X
-- On the left-hand side we'll use the binomial theorem, then simplify.
· -- We first prepare a tedious rewrite:
have w : ∀ k : ℕ, k • bernsteinPolynomial R n k =
(k : R[X]) * Polynomial.X ^ (k - 1) * (1 - Polynomial.X) ^ (n - k) * (n.choose k : R[X]) *
Polynomial.X := by
rintro (_ | k)
· simp
· rw [bernsteinPolynomial]
simp only [← natCast_mul, Nat.add_succ_sub_one, add_zero, pow_succ]
push_cast
ring
rw [add_pow, map_sum (pderiv true), map_sum (MvPolynomial.aeval e), Finset.sum_mul]
-- Step inside the sum:
refine Finset.sum_congr rfl fun k _ => (w k).trans ?_
simp only [x, y, e, pderiv_true_x, pderiv_true_y, Algebra.id.smul_eq_mul, nsmul_eq_mul,
Bool.cond_true, Bool.cond_false, add_zero, mul_one, mul_zero, smul_zero, MvPolynomial.aeval_X,
MvPolynomial.pderiv_mul, Derivation.leibniz_pow, Derivation.map_natCast, map_natCast, map_pow,
map_mul]
· rw [(pderiv true).leibniz_pow, (pderiv true).map_add, pderiv_true_x, pderiv_true_y]
simp only [x, y, e, Algebra.id.smul_eq_mul, nsmul_eq_mul, map_natCast, map_pow, map_add,
map_mul, Bool.cond_true, Bool.cond_false, MvPolynomial.aeval_X, add_sub_cancel,
one_pow, add_zero, mul_one]
theorem sum_mul_smul (n : ℕ) :
(∑ ν ∈ Finset.range (n + 1), (ν * (ν - 1)) • bernsteinPolynomial R n ν) =
(n * (n - 1)) • X ^ 2 := by
-- We calculate the second `x`-derivative of `(x+y)^n`, evaluated at `y=(1-x)`,
-- either directly or by using the binomial theorem.
-- We'll work in `MvPolynomial Bool R`.
let x : MvPolynomial Bool R := MvPolynomial.X true
let y : MvPolynomial Bool R := MvPolynomial.X false
have pderiv_true_x : pderiv true x = 1 := by rw [pderiv_X]; rfl
have pderiv_true_y : pderiv true y = 0 := by rw [pderiv_X]; rfl
let e : Bool → R[X] := fun i => cond i X (1 - X)
-- Start with `(x+y)^n = (x+y)^n`,
-- take the second `x`-derivative, evaluate at `x=X, y=1-X`, and multiply by `X`:
trans MvPolynomial.aeval e (pderiv true (pderiv true ((x + y) ^ n))) * X ^ 2
-- On the left-hand side we'll use the binomial theorem, then simplify.
· -- We first prepare a tedious rewrite:
have w : ∀ k : ℕ, (k * (k - 1)) • bernsteinPolynomial R n k =
(n.choose k : R[X]) * ((1 - Polynomial.X) ^ (n - k) *
((k : R[X]) * ((↑(k - 1) : R[X]) * Polynomial.X ^ (k - 1 - 1)))) * Polynomial.X ^ 2 := by
rintro (_ | _ | k)
· simp
· simp
· rw [bernsteinPolynomial]
simp only [← natCast_mul, Nat.add_succ_sub_one, add_zero, pow_succ]
push_cast
ring
rw [add_pow, map_sum (pderiv true), map_sum (pderiv true), map_sum (MvPolynomial.aeval e),
Finset.sum_mul]
-- Step inside the sum:
refine Finset.sum_congr rfl fun k _ => (w k).trans ?_
simp only [x, y, e, pderiv_true_x, pderiv_true_y, Algebra.id.smul_eq_mul, nsmul_eq_mul,
Bool.cond_true, Bool.cond_false, add_zero, zero_add, mul_zero, smul_zero, mul_one,
MvPolynomial.aeval_X,
Derivation.leibniz_pow, Derivation.leibniz, Derivation.map_natCast, map_natCast, map_pow,
map_mul]
-- On the right-hand side, we'll just simplify.
· simp only [x, y, e, (pderiv _).leibniz_pow,
(pderiv true).map_add, pderiv_true_x, pderiv_true_y, Algebra.id.smul_eq_mul, add_zero,
mul_one, map_nsmul, map_pow, map_add, Bool.cond_true,
Bool.cond_false, MvPolynomial.aeval_X, add_sub_cancel, one_pow, smul_smul,
smul_one_mul]
/-- A certain linear combination of the previous three identities,
which we'll want later.
-/
theorem variance (n : ℕ) :
(∑ ν ∈ Finset.range (n + 1), (n • Polynomial.X - (ν : R[X])) ^ 2 * bernsteinPolynomial R n ν) =
n • Polynomial.X * ((1 : R[X]) - Polynomial.X) := by
have p : ((((Finset.range (n + 1)).sum fun ν => (ν * (ν - 1)) • bernsteinPolynomial R n ν) +
(1 - (2 * n) • Polynomial.X) * (Finset.range (n + 1)).sum fun ν =>
ν • bernsteinPolynomial R n ν) + n ^ 2 • X ^ 2 *
(Finset.range (n + 1)).sum fun ν => bernsteinPolynomial R n ν) = _ :=
rfl
conv at p =>
lhs
rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_add_distrib]
simp only [← natCast_mul]
simp only [← mul_assoc]
simp only [← add_mul]
conv at p =>
rhs
rw [sum, sum_smul, sum_mul_smul, ← natCast_mul]
calc
_ = _ := Finset.sum_congr rfl fun k m => ?_
_ = _ := p
_ = _ := ?_
· congr 1; simp only [← natCast_mul, push_cast]
cases k <;> · simp; ring
· simp only [← natCast_mul, push_cast]
cases n
· simp
· simp; ring
end bernsteinPolynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Quotient.lean | import Mathlib.Algebra.Field.Equiv
import Mathlib.Algebra.Polynomial.Div
import Mathlib.Algebra.Polynomial.Eval.SMul
import Mathlib.GroupTheory.GroupAction.Ring
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Polynomial.Basic
import Mathlib.RingTheory.Polynomial.Ideal
import Mathlib.RingTheory.PrincipalIdealDomain
/-!
# Quotients of polynomial rings
-/
open Polynomial
namespace Polynomial
variable {R : Type*} [CommRing R]
/-- For a commutative ring $R$, evaluating a polynomial at an element $x \in R$ induces an
isomorphism of $R$-algebras $R[X] / \langle X - x \rangle \cong R$. -/
noncomputable def quotientSpanXSubCAlgEquiv (x : R) :
(R[X] ⧸ Ideal.span ({X - C x} : Set R[X])) ≃ₐ[R] R :=
let e := RingHom.quotientKerEquivOfRightInverse (fun x => by
exact eval_C : Function.RightInverse (fun a : R => (C a : R[X])) (@aeval R R _ _ _ x))
(Ideal.quotientEquivAlgOfEq R (ker_evalRingHom x).symm).trans
{ e with commutes' := fun r => e.apply_symm_apply r }
@[simp]
theorem quotientSpanXSubCAlgEquiv_mk (x : R) (p : R[X]) :
quotientSpanXSubCAlgEquiv x (Ideal.Quotient.mk _ p) = p.eval x :=
rfl
@[simp]
theorem quotientSpanXSubCAlgEquiv_symm_apply (x : R) (y : R) :
(quotientSpanXSubCAlgEquiv x).symm y = algebraMap R _ y :=
rfl
/-- For a commutative ring $R$, evaluating a polynomial at an element $y \in R$ induces an
isomorphism of $R$-algebras $R[X] / \langle x, X - y \rangle \cong R / \langle x \rangle$. -/
noncomputable def quotientSpanCXSubCAlgEquiv (x y : R) :
(R[X] ⧸ (Ideal.span {C x, X - C y} : Ideal R[X])) ≃ₐ[R] R ⧸ (Ideal.span {x} : Ideal R) :=
(Ideal.quotientEquivAlgOfEq R <| by rw [Ideal.span_insert, sup_comm]).trans <|
(DoubleQuot.quotQuotEquivQuotSupₐ R _ _).symm.trans <|
(Ideal.quotientEquivAlg _ _ (quotientSpanXSubCAlgEquiv y) rfl).trans <|
Ideal.quotientEquivAlgOfEq R <| by
simp only [Ideal.map_span, Set.image_singleton]; congr 2; exact eval_C
/-- For a commutative ring $R$, evaluating a polynomial at elements $y(X) \in R[X]$ and $x \in R$
induces an isomorphism of $R$-algebras $R[X, Y] / \langle X - x, Y - y(X) \rangle \cong R$. -/
noncomputable def quotientSpanCXSubCXSubCAlgEquiv {x : R} {y : R[X]} :
@AlgEquiv R (R[X][X] ⧸ (Ideal.span {C (X - C x), X - C y} : Ideal <| R[X][X])) R _ _ _
(Ideal.Quotient.algebra R) _ :=
((quotientSpanCXSubCAlgEquiv (X - C x) y).restrictScalars R).trans <| quotientSpanXSubCAlgEquiv x
lemma modByMonic_eq_zero_iff_quotient_eq_zero (p q : R[X]) (hq : q.Monic) :
p %ₘ q = 0 ↔ (p : R[X] ⧸ Ideal.span {q}) = 0 := by
rw [modByMonic_eq_zero_iff_dvd hq, Ideal.Quotient.eq_zero_iff_dvd]
end Polynomial
namespace Ideal
noncomputable section
open Polynomial
variable {R : Type*} [CommRing R]
theorem quotient_map_C_eq_zero {I : Ideal R} :
∀ a ∈ I, ((Quotient.mk (map (C : R →+* R[X]) I : Ideal R[X])).comp C) a = 0 := by
intro a ha
rw [RingHom.comp_apply, Quotient.eq_zero_iff_mem]
exact mem_map_of_mem _ ha
theorem eval₂_C_mk_eq_zero {I : Ideal R} :
∀ f ∈ (map (C : R →+* R[X]) I : Ideal R[X]), eval₂RingHom (C.comp (Quotient.mk I)) X f = 0 := by
intro a ha
rw [← sum_monomial_eq a]
dsimp
rw [eval₂_sum]
refine Finset.sum_eq_zero fun n _ => ?_
dsimp
rw [eval₂_monomial (C.comp (Quotient.mk I)) X]
refine mul_eq_zero_of_left (Polynomial.ext fun m => ?_) (X ^ n)
rw [RingHom.comp_apply, coeff_C]
by_cases h : m = 0
· simpa [h] using Quotient.eq_zero_iff_mem.2 ((mem_map_C_iff.1 ha) n)
· simp [h]
/-- If `I` is an ideal of `R`, then the ring polynomials over the quotient ring `I.quotient` is
isomorphic to the quotient of `R[X]` by the ideal `map C I`,
where `map C I` contains exactly the polynomials whose coefficients all lie in `I`. -/
def polynomialQuotientEquivQuotientPolynomial (I : Ideal R) :
(R ⧸ I)[X] ≃+* R[X] ⧸ (map C I : Ideal R[X]) where
toFun :=
eval₂RingHom
(Quotient.lift I ((Quotient.mk (map C I : Ideal R[X])).comp C) quotient_map_C_eq_zero)
(Quotient.mk (map C I : Ideal R[X]) X)
invFun :=
Quotient.lift (map C I : Ideal R[X]) (eval₂RingHom (C.comp (Quotient.mk I)) X)
eval₂_C_mk_eq_zero
map_mul' f g := by simp only [coe_eval₂RingHom, eval₂_mul]
map_add' f g := by simp only [eval₂_add, coe_eval₂RingHom]
left_inv := by
intro f
refine Polynomial.induction_on' f ?_ ?_
· intro p q hp hq
simp only [coe_eval₂RingHom] at hp hq
simp only [coe_eval₂RingHom, hp, hq, RingHom.map_add]
· rintro n ⟨x⟩
simp only [← smul_X_eq_monomial, C_mul', Quotient.lift_mk, Submodule.Quotient.quot_mk_eq_mk,
Quotient.mk_eq_mk, eval₂_X_pow, eval₂_smul, coe_eval₂RingHom, RingHom.map_pow, eval₂_C,
RingHom.coe_comp, RingHom.map_mul, eval₂_X, Function.comp_apply]
right_inv := by
rintro ⟨f⟩
refine Polynomial.induction_on' f ?_ ?_
· intro p q hp hq
simp only [Submodule.Quotient.quot_mk_eq_mk, Quotient.mk_eq_mk, map_add, Quotient.lift_mk,
coe_eval₂RingHom] at hp hq ⊢
rw [hp, hq]
· intro n a
simp only [← smul_X_eq_monomial, ← C_mul' a (X ^ n), Quotient.lift_mk,
Submodule.Quotient.quot_mk_eq_mk, Quotient.mk_eq_mk,
coe_eval₂RingHom, RingHom.map_pow, eval₂_C, RingHom.coe_comp, RingHom.map_mul, eval₂_X,
Function.comp_apply]
@[simp]
theorem polynomialQuotientEquivQuotientPolynomial_symm_mk (I : Ideal R) (f : R[X]) :
I.polynomialQuotientEquivQuotientPolynomial.symm (Quotient.mk _ f) = f.map (Quotient.mk I) := by
rw [polynomialQuotientEquivQuotientPolynomial, RingEquiv.symm_mk, RingEquiv.coe_mk,
Equiv.coe_fn_mk, Quotient.lift_mk, coe_eval₂RingHom, eval₂_eq_eval_map, ← Polynomial.map_map,
← eval₂_eq_eval_map, Polynomial.eval₂_C_X]
@[simp]
theorem polynomialQuotientEquivQuotientPolynomial_map_mk (I : Ideal R) (f : R[X]) :
I.polynomialQuotientEquivQuotientPolynomial (f.map <| Quotient.mk I) =
Quotient.mk (map C I : Ideal R[X]) f := by
apply (polynomialQuotientEquivQuotientPolynomial I).symm.injective
rw [RingEquiv.symm_apply_apply, polynomialQuotientEquivQuotientPolynomial_symm_mk]
/-- If `P` is a prime ideal of `R`, then `R[x]/(P)` is an integral domain. -/
theorem isDomain_map_C_quotient {P : Ideal R} (_ : IsPrime P) :
IsDomain (R[X] ⧸ (map (C : R →+* R[X]) P : Ideal R[X])) :=
MulEquiv.isDomain (Polynomial (R ⧸ P)) (polynomialQuotientEquivQuotientPolynomial P).symm
/-- Given any ring `R` and an ideal `I` of `R[X]`, we get a map `R → R[x] → R[x]/I`.
If we let `R` be the image of `R` in `R[x]/I` then we also have a map `R[x] → R'[x]`.
In particular we can map `I` across this map, to get `I'` and a new map `R' → R'[x] → R'[x]/I`.
This theorem shows `I'` will not contain any non-zero constant polynomials. -/
theorem eq_zero_of_polynomial_mem_map_range (I : Ideal R[X]) (x : ((Quotient.mk I).comp C).range)
(hx : C x ∈ I.map (Polynomial.mapRingHom ((Quotient.mk I).comp C).rangeRestrict)) : x = 0 := by
let i := ((Quotient.mk I).comp C).rangeRestrict
have hi' : RingHom.ker (Polynomial.mapRingHom i) ≤ I := by
refine fun f hf => polynomial_mem_ideal_of_coeff_mem_ideal I f fun n => ?_
rw [mem_comap, ← Quotient.eq_zero_iff_mem, ← RingHom.comp_apply]
rw [RingHom.mem_ker, coe_mapRingHom] at hf
replace hf := congr_arg (fun f : Polynomial _ => f.coeff n) hf
simp only [coeff_map, coeff_zero] at hf
rwa [Subtype.ext_iff, RingHom.coe_rangeRestrict] at hf
obtain ⟨x, hx'⟩ := x
obtain ⟨y, rfl⟩ := RingHom.mem_range.1 hx'
refine Subtype.eq ?_
simp only [RingHom.comp_apply, Quotient.eq_zero_iff_mem, ZeroMemClass.coe_zero]
suffices C (i y) ∈ I.map (Polynomial.mapRingHom i) by
obtain ⟨f, hf⟩ := mem_image_of_mem_map_of_surjective (Polynomial.mapRingHom i)
(Polynomial.map_surjective _ (RingHom.rangeRestrict_surjective ((Quotient.mk I).comp C))) this
refine sub_add_cancel (C y) f ▸ I.add_mem (hi' ?_ : C y - f ∈ I) hf.1
rw [RingHom.mem_ker, RingHom.map_sub, hf.2, sub_eq_zero, coe_mapRingHom, map_C]
exact hx
/-- Given a domain `R`, if `R[X]` is a principal ideal ring, then `R` is a field. -/
lemma IsField.of_isPrincipalIdealRing_polynomial [IsDomain R] [IsPrincipalIdealRing R[X]] :
IsField R := by
apply (quotientSpanXSubCAlgEquiv 0).symm.toMulEquiv.isField
rw [← Quotient.maximal_ideal_iff_isField_quotient]
exact PrincipalIdealRing.isMaximal_of_irreducible (irreducible_X_sub_C 0)
end
end Ideal
namespace MvPolynomial
variable {R : Type*} {σ : Type*} [CommRing R] {r : R}
theorem quotient_map_C_eq_zero {I : Ideal R} {i : R} (hi : i ∈ I) :
(Ideal.Quotient.mk (Ideal.map (C : R →+* MvPolynomial σ R) I :
Ideal (MvPolynomial σ R))).comp C i = 0 := by
simp only [Function.comp_apply, RingHom.coe_comp, Ideal.Quotient.eq_zero_iff_mem]
exact Ideal.mem_map_of_mem _ hi
theorem eval₂_C_mk_eq_zero {I : Ideal R} {a : MvPolynomial σ R}
(ha : a ∈ (Ideal.map (C : R →+* MvPolynomial σ R) I : Ideal (MvPolynomial σ R))) :
eval₂Hom (C.comp (Ideal.Quotient.mk I)) X a = 0 := by
rw [as_sum a]
rw [coe_eval₂Hom, eval₂_sum]
refine Finset.sum_eq_zero fun n _ => ?_
simp only [eval₂_monomial, Function.comp_apply, RingHom.coe_comp]
refine mul_eq_zero_of_left ?_ _
suffices coeff n a ∈ I by
rw [← @Ideal.mk_ker R _ I, RingHom.mem_ker] at this
simp only [this, C_0]
exact mem_map_C_iff.1 ha n
/-- Split off from `quotientEquivQuotientMvPolynomial` for speed. -/
lemma quotientEquivQuotientMvPolynomial_rightInverse (I : Ideal R) :
Function.RightInverse
(eval₂ (Ideal.Quotient.lift I
((Ideal.Quotient.mk (Ideal.map C I : Ideal (MvPolynomial σ R))).comp C)
fun _ hi => quotient_map_C_eq_zero hi)
fun i => Ideal.Quotient.mk (Ideal.map C I : Ideal (MvPolynomial σ R)) (X i))
(Ideal.Quotient.lift (Ideal.map C I : Ideal (MvPolynomial σ R))
(eval₂Hom (C.comp (Ideal.Quotient.mk I)) X) fun _ ha => eval₂_C_mk_eq_zero ha) := by
intro f
apply induction_on f
· intro r
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective r
rw [eval₂_C, Ideal.Quotient.lift_mk, RingHom.comp_apply, Ideal.Quotient.lift_mk, eval₂Hom_C,
RingHom.comp_apply]
· intro p q hp hq
simp only [RingHom.map_add, MvPolynomial.eval₂_add]
at hp hq ⊢
rw [hp, hq]
· intro p i hp
simp only at hp
simp only [hp, coe_eval₂Hom, Ideal.Quotient.lift_mk, eval₂_mul, RingHom.map_mul, eval₂_X]
/-- Split off from `quotientEquivQuotientMvPolynomial` for speed. -/
lemma quotientEquivQuotientMvPolynomial_leftInverse (I : Ideal R) :
Function.LeftInverse
(eval₂ (Ideal.Quotient.lift I
((Ideal.Quotient.mk (Ideal.map C I : Ideal (MvPolynomial σ R))).comp C)
fun _ hi => quotient_map_C_eq_zero hi)
fun i => Ideal.Quotient.mk (Ideal.map C I : Ideal (MvPolynomial σ R)) (X i))
(Ideal.Quotient.lift (Ideal.map C I : Ideal (MvPolynomial σ R))
(eval₂Hom (C.comp (Ideal.Quotient.mk I)) X) fun _ ha => eval₂_C_mk_eq_zero ha) := by
intro f
obtain ⟨f, rfl⟩ := Ideal.Quotient.mk_surjective f
apply induction_on f
· intro r
rw [Ideal.Quotient.lift_mk, eval₂Hom_C, RingHom.comp_apply, eval₂_C, Ideal.Quotient.lift_mk,
RingHom.comp_apply]
· intro p q hp hq
rw [Ideal.Quotient.lift_mk] at hp hq ⊢
simp only [eval₂_add, RingHom.map_add, coe_eval₂Hom] at hp hq ⊢
rw [hp, hq]
· intro p i hp
simp only [coe_eval₂Hom, Ideal.Quotient.lift_mk,
eval₂_mul, RingHom.map_mul, eval₂_X] at hp ⊢
simp only [hp]
/-- If `I` is an ideal of `R`, then the ring `MvPolynomial σ I.quotient` is isomorphic as an
`R`-algebra to the quotient of `MvPolynomial σ R` by the ideal generated by `I`. -/
noncomputable def quotientEquivQuotientMvPolynomial (I : Ideal R) :
MvPolynomial σ (R ⧸ I) ≃ₐ[R] MvPolynomial σ R ⧸ (Ideal.map C I : Ideal (MvPolynomial σ R)) :=
let e : MvPolynomial σ (R ⧸ I) →ₐ[R]
MvPolynomial σ R ⧸ (Ideal.map C I : Ideal (MvPolynomial σ R)) :=
{ eval₂Hom
(Ideal.Quotient.lift I ((Ideal.Quotient.mk (Ideal.map C I : Ideal (MvPolynomial σ R))).comp C)
fun _ hi => quotient_map_C_eq_zero hi)
fun i => Ideal.Quotient.mk (Ideal.map C I : Ideal (MvPolynomial σ R)) (X i) with
commutes' := fun r => eval₂Hom_C _ _ (Ideal.Quotient.mk I r) }
{ e with
invFun := Ideal.Quotient.lift (Ideal.map C I : Ideal (MvPolynomial σ R))
(eval₂Hom (C.comp (Ideal.Quotient.mk I)) X) fun _ ha => eval₂_C_mk_eq_zero ha
left_inv := quotientEquivQuotientMvPolynomial_rightInverse I
right_inv := quotientEquivQuotientMvPolynomial_leftInverse I }
end MvPolynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Ideal.lean | import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.RingTheory.Adjoin.Polynomial
import Mathlib.RingTheory.Ideal.Maps
/-!
# Ideals in polynomial rings
-/
noncomputable section
open Polynomial
open Finset
universe u v w
namespace Polynomial
variable {R : Type*} [CommRing R] {a : R}
theorem mem_span_C_X_sub_C_X_sub_C_iff_eval_eval_eq_zero {b : R[X]} {P : R[X][X]} :
P ∈ Ideal.span {C (X - C a), X - C b} ↔ (P.eval b).eval a = 0 := by
rw [Ideal.mem_span_pair]
constructor <;> intro h
· rcases h with ⟨_, _, rfl⟩
simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul, add_zero, mul_zero, sub_self]
· rcases dvd_iff_isRoot.mpr h with ⟨p, hp⟩
rcases @X_sub_C_dvd_sub_C_eval _ b _ P with ⟨q, hq⟩
exact ⟨C p, q, by rw [mul_comm, mul_comm q, eq_add_of_sub_eq' hq, hp, C_mul]⟩
theorem ker_evalRingHom (x : R) : RingHom.ker (evalRingHom x) = Ideal.span {X - C x} := by
ext y
simp [Ideal.mem_span_singleton, dvd_iff_isRoot, RingHom.mem_ker]
@[simp]
theorem ker_modByMonicHom {q : R[X]} (hq : q.Monic) :
LinearMap.ker (Polynomial.modByMonicHom q) = (Ideal.span {q}).restrictScalars R :=
Submodule.ext fun _ => (mem_ker_modByMonic hq).trans Ideal.mem_span_singleton.symm
@[simp]
lemma ker_constantCoeff : RingHom.ker constantCoeff = .span {(X : R[X])} := by
refine le_antisymm (fun p hp ↦ ?_) (by simp [Ideal.span_le])
simp only [RingHom.mem_ker, constantCoeff_apply, ← Polynomial.X_dvd_iff] at hp
rwa [Ideal.mem_span_singleton]
open Algebra in
lemma _root_.Algebra.mem_ideal_map_adjoin {R S : Type*} [CommSemiring R] [Semiring S] [Algebra R S]
(x : S) (I : Ideal R) {y : adjoin R ({x} : Set S)} :
y ∈ I.map (algebraMap R (adjoin R ({x} : Set S))) ↔
∃ p : R[X], (∀ i, p.coeff i ∈ I) ∧ Polynomial.aeval x p = y := by
constructor
· intro H
induction H using Submodule.span_induction with
| mem a ha =>
obtain ⟨a, ha, rfl⟩ := ha
exact ⟨C a, fun i ↦ by rw [coeff_C]; aesop, aeval_C _ _⟩
| zero => exact ⟨0, by simp, aeval_zero _⟩
| add a b ha hb ha' hb' =>
obtain ⟨a, ha, ha'⟩ := ha'
obtain ⟨b, hb, hb'⟩ := hb'
exact ⟨a + b, fun i ↦ by simpa using add_mem (ha i) (hb i), by simp [ha', hb']⟩
| smul a b hb hb' =>
obtain ⟨b', hb, hb'⟩ := hb'
obtain ⟨a, ha⟩ := a
rw [Algebra.adjoin_singleton_eq_range_aeval] at ha
obtain ⟨p, hp : aeval x p = a⟩ := ha
refine ⟨p * b', fun i ↦ ?_, by simp [hp, hb']⟩
rw [coeff_mul]
exact sum_mem fun i hi ↦ Ideal.mul_mem_left _ _ (hb _)
· rintro ⟨p, hp, hp'⟩
have : y = ∑ i ∈ p.support, p.coeff i • ⟨_, (X ^ i).aeval_mem_adjoin_singleton _ x⟩ := by
trans ∑ i ∈ p.support, ⟨_, (C (p.coeff i) * X ^ i).aeval_mem_adjoin_singleton _ x⟩
· ext1
simp only [AddSubmonoidClass.coe_finset_sum, ← map_sum, ← hp', ← as_sum_support_C_mul_X_pow]
· congr with i
simp [Algebra.smul_def]
simp_rw [this, Algebra.smul_def]
exact sum_mem fun i _ ↦ Ideal.mul_mem_right _ _ (Ideal.mem_map_of_mem _ (hp i))
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Content.lean | import Mathlib.Algebra.GCDMonoid.Finset
import Mathlib.Algebra.Polynomial.CancelLeads
import Mathlib.Algebra.Polynomial.EraseLead
import Mathlib.Algebra.Polynomial.FieldDivision
/-!
# GCD structures on polynomials
Definitions and basic results about polynomials over GCD domains, particularly their contents
and primitive polynomials.
## Main Definitions
Let `p : R[X]`.
- `p.content` is the `gcd` of the coefficients of `p`.
- `p.IsPrimitive` indicates that `p.content = 1`.
## Main Results
- `Polynomial.content_mul`: if `p q : R[X]`, then `(p * q).content = p.content * q.content`.
- `Polynomial.NormalizedGcdMonoid`: the polynomial ring of a GCD domain is itself a GCD domain.
## Note
This has nothing to do with minimal polynomials of primitive elements in finite fields.
-/
namespace Polynomial
section Primitive
variable {R : Type*} [CommSemiring R]
/-- A polynomial is primitive when the only constant polynomials dividing it are units.
Note: This has nothing to do with minimal polynomials of primitive elements in finite fields. -/
def IsPrimitive (p : R[X]) : Prop :=
∀ r : R, C r ∣ p → IsUnit r
theorem isPrimitive_iff_isUnit_of_C_dvd {p : R[X]} : p.IsPrimitive ↔ ∀ r : R, C r ∣ p → IsUnit r :=
Iff.rfl
@[simp]
theorem isPrimitive_one : IsPrimitive (1 : R[X]) := fun _ h =>
isUnit_C.mp (isUnit_of_dvd_one h)
theorem Monic.isPrimitive {p : R[X]} (hp : p.Monic) : p.IsPrimitive := by
rintro r ⟨q, h⟩
exact .of_mul_eq_one (q.coeff p.natDegree) (by rwa [← coeff_C_mul, ← h])
theorem IsPrimitive.ne_zero [Nontrivial R] {p : R[X]} (hp : p.IsPrimitive) : p ≠ 0 := by
rintro rfl
exact (hp 0 (dvd_zero (C 0))).ne_zero rfl
theorem isPrimitive_of_dvd {p q : R[X]} (hp : IsPrimitive p) (hq : q ∣ p) : IsPrimitive q :=
fun a ha => isPrimitive_iff_isUnit_of_C_dvd.mp hp a (dvd_trans ha hq)
/-- An irreducible nonconstant polynomial over a domain is primitive. -/
theorem _root_.Irreducible.isPrimitive [NoZeroDivisors R]
{p : Polynomial R} (hp : Irreducible p) (hp' : p.natDegree ≠ 0) : p.IsPrimitive := by
rintro r ⟨q, hq⟩
suffices ¬IsUnit q by simpa using ((hp.2 hq).resolve_right this).map Polynomial.constantCoeff
intro H
have hr : r ≠ 0 := by rintro rfl; simp_all
obtain ⟨s, hs, rfl⟩ := Polynomial.isUnit_iff.mp H
simp [hq, Polynomial.natDegree_C_mul hr] at hp'
end Primitive
variable {R : Type*} [CommRing R] [IsDomain R]
section NormalizedGCDMonoid
variable [NormalizedGCDMonoid R]
/-- `p.content` is the `gcd` of the coefficients of `p`. -/
def content (p : R[X]) : R :=
p.support.gcd p.coeff
theorem content_dvd_coeff {p : R[X]} (n : ℕ) : p.content ∣ p.coeff n := by
by_cases h : n ∈ p.support
· apply Finset.gcd_dvd h
rw [mem_support_iff, Classical.not_not] at h
rw [h]
apply dvd_zero
@[simp]
theorem content_C {r : R} : (C r).content = normalize r := by
rw [content]
by_cases h0 : r = 0
· simp [h0]
have h : (C r).support = {0} := support_monomial _ h0
simp [h]
@[simp]
theorem content_zero : content (0 : R[X]) = 0 := by rw [← C_0, content_C, normalize_zero]
@[simp]
theorem content_one : content (1 : R[X]) = 1 := by rw [← C_1, content_C, normalize_one]
theorem content_X_mul {p : R[X]} : content (X * p) = content p := by
rw [content, content, Finset.gcd_def, Finset.gcd_def]
refine congr rfl ?_
have h : (X * p).support = p.support.map ⟨Nat.succ, Nat.succ_injective⟩ := by
ext a
simp only [Finset.mem_map, Function.Embedding.coeFn_mk, Ne, mem_support_iff]
rcases a with - | a
· simp
rw [mul_comm, coeff_mul_X]
constructor
· intro h
use a
· rintro ⟨b, ⟨h1, h2⟩⟩
rw [← Nat.succ_injective h2]
apply h1
rw [h]
simp only [Finset.map_val, Function.comp_apply, Function.Embedding.coeFn_mk, Multiset.map_map]
refine congr (congr rfl ?_) rfl
ext a
rw [mul_comm]
simp [coeff_mul_X]
@[simp]
theorem content_X_pow {k : ℕ} : content ((X : R[X]) ^ k) = 1 := by
induction k with
| zero => simp
| succ k hi => rw [pow_succ', content_X_mul, hi]
@[simp]
theorem content_X : content (X : R[X]) = 1 := by rw [← mul_one X, content_X_mul, content_one]
theorem content_C_mul (r : R) (p : R[X]) : (C r * p).content = normalize r * p.content := by
by_cases h0 : r = 0; · simp [h0]
rw [content]; rw [content]; rw [← Finset.gcd_mul_left]
refine congr (congr rfl ?_) ?_ <;> ext <;> simp [h0, mem_support_iff]
@[simp]
theorem content_monomial {r : R} {k : ℕ} : content (monomial k r) = normalize r := by
rw [← C_mul_X_pow_eq_monomial, content_C_mul, content_X_pow, mul_one]
theorem content_eq_zero_iff {p : R[X]} : content p = 0 ↔ p = 0 := by
rw [content, Finset.gcd_eq_zero_iff]
constructor <;> intro h
· ext n
by_cases h0 : n ∈ p.support
· rw [h n h0, coeff_zero]
· rw [mem_support_iff] at h0
push_neg at h0
simp [h0]
· intro x
simp [h]
-- `simp`-normal form is `normUnit_content`
theorem normalize_content {p : R[X]} : normalize p.content = p.content :=
Finset.normalize_gcd
@[simp]
theorem normUnit_content {p : R[X]} : normUnit (content p) = 1 := by
by_cases hp0 : p.content = 0
· simp [hp0]
· ext
apply mul_left_cancel₀ hp0
rw [← normalize_apply, normalize_content, Units.val_one, mul_one]
theorem content_eq_gcd_range_of_lt (p : R[X]) (n : ℕ) (h : p.natDegree < n) :
p.content = (Finset.range n).gcd p.coeff := by
apply dvd_antisymm_of_normalize_eq normalize_content Finset.normalize_gcd
· rw [Finset.dvd_gcd_iff]
intro i _
apply content_dvd_coeff _
· apply Finset.gcd_mono
intro i
simp only [mem_support_iff, Ne, Finset.mem_range]
contrapose!
intro h1
apply coeff_eq_zero_of_natDegree_lt (lt_of_lt_of_le h h1)
theorem content_eq_gcd_range_succ (p : R[X]) :
p.content = (Finset.range p.natDegree.succ).gcd p.coeff :=
content_eq_gcd_range_of_lt _ _ (Nat.lt_succ_self _)
theorem content_eq_gcd_leadingCoeff_content_eraseLead (p : R[X]) :
p.content = GCDMonoid.gcd p.leadingCoeff (eraseLead p).content := by
by_cases h : p = 0
· simp [h]
rw [← leadingCoeff_eq_zero, leadingCoeff, ← Ne, ← mem_support_iff] at h
rw [content, ← Finset.insert_erase h, Finset.gcd_insert, leadingCoeff, content,
eraseLead_support]
refine congr rfl (Finset.gcd_congr rfl fun i hi => ?_)
rw [Finset.mem_erase] at hi
rw [eraseLead_coeff, if_neg hi.1]
theorem dvd_content_iff_C_dvd {p : R[X]} {r : R} : r ∣ p.content ↔ C r ∣ p := by
rw [C_dvd_iff_dvd_coeff]
constructor
· intro h i
apply h.trans (content_dvd_coeff _)
· intro h
rw [content, Finset.dvd_gcd_iff]
intro i _
apply h i
theorem C_content_dvd (p : R[X]) : C p.content ∣ p :=
dvd_content_iff_C_dvd.1 dvd_rfl
theorem isPrimitive_iff_content_eq_one {p : R[X]} : p.IsPrimitive ↔ p.content = 1 := by
rw [← normalize_content, normalize_eq_one, IsPrimitive]
simp_rw [← dvd_content_iff_C_dvd]
exact ⟨fun h => h p.content (dvd_refl p.content), fun h r hdvd => isUnit_of_dvd_unit hdvd h⟩
theorem IsPrimitive.content_eq_one {p : R[X]} (hp : p.IsPrimitive) : p.content = 1 :=
isPrimitive_iff_content_eq_one.mp hp
section PrimPart
/-- The primitive part of a polynomial `p` is the primitive polynomial gained by dividing `p` by
`p.content`. If `p = 0`, then `p.primPart = 1`. -/
noncomputable def primPart (p : R[X]) : R[X] :=
letI := Classical.decEq R
if p = 0 then 1 else Classical.choose (C_content_dvd p)
theorem eq_C_content_mul_primPart (p : R[X]) : p = C p.content * p.primPart := by
by_cases h : p = 0; · simp [h]
rw [primPart, if_neg h, ← Classical.choose_spec (C_content_dvd p)]
@[simp]
theorem primPart_zero : primPart (0 : R[X]) = 1 :=
if_pos rfl
theorem isPrimitive_primPart (p : R[X]) : p.primPart.IsPrimitive := by
by_cases h : p = 0; · simp [h]
rw [← content_eq_zero_iff] at h
rw [isPrimitive_iff_content_eq_one]
apply mul_left_cancel₀ h
conv_rhs => rw [p.eq_C_content_mul_primPart, mul_one, content_C_mul, normalize_content]
theorem content_primPart (p : R[X]) : p.primPart.content = 1 :=
p.isPrimitive_primPart.content_eq_one
theorem primPart_ne_zero (p : R[X]) : p.primPart ≠ 0 :=
p.isPrimitive_primPart.ne_zero
theorem natDegree_primPart (p : R[X]) : p.primPart.natDegree = p.natDegree := by
by_cases h : C p.content = 0
· rw [C_eq_zero, content_eq_zero_iff] at h
simp [h]
conv_rhs =>
rw [p.eq_C_content_mul_primPart, natDegree_mul h p.primPart_ne_zero, natDegree_C, zero_add]
@[simp]
theorem IsPrimitive.primPart_eq {p : R[X]} (hp : p.IsPrimitive) : p.primPart = p := by
rw [← one_mul p.primPart, ← C_1, ← hp.content_eq_one, ← p.eq_C_content_mul_primPart]
theorem isUnit_primPart_C (r : R) : IsUnit (C r).primPart := by
by_cases h0 : r = 0
· simp [h0]
unfold IsUnit
refine
⟨⟨C ↑(normUnit r)⁻¹, C ↑(normUnit r), by rw [← RingHom.map_mul, Units.inv_mul, C_1], by
rw [← RingHom.map_mul, Units.mul_inv, C_1]⟩,
?_⟩
rw [← normalize_eq_zero, ← C_eq_zero] at h0
apply mul_left_cancel₀ h0
conv_rhs => rw [← content_C, ← (C r).eq_C_content_mul_primPart]
simp only [normalize_apply, RingHom.map_mul]
rw [mul_assoc, ← RingHom.map_mul, Units.mul_inv, C_1, mul_one]
theorem primPart_dvd (p : R[X]) : p.primPart ∣ p :=
Dvd.intro_left (C p.content) p.eq_C_content_mul_primPart.symm
theorem aeval_primPart_eq_zero {S : Type*} [Ring S] [IsDomain S] [Algebra R S]
[NoZeroSMulDivisors R S] {p : R[X]} {s : S} (hpzero : p ≠ 0) (hp : aeval s p = 0) :
aeval s p.primPart = 0 := by
rw [eq_C_content_mul_primPart p, map_mul, aeval_C] at hp
refine eq_zero_of_ne_zero_of_mul_left_eq_zero ?_ hp
rwa [(FaithfulSMul.algebraMap_injective R S).ne_iff' (map_zero _), Ne, content_eq_zero_iff]
theorem eval₂_primPart_eq_zero {S : Type*} [CommSemiring S] [IsDomain S] {f : R →+* S}
(hinj : Function.Injective f) {p : R[X]} {s : S} (hpzero : p ≠ 0) (hp : eval₂ f s p = 0) :
eval₂ f s p.primPart = 0 := by
rw [eq_C_content_mul_primPart p, eval₂_mul, eval₂_C] at hp
refine eq_zero_of_ne_zero_of_mul_left_eq_zero ?_ hp
rwa [hinj.ne_iff' (map_zero _), Ne, content_eq_zero_iff]
end PrimPart
theorem gcd_content_eq_of_dvd_sub {a : R} {p q : R[X]} (h : C a ∣ p - q) :
GCDMonoid.gcd a p.content = GCDMonoid.gcd a q.content := by
rw [content_eq_gcd_range_of_lt p (max p.natDegree q.natDegree).succ
(lt_of_le_of_lt (le_max_left _ _) (Nat.lt_succ_self _))]
rw [content_eq_gcd_range_of_lt q (max p.natDegree q.natDegree).succ
(lt_of_le_of_lt (le_max_right _ _) (Nat.lt_succ_self _))]
apply Finset.gcd_eq_of_dvd_sub
intro x _
obtain ⟨w, hw⟩ := h
use w.coeff x
rw [← coeff_sub, hw, coeff_C_mul]
theorem content_mul_aux {p q : R[X]} :
GCDMonoid.gcd (p * q).eraseLead.content p.leadingCoeff =
GCDMonoid.gcd (p.eraseLead * q).content p.leadingCoeff := by
rw [gcd_comm (content _) _, gcd_comm (content _) _]
apply gcd_content_eq_of_dvd_sub
rw [← self_sub_C_mul_X_pow, ← self_sub_C_mul_X_pow, sub_mul, sub_sub, add_comm, sub_add,
sub_sub_cancel, leadingCoeff_mul, RingHom.map_mul, mul_assoc, mul_assoc]
apply dvd_sub (Dvd.intro _ rfl) (Dvd.intro _ rfl)
@[simp]
theorem content_mul {p q : R[X]} : (p * q).content = p.content * q.content := by
classical
suffices h :
∀ (n : ℕ) (p q : R[X]), (p * q).degree < n → (p * q).content = p.content * q.content by
apply h
apply lt_of_le_of_lt degree_le_natDegree (WithBot.coe_lt_coe.2 (Nat.lt_succ_self _))
intro n p q hpq
induction n generalizing p q with
| zero =>
rw [Nat.cast_zero, Nat.WithBot.lt_zero_iff, degree_eq_bot, mul_eq_zero] at hpq
rcases hpq with (rfl | rfl) <;> simp
| succ n ih => ?_
by_cases p0 : p = 0
· simp [p0]
by_cases q0 : q = 0
· simp [q0]
rw [degree_eq_natDegree (mul_ne_zero p0 q0), Nat.cast_lt,
Nat.lt_succ_iff_lt_or_eq, ← Nat.cast_lt (α := WithBot ℕ),
← degree_eq_natDegree (mul_ne_zero p0 q0), natDegree_mul p0 q0] at hpq
rcases hpq with (hlt | heq)
· apply ih _ _ hlt
rw [← p.natDegree_primPart, ← q.natDegree_primPart, ← Nat.cast_inj (R := WithBot ℕ),
Nat.cast_add, ← degree_eq_natDegree p.primPart_ne_zero,
← degree_eq_natDegree q.primPart_ne_zero] at heq
rw [p.eq_C_content_mul_primPart, q.eq_C_content_mul_primPart]
suffices h : (q.primPart * p.primPart).content = 1 by
rw [mul_assoc, content_C_mul, content_C_mul, mul_comm p.primPart, mul_assoc, content_C_mul,
content_C_mul, h, mul_one, content_primPart, content_primPart, mul_one, mul_one]
rw [← normalize_content, normalize_eq_one, isUnit_iff_dvd_one,
content_eq_gcd_leadingCoeff_content_eraseLead, leadingCoeff_mul, gcd_comm]
apply (gcd_mul_dvd_mul_gcd _ _ _).trans
rw [content_mul_aux, ih, content_primPart, mul_one, gcd_comm, ←
content_eq_gcd_leadingCoeff_content_eraseLead, content_primPart, one_mul,
mul_comm q.primPart, content_mul_aux, ih, content_primPart, mul_one, gcd_comm, ←
content_eq_gcd_leadingCoeff_content_eraseLead, content_primPart]
· rw [← heq, degree_mul, WithBot.add_lt_add_iff_right]
· apply degree_erase_lt p.primPart_ne_zero
· rw [Ne, degree_eq_bot]
apply q.primPart_ne_zero
· rw [mul_comm, ← heq, degree_mul, WithBot.add_lt_add_iff_left]
· apply degree_erase_lt q.primPart_ne_zero
· rw [Ne, degree_eq_bot]
apply p.primPart_ne_zero
theorem IsPrimitive.mul {p q : R[X]} (hp : p.IsPrimitive) (hq : q.IsPrimitive) :
(p * q).IsPrimitive := by
rw [isPrimitive_iff_content_eq_one, content_mul, hp.content_eq_one, hq.content_eq_one, mul_one]
@[simp]
theorem primPart_mul {p q : R[X]} (h0 : p * q ≠ 0) :
(p * q).primPart = p.primPart * q.primPart := by
rw [Ne, ← content_eq_zero_iff, ← C_eq_zero] at h0
apply mul_left_cancel₀ h0
conv_lhs =>
rw [← (p * q).eq_C_content_mul_primPart, p.eq_C_content_mul_primPart,
q.eq_C_content_mul_primPart]
rw [content_mul, RingHom.map_mul]
ring
theorem IsPrimitive.dvd_primPart_iff_dvd {p q : R[X]} (hp : p.IsPrimitive) (hq : q ≠ 0) :
p ∣ q.primPart ↔ p ∣ q := by
refine ⟨fun h => h.trans (Dvd.intro_left _ q.eq_C_content_mul_primPart.symm), fun h => ?_⟩
rcases h with ⟨r, rfl⟩
apply Dvd.intro _
rw [primPart_mul hq, hp.primPart_eq]
theorem exists_primitive_lcm_of_isPrimitive {p q : R[X]} (hp : p.IsPrimitive) (hq : q.IsPrimitive) :
∃ r : R[X], r.IsPrimitive ∧ ∀ s : R[X], p ∣ s ∧ q ∣ s ↔ r ∣ s := by
classical
have h : ∃ (n : ℕ) (r : R[X]), r.natDegree = n ∧ r.IsPrimitive ∧ p ∣ r ∧ q ∣ r :=
⟨(p * q).natDegree, p * q, rfl, hp.mul hq, dvd_mul_right _ _, dvd_mul_left _ _⟩
rcases Nat.find_spec h with ⟨r, rdeg, rprim, pr, qr⟩
refine ⟨r, rprim, fun s => ⟨?_, fun rs => ⟨pr.trans rs, qr.trans rs⟩⟩⟩
suffices hs : ∀ (n : ℕ) (s : R[X]), s.natDegree = n → p ∣ s ∧ q ∣ s → r ∣ s from
hs s.natDegree s rfl
clear s
by_contra! con
rcases Nat.find_spec con with ⟨s, sdeg, ⟨ps, qs⟩, rs⟩
have s0 : s ≠ 0 := by
contrapose! rs
simp [rs]
have hs :=
Nat.find_min' h
⟨_, s.natDegree_primPart, s.isPrimitive_primPart, (hp.dvd_primPart_iff_dvd s0).2 ps,
(hq.dvd_primPart_iff_dvd s0).2 qs⟩
rw [← rdeg] at hs
by_cases! sC : s.natDegree ≤ 0
· rw [eq_C_of_natDegree_le_zero (le_trans hs sC), isPrimitive_iff_content_eq_one, content_C,
normalize_eq_one] at rprim
rw [eq_C_of_natDegree_le_zero (le_trans hs sC), ← dvd_content_iff_C_dvd] at rs
apply rs rprim.dvd
have hcancel := natDegree_cancelLeads_lt_of_natDegree_le_natDegree hs sC
rw [sdeg] at hcancel
apply Nat.find_min con hcancel
refine
⟨_, rfl, ⟨dvd_cancelLeads_of_dvd_of_dvd pr ps, dvd_cancelLeads_of_dvd_of_dvd qr qs⟩,
fun rcs => rs ?_⟩
rw [← rprim.dvd_primPart_iff_dvd s0]
rw [cancelLeads, tsub_eq_zero_iff_le.mpr hs, pow_zero, mul_one] at rcs
have h :=
dvd_add rcs (Dvd.intro_left (C (leadingCoeff s) * X ^ (natDegree s - natDegree r)) rfl)
have hC0 := rprim.ne_zero
rw [Ne, ← leadingCoeff_eq_zero, ← C_eq_zero] at hC0
rw [sub_add_cancel, ← rprim.dvd_primPart_iff_dvd (mul_ne_zero hC0 s0)] at h
rcases isUnit_primPart_C r.leadingCoeff with ⟨u, hu⟩
apply h.trans (Associated.symm ⟨u, _⟩).dvd
rw [primPart_mul (mul_ne_zero hC0 s0), hu, mul_comm]
theorem dvd_iff_content_dvd_content_and_primPart_dvd_primPart {p q : R[X]} (hq : q ≠ 0) :
p ∣ q ↔ p.content ∣ q.content ∧ p.primPart ∣ q.primPart := by
constructor
· rintro ⟨r, rfl⟩
rw [content_mul, p.isPrimitive_primPart.dvd_primPart_iff_dvd hq]
exact ⟨dvd_mul_right .., dvd_mul_of_dvd_left p.primPart_dvd _⟩
· rintro ⟨h₁, h₂⟩
rw [p.eq_C_content_mul_primPart, q.eq_C_content_mul_primPart]
gcongr
noncomputable instance (priority := 100) normalizedGcdMonoid : NormalizedGCDMonoid R[X] :=
letI := Classical.decEq R
normalizedGCDMonoidOfExistsLCM fun p q => by
rcases exists_primitive_lcm_of_isPrimitive p.isPrimitive_primPart
q.isPrimitive_primPart with
⟨r, rprim, hr⟩
refine ⟨C (lcm p.content q.content) * r, fun s => ?_⟩
by_cases hs : s = 0
· simp [hs]
by_cases hpq : C (lcm p.content q.content) = 0
· rw [C_eq_zero, lcm_eq_zero_iff, content_eq_zero_iff, content_eq_zero_iff] at hpq
rcases hpq with (hpq | hpq) <;> simp [hpq, hs]
iterate 3 rw [dvd_iff_content_dvd_content_and_primPart_dvd_primPart hs]
rw [content_mul, rprim.content_eq_one, mul_one, content_C, normalize_lcm, lcm_dvd_iff,
primPart_mul (mul_ne_zero hpq rprim.ne_zero), rprim.primPart_eq,
(isUnit_primPart_C (lcm p.content q.content)).mul_left_dvd, ← hr s.primPart]
tauto
theorem degree_gcd_le_left {p : R[X]} (hp : p ≠ 0) (q) : (gcd p q).degree ≤ p.degree := by
have := natDegree_le_iff_degree_le.mp (natDegree_le_of_dvd (gcd_dvd_left p q) hp)
rwa [degree_eq_natDegree hp]
theorem degree_gcd_le_right (p) {q : R[X]} (hq : q ≠ 0) : (gcd p q).degree ≤ q.degree := by
rw [gcd_comm]
exact degree_gcd_le_left hq p
end NormalizedGCDMonoid
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/DegreeLT.lean | import Mathlib.Algebra.Polynomial.Div
import Mathlib.Algebra.Polynomial.Taylor
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.Block
import Mathlib.RingTheory.Polynomial.Basic
/-!
# Polynomials with degree strictly less than `n`
This file contains the properties of the submodule of polynomials of degree less than `n` in a
(semi)ring `R`, denoted `R[X]_n`.
## Main definitions/lemmas
* `degreeLT.basis R n`: a basis for `R[X]_n` the submodule of polynomials with degree `< n`,
given by the monomials `X^i` for `i < n`.
* `degreeLT.basisProd R m n`: a basis for `R[X]_m × R[X]_n`, which is the sum of two instances of
the basis given above.
* `degreeLT.addLinearEquiv R m n`: an isomorphism between `R[X]_(m + n)` and `R[X]_m × R[X]_n`,
given by the fact that the bases are both indexed by `Fin (m + n)`. This is used for the Sylvester
matrix, which is the matrix representing the Sylvester map between these two spaces, in a future
file.
* `taylorLinear r n`: The linear automorphism induced by `taylor r` on `R[X]_n` which sends `X` to
`X + r` and preserves degrees.
-/
open Module
namespace Polynomial
@[inherit_doc] scoped notation:9000 R "[X]_" n:arg => Polynomial.degreeLT R n
namespace degreeLT
variable {R : Type*} [Semiring R] {m n : ℕ} (i : Fin n) (P : R[X]_n)
variable (R) in
/-- Basis for `R[X]_n` given by `X^i` with `i < n`. -/
noncomputable def basis (n : ℕ) : Basis (Fin n) R R[X]_n :=
.ofEquivFun (degreeLTEquiv R n)
instance : Module.Finite R R[X]_n := .of_basis <| basis ..
instance : Module.Free R R[X]_n := .of_basis <| basis ..
@[simp] lemma basis_repr : (basis R n).repr P i = (P : R[X]).coeff i :=
rfl
@[simp] lemma basis_val : (basis R n i : R[X]) = X ^ (i : ℕ) := by
change _ = ((⟨X ^ (i : ℕ), mem_degreeLT.2 <| (degree_X_pow_le i).trans_lt <|
Nat.cast_lt.2 i.is_lt⟩ : R[X]_n) : R[X])
refine congr_arg _ (Basis.apply_eq_iff.2 <| Finsupp.ext fun j ↦ ?_)
simp only [basis_repr, coeff_X_pow, eq_comm, Finsupp.single_apply, Fin.ext_iff]
variable (R m n) in
/-- Basis for `R[X]_m × R[X]_n`. -/
noncomputable def basisProd : Basis (Fin (m + n)) R (R[X]_m × R[X]_n) :=
((basis R m).prod (basis R n)).reindex finSumFinEquiv
@[simp] lemma basisProd_castAdd (m n : ℕ) (i : Fin m) :
basisProd R m n (i.castAdd n) = (basis R m i, 0) := by
rw [basisProd, Basis.reindex_apply, finSumFinEquiv_symm_apply_castAdd, Basis.prod_apply,
Sum.elim_inl, LinearMap.coe_inl, Function.comp_apply]
@[simp] lemma basisProd_natAdd (m n : ℕ) (i : Fin n) :
basisProd R m n (i.natAdd m) = (0, basis R n i) := by
rw [basisProd, Basis.reindex_apply, finSumFinEquiv_symm_apply_natAdd, Basis.prod_apply,
Sum.elim_inr, LinearMap.coe_inr, Function.comp_apply]
variable (R m n) in
/-- An isomorphism between `R[X]_(m + n)` and `R[X]_m × R[X]_n` given by the fact that the bases are
both indexed by `Fin (m + n)`. -/
noncomputable def addLinearEquiv :
R[X]_(m + n) ≃ₗ[R] R[X]_m × R[X]_n :=
Basis.equiv (basis ..) (basisProd ..) (Equiv.refl _)
lemma addLinearEquiv_castAdd (i : Fin m) :
addLinearEquiv R m n (basis R (m + n) (i.castAdd n)) = (basis R m i, 0) := by
rw [addLinearEquiv, Basis.equiv_apply, Equiv.refl_apply, basisProd_castAdd]
lemma addLinearEquiv_natAdd (i : Fin n) :
addLinearEquiv R m n (basis R (m + n) (i.natAdd m)) = (0, basis R n i) := by
rw [addLinearEquiv, Basis.equiv_apply, Equiv.refl_apply, basisProd_natAdd]
lemma addLinearEquiv_symm_apply_inl_basis (i : Fin m) :
(addLinearEquiv R m n).symm (LinearMap.inl R _ _ (basis R m i)) =
basis R (m + n) (i.castAdd n) :=
(LinearEquiv.symm_apply_eq _).2 (addLinearEquiv_castAdd i).symm
lemma addLinearEquiv_symm_apply_inr_basis (j : Fin n) :
(addLinearEquiv R m n).symm (LinearMap.inr R _ _ (basis R n j)) =
basis R (m + n) (j.natAdd m) :=
(LinearEquiv.symm_apply_eq _).2 (addLinearEquiv_natAdd j).symm
lemma addLinearEquiv_symm_apply_inl (P : R[X]_m) :
((addLinearEquiv R m n).symm (LinearMap.inl R _ _ P) : R[X]) = (P : R[X]) := by
rw [← (basis ..).sum_repr P]
simp [-LinearMap.coe_inl, addLinearEquiv_symm_apply_inl_basis]
lemma addLinearEquiv_symm_apply_inr (Q : R[X]_n) :
((addLinearEquiv R m n).symm (LinearMap.inr R _ _ Q) : R[X]) = (Q : R[X]) * X ^ (m : ℕ) := by
rw [← (basis ..).sum_repr Q]
simp [-LinearMap.coe_inr, Finset.sum_mul, addLinearEquiv_symm_apply_inr_basis,
smul_eq_C_mul, mul_assoc, ← pow_add, add_comm]
lemma addLinearEquiv_symm_apply (PQ) :
((addLinearEquiv R m n).symm PQ : R[X]) = (PQ.1 : R[X]) + (PQ.2 : R[X]) * X ^ (m : ℕ) := calc
_ = ((addLinearEquiv R m n).symm (LinearMap.inl R _ _ PQ.1 + LinearMap.inr R _ _ PQ.2) : R[X]) :=
by rw [LinearMap.inl_apply, LinearMap.inr_apply, Prod.add_def, add_zero, zero_add]
_ = _ := by rw [map_add, Submodule.coe_add,
addLinearEquiv_symm_apply_inl, addLinearEquiv_symm_apply_inr]
lemma addLinearEquiv_symm_apply' (PQ) :
((addLinearEquiv R m n).symm PQ : R[X]) = (PQ.1 : R[X]) + X ^ (m : ℕ) * (PQ.2 : R[X]) := by
rw [X_pow_mul, addLinearEquiv_symm_apply]
lemma addLinearEquiv_apply' {R : Type*} [Ring R] (f) :
((addLinearEquiv R m n f).1 : R[X]) = f %ₘ (X ^ m) ∧
((addLinearEquiv R m n f).2 : R[X]) = f /ₘ (X ^ m) := by
rw [and_comm, eq_comm, eq_comm (b := _ %ₘ _)]
nontriviality R; refine div_modByMonic_unique _ _ (monic_X_pow _) ⟨?_, ?_⟩
· rw [← addLinearEquiv_symm_apply', LinearEquiv.symm_apply_apply]
· rw [degree_X_pow, ← mem_degreeLT]; exact Subtype.prop _
lemma addLinearEquiv_apply_fst {R : Type*} [Ring R] (f) :
((addLinearEquiv R m n f).1 : R[X]) = f %ₘ (X ^ m) :=
(addLinearEquiv_apply' f).1
lemma addLinearEquiv_apply_snd {R : Type*} [Ring R] (f) :
((addLinearEquiv R m n f).2 : R[X]) = f /ₘ (X ^ m) :=
(addLinearEquiv_apply' f).2
lemma addLinearEquiv_apply {R : Type*} [Ring R] (f) :
addLinearEquiv R m n f =
(⟨f %ₘ (X ^ m), addLinearEquiv_apply_fst f ▸ Subtype.prop _⟩,
⟨f /ₘ (X ^ m), addLinearEquiv_apply_snd f ▸ Subtype.prop _⟩) :=
Prod.ext (Subtype.ext <| addLinearEquiv_apply_fst f) (Subtype.ext <| addLinearEquiv_apply_snd f)
end degreeLT
section taylor
variable {R : Type*} [CommRing R] {r : R} {m n : ℕ} {s : R} {f g : R[X]}
@[simp]
lemma taylor_mem_degreeLT : taylor r f ∈ R[X]_n ↔ f ∈ R[X]_n := by simp [mem_degreeLT]
lemma comap_taylorEquiv_degreeLT : (R[X]_n).comap (taylorEquiv r) = R[X]_n := by
ext; simp [taylorEquiv]
lemma map_taylorEquiv_degreeLT : (R[X]_n).map (taylorEquiv r) = R[X]_n := by
nth_rw 1 [← comap_taylorEquiv_degreeLT (r := r),
Submodule.map_comap_eq_of_surjective (taylorEquiv r).surjective]
/-- The map `taylor r` induces an automorphism of the module `R[X]_n` of polynomials of
degree `< n`. -/
@[simps! apply_coe]
noncomputable def taylorLinearEquiv (r : R) (n : ℕ) : R[X]_n ≃ₗ[R] R[X]_n :=
(taylorEquiv r : R[X] ≃ₗ[R] R[X]).ofSubmodules _ _ map_taylorEquiv_degreeLT
@[simp] lemma taylorLinearEquiv_symm (r : R) :
(taylorLinearEquiv r n).symm = taylorLinearEquiv (-r) n :=
LinearEquiv.ext <| fun _ ↦ rfl
@[simp] theorem det_taylorLinearEquiv_toLinearMap :
(taylorLinearEquiv r n).toLinearMap.det = 1 := by
nontriviality R
rw [← LinearMap.det_toMatrix (degreeLT.basis R n),
Matrix.det_of_upperTriangular, Fintype.prod_eq_one]
· intro i
rw [LinearMap.toMatrix_apply, degreeLT.basis_repr, ← natDegree_X_pow (R := R) (i : ℕ)]
change (taylor r (degreeLT.basis R n i)).coeff _ = 1
rw [degreeLT.basis_val, coeff_taylor_natDegree, leadingCoeff_X_pow]
· intro i j hji
rw [LinearMap.toMatrix_apply, LinearEquiv.coe_coe, degreeLT.basis_repr]
change (taylor r (degreeLT.basis R n j)).coeff i = 0
rw [degreeLT.basis_val, coeff_eq_zero_of_degree_lt (by simpa [-taylor_X_pow, -taylor_pow])]
@[simp] theorem det_taylorLinearEquiv :
(taylorLinearEquiv r n).det = 1 :=
Units.ext <| by rw [LinearEquiv.coe_det, det_taylorLinearEquiv_toLinearMap, Units.val_one]
end taylor
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/GaussNorm.lean | import Mathlib.RingTheory.PowerSeries.GaussNorm
/-!
# Gauss norm for polynomials
This file defines the Gauss norm for polynomials. Given a polynomial `p` in `R[X]`, a function
`v : R → ℝ` and a real number `c`, the Gauss norm is defined as the supremum of the set of all
values of `v (p.coeff i) * c ^ i` for all `i` in the support of `p`.
In the file `Mathlib/RingTheory/PowerSeries/GaussNorm.lean`, the Gauss norm is defined for power
series. This is a generalization of the Gauss norm defined in this file in case `v` is a
non-negative function with `v 0 = 0` and `c ≥ 0`.
## Main Definitions and Results
* `Polynomial.gaussNorm` is the supremum of the set of all values of `v (p.coeff i) * c ^ i`
for all `i` in the support of `p`, where `p` is a polynomial in `R[X]`, `v : R → ℝ` is a function
and `c` is a real number.
* `Polynomial.gaussNorm_coe_powerSeries`: if `v` is a non-negative function with `v 0 = 0` and `c`
is nonnegative, the Gauss norm of a polynomial is equal to its Gauss norm as a power series.
* `Polynomial.gaussNorm_nonneg`: if `v` is a non-negative function, then the Gauss norm is
non-negative.
* `Polynomial.gaussNorm_eq_zero_iff`: if `v x = 0 ↔ x = 0` for all `x : R`, then the Gauss
norm is zero if and only if the polynomial is zero.
-/
variable {R F : Type*} [Semiring R] [FunLike F R ℝ] (v : F) (c : ℝ)
namespace Polynomial
variable (p : R[X])
/-- Given a polynomial `p` in `R[X]`, a function `v : R → ℝ` and a real number `c`, the Gauss norm
is defined as the supremum of the set of all values of `v (p.coeff i) * c ^ i` for all `i` in the
support of `p`. -/
def gaussNorm : ℝ := if h : p.support.Nonempty then p.support.sup' h fun i ↦
(v (p.coeff i) * c ^ i) else 0
@[simp]
lemma gaussNorm_zero : gaussNorm v c 0 = 0 := by simp [gaussNorm]
theorem exists_eq_gaussNorm [ZeroHomClass F R ℝ] :
∃ i, p.gaussNorm v c = v (p.coeff i) * c ^ i := by
by_cases h_supp : p.support.Nonempty
· simp only [gaussNorm, h_supp]
obtain ⟨i, hi1, hi2⟩ := Finset.exists_mem_eq_sup' h_supp fun i ↦ (v (p.coeff i) * c ^ i)
exact ⟨i, hi2⟩
· simp_all
@[simp]
lemma gaussNorm_C [ZeroHomClass F R ℝ] (r : R) : (C r).gaussNorm v c = v r := by
by_cases hr : r = 0 <;> simp [gaussNorm, support_C, hr]
@[simp]
theorem gaussNorm_monomial [ZeroHomClass F R ℝ] (n : ℕ) (r : R) :
(monomial n r).gaussNorm v c = v r * c ^ n := by
by_cases hr : r = 0 <;> simp [gaussNorm, support_monomial, hr]
variable {c}
private lemma sup'_nonneg_of_ne_zero [NonnegHomClass F R ℝ] {p : R[X]} (h : p.support.Nonempty)
(hc : 0 ≤ c) : 0 ≤ p.support.sup' h fun i ↦ (v (p.coeff i) * c ^ i) := by
simp only [Finset.le_sup'_iff, mem_support_iff]
use p.natDegree
simp_all only [support_nonempty, ne_eq, coeff_natDegree, leadingCoeff_eq_zero, not_false_eq_true,
true_and]
positivity
private lemma aux_bdd [ZeroHomClass F R ℝ] : BddAbove {x | ∃ i, v (p.coeff i) * c ^ i = x} := by
let f : p.support → ℝ := fun i ↦ v (p.coeff i) * c ^ i.val
have h_fin : (f '' ⊤ ∪ {0}).Finite := by
apply Set.Finite.union _ <| Set.finite_singleton 0
apply Set.Finite.image f
rw [Set.top_eq_univ, Set.finite_univ_iff, ← @Finset.coe_sort_coe]
exact Finite.of_fintype p.support
apply Set.Finite.bddAbove <| Set.Finite.subset h_fin _
intro x hx
obtain ⟨i, hi⟩ := hx
rw [← hi]
by_cases hi : i ∈ p.support
· left
use ⟨i, hi⟩
simp [f]
· right
simp [Polynomial.notMem_support_iff.mp hi]
@[simp]
theorem gaussNorm_coe_powerSeries [ZeroHomClass F R ℝ] [NonnegHomClass F R ℝ]
(hc : 0 ≤ c) : (p.toPowerSeries).gaussNorm v c = p.gaussNorm v c := by
by_cases hp : p = 0
· simp [hp]
· simp only [PowerSeries.gaussNorm, coeff_coe, gaussNorm, support_nonempty, ne_eq, hp,
not_false_eq_true, ↓reduceDIte]
apply le_antisymm
· apply ciSup_le
intro n
by_cases h : n ∈ p.support
· exact Finset.le_sup' (fun j ↦ v (p.coeff j) * c ^ j) h
· simp_all [sup'_nonneg_of_ne_zero v (support_nonempty.mpr hp) hc]
· obtain ⟨i, hi⟩ := exists_eq_gaussNorm v c p
simp only [gaussNorm, support_nonempty.mpr hp, ↓reduceDIte] at hi
rw [hi]
exact le_ciSup (aux_bdd v p) i
@[simp]
theorem gaussNorm_eq_zero_iff [ZeroHomClass F R ℝ] [NonnegHomClass F R ℝ]
(h_eq_zero : ∀ x : R, v x = 0 → x = 0) (hc : 0 < c) : p.gaussNorm v c = 0 ↔ p = 0 := by
rw [← gaussNorm_coe_powerSeries _ _ (le_of_lt hc),
PowerSeries.gaussNorm_eq_zero_iff h_eq_zero hc (by simpa only [coeff_coe] using aux_bdd v p),
coe_eq_zero_iff]
theorem gaussNorm_nonneg (hc : 0 ≤ c) [NonnegHomClass F R ℝ] : 0 ≤ p.gaussNorm v c := by
by_cases hp : p.support.Nonempty <;>
simp_all [gaussNorm, sup'_nonneg_of_ne_zero, -Finset.le_sup'_iff]
lemma le_gaussNorm [ZeroHomClass F R ℝ] [NonnegHomClass F R ℝ] (hc : 0 ≤ c) (i : ℕ) :
v (p.coeff i) * c ^ i ≤ p.gaussNorm v c := by
rw [← gaussNorm_coe_powerSeries _ _ hc, ← coeff_coe]
apply PowerSeries.le_gaussNorm
simpa using aux_bdd v p
end Polynomial
namespace PowerSeries
variable {c} (r : R)
@[simp]
theorem gaussNorm_C [ZeroHomClass F R ℝ] [NonnegHomClass F R ℝ] (hc : 0 ≤ c) :
(C r).gaussNorm v c = v r := by
simp [← Polynomial.coe_C, hc]
@[simp]
theorem gaussNorm_monomial [ZeroHomClass F R ℝ] [NonnegHomClass F R ℝ] (hc : 0 ≤ c) (n : ℕ) :
(monomial n r).gaussNorm v c = v r * c ^ n := by
simp [← Polynomial.coe_monomial, hc]
end PowerSeries |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/SmallDegreeVieta.lean | import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.LinearCombination
import Mathlib.RingTheory.Polynomial.Vieta
/-!
# Vieta's Formula for polynomial of small degrees.
-/
namespace Polynomial
variable {R T S : Type*}
lemma eq_quadratic_of_degree_le_two [Semiring R] {p : R[X]} (hp : p.degree ≤ 2) :
p = C (p.coeff 2) * X ^ 2 + C (p.coeff 1) * X + C (p.coeff 0) := by
rw [p.as_sum_range_C_mul_X_pow'
(Nat.lt_of_le_of_lt (natDegree_le_iff_degree_le.mpr hp) (Nat.lt_add_one 2))]
simp [Finset.sum_range_succ]
abel
/-- **Vieta's formula** for quadratics. -/
lemma eq_neg_mul_add_of_roots_quadratic_eq_pair [CommRing R] [IsDomain R] {a b c x1 x2 : R}
(hroots : (C a * X ^ 2 + C b * X + C c).roots = {x1, x2}) :
b = -a * (x1 + x2) := by
let p : R[X] := C a * X ^ 2 + C b * X + C c
have hp_natDegree : p.natDegree = 2 := le_antisymm natDegree_quadratic_le
(by convert p.card_roots'; rw [hroots, Multiset.card_pair])
have hp_roots_card : p.roots.card = p.natDegree := by
rw [hp_natDegree, hroots, Multiset.card_pair]
simpa [leadingCoeff, hp_natDegree, p, hroots, mul_assoc, add_comm x1] using
coeff_eq_esymm_roots_of_card hp_roots_card (k := 1) (by simp [hp_natDegree])
/-- **Vieta's formula** for quadratics. -/
lemma eq_mul_mul_of_roots_quadratic_eq_pair [CommRing R] [IsDomain R] {a b c x1 x2 : R}
(hroots : (C a * X ^ 2 + C b * X + C c).roots = {x1, x2}) :
c = a * x1 * x2 := by
let p : R[X] := C a * X ^ 2 + C b * X + C c
have hp_natDegree : p.natDegree = 2 := le_antisymm natDegree_quadratic_le
(by convert p.card_roots'; rw [hroots, Multiset.card_pair])
have hp_roots_card : p.roots.card = p.natDegree := by
rw [hp_natDegree, hroots, Multiset.card_pair]
simpa [leadingCoeff, hp_natDegree, p, hroots, mul_assoc, add_comm x1] using
coeff_eq_esymm_roots_of_card hp_roots_card (k := 0) (by simp [hp_natDegree])
/-- **Vieta's formula** for quadratics (`aroots` version). -/
lemma eq_neg_mul_add_of_aroots_quadratic_eq_pair
[CommRing T] [CommRing S] [IsDomain S] [Algebra T S] {a b c : T} {x1 x2 : S}
(haroots : (C a * X ^ 2 + C b * X + C c).aroots S = {x1, x2}) :
algebraMap T S b = -algebraMap T S a * (x1 + x2) := by
rw [aroots_def, show map (algebraMap T S) (C a * X ^ 2 + C b * X + C c) = C ((algebraMap T S) a) *
X ^ 2 + C ((algebraMap T S) b) * X + C ((algebraMap T S) c) by simp] at haroots
exact eq_neg_mul_add_of_roots_quadratic_eq_pair haroots
/-- **Vieta's formula** for quadratics (`aroots` version). -/
lemma eq_mul_mul_of_aroots_quadratic_eq_pair [CommRing T] [CommRing S] [IsDomain S] [Algebra T S]
{a b c : T} {x1 x2 : S} (haroots : (C a * X ^ 2 + C b * X + C c).aroots S = {x1, x2}) :
algebraMap T S c = algebraMap T S a * x1 * x2 := by
rw [aroots_def, show map (algebraMap T S) (C a * X ^ 2 + C b * X + C c) = C ((algebraMap T S) a) *
X ^ 2 + C ((algebraMap T S) b) * X + C ((algebraMap T S) c) by simp] at haroots
exact eq_mul_mul_of_roots_quadratic_eq_pair haroots
/-- **Vieta's formula** for quadratics as an iff. -/
lemma roots_quadratic_eq_pair_iff_of_ne_zero [CommRing R] [IsDomain R] {a b c x1 x2 : R}
(ha : a ≠ 0) :
(C a * X ^ 2 + C b * X + C c).roots = {x1, x2} ↔
b = -a * (x1 + x2) ∧ c = a * x1 * x2 :=
have roots_of_ne_zero_of_vieta (hvieta : b = -a * (x1 + x2) ∧ c = a * x1 * x2) :
(C a * X ^ 2 + C b * X + C c).roots = {x1, x2} := by
suffices C a * X ^ 2 + C b * X + C c = C a * (X - C x1) * (X - C x2) by
have h1 : C a * (X - C x1) ≠ 0 := mul_ne_zero (by simpa) (Polynomial.X_sub_C_ne_zero _)
have h2 : C a * (X - C x1) * (X - C x2) ≠ 0 := mul_ne_zero h1 (Polynomial.X_sub_C_ne_zero _)
simp [this, Polynomial.roots_mul h2, Polynomial.roots_mul h1]
simpa [hvieta.1, hvieta.2] using by ring
⟨fun h => ⟨eq_neg_mul_add_of_roots_quadratic_eq_pair h, eq_mul_mul_of_roots_quadratic_eq_pair h⟩,
roots_of_ne_zero_of_vieta⟩
/-- **Vieta's formula** for quadratics as an iff (`aroots` version). -/
lemma aroots_quadratic_eq_pair_iff_of_ne_zero [CommRing T] [CommRing S] [IsDomain S]
[Algebra T S] {a b c : T} {x1 x2 : S} (ha : algebraMap T S a ≠ 0) :
(C a * X ^ 2 + C b * X + C c).aroots S = {x1, x2} ↔
algebraMap T S b = -algebraMap T S a * (x1 + x2) ∧
algebraMap T S c = algebraMap T S a * x1 * x2 := by
rw [aroots_def, show map (algebraMap T S) (C a * X ^ 2 + C b * X + C c) = C ((algebraMap T S) a) *
X ^ 2 + C ((algebraMap T S) b) * X + C ((algebraMap T S) c) by simp]
exact roots_quadratic_eq_pair_iff_of_ne_zero ha
/-- **Vieta's formula** for quadratics as an iff (`Field` version). -/
lemma roots_quadratic_eq_pair_iff_of_ne_zero' [Field R] {a b c x1 x2 : R} (ha : a ≠ 0) :
(C a * X ^ 2 + C b * X + C c).roots = {x1, x2} ↔
x1 + x2 = -b / a ∧ x1 * x2 = c / a := by
rw [roots_quadratic_eq_pair_iff_of_ne_zero ha]
field_simp
exact and_congr ⟨fun h => by linear_combination h, fun h => by linear_combination h⟩
⟨fun h => by linear_combination -h, fun h => by linear_combination -h⟩
/-- **Vieta's formula** for quadratics as an iff (`aroots, Field` version). -/
lemma aroots_quadratic_eq_pair_iff_of_ne_zero' [CommRing T] [Field S] [Algebra T S] {a b c : T}
{x1 x2 : S} (ha : algebraMap T S a ≠ 0) :
(C a * X ^ 2 + C b * X + C c).aroots S = {x1, x2} ↔
x1 + x2 = -algebraMap T S b / algebraMap T S a ∧
x1 * x2 = algebraMap T S c / algebraMap T S a := by
rw [aroots_def, show map (algebraMap T S) (C a * X ^ 2 + C b * X + C c) = C ((algebraMap T S) a) *
X ^ 2 + C ((algebraMap T S) b) * X + C ((algebraMap T S) c) by simp]
exact roots_quadratic_eq_pair_iff_of_ne_zero' ha
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Vieta.lean | import Mathlib.Algebra.Polynomial.Splits
import Mathlib.RingTheory.MvPolynomial.Symmetric.Defs
/-!
# Vieta's Formula
The main result is `Multiset.prod_X_add_C_eq_sum_esymm`, which shows that the product of
linear terms `X + λ` with `λ` in a `Multiset s` is equal to a linear combination of the
symmetric functions `esymm s`.
From this, we deduce `MvPolynomial.prod_X_add_C_eq_sum_esymm` which is the equivalent formula
for the product of linear terms `X + X i` with `i` in a `Fintype σ` as a linear combination
of the symmetric polynomials `esymm σ R j`.
For `R` be an integral domain (so that `p.roots` is defined for any `p : R[X]` as a multiset),
we derive `Polynomial.coeff_eq_esymm_roots_of_card`, the relationship between the coefficients and
the roots of `p` for a polynomial `p` that splits (i.e. having as many roots as its degree).
-/
open Finset Polynomial
namespace Multiset
section Semiring
variable {R : Type*} [CommSemiring R]
/-- A sum version of **Vieta's formula** for `Multiset`: the product of the linear terms `X + λ`
where `λ` runs through a multiset `s` is equal to a linear combination of the symmetric functions
`esymm s` of the `λ`'s . -/
theorem prod_X_add_C_eq_sum_esymm (s : Multiset R) :
(s.map fun r => X + C r).prod =
∑ j ∈ Finset.range (Multiset.card s + 1), (C (s.esymm j) * X ^ (Multiset.card s - j)) := by
classical
rw [prod_map_add, antidiagonal_eq_map_powerset, map_map, ← bind_powerset_len,
map_bind, sum_bind, Finset.sum_eq_multiset_sum, Finset.range_val, map_congr (Eq.refl _)]
intro _ _
rw [esymm, ← sum_hom', ← sum_map_mul_right, map_congr (Eq.refl _)]
intro s ht
rw [mem_powersetCard] at ht
dsimp
rw [prod_hom' s (Polynomial.C : R →+* R[X])]
simp [ht, prod_replicate, map_id', card_sub]
/-- Vieta's formula for the coefficients of the product of linear terms `X + λ` where `λ` runs
through a multiset `s` : the `k`th coefficient is the symmetric function `esymm (card s - k) s`. -/
theorem prod_X_add_C_coeff (s : Multiset R) {k : ℕ} (h : k ≤ Multiset.card s) :
(s.map fun r => X + C r).prod.coeff k = s.esymm (Multiset.card s - k) := by
convert Polynomial.ext_iff.mp (prod_X_add_C_eq_sum_esymm s) k using 1
simp_rw [finset_sum_coeff, coeff_C_mul_X_pow]
rw [Finset.sum_eq_single_of_mem (Multiset.card s - k) _] <;> grind
theorem prod_X_add_C_coeff' {σ} (s : Multiset σ) (r : σ → R) {k : ℕ} (h : k ≤ Multiset.card s) :
(s.map fun i => X + C (r i)).prod.coeff k = (s.map r).esymm (Multiset.card s - k) := by
rw [← Function.comp_def (f := fun r => X + C r) (g := r), ← map_map, prod_X_add_C_coeff]
<;> rw [s.card_map r]; assumption
theorem _root_.Finset.prod_X_add_C_coeff {σ} (s : Finset σ) (r : σ → R) {k : ℕ} (h : k ≤ #s) :
(∏ i ∈ s, (X + C (r i))).coeff k = ∑ t ∈ s.powersetCard (#s - k), ∏ i ∈ t, r i := by
rw [Finset.prod, prod_X_add_C_coeff' _ r h, Finset.esymm_map_val]
rfl
end Semiring
section Ring
variable {R : Type*} [CommRing R]
theorem esymm_neg (s : Multiset R) (k : ℕ) : (map Neg.neg s).esymm k = (-1) ^ k * esymm s k := by
rw [esymm, esymm, ← Multiset.sum_map_mul_left, Multiset.powersetCard_map, Multiset.map_map,
map_congr rfl]
intro x hx
rw [(mem_powersetCard.mp hx).right.symm, ← prod_replicate, ← Multiset.map_const]
nth_rw 3 [← map_id' x]
rw [← prod_map_mul, map_congr rfl, Function.comp_apply]
exact fun z _ => neg_one_mul z
theorem prod_X_sub_X_eq_sum_esymm (s : Multiset R) :
(s.map fun t => X - C t).prod =
∑ j ∈ Finset.range (Multiset.card s + 1),
(-1) ^ j * (C (s.esymm j) * X ^ (Multiset.card s - j)) := by
conv_lhs =>
congr
congr
ext x
rw [sub_eq_add_neg]
rw [← map_neg C x]
convert prod_X_add_C_eq_sum_esymm (map (fun t => -t) s) using 1
· rw [map_map]; rfl
· simp only [esymm_neg, card_map, mul_assoc, map_mul, map_pow, map_neg, map_one]
theorem prod_X_sub_C_coeff (s : Multiset R) {k : ℕ} (h : k ≤ Multiset.card s) :
(s.map fun t => X - C t).prod.coeff k =
(-1) ^ (Multiset.card s - k) * s.esymm (Multiset.card s - k) := by
conv_lhs =>
congr
congr
congr
ext x
rw [sub_eq_add_neg]
rw [← map_neg C x]
convert prod_X_add_C_coeff (map (fun t => -t) s) _ using 1
· rw [map_map]; rfl
· rw [esymm_neg, card_map]
· rwa [card_map]
/-- Vieta's formula for the coefficients and the roots of a polynomial over an integral domain
with as many roots as its degree. -/
theorem _root_.Polynomial.coeff_eq_esymm_roots_of_card [IsDomain R] {p : R[X]}
(hroots : Multiset.card p.roots = p.natDegree) {k : ℕ} (h : k ≤ p.natDegree) :
p.coeff k = p.leadingCoeff * (-1) ^ (p.natDegree - k) * p.roots.esymm (p.natDegree - k) := by
conv_lhs => rw [← C_leadingCoeff_mul_prod_multiset_X_sub_C hroots]
rw [coeff_C_mul, mul_assoc]; congr
have : k ≤ card (roots p) := by rw [hroots]; exact h
convert p.roots.prod_X_sub_C_coeff this using 3 <;> rw [hroots]
/-- Vieta's formula for split polynomials over a field. -/
theorem _root_.Polynomial.coeff_eq_esymm_roots_of_splits {F} [Field F] {p : F[X]}
(hsplit : p.Splits (RingHom.id F)) {k : ℕ} (h : k ≤ p.natDegree) :
p.coeff k = p.leadingCoeff * (-1) ^ (p.natDegree - k) * p.roots.esymm (p.natDegree - k) :=
Polynomial.coeff_eq_esymm_roots_of_card (splits_iff_card_roots.1 hsplit) h
end Ring
end Multiset
section MvPolynomial
open Finset Polynomial Fintype
variable (R σ : Type*) [CommSemiring R] [Fintype σ]
/-- A sum version of Vieta's formula for `MvPolynomial`: viewing `X i` as variables,
the product of linear terms `λ + X i` is equal to a linear combination of
the symmetric polynomials `esymm σ R j`. -/
theorem MvPolynomial.prod_C_add_X_eq_sum_esymm :
(∏ i : σ, (Polynomial.X + Polynomial.C (MvPolynomial.X i))) =
∑ j ∈ range (card σ + 1), Polynomial.C
(MvPolynomial.esymm σ R j) * Polynomial.X ^ (card σ - j) := by
let s := Finset.univ.val.map fun i : σ => (MvPolynomial.X i : MvPolynomial σ R)
have : Fintype.card σ = Multiset.card s := by
rw [Multiset.card_map, ← Finset.card_univ, Finset.card_def]
simp_rw [this, MvPolynomial.esymm_eq_multiset_esymm σ R, Finset.prod_eq_multiset_prod]
convert Multiset.prod_X_add_C_eq_sum_esymm s
simp_rw [s, Multiset.map_map, Function.comp_apply]
theorem MvPolynomial.prod_X_add_C_coeff (k : ℕ) (h : k ≤ card σ) :
(∏ i : σ, (Polynomial.X + Polynomial.C (MvPolynomial.X i)) : Polynomial _).coeff k =
MvPolynomial.esymm σ R (card σ - k) := by
let s := Finset.univ.val.map fun i => (MvPolynomial.X i : MvPolynomial σ R)
have : Fintype.card σ = Multiset.card s := by
rw [Multiset.card_map, ← Finset.card_univ, Finset.card_def]
rw [this] at h ⊢
rw [MvPolynomial.esymm_eq_multiset_esymm σ R, Finset.prod_eq_multiset_prod]
convert Multiset.prod_X_add_C_coeff s h
dsimp
simp_rw [s, Multiset.map_map, Function.comp_apply]
end MvPolynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/IrreducibleRing.lean | import Mathlib.Algebra.Polynomial.Eval.Irreducible
import Mathlib.RingTheory.Polynomial.Nilpotent
/-!
# Polynomials over an irreducible ring
This file contains results about the polynomials over an irreducible ring (i.e. a ring with only
one minimal prime ideal, equivalently, whose spectrum is an irreducible topological space).
## Main results
- `Polynomial.Monic.irreducible_of_irreducible_map_of_isPrime_nilradical`: a monic polynomial over
an irreducible ring is irreducible if it is irreducible after mapping into an integral domain.
A generalization to `Polynomial.Monic.irreducible_of_irreducible_map`.
## Tags
polynomial, irreducible ring, nilradical, prime ideal
-/
open Polynomial
noncomputable section
/-- A polynomial over an irreducible ring `R` is irreducible if it is monic and irreducible after
mapping into an integral domain `S` (https://math.stackexchange.com/a/4843432/235999).
A generalization to `Polynomial.Monic.irreducible_of_irreducible_map`. -/
theorem Polynomial.Monic.irreducible_of_irreducible_map_of_isPrime_nilradical
{R S : Type*} [CommRing R] [(nilradical R).IsPrime] [CommRing S] [IsDomain S]
(φ : R →+* S) (f : R[X]) (hm : f.Monic) (hi : Irreducible (f.map φ)) : Irreducible f := by
let R' := R ⧸ nilradical R
let ψ : R' →+* S := Ideal.Quotient.lift (nilradical R) φ
(haveI := RingHom.ker_isPrime φ; nilradical_le_prime (RingHom.ker φ))
let ι := algebraMap R R'
rw [show φ = ψ.comp ι from rfl, ← map_map] at hi
replace hi := hm.map ι |>.irreducible_of_irreducible_map _ _ hi
refine ⟨fun h ↦ hi.1 <| (mapRingHom ι).isUnit_map h, fun a b h ↦ ?_⟩
wlog hb : IsUnit (b.map ι) generalizing a b
· exact (this b a (mul_comm a b ▸ h)
(hi.2 (by rw [h, Polynomial.map_mul]) |>.resolve_right hb)).symm
have hn (i : ℕ) (hi : i ≠ 0) : IsNilpotent (b.coeff i) := by
obtain ⟨_, _, h⟩ := Polynomial.isUnit_iff.1 hb
simpa only [coeff_map, coeff_C, hi, ite_false, ← RingHom.mem_ker,
show RingHom.ker ι = nilradical R from Ideal.mk_ker] using congr(coeff $(h.symm) i)
refine .inr <| isUnit_of_coeff_isUnit_isNilpotent (isUnit_of_mul_isUnit_right
(x := a.coeff f.natDegree) <| (IsUnit.neg_iff _).1 ?_) hn
have hc : f.leadingCoeff = _ := congr(coeff $h f.natDegree)
rw [hm, coeff_mul, Finset.Nat.sum_antidiagonal_eq_sum_range_succ fun i j ↦ a.coeff i * b.coeff j,
Finset.sum_range_succ, ← sub_eq_iff_eq_add, Nat.sub_self] at hc
rw [← add_sub_cancel_left 1 (-(_ * _)), ← sub_eq_add_neg, hc]
exact IsNilpotent.isUnit_sub_one <| show _ ∈ nilradical R from sum_mem fun i hi ↦
Ideal.mul_mem_left _ _ <| hn _ <| Nat.sub_ne_zero_of_lt (List.mem_range.1 hi) |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Opposites.lean | import Mathlib.Algebra.Polynomial.Degree.Support
import Mathlib.Tactic.NoncommRing
/-! # Interactions between `R[X]` and `Rᵐᵒᵖ[X]`
This file contains the basic API for "pushing through" the isomorphism
`opRingEquiv : R[X]ᵐᵒᵖ ≃+* Rᵐᵒᵖ[X]`. It allows going back and forth between a polynomial ring
over a semiring and the polynomial ring over the opposite semiring. -/
open Polynomial
open MulOpposite
variable {R : Type*} [Semiring R]
noncomputable section
namespace Polynomial
/-- Ring isomorphism between `R[X]ᵐᵒᵖ` and `Rᵐᵒᵖ[X]` sending each coefficient of a polynomial
to the corresponding element of the opposite ring. -/
def opRingEquiv (R : Type*) [Semiring R] : R[X]ᵐᵒᵖ ≃+* Rᵐᵒᵖ[X] :=
((toFinsuppIso R).op.trans AddMonoidAlgebra.opRingEquiv).trans (toFinsuppIso _).symm
/-! Lemmas to get started, using `opRingEquiv R` on the various expressions of
`Finsupp.single`: `monomial`, `C a`, `X`, `C a * X ^ n`. -/
@[simp]
theorem opRingEquiv_op_monomial (n : ℕ) (r : R) :
opRingEquiv R (op (monomial n r : R[X])) = monomial n (op r) := by
simp only [opRingEquiv, RingEquiv.coe_trans, Function.comp_apply,
AddMonoidAlgebra.opRingEquiv_apply, RingEquiv.op_apply_apply, toFinsuppIso_apply, unop_op,
toFinsupp_monomial, Finsupp.mapRange_single, toFinsuppIso_symm_apply, ofFinsupp_single]
@[simp]
theorem opRingEquiv_op_C (a : R) : opRingEquiv R (op (C a)) = C (op a) :=
opRingEquiv_op_monomial 0 a
@[simp]
theorem opRingEquiv_op_X : opRingEquiv R (op (X : R[X])) = X :=
opRingEquiv_op_monomial 1 1
theorem opRingEquiv_op_C_mul_X_pow (r : R) (n : ℕ) :
opRingEquiv R (op (C r * X ^ n : R[X])) = C (op r) * X ^ n := by
simp only [X_pow_mul, op_mul, op_pow, map_mul, map_pow, opRingEquiv_op_X, opRingEquiv_op_C]
/-! Lemmas to get started, using `(opRingEquiv R).symm` on the various expressions of
`Finsupp.single`: `monomial`, `C a`, `X`, `C a * X ^ n`. -/
@[simp]
theorem opRingEquiv_symm_monomial (n : ℕ) (r : Rᵐᵒᵖ) :
(opRingEquiv R).symm (monomial n r) = op (monomial n (unop r)) :=
(opRingEquiv R).injective (by simp)
@[simp]
theorem opRingEquiv_symm_C (a : Rᵐᵒᵖ) : (opRingEquiv R).symm (C a) = op (C (unop a)) :=
opRingEquiv_symm_monomial 0 a
@[simp]
theorem opRingEquiv_symm_X : (opRingEquiv R).symm (X : Rᵐᵒᵖ[X]) = op X :=
opRingEquiv_symm_monomial 1 1
theorem opRingEquiv_symm_C_mul_X_pow (r : Rᵐᵒᵖ) (n : ℕ) :
(opRingEquiv R).symm (C r * X ^ n : Rᵐᵒᵖ[X]) = op (C (unop r) * X ^ n) := by
rw [C_mul_X_pow_eq_monomial, opRingEquiv_symm_monomial, C_mul_X_pow_eq_monomial]
/-! Lemmas about more global properties of polynomials and opposites. -/
@[simp]
theorem coeff_opRingEquiv (p : R[X]ᵐᵒᵖ) (n : ℕ) :
(opRingEquiv R p).coeff n = op ((unop p).coeff n) := rfl
@[simp]
theorem support_opRingEquiv (p : R[X]ᵐᵒᵖ) : (opRingEquiv R p).support = (unop p).support :=
Finsupp.support_mapRange_of_injective (by simp) _ op_injective
@[simp]
theorem natDegree_opRingEquiv (p : R[X]ᵐᵒᵖ) : (opRingEquiv R p).natDegree = (unop p).natDegree := by
by_cases p0 : p = 0
· simp only [p0, map_zero, natDegree_zero, unop_zero]
· simp only [p0, natDegree_eq_support_max', Ne, EmbeddingLike.map_eq_zero_iff, not_false_iff,
support_opRingEquiv, unop_eq_zero_iff]
@[simp]
theorem leadingCoeff_opRingEquiv (p : R[X]ᵐᵒᵖ) :
(opRingEquiv R p).leadingCoeff = op (unop p).leadingCoeff := by
rw [leadingCoeff, coeff_opRingEquiv, natDegree_opRingEquiv, leadingCoeff]
theorem isLeftCancelMulZero_iff :
IsLeftCancelMulZero R[X] ↔ IsLeftCancelMulZero R ∧ IsCancelAdd R where
mp h := .intro (C_injective.isLeftCancelMulZero _ C_0 fun _ _ ↦ C_mul) <|
have : IsLeftCancelAdd R := .mk fun a b c eq ↦ by
nontriviality R
let trinomial (r : R) : R[X] := a • X ^ 2 + r • X + C a
have ht r : (X + C 1) * trinomial r = a • X ^ 3 + (a + r) • X ^ 2 + (a + r) • X + C a := by
simp only [trinomial, mul_add, add_mul, ← C_mul', C_1, one_mul, ← mul_assoc, X_mul_C, C_add]
noncomm_ring
simpa [trinomial] using congr_arg (coeff · 1) <|
h.1 (a₁ := trinomial b) (a₂ := trinomial c) (X_add_C_ne_zero 1) <| by simp_rw [ht, eq]
AddCommMagma.IsLeftCancelAdd.toIsCancelAdd R
mpr := fun ⟨_, _⟩ ↦ inferInstance
theorem isRightCancelMulZero_iff :
IsRightCancelMulZero R[X] ↔ IsRightCancelMulZero R ∧ IsCancelAdd R := by
rw [← MulOpposite.isLeftCancelMulZero_iff, (opRingEquiv R).isLeftCancelMulZero_iff,
isLeftCancelMulZero_iff, MulOpposite.isLeftCancelMulZero_iff, MulOpposite.isCancelAdd_iff]
protected theorem isCancelMulZero_iff :
IsCancelMulZero R[X] ↔ IsCancelMulZero R ∧ IsCancelAdd R := by
simp_rw [isCancelMulZero_iff, isLeftCancelMulZero_iff, isRightCancelMulZero_iff]
rw [and_and_and_comm, and_self]
theorem isDomain_iff : IsDomain R[X] ↔ IsDomain R ∧ IsCancelAdd R := by
simp_rw [isDomain_iff_cancelMulZero_and_nontrivial, nontrivial_iff,
Polynomial.isCancelMulZero_iff, and_right_comm]
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/HilbertPoly.lean | import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Eval.SMul
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.Order.Interval.Set.Infinite
import Mathlib.RingTheory.Polynomial.Pochhammer
import Mathlib.RingTheory.PowerSeries.WellKnown
import Mathlib.Tactic.FieldSimp
/-!
# Hilbert polynomials
In this file, we formalise the following statement: if `F` is a field with characteristic `0`, then
given any `p : F[X]` and `d : ℕ`, there exists some `h : F[X]` such that for any large enough
`n : ℕ`, `h(n)` is equal to the coefficient of `Xⁿ` in the power series expansion of `p/(1 - X)ᵈ`.
This `h` is unique and is denoted as `Polynomial.hilbertPoly p d`.
For example, given `d : ℕ`, the power series expansion of `1/(1 - X)ᵈ⁺¹` in `F[X]`
is `Σₙ ((d + n).choose d)Xⁿ`, which equals `Σₙ ((n + 1)···(n + d)/d!)Xⁿ` and hence
`Polynomial.hilbertPoly (1 : F[X]) (d + 1)` is the polynomial `(X + 1)···(X + d)/d!`. Note that
if `d! = 0` in `F`, then the polynomial `(X + 1)···(X + d)/d!` no longer works, so we do not want
`d!` to be divisible by the characteristic of `F`. As `Polynomial.hilbertPoly` may take any
`p : F[X]` and `d : ℕ` as its inputs, it is necessary for us to assume that `CharZero F`.
## Main definitions
* `Polynomial.hilbertPoly p d`. Given a field `F`, a polynomial `p : F[X]` and a natural number `d`,
if `F` is of characteristic `0`, then `Polynomial.hilbertPoly p d : F[X]` is the polynomial whose
value at `n` equals the coefficient of `Xⁿ` in the power series expansion of `p/(1 - X)ᵈ`.
## TODO
* Hilbert polynomials of finitely generated graded modules over Noetherian rings.
-/
open Nat PowerSeries
variable (F : Type*) [Field F]
namespace Polynomial
/--
For any field `F` and natural numbers `d` and `k`, `Polynomial.preHilbertPoly F d k`
is defined as `(d.factorial : F)⁻¹ • ((ascPochhammer F d).comp (X - (C (k : F)) + 1))`.
This is the most basic form of Hilbert polynomials. `Polynomial.preHilbertPoly ℚ d 0`
is exactly the Hilbert polynomial of the polynomial ring `ℚ[X_0,...,X_d]` viewed as
a graded module over itself. In fact, `Polynomial.preHilbertPoly F d k` is the
same as `Polynomial.hilbertPoly ((X : F[X]) ^ k) (d + 1)` for any field `F` and
`d k : ℕ` (see the lemma `Polynomial.hilbertPoly_X_pow_succ`). See also the lemma
`Polynomial.preHilbertPoly_eq_choose_sub_add`, which states that if `CharZero F`,
then for any `d k n : ℕ` with `k ≤ n`, `(Polynomial.preHilbertPoly F d k).eval (n : F)`
equals `(n - k + d).choose d`.
-/
noncomputable def preHilbertPoly (d k : ℕ) : F[X] :=
(d.factorial : F)⁻¹ • ((ascPochhammer F d).comp (Polynomial.X - (C (k : F)) + 1))
lemma natDegree_preHilbertPoly [CharZero F] (d k : ℕ) :
(preHilbertPoly F d k).natDegree = d := by
have hne : (d ! : F) ≠ 0 := by norm_cast; positivity
rw [preHilbertPoly, natDegree_smul _ (inv_ne_zero hne), natDegree_comp, ascPochhammer_natDegree,
add_comm_sub, ← C_1, ← map_sub, natDegree_add_C, natDegree_X, mul_one]
lemma coeff_preHilbertPoly_self [CharZero F] (d k : ℕ) :
(preHilbertPoly F d k).coeff d = (d ! : F)⁻¹ := by
delta preHilbertPoly
have hne : (d ! : F) ≠ 0 := by norm_cast; positivity
have heq : d = ((ascPochhammer F d).comp (X - C (k : F) + 1)).natDegree :=
(natDegree_preHilbertPoly F d k).symm.trans (natDegree_smul _ (inv_ne_zero hne))
nth_rw 3 [heq]
calc
_ = (d ! : F)⁻¹ • ((ascPochhammer F d).comp (X - C ((k : F) - 1))).leadingCoeff := by
simp only [sub_add, ← C_1, ← map_sub, coeff_smul, coeff_natDegree]
_ = (d ! : F)⁻¹ := by
simp only [leadingCoeff_comp (ne_of_eq_of_ne (natDegree_X_sub_C _) one_ne_zero), Monic.def.1
(monic_ascPochhammer _ _), leadingCoeff_X_sub_C, one_pow, smul_eq_mul, mul_one]
lemma leadingCoeff_preHilbertPoly [CharZero F] (d k : ℕ) :
(preHilbertPoly F d k).leadingCoeff = (d ! : F)⁻¹ := by
rw [leadingCoeff, natDegree_preHilbertPoly, coeff_preHilbertPoly_self]
lemma preHilbertPoly_eq_choose_sub_add [CharZero F] (d : ℕ) {k n : ℕ} (hkn : k ≤ n) :
(preHilbertPoly F d k).eval (n : F) = (n - k + d).choose d := by
have : (d ! : F) ≠ 0 := by norm_cast; positivity
calc
_ = (↑d !)⁻¹ * eval (↑(n - k + 1)) (ascPochhammer F d) := by simp [cast_sub hkn, preHilbertPoly]
_ = (n - k + d).choose d := by
rw [ascPochhammer_nat_eq_natCast_ascFactorial];
simp [field, ascFactorial_eq_factorial_mul_choose]
variable {F}
/--
`Polynomial.hilbertPoly p 0 = 0`; for any `d : ℕ`, `Polynomial.hilbertPoly p (d + 1)`
is defined as `∑ i ∈ p.support, (p.coeff i) • Polynomial.preHilbertPoly F d i`. If
`M` is a graded module whose Poincaré series can be written as `p(X)/(1 - X)ᵈ` for some
`p : ℚ[X]` with integer coefficients, then `Polynomial.hilbertPoly p d` is the Hilbert
polynomial of `M`. See also `Polynomial.coeff_mul_invOneSubPow_eq_hilbertPoly_eval`,
which says that `PowerSeries.coeff F n (p * PowerSeries.invOneSubPow F d)` equals
`(Polynomial.hilbertPoly p d).eval (n : F)` for any large enough `n : ℕ`.
-/
noncomputable def hilbertPoly (p : F[X]) : (d : ℕ) → F[X]
| 0 => 0
| d + 1 => ∑ i ∈ p.support, (p.coeff i) • preHilbertPoly F d i
lemma hilbertPoly_zero_left (d : ℕ) : hilbertPoly (0 : F[X]) d = 0 := by
delta hilbertPoly; induction d with
| zero => simp only
| succ d _ => simp only [coeff_zero, zero_smul, Finset.sum_const_zero]
lemma hilbertPoly_zero_right (p : F[X]) : hilbertPoly p 0 = 0 := rfl
lemma hilbertPoly_succ (p : F[X]) (d : ℕ) :
hilbertPoly p (d + 1) = ∑ i ∈ p.support, (p.coeff i) • preHilbertPoly F d i := rfl
lemma hilbertPoly_X_pow_succ (d k : ℕ) :
hilbertPoly ((X : F[X]) ^ k) (d + 1) = preHilbertPoly F d k := by
delta hilbertPoly; simp
lemma hilbertPoly_add_left (p q : F[X]) (d : ℕ) :
hilbertPoly (p + q) d = hilbertPoly p d + hilbertPoly q d := by
delta hilbertPoly
induction d with
| zero => simp only [add_zero]
| succ d _ =>
simp only
rw [← sum_def _ fun _ r => r • _]
exact sum_add_index _ _ _ (fun _ => zero_smul ..) (fun _ _ _ => add_smul ..)
lemma hilbertPoly_smul (a : F) (p : F[X]) (d : ℕ) :
hilbertPoly (a • p) d = a • hilbertPoly p d := by
delta hilbertPoly
induction d with
| zero => simp only [smul_zero]
| succ d _ =>
simp only
rw [← sum_def _ fun _ r => r • _, ← sum_def _ fun _ r => r • _, Polynomial.smul_sum,
sum_smul_index' _ _ _ fun i => zero_smul F (preHilbertPoly F d i)]
simp only [smul_assoc]
variable (F) in
/--
The function that sends any `p : F[X]` to `Polynomial.hilbertPoly p d` is an `F`-linear map from
`F[X]` to `F[X]`.
-/
noncomputable def hilbertPoly_linearMap (d : ℕ) : F[X] →ₗ[F] F[X] where
toFun p := hilbertPoly p d
map_add' p q := hilbertPoly_add_left p q d
map_smul' r p := hilbertPoly_smul r p d
variable [CharZero F]
/--
The key property of Hilbert polynomials. If `F` is a field with characteristic `0`, `p : F[X]` and
`d : ℕ`, then for any large enough `n : ℕ`, `(Polynomial.hilbertPoly p d).eval (n : F)` equals the
coefficient of `Xⁿ` in the power series expansion of `p/(1 - X)ᵈ`.
-/
theorem coeff_mul_invOneSubPow_eq_hilbertPoly_eval
{p : F[X]} (d : ℕ) {n : ℕ} (hn : p.natDegree < n) :
(p * invOneSubPow F d : F⟦X⟧).coeff n = (hilbertPoly p d).eval (n : F) := by
delta hilbertPoly; induction d with
| zero => simp only [invOneSubPow_zero, Units.val_one, mul_one, coeff_coe, eval_zero]
exact coeff_eq_zero_of_natDegree_lt hn
| succ d hd =>
simp only [eval_finset_sum, eval_smul, smul_eq_mul]
rw [← Finset.sum_coe_sort]
have h_le (i : p.support) : (i : ℕ) ≤ n :=
le_trans (le_natDegree_of_ne_zero <| mem_support_iff.1 i.2) hn.le
have h (i : p.support) : eval ↑n (preHilbertPoly F d ↑i) = (n + d - ↑i).choose d := by
rw [preHilbertPoly_eq_choose_sub_add _ _ (h_le i), Nat.sub_add_comm (h_le i)]
simp_rw [h]
rw [Finset.sum_coe_sort _ (fun x => (p.coeff ↑x) * (_ + d - ↑x).choose _),
PowerSeries.coeff_mul, Finset.Nat.sum_antidiagonal_eq_sum_range_succ_mk,
invOneSubPow_val_eq_mk_sub_one_add_choose_of_pos _ _ (zero_lt_succ d)]
simp only [coeff_coe, coeff_mk]
symm
refine Finset.sum_subset_zero_on_sdiff (fun s hs ↦ ?_) (fun x hx ↦ ?_) (fun x hx ↦ ?_)
· rw [Finset.mem_range_succ_iff]
exact h_le ⟨s, hs⟩
· simp only [Finset.mem_sdiff, mem_support_iff, not_not] at hx
rw [hx.2, zero_mul]
· rw [add_comm, Nat.add_sub_assoc (h_le ⟨x, hx⟩), succ_eq_add_one, add_tsub_cancel_right]
/--
The polynomial satisfying the key property of `Polynomial.hilbertPoly p d` is unique.
-/
theorem existsUnique_hilbertPoly (p : F[X]) (d : ℕ) :
∃! h : F[X], ∃ N : ℕ, ∀ n > N,
(p * invOneSubPow F d : F⟦X⟧).coeff n = h.eval (n : F) := by
use hilbertPoly p d; constructor
· use p.natDegree
exact fun n => coeff_mul_invOneSubPow_eq_hilbertPoly_eval d
· rintro h ⟨N, hhN⟩
apply eq_of_infinite_eval_eq h (hilbertPoly p d)
apply ((Set.Ioi_infinite (max N p.natDegree)).image cast_injective.injOn).mono
rintro x ⟨n, hn, rfl⟩
simp only [Set.mem_Ioi, sup_lt_iff, Set.mem_setOf_eq] at hn ⊢
rw [← coeff_mul_invOneSubPow_eq_hilbertPoly_eval d hn.2, hhN n hn.1]
/--
If `h : F[X]` and there exists some `N : ℕ` such that for any number `n : ℕ` bigger than `N`
we have `PowerSeries.coeff F n (p * invOneSubPow F d) = h.eval (n : F)`, then `h` is exactly
`Polynomial.hilbertPoly p d`.
-/
theorem eq_hilbertPoly_of_forall_coeff_eq_eval
{p h : F[X]} {d : ℕ} (N : ℕ) (hhN : ∀ n > N,
PowerSeries.coeff (R := F) n (p * invOneSubPow F d) = h.eval (n : F)) :
h = hilbertPoly p d :=
ExistsUnique.unique (existsUnique_hilbertPoly p d) ⟨N, hhN⟩
⟨p.natDegree, fun _ x => coeff_mul_invOneSubPow_eq_hilbertPoly_eval d x⟩
lemma hilbertPoly_mul_one_sub_succ (p : F[X]) (d : ℕ) :
hilbertPoly (p * (1 - X)) (d + 1) = hilbertPoly p d := by
apply eq_hilbertPoly_of_forall_coeff_eq_eval (p * (1 - X)).natDegree
intro n hn
have heq : 1 - PowerSeries.X = ((1 - X : F[X]) : F⟦X⟧) := by simp only [coe_sub, coe_one, coe_X]
rw [← one_sub_pow_mul_invOneSubPow_val_add_eq_invOneSubPow_val F d 1, pow_one, ← mul_assoc, heq,
← coe_mul, coeff_mul_invOneSubPow_eq_hilbertPoly_eval (d + 1) hn]
lemma hilbertPoly_mul_one_sub_pow_add (p : F[X]) (d e : ℕ) :
hilbertPoly (p * (1 - X) ^ e) (d + e) = hilbertPoly p d := by
induction e with
| zero => simp
| succ e he => rw [pow_add, pow_one, ← mul_assoc, ← add_assoc, hilbertPoly_mul_one_sub_succ, he]
lemma hilbertPoly_eq_zero_of_le_rootMultiplicity_one
{p : F[X]} {d : ℕ} (hdp : d ≤ p.rootMultiplicity 1) :
hilbertPoly p d = 0 := by
by_cases hp : p = 0
· rw [hp, hilbertPoly_zero_left]
· rcases exists_eq_pow_rootMultiplicity_mul_and_not_dvd p hp 1 with ⟨q, hq1, hq2⟩
have heq : p = q * (-1) ^ p.rootMultiplicity 1 * (1 - X) ^ p.rootMultiplicity 1 := by
simp only [mul_assoc, ← mul_pow, neg_mul, one_mul, neg_sub]
exact hq1.trans (mul_comm _ _)
rw [heq, ← zero_add d, ← Nat.sub_add_cancel hdp, pow_add (1 - X), ← mul_assoc,
hilbertPoly_mul_one_sub_pow_add, hilbertPoly]
theorem natDegree_hilbertPoly_of_ne_zero_of_rootMultiplicity_lt
{p : F[X]} {d : ℕ} (hp : p ≠ 0) (hpd : p.rootMultiplicity 1 < d) :
(hilbertPoly p d).natDegree = d - p.rootMultiplicity 1 - 1 := by
rcases exists_eq_pow_rootMultiplicity_mul_and_not_dvd p hp 1 with ⟨q, hq1, hq2⟩
have heq : p = q * (-1) ^ p.rootMultiplicity 1 * (1 - X) ^ p.rootMultiplicity 1 := by
simp only [mul_assoc, ← mul_pow, neg_mul, one_mul, neg_sub]
exact hq1.trans (mul_comm _ _)
nth_rw 1 [heq, ← Nat.sub_add_cancel (le_of_lt hpd), hilbertPoly_mul_one_sub_pow_add,
← Nat.sub_add_cancel (Nat.le_sub_of_add_le' <| add_one_le_of_lt hpd)]
delta hilbertPoly
apply natDegree_eq_of_le_of_coeff_ne_zero
· apply natDegree_sum_le_of_forall_le _ _ <| fun _ _ => ?_
apply le_trans (natDegree_smul_le _ _)
rw [natDegree_preHilbertPoly]
· have : (fun (x : ℕ) (a : F) => a) = fun x a => a * 1 ^ x := by simp only [one_pow, mul_one]
simp only [finset_sum_coeff, coeff_smul, smul_eq_mul, coeff_preHilbertPoly_self,
← Finset.sum_mul, ← sum_def _ (fun _ a => a), this, ← eval_eq_sum, eval_mul, eval_pow,
eval_neg, eval_one, _root_.mul_eq_zero, pow_eq_zero_iff', neg_eq_zero, one_ne_zero, ne_eq,
false_and, or_false, inv_eq_zero, cast_eq_zero, not_or]
exact ⟨(not_iff_not.2 dvd_iff_isRoot).1 hq2, factorial_ne_zero _⟩
theorem natDegree_hilbertPoly_of_ne_zero
{p : F[X]} {d : ℕ} (hh : hilbertPoly p d ≠ 0) :
(hilbertPoly p d).natDegree = d - p.rootMultiplicity 1 - 1 := by
have hp : p ≠ 0 := by
intro h
rw [h] at hh
exact hh (hilbertPoly_zero_left d)
have hpd : p.rootMultiplicity 1 < d := by
by_contra h
exact hh (hilbertPoly_eq_zero_of_le_rootMultiplicity_one <| not_lt.1 h)
exact natDegree_hilbertPoly_of_ne_zero_of_rootMultiplicity_lt hp hpd
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Chebyshev.lean | import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Algebra.Ring.NegOnePow
import Mathlib.Tactic.LinearCombination
/-!
# Chebyshev polynomials
The Chebyshev polynomials are families of polynomials indexed by `ℤ`,
with integral coefficients.
## Main definitions
* `Polynomial.Chebyshev.T`: the Chebyshev polynomials of the first kind.
* `Polynomial.Chebyshev.U`: the Chebyshev polynomials of the second kind.
* `Polynomial.Chebyshev.C`: the rescaled Chebyshev polynomials of the first kind (also known as the
Vieta–Lucas polynomials), given by $C_n(2x) = 2T_n(x)$.
* `Polynomial.Chebyshev.S`: the rescaled Chebyshev polynomials of the second kind (also known as the
Vieta–Fibonacci polynomials), given by $S_n(2x) = U_n(x)$.
## Main statements
* The formal derivative of the Chebyshev polynomials of the first kind is a scalar multiple of the
Chebyshev polynomials of the second kind.
* `Polynomial.Chebyshev.T_mul_T`, twice the product of the `m`-th and `k`-th Chebyshev polynomials
of the first kind is the sum of the `m + k`-th and `m - k`-th Chebyshev polynomials of the first
kind. There is a similar statement `Polynomial.Chebyshev.C_mul_C` for the `C` polynomials.
* `Polynomial.Chebyshev.T_mul`, the `(m * n)`-th Chebyshev polynomial of the first kind is the
composition of the `m`-th and `n`-th Chebyshev polynomials of the first kind. There is a similar
statement `Polynomial.Chebyshev.C_mul` for the `C` polynomials.
## Implementation details
Since Chebyshev polynomials have interesting behaviour over the complex numbers and modulo `p`,
we define them to have coefficients in an arbitrary commutative ring, even though
technically `ℤ` would suffice.
The benefit of allowing arbitrary coefficient rings, is that the statements afterwards are clean,
and do not have `map (Int.castRingHom R)` interfering all the time.
## References
[Lionel Ponton, _Roots of the Chebyshev polynomials: A purely algebraic approach_]
[ponton2020chebyshev]
## TODO
* Redefine and/or relate the definition of Chebyshev polynomials to `LinearRecurrence`.
* Add explicit formula involving square roots for Chebyshev polynomials
* Compute zeroes and extrema of Chebyshev polynomials.
* Prove that the roots of the Chebyshev polynomials (except 0) are irrational.
* Prove minimax properties of Chebyshev polynomials.
-/
namespace Polynomial.Chebyshev
open Polynomial
variable (R R' : Type*) [CommRing R] [CommRing R']
/-- `T n` is the `n`-th Chebyshev polynomial of the first kind. -/
noncomputable def T : ℤ → R[X]
| 0 => 1
| 1 => X
| (n : ℕ) + 2 => 2 * X * T (n + 1) - T n
| -((n : ℕ) + 1) => 2 * X * T (-n) - T (-n + 1)
termination_by n => Int.natAbs n + Int.natAbs (n - 1)
/-- Induction principle used for proving facts about Chebyshev polynomials. -/
@[elab_as_elim]
protected theorem induct (motive : ℤ → Prop)
(zero : motive 0)
(one : motive 1)
(add_two : ∀ (n : ℕ), motive (↑n + 1) → motive ↑n → motive (↑n + 2))
(neg_add_one : ∀ (n : ℕ), motive (-↑n) → motive (-↑n + 1) → motive (-↑n - 1)) :
∀ (a : ℤ), motive a :=
T.induct motive zero one add_two fun n hn hnm => by
simpa only [Int.negSucc_eq, neg_add] using neg_add_one n hn hnm
@[simp]
theorem T_add_two : ∀ n, T R (n + 2) = 2 * X * T R (n + 1) - T R n
| (k : ℕ) => T.eq_3 R k
| -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) T.eq_4 R k
theorem T_add_one (n : ℤ) : T R (n + 1) = 2 * X * T R n - T R (n - 1) := by
linear_combination (norm := ring_nf) T_add_two R (n - 1)
theorem T_sub_two (n : ℤ) : T R (n - 2) = 2 * X * T R (n - 1) - T R n := by
linear_combination (norm := ring_nf) T_add_two R (n - 2)
theorem T_sub_one (n : ℤ) : T R (n - 1) = 2 * X * T R n - T R (n + 1) := by
linear_combination (norm := ring_nf) T_add_two R (n - 1)
theorem T_eq (n : ℤ) : T R n = 2 * X * T R (n - 1) - T R (n - 2) := by
linear_combination (norm := ring_nf) T_add_two R (n - 2)
@[simp]
theorem T_zero : T R 0 = 1 := by simp [T]
@[simp]
theorem T_one : T R 1 = X := by simp [T]
theorem T_neg_one : T R (-1) = X := by
change T R (Int.negSucc 0) = X
rw [T]
suffices 2 * X - X = X by simpa
ring
theorem T_two : T R 2 = 2 * X ^ 2 - 1 := by
unfold T; simp [pow_two, mul_assoc]
@[simp]
theorem T_neg (n : ℤ) : T R (-n) = T R n := by
induction n using Polynomial.Chebyshev.induct with
| zero => rfl
| one => simp only [T_neg_one, T_one]
| add_two n ih1 ih2 =>
have h₁ := T_add_two R n
have h₂ := T_sub_two R (-n)
linear_combination (norm := ring_nf) (2 * (X : R[X])) * ih1 - ih2 - h₁ + h₂
| neg_add_one n ih1 ih2 =>
have h₁ := T_add_one R n
have h₂ := T_sub_one R (-n)
linear_combination (norm := ring_nf) (2 * (X : R[X])) * ih1 - ih2 + h₁ - h₂
theorem T_natAbs (n : ℤ) : T R n.natAbs = T R n := by
obtain h | h := Int.natAbs_eq n <;> nth_rw 2 [h]; simp
theorem T_neg_two : T R (-2) = 2 * X ^ 2 - 1 := by simp [T_two]
@[simp]
theorem T_eval_one (n : ℤ) : (T R n).eval 1 = 1 := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 => simp [T_add_two, ih1, ih2]; norm_num
| neg_add_one n ih1 ih2 => simp [T_sub_one, -T_neg, ih1, ih2]; norm_num
@[simp]
theorem T_eval_neg_one (n : ℤ) : (T R n).eval (-1) = n.negOnePow := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp only [T_add_two, eval_sub, eval_mul, eval_ofNat, eval_X, mul_neg, mul_one, ih1,
Int.negOnePow_add, Int.negOnePow_one, Units.val_neg, Int.cast_neg, neg_mul, neg_neg, ih2,
Int.negOnePow_def 2]
norm_cast
norm_num
ring
| neg_add_one n ih1 ih2 =>
simp only [T_sub_one, eval_sub, eval_mul, eval_ofNat, eval_X, mul_neg, mul_one, ih1, neg_mul,
ih2, Int.negOnePow_add, Int.negOnePow_one, Units.val_neg, Int.cast_neg, sub_neg_eq_add,
Int.negOnePow_sub]
ring
/-- `U n` is the `n`-th Chebyshev polynomial of the second kind. -/
noncomputable def U : ℤ → R[X]
| 0 => 1
| 1 => 2 * X
| (n : ℕ) + 2 => 2 * X * U (n + 1) - U n
| -((n : ℕ) + 1) => 2 * X * U (-n) - U (-n + 1)
termination_by n => Int.natAbs n + Int.natAbs (n - 1)
@[simp]
theorem U_add_two : ∀ n, U R (n + 2) = 2 * X * U R (n + 1) - U R n
| (k : ℕ) => U.eq_3 R k
| -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) U.eq_4 R k
theorem U_add_one (n : ℤ) : U R (n + 1) = 2 * X * U R n - U R (n - 1) := by
linear_combination (norm := ring_nf) U_add_two R (n - 1)
theorem U_sub_two (n : ℤ) : U R (n - 2) = 2 * X * U R (n - 1) - U R n := by
linear_combination (norm := ring_nf) U_add_two R (n - 2)
theorem U_sub_one (n : ℤ) : U R (n - 1) = 2 * X * U R n - U R (n + 1) := by
linear_combination (norm := ring_nf) U_add_two R (n - 1)
theorem U_eq (n : ℤ) : U R n = 2 * X * U R (n - 1) - U R (n - 2) := by
linear_combination (norm := ring_nf) U_add_two R (n - 2)
@[simp]
theorem U_zero : U R 0 = 1 := by simp [U]
@[simp]
theorem U_one : U R 1 = 2 * X := by simp [U]
@[simp]
theorem U_neg_one : U R (-1) = 0 := by simpa using U_sub_one R 0
theorem U_two : U R 2 = 4 * X ^ 2 - 1 := by
have := U_add_two R 0
simp only [zero_add, U_one, U_zero] at this
linear_combination this
@[simp]
theorem U_neg_two : U R (-2) = -1 := by
simpa [zero_sub, Int.reduceNeg, U_neg_one, mul_zero, U_zero] using U_sub_two R 0
theorem U_neg_sub_one (n : ℤ) : U R (-n - 1) = -U R (n - 1) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
have h₁ := U_add_one R n
have h₂ := U_sub_two R (-n - 1)
linear_combination (norm := ring_nf) 2 * (X : R[X]) * ih1 - ih2 + h₁ + h₂
| neg_add_one n ih1 ih2 =>
have h₁ := U_eq R n
have h₂ := U_sub_two R (-n)
linear_combination (norm := ring_nf) 2 * (X : R[X]) * ih1 - ih2 + h₁ + h₂
theorem U_neg (n : ℤ) : U R (-n) = -U R (n - 2) := by simpa [sub_sub] using U_neg_sub_one R (n - 1)
@[simp]
theorem U_neg_sub_two (n : ℤ) : U R (-n - 2) = -U R n := by
simpa [sub_eq_add_neg, add_comm] using U_neg R (n + 2)
@[simp]
theorem U_eval_one (n : ℤ) : (U R n).eval 1 = n + 1 := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp; norm_num
| add_two n ih1 ih2 =>
simp only [U_add_two, eval_sub, eval_mul, eval_ofNat, eval_X, mul_one, ih1,
Int.cast_add, Int.cast_natCast, Int.cast_one, ih2, Int.cast_ofNat]
ring
| neg_add_one n ih1 ih2 =>
simp only [U_sub_one, eval_sub, eval_mul, eval_ofNat, eval_X, mul_one,
ih1, Int.cast_neg, Int.cast_natCast, ih2, Int.cast_add, Int.cast_one, Int.cast_sub,
sub_add_cancel]
ring
@[simp]
theorem U_eval_neg_one (n : ℤ) : (U R n).eval (-1) = n.negOnePow * (n + 1) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp; norm_num
| add_two n ih1 ih2 =>
simp only [U_add_two, eval_sub, eval_mul, eval_ofNat, eval_X, mul_neg, mul_one, ih1,
Int.cast_add, Int.cast_natCast, Int.cast_one, neg_mul, ih2, Int.cast_ofNat, Int.negOnePow_add,
Int.negOnePow_def 2]
norm_cast
norm_num
ring
| neg_add_one n ih1 ih2 =>
simp only [U_sub_one, eval_sub, eval_mul, eval_ofNat, eval_X, mul_neg, mul_one, ih1,
Int.cast_neg, Int.cast_natCast, Int.negOnePow_neg, neg_mul, ih2, Int.cast_add, Int.cast_one,
Int.cast_sub, sub_add_cancel, Int.negOnePow_sub, Int.negOnePow_add]
norm_cast
norm_num
ring
theorem U_eq_X_mul_U_add_T (n : ℤ) : U R (n + 1) = X * U R n + T R (n + 1) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp [two_mul]
| one => simp [U_two, T_two]; ring
| add_two n ih1 ih2 =>
have h₁ := U_add_two R (n + 1)
have h₂ := U_add_two R n
have h₃ := T_add_two R (n + 1)
linear_combination (norm := ring_nf) -h₃ - (X : R[X]) * h₂ + h₁ + 2 * (X : R[X]) * ih1 - ih2
| neg_add_one n ih1 ih2 =>
have h₁ := U_add_two R (-n - 1)
have h₂ := U_add_two R (-n)
have h₃ := T_add_two R (-n)
linear_combination (norm := ring_nf) -h₃ + h₂ - (X : R[X]) * h₁ - ih2 + 2 * (X : R[X]) * ih1
theorem T_eq_U_sub_X_mul_U (n : ℤ) : T R n = U R n - X * U R (n - 1) := by
linear_combination (norm := ring_nf) - U_eq_X_mul_U_add_T R (n - 1)
theorem T_eq_X_mul_T_sub_pol_U (n : ℤ) : T R (n + 2) = X * T R (n + 1) - (1 - X ^ 2) * U R n := by
have h₁ := U_eq_X_mul_U_add_T R n
have h₂ := U_eq_X_mul_U_add_T R (n + 1)
have h₃ := U_add_two R n
linear_combination (norm := ring_nf) h₃ - h₂ + (X : R[X]) * h₁
theorem one_sub_X_sq_mul_U_eq_pol_in_T (n : ℤ) :
(1 - X ^ 2) * U R n = X * T R (n + 1) - T R (n + 2) := by
linear_combination T_eq_X_mul_T_sub_pol_U R n
/-- `C n` is the `n`th rescaled Chebyshev polynomial of the first kind (also known as a Vieta–Lucas
polynomial), given by $C_n(2x) = 2T_n(x)$. See `Polynomial.Chebyshev.C_comp_two_mul_X`. -/
noncomputable def C : ℤ → R[X]
| 0 => 2
| 1 => X
| (n : ℕ) + 2 => X * C (n + 1) - C n
| -((n : ℕ) + 1) => X * C (-n) - C (-n + 1)
termination_by n => Int.natAbs n + Int.natAbs (n - 1)
@[simp]
theorem C_add_two : ∀ n, C R (n + 2) = X * C R (n + 1) - C R n
| (k : ℕ) => C.eq_3 R k
| -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) C.eq_4 R k
theorem C_add_one (n : ℤ) : C R (n + 1) = X * C R n - C R (n - 1) := by
linear_combination (norm := ring_nf) C_add_two R (n - 1)
theorem C_sub_two (n : ℤ) : C R (n - 2) = X * C R (n - 1) - C R n := by
linear_combination (norm := ring_nf) C_add_two R (n - 2)
theorem C_sub_one (n : ℤ) : C R (n - 1) = X * C R n - C R (n + 1) := by
linear_combination (norm := ring_nf) C_add_two R (n - 1)
theorem C_eq (n : ℤ) : C R n = X * C R (n - 1) - C R (n - 2) := by
linear_combination (norm := ring_nf) C_add_two R (n - 2)
@[simp]
theorem C_zero : C R 0 = 2 := by simp [C]
@[simp]
theorem C_one : C R 1 = X := by simp [C]
theorem C_neg_one : C R (-1) = X := by
change C R (Int.negSucc 0) = X
rw [C]
suffices X * 2 - X = X by simpa
ring
theorem C_two : C R 2 = X ^ 2 - 2 := by
simpa [pow_two, mul_assoc] using C_add_two R 0
@[simp]
theorem C_neg (n : ℤ) : C R (-n) = C R n := by
induction n using Polynomial.Chebyshev.induct with
| zero => rfl
| one => simp only [C_neg_one, C_one]
| add_two n ih1 ih2 =>
have h₁ := C_add_two R n
have h₂ := C_sub_two R (-n)
linear_combination (norm := ring_nf) (X:R[X]) * ih1 - ih2 - h₁ + h₂
| neg_add_one n ih1 ih2 =>
have h₁ := C_add_one R n
have h₂ := C_sub_one R (-n)
linear_combination (norm := ring_nf) (X:R[X]) * ih1 - ih2 + h₁ - h₂
theorem C_natAbs (n : ℤ) : C R n.natAbs = C R n := by
obtain h | h := Int.natAbs_eq n <;> nth_rw 2 [h]; simp
theorem C_neg_two : C R (-2) = X ^ 2 - 2 := by simp [C_two]
theorem C_comp_two_mul_X (n : ℤ) : (C R n).comp (2 * X) = 2 * T R n := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp_rw [C_add_two, T_add_two, sub_comp, mul_comp, X_comp, ih1, ih2]
ring
| neg_add_one n ih1 ih2 =>
simp_rw [C_sub_one, T_sub_one, sub_comp, mul_comp, X_comp, ih1, ih2]
ring
@[simp]
theorem C_eval_two (n : ℤ) : (C R n).eval 2 = 2 := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 => simp [C_add_two, ih1, ih2]; norm_num
| neg_add_one n ih1 ih2 => simp [C_sub_one, -C_neg, ih1, ih2]; norm_num
@[simp]
theorem C_eval_neg_two (n : ℤ) : (C R n).eval (-2) = 2 * n.negOnePow := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp only [C_add_two, eval_sub, eval_mul, eval_X, mul_neg, mul_one, ih1,
Int.negOnePow_add, Int.negOnePow_one, Units.val_neg, Int.cast_neg, neg_mul, neg_neg, ih2,
Int.negOnePow_def 2]
norm_cast
norm_num
ring
| neg_add_one n ih1 ih2 =>
simp only [C_sub_one, eval_sub, eval_mul, eval_X, mul_neg, mul_one, ih1, neg_mul,
ih2, Int.negOnePow_add, Int.negOnePow_one, Units.val_neg, Int.cast_neg, sub_neg_eq_add,
Int.negOnePow_sub]
ring
theorem C_eq_two_mul_T_comp_half_mul_X [Invertible (2 : R)] (n : ℤ) :
C R n = 2 * (T R n).comp (Polynomial.C ⅟2 * X) := by
have := congr_arg (·.comp (Polynomial.C ⅟2 * X)) (C_comp_two_mul_X R n)
simp_rw [comp_assoc, mul_comp, ofNat_comp, X_comp, ← mul_assoc, ← C_eq_natCast, ← C_mul,
Nat.cast_ofNat, mul_invOf_self', map_one, one_mul, comp_X, map_ofNat] at this
assumption
theorem T_eq_half_mul_C_comp_two_mul_X [Invertible (2 : R)] (n : ℤ) :
T R n = Polynomial.C ⅟2 * (C R n).comp (2 * X) := by
rw [C_comp_two_mul_X, ← mul_assoc, ← map_ofNat Polynomial.C 2, ← map_mul, invOf_mul_self',
map_one, one_mul]
/-- `S n` is the `n`th rescaled Chebyshev polynomial of the second kind (also known as a
Vieta–Fibonacci polynomial), given by $S_n(2x) = U_n(x)$. See
`Polynomial.Chebyshev.S_comp_two_mul_X`. -/
noncomputable def S : ℤ → R[X]
| 0 => 1
| 1 => X
| (n : ℕ) + 2 => X * S (n + 1) - S n
| -((n : ℕ) + 1) => X * S (-n) - S (-n + 1)
termination_by n => Int.natAbs n + Int.natAbs (n - 1)
@[simp]
theorem S_add_two : ∀ n, S R (n + 2) = X * S R (n + 1) - S R n
| (k : ℕ) => S.eq_3 R k
| -(k + 1 : ℕ) => by linear_combination (norm := (simp [Int.negSucc_eq]; ring_nf)) S.eq_4 R k
theorem S_add_one (n : ℤ) : S R (n + 1) = X * S R n - S R (n - 1) := by
linear_combination (norm := ring_nf) S_add_two R (n - 1)
theorem S_sub_two (n : ℤ) : S R (n - 2) = X * S R (n - 1) - S R n := by
linear_combination (norm := ring_nf) S_add_two R (n - 2)
theorem S_sub_one (n : ℤ) : S R (n - 1) = X * S R n - S R (n + 1) := by
linear_combination (norm := ring_nf) S_add_two R (n - 1)
theorem S_eq (n : ℤ) : S R n = X * S R (n - 1) - S R (n - 2) := by
linear_combination (norm := ring_nf) S_add_two R (n - 2)
@[simp]
theorem S_zero : S R 0 = 1 := by simp [S]
@[simp]
theorem S_one : S R 1 = X := by simp [S]
@[simp]
theorem S_neg_one : S R (-1) = 0 := by simpa using S_sub_one R 0
theorem S_two : S R 2 = X ^ 2 - 1 := by
have := S_add_two R 0
simp only [zero_add, S_one, S_zero] at this
linear_combination this
@[simp]
theorem S_neg_two : S R (-2) = -1 := by
simpa [zero_sub, Int.reduceNeg, S_neg_one, mul_zero, S_zero] using S_sub_two R 0
theorem S_neg_sub_one (n : ℤ) : S R (-n - 1) = -S R (n - 1) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
have h₁ := S_add_one R n
have h₂ := S_sub_two R (-n - 1)
linear_combination (norm := ring_nf) (X:R[X]) * ih1 - ih2 + h₁ + h₂
| neg_add_one n ih1 ih2 =>
have h₁ := S_eq R n
have h₂ := S_sub_two R (-n)
linear_combination (norm := ring_nf) (X:R[X]) * ih1 - ih2 + h₁ + h₂
theorem S_neg (n : ℤ) : S R (-n) = -S R (n - 2) := by simpa [sub_sub] using S_neg_sub_one R (n - 1)
@[simp]
theorem S_neg_sub_two (n : ℤ) : S R (-n - 2) = -S R n := by
simpa [sub_eq_add_neg, add_comm] using S_neg R (n + 2)
@[simp]
theorem S_eval_two (n : ℤ) : (S R n).eval 2 = n + 1 := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp; norm_num
| add_two n ih1 ih2 =>
simp only [S_add_two, eval_sub, eval_mul, eval_X, ih1,
Int.cast_add, Int.cast_natCast, Int.cast_one, ih2, Int.cast_ofNat]
ring
| neg_add_one n ih1 ih2 =>
simp only [S_sub_one, eval_sub, eval_mul, eval_X,
ih1, Int.cast_neg, Int.cast_natCast, ih2, Int.cast_add, Int.cast_one, Int.cast_sub,
sub_add_cancel]
ring
@[simp]
theorem S_eval_neg_two (n : ℤ) : (S R n).eval (-2) = n.negOnePow * (n + 1) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp; norm_num
| add_two n ih1 ih2 =>
simp only [S_add_two, eval_sub, eval_mul, eval_X, ih1,
Int.cast_add, Int.cast_natCast, Int.cast_one, neg_mul, ih2, Int.cast_ofNat, Int.negOnePow_add,
Int.negOnePow_def 2]
norm_cast
norm_num
ring
| neg_add_one n ih1 ih2 =>
simp only [S_sub_one, eval_sub, eval_mul, eval_X, mul_neg, ih1,
Int.cast_neg, Int.cast_natCast, Int.negOnePow_neg, neg_mul, ih2, Int.cast_add, Int.cast_one,
Int.cast_sub, sub_add_cancel, Int.negOnePow_sub, Int.negOnePow_add]
norm_cast
norm_num
ring
theorem S_comp_two_mul_X (n : ℤ) : (S R n).comp (2 * X) = U R n := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 => simp_rw [U_add_two, S_add_two, sub_comp, mul_comp, X_comp, ih1, ih2]
| neg_add_one n ih1 ih2 => simp_rw [U_sub_one, S_sub_one, sub_comp, mul_comp, X_comp, ih1, ih2]
theorem S_sq_add_S_sq (n : ℤ) : S R n ^ 2 + S R (n + 1) ^ 2 - X * S R n * S R (n + 1) = 1 := by
induction n with
| zero => simp; ring
| succ n ih =>
have h₁ := S_add_two R n
linear_combination (norm := ring_nf) (S R (2 + n) - S R n) * h₁ + ih
| pred n ih =>
have h₁ := S_sub_one R (-n)
linear_combination (norm := ring_nf) (S R (-1 - n) - S R (1 - n)) * h₁ + ih
theorem S_eq_U_comp_half_mul_X [Invertible (2 : R)] (n : ℤ) :
S R n = (U R n).comp (Polynomial.C ⅟2 * X) := by
have := congr_arg (·.comp (Polynomial.C ⅟2 * X)) (S_comp_two_mul_X R n)
simp_rw [comp_assoc, mul_comp, ofNat_comp, X_comp, ← mul_assoc, ← C_eq_natCast, ← C_mul,
Nat.cast_ofNat, mul_invOf_self', map_one, one_mul, comp_X] at this
assumption
theorem S_eq_X_mul_S_add_C (n : ℤ) : 2 * S R (n + 1) = X * S R n + C R (n + 1) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp [two_mul]
| one => simp [S_two, C_two]; ring
| add_two n ih1 ih2 =>
have h₁ := S_add_two R (n + 1)
have h₂ := S_add_two R n
have h₃ := C_add_two R (n + 1)
linear_combination (norm := ring_nf) -h₃ - (X:R[X]) * h₂ + 2 * h₁ + (X:R[X]) * ih1 - ih2
| neg_add_one n ih1 ih2 =>
have h₁ := S_add_two R (-n - 1)
have h₂ := S_add_two R (-n)
have h₃ := C_add_two R (-n)
linear_combination (norm := ring_nf) -h₃ + 2 * h₂ - (X:R[X]) * h₁ - ih2 + (X:R[X]) * ih1
theorem C_eq_S_sub_X_mul_S (n : ℤ) : C R n = 2 * S R n - X * S R (n - 1) := by
linear_combination (norm := ring_nf) - S_eq_X_mul_S_add_C R (n - 1)
variable {R R'}
@[simp]
theorem map_T (f : R →+* R') (n : ℤ) : map f (T R n) = T R' n := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp_rw [T_add_two, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X,
ih1, ih2]
| neg_add_one n ih1 ih2 =>
simp_rw [T_sub_one, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X, ih1,
ih2]
@[simp]
theorem map_U (f : R →+* R') (n : ℤ) : map f (U R n) = U R' n := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp_rw [U_add_two, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X, ih1,
ih2]
| neg_add_one n ih1 ih2 =>
simp_rw [U_sub_one, Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_ofNat, map_X, ih1,
ih2]
@[simp]
theorem map_C (f : R →+* R') (n : ℤ) : map f (C R n) = C R' n := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp_rw [C_add_two, Polynomial.map_sub, Polynomial.map_mul, map_X, ih1, ih2]
| neg_add_one n ih1 ih2 =>
simp_rw [C_sub_one, Polynomial.map_sub, Polynomial.map_mul, map_X, ih1, ih2]
@[simp]
theorem map_S (f : R →+* R') (n : ℤ) : map f (S R n) = S R' n := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two n ih1 ih2 =>
simp_rw [S_add_two, Polynomial.map_sub, Polynomial.map_mul, map_X, ih1, ih2]
| neg_add_one n ih1 ih2 =>
simp_rw [S_sub_one, Polynomial.map_sub, Polynomial.map_mul, map_X, ih1, ih2]
@[simp]
theorem aeval_T [Algebra R R'] (x : R') (n : ℤ) : aeval x (T R n) = (T R' n).eval x := by
rw [aeval_def, eval₂_eq_eval_map, map_T]
@[simp]
theorem aeval_U [Algebra R R'] (x : R') (n : ℤ) : aeval x (U R n) = (U R' n).eval x := by
rw [aeval_def, eval₂_eq_eval_map, map_U]
@[simp]
theorem aeval_C [Algebra R R'] (x : R') (n : ℤ) : aeval x (C R n) = (C R' n).eval x := by
rw [aeval_def, eval₂_eq_eval_map, map_C]
@[simp]
theorem aeval_S [Algebra R R'] (x : R') (n : ℤ) : aeval x (S R n) = (S R' n).eval x := by
rw [aeval_def, eval₂_eq_eval_map, map_S]
@[simp]
theorem algebraMap_eval_T [Algebra R R'] (x : R) (n : ℤ) :
algebraMap R R' ((T R n).eval x) = (T R' n).eval (algebraMap R R' x) := by
rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_T]
@[simp]
theorem algebraMap_eval_U [Algebra R R'] (x : R) (n : ℤ) :
algebraMap R R' ((U R n).eval x) = (U R' n).eval (algebraMap R R' x) := by
rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_U]
@[simp]
theorem algebraMap_eval_C [Algebra R R'] (x : R) (n : ℤ) :
algebraMap R R' ((C R n).eval x) = (C R' n).eval (algebraMap R R' x) := by
rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_C]
@[simp]
theorem algebraMap_eval_S [Algebra R R'] (x : R) (n : ℤ) :
algebraMap R R' ((S R n).eval x) = (S R' n).eval (algebraMap R R' x) := by
rw [← aeval_algebraMap_apply_eq_algebraMap_eval, aeval_S]
theorem T_derivative_eq_U (n : ℤ) : derivative (T R n) = n * U R (n - 1) := by
induction n using Polynomial.Chebyshev.induct with
| zero => simp
| one =>
simp
| add_two n ih1 ih2 =>
have h₁ := congr_arg derivative (T_add_two R n)
have h₂ := U_sub_one R n
have h₃ := T_eq_U_sub_X_mul_U R (n + 1)
simp only [derivative_sub, derivative_mul, derivative_ofNat, derivative_X] at h₁
linear_combination (norm := (push_cast; ring_nf))
h₁ - ih2 + 2 * (X : R[X]) * ih1 + 2 * h₃ - n * h₂
| neg_add_one n ih1 ih2 =>
have h₁ := congr_arg derivative (T_sub_one R (-n))
have h₂ := U_sub_two R (-n)
have h₃ := T_eq_U_sub_X_mul_U R (-n)
simp only [derivative_sub, derivative_mul, derivative_ofNat, derivative_X] at h₁
linear_combination (norm := (push_cast; ring_nf))
-ih2 + 2 * (X : R[X]) * ih1 + h₁ + 2 * h₃ + (n + 1) * h₂
theorem one_sub_X_sq_mul_derivative_T_eq_poly_in_T (n : ℤ) :
(1 - X ^ 2) * derivative (T R (n + 1)) = (n + 1 : R[X]) * (T R n - X * T R (n + 1)) := by
have H₁ := one_sub_X_sq_mul_U_eq_pol_in_T R n
have H₂ := T_derivative_eq_U (R := R) (n + 1)
have h₁ := T_add_two R n
linear_combination (norm := (push_cast; ring_nf))
(-n - 1) * h₁ + (-(X : R[X]) ^ 2 + 1) * H₂ + (n + 1) * H₁
theorem add_one_mul_T_eq_poly_in_U (n : ℤ) :
((n : R[X]) + 1) * T R (n + 1) = X * U R n - (1 - X ^ 2) * derivative (U R n) := by
have h₁ := congr_arg derivative <| T_eq_X_mul_T_sub_pol_U R n
simp only [derivative_sub, derivative_mul, derivative_X, derivative_one, derivative_X_pow,
T_derivative_eq_U, C_eq_natCast] at h₁
have h₂ := T_eq_U_sub_X_mul_U R (n + 1)
linear_combination (norm := (push_cast; ring_nf))
h₁ + (n + 2) * h₂
variable (R)
/-- Twice the product of two Chebyshev `T` polynomials is the sum of two other Chebyshev `T`
polynomials. -/
theorem T_mul_T (m k : ℤ) : 2 * T R m * T R k = T R (m + k) + T R (m - k) := by
induction k using Polynomial.Chebyshev.induct with
| zero => simp [two_mul]
| one => rw [T_add_one, T_one]; ring
| add_two k ih1 ih2 =>
have h₁ := T_add_two R (m + k)
have h₂ := T_sub_two R (m - k)
have h₃ := T_add_two R k
linear_combination (norm := ring_nf) 2 * T R m * h₃ - h₂ - h₁ - ih2 + 2 * (X : R[X]) * ih1
| neg_add_one k ih1 ih2 =>
have h₁ := T_add_two R (m + (-k - 1))
have h₂ := T_sub_two R (m - (-k - 1))
have h₃ := T_add_two R (-k - 1)
linear_combination (norm := ring_nf) 2 * T R m * h₃ - h₂ - h₁ - ih2 + 2 * (X : R[X]) * ih1
/-- The product of two Chebyshev `C` polynomials is the sum of two other Chebyshev `C` polynomials.
-/
theorem C_mul_C (m k : ℤ) : C R m * C R k = C R (m + k) + C R (m - k) := by
induction k using Polynomial.Chebyshev.induct with
| zero => simp [mul_two]
| one => rw [C_add_one, C_one]; ring
| add_two k ih1 ih2 =>
have h₁ := C_add_two R (m + k)
have h₂ := C_sub_two R (m - k)
have h₃ := C_add_two R k
linear_combination (norm := ring_nf) C R m * h₃ - h₂ - h₁ - ih2 + (X:R[X]) * ih1
| neg_add_one k ih1 ih2 =>
have h₁ := C_add_two R (m + (-k - 1))
have h₂ := C_sub_two R (m - (-k - 1))
have h₃ := C_add_two R (-k - 1)
linear_combination (norm := ring_nf) C R m * h₃ - h₂ - h₁ - ih2 + (X:R[X]) * ih1
/-- The `(m * n)`-th Chebyshev `T` polynomial is the composition of the `m`-th and `n`-th. -/
theorem T_mul (m n : ℤ) : T R (m * n) = (T R m).comp (T R n) := by
induction m using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two m ih1 ih2 =>
have h₁ := T_mul_T R ((m + 1) * n) n
have h₂ := congr_arg (comp · (T R n)) <| T_add_two R m
simp only [sub_comp, mul_comp, ofNat_comp, X_comp] at h₂
linear_combination (norm := ring_nf) -ih2 - h₂ - h₁ + 2 * T R n * ih1
| neg_add_one m ih1 ih2 =>
have h₁ := T_mul_T R ((-m) * n) n
have h₂ := congr_arg (comp · (T R n)) <| T_add_two R (-m - 1)
simp only [sub_comp, mul_comp, ofNat_comp, X_comp] at h₂
linear_combination (norm := ring_nf) -ih2 - h₂ - h₁ + 2 * T R n * ih1
/-- The `(m * n)`-th Chebyshev `C` polynomial is the composition of the `m`-th and `n`-th. -/
theorem C_mul (m n : ℤ) : C R (m * n) = (C R m).comp (C R n) := by
induction m using Polynomial.Chebyshev.induct with
| zero => simp
| one => simp
| add_two m ih1 ih2 =>
have h₁ := C_mul_C R ((m + 1) * n) n
have h₂ := congr_arg (comp · (C R n)) <| C_add_two R m
simp only [sub_comp, mul_comp, X_comp] at h₂
linear_combination (norm := ring_nf) -ih2 - h₂ - h₁ + C R n * ih1
| neg_add_one m ih1 ih2 =>
have h₁ := C_mul_C R ((-m) * n) n
have h₂ := congr_arg (comp · (C R n)) <| C_add_two R (-m - 1)
simp only [sub_comp, mul_comp, X_comp] at h₂
linear_combination (norm := ring_nf) -ih2 - h₂ - h₁ + C R n * ih1
end Polynomial.Chebyshev |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/ScaleRoots.lean | import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.RingTheory.Coprime.Basic
import Mathlib.Tactic.AdaptationNote
/-!
# Scaling the roots of a polynomial
This file defines `scaleRoots p s` for a polynomial `p` in one variable and a ring element `s` to
be the polynomial with root `r * s` for each root `r` of `p` and proves some basic results about it.
-/
variable {R S A K : Type*}
namespace Polynomial
section Semiring
variable [Semiring R] [Semiring S]
/-- `scaleRoots p s` is a polynomial with root `r * s` for each root `r` of `p`. -/
noncomputable def scaleRoots (p : R[X]) (s : R) : R[X] :=
∑ i ∈ p.support, monomial i (p.coeff i * s ^ (p.natDegree - i))
@[simp]
theorem coeff_scaleRoots (p : R[X]) (s : R) (i : ℕ) :
(scaleRoots p s).coeff i = coeff p i * s ^ (p.natDegree - i) := by
simp +contextual [scaleRoots, coeff_monomial]
theorem coeff_scaleRoots_natDegree (p : R[X]) (s : R) :
(scaleRoots p s).coeff p.natDegree = p.leadingCoeff := by
rw [leadingCoeff, coeff_scaleRoots, tsub_self, pow_zero, mul_one]
@[simp]
theorem zero_scaleRoots (s : R) : scaleRoots 0 s = 0 := by
ext
simp
theorem scaleRoots_ne_zero {p : R[X]} (hp : p ≠ 0) (s : R) : scaleRoots p s ≠ 0 := by
intro h
have : p.coeff p.natDegree ≠ 0 := mt leadingCoeff_eq_zero.mp hp
have : (scaleRoots p s).coeff p.natDegree = 0 :=
congr_fun (congr_arg (coeff : R[X] → ℕ → R) h) p.natDegree
rw [coeff_scaleRoots_natDegree] at this
contradiction
theorem support_scaleRoots_le (p : R[X]) (s : R) : (scaleRoots p s).support ≤ p.support := by
intro
simpa using left_ne_zero_of_mul
theorem support_scaleRoots_eq (p : R[X]) {s : R} (hs : s ∈ nonZeroDivisors R) :
(scaleRoots p s).support = p.support :=
le_antisymm (support_scaleRoots_le p s)
(by intro i
simp only [coeff_scaleRoots, Polynomial.mem_support_iff]
intro p_ne_zero ps_zero
have := (pow_mem hs (p.natDegree - i)).2 _ ps_zero
contradiction)
@[simp]
theorem degree_scaleRoots (p : R[X]) {s : R} : degree (scaleRoots p s) = degree p := by
haveI := Classical.propDecidable
by_cases hp : p = 0
· rw [hp, zero_scaleRoots]
refine le_antisymm (Finset.sup_mono (support_scaleRoots_le p s)) (degree_le_degree ?_)
rw [coeff_scaleRoots_natDegree]
intro h
have := leadingCoeff_eq_zero.mp h
contradiction
@[simp]
theorem natDegree_scaleRoots (p : R[X]) (s : R) : natDegree (scaleRoots p s) = natDegree p := by
simp only [natDegree, degree_scaleRoots]
theorem monic_scaleRoots_iff {p : R[X]} (s : R) : Monic (scaleRoots p s) ↔ Monic p := by
simp only [Monic, leadingCoeff, natDegree_scaleRoots, coeff_scaleRoots_natDegree]
theorem map_scaleRoots (p : R[X]) (x : R) (f : R →+* S) (h : f p.leadingCoeff ≠ 0) :
(p.scaleRoots x).map f = (p.map f).scaleRoots (f x) := by
ext
simp [Polynomial.natDegree_map_of_leadingCoeff_ne_zero _ h]
@[simp]
lemma scaleRoots_C (r c : R) : (C c).scaleRoots r = C c := by
ext; simp
@[simp]
lemma scaleRoots_one (p : R[X]) :
p.scaleRoots 1 = p := by ext; simp
@[simp]
lemma scaleRoots_zero (p : R[X]) :
p.scaleRoots 0 = p.leadingCoeff • X ^ p.natDegree := by
ext n
simp only [coeff_scaleRoots, tsub_eq_zero_iff_le, zero_pow_eq, mul_ite,
mul_one, mul_zero, coeff_smul, coeff_X_pow, smul_eq_mul]
split_ifs with h₁ h₂ h₂
· subst h₂; rfl
· exact coeff_eq_zero_of_natDegree_lt (lt_of_le_of_ne h₁ (Ne.symm h₂))
· exact (h₁ h₂.ge).elim
· rfl
@[simp]
lemma one_scaleRoots (r : R) :
(1 : R[X]).scaleRoots r = 1 := by ext; simp
end Semiring
section CommSemiring
variable [Semiring S] [CommSemiring R] [Semiring A] [Field K]
theorem scaleRoots_eval₂_mul_of_commute {p : S[X]} (f : S →+* A) (a : A) (s : S)
(hsa : Commute (f s) a) (hf : ∀ s₁ s₂, Commute (f s₁) (f s₂)) :
eval₂ f (f s * a) (scaleRoots p s) = f s ^ p.natDegree * eval₂ f a p := by
calc
_ = (scaleRoots p s).support.sum fun i =>
f (coeff p i * s ^ (p.natDegree - i)) * (f s * a) ^ i := by
simp [eval₂_eq_sum, sum_def]
_ = p.support.sum fun i => f (coeff p i * s ^ (p.natDegree - i)) * (f s * a) ^ i :=
(Finset.sum_subset (support_scaleRoots_le p s) fun i _hi hi' => by
let this : coeff p i * s ^ (p.natDegree - i) = 0 := by simpa using hi'
simp [this])
_ = p.support.sum fun i : ℕ => f (p.coeff i) * f s ^ (p.natDegree - i + i) * a ^ i :=
(Finset.sum_congr rfl fun i _hi => by
simp_rw [f.map_mul, f.map_pow, pow_add, hsa.mul_pow, mul_assoc])
_ = p.support.sum fun i : ℕ => f s ^ p.natDegree * (f (p.coeff i) * a ^ i) :=
Finset.sum_congr rfl fun i hi => by
rw [mul_assoc, ← map_pow, (hf _ _).left_comm, map_pow, tsub_add_cancel_of_le]
exact le_natDegree_of_ne_zero (Polynomial.mem_support_iff.mp hi)
_ = f s ^ p.natDegree * eval₂ f a p := by simp [← Finset.mul_sum, eval₂_eq_sum, sum_def]
theorem scaleRoots_eval₂_mul {p : S[X]} (f : S →+* R) (r : R) (s : S) :
eval₂ f (f s * r) (scaleRoots p s) = f s ^ p.natDegree * eval₂ f r p :=
scaleRoots_eval₂_mul_of_commute f r s (mul_comm _ _) fun _ _ ↦ mul_comm _ _
theorem scaleRoots_eval₂_eq_zero {p : S[X]} (f : S →+* R) {r : R} {s : S} (hr : eval₂ f r p = 0) :
eval₂ f (f s * r) (scaleRoots p s) = 0 := by rw [scaleRoots_eval₂_mul, hr, mul_zero]
theorem scaleRoots_aeval_eq_zero [Algebra R A] {p : R[X]} {a : A} {r : R} (ha : aeval a p = 0) :
aeval (algebraMap R A r * a) (scaleRoots p r) = 0 := by
rw [aeval_def, scaleRoots_eval₂_mul_of_commute, ← aeval_def, ha, mul_zero]
· apply Algebra.commutes
· intros; rw [Commute, SemiconjBy, ← map_mul, ← map_mul, mul_comm]
theorem scaleRoots_eval₂_eq_zero_of_eval₂_div_eq_zero {p : S[X]} {f : S →+* K}
(hf : Function.Injective f) {r s : S} (hr : eval₂ f (f r / f s) p = 0)
(hs : s ∈ nonZeroDivisors S) : eval₂ f (f r) (scaleRoots p s) = 0 := by
-- if we don't specify the type with `(_ : S)`, the proof is much slower
nontriviality S using Subsingleton.eq_zero (_ : S)
convert @scaleRoots_eval₂_eq_zero _ _ _ _ p f _ s hr
rw [← mul_div_assoc, mul_comm, mul_div_cancel_right₀]
exact map_ne_zero_of_mem_nonZeroDivisors _ hf hs
theorem scaleRoots_aeval_eq_zero_of_aeval_div_eq_zero [Algebra R K]
(inj : Function.Injective (algebraMap R K)) {p : R[X]} {r s : R}
(hr : aeval (algebraMap R K r / algebraMap R K s) p = 0) (hs : s ∈ nonZeroDivisors R) :
aeval (algebraMap R K r) (scaleRoots p s) = 0 :=
scaleRoots_eval₂_eq_zero_of_eval₂_div_eq_zero inj hr hs
@[simp]
lemma scaleRoots_mul (p : R[X]) (r s) :
p.scaleRoots (r * s) = (p.scaleRoots r).scaleRoots s := by
ext; simp [mul_pow, mul_assoc]
/-- Multiplication and `scaleRoots` commute up to a power of `r`. The factor disappears if we
assume that the product of the leading coeffs does not vanish. See `Polynomial.mul_scaleRoots'`. -/
lemma mul_scaleRoots (p q : R[X]) (r : R) :
r ^ (natDegree p + natDegree q - natDegree (p * q)) • (p * q).scaleRoots r =
p.scaleRoots r * q.scaleRoots r := by
ext n; simp only [coeff_scaleRoots, coeff_smul, smul_eq_mul]
trans (∑ x ∈ Finset.antidiagonal n, coeff p x.1 * coeff q x.2) *
r ^ (natDegree p + natDegree q - n)
· rw [← coeff_mul]
cases lt_or_ge (natDegree (p * q)) n with
| inl h => simp only [coeff_eq_zero_of_natDegree_lt h, zero_mul, mul_zero]
| inr h =>
rw [mul_comm, mul_assoc, ← pow_add, add_comm, tsub_add_tsub_cancel natDegree_mul_le h]
· rw [coeff_mul, Finset.sum_mul]
apply Finset.sum_congr rfl
simp only [Finset.mem_antidiagonal, coeff_scaleRoots, Prod.forall]
intro a b e
cases lt_or_ge (natDegree p) a with
| inl h => simp only [coeff_eq_zero_of_natDegree_lt h, zero_mul]
| inr ha =>
cases lt_or_ge (natDegree q) b with
| inl h => simp only [coeff_eq_zero_of_natDegree_lt h, zero_mul, mul_zero]
| inr hb =>
simp only [← e, mul_assoc, mul_comm (r ^ (_ - a)), ← pow_add]
rw [add_comm (_ - _), tsub_add_tsub_comm ha hb]
lemma mul_scaleRoots' (p q : R[X]) (r : R) (h : leadingCoeff p * leadingCoeff q ≠ 0) :
(p * q).scaleRoots r = p.scaleRoots r * q.scaleRoots r := by
rw [← mul_scaleRoots, natDegree_mul' h, tsub_self, pow_zero, one_smul]
lemma mul_scaleRoots_of_noZeroDivisors (p q : R[X]) (r : R) [NoZeroDivisors R] :
(p * q).scaleRoots r = p.scaleRoots r * q.scaleRoots r := by
by_cases hp : p = 0; · simp [hp]
by_cases hq : q = 0; · simp [hq]
apply mul_scaleRoots'
simp only [ne_eq, mul_eq_zero, leadingCoeff_eq_zero, hp, hq, or_self, not_false_eq_true]
lemma add_scaleRoots_of_natDegree_eq (p q : R[X]) (r : R) (h : natDegree p = natDegree q) :
r ^ (natDegree p - natDegree (p + q)) • (p + q).scaleRoots r =
p.scaleRoots r + q.scaleRoots r := by
ext n; simp only [coeff_smul, coeff_scaleRoots, coeff_add, smul_eq_mul,
mul_comm (r ^ _), ← h, ← add_mul]
#adaptation_note /-- v4.7.0-rc1
Previously `mul_assoc` was part of the `simp only` above, and this `rw` was not needed.
but this now causes a max rec depth error. -/
rw [mul_assoc, ← pow_add]
cases lt_or_ge (natDegree (p + q)) n with
| inl hn => simp only [← coeff_add, coeff_eq_zero_of_natDegree_lt hn, zero_mul]
| inr hn =>
rw [add_comm (_ - n), tsub_add_tsub_cancel (natDegree_add_le_of_degree_le le_rfl h.ge) hn]
lemma scaleRoots_dvd' (p q : R[X]) {r : R} (hr : IsUnit r)
(hpq : p ∣ q) : p.scaleRoots r ∣ q.scaleRoots r := by
obtain ⟨a, rfl⟩ := hpq
rw [← ((hr.pow (natDegree p + natDegree a - natDegree (p * a))).map
(algebraMap R R[X])).dvd_mul_left, ← Algebra.smul_def, mul_scaleRoots]
exact dvd_mul_right (scaleRoots p r) (scaleRoots a r)
lemma scaleRoots_dvd (p q : R[X]) {r : R} [NoZeroDivisors R] (hpq : p ∣ q) :
p.scaleRoots r ∣ q.scaleRoots r := by
obtain ⟨a, rfl⟩ := hpq
rw [mul_scaleRoots_of_noZeroDivisors]
exact dvd_mul_right (scaleRoots p r) (scaleRoots a r)
alias _root_.Dvd.dvd.scaleRoots := scaleRoots_dvd
lemma scaleRoots_dvd_iff (p q : R[X]) {r : R} (hr : IsUnit r) :
p.scaleRoots r ∣ q.scaleRoots r ↔ p ∣ q := by
refine ⟨?_ ∘ scaleRoots_dvd' _ _ (hr.unit⁻¹).isUnit, scaleRoots_dvd' p q hr⟩
simp [← scaleRoots_mul, scaleRoots_one]
alias _root_.IsUnit.scaleRoots_dvd_iff := scaleRoots_dvd_iff
lemma isCoprime_scaleRoots (p q : R[X]) (r : R) (hr : IsUnit r) (h : IsCoprime p q) :
IsCoprime (p.scaleRoots r) (q.scaleRoots r) := by
obtain ⟨a, b, e⟩ := h
let s : R := ↑hr.unit⁻¹
have : natDegree (a * p) = natDegree (b * q) := by
apply natDegree_eq_of_natDegree_add_eq_zero
rw [e, natDegree_one]
use s ^ natDegree (a * p) • s ^ (natDegree a + natDegree p - natDegree (a * p)) • a.scaleRoots r
use s ^ natDegree (a * p) • s ^ (natDegree b + natDegree q - natDegree (b * q)) • b.scaleRoots r
simp only [s, smul_mul_assoc, ← mul_scaleRoots, smul_smul, mul_assoc,
← mul_pow, IsUnit.val_inv_mul, one_pow, mul_one, ← smul_add, one_smul, e, natDegree_one,
one_scaleRoots, ← add_scaleRoots_of_natDegree_eq _ _ _ this, tsub_zero]
alias _root_.IsCoprime.scaleRoots := isCoprime_scaleRoots
end CommSemiring
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/RationalRoot.lean | import Mathlib.RingTheory.IntegralClosure.IntegrallyClosed
import Mathlib.RingTheory.Localization.NumDen
import Mathlib.RingTheory.Polynomial.ScaleRoots
/-!
# Rational root theorem and integral root theorem
This file contains the rational root theorem and integral root theorem.
The rational root theorem (`num_dvd_of_is_root` and `den_dvd_of_is_root`)
for a unique factorization domain `A`
with localization `S`, states that the roots of `p : A[X]` in `A`'s
field of fractions are of the form `x / y` with `x y : A`, `x ∣ p.coeff 0` and
`y ∣ p.leadingCoeff`.
The corollary is the integral root theorem `isInteger_of_is_root_of_monic`:
if `p` is monic, its roots must be integers.
Finally, we use this to show unique factorization domains are integrally closed.
## References
* https://en.wikipedia.org/wiki/Rational_root_theorem
-/
open scoped Polynomial
section ScaleRoots
variable {A K R S : Type*} [CommRing A] [Field K] [CommRing R] [CommRing S]
variable {M : Submonoid A} [Algebra A S] [IsLocalization M S] [Algebra A K] [IsFractionRing A K]
open Finsupp IsFractionRing IsLocalization Polynomial
theorem scaleRoots_aeval_eq_zero_of_aeval_mk'_eq_zero {p : A[X]} {r : A} {s : M}
(hr : aeval (mk' S r s) p = 0) : aeval (algebraMap A S r) (scaleRoots p s) = 0 := by
convert scaleRoots_eval₂_eq_zero (algebraMap A S) hr
funext
rw [aeval_def, mk'_spec' _ r s]
variable [IsDomain A]
theorem num_isRoot_scaleRoots_of_aeval_eq_zero [UniqueFactorizationMonoid A] {p : A[X]} {x : K}
(hr : aeval x p = 0) : IsRoot (scaleRoots p (den A x)) (num A x) := by
apply isRoot_of_eval₂_map_eq_zero (IsFractionRing.injective A K)
refine scaleRoots_aeval_eq_zero_of_aeval_mk'_eq_zero ?_
rw [mk'_num_den]
exact hr
end ScaleRoots
section RationalRootTheorem
variable {A K : Type*} [CommRing A] [IsDomain A] [UniqueFactorizationMonoid A] [Field K]
variable [Algebra A K] [IsFractionRing A K]
open IsFractionRing IsLocalization Polynomial UniqueFactorizationMonoid
/-- **Rational root theorem** part 1:
if `r : f.codomain` is a root of a polynomial over the ufd `A`,
then the numerator of `r` divides the constant coefficient -/
theorem num_dvd_of_is_root {p : A[X]} {r : K} (hr : aeval r p = 0) : num A r ∣ p.coeff 0 := by
suffices num A r ∣ (scaleRoots p (den A r)).coeff 0 by
simp only [coeff_scaleRoots, tsub_zero] at this
haveI inst := Classical.propDecidable
by_cases hr : num A r = 0
· simp_all [nonZeroDivisors.coe_ne_zero]
· refine dvd_of_dvd_mul_left_of_no_prime_factors hr ?_ this
intro q dvd_num dvd_denom_pow hq
apply hq.not_unit
exact num_den_reduced A r dvd_num (hq.dvd_of_dvd_pow dvd_denom_pow)
convert dvd_term_of_isRoot_of_dvd_terms 0 (num_isRoot_scaleRoots_of_aeval_eq_zero hr) _
· rw [pow_zero, mul_one]
intro j hj
apply dvd_mul_of_dvd_right
convert pow_dvd_pow (num A r) (Nat.succ_le_of_lt (bot_lt_iff_ne_bot.mpr hj))
exact (pow_one _).symm
/-- Rational root theorem part 2:
if `r : f.codomain` is a root of a polynomial over the ufd `A`,
then the denominator of `r` divides the leading coefficient -/
theorem den_dvd_of_is_root {p : A[X]} {r : K} (hr : aeval r p = 0) :
(den A r : A) ∣ p.leadingCoeff := by
suffices (den A r : A) ∣ p.leadingCoeff * num A r ^ p.natDegree by
refine
dvd_of_dvd_mul_left_of_no_prime_factors (mem_nonZeroDivisors_iff_ne_zero.mp (den A r).2) ?_
this
intro q dvd_den dvd_num_pow hq
apply hq.not_unit
exact num_den_reduced A r (hq.dvd_of_dvd_pow dvd_num_pow) dvd_den
rw [← coeff_scaleRoots_natDegree]
apply dvd_term_of_isRoot_of_dvd_terms _ (num_isRoot_scaleRoots_of_aeval_eq_zero hr)
intro j hj
by_cases! h : j < p.natDegree
· rw [coeff_scaleRoots]
refine (dvd_mul_of_dvd_right ?_ _).mul_right _
convert pow_dvd_pow (den A r : A) (Nat.succ_le_iff.mpr (lt_tsub_iff_left.mpr _))
· exact (pow_one _).symm
simpa using h
rw [← natDegree_scaleRoots p (den A r)] at *
rw [coeff_eq_zero_of_natDegree_lt (lt_of_le_of_ne h hj.symm),
zero_mul]
exact dvd_zero _
/-- **Integral root theorem**:
if `r : f.codomain` is a root of a monic polynomial over the ufd `A`,
then `r` is an integer -/
theorem isInteger_of_is_root_of_monic {p : A[X]} (hp : Monic p) {r : K} (hr : aeval r p = 0) :
IsInteger A r :=
isInteger_of_isUnit_den (isUnit_of_dvd_one (hp ▸ den_dvd_of_is_root hr))
theorem exists_integer_of_is_root_of_monic {p : A[X]} (hp : Monic p) {r : K} (hr : aeval r p = 0) :
∃ r' : A, r = algebraMap A K r' ∧ r' ∣ p.coeff 0 := by
/- I tried deducing this from above by unwrapping IsInteger,
but the divisibility condition is annoying -/
obtain ⟨inv, h_inv⟩ := hp ▸ den_dvd_of_is_root hr
use num A r * inv, ?_
· have h : inv ∣ 1 := ⟨den A r, by simpa [mul_comm] using h_inv⟩
simpa using mul_dvd_mul (num_dvd_of_is_root hr) h
· have d_ne_zero : algebraMap A K (den A r) ≠ 0 :=
IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors (den A r).prop
nth_rw 1 [← mk'_num_den' A r]
rw [div_eq_iff d_ne_zero, map_mul, mul_assoc, mul_comm ((algebraMap A K) inv),
← map_mul, ← h_inv, map_one, mul_one]
namespace UniqueFactorizationMonoid
theorem integer_of_integral {x : K} : IsIntegral A x → IsInteger A x := fun ⟨_, hp, hx⟩ =>
isInteger_of_is_root_of_monic hp hx
-- See library note [lower instance priority]
instance (priority := 100) instIsIntegrallyClosed : IsIntegrallyClosed A :=
(isIntegrallyClosed_iff (FractionRing A)).mpr fun {_} => integer_of_integral
end UniqueFactorizationMonoid
end RationalRootTheorem |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Wronskian.lean | import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.LinearAlgebra.SesquilinearForm.Basic
import Mathlib.RingTheory.Coprime.Basic
/-!
# Wronskian of a pair of polynomial
This file defines Wronskian of a pair of polynomials, which is `W(a, b) = ab' - a'b`.
We also prove basic properties of it.
## Main declarations
- `Polynomial.wronskian_eq_of_sum_zero`: We have `W(a, b) = W(b, c)` when `a + b + c = 0`.
- `Polynomial.degree_wronskian_lt_add`: Degree of Wronskian `W(a, b)` is strictly smaller than
the sum of degrees of `a` and `b`
- `Polynomial.natDegree_wronskian_lt_add`: `natDegree` version of the above theorem.
We need to assume that the Wronskian is nonzero. (Otherwise, `a = b = 1` gives a counterexample.)
## TODO
- Define Wronskian for n-tuple of polynomials, not necessarily two.
-/
noncomputable section
open scoped Polynomial
namespace Polynomial
variable {R : Type*} [CommRing R]
/-- Wronskian of a pair of polynomials, `W(a, b) = ab' - a'b`. -/
def wronskian (a b : R[X]) : R[X] :=
a * (derivative b) - (derivative a) * b
variable (R) in
/-- `Polynomial.wronskian` as a bilinear map. -/
def wronskianBilin : R[X] →ₗ[R] R[X] →ₗ[R] R[X] :=
(LinearMap.mul R R[X]).compl₂ derivative - (LinearMap.mul R R[X]).comp derivative
@[simp]
theorem wronskianBilin_apply (a b : R[X]) : wronskianBilin R a b = wronskian a b := rfl
@[simp]
theorem wronskian_zero_left (a : R[X]) : wronskian 0 a = 0 := by
rw [← wronskianBilin_apply 0 a, map_zero]; rfl
@[simp]
theorem wronskian_zero_right (a : R[X]) : wronskian a 0 = 0 := (wronskianBilin R a).map_zero
theorem wronskian_neg_left (a b : R[X]) : wronskian (-a) b = -wronskian a b :=
LinearMap.map_neg₂ (wronskianBilin R) a b
theorem wronskian_neg_right (a b : R[X]) : wronskian a (-b) = -wronskian a b :=
(wronskianBilin R a).map_neg b
theorem wronskian_add_right (a b c : R[X]) : wronskian a (b + c) = wronskian a b + wronskian a c :=
(wronskianBilin R a).map_add b c
theorem wronskian_add_left (a b c : R[X]) : wronskian (a + b) c = wronskian a c + wronskian b c :=
(wronskianBilin R).map_add₂ a b c
theorem wronskian_self_eq_zero (a : R[X]) : wronskian a a = 0 := by
rw [wronskian, mul_comm, sub_self]
theorem isAlt_wronskianBilin : (wronskianBilin R).IsAlt := wronskian_self_eq_zero
theorem wronskian_neg_eq (a b : R[X]) : -wronskian a b = wronskian b a :=
LinearMap.IsAlt.neg isAlt_wronskianBilin a b
theorem wronskian_eq_of_sum_zero {a b c : R[X]} (hAdd : a + b + c = 0) :
wronskian a b = wronskian b c := isAlt_wronskianBilin.eq_of_add_add_eq_zero hAdd
/-- Degree of `W(a,b)` is strictly less than the sum of degrees of `a` and `b` (both nonzero). -/
theorem degree_wronskian_lt_add {a b : R[X]} (ha : a ≠ 0) (hb : b ≠ 0) :
(wronskian a b).degree < a.degree + b.degree := by
calc
(wronskian a b).degree ≤ max (a * derivative b).degree (derivative a * b).degree :=
Polynomial.degree_sub_le _ _
_ < a.degree + b.degree := by
rw [max_lt_iff]
constructor
case left =>
apply lt_of_le_of_lt
· exact degree_mul_le a (derivative b)
· rw [← Polynomial.degree_ne_bot] at ha
rw [WithBot.add_lt_add_iff_left ha]
exact Polynomial.degree_derivative_lt hb
case right =>
apply lt_of_le_of_lt
· exact degree_mul_le (derivative a) b
· rw [← Polynomial.degree_ne_bot] at hb
rw [WithBot.add_lt_add_iff_right hb]
exact Polynomial.degree_derivative_lt ha
/--
`natDegree` version of the above theorem.
Note this would be false with just `(ha : a ≠ 0) (hb : b ≠ 0),
as when `a = b = 1` we have `(wronskian a b).natDegree = a.natDegree = b.natDegree = 0`.
-/
theorem natDegree_wronskian_lt_add {a b : R[X]} (hw : wronskian a b ≠ 0) :
(wronskian a b).natDegree < a.natDegree + b.natDegree := by
have ha : a ≠ 0 := by intro h; subst h; rw [wronskian_zero_left] at hw; exact hw rfl
have hb : b ≠ 0 := by intro h; subst h; rw [wronskian_zero_right] at hw; exact hw rfl
rw [← WithBot.coe_lt_coe, WithBot.coe_add]
convert ← degree_wronskian_lt_add ha hb
· exact Polynomial.degree_eq_natDegree hw
· exact Polynomial.degree_eq_natDegree ha
· exact Polynomial.degree_eq_natDegree hb
/--
For coprime polynomials `a` and `b`, their Wronskian is zero
if and only if their derivatives are zeros.
-/
theorem _root_.IsCoprime.wronskian_eq_zero_iff
[NoZeroDivisors R] {a b : R[X]} (hc : IsCoprime a b) :
wronskian a b = 0 ↔ derivative a = 0 ∧ derivative b = 0 where
mp hw := by
rw [wronskian, sub_eq_iff_eq_add, zero_add] at hw
constructor
· rw [← dvd_derivative_iff]
apply hc.dvd_of_dvd_mul_right
rw [← hw]; exact dvd_mul_right _ _
· rw [← dvd_derivative_iff]
apply hc.symm.dvd_of_dvd_mul_left
rw [hw]; exact dvd_mul_left _ _
mpr hdab := by
obtain ⟨hda, hdb⟩ := hdab
rw [wronskian]
rw [hda, hdb]; simp only [mul_zero, zero_mul, sub_self]
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Radical.lean | import Mathlib.Algebra.Polynomial.FieldDivision
import Mathlib.RingTheory.Polynomial.Wronskian
import Mathlib.RingTheory.Radical
import Mathlib.RingTheory.UniqueFactorizationDomain.Multiplicative
/-!
# Radical of a polynomial
This file proves some theorems on `radical` and `divRadical` of polynomials.
See `RingTheory.Radical` for the definition of `radical` and `divRadical`.
-/
open Polynomial UniqueFactorizationMonoid UniqueFactorizationDomain EuclideanDomain
variable {k : Type*} [Field k] [DecidableEq k]
theorem degree_radical_le {a : k[X]} (h : a ≠ 0) : (radical a).degree ≤ a.degree :=
degree_le_of_dvd radical_dvd_self h
theorem natDegree_radical_le {a : k[X]} :
(radical a).natDegree ≤ a.natDegree := by
by_cases ha : a = 0
· simp [ha]
· exact natDegree_le_of_dvd radical_dvd_self ha
theorem divRadical_dvd_derivative (a : k[X]) : divRadical a ∣ derivative a := by
induction a using induction_on_coprime
· case h0 =>
rw [derivative_zero]
apply dvd_zero
· case h1 a ha =>
exact (divRadical_isUnit ha).dvd
· case hpr p i hp =>
cases i
· rw [pow_zero, derivative_one]
apply dvd_zero
· case succ i =>
rw [← mul_dvd_mul_iff_left radical_ne_zero, radical_mul_divRadical,
radical_pow_of_prime hp i.succ_ne_zero, derivative_pow_succ, ← mul_assoc]
apply dvd_mul_of_dvd_left
rw [mul_comm, mul_assoc]
apply dvd_mul_of_dvd_right
rw [pow_succ, mul_dvd_mul_iff_left (pow_ne_zero i hp.ne_zero), dvd_normalize_iff]
· -- If it holds for coprime pair a and b, then it also holds for a * b.
case hcp x y hpxy hx hy =>
have hc : IsCoprime x y :=
EuclideanDomain.isCoprime_of_dvd
(fun ⟨hx, hy⟩ => not_isUnit_zero (hpxy (zero_dvd_iff.mpr hx) (zero_dvd_iff.mpr hy)))
fun p hp _ hpx hpy => hp (hpxy hpx hpy)
rw [divRadical_mul hc, derivative_mul]
exact dvd_add (mul_dvd_mul hx (divRadical_dvd_self y)) (mul_dvd_mul (divRadical_dvd_self x) hy)
theorem divRadical_dvd_wronskian_left (a b : k[X]) : divRadical a ∣ wronskian a b := by
rw [wronskian]
apply dvd_sub
· apply dvd_mul_of_dvd_left
exact divRadical_dvd_self a
· apply dvd_mul_of_dvd_left
exact divRadical_dvd_derivative a
theorem divRadical_dvd_wronskian_right (a b : k[X]) : divRadical b ∣ wronskian a b := by
rw [← wronskian_neg_eq, dvd_neg]
exact divRadical_dvd_wronskian_left _ _ |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Cyclotomic/Expand.lean | import Mathlib.Algebra.Algebra.ZMod
import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots
/-!
# Cyclotomic polynomials and `expand`.
We gather results relating cyclotomic polynomials and `expand`.
## Main results
* `Polynomial.cyclotomic_expand_eq_cyclotomic_mul` : If `p` is a prime such that `¬ p ∣ n`, then
`expand R p (cyclotomic n R) = (cyclotomic (n * p) R) * (cyclotomic n R)`.
* `Polynomial.cyclotomic_expand_eq_cyclotomic` : If `p` is a prime such that `p ∣ n`, then
`expand R p (cyclotomic n R) = cyclotomic (p * n) R`.
* `Polynomial.cyclotomic_mul_prime_eq_pow_of_not_dvd` : If `R` is of characteristic `p` and
`¬p ∣ n`, then `cyclotomic (n * p) R = (cyclotomic n R) ^ (p - 1)`.
* `Polynomial.cyclotomic_mul_prime_dvd_eq_pow` : If `R` is of characteristic `p` and `p ∣ n`, then
`cyclotomic (n * p) R = (cyclotomic n R) ^ p`.
* `Polynomial.cyclotomic_mul_prime_pow_eq` : If `R` is of characteristic `p` and `¬p ∣ m`, then
`cyclotomic (p ^ k * m) R = (cyclotomic m R) ^ (p ^ k - p ^ (k - 1))`.
-/
namespace Polynomial
/-- If `p` is a prime such that `¬ p ∣ n`, then
`expand R p (cyclotomic n R) = (cyclotomic (n * p) R) * (cyclotomic n R)`. -/
@[simp]
theorem cyclotomic_expand_eq_cyclotomic_mul {p n : ℕ} (hp : Nat.Prime p) (hdiv : ¬p ∣ n)
(R : Type*) [CommRing R] :
expand R p (cyclotomic n R) = cyclotomic (n * p) R * cyclotomic n R := by
rcases Nat.eq_zero_or_pos n with (rfl | hnpos)
· simp
haveI := NeZero.of_pos hnpos
suffices expand ℤ p (cyclotomic n ℤ) = cyclotomic (n * p) ℤ * cyclotomic n ℤ by
rw [← map_cyclotomic_int, ← map_expand, this, Polynomial.map_mul, map_cyclotomic_int,
map_cyclotomic]
refine eq_of_monic_of_dvd_of_natDegree_le ((cyclotomic.monic _ ℤ).mul (cyclotomic.monic _ ℤ))
((cyclotomic.monic n ℤ).expand hp.pos) ?_ ?_
· refine (IsPrimitive.Int.dvd_iff_map_cast_dvd_map_cast _ _
(IsPrimitive.mul (cyclotomic.isPrimitive (n * p) ℤ) (cyclotomic.isPrimitive n ℤ))
((cyclotomic.monic n ℤ).expand hp.pos).isPrimitive).2 ?_
rw [Polynomial.map_mul, map_cyclotomic_int, map_cyclotomic_int, map_expand, map_cyclotomic_int]
refine IsCoprime.mul_dvd (cyclotomic.isCoprime_rat fun h => ?_) ?_ ?_
· replace h : n * p = n * 1 := by simp [h]
exact Nat.Prime.ne_one hp (mul_left_cancel₀ hnpos.ne' h)
· have hpos : 0 < n * p := mul_pos hnpos hp.pos
have hprim := Complex.isPrimitiveRoot_exp _ hpos.ne'
rw [cyclotomic_eq_minpoly_rat hprim hpos]
refine minpoly.dvd ℚ _ ?_
rw [aeval_def, ← eval_map, map_expand, map_cyclotomic, expand_eval, ← IsRoot.def,
@isRoot_cyclotomic_iff]
convert IsPrimitiveRoot.pow_of_dvd hprim hp.ne_zero (dvd_mul_left p n)
rw [Nat.mul_div_cancel _ (Nat.Prime.pos hp)]
· have hprim := Complex.isPrimitiveRoot_exp _ hnpos.ne.symm
rw [cyclotomic_eq_minpoly_rat hprim hnpos]
refine minpoly.dvd ℚ _ ?_
rw [aeval_def, ← eval_map, map_expand, expand_eval, ← IsRoot.def, ←
cyclotomic_eq_minpoly_rat hprim hnpos, map_cyclotomic, @isRoot_cyclotomic_iff]
exact IsPrimitiveRoot.pow_of_prime hprim hp hdiv
· rw [natDegree_expand, natDegree_cyclotomic,
natDegree_mul (cyclotomic_ne_zero _ ℤ) (cyclotomic_ne_zero _ ℤ), natDegree_cyclotomic,
natDegree_cyclotomic, mul_comm n,
Nat.totient_mul ((Nat.Prime.coprime_iff_not_dvd hp).2 hdiv), Nat.totient_prime hp,
mul_comm (p - 1), ← Nat.mul_succ, Nat.sub_one, Nat.succ_pred_eq_of_pos hp.pos]
@[simp]
lemma cyclotomic_six (R : Type*) [Ring R] : cyclotomic 6 R = X ^ 2 - X + 1 := by
suffices cyclotomic 6 ℤ = X ^ 2 - X + 1 by
rw [← map_cyclotomic_int, this]
simp
apply mul_right_cancel₀ (cyclotomic_ne_zero 2 ℤ)
rw [show 6 = 2 * 3 by rfl, ← cyclotomic_expand_eq_cyclotomic_mul Nat.prime_three (by norm_num1)]
simp; ring
/-- If `p` is a prime such that `p ∣ n`, then
`expand R p (cyclotomic n R) = cyclotomic (p * n) R`. -/
@[simp]
theorem cyclotomic_expand_eq_cyclotomic {p n : ℕ} (hp : Nat.Prime p) (hdiv : p ∣ n) (R : Type*)
[CommRing R] : expand R p (cyclotomic n R) = cyclotomic (n * p) R := by
rcases n.eq_zero_or_pos with (rfl | hzero)
· simp
haveI := NeZero.of_pos hzero
suffices expand ℤ p (cyclotomic n ℤ) = cyclotomic (n * p) ℤ by
rw [← map_cyclotomic_int, ← map_expand, this, map_cyclotomic_int]
refine eq_of_monic_of_dvd_of_natDegree_le (cyclotomic.monic _ ℤ)
((cyclotomic.monic n ℤ).expand hp.pos) ?_ ?_
· have hpos := Nat.mul_pos hzero hp.pos
have hprim := Complex.isPrimitiveRoot_exp _ hpos.ne.symm
rw [cyclotomic_eq_minpoly hprim hpos]
refine minpoly.isIntegrallyClosed_dvd (hprim.isIntegral hpos) ?_
rw [aeval_def, ← eval_map, map_expand, map_cyclotomic, expand_eval, ← IsRoot.def,
@isRoot_cyclotomic_iff]
convert IsPrimitiveRoot.pow_of_dvd hprim hp.ne_zero (dvd_mul_left p n)
rw [Nat.mul_div_cancel _ hp.pos]
· rw [natDegree_expand, natDegree_cyclotomic, natDegree_cyclotomic, mul_comm n,
Nat.totient_mul_of_prime_of_dvd hp hdiv, mul_comm]
/-- If the `p ^ n`th cyclotomic polynomial is irreducible, so is the `p ^ m`th, for `m ≤ n`. -/
theorem cyclotomic_irreducible_pow_of_irreducible_pow {p : ℕ} (hp : Nat.Prime p) {R} [CommRing R]
[IsDomain R] {n m : ℕ} (hmn : m ≤ n) (h : Irreducible (cyclotomic (p ^ n) R)) :
Irreducible (cyclotomic (p ^ m) R) := by
rcases m.eq_zero_or_pos with (rfl | hm)
· simpa using irreducible_X_sub_C (1 : R)
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmn
induction k with
| zero => simpa using h
| succ k hk =>
have : m + k ≠ 0 := (add_pos_of_pos_of_nonneg hm k.zero_le).ne'
rw [Nat.add_succ, pow_succ, ← cyclotomic_expand_eq_cyclotomic hp <| dvd_pow_self p this] at h
exact hk (by cutsat) (of_irreducible_expand hp.ne_zero h)
/-- If `Irreducible (cyclotomic (p ^ n) R)` then `Irreducible (cyclotomic p R).` -/
theorem cyclotomic_irreducible_of_irreducible_pow {p : ℕ} (hp : Nat.Prime p) {R} [CommRing R]
[IsDomain R] {n : ℕ} (hn : n ≠ 0) (h : Irreducible (cyclotomic (p ^ n) R)) :
Irreducible (cyclotomic p R) :=
pow_one p ▸ cyclotomic_irreducible_pow_of_irreducible_pow hp hn.bot_lt h
section CharP
/-- If `R` is of characteristic `p` and `¬p ∣ n`, then
`cyclotomic (n * p) R = (cyclotomic n R) ^ (p - 1)`. -/
theorem cyclotomic_mul_prime_eq_pow_of_not_dvd (R : Type*) {p n : ℕ} [hp : Fact (Nat.Prime p)]
[Ring R] [CharP R p] (hn : ¬p ∣ n) : cyclotomic (n * p) R = cyclotomic n R ^ (p - 1) := by
letI : Algebra (ZMod p) R := ZMod.algebra _ _
suffices cyclotomic (n * p) (ZMod p) = cyclotomic n (ZMod p) ^ (p - 1) by
rw [← map_cyclotomic _ (algebraMap (ZMod p) R), ← map_cyclotomic _ (algebraMap (ZMod p) R),
this, Polynomial.map_pow]
apply mul_right_injective₀ (cyclotomic_ne_zero n <| ZMod p); dsimp
rw [← pow_succ', tsub_add_cancel_of_le hp.out.one_lt.le, mul_comm, ← ZMod.expand_card]
conv_rhs => rw [← map_cyclotomic_int]
rw [← map_expand, cyclotomic_expand_eq_cyclotomic_mul hp.out hn, Polynomial.map_mul,
map_cyclotomic, map_cyclotomic]
/-- If `R` is of characteristic `p` and `p ∣ n`, then
`cyclotomic (n * p) R = (cyclotomic n R) ^ p`. -/
theorem cyclotomic_mul_prime_dvd_eq_pow (R : Type*) {p n : ℕ} [hp : Fact (Nat.Prime p)] [Ring R]
[CharP R p] (hn : p ∣ n) : cyclotomic (n * p) R = cyclotomic n R ^ p := by
letI : Algebra (ZMod p) R := ZMod.algebra _ _
suffices cyclotomic (n * p) (ZMod p) = cyclotomic n (ZMod p) ^ p by
rw [← map_cyclotomic _ (algebraMap (ZMod p) R), ← map_cyclotomic _ (algebraMap (ZMod p) R),
this, Polynomial.map_pow]
rw [← ZMod.expand_card, ← map_cyclotomic_int n, ← map_expand,
cyclotomic_expand_eq_cyclotomic hp.out hn, map_cyclotomic]
/-- If `R` is of characteristic `p` and `¬p ∣ m`, then
`cyclotomic (p ^ k * m) R = (cyclotomic m R) ^ (p ^ k - p ^ (k - 1))`. -/
theorem cyclotomic_mul_prime_pow_eq (R : Type*) {p m : ℕ} [Fact (Nat.Prime p)] [Ring R] [CharP R p]
(hm : ¬p ∣ m) : ∀ {k}, 0 < k → cyclotomic (p ^ k * m) R = cyclotomic m R ^ (p ^ k - p ^ (k - 1))
| 1, _ => by
rw [pow_one, Nat.sub_self, pow_zero, mul_comm, cyclotomic_mul_prime_eq_pow_of_not_dvd R hm]
| a + 2, _ => by
have hdiv : p ∣ p ^ a.succ * m := ⟨p ^ a * m, by rw [← mul_assoc, pow_succ']⟩
rw [pow_succ', mul_assoc, mul_comm, cyclotomic_mul_prime_dvd_eq_pow R hdiv,
cyclotomic_mul_prime_pow_eq _ _ a.succ_pos, ← pow_mul]
· simp only [tsub_zero, Nat.succ_sub_succ_eq_sub]
rw [Nat.mul_sub_right_distrib, mul_comm, pow_succ]
· assumption
/-- If `R` is of characteristic `p` and `¬p ∣ m`, then `ζ` is a root of `cyclotomic (p ^ k * m) R`
if and only if it is a primitive `m`-th root of unity. -/
theorem isRoot_cyclotomic_prime_pow_mul_iff_of_charP {m k p : ℕ} {R : Type*} [CommRing R]
[IsDomain R] [hp : Fact (Nat.Prime p)] [hchar : CharP R p] {μ : R} [NeZero (m : R)] :
(Polynomial.cyclotomic (p ^ k * m) R).IsRoot μ ↔ IsPrimitiveRoot μ m := by
rcases k.eq_zero_or_pos with (rfl | hk)
· rw [pow_zero, one_mul, isRoot_cyclotomic_iff]
refine ⟨fun h => ?_, fun h => ?_⟩
· rw [IsRoot.def, cyclotomic_mul_prime_pow_eq R (NeZero.not_char_dvd R p m) hk, eval_pow]
at h
replace h := eq_zero_of_pow_eq_zero h
rwa [← IsRoot.def, isRoot_cyclotomic_iff] at h
· rw [← isRoot_cyclotomic_iff, IsRoot.def] at h
rw [cyclotomic_mul_prime_pow_eq R (NeZero.not_char_dvd R p m) hk, IsRoot.def, eval_pow,
h, zero_pow]
exact Nat.sub_ne_zero_of_lt <| pow_right_strictMono₀ hp.out.one_lt <| Nat.pred_lt hk.ne'
end CharP
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean | import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots
import Mathlib.Tactic.ByContra
import Mathlib.Topology.Algebra.Polynomial
import Mathlib.NumberTheory.Padics.PadicVal.Basic
import Mathlib.Analysis.Complex.Arg
/-!
# Evaluating cyclotomic polynomials
This file states some results about evaluating cyclotomic polynomials in various different ways.
## Main definitions
* `Polynomial.eval(₂)_one_cyclotomic_prime(_pow)`: `eval 1 (cyclotomic p^k R) = p`.
* `Polynomial.eval_one_cyclotomic_not_prime_pow`: Otherwise, `eval 1 (cyclotomic n R) = 1`.
* `Polynomial.cyclotomic_pos` : `∀ x, 0 < eval x (cyclotomic n R)` if `2 < n`.
-/
namespace Polynomial
open Finset Nat
@[simp]
theorem eval_one_cyclotomic_prime {R : Type*} [CommRing R] {p : ℕ} [hn : Fact p.Prime] :
eval 1 (cyclotomic p R) = p := by
simp only [cyclotomic_prime, eval_X, one_pow, Finset.sum_const, eval_pow, eval_finset_sum,
Finset.card_range, smul_one_eq_cast]
theorem eval₂_one_cyclotomic_prime {R S : Type*} [CommRing R] [Semiring S] (f : R →+* S) {p : ℕ}
[Fact p.Prime] : eval₂ f 1 (cyclotomic p R) = p := by simp
@[simp]
theorem eval_one_cyclotomic_prime_pow {R : Type*} [CommRing R] {p : ℕ} (k : ℕ)
[hn : Fact p.Prime] : eval 1 (cyclotomic (p ^ (k + 1)) R) = p := by
simp only [cyclotomic_prime_pow_eq_geom_sum hn.out, eval_X, one_pow, Finset.sum_const, eval_pow,
eval_finset_sum, Finset.card_range, smul_one_eq_cast]
theorem eval₂_one_cyclotomic_prime_pow {R S : Type*} [CommRing R] [Semiring S] (f : R →+* S)
{p : ℕ} (k : ℕ) [Fact p.Prime] : eval₂ f 1 (cyclotomic (p ^ (k + 1)) R) = p := by simp
private theorem cyclotomic_neg_one_pos {n : ℕ} (hn : 2 < n) {R}
[CommRing R] [PartialOrder R] [IsStrictOrderedRing R] :
0 < eval (-1 : R) (cyclotomic n R) := by
haveI := NeZero.of_gt hn
rw [← map_cyclotomic_int, ← Int.cast_one, ← Int.cast_neg, eval_intCast_map, Int.coe_castRingHom,
Int.cast_pos]
suffices 0 < eval (↑(-1 : ℤ)) (cyclotomic n ℝ) by
rw [← map_cyclotomic_int n ℝ, eval_intCast_map, Int.coe_castRingHom] at this
simpa only [Int.cast_pos] using this
simp only [Int.cast_one, Int.cast_neg]
have h0 := cyclotomic_coeff_zero ℝ hn.le
rw [coeff_zero_eq_eval_zero] at h0
by_contra! hx
have := intermediate_value_univ (-1) 0 (cyclotomic n ℝ).continuous
obtain ⟨y, hy : IsRoot _ y⟩ := this (show (0 : ℝ) ∈ Set.Icc _ _ by simpa [h0] using hx)
rw [@isRoot_cyclotomic_iff] at hy
rw [hy.eq_orderOf] at hn
exact hn.not_ge LinearOrderedRing.orderOf_le_two
theorem cyclotomic_pos {n : ℕ} (hn : 2 < n) {R}
[CommRing R] [LinearOrder R] [IsStrictOrderedRing R] (x : R) :
0 < eval x (cyclotomic n R) := by
induction n using Nat.strong_induction_on with | _ n ih
have hn' : 0 < n := pos_of_gt hn
have hn'' : 1 < n := one_lt_two.trans hn
have := prod_cyclotomic_eq_geom_sum hn' R
apply_fun eval x at this
rw [← cons_self_properDivisors hn'.ne', Finset.erase_cons_of_ne _ hn''.ne', Finset.prod_cons,
eval_mul, eval_geom_sum] at this
rcases lt_trichotomy 0 (∑ i ∈ Finset.range n, x ^ i) with (h | h | h)
· apply pos_of_mul_pos_left
· rwa [this]
rw [eval_prod]
refine Finset.prod_nonneg fun i hi => ?_
simp only [Finset.mem_erase, mem_properDivisors] at hi
rw [geom_sum_pos_iff hn'.ne'] at h
rcases h with hk | hx
· refine (ih _ hi.2.2 (Nat.two_lt_of_ne ?_ hi.1 ?_)).le <;> rintro rfl
· exact hn'.ne' (zero_dvd_iff.mp hi.2.1)
· exact not_odd_iff_even.2 (even_iff_two_dvd.mpr hi.2.1) hk
· rcases eq_or_ne i 2 with (rfl | hk)
· simpa only [eval_X, eval_one, cyclotomic_two, eval_add] using hx.le
refine (ih _ hi.2.2 (Nat.two_lt_of_ne ?_ hi.1 hk)).le
rintro rfl
exact hn'.ne' <| zero_dvd_iff.mp hi.2.1
· rw [eq_comm, geom_sum_eq_zero_iff_neg_one hn'.ne'] at h
exact h.1.symm ▸ cyclotomic_neg_one_pos hn
· apply pos_of_mul_neg_left
· rwa [this]
rw [geom_sum_neg_iff hn'.ne'] at h
have h2 : 2 ∈ n.properDivisors.erase 1 := by
rw [Finset.mem_erase, mem_properDivisors]
exact ⟨by decide, even_iff_two_dvd.mp h.1, hn⟩
rw [eval_prod, ← Finset.prod_erase_mul _ _ h2]
apply mul_nonpos_of_nonneg_of_nonpos
· refine Finset.prod_nonneg fun i hi => le_of_lt ?_
simp only [Finset.mem_erase, mem_properDivisors] at hi
refine ih _ hi.2.2.2 (Nat.two_lt_of_ne ?_ hi.2.1 hi.1)
rintro rfl
rw [zero_dvd_iff] at hi
exact hn'.ne' hi.2.2.1
· simpa only [eval_X, eval_one, cyclotomic_two, eval_add] using h.right.le
theorem cyclotomic_pos_and_nonneg (n : ℕ) {R}
[CommRing R] [LinearOrder R] [IsStrictOrderedRing R] (x : R) :
(1 < x → 0 < eval x (cyclotomic n R)) ∧ (1 ≤ x → 0 ≤ eval x (cyclotomic n R)) := by
rcases n with (_ | _ | _ | n)
· simp only [cyclotomic_zero, eval_one, zero_lt_one, implies_true, zero_le_one, and_self]
· simp only [zero_add, cyclotomic_one, eval_sub, eval_X, eval_one, sub_pos, imp_self, sub_nonneg,
and_self]
· simp only [zero_add, reduceAdd, cyclotomic_two, eval_add, eval_X, eval_one]
constructor <;> intro <;> linarith
· constructor <;> intro <;> [skip; apply le_of_lt] <;> apply cyclotomic_pos (by cutsat)
/-- Cyclotomic polynomials are always positive on inputs larger than one.
Similar to `cyclotomic_pos` but with the condition on the input rather than index of the
cyclotomic polynomial. -/
theorem cyclotomic_pos' (n : ℕ) {R}
[CommRing R] [LinearOrder R] [IsStrictOrderedRing R] {x : R} (hx : 1 < x) :
0 < eval x (cyclotomic n R) :=
(cyclotomic_pos_and_nonneg n x).1 hx
/-- Cyclotomic polynomials are always nonnegative on inputs one or more. -/
theorem cyclotomic_nonneg (n : ℕ) {R}
[CommRing R] [LinearOrder R] [IsStrictOrderedRing R] {x : R} (hx : 1 ≤ x) :
0 ≤ eval x (cyclotomic n R) :=
(cyclotomic_pos_and_nonneg n x).2 hx
theorem eval_one_cyclotomic_not_prime_pow {R : Type*} [Ring R] {n : ℕ}
(h : ∀ {p : ℕ}, p.Prime → ∀ k : ℕ, p ^ k ≠ n) : eval 1 (cyclotomic n R) = 1 := by
rcases n.eq_zero_or_pos with (rfl | hn')
· simp
have hn : 1 < n := one_lt_iff_ne_zero_and_ne_one.mpr ⟨hn'.ne', (h Nat.prime_two 0).symm⟩
rsuffices h | h : eval 1 (cyclotomic n ℤ) = 1 ∨ eval 1 (cyclotomic n ℤ) = -1
· have := eval_intCast_map (Int.castRingHom R) (cyclotomic n ℤ) 1
simpa only [map_cyclotomic, Int.cast_one, h, eq_intCast] using this
· exfalso
linarith [cyclotomic_nonneg n (le_refl (1 : ℤ))]
rw [← Int.natAbs_eq_natAbs_iff, Int.natAbs_one, Nat.eq_one_iff_not_exists_prime_dvd]
intro p hp hpe
haveI := Fact.mk hp
have := prod_cyclotomic_eq_geom_sum hn' ℤ
apply_fun eval 1 at this
rw [eval_geom_sum, one_geom_sum, eval_prod, eq_comm, ←
Finset.prod_sdiff <| @range_pow_padicValNat_subset_divisors' p _ _, Finset.prod_image] at this
· simp_rw [eval_one_cyclotomic_prime_pow, Finset.prod_const, Finset.card_range, mul_comm] at this
rw [← Finset.prod_sdiff <| show {n} ⊆ _ from _] at this
swap
· simp only [singleton_subset_iff, mem_sdiff, mem_erase, Ne, mem_divisors, dvd_refl,
true_and, mem_image, mem_range, not_exists, not_and]
exact ⟨⟨hn.ne', hn'.ne'⟩, fun t _ => h hp _⟩
rw [← Int.natAbs_natCast p, Int.natAbs_dvd_natAbs] at hpe
obtain ⟨t, ht⟩ := hpe
rw [Finset.prod_singleton, ht, mul_left_comm, mul_comm, ← mul_assoc, mul_assoc] at this
have : (p : ℤ) ^ padicValNat p n * p ∣ n := ⟨_, this⟩
simp only [← _root_.pow_succ, ← Int.natAbs_dvd_natAbs, Int.natAbs_natCast,
Int.natAbs_pow] at this
exact pow_succ_padicValNat_not_dvd hn'.ne' this
· rintro x - y - hxy
apply Nat.succ_injective
exact Nat.pow_right_injective hp.two_le hxy
theorem sub_one_pow_totient_lt_cyclotomic_eval {n : ℕ} {q : ℝ} (hn' : 2 ≤ n) (hq' : 1 < q) :
(q - 1) ^ totient n < (cyclotomic n ℝ).eval q := by
have hn : 0 < n := pos_of_gt hn'
have hq := zero_lt_one.trans hq'
have hfor : ∀ ζ' ∈ primitiveRoots n ℂ, q - 1 ≤ ‖↑q - ζ'‖ := by
intro ζ' hζ'
rw [mem_primitiveRoots hn] at hζ'
convert norm_sub_norm_le (↑q) ζ'
· rw [Complex.norm_real, Real.norm_of_nonneg hq.le]
· rw [hζ'.norm'_eq_one hn.ne']
let ζ := Complex.exp (2 * ↑Real.pi * Complex.I / ↑n)
have hζ : IsPrimitiveRoot ζ n := Complex.isPrimitiveRoot_exp n hn.ne'
have hex : ∃ ζ' ∈ primitiveRoots n ℂ, q - 1 < ‖↑q - ζ'‖ := by
refine ⟨ζ, (mem_primitiveRoots hn).mpr hζ, ?_⟩
suffices ¬SameRay ℝ (q : ℂ) ζ by
convert lt_norm_sub_of_not_sameRay this <;>
simp only [hζ.norm'_eq_one hn.ne', Real.norm_of_nonneg hq.le, Complex.norm_real]
rw [Complex.sameRay_iff]
push_neg
refine ⟨mod_cast hq.ne', hζ.ne_zero hn.ne', ?_⟩
rw [Complex.arg_ofReal_of_nonneg hq.le, Ne, eq_comm, hζ.arg_eq_zero_iff hn.ne']
clear_value ζ
rintro rfl
linarith [hζ.unique IsPrimitiveRoot.one]
have : ¬eval (↑q) (cyclotomic n ℂ) = 0 := by simpa using (cyclotomic_pos' n hq').ne'
suffices Units.mk0 (Real.toNNReal (q - 1)) (by simp [hq']) ^ totient n <
Units.mk0 ‖(cyclotomic n ℂ).eval ↑q‖₊ (by simp_all) by
simp [← Units.val_lt_val, Units.val_pow_eq_pow_val, Units.val_mk0, ← NNReal.coe_lt_coe,
hq'.le, coe_nnnorm, NNReal.coe_pow,
Real.coe_toNNReal', sub_nonneg] at this
convert this
rw [eq_comm]
simp [cyclotomic_nonneg n hq'.le]
simp only [cyclotomic_eq_prod_X_sub_primitiveRoots hζ, eval_prod, eval_C, eval_X, eval_sub,
nnnorm_prod, Units.mk0_prod]
convert Finset.prod_lt_prod' (M := NNRealˣ) _ _
swap; · exact fun _ => Units.mk0 (Real.toNNReal (q - 1)) (by simp [hq'])
· simp only [Complex.card_primitiveRoots, prod_const, card_attach]
· simp only [Finset.mem_attach, forall_true_left, Subtype.forall, ←
Units.val_le_val, ← NNReal.coe_le_coe, norm_nonneg, Units.val_mk0,
Real.coe_toNNReal', coe_nnnorm, max_le_iff, tsub_le_iff_right]
intro x hx
simpa only [and_true, tsub_le_iff_right] using hfor x hx
· simp only [Finset.mem_attach, Subtype.exists, ←
NNReal.coe_lt_coe, ← Units.val_lt_val, Units.val_mk0 _, coe_nnnorm]
simpa [hq'.le, Real.coe_toNNReal', max_eq_left, sub_nonneg] using hex
theorem sub_one_pow_totient_le_cyclotomic_eval {q : ℝ} (hq' : 1 < q) :
∀ n, (q - 1) ^ totient n ≤ (cyclotomic n ℝ).eval q
| 0 => by simp only [totient_zero, _root_.pow_zero, cyclotomic_zero, eval_one, le_refl]
| 1 => by simp only [totient_one, pow_one, cyclotomic_one, eval_sub, eval_X, eval_one, le_refl]
| _ + 2 => (sub_one_pow_totient_lt_cyclotomic_eval le_add_self hq').le
theorem cyclotomic_eval_lt_add_one_pow_totient {n : ℕ} {q : ℝ} (hn' : 3 ≤ n) (hq' : 1 < q) :
(cyclotomic n ℝ).eval q < (q + 1) ^ totient n := by
have hn : 0 < n := pos_of_gt hn'
have hq := zero_lt_one.trans hq'
have hfor : ∀ ζ' ∈ primitiveRoots n ℂ, ‖↑q - ζ'‖ ≤ q + 1 := by
intro ζ' hζ'
rw [mem_primitiveRoots hn] at hζ'
convert norm_sub_le (↑q) ζ'
· rw [Complex.norm_real, Real.norm_of_nonneg (zero_le_one.trans_lt hq').le]
· rw [hζ'.norm'_eq_one hn.ne']
let ζ := Complex.exp (2 * ↑Real.pi * Complex.I / ↑n)
have hζ : IsPrimitiveRoot ζ n := Complex.isPrimitiveRoot_exp n hn.ne'
have hex : ∃ ζ' ∈ primitiveRoots n ℂ, ‖↑q - ζ'‖ < q + 1 := by
refine ⟨ζ, (mem_primitiveRoots hn).mpr hζ, ?_⟩
suffices ¬SameRay ℝ (q : ℂ) (-ζ) by
convert norm_add_lt_of_not_sameRay this using 2
· rw [Complex.norm_real]
symm
exact abs_eq_self.mpr hq.le
· simp [hζ.norm'_eq_one hn.ne']
rw [Complex.sameRay_iff]
push_neg
refine ⟨mod_cast hq.ne', neg_ne_zero.mpr <| hζ.ne_zero hn.ne', ?_⟩
rw [Complex.arg_ofReal_of_nonneg hq.le, Ne, eq_comm]
intro h
rw [Complex.arg_eq_zero_iff, Complex.neg_re, neg_nonneg, Complex.neg_im, neg_eq_zero] at h
have hζ₀ : ζ ≠ 0 := by
clear_value ζ
rintro rfl
exact hn.ne' (hζ.unique IsPrimitiveRoot.zero)
have : ζ.re < 0 ∧ ζ.im = 0 := ⟨h.1.lt_of_ne ?_, h.2⟩
· rw [← Complex.arg_eq_pi_iff, hζ.arg_eq_pi_iff hn.ne'] at this
rw [this] at hζ
linarith [hζ.unique <| IsPrimitiveRoot.neg_one 0 two_ne_zero.symm]
· contrapose! hζ₀
apply Complex.ext <;> simp [hζ₀, h.2]
have : ¬eval (↑q) (cyclotomic n ℂ) = 0 := by simpa using (cyclotomic_pos' n hq').ne.symm
suffices Units.mk0 ‖(cyclotomic n ℂ).eval ↑q‖₊ (by simp_all) <
Units.mk0 (Real.toNNReal (q + 1)) (by simp; linarith) ^ totient n by
simp only [← Units.val_lt_val, Units.val_pow_eq_pow_val, Units.val_mk0, ← NNReal.coe_lt_coe,
coe_nnnorm, NNReal.coe_pow,
Real.coe_toNNReal'] at this
convert this using 2
· rw [eq_comm]
simp [cyclotomic_nonneg n hq'.le]
rw [eq_comm, max_eq_left_iff]
linarith
simp only [cyclotomic_eq_prod_X_sub_primitiveRoots hζ, eval_prod, eval_C, eval_X, eval_sub,
nnnorm_prod, Units.mk0_prod]
convert Finset.prod_lt_prod' (M := NNRealˣ) _ _
swap; · exact fun _ => Units.mk0 (Real.toNNReal (q + 1)) (by simp; linarith only [hq'])
· simp [Complex.card_primitiveRoots]
· simp only [Finset.mem_attach, forall_true_left, Subtype.forall, ←
Units.val_le_val, ← NNReal.coe_le_coe, Units.val_mk0,
coe_nnnorm]
intro x hx
have : ‖_‖ ≤ _ := hfor x hx
simp [this]
· simp only [Finset.mem_attach, Subtype.exists, ←
NNReal.coe_lt_coe, ← Units.val_lt_val, Units.val_mk0 _, coe_nnnorm]
obtain ⟨ζ, hζ, hhζ : ‖_‖ < _⟩ := hex
exact ⟨ζ, hζ, by simp [hhζ]⟩
theorem cyclotomic_eval_le_add_one_pow_totient {q : ℝ} (hq' : 1 < q) :
∀ n, (cyclotomic n ℝ).eval q ≤ (q + 1) ^ totient n
| 0 => by simp
| 1 => by simp [add_assoc, zero_le_one]
| 2 => by simp
| _ + 3 => (cyclotomic_eval_lt_add_one_pow_totient le_add_self hq').le
theorem sub_one_pow_totient_lt_natAbs_cyclotomic_eval {n : ℕ} {q : ℕ} (hn' : 1 < n) (hq : q ≠ 1) :
(q - 1) ^ totient n < ((cyclotomic n ℤ).eval ↑q).natAbs := by
rcases hq.lt_or_gt.imp_left Nat.lt_one_iff.mp with (rfl | hq')
· rw [zero_tsub, zero_pow (Nat.totient_pos.2 (pos_of_gt hn')).ne', pos_iff_ne_zero,
Int.natAbs_ne_zero, Nat.cast_zero, ← coeff_zero_eq_eval_zero, cyclotomic_coeff_zero _ hn']
exact one_ne_zero
rw [← @Nat.cast_lt ℝ, Nat.cast_pow, Nat.cast_sub hq'.le, Nat.cast_one, Nat.cast_natAbs]
refine (sub_one_pow_totient_lt_cyclotomic_eval hn' (Nat.one_lt_cast.2 hq')).trans_le ?_
convert (cyclotomic.eval_apply (q : ℤ) n (algebraMap ℤ ℝ)).trans_le (le_abs_self _)
simp
theorem sub_one_lt_natAbs_cyclotomic_eval {n : ℕ} {q : ℕ} (hn' : 1 < n) (hq : q ≠ 1) :
q - 1 < ((cyclotomic n ℤ).eval ↑q).natAbs :=
calc
q - 1 ≤ (q - 1) ^ totient n := Nat.le_self_pow (Nat.totient_pos.2 <| pos_of_gt hn').ne' _
_ < ((cyclotomic n ℤ).eval ↑q).natAbs := sub_one_pow_totient_lt_natAbs_cyclotomic_eval hn' hq
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean | import Mathlib.Algebra.Polynomial.Splits
import Mathlib.FieldTheory.RatFunc.AsPolynomial
import Mathlib.NumberTheory.ArithmeticFunction
import Mathlib.RingTheory.RootsOfUnity.Complex
/-!
# Cyclotomic polynomials.
For `n : ℕ` and an integral domain `R`, we define a modified version of the `n`-th cyclotomic
polynomial with coefficients in `R`, denoted `cyclotomic' n R`, as `∏ (X - μ)`, where `μ` varies
over the primitive `n`th roots of unity. If there is a primitive `n`th root of unity in `R` then
this the standard definition. We then define the standard cyclotomic polynomial `cyclotomic n R`
with coefficients in any ring `R`.
## Main definition
* `cyclotomic n R` : the `n`-th cyclotomic polynomial with coefficients in `R`.
## Main results
* `Polynomial.degree_cyclotomic` : The degree of `cyclotomic n` is `totient n`.
* `Polynomial.prod_cyclotomic_eq_X_pow_sub_one` : `X ^ n - 1 = ∏ (cyclotomic i)`, where `i`
divides `n`.
* `Polynomial.cyclotomic_eq_prod_X_pow_sub_one_pow_moebius` : The Möbius inversion formula for
`cyclotomic n R` over an abstract fraction field for `R[X]`.
## Implementation details
Our definition of `cyclotomic' n R` makes sense in any integral domain `R`, but the interesting
results hold if there is a primitive `n`-th root of unity in `R`. In particular, our definition is
not the standard one unless there is a primitive `n`th root of unity in `R`. For example,
`cyclotomic' 3 ℤ = 1`, since there are no primitive cube roots of unity in `ℤ`. The main example is
`R = ℂ`, we decided to work in general since the difficulties are essentially the same.
To get the standard cyclotomic polynomials, we use `unique_int_coeff_of_cycl`, with `R = ℂ`,
to get a polynomial with integer coefficients and then we map it to `R[X]`, for any ring `R`.
-/
open scoped Polynomial
noncomputable section
universe u
namespace Polynomial
section Cyclotomic'
section IsDomain
variable {R : Type*} [CommRing R] [IsDomain R]
/-- The modified `n`-th cyclotomic polynomial with coefficients in `R`, it is the usual cyclotomic
polynomial if there is a primitive `n`-th root of unity in `R`. -/
def cyclotomic' (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] : R[X] :=
∏ μ ∈ primitiveRoots n R, (X - C μ)
/-- The zeroth modified cyclotomic polynomial is `1`. -/
@[simp]
theorem cyclotomic'_zero (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 0 R = 1 := by
simp only [cyclotomic', Finset.prod_empty, primitiveRoots_zero]
/-- The first modified cyclotomic polynomial is `X - 1`. -/
@[simp]
theorem cyclotomic'_one (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 1 R = X - 1 := by
simp only [cyclotomic', Finset.prod_singleton, RingHom.map_one,
IsPrimitiveRoot.primitiveRoots_one]
/-- The second modified cyclotomic polynomial is `X + 1` if the characteristic of `R` is not `2`. -/
-- Cannot be @[simp] because `p` cannot be inferred by `simp`.
theorem cyclotomic'_two (R : Type*) [CommRing R] [IsDomain R] (p : ℕ) [CharP R p] (hp : p ≠ 2) :
cyclotomic' 2 R = X + 1 := by
rw [cyclotomic']
have prim_root_two : primitiveRoots 2 R = {(-1 : R)} := by
simp only [Finset.eq_singleton_iff_unique_mem, mem_primitiveRoots two_pos]
exact ⟨IsPrimitiveRoot.neg_one p hp, fun x => IsPrimitiveRoot.eq_neg_one_of_two_right⟩
simp only [prim_root_two, Finset.prod_singleton, RingHom.map_neg, RingHom.map_one, sub_neg_eq_add]
/-- `cyclotomic' n R` is monic. -/
theorem cyclotomic'.monic (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] :
(cyclotomic' n R).Monic :=
monic_prod_of_monic _ _ fun _ _ => monic_X_sub_C _
/-- `cyclotomic' n R` is different from `0`. -/
theorem cyclotomic'_ne_zero (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' n R ≠ 0 :=
(cyclotomic'.monic n R).ne_zero
/-- The natural degree of `cyclotomic' n R` is `totient n` if there is a primitive root of
unity in `R`. -/
theorem natDegree_cyclotomic' {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
(cyclotomic' n R).natDegree = Nat.totient n := by
rw [cyclotomic']
rw [natDegree_prod (primitiveRoots n R) fun z : R => X - C z]
· simp only [IsPrimitiveRoot.card_primitiveRoots h, mul_one, natDegree_X_sub_C, Nat.cast_id,
Finset.sum_const, nsmul_eq_mul]
intro z _
exact X_sub_C_ne_zero z
/-- The degree of `cyclotomic' n R` is `totient n` if there is a primitive root of unity in `R`. -/
theorem degree_cyclotomic' {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
(cyclotomic' n R).degree = Nat.totient n := by
simp only [degree_eq_natDegree (cyclotomic'_ne_zero n R), natDegree_cyclotomic' h]
/-- The roots of `cyclotomic' n R` are the primitive `n`-th roots of unity. -/
theorem roots_of_cyclotomic (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] :
(cyclotomic' n R).roots = (primitiveRoots n R).val := by
rw [cyclotomic']; exact roots_prod_X_sub_C (primitiveRoots n R)
/-- If there is a primitive `n`th root of unity in `K`, then `X ^ n - 1 = ∏ (X - μ)`, where `μ`
varies over the `n`-th roots of unity. -/
theorem X_pow_sub_one_eq_prod {ζ : R} {n : ℕ} (hpos : 0 < n) (h : IsPrimitiveRoot ζ n) :
X ^ n - 1 = ∏ ζ ∈ nthRootsFinset n (1 : R), (X - C ζ) := by
classical
rw [nthRootsFinset, ← Multiset.toFinset_eq (IsPrimitiveRoot.nthRoots_one_nodup h)]
simp only [Finset.prod_mk]
rw [nthRoots]
have hmonic : (X ^ n - C (1 : R)).Monic := monic_X_pow_sub_C (1 : R) (ne_of_lt hpos).symm
symm
apply prod_multiset_X_sub_C_of_monic_of_roots_card_eq hmonic
rw [@natDegree_X_pow_sub_C R _ _ n 1, ← nthRoots]
exact IsPrimitiveRoot.card_nthRoots_one h
end IsDomain
section Field
variable {K : Type*} [Field K]
/-- `cyclotomic' n K` splits. -/
theorem cyclotomic'_splits (n : ℕ) : Splits (RingHom.id K) (cyclotomic' n K) := by
apply splits_prod (RingHom.id K)
intro z _
simp only [splits_X_sub_C (RingHom.id K)]
/-- If there is a primitive `n`-th root of unity in `K`, then `X ^ n - 1` splits. -/
theorem X_pow_sub_one_splits {ζ : K} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
Splits (RingHom.id K) (X ^ n - C (1 : K)) := by
rw [splits_iff_card_roots, ← nthRoots, IsPrimitiveRoot.card_nthRoots_one h, natDegree_X_pow_sub_C]
/-- If there is a primitive `n`-th root of unity in `K`, then
`∏ i ∈ Nat.divisors n, cyclotomic' i K = X ^ n - 1`. -/
theorem prod_cyclotomic'_eq_X_pow_sub_one {K : Type*} [CommRing K] [IsDomain K] {ζ : K} {n : ℕ}
(hpos : 0 < n) (h : IsPrimitiveRoot ζ n) :
∏ i ∈ Nat.divisors n, cyclotomic' i K = X ^ n - 1 := by
classical
have hd : (n.divisors : Set ℕ).PairwiseDisjoint fun k => primitiveRoots k K :=
fun x _ y _ hne => IsPrimitiveRoot.disjoint hne
simp only [X_pow_sub_one_eq_prod hpos h, cyclotomic', ← Finset.prod_biUnion hd,
IsPrimitiveRoot.nthRoots_one_eq_biUnion_primitiveRoots]
/-- If there is a primitive `n`-th root of unity in `K`, then
`cyclotomic' n K = (X ^ k - 1) /ₘ (∏ i ∈ Nat.properDivisors k, cyclotomic' i K)`. -/
theorem cyclotomic'_eq_X_pow_sub_one_div {K : Type*} [CommRing K] [IsDomain K] {ζ : K} {n : ℕ}
(hpos : 0 < n) (h : IsPrimitiveRoot ζ n) :
cyclotomic' n K = (X ^ n - 1) /ₘ ∏ i ∈ Nat.properDivisors n, cyclotomic' i K := by
rw [← prod_cyclotomic'_eq_X_pow_sub_one hpos h, ← Nat.cons_self_properDivisors hpos.ne',
Finset.prod_cons]
have prod_monic : (∏ i ∈ Nat.properDivisors n, cyclotomic' i K).Monic := by
apply monic_prod_of_monic
intro i _
exact cyclotomic'.monic i K
rw [(div_modByMonic_unique (cyclotomic' n K) 0 prod_monic _).1]
simp only [degree_zero, zero_add]
refine ⟨by rw [mul_comm], ?_⟩
rw [bot_lt_iff_ne_bot]
intro h
exact Monic.ne_zero prod_monic (degree_eq_bot.1 h)
/-- If there is a primitive `n`-th root of unity in `K`, then `cyclotomic' n K` comes from a
monic polynomial with integer coefficients. -/
theorem int_coeff_of_cyclotomic' {K : Type*} [CommRing K] [IsDomain K] {ζ : K} {n : ℕ}
(h : IsPrimitiveRoot ζ n) : ∃ P : ℤ[X], map (Int.castRingHom K) P =
cyclotomic' n K ∧ P.degree = (cyclotomic' n K).degree ∧ P.Monic := by
refine lifts_and_degree_eq_and_monic ?_ (cyclotomic'.monic n K)
induction n using Nat.strong_induction_on generalizing ζ with | _ k ihk
rcases k.eq_zero_or_pos with (rfl | hpos)
· use 1
simp only [cyclotomic'_zero, coe_mapRingHom, Polynomial.map_one]
let B : K[X] := ∏ i ∈ Nat.properDivisors k, cyclotomic' i K
have Bmo : B.Monic := by
apply monic_prod_of_monic
intro i _
exact cyclotomic'.monic i K
have Bint : B ∈ lifts (Int.castRingHom K) := by
refine Subsemiring.prod_mem (lifts (Int.castRingHom K)) ?_
intro x hx
have xsmall := (Nat.mem_properDivisors.1 hx).2
obtain ⟨d, hd⟩ := (Nat.mem_properDivisors.1 hx).1
rw [mul_comm] at hd
exact ihk x xsmall (h.pow hpos hd)
replace Bint := lifts_and_degree_eq_and_monic Bint Bmo
obtain ⟨B₁, hB₁, _, hB₁mo⟩ := Bint
let Q₁ : ℤ[X] := (X ^ k - 1) /ₘ B₁
have huniq : 0 + B * cyclotomic' k K = X ^ k - 1 ∧ (0 : K[X]).degree < B.degree := by
constructor
· rw [zero_add, mul_comm, ← prod_cyclotomic'_eq_X_pow_sub_one hpos h, ←
Nat.cons_self_properDivisors hpos.ne', Finset.prod_cons]
· simpa only [degree_zero, bot_lt_iff_ne_bot, Ne, degree_eq_bot] using Bmo.ne_zero
replace huniq := div_modByMonic_unique (cyclotomic' k K) (0 : K[X]) Bmo huniq
simp only [lifts, RingHom.mem_rangeS]
use Q₁
rw [coe_mapRingHom, map_divByMonic (Int.castRingHom K) hB₁mo, hB₁, ← huniq.1]
simp
/-- If `K` is of characteristic `0` and there is a primitive `n`-th root of unity in `K`,
then `cyclotomic n K` comes from a unique polynomial with integer coefficients. -/
theorem unique_int_coeff_of_cycl {K : Type*} [CommRing K] [IsDomain K] [CharZero K] {ζ : K}
{n : ℕ+} (h : IsPrimitiveRoot ζ n) :
∃! P : ℤ[X], map (Int.castRingHom K) P = cyclotomic' n K := by
obtain ⟨P, hP⟩ := int_coeff_of_cyclotomic' h
refine ⟨P, hP.1, fun Q hQ => ?_⟩
apply map_injective (Int.castRingHom K) Int.cast_injective
rw [hP.1, hQ]
end Field
end Cyclotomic'
section Cyclotomic
/-- The `n`-th cyclotomic polynomial with coefficients in `R`. -/
def cyclotomic (n : ℕ) (R : Type*) [Ring R] : R[X] :=
if h : n = 0 then 1
else map (Int.castRingHom R) (int_coeff_of_cyclotomic' (Complex.isPrimitiveRoot_exp n h)).choose
theorem int_cyclotomic_rw {n : ℕ} (h : n ≠ 0) :
cyclotomic n ℤ = (int_coeff_of_cyclotomic' (Complex.isPrimitiveRoot_exp n h)).choose := by
simp only [cyclotomic, h, dif_neg, not_false_iff]
ext i
simp only [coeff_map, Int.cast_id, eq_intCast]
/-- `cyclotomic n R` comes from `cyclotomic n ℤ`. -/
theorem map_cyclotomic_int (n : ℕ) (R : Type*) [Ring R] :
map (Int.castRingHom R) (cyclotomic n ℤ) = cyclotomic n R := by
by_cases hzero : n = 0
· simp only [hzero, cyclotomic, dif_pos, Polynomial.map_one]
simp [cyclotomic, hzero]
theorem int_cyclotomic_spec (n : ℕ) :
map (Int.castRingHom ℂ) (cyclotomic n ℤ) = cyclotomic' n ℂ ∧
(cyclotomic n ℤ).degree = (cyclotomic' n ℂ).degree ∧ (cyclotomic n ℤ).Monic := by
by_cases hzero : n = 0
· simp only [hzero, cyclotomic, degree_one, monic_one, cyclotomic'_zero, dif_pos,
Polynomial.map_one, and_self_iff]
rw [int_cyclotomic_rw hzero]
exact (int_coeff_of_cyclotomic' (Complex.isPrimitiveRoot_exp n hzero)).choose_spec
theorem int_cyclotomic_unique {n : ℕ} {P : ℤ[X]} (h : map (Int.castRingHom ℂ) P = cyclotomic' n ℂ) :
P = cyclotomic n ℤ := by
apply map_injective (Int.castRingHom ℂ) Int.cast_injective
rw [h, (int_cyclotomic_spec n).1]
/-- The definition of `cyclotomic n R` commutes with any ring homomorphism. -/
@[simp]
theorem map_cyclotomic (n : ℕ) {R S : Type*} [Ring R] [Ring S] (f : R →+* S) :
map f (cyclotomic n R) = cyclotomic n S := by
rw [← map_cyclotomic_int n R, ← map_cyclotomic_int n S, map_map]
have : Subsingleton (ℤ →+* S) := inferInstance
congr!
theorem cyclotomic.eval_apply {R S : Type*} (q : R) (n : ℕ) [Ring R] [Ring S] (f : R →+* S) :
eval (f q) (cyclotomic n S) = f (eval q (cyclotomic n R)) := by
rw [← map_cyclotomic n f, eval_map, eval₂_at_apply]
@[simp] theorem cyclotomic.eval_apply_ofReal (q : ℝ) (n : ℕ) :
eval (q : ℂ) (cyclotomic n ℂ) = (eval q (cyclotomic n ℝ)) :=
cyclotomic.eval_apply q n (algebraMap ℝ ℂ)
/-- The zeroth cyclotomic polynomial is `1`. -/
@[simp]
theorem cyclotomic_zero (R : Type*) [Ring R] : cyclotomic 0 R = 1 := by
simp only [cyclotomic, dif_pos]
/-- The first cyclotomic polynomial is `X - 1`. -/
@[simp]
theorem cyclotomic_one (R : Type*) [Ring R] : cyclotomic 1 R = X - 1 := by
have hspec : map (Int.castRingHom ℂ) (X - 1) = cyclotomic' 1 ℂ := by
simp only [cyclotomic'_one, map_X, Polynomial.map_one, Polynomial.map_sub]
symm
rw [← map_cyclotomic_int, ← int_cyclotomic_unique hspec]
simp only [map_X, Polynomial.map_one, Polynomial.map_sub]
/-- `cyclotomic n` is monic. -/
theorem cyclotomic.monic (n : ℕ) (R : Type*) [Ring R] : (cyclotomic n R).Monic := by
rw [← map_cyclotomic_int]
exact (int_cyclotomic_spec n).2.2.map _
/-- `cyclotomic n` is primitive. -/
theorem cyclotomic.isPrimitive (n : ℕ) (R : Type*) [CommRing R] : (cyclotomic n R).IsPrimitive :=
(cyclotomic.monic n R).isPrimitive
/-- `cyclotomic n R` is different from `0`. -/
theorem cyclotomic_ne_zero (n : ℕ) (R : Type*) [Ring R] [Nontrivial R] : cyclotomic n R ≠ 0 :=
(cyclotomic.monic n R).ne_zero
/-- The degree of `cyclotomic n` is `totient n`. -/
theorem degree_cyclotomic (n : ℕ) (R : Type*) [Ring R] [Nontrivial R] :
(cyclotomic n R).degree = Nat.totient n := by
rw [← map_cyclotomic_int]
rw [degree_map_eq_of_leadingCoeff_ne_zero (Int.castRingHom R) _]
· rcases n with - | k
· simp only [cyclotomic, degree_one, dif_pos, Nat.totient_zero, CharP.cast_eq_zero]
rw [← degree_cyclotomic' (Complex.isPrimitiveRoot_exp k.succ (Nat.succ_ne_zero k))]
exact (int_cyclotomic_spec k.succ).2.1
simp only [(int_cyclotomic_spec n).right.right, eq_intCast, Monic.leadingCoeff, Int.cast_one,
Ne, not_false_iff, one_ne_zero]
/-- The natural degree of `cyclotomic n` is `totient n`. -/
theorem natDegree_cyclotomic (n : ℕ) (R : Type*) [Ring R] [Nontrivial R] :
(cyclotomic n R).natDegree = Nat.totient n := by
rw [natDegree, degree_cyclotomic]; norm_cast
/-- The natural degree of `cyclotomic n` is at most `totient n`.
If the base ring is nontrivial, then the degree is exactly `φ n`,
otherwise it's zero. -/
lemma natDegree_cyclotomic_le {R : Type*} [Ring R] {n : ℕ} :
natDegree (cyclotomic n R) ≤ n.totient := by
nontriviality R
rw [natDegree_cyclotomic]
/-- The degree of `cyclotomic n R` is positive. -/
theorem degree_cyclotomic_pos (n : ℕ) (R : Type*) (hpos : 0 < n) [Ring R] [Nontrivial R] :
0 < (cyclotomic n R).degree := by
rwa [degree_cyclotomic n R, Nat.cast_pos, Nat.totient_pos]
open Finset
/-- `∏ i ∈ Nat.divisors n, cyclotomic i R = X ^ n - 1`. -/
theorem prod_cyclotomic_eq_X_pow_sub_one {n : ℕ} (hpos : 0 < n) (R : Type*) [CommRing R] :
∏ i ∈ Nat.divisors n, cyclotomic i R = X ^ n - 1 := by
have integer : ∏ i ∈ Nat.divisors n, cyclotomic i ℤ = X ^ n - 1 := by
apply map_injective (Int.castRingHom ℂ) Int.cast_injective
simp only [Polynomial.map_prod, int_cyclotomic_spec, Polynomial.map_pow, map_X,
Polynomial.map_one, Polynomial.map_sub]
exact prod_cyclotomic'_eq_X_pow_sub_one hpos (Complex.isPrimitiveRoot_exp n hpos.ne')
simpa only [Polynomial.map_prod, map_cyclotomic_int, Polynomial.map_sub, Polynomial.map_one,
Polynomial.map_pow, Polynomial.map_X] using congr_arg (map (Int.castRingHom R)) integer
theorem cyclotomic.dvd_X_pow_sub_one (n : ℕ) (R : Type*) [Ring R] :
cyclotomic n R ∣ X ^ n - 1 := by
suffices cyclotomic n ℤ ∣ X ^ n - 1 by
simpa only [map_cyclotomic_int, Polynomial.map_sub, Polynomial.map_one, Polynomial.map_pow,
Polynomial.map_X] using Polynomial.map_dvd (Int.castRingHom R) this
rcases n.eq_zero_or_pos with (rfl | hn)
· simp
rw [← prod_cyclotomic_eq_X_pow_sub_one hn]
exact Finset.dvd_prod_of_mem _ (n.mem_divisors_self hn.ne')
theorem prod_cyclotomic_eq_geom_sum {n : ℕ} (h : 0 < n) (R) [CommRing R] :
∏ i ∈ n.divisors.erase 1, cyclotomic i R = ∑ i ∈ Finset.range n, X ^ i := by
suffices (∏ i ∈ n.divisors.erase 1, cyclotomic i ℤ) = ∑ i ∈ Finset.range n, X ^ i by
simpa only [Polynomial.map_prod, map_cyclotomic_int, Polynomial.map_sum, Polynomial.map_pow,
Polynomial.map_X] using congr_arg (map (Int.castRingHom R)) this
rw [← mul_left_inj' (cyclotomic_ne_zero 1 ℤ), prod_erase_mul _ _ (Nat.one_mem_divisors.2 h.ne'),
cyclotomic_one, geom_sum_mul, prod_cyclotomic_eq_X_pow_sub_one h]
/-- If `p` is prime, then `cyclotomic p R = ∑ i ∈ range p, X ^ i`. -/
theorem cyclotomic_prime (R : Type*) [Ring R] (p : ℕ) [hp : Fact p.Prime] :
cyclotomic p R = ∑ i ∈ Finset.range p, X ^ i := by
suffices cyclotomic p ℤ = ∑ i ∈ range p, X ^ i by
simpa only [map_cyclotomic_int, Polynomial.map_sum, Polynomial.map_pow, Polynomial.map_X] using
congr_arg (map (Int.castRingHom R)) this
rw [← prod_cyclotomic_eq_geom_sum hp.out.pos, hp.out.divisors,
erase_insert (mem_singleton.not.2 hp.out.ne_one.symm), prod_singleton]
theorem cyclotomic_prime_mul_X_sub_one (R : Type*) [Ring R] (p : ℕ) [hn : Fact (Nat.Prime p)] :
cyclotomic p R * (X - 1) = X ^ p - 1 := by rw [cyclotomic_prime, geom_sum_mul]
@[simp]
theorem cyclotomic_two (R : Type*) [Ring R] : cyclotomic 2 R = X + 1 := by simp [cyclotomic_prime]
@[simp]
theorem cyclotomic_three (R : Type*) [Ring R] : cyclotomic 3 R = X ^ 2 + X + 1 := by
simp [cyclotomic_prime, sum_range_succ']
theorem cyclotomic_dvd_geom_sum_of_dvd (R) [Ring R] {d n : ℕ} (hdn : d ∣ n) (hd : d ≠ 1) :
cyclotomic d R ∣ ∑ i ∈ Finset.range n, X ^ i := by
suffices cyclotomic d ℤ ∣ ∑ i ∈ Finset.range n, X ^ i by
simpa only [map_cyclotomic_int, Polynomial.map_sum, Polynomial.map_pow, Polynomial.map_X] using
map_dvd (Int.castRingHom R) this
rcases n.eq_zero_or_pos with (rfl | hn)
· simp
rw [← prod_cyclotomic_eq_geom_sum hn]
apply Finset.dvd_prod_of_mem
simp [hd, hdn, hn.ne']
theorem X_pow_sub_one_mul_prod_cyclotomic_eq_X_pow_sub_one_of_dvd (R) [CommRing R] {d n : ℕ}
(hdvd : d ∣ n) (hn : n ≠ 0) :
((X ^ d - 1) * ∏ x ∈ n.divisors \ d.divisors, cyclotomic x R) = X ^ n - 1 := by
have h0d : 0 < d := Nat.pos_of_dvd_of_pos hdvd (by positivity)
rw [← prod_cyclotomic_eq_X_pow_sub_one h0d,
← prod_cyclotomic_eq_X_pow_sub_one (by positivity), mul_comm,
Finset.prod_sdiff (by gcongr)]
theorem X_pow_sub_one_mul_cyclotomic_dvd_X_pow_sub_one_of_dvd (R) [CommRing R] {d n : ℕ}
(h : d ∈ n.properDivisors) : (X ^ d - 1) * cyclotomic n R ∣ X ^ n - 1 := by
rw [Nat.mem_properDivisors] at h
use ∏ x ∈ n.properDivisors \ d.divisors, cyclotomic x R
rw [← X_pow_sub_one_mul_prod_cyclotomic_eq_X_pow_sub_one_of_dvd R h.1 h.2.ne_bot,
← Nat.insert_self_properDivisors, Finset.insert_sdiff_of_notMem,
Finset.prod_insert, mul_assoc]
· exact Finset.notMem_sdiff_of_notMem_left Nat.self_notMem_properDivisors
· exact fun hk => h.2.not_ge <| Nat.divisor_le hk
· exact h.2.ne_bot
section ArithmeticFunction
open ArithmeticFunction
-- access notation `μ`
open scoped ArithmeticFunction.Moebius
/-- `cyclotomic n R` can be expressed as a product in a fraction field of `R[X]`
using Möbius inversion. -/
theorem cyclotomic_eq_prod_X_pow_sub_one_pow_moebius {n : ℕ} (R : Type*) [CommRing R]
[IsDomain R] : algebraMap _ (RatFunc R) (cyclotomic n R) =
∏ i ∈ n.divisorsAntidiagonal, algebraMap R[X] _ (X ^ i.snd - 1) ^ μ i.fst := by
rcases n.eq_zero_or_pos with (rfl | hpos)
· simp
have h : ∀ n : ℕ, 0 < n → (∏ i ∈ Nat.divisors n, algebraMap _ (RatFunc R) (cyclotomic i R)) =
algebraMap _ _ (X ^ n - 1 : R[X]) := by
intro n hn
rw [← prod_cyclotomic_eq_X_pow_sub_one hn R, map_prod]
rw [(prod_eq_iff_prod_pow_moebius_eq_of_nonzero (fun n hn => _) fun n hn => _).1 h n hpos] <;>
simp_rw [Ne, IsFractionRing.to_map_eq_zero_iff]
· simp [cyclotomic_ne_zero]
· intro n hn
apply Monic.ne_zero
apply monic_X_pow_sub_C _ (ne_of_gt hn)
end ArithmeticFunction
/-- We have
`cyclotomic n R = (X ^ k - 1) /ₘ (∏ i ∈ Nat.properDivisors k, cyclotomic i K)`. -/
theorem cyclotomic_eq_X_pow_sub_one_div {R : Type*} [CommRing R] {n : ℕ} (hpos : 0 < n) :
cyclotomic n R = (X ^ n - 1) /ₘ ∏ i ∈ Nat.properDivisors n, cyclotomic i R := by
nontriviality R
rw [← prod_cyclotomic_eq_X_pow_sub_one hpos, ← Nat.cons_self_properDivisors hpos.ne',
Finset.prod_cons]
have prod_monic : (∏ i ∈ Nat.properDivisors n, cyclotomic i R).Monic := by
apply monic_prod_of_monic
intro i _
exact cyclotomic.monic i R
rw [(div_modByMonic_unique (cyclotomic n R) 0 prod_monic _).1]
simp only [degree_zero, zero_add]
constructor
· rw [mul_comm]
rw [bot_lt_iff_ne_bot]
intro h
exact Monic.ne_zero prod_monic (degree_eq_bot.1 h)
/-- If `m` is a proper divisor of `n`, then `X ^ m - 1` divides
`∏ i ∈ Nat.properDivisors n, cyclotomic i R`. -/
theorem X_pow_sub_one_dvd_prod_cyclotomic (R : Type*) [CommRing R] {n m : ℕ} (hpos : 0 < n)
(hm : m ∣ n) (hdiff : m ≠ n) : X ^ m - 1 ∣ ∏ i ∈ Nat.properDivisors n, cyclotomic i R := by
replace hm := Nat.mem_properDivisors.2
⟨hm, lt_of_le_of_ne (Nat.divisor_le (Nat.mem_divisors.2 ⟨hm, hpos.ne'⟩)) hdiff⟩
rw [← Finset.sdiff_union_of_subset (Nat.divisors_subset_properDivisors (ne_of_lt hpos).symm
(Nat.mem_properDivisors.1 hm).1 (ne_of_lt (Nat.mem_properDivisors.1 hm).2)),
Finset.prod_union Finset.sdiff_disjoint,
prod_cyclotomic_eq_X_pow_sub_one (Nat.pos_of_mem_properDivisors hm)]
exact ⟨∏ x ∈ n.properDivisors \ m.divisors, cyclotomic x R, by rw [mul_comm]⟩
/-- If there is a primitive `n`-th root of unity in `K`, then
`cyclotomic n K = ∏ μ ∈ primitiveRoots n K, (X - C μ)`. ∈ particular,
`cyclotomic n K = cyclotomic' n K` -/
theorem cyclotomic_eq_prod_X_sub_primitiveRoots {K : Type*} [CommRing K] [IsDomain K] {ζ : K}
{n : ℕ} (hz : IsPrimitiveRoot ζ n) : cyclotomic n K = ∏ μ ∈ primitiveRoots n K, (X - C μ) := by
rw [← cyclotomic']
induction n using Nat.strong_induction_on generalizing ζ with | _ k hk
obtain hzero | hpos := k.eq_zero_or_pos
· simp only [hzero, cyclotomic'_zero, cyclotomic_zero]
have h : ∀ i ∈ k.properDivisors, cyclotomic i K = cyclotomic' i K := by
intro i hi
obtain ⟨d, hd⟩ := (Nat.mem_properDivisors.1 hi).1
rw [mul_comm] at hd
exact hk i (Nat.mem_properDivisors.1 hi).2 (IsPrimitiveRoot.pow hpos hz hd)
rw [@cyclotomic_eq_X_pow_sub_one_div _ _ _ hpos, cyclotomic'_eq_X_pow_sub_one_div hpos hz,
Finset.prod_congr (refl k.properDivisors) h]
theorem eq_cyclotomic_iff {R : Type*} [CommRing R] {n : ℕ} (hpos : 0 < n) (P : R[X]) :
P = cyclotomic n R ↔
(P * ∏ i ∈ Nat.properDivisors n, Polynomial.cyclotomic i R) = X ^ n - 1 := by
nontriviality R
refine ⟨fun hcycl => ?_, fun hP => ?_⟩
· rw [hcycl, ← prod_cyclotomic_eq_X_pow_sub_one hpos R, ← Nat.cons_self_properDivisors hpos.ne',
Finset.prod_cons]
· have prod_monic : (∏ i ∈ Nat.properDivisors n, cyclotomic i R).Monic := by
apply monic_prod_of_monic
intro i _
exact cyclotomic.monic i R
rw [@cyclotomic_eq_X_pow_sub_one_div R _ _ hpos, (div_modByMonic_unique P 0 prod_monic _).1]
refine ⟨by rwa [zero_add, mul_comm], ?_⟩
rw [degree_zero, bot_lt_iff_ne_bot]
intro h
exact Monic.ne_zero prod_monic (degree_eq_bot.1 h)
/-- If `p ^ k` is a prime power, then
`cyclotomic (p ^ (n + 1)) R = ∑ i ∈ range p, (X ^ (p ^ n)) ^ i`. -/
theorem cyclotomic_prime_pow_eq_geom_sum {R : Type*} [CommRing R] {p n : ℕ} (hp : p.Prime) :
cyclotomic (p ^ (n + 1)) R = ∑ i ∈ Finset.range p, (X ^ p ^ n) ^ i := by
have : ∀ m, (cyclotomic (p ^ (m + 1)) R = ∑ i ∈ Finset.range p, (X ^ p ^ m) ^ i) ↔
((∑ i ∈ Finset.range p, (X ^ p ^ m) ^ i) *
∏ x ∈ Finset.range (m + 1), cyclotomic (p ^ x) R) = X ^ p ^ (m + 1) - 1 := by
intro m
have := eq_cyclotomic_iff (R := R) (P := ∑ i ∈ range p, (X ^ p ^ m) ^ i)
(pow_pos hp.pos (m + 1))
rw [eq_comm] at this
rw [this, Nat.prod_properDivisors_prime_pow hp]
induction n with
| zero => haveI := Fact.mk hp; simp [cyclotomic_prime]
| succ n_n n_ih =>
rw [← (eq_cyclotomic_iff (pow_pos hp.pos (n_n + 1 + 1)) _).mpr ?_]
rw [Nat.prod_properDivisors_prime_pow hp, Finset.prod_range_succ, n_ih]
rw [this] at n_ih
rw [mul_comm _ (∑ i ∈ _, _), n_ih, geom_sum_mul, sub_left_inj, ← pow_mul]
simp only [pow_add, pow_one]
theorem cyclotomic_prime_pow_mul_X_pow_sub_one (R : Type*) [CommRing R] (p k : ℕ)
[hn : Fact (Nat.Prime p)] :
cyclotomic (p ^ (k + 1)) R * (X ^ p ^ k - 1) = X ^ p ^ (k + 1) - 1 := by
rw [cyclotomic_prime_pow_eq_geom_sum hn.out, geom_sum_mul, ← pow_mul, pow_succ, mul_comm]
/-- The constant term of `cyclotomic n R` is `1` if `2 ≤ n`. -/
theorem cyclotomic_coeff_zero (R : Type*) [CommRing R] {n : ℕ} (hn : 1 < n) :
(cyclotomic n R).coeff 0 = 1 := by
induction n using Nat.strong_induction_on with | _ n hi
have hprod : (∏ i ∈ Nat.properDivisors n, (Polynomial.cyclotomic i R).coeff 0) = -1 := by
rw [← Finset.insert_erase (Nat.one_mem_properDivisors_iff_one_lt.2
(lt_of_lt_of_le one_lt_two hn)), Finset.prod_insert (Finset.notMem_erase 1 _),
cyclotomic_one R]
have hleq : ∀ j ∈ n.properDivisors.erase 1, 2 ≤ j := by
intro j hj
apply Nat.succ_le_of_lt
exact (Ne.le_iff_lt (Finset.mem_erase.1 hj).1.symm).mp
(Nat.succ_le_of_lt (Nat.pos_of_mem_properDivisors (Finset.mem_erase.1 hj).2))
have hcongr : ∀ j ∈ n.properDivisors.erase 1, (cyclotomic j R).coeff 0 = 1 := by
intro j hj
exact hi j (Nat.mem_properDivisors.1 (Finset.mem_erase.1 hj).2).2 (hleq j hj)
have hrw : (∏ x ∈ n.properDivisors.erase 1, (cyclotomic x R).coeff 0) = 1 := by
rw [Finset.prod_congr (refl (n.properDivisors.erase 1)) hcongr]
simp only [Finset.prod_const_one]
simp only [hrw, mul_one, zero_sub, coeff_one_zero, coeff_X_zero, coeff_sub]
have heq : (X ^ n - 1 : R[X]).coeff 0 = -(cyclotomic n R).coeff 0 := by
rw [← prod_cyclotomic_eq_X_pow_sub_one (zero_le_one.trans_lt hn), ←
Nat.cons_self_properDivisors hn.ne_bot, Finset.prod_cons, mul_coeff_zero, coeff_zero_prod,
hprod, mul_neg, mul_one]
have hzero : (X ^ n - 1 : R[X]).coeff 0 = (-1 : R) := by
rw [coeff_zero_eq_eval_zero _]
simp only [zero_pow (by positivity : n ≠ 0), eval_X, eval_one, zero_sub, eval_pow, eval_sub]
rw [hzero] at heq
exact neg_inj.mp (Eq.symm heq)
/-- If `(a : ℕ)` is a root of `cyclotomic n (ZMod p)`, where `p` is a prime, then `a` and `p` are
coprime. -/
theorem coprime_of_root_cyclotomic {n : ℕ} (hpos : 0 < n) {p : ℕ} [hprime : Fact p.Prime] {a : ℕ}
(hroot : IsRoot (cyclotomic n (ZMod p)) (Nat.castRingHom (ZMod p) a)) : a.Coprime p := by
apply Nat.Coprime.symm
rw [hprime.1.coprime_iff_not_dvd]
intro h
replace h := (ZMod.natCast_eq_zero_iff a p).2 h
rw [IsRoot.def, eq_natCast, h, ← coeff_zero_eq_eval_zero] at hroot
by_cases hone : n = 1
· simp only [hone, cyclotomic_one, zero_sub, coeff_one_zero, coeff_X_zero, neg_eq_zero,
one_ne_zero, coeff_sub] at hroot
rw [cyclotomic_coeff_zero (ZMod p) (Nat.succ_le_of_lt
(lt_of_le_of_ne (Nat.succ_le_of_lt hpos) (Ne.symm hone)))] at hroot
exact one_ne_zero hroot
end Cyclotomic
section Order
/-- If `(a : ℕ)` is a root of `cyclotomic n (ZMod p)`, then the multiplicative order of `a` modulo
`p` divides `n`. -/
theorem orderOf_root_cyclotomic_dvd {n : ℕ} (hpos : 0 < n) {p : ℕ} [Fact p.Prime] {a : ℕ}
(hroot : IsRoot (cyclotomic n (ZMod p)) (Nat.castRingHom (ZMod p) a)) :
orderOf (ZMod.unitOfCoprime a (coprime_of_root_cyclotomic hpos hroot)) ∣ n := by
apply orderOf_dvd_of_pow_eq_one
suffices hpow : eval (Nat.castRingHom (ZMod p) a) (X ^ n - 1 : (ZMod p)[X]) = 0 by
simp only [eval_X, eval_one, eval_pow, eval_sub, eq_natCast] at hpow
apply Units.val_eq_one.1
simp only [sub_eq_zero.mp hpow, ZMod.coe_unitOfCoprime, Units.val_pow_eq_pow_val]
rw [IsRoot.def] at hroot
rw [← prod_cyclotomic_eq_X_pow_sub_one hpos (ZMod p), ← Nat.cons_self_properDivisors hpos.ne',
Finset.prod_cons, eval_mul, hroot, zero_mul]
end Order
section miscellaneous
open Finset
variable {R : Type*} [CommRing R] {ζ : R} {n : ℕ} (x y : R)
lemma dvd_C_mul_X_sub_one_pow_add_one {p : ℕ} (hpri : p.Prime)
(hp : p ≠ 2) (a r : R) (h₁ : r ∣ a ^ p) (h₂ : r ∣ p * a) : C r ∣ (C a * X - 1) ^ p + 1 := by
have := hpri.dvd_add_pow_sub_pow_of_dvd (C a * X) (-1) (r := C r) ?_ ?_
· rwa [← sub_eq_add_neg, (hpri.odd_of_ne_two hp).neg_pow, one_pow, sub_neg_eq_add] at this
· simp only [mul_pow, ← map_pow, dvd_mul_right, (_root_.map_dvd C h₁).trans]
simp only [map_mul, map_natCast, ← mul_assoc, dvd_mul_right, (_root_.map_dvd C h₂).trans]
private theorem _root_.IsPrimitiveRoot.pow_sub_pow_eq_prod_sub_mul_field {K : Type*}
[Field K] {ζ : K} (x y : K) (hpos : 0 < n) (h : IsPrimitiveRoot ζ n) :
x ^ n - y ^ n = ∏ ζ ∈ nthRootsFinset n (1 : K), (x - ζ * y) := by
by_cases hy : y = 0
· simp only [hy, zero_pow (Nat.ne_zero_of_lt hpos), sub_zero, mul_zero, prod_const]
congr
rw [h.card_nthRootsFinset]
convert congr_arg (eval (x/y) · * y ^ card (nthRootsFinset n (1 : K)))
<| X_pow_sub_one_eq_prod hpos h
using 1
· simp [sub_mul, div_pow, hy, h.card_nthRootsFinset]
· simp [eval_prod, prod_mul_pow_card, sub_mul, hy]
variable [IsDomain R]
/-- If there is a primitive `n`th root of unity in `R`, then `X ^ n - Y ^ n = ∏ (X - μ Y)`,
where `μ` varies over the `n`-th roots of unity. -/
theorem _root_.IsPrimitiveRoot.pow_sub_pow_eq_prod_sub_mul (hpos : 0 < n)
(h : IsPrimitiveRoot ζ n) : x ^ n - y ^ n = ∏ ζ ∈ nthRootsFinset n (1 : R), (x - ζ * y) := by
let K := FractionRing R
apply FaithfulSMul.algebraMap_injective R K
rw [map_sub, map_pow, map_pow, map_prod]
simp_rw [map_sub, map_mul]
have h' : IsPrimitiveRoot (algebraMap R K ζ) n :=
h.map_of_injective <| FaithfulSMul.algebraMap_injective R K
rw [h'.pow_sub_pow_eq_prod_sub_mul_field _ _ hpos]
refine (prod_nbij (algebraMap R K) (fun a ha ↦ map_mem_nthRootsFinset_one ha _)
(fun a _ b _ H ↦ FaithfulSMul.algebraMap_injective R K H) (fun a ha ↦ ?_) (fun _ _ ↦ rfl)).symm
have := Set.surj_on_of_inj_on_of_ncard_le (s := nthRootsFinset n (1 : R))
(t := nthRootsFinset n (1: K)) _ (fun _ hr ↦ map_mem_nthRootsFinset_one hr _)
(fun a _ b _ H ↦ FaithfulSMul.algebraMap_injective R K H)
(by simp [h.card_nthRootsFinset, h'.card_nthRootsFinset])
obtain ⟨x, hx, hx1⟩ := this _ ha
exact ⟨x, hx, hx1.symm⟩
/-- If there is a primitive `n`th root of unity in `R` and `n` is odd, then
`X ^ n + Y ^ n = ∏ (X + μ Y)`, where `μ` varies over the `n`-th roots of unity. -/
theorem _root_.IsPrimitiveRoot.pow_add_pow_eq_prod_add_mul (hodd : Odd n)
(h : IsPrimitiveRoot ζ n) : x ^ n + y ^ n = ∏ ζ ∈ nthRootsFinset n (1 : R), (x + ζ * y) := by
simpa [hodd.neg_pow] using h.pow_sub_pow_eq_prod_sub_mul x (-y) hodd.pos
theorem separable_cyclotomic (n : ℕ) (K : Type*) [Field K] [NeZero (n : K)] :
(cyclotomic n K).Separable :=
.of_dvd (separable_X_pow_sub_C 1 NeZero.out one_ne_zero) (cyclotomic.dvd_X_pow_sub_one n K)
theorem squarefree_cyclotomic (n : ℕ) (K : Type*) [Field K] [NeZero (n : K)] :
Squarefree (cyclotomic n K) :=
(separable_cyclotomic n K).squarefree
end miscellaneous
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Cyclotomic/Factorization.lean | import Mathlib.FieldTheory.Finite.GaloisField
import Mathlib.RingTheory.SimpleModule.Basic
import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots
import Mathlib.Algebra.CharP.CharAndCard
/-!
# Factorization of cyclotomic polynomials over finite fields
We compute the degree of the irreducible factors of the `n`-th cyclotomic polynomial over a finite
field of characteristic `p`, where `p` and `n` are coprime.
## Main results
* `Polynomial.natDegree_of_dvd_cyclotomic_of_irreducible` : Let `K` be a finite field of cardinality
`p ^ f` and let `P` be an irreducible factor of the `n`-th cyclotomic polynomial over `K`, where
`p` and `n` are coprime. Then the degree of `P` is the multiplicative order of `p ^ f` modulo `n`.
-/
namespace Polynomial
variable {K : Type*} [Field K] [Fintype K] {p f n : ℕ} {P : K[X]}
(hK : Fintype.card K = p ^ f) (hn : p.Coprime n)
open ZMod AdjoinRoot FiniteField Multiset
include hK
private lemma f_ne_zero : f ≠ 0 := fun h0 ↦ not_subsingleton K <|
Fintype.card_le_one_iff_subsingleton.mp <| by simpa [h0] using hK.le
variable [hp : Fact p.Prime]
/-- The degree of an irreducible monic factor of the `n`-th cyclotomic polynomial over a finite
field. This is a special case of `natDegree_of_dvd_cyclotomic_of_irreducible` below. -/
private theorem natDegree_of_dvd_cyclotomic_of_irreducible_of_monic (hP : P ∣ cyclotomic n K)
(hPirr : Irreducible P) (hPmo : P.Monic) :
P.natDegree = orderOf (unitOfCoprime _ (hn.pow_left f)) := by
have : Fact (Irreducible P) := ⟨hPirr⟩
have := hPmo.finite_adjoinRoot
have : Finite (AdjoinRoot P) := Module.finite_of_finite K
have hζ : IsPrimitiveRoot (root P) n := by
have : NeZero (n : AdjoinRoot P) := by
suffices NeZero (n : K) by
simpa using NeZero.of_injective (algebraMap K (AdjoinRoot P)).injective
have := charP_of_card_eq_prime_pow hK
exact ⟨fun h0 ↦ Nat.Prime.not_coprime_iff_dvd.mpr
⟨p, hp.out, dvd_pow_self p (f_ne_zero hK), (CharP.cast_eq_zero_iff K p n).mp h0⟩
(hn.pow_left f)⟩
simpa [← isRoot_cyclotomic_iff] using (isRoot_root P).dvd
(by simpa using map_dvd (algebraMap K (AdjoinRoot P)) hP)
let pB := powerBasis hPirr.ne_zero
rw [← powerBasis_dim hPirr.ne_zero, ← pB.finrank, ← orderOf_frobeniusAlgEquivOfAlgebraic]
have hζ' := isOfFinOrder_iff_pow_eq_one.mpr
⟨n, pos_of_ne_zero (fun h0 ↦ by simp [h0, hp.out.ne_one] at hn),
hζ.pow_eq_one⟩
refine dvd_antisymm
(orderOf_dvd_iff_pow_eq_one.mpr <| AlgEquiv.coe_algHom_injective <| pB.algHom_ext ?_)
(orderOf_dvd_iff_pow_eq_one.mpr <| Units.ext ?_)
· simp only [AlgHom.coe_coe, AlgEquiv.coe_pow, AlgEquiv.one_apply,
coe_frobeniusAlgEquivOfAlgebraic, pow_iterate, hK]
nth_rewrite 2 [← pow_one pB.gen]
rw [powerBasis_gen hPirr.ne_zero, hζ'.pow_eq_pow_iff_modEq, ← hζ.eq_orderOf,
← natCast_eq_natCast_iff]
simpa only [Nat.cast_pow, Nat.cast_one, coe_unitOfCoprime, Units.val_one,
Units.val_pow_eq_pow_val] using Units.val_inj.mpr <| pow_orderOf_eq_one
(unitOfCoprime _ (hn.pow_left f))
· let φ := frobeniusAlgEquivOfAlgebraic K (AdjoinRoot P)
have : (φ ^ orderOf φ) (root P) = root P := by simp [pow_orderOf_eq_one φ]
simp only [AlgEquiv.coe_pow, φ, coe_frobeniusAlgEquivOfAlgebraic, pow_iterate, hK] at this
rw [Units.val_one, ← Nat.cast_one, Units.val_pow_eq_pow_val, coe_unitOfCoprime,
← Nat.cast_pow, natCast_eq_natCast_iff, hζ.eq_orderOf, ← hζ'.pow_eq_pow_iff_modEq, this,
pow_one]
/-- Let `K` be a finite field of cardinality `p ^ f` and let `P` be an irreducible factor of the
`n`-th cyclotomic polynomial over `K`, where `p` and `n` are coprime. Then the degree of `P` is
the multiplicative order of `p ^ f` modulo `n`. -/
theorem natDegree_of_dvd_cyclotomic_of_irreducible (hP : P ∣ cyclotomic n K)
(hPirr : Irreducible P) : P.natDegree = orderOf (unitOfCoprime _ (hn.pow_left f)) := by
obtain ⟨A, hA⟩ := hP
have hQ : P * C P.leadingCoeff⁻¹ ∣ cyclotomic n K := by
refine ⟨A * C P.leadingCoeff, ?_⟩
calc
_ = P * A := hA
_ = P * (C P.leadingCoeff⁻¹ * C P.leadingCoeff) * A := by
simp [← C_mul, leadingCoeff_ne_zero.mpr hPirr.ne_zero]
_ = _ := by ring
simpa [← natDegree_mul_leadingCoeff_self_inv P] using
natDegree_of_dvd_cyclotomic_of_irreducible_of_monic hK hn hQ
(irreducible_mul_leadingCoeff_inv.mpr hPirr) (monic_mul_leadingCoeff_inv hPirr.ne_zero)
open UniqueFactorizationMonoid in
/-- Let `K` be a finite field of cardinality `p ^ f` and let `P` be a factor of the `n`-th
cyclotomic polynomial over `K`, where `p` and `n` are coprime. If the degree of `P` is
the multiplicative order of `p ^ f` modulo `n` then `P` is irreducible. -/
theorem irreducible_of_dvd_cyclotomic_of_natDegree (hP : P ∣ cyclotomic n K)
(hPdeg : P.natDegree = orderOf (unitOfCoprime _ (hn.pow_left f))) : Irreducible P := by
classical
have hP0 : P ≠ 0 := ne_zero_of_dvd_ne_zero (cyclotomic_ne_zero n K) hP
obtain ⟨Q, HQ⟩ := exists_mem_normalizedFactors hP0 <| not_isUnit_of_natDegree_pos _ <|
pos_of_ne_zero <| fun h ↦ orderOf_eq_zero_iff.mp (h ▸ hPdeg.symm) <| isOfFinOrder_of_finite ..
refine (associated_of_dvd_of_natDegree_le (dvd_of_mem_normalizedFactors HQ) hP0 ?_).irreducible
(irreducible_of_normalized_factor Q HQ)
rw [hPdeg, ← natDegree_of_dvd_cyclotomic_of_irreducible hK hn ?_
(irreducible_of_normalized_factor Q HQ)]
exact dvd_of_mem_normalizedFactors <| mem_of_le
((dvd_iff_normalizedFactors_le_normalizedFactors hP0 (cyclotomic_ne_zero n K)).mp hP) HQ
omit hK in
/-- Let `P` be a factor of the `n`-th cyclotomic polynomial over `ZMod p`, where `p` does not divide
`n`. If the degree of `P` is the multiplicative order of `p` modulo `n` then `P` is
irreducible. -/
theorem _root_.ZMod.irreducible_of_dvd_cyclotomic_of_natDegree {P : (ZMod p)[X]} (hpn : ¬p ∣ n)
(hP : P ∣ cyclotomic n (ZMod p))
(hPdeg : P.natDegree = orderOf (unitOfCoprime _ (hp.1.coprime_iff_not_dvd.mpr hpn))) :
Irreducible P :=
Polynomial.irreducible_of_dvd_cyclotomic_of_natDegree (f := 1) (p := p) (by simp)
(by simpa using hp.1.coprime_iff_not_dvd.mpr hpn) hP (by simpa)
open UniqueFactorizationMonoid Nat
variable [DecidableEq K]
theorem natDegree_of_mem_normalizedFactors_cyclotomic
(hP : P ∈ normalizedFactors (cyclotomic n K)) :
P.natDegree = orderOf (unitOfCoprime _ (hn.pow_left f)) :=
natDegree_of_dvd_cyclotomic_of_irreducible hK hn (dvd_of_mem_normalizedFactors hP)
(irreducible_of_normalized_factor P hP)
/-- Let `K` be a finite field of cardinality `p ^ f` and let `P` be an irreducible factor of the
`n`-th cyclotomic polynomial over `K`, where `p` and `n` are coprime. This result computes the
number of distinct irreducible factors of `cyclotomic n K`. -/
theorem normalizedFactors_cyclotomic_card : (normalizedFactors (cyclotomic n K)).toFinset.card =
φ n / orderOf (unitOfCoprime _ (hn.pow_left f)) := by
have h := prod_normalizedFactors (cyclotomic_ne_zero n K)
have : ∀ P ∈ normalizedFactors (cyclotomic n K),
P.natDegree = orderOf (unitOfCoprime _ (hn.pow_left f)) := fun P hP ↦
natDegree_of_mem_normalizedFactors_cyclotomic hK hn hP
have H := natDegree_eq_of_degree_eq <| degree_eq_degree_of_associated h
rw [natDegree_cyclotomic, natDegree_multiset_prod _ (zero_notMem_normalizedFactors _),
map_congr rfl this] at H
simp only [map_const', sum_replicate, smul_eq_mul] at H
rw [← H, mul_div_left _ (orderOf_pos _), toFinset_card_of_nodup]
refine nodup_iff_count_le_one.mpr (fun P ↦ ?_)
by_contra! H
have : NeZero (n : K) := by
refine ⟨fun H ↦ ?_⟩
have := charP_of_card_eq_prime_pow hK
exact hp.out.coprime_iff_not_dvd.mp ((coprime_pow_left_iff
(pos_of_ne_zero <| f_ne_zero hK) _ _).mp (hn.pow_left f))
((CharP.cast_eq_zero_iff K p _).mp H)
have hP : P ∈ normalizedFactors (cyclotomic n K) := count_pos.mp (by omega)
refine (prime_of_normalized_factor _ hP).not_unit (squarefree_cyclotomic n K P ?_)
have : {P, P} ≤ normalizedFactors (cyclotomic n K) := by
refine le_iff_count.mpr (fun Q ↦ ?_)
by_cases hQ : Q = P
· simp only [hQ, insert_eq_cons, count_cons_self, nodup_singleton, mem_singleton,
count_eq_one_of_mem, reduceAdd]
cutsat
· simp [hQ]
have := prod_dvd_prod_of_le this
simp only [insert_eq_cons, prod_cons, prod_singleton] at this
exact this.trans h.dvd
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean | import Mathlib.RingTheory.Polynomial.Cyclotomic.Basic
import Mathlib.RingTheory.RootsOfUnity.Minpoly
/-!
# Roots of cyclotomic polynomials.
We gather results about roots of cyclotomic polynomials. In particular we show in
`Polynomial.cyclotomic_eq_minpoly` that `cyclotomic n R` is the minimal polynomial of a primitive
root of unity.
## Main results
* `IsPrimitiveRoot.isRoot_cyclotomic` : Any `n`-th primitive root of unity is a root of
`cyclotomic n R`.
* `isRoot_cyclotomic_iff` : if `NeZero (n : R)`, then `μ` is a root of `cyclotomic n R`
if and only if `μ` is a primitive root of unity.
* `Polynomial.cyclotomic_eq_minpoly` : `cyclotomic n ℤ` is the minimal polynomial of a primitive
`n`-th root of unity `μ`.
* `Polynomial.cyclotomic.irreducible` : `cyclotomic n ℤ` is irreducible.
## Implementation details
To prove `Polynomial.cyclotomic.irreducible`, the irreducibility of `cyclotomic n ℤ`, we show in
`Polynomial.cyclotomic_eq_minpoly` that `cyclotomic n ℤ` is the minimal polynomial of any `n`-th
primitive root of unity `μ : K`, where `K` is a field of characteristic `0`.
-/
namespace Polynomial
variable {R : Type*} [CommRing R] {n : ℕ}
theorem isRoot_of_unity_of_root_cyclotomic {ζ : R} {i : ℕ} (hi : i ∈ n.divisors)
(h : (cyclotomic i R).IsRoot ζ) : ζ ^ n = 1 := by
rcases n.eq_zero_or_pos with (rfl | hn)
· exact pow_zero _
have := congr_arg (eval ζ) (prod_cyclotomic_eq_X_pow_sub_one hn R).symm
rw [eval_sub, eval_X_pow, eval_one] at this
convert eq_add_of_sub_eq' this
convert (add_zero (M := R) _).symm
apply eval_eq_zero_of_dvd_of_eval_eq_zero _ h
exact Finset.dvd_prod_of_mem _ hi
section IsDomain
variable [IsDomain R]
theorem _root_.isRoot_of_unity_iff (h : 0 < n) (R : Type*) [CommRing R] [IsDomain R] {ζ : R} :
ζ ^ n = 1 ↔ ∃ i ∈ n.divisors, (cyclotomic i R).IsRoot ζ := by
rw [← mem_nthRoots h, nthRoots, mem_roots <| X_pow_sub_C_ne_zero h _, C_1, ←
prod_cyclotomic_eq_X_pow_sub_one h, isRoot_prod]
/-- Any `n`-th primitive root of unity is a root of `cyclotomic n R`. -/
theorem _root_.IsPrimitiveRoot.isRoot_cyclotomic (hpos : 0 < n) {μ : R} (h : IsPrimitiveRoot μ n) :
IsRoot (cyclotomic n R) μ := by
rw [← mem_roots (cyclotomic_ne_zero n R), cyclotomic_eq_prod_X_sub_primitiveRoots h,
roots_prod_X_sub_C, ← Finset.mem_def]
rwa [← mem_primitiveRoots hpos] at h
private theorem isRoot_cyclotomic_iff' {n : ℕ} {K : Type*} [Field K] {μ : K} [NeZero (n : K)] :
IsRoot (cyclotomic n K) μ ↔ IsPrimitiveRoot μ n := by
-- in this proof, `o` stands for `orderOf μ`
have hnpos : 0 < n := (NeZero.of_neZero_natCast K).out.bot_lt
refine ⟨fun hμ => ?_, IsPrimitiveRoot.isRoot_cyclotomic hnpos⟩
have hμn : μ ^ n = 1 := by
rw [isRoot_of_unity_iff hnpos _]
exact ⟨n, n.mem_divisors_self hnpos.ne', hμ⟩
by_contra hnμ
have ho : 0 < orderOf μ := (isOfFinOrder_iff_pow_eq_one.2 <| ⟨n, hnpos, hμn⟩).orderOf_pos
have := pow_orderOf_eq_one μ
rw [isRoot_of_unity_iff ho] at this
obtain ⟨i, hio, hiμ⟩ := this
replace hio := Nat.dvd_of_mem_divisors hio
rw [IsPrimitiveRoot.not_iff] at hnμ
rw [← orderOf_dvd_iff_pow_eq_one] at hμn
have key : i < n := (Nat.le_of_dvd ho hio).trans_lt ((Nat.le_of_dvd hnpos hμn).lt_of_ne hnμ)
have key' : i ∣ n := hio.trans hμn
rw [← Polynomial.dvd_iff_isRoot] at hμ hiμ
have hni : {i, n} ⊆ n.divisors := by simpa [Finset.insert_subset_iff, key'] using hnpos.ne'
obtain ⟨k, hk⟩ := hiμ
obtain ⟨j, hj⟩ := hμ
have := prod_cyclotomic_eq_X_pow_sub_one hnpos K
rw [← Finset.prod_sdiff hni, Finset.prod_pair key.ne, hk, hj] at this
have hn := (X_pow_sub_one_separable_iff.mpr <| NeZero.natCast_ne n K).squarefree
rw [← this, Squarefree] at hn
specialize hn (X - C μ) ⟨(∏ x ∈ n.divisors \ {i, n}, cyclotomic x K) * k * j, by ring⟩
simp [Polynomial.isUnit_iff_degree_eq_zero] at hn
theorem isRoot_cyclotomic_iff [NeZero (n : R)] {μ : R} :
IsRoot (cyclotomic n R) μ ↔ IsPrimitiveRoot μ n := by
have hf : Function.Injective _ := IsFractionRing.injective R (FractionRing R)
haveI : NeZero (n : FractionRing R) := NeZero.nat_of_injective hf
rw [← isRoot_map_iff hf, ← IsPrimitiveRoot.map_iff_of_injective hf, map_cyclotomic, ←
isRoot_cyclotomic_iff']
theorem roots_cyclotomic_nodup [NeZero (n : R)] : (cyclotomic n R).roots.Nodup := by
obtain h | ⟨ζ, hζ⟩ := (cyclotomic n R).roots.empty_or_exists_mem
· exact h.symm ▸ Multiset.nodup_zero
rw [mem_roots <| cyclotomic_ne_zero n R, isRoot_cyclotomic_iff] at hζ
refine Multiset.nodup_of_le
(roots.le_of_dvd (X_pow_sub_C_ne_zero (NeZero.pos_of_neZero_natCast R) 1) <|
cyclotomic.dvd_X_pow_sub_one n R) hζ.nthRoots_one_nodup
theorem cyclotomic.roots_to_finset_eq_primitiveRoots [NeZero (n : R)] :
(⟨(cyclotomic n R).roots, roots_cyclotomic_nodup⟩ : Finset _) = primitiveRoots n R := by
ext a
simp [cyclotomic_ne_zero n R, ← isRoot_cyclotomic_iff, mem_primitiveRoots,
NeZero.pos_of_neZero_natCast R]
theorem cyclotomic.roots_eq_primitiveRoots_val [NeZero (n : R)] :
(cyclotomic n R).roots = (primitiveRoots n R).val := by
rw [← cyclotomic.roots_to_finset_eq_primitiveRoots]
/-- If `R` is of characteristic zero, then `ζ` is a root of `cyclotomic n R` if and only if it is a
primitive `n`-th root of unity. -/
theorem isRoot_cyclotomic_iff_charZero {n : ℕ} {R : Type*} [CommRing R] [IsDomain R] [CharZero R]
{μ : R} (hn : 0 < n) : (Polynomial.cyclotomic n R).IsRoot μ ↔ IsPrimitiveRoot μ n :=
letI := NeZero.of_gt hn
isRoot_cyclotomic_iff
end IsDomain
/-- Over a ring `R` of characteristic zero, `fun n => cyclotomic n R` is injective. -/
theorem cyclotomic_injective [CharZero R] : Function.Injective fun n => cyclotomic n R := by
intro n m hnm
simp only at hnm
rcases eq_or_ne n 0 with (rfl | hzero)
· rw [cyclotomic_zero] at hnm
replace hnm := congr_arg natDegree hnm
rwa [natDegree_one, natDegree_cyclotomic, eq_comm, Nat.totient_eq_zero, eq_comm] at hnm
· haveI := NeZero.mk hzero
rw [← map_cyclotomic_int _ R, ← map_cyclotomic_int _ R] at hnm
replace hnm := map_injective (Int.castRingHom R) Int.cast_injective hnm
replace hnm := congr_arg (map (Int.castRingHom ℂ)) hnm
rw [map_cyclotomic_int, map_cyclotomic_int] at hnm
have hprim := Complex.isPrimitiveRoot_exp _ hzero
have hroot := isRoot_cyclotomic_iff (R := ℂ).2 hprim
rw [hnm] at hroot
haveI hmzero : NeZero m := ⟨fun h => by simp [h] at hroot⟩
rw [isRoot_cyclotomic_iff (R := ℂ)] at hroot
replace hprim := hprim.eq_orderOf
rwa [← IsPrimitiveRoot.eq_orderOf hroot] at hprim
/-- The minimal polynomial of a primitive `n`-th root of unity `μ` divides `cyclotomic n ℤ`. -/
theorem _root_.IsPrimitiveRoot.minpoly_dvd_cyclotomic {n : ℕ} {K : Type*} [Field K] {μ : K}
(h : IsPrimitiveRoot μ n) (hpos : 0 < n) [CharZero K] : minpoly ℤ μ ∣ cyclotomic n ℤ := by
apply minpoly.isIntegrallyClosed_dvd (h.isIntegral hpos)
simpa [aeval_def, eval₂_eq_eval_map, IsRoot.def] using h.isRoot_cyclotomic hpos
section minpoly
open IsPrimitiveRoot Complex
theorem _root_.IsPrimitiveRoot.minpoly_eq_cyclotomic_of_irreducible {K : Type*} [Field K]
{R : Type*} [CommRing R] [IsDomain R] {μ : R} {n : ℕ} [Algebra K R] (hμ : IsPrimitiveRoot μ n)
(h : Irreducible <| cyclotomic n K) [NeZero (n : K)] : cyclotomic n K = minpoly K μ := by
haveI := NeZero.of_faithfulSMul K R n
refine minpoly.eq_of_irreducible_of_monic h ?_ (cyclotomic.monic n K)
rwa [aeval_def, eval₂_eq_eval_map, map_cyclotomic, ← IsRoot.def, isRoot_cyclotomic_iff]
/-- `cyclotomic n ℤ` is the minimal polynomial of a primitive `n`-th root of unity `μ`. -/
theorem cyclotomic_eq_minpoly {n : ℕ} {K : Type*} [Field K] {μ : K} (h : IsPrimitiveRoot μ n)
(hpos : 0 < n) [CharZero K] : cyclotomic n ℤ = minpoly ℤ μ := by
refine eq_of_monic_of_dvd_of_natDegree_le (minpoly.monic (IsPrimitiveRoot.isIntegral h hpos))
(cyclotomic.monic n ℤ) (h.minpoly_dvd_cyclotomic hpos) ?_
simpa [natDegree_cyclotomic n ℤ] using totient_le_degree_minpoly h
/-- `cyclotomic n ℚ` is the minimal polynomial of a primitive `n`-th root of unity `μ`. -/
theorem cyclotomic_eq_minpoly_rat {n : ℕ} {K : Type*} [Field K] {μ : K} (h : IsPrimitiveRoot μ n)
(hpos : 0 < n) [CharZero K] : cyclotomic n ℚ = minpoly ℚ μ := by
rw [← map_cyclotomic_int, cyclotomic_eq_minpoly h hpos]
exact (minpoly.isIntegrallyClosed_eq_field_fractions' _ (IsPrimitiveRoot.isIntegral h hpos)).symm
/-- `cyclotomic n ℤ` is irreducible. -/
theorem cyclotomic.irreducible {n : ℕ} (hpos : 0 < n) : Irreducible (cyclotomic n ℤ) := by
rw [cyclotomic_eq_minpoly (isPrimitiveRoot_exp n hpos.ne') hpos]
apply minpoly.irreducible
exact (isPrimitiveRoot_exp n hpos.ne').isIntegral hpos
/-- `cyclotomic n ℚ` is irreducible. -/
theorem cyclotomic.irreducible_rat {n : ℕ} (hpos : 0 < n) : Irreducible (cyclotomic n ℚ) := by
rw [← map_cyclotomic_int]
exact (IsPrimitive.irreducible_iff_irreducible_map_fraction_map (cyclotomic.isPrimitive n ℤ)).1
(cyclotomic.irreducible hpos)
/-- If `n ≠ m`, then `(cyclotomic n ℚ)` and `(cyclotomic m ℚ)` are coprime. -/
theorem cyclotomic.isCoprime_rat {n m : ℕ} (h : n ≠ m) :
IsCoprime (cyclotomic n ℚ) (cyclotomic m ℚ) := by
rcases n.eq_zero_or_pos with (rfl | hnzero)
· exact isCoprime_one_left
rcases m.eq_zero_or_pos with (rfl | hmzero)
· exact isCoprime_one_right
rw [Irreducible.coprime_iff_not_dvd <| cyclotomic.irreducible_rat <| hnzero]
exact fun hdiv => h <| cyclotomic_injective <|
eq_of_monic_of_associated (cyclotomic.monic n ℚ) (cyclotomic.monic m ℚ) <|
Irreducible.associated_of_dvd (cyclotomic.irreducible_rat hnzero)
(cyclotomic.irreducible_rat hmzero) hdiv
end minpoly
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Hermite/Gaussian.lean | import Mathlib.RingTheory.Polynomial.Hermite.Basic
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
/-!
# Hermite polynomials and Gaussians
This file shows that the Hermite polynomial `hermite n` is (up to sign) the
polynomial factor occurring in the `n`th derivative of a Gaussian.
## Results
* `Polynomial.deriv_gaussian_eq_hermite_mul_gaussian`:
The Hermite polynomial is (up to sign) the polynomial factor occurring in the
`n`th derivative of a Gaussian.
## References
* [Hermite Polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials)
-/
noncomputable section
open Polynomial
namespace Polynomial
/-- `hermite n` is (up to sign) the factor appearing in `deriv^[n]` of a Gaussian. -/
theorem deriv_gaussian_eq_hermite_mul_gaussian (n : ℕ) (x : ℝ) :
deriv^[n] (fun y => Real.exp (-(y ^ 2 / 2))) x =
(-1 : ℝ) ^ n * aeval x (hermite n) * Real.exp (-(x ^ 2 / 2)) := by
rw [mul_assoc]
induction n generalizing x with
| zero => rw [Function.iterate_zero_apply, pow_zero, one_mul, hermite_zero, C_1, map_one, one_mul]
| succ n ih =>
replace ih : deriv^[n] _ = _ := _root_.funext ih
have deriv_gaussian :
deriv (fun y => Real.exp (-(y ^ 2 / 2))) x = -x * Real.exp (-(x ^ 2 / 2)) := by
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/10745): was `simp [mul_comm, ← neg_mul]`
rw [deriv_exp (by simp)]
simp [mul_comm]
rw [Function.iterate_succ_apply', ih, deriv_const_mul_field, deriv_fun_mul, pow_succ (-1 : ℝ),
deriv_gaussian, hermite_succ, map_sub, map_mul, aeval_X, Polynomial.deriv_aeval]
· ring
· apply Polynomial.differentiable_aeval
· apply DifferentiableAt.exp; simp -- Porting note: was just `simp`
theorem hermite_eq_deriv_gaussian (n : ℕ) (x : ℝ) : aeval x (hermite n) =
(-1 : ℝ) ^ n * deriv^[n] (fun y => Real.exp (-(y ^ 2 / 2))) x / Real.exp (-(x ^ 2 / 2)) := by
rw [deriv_gaussian_eq_hermite_mul_gaussian]
field_simp
rw [← pow_mul]
simp
theorem hermite_eq_deriv_gaussian' (n : ℕ) (x : ℝ) : aeval x (hermite n) =
(-1 : ℝ) ^ n * deriv^[n] (fun y => Real.exp (-(y ^ 2 / 2))) x * Real.exp (x ^ 2 / 2) := by
rw [hermite_eq_deriv_gaussian, Real.exp_neg]
field
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Hermite/Basic.lean | import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Data.Nat.Factorial.DoubleFactorial
/-!
# Hermite polynomials
This file defines `Polynomial.hermite n`, the `n`th probabilists' Hermite polynomial.
## Main definitions
* `Polynomial.hermite n`: the `n`th probabilists' Hermite polynomial,
defined recursively as a `Polynomial ℤ`
## Results
* `Polynomial.hermite_succ`: the recursion `hermite (n+1) = (x - d/dx) (hermite n)`
* `Polynomial.coeff_hermite_explicit`: a closed formula for (nonvanishing) coefficients in terms
of binomial coefficients and double factorials.
* `Polynomial.coeff_hermite_of_odd_add`: for `n`,`k` where `n+k` is odd, `(hermite n).coeff k` is
zero.
* `Polynomial.coeff_hermite_of_even_add`: a closed formula for `(hermite n).coeff k` when `n+k` is
even, equivalent to `Polynomial.coeff_hermite_explicit`.
* `Polynomial.monic_hermite`: for all `n`, `hermite n` is monic.
* `Polynomial.degree_hermite`: for all `n`, `hermite n` has degree `n`.
## References
* [Hermite Polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials)
-/
noncomputable section
open Polynomial
namespace Polynomial
/-- the probabilists' Hermite polynomials. -/
noncomputable def hermite : ℕ → Polynomial ℤ
| 0 => 1
| n + 1 => X * hermite n - derivative (hermite n)
/-- The recursion `hermite (n+1) = (x - d/dx) (hermite n)` -/
@[simp]
theorem hermite_succ (n : ℕ) : hermite (n + 1) = X * hermite n - derivative (hermite n) := by
rw [hermite]
theorem hermite_eq_iterate (n : ℕ) : hermite n = (fun p => X * p - derivative p)^[n] 1 := by
induction n with
| zero => rfl
| succ n ih => rw [Function.iterate_succ_apply', ← ih, hermite_succ]
@[simp]
theorem hermite_zero : hermite 0 = C 1 :=
rfl
theorem hermite_one : hermite 1 = X := by
rw [hermite_succ, hermite_zero]
simp only [map_one, mul_one, derivative_one, sub_zero]
/-! ### Lemmas about `Polynomial.coeff` -/
section coeff
theorem coeff_hermite_succ_zero (n : ℕ) : coeff (hermite (n + 1)) 0 = -coeff (hermite n) 1 := by
simp [coeff_derivative]
theorem coeff_hermite_succ_succ (n k : ℕ) : coeff (hermite (n + 1)) (k + 1) =
coeff (hermite n) k - (k + 2) * coeff (hermite n) (k + 2) := by
rw [hermite_succ, coeff_sub, coeff_X_mul, coeff_derivative, mul_comm]
norm_cast
theorem coeff_hermite_of_lt {n k : ℕ} (hnk : n < k) : coeff (hermite n) k = 0 := by
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hnk
clear hnk
induction n generalizing k with
| zero => exact coeff_C
| succ n ih =>
have : n + k + 1 + 2 = n + (k + 2) + 1 := by ring
rw [coeff_hermite_succ_succ, add_right_comm, this, ih k, ih (k + 2), mul_zero, sub_zero]
@[simp]
theorem coeff_hermite_self (n : ℕ) : coeff (hermite n) n = 1 := by
induction n with
| zero => exact coeff_C
| succ n ih =>
rw [coeff_hermite_succ_succ, ih, coeff_hermite_of_lt, mul_zero, sub_zero]
simp
@[simp]
theorem degree_hermite (n : ℕ) : (hermite n).degree = n := by
rw [degree_eq_of_le_of_coeff_ne_zero]
· simp_rw [degree_le_iff_coeff_zero, Nat.cast_lt]
rintro m hnm
exact coeff_hermite_of_lt hnm
· simp [coeff_hermite_self n]
@[simp]
theorem natDegree_hermite {n : ℕ} : (hermite n).natDegree = n :=
natDegree_eq_of_degree_eq_some (degree_hermite n)
@[simp]
theorem leadingCoeff_hermite (n : ℕ) : (hermite n).leadingCoeff = 1 := by
rw [← coeff_natDegree, natDegree_hermite, coeff_hermite_self]
theorem hermite_monic (n : ℕ) : (hermite n).Monic :=
leadingCoeff_hermite n
theorem coeff_hermite_of_odd_add {n k : ℕ} (hnk : Odd (n + k)) : coeff (hermite n) k = 0 := by
induction n generalizing k with
| zero =>
rw [zero_add k] at hnk
exact coeff_hermite_of_lt hnk.pos
| succ n ih =>
cases k with
| zero =>
rw [Nat.succ_add_eq_add_succ] at hnk
rw [coeff_hermite_succ_zero, ih hnk, neg_zero]
| succ k =>
rw [coeff_hermite_succ_succ, ih, ih, mul_zero, sub_zero]
· rwa [Nat.succ_add_eq_add_succ] at hnk
· rw [(by rw [Nat.succ_add, Nat.add_succ] : n.succ + k.succ = n + k + 2)] at hnk
exact (Nat.odd_add.mp hnk).mpr even_two
end coeff
section CoeffExplicit
open scoped Nat
/-- Because of `coeff_hermite_of_odd_add`, every nonzero coefficient is described as follows. -/
theorem coeff_hermite_explicit :
∀ n k : ℕ, coeff (hermite (2 * n + k)) k = (-1) ^ n * (2 * n - 1)‼ * Nat.choose (2 * n + k) k
| 0, _ => by simp
| n + 1, 0 => by
convert coeff_hermite_succ_zero (2 * n + 1) using 1
rw [coeff_hermite_explicit n 1, (by grind : 2 * (n + 1) - 1 = 2 * n + 1),
Nat.doubleFactorial_add_one, Nat.choose_zero_right,
Nat.choose_one_right, pow_succ]
push_cast
ring
| n + 1, k + 1 => by
let hermite_explicit : ℕ → ℕ → ℤ := fun n k =>
(-1) ^ n * (2 * n - 1)‼ * Nat.choose (2 * n + k) k
have hermite_explicit_recur :
∀ n k : ℕ,
hermite_explicit (n + 1) (k + 1) =
hermite_explicit (n + 1) k - (k + 2) * hermite_explicit n (k + 2) := by
intro n k
simp only [hermite_explicit]
-- Factor out (-1)'s.
rw [mul_comm (↑k + _ : ℤ), sub_eq_add_neg]
nth_rw 3 [neg_eq_neg_one_mul]
simp only [mul_assoc, ← mul_add, pow_succ']
congr 2
-- Factor out double factorials.
norm_cast
rw [(by grind : 2 * (n + 1) - 1 = 2 * n + 1),
Nat.doubleFactorial_add_one, mul_comm (2 * n + 1)]
simp only [mul_assoc, ← mul_add]
congr 1
-- Match up binomial coefficients using `Nat.choose_succ_right_eq`.
rw [(by ring : 2 * (n + 1) + (k + 1) = 2 * n + 1 + (k + 1) + 1),
(by ring : 2 * (n + 1) + k = 2 * n + 1 + (k + 1)),
(by ring : 2 * n + (k + 2) = 2 * n + 1 + (k + 1))]
rw [Nat.choose, Nat.choose_succ_right_eq (2 * n + 1 + (k + 1)) (k + 1), Nat.add_sub_cancel]
ring
change _ = hermite_explicit _ _
rw [← add_assoc, coeff_hermite_succ_succ, hermite_explicit_recur]
congr
· rw [coeff_hermite_explicit (n + 1) k]
· rw [(by ring : 2 * (n + 1) + k = 2 * n + (k + 2)), coeff_hermite_explicit n (k + 2)]
theorem coeff_hermite_of_even_add {n k : ℕ} (hnk : Even (n + k)) :
coeff (hermite n) k = (-1) ^ ((n - k) / 2) * (n - k - 1)‼ * Nat.choose n k := by
rcases le_or_gt k n with h_le | h_lt
· rw [Nat.even_add, ← Nat.even_sub h_le] at hnk
obtain ⟨m, hm⟩ := hnk
rw [(by cutsat : n = 2 * m + k),
Nat.add_sub_cancel, Nat.mul_div_cancel_left _ (Nat.succ_pos 1), coeff_hermite_explicit]
· simp [Nat.choose_eq_zero_of_lt h_lt, coeff_hermite_of_lt h_lt]
theorem coeff_hermite (n k : ℕ) :
coeff (hermite n) k =
if Even (n + k) then (-1 : ℤ) ^ ((n - k) / 2) * (n - k - 1)‼ * Nat.choose n k else 0 := by
split_ifs with h
· exact coeff_hermite_of_even_add h
· exact coeff_hermite_of_odd_add (Nat.not_even_iff_odd.1 h)
end CoeffExplicit
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Eisenstein/Criterion.lean | import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Polynomial.Content
import Mathlib.RingTheory.Ideal.Quotient.Operations
/-! # The Eisenstein criterion
`Polynomial.generalizedEisenstein` :
Let `R` be an integral domain
and let `K` an `R`-algebra which is a field
Let `q : R[X]` be a monic polynomial which is prime in `K[X]`.
Let `f : R[X]` be a polynomial of strictly positive degree
satisfying the following properties:
* the image of `f` in `K[X]` is a power of `q`.
* the leading coefficient of `f` is not zero in `K`
* the polynomial `f` is primitive.
Assume moreover that `f.modByMonic q` is not zero in `(R ⧸ (P ^ 2))[X]`,
where `P` is the kernel of `algebraMap R K`.
Then `f` is irreducible.
We give in `Archive.Examples.Eisenstein` an explicit example
of application of this criterion.
* `Polynomial.irreducible_of_eisenstein_criterion` : the classic Eisenstein criterion.
It is the particular case where `q := X`.
## TODO
The case of a polynomial `q := X - a` is interesting,
then the mod `P ^ 2` hypothesis can rephrased as saying
that `f.derivative.eval a ∉ P ^ 2`. (TODO)
The case of cyclotomic polynomials of prime index `p`
could be proved directly using that result, taking `a = 1`.
The result can also be generalized to the case where
the leading coefficients of `f` and `q` do not belong to `P`.
(By localization at `P`, make these coefficients invertible.)
There are two obstructions, though :
* Usually, one will only obtain irreducibility in `F[X]`, where `F` is the field
of fractions of `R`. (If `R` is a UFD, this will be close to what is wanted,
but not in general.)
* The mod `P ^ 2` hypothesis will have to be rephrased to a condition
in the second symbolic power of `P`. When `P` is a maximal ideal,
that symbolic power coincides with `P ^ 2`, but not in general.
-/
namespace Polynomial
open Ideal.Quotient Ideal RingHom
variable {R : Type*} [CommRing R] [IsDomain R]
{K : Type*} [Field K] [Algebra R K]
private lemma generalizedEisenstein_aux {q f g : R[X]} {p : ℕ}
(hq_irr : Irreducible (q.map (algebraMap R K)))
(hq_monic : q.Monic)
(hf_lC : algebraMap R K f.leadingCoeff ≠ 0)
(hf_prim : f.IsPrimitive)
(hfmodP : f.map (algebraMap R K) =
C (algebraMap R K f.leadingCoeff) * q.map (algebraMap R K) ^ p)
(hg_div : g ∣ f) :
∃ m r, g = C g.leadingCoeff * q ^ m + r ∧
r.map (algebraMap R K) = 0 ∧ (m = 0 → IsUnit g) := by
set P := ker (algebraMap R K)
have hP : P.IsPrime := ker_isPrime (algebraMap R K)
have hgP : g.leadingCoeff ∉ P := by
simp only [mem_ker, P]
obtain ⟨h, rfl⟩ := hg_div
simp only [leadingCoeff_mul, map_mul, ne_eq, mul_eq_zero, not_or] at hf_lC
exact hf_lC.1
have map_dvd_pow_q :
g.map (algebraMap R K) ∣ q.map (algebraMap R K) ^ p := by
rw [← IsUnit.dvd_mul_left _, ← hfmodP]
· exact Polynomial.map_dvd _ hg_div
· simp_all
obtain ⟨m, hm, hf⟩ := (dvd_prime_pow hq_irr.prime _).mp map_dvd_pow_q
set r := g - C g.leadingCoeff * q ^ m
have hg : g = C g.leadingCoeff * q ^ m + r := by ring
have hr : r.map (algebraMap R K) = 0 := by
obtain ⟨u, hu⟩ := hf.symm
obtain ⟨a, ha, ha'⟩ := Polynomial.isUnit_iff.mp u.isUnit
suffices C (algebraMap R K g.leadingCoeff) = u by
simp [r, ← this, Polynomial.map_sub, ← hu, Polynomial.map_mul, map_C,
Polynomial.map_pow, mul_comm]
rw [← leadingCoeff_map_of_leadingCoeff_ne_zero _ hgP, ← hu, ← ha',
leadingCoeff_mul, leadingCoeff_C, (hq_monic.map _).pow m, one_mul]
use m, r, hg, hr
intro hm
rw [isPrimitive_iff_isUnit_of_C_dvd] at hf_prim
rw [hm, pow_zero, mul_one] at hg
suffices g.natDegree = 0 by
obtain ⟨a, rfl⟩ := Polynomial.natDegree_eq_zero.mp this
apply IsUnit.map
apply hf_prim
rwa [leadingCoeff_C] at hgP
by_contra hg'
apply hgP
rw [hg, leadingCoeff, coeff_add, ← hg, coeff_C, if_neg hg', zero_add,
mem_ker, ← coeff_map, hr, coeff_zero]
/-- A generalized Eisenstein criterion
Let `R` be an integral domain and `K` an `R`-algebra which is a domain.
Let `q : R[X]` be a monic polynomial which is prime in `K[X]`.
Let `f : R[X]` be a primitive polynomial of strictly positive degree
whose leading coefficient is not zero in `K`
and such that the image `f` in `K[X]` is a power of `q`.
Assume moreover that `f.modByMonic q` is not zero in `(R ⧸ (P ^ 2))[X]`,
where `P` is the kernel of `algebraMap R K`.
Then `f` is irreducible. -/
theorem generalizedEisenstein {q f : R[X]} {p : ℕ}
(hq_irr : Irreducible (q.map (algebraMap R K))) (hq_monic : q.Monic)
(hf_prim : f.IsPrimitive)
(hfd0 : 0 < natDegree f)
(hfP : algebraMap R K f.leadingCoeff ≠ 0)
(hfmodP : f.map (algebraMap R K) =
C (algebraMap R K f.leadingCoeff) * q.map (algebraMap R K) ^ p)
(hfmodP2 : (f.modByMonic q).map (mk ((ker (algebraMap R K)) ^ 2)) ≠ 0) :
Irreducible f where
not_isUnit := mt degree_eq_zero_of_isUnit fun h => by
simp_all [natDegree_pos_iff_degree_pos]
isUnit_or_isUnit g h h_eq := by
-- We have to show that factorizations `f = g * h` are trivial
set P : Ideal R := ker (algebraMap R K)
obtain ⟨m, r, hg, hr, hm0⟩ :=
generalizedEisenstein_aux hq_irr hq_monic hfP hf_prim hfmodP (h_eq ▸ dvd_mul_right g h)
obtain ⟨n, s, hh, hs, hn0⟩ :=
generalizedEisenstein_aux hq_irr hq_monic hfP hf_prim hfmodP (h_eq ▸ dvd_mul_left h g)
by_cases hm : m = 0
-- If `m = 0`, `generalizedEisenstein_aux` shows that `g` is a unit.
· left; exact hm0 hm
by_cases hn : n = 0
-- If `n = 0`, `generalizedEisenstein_aux` shows that `h` is a unit.
· right; exact hn0 hn
-- Otherwise, we will get a contradiction by showing that `f %ₘ q` is zero mod `P ^ 2`.
exfalso
apply hfmodP2
suffices f %ₘ q = (r * s) %ₘ q by
-- Since the coefficients of `r` and `s` are in `P`, those of `r * s` are in `P ^ 2`
suffices h : map (Ideal.Quotient.mk (P ^ 2)) (r * s) = 0 by
simp [this, h, map_modByMonic, hq_monic]
ext n
have h (x : ℕ × ℕ) : (Ideal.Quotient.mk (P ^ 2)) (r.coeff x.1 * s.coeff x.2) = 0 := by
rw [eq_zero_iff_mem, pow_two]
apply mul_mem_mul
· rw [mem_ker, ← coeff_map, hr, coeff_zero]
· rw [mem_ker, ← coeff_map, hs, coeff_zero]
simp [- Polynomial.map_mul, coeff_mul, h]
-- It remains to prove the equality `f %ₘ q = (r * s) %ₘ q`, which is straightforward
rw [h_eq, hg, hh]
simp only [add_mul, mul_add, map_add, ← modByMonicHom_apply]
simp only [← add_assoc, modByMonicHom_apply]
iterate 3 rw [(modByMonic_eq_zero_iff_dvd hq_monic).mpr]
· simp
· exact ((dvd_pow_self q hm).mul_left _).mul_right _
· simp only [← mul_assoc]
exact (dvd_pow_self q hn).mul_left _
· exact ((dvd_pow_self q hn).mul_left _).mul_left _
/-- If `f` is a nonconstant polynomial with coefficients in `R`, and `P` is a prime ideal in `R`,
then if every coefficient in `R` except the leading coefficient is in `P`, and
the trailing coefficient is not in `P^2` and no nonunits in `R` divide `f`, then `f` is
irreducible. -/
theorem irreducible_of_eisenstein_criterion {f : R[X]} {P : Ideal R} (hP : P.IsPrime)
(hfl : f.leadingCoeff ∉ P)
(hfP : ∀ n : ℕ, ↑n < degree f → f.coeff n ∈ P) (hfd0 : 0 < degree f)
(h0 : f.coeff 0 ∉ P ^ 2) (hu : f.IsPrimitive) : Irreducible f := by
apply generalizedEisenstein (K := FractionRing (R ⧸ P)) (q := X) (p := f.natDegree)
(by simp [map_X, irreducible_X]) monic_X hu
(natDegree_pos_iff_degree_pos.mpr hfd0)
· simp only [IsScalarTower.algebraMap_eq R (R ⧸ P) (FractionRing (R ⧸ P)),
Quotient.algebraMap_eq, coe_comp, Function.comp_apply, ne_eq,
FaithfulSMul.algebraMap_eq_zero_iff]
rw [Ideal.Quotient.eq_zero_iff_mem]
exact hfl
· rw [← map_C, ← Polynomial.map_pow, ← Polynomial.map_mul]
simp only [IsScalarTower.algebraMap_eq R (R ⧸ P) (FractionRing (R ⧸ P)),
Quotient.algebraMap_eq, ← map_map]
congr 1
ext n
simp only [coeff_map, Ideal.Quotient.mk_eq_mk_iff_sub_mem]
simp only [coeff_C_mul, coeff_X_pow, mul_ite, mul_one, mul_zero, sub_ite, sub_zero]
split_ifs with hn
· rw [hn, leadingCoeff, sub_self]
exact zero_mem _
· by_cases hn' : n < f.natDegree
· exact hfP _ (coe_lt_degree.mpr hn')
· rw [f.coeff_eq_zero_of_natDegree_lt]
· exact P.zero_mem
· simp [Nat.lt_iff_le_and_ne, ← Nat.not_lt, hn', Ne.symm hn]
· rw [modByMonic_X, map_C, ne_eq, C_eq_zero, Ideal.Quotient.eq_zero_iff_mem,
← coeff_zero_eq_eval_zero]
convert h0
· rw [IsScalarTower.algebraMap_eq R (R ⧸ P) (FractionRing (R ⧸ P))]
rw [ker_comp_of_injective]
· ext a; simp
· exact FaithfulSMul.algebraMap_injective (R ⧸ P) (FractionRing (R ⧸ P))
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Eisenstein/Basic.lean | import Mathlib.RingTheory.Ideal.BigOperators
import Mathlib.RingTheory.Polynomial.Eisenstein.Criterion
import Mathlib.RingTheory.Polynomial.ScaleRoots
/-!
# Eisenstein polynomials
Given an ideal `𝓟` of a commutative semiring `R`, we say that a polynomial `f : R[X]` is
*Eisenstein at `𝓟`* if `f.leadingCoeff ∉ 𝓟`, `∀ n, n < f.natDegree → f.coeff n ∈ 𝓟` and
`f.coeff 0 ∉ 𝓟 ^ 2`. In this file we gather miscellaneous results about Eisenstein polynomials.
## Main definitions
* `Polynomial.IsEisensteinAt f 𝓟`: the property of being Eisenstein at `𝓟`.
## Main results
* `Polynomial.IsEisensteinAt.irreducible`: if a primitive `f` satisfies `f.IsEisensteinAt 𝓟`,
where `𝓟.IsPrime`, then `f` is irreducible.
## Implementation details
We also define a notion `IsWeaklyEisensteinAt` requiring only that
`∀ n < f.natDegree → f.coeff n ∈ 𝓟`. This makes certain results slightly more general and it is
useful since it is sometimes better behaved (for example it is stable under `Polynomial.map`).
-/
universe u v w z
variable {R : Type u}
open Ideal Algebra Finset
open Polynomial
namespace Polynomial
/-- Given an ideal `𝓟` of a commutative semiring `R`, we say that a polynomial `f : R[X]`
is *weakly Eisenstein at `𝓟`* if `∀ n, n < f.natDegree → f.coeff n ∈ 𝓟`. -/
@[mk_iff]
structure IsWeaklyEisensteinAt [CommSemiring R] (f : R[X]) (𝓟 : Ideal R) : Prop where
mem : ∀ {n}, n < f.natDegree → f.coeff n ∈ 𝓟
/-- Given an ideal `𝓟` of a commutative semiring `R`, we say that a polynomial `f : R[X]`
is *Eisenstein at `𝓟`* if `f.leadingCoeff ∉ 𝓟`, `∀ n, n < f.natDegree → f.coeff n ∈ 𝓟` and
`f.coeff 0 ∉ 𝓟 ^ 2`. -/
@[mk_iff]
structure IsEisensteinAt [CommSemiring R] (f : R[X]) (𝓟 : Ideal R) : Prop where
leading : f.leadingCoeff ∉ 𝓟
mem : ∀ {n}, n < f.natDegree → f.coeff n ∈ 𝓟
notMem : f.coeff 0 ∉ 𝓟 ^ 2
namespace IsWeaklyEisensteinAt
section CommSemiring
variable [CommSemiring R] {𝓟 : Ideal R} {f f' : R[X]}
theorem map (hf : f.IsWeaklyEisensteinAt 𝓟) {A : Type v} [CommSemiring A] (φ : R →+* A) :
(f.map φ).IsWeaklyEisensteinAt (𝓟.map φ) := by
refine (isWeaklyEisensteinAt_iff _ _).2 fun hn => ?_
rw [coeff_map]
exact mem_map_of_mem _ (hf.mem (lt_of_lt_of_le hn natDegree_map_le))
theorem mul (hf : f.IsWeaklyEisensteinAt 𝓟) (hf' : f'.IsWeaklyEisensteinAt 𝓟) :
(f * f').IsWeaklyEisensteinAt 𝓟 := by
rw [isWeaklyEisensteinAt_iff] at hf hf' ⊢
intro n hn
rw [coeff_mul]
refine sum_mem _ fun x hx ↦ ?_
rcases lt_or_ge x.1 f.natDegree with hx1 | hx1
· exact mul_mem_right _ _ (hf hx1)
replace hx1 : x.2 < f'.natDegree := by
by_contra!
rw [HasAntidiagonal.mem_antidiagonal] at hx
replace hn := hn.trans_le natDegree_mul_le
linarith
exact mul_mem_left _ _ (hf' hx1)
end CommSemiring
section CommRing
variable [CommRing R] {𝓟 : Ideal R} {f : R[X]}
variable {S : Type v} [CommRing S] [Algebra R S]
section Principal
variable {p : R}
theorem exists_mem_adjoin_mul_eq_pow_natDegree {x : S} (hx : aeval x f = 0) (hmo : f.Monic)
(hf : f.IsWeaklyEisensteinAt (Submodule.span R {p})) : ∃ y ∈ adjoin R ({x} : Set S),
(algebraMap R S) p * y = x ^ (f.map (algebraMap R S)).natDegree := by
rw [aeval_def, Polynomial.eval₂_eq_eval_map, eval_eq_sum_range, range_add_one,
sum_insert notMem_range_self, sum_range, (hmo.map (algebraMap R S)).coeff_natDegree,
one_mul] at hx
replace hx := eq_neg_of_add_eq_zero_left hx
have : ∀ n < f.natDegree, p ∣ f.coeff n := by
intro n hn
exact mem_span_singleton.1 (by simpa using hf.mem hn)
choose! φ hφ using this
conv_rhs at hx =>
congr
congr
· skip
ext i
rw [coeff_map, hφ i.1 (lt_of_lt_of_le i.2 natDegree_map_le),
RingHom.map_mul, mul_assoc]
rw [hx, ← mul_sum, neg_eq_neg_one_mul, ← mul_assoc (-1 : S), mul_comm (-1 : S), mul_assoc]
refine
⟨-1 * ∑ i : Fin (f.map (algebraMap R S)).natDegree, (algebraMap R S) (φ i.1) * x ^ i.1, ?_, rfl⟩
exact
Subalgebra.mul_mem _ (Subalgebra.neg_mem _ (Subalgebra.one_mem _))
(Subalgebra.sum_mem _ fun i _ =>
Subalgebra.mul_mem _ (Subalgebra.algebraMap_mem _ _)
(Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton x)) _))
theorem exists_mem_adjoin_mul_eq_pow_natDegree_le {x : S} (hx : aeval x f = 0) (hmo : f.Monic)
(hf : f.IsWeaklyEisensteinAt (Submodule.span R {p})) :
∀ i, (f.map (algebraMap R S)).natDegree ≤ i →
∃ y ∈ adjoin R ({x} : Set S), (algebraMap R S) p * y = x ^ i := by
intro i hi
obtain ⟨k, hk⟩ := exists_add_of_le hi
rw [hk, pow_add]
obtain ⟨y, hy, H⟩ := exists_mem_adjoin_mul_eq_pow_natDegree hx hmo hf
refine ⟨y * x ^ k, ?_, ?_⟩
· exact Subalgebra.mul_mem _ hy (Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton x)) _)
· rw [← mul_assoc _ y, H]
end Principal
theorem pow_natDegree_le_of_root_of_monic_mem (hf : f.IsWeaklyEisensteinAt 𝓟)
{x : R} (hroot : IsRoot f x) (hmo : f.Monic) :
∀ i, f.natDegree ≤ i → x ^ i ∈ 𝓟 := by
intro i hi
obtain ⟨k, hk⟩ := exists_add_of_le hi
rw [hk, pow_add]
suffices x ^ f.natDegree ∈ 𝓟 by exact mul_mem_right (x ^ k) 𝓟 this
rw [IsRoot.def, eval_eq_sum_range, Finset.range_add_one,
Finset.sum_insert Finset.notMem_range_self, Finset.sum_range, hmo.coeff_natDegree, one_mul] at
*
rw [eq_neg_of_add_eq_zero_left hroot, neg_mem_iff]
exact Submodule.sum_mem _ fun i _ => mul_mem_right _ _ (hf.mem (Fin.is_lt i))
theorem pow_natDegree_le_of_aeval_zero_of_monic_mem_map (hf : f.IsWeaklyEisensteinAt 𝓟)
{x : S} (hx : aeval x f = 0) (hmo : f.Monic) :
∀ i, (f.map (algebraMap R S)).natDegree ≤ i → x ^ i ∈ 𝓟.map (algebraMap R S) := by
suffices x ^ (f.map (algebraMap R S)).natDegree ∈ 𝓟.map (algebraMap R S) by
intro i hi
obtain ⟨k, hk⟩ := exists_add_of_le hi
rw [hk, pow_add]
exact mul_mem_right _ _ this
rw [aeval_def, eval₂_eq_eval_map, ← IsRoot.def] at hx
exact pow_natDegree_le_of_root_of_monic_mem (hf.map _) hx (hmo.map _) _ rfl.le
end CommRing
end IsWeaklyEisensteinAt
section ScaleRoots
variable {A : Type*} [CommRing R] [CommRing A]
theorem scaleRoots.isWeaklyEisensteinAt (p : R[X]) {x : R} {P : Ideal R} (hP : x ∈ P) :
(scaleRoots p x).IsWeaklyEisensteinAt P := by
refine ⟨fun i => ?_⟩
rw [coeff_scaleRoots]
rw [natDegree_scaleRoots, ← tsub_pos_iff_lt] at i
exact Ideal.mul_mem_left _ _ (Ideal.pow_mem_of_mem P hP _ i)
theorem dvd_pow_natDegree_of_eval₂_eq_zero {f : R →+* A} (hf : Function.Injective f) {p : R[X]}
(hp : p.Monic) (x y : R) (z : A) (h : p.eval₂ f z = 0) (hz : f x * z = f y) :
x ∣ y ^ p.natDegree := by
rw [← natDegree_scaleRoots p x, ← Ideal.mem_span_singleton]
refine
(scaleRoots.isWeaklyEisensteinAt _
(Ideal.mem_span_singleton.mpr <| dvd_refl x)).pow_natDegree_le_of_root_of_monic_mem
?_ ((monic_scaleRoots_iff x).mpr hp) _ le_rfl
rw [injective_iff_map_eq_zero'] at hf
have : eval₂ f _ (p.scaleRoots x) = 0 := scaleRoots_eval₂_eq_zero f h
rwa [hz, Polynomial.eval₂_at_apply, hf] at this
theorem dvd_pow_natDegree_of_aeval_eq_zero [Algebra R A] [Nontrivial A] [NoZeroSMulDivisors R A]
{p : R[X]} (hp : p.Monic) (x y : R) (z : A) (h : Polynomial.aeval z p = 0)
(hz : z * algebraMap R A x = algebraMap R A y) : x ∣ y ^ p.natDegree :=
dvd_pow_natDegree_of_eval₂_eq_zero (FaithfulSMul.algebraMap_injective R A) hp x y z h
((mul_comm _ _).trans hz)
end ScaleRoots
namespace IsEisensteinAt
@[deprecated (since := "2025-05-23")] alias not_mem := notMem
section CommSemiring
variable [CommSemiring R] {𝓟 : Ideal R} {f : R[X]}
theorem _root_.Polynomial.Monic.leadingCoeff_notMem (hf : f.Monic) (h : 𝓟 ≠ ⊤) :
f.leadingCoeff ∉ 𝓟 := hf.leadingCoeff.symm ▸ (Ideal.ne_top_iff_one _).1 h
@[deprecated (since := "2025-05-23")]
alias _root_.Polynomial.Monic.leadingCoeff_not_mem := _root_.Polynomial.Monic.leadingCoeff_notMem
theorem _root_.Polynomial.Monic.isEisensteinAt_of_mem_of_notMem (hf : f.Monic) (h : 𝓟 ≠ ⊤)
(hmem : ∀ {n}, n < f.natDegree → f.coeff n ∈ 𝓟) (hnotMem : f.coeff 0 ∉ 𝓟 ^ 2) :
f.IsEisensteinAt 𝓟 :=
{ leading := Polynomial.Monic.leadingCoeff_notMem hf h
mem := fun hn => hmem hn
notMem := hnotMem }
@[deprecated (since := "2025-05-23")]
alias _root_.Polynomial.Monic.isEisensteinAt_of_mem_of_not_mem :=
_root_.Polynomial.Monic.isEisensteinAt_of_mem_of_notMem
theorem isWeaklyEisensteinAt (hf : f.IsEisensteinAt 𝓟) : IsWeaklyEisensteinAt f 𝓟 :=
⟨fun h => hf.mem h⟩
theorem coeff_mem (hf : f.IsEisensteinAt 𝓟) {n : ℕ} (hn : n ≠ f.natDegree) : f.coeff n ∈ 𝓟 := by
rcases ne_iff_lt_or_gt.1 hn with h₁ | h₂
· exact hf.mem h₁
· rw [coeff_eq_zero_of_natDegree_lt h₂]
exact Ideal.zero_mem _
end CommSemiring
section IsDomain
variable [CommRing R] [IsDomain R] {𝓟 : Ideal R} {f : R[X]}
/-- If a primitive `f` satisfies `f.IsEisensteinAt 𝓟`, where `𝓟.IsPrime`,
then `f` is irreducible. -/
theorem irreducible (hf : f.IsEisensteinAt 𝓟) (hprime : 𝓟.IsPrime) (hu : f.IsPrimitive)
(hfd0 : 0 < f.natDegree) : Irreducible f :=
irreducible_of_eisenstein_criterion hprime hf.leading (fun _ hn => hf.mem (coe_lt_degree.1 hn))
(natDegree_pos_iff_degree_pos.1 hfd0) hf.notMem hu
end IsDomain
end IsEisensteinAt
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Eisenstein/IsIntegral.lean | import Mathlib.Data.Nat.Choose.Dvd
import Mathlib.RingTheory.IntegralClosure.IntegrallyClosed
import Mathlib.RingTheory.Norm.Transitivity
import Mathlib.RingTheory.Polynomial.Cyclotomic.Expand
/-!
# Eisenstein polynomials
In this file we gather more miscellaneous results about Eisenstein polynomials
## Main results
* `mem_adjoin_of_smul_prime_pow_smul_of_minpoly_isEisensteinAt`: let `K` be the field of fraction
of an integrally closed domain `R` and let `L` be an extension of `K`, generated by an integral
power basis `B` such that the minimal polynomial of `B.gen` is Eisenstein at `p`. Given `z : L`
integral over `R`, if `p ^ n • z ∈ adjoin R {B.gen}`, then `z ∈ adjoin R {B.gen}`.
Together with `Algebra.discr_mul_isIntegral_mem_adjoin` this result often allows to compute the
ring of integers of `L`.
-/
universe u v w z
variable {R : Type u}
open Ideal Algebra Finset
open scoped Polynomial
section Cyclotomic
variable (p : ℕ)
local notation "𝓟" => Submodule.span ℤ {(p : ℤ)}
open Polynomial
theorem cyclotomic_comp_X_add_one_isEisensteinAt [hp : Fact p.Prime] :
((cyclotomic p ℤ).comp (X + 1)).IsEisensteinAt 𝓟 := by
refine Monic.isEisensteinAt_of_mem_of_notMem ?_
(Ideal.IsPrime.ne_top <| (Ideal.span_singleton_prime (mod_cast hp.out.ne_zero)).2 <|
Nat.prime_iff_prime_int.1 hp.out) (fun {i hi} => ?_) ?_
· rw [show (X + 1 : ℤ[X]) = X + C 1 by simp]
refine (cyclotomic.monic p ℤ).comp (monic_X_add_C 1) fun h => ?_
rw [natDegree_X_add_C] at h
exact zero_ne_one h.symm
· rw [cyclotomic_prime, geom_sum_X_comp_X_add_one_eq_sum, ← lcoeff_apply, map_sum]
conv =>
congr
congr
next => skip
congr
next => skip
ext
rw [lcoeff_apply, ← C_eq_natCast, C_mul_X_pow_eq_monomial, coeff_monomial]
rw [natDegree_comp, show (X + 1 : ℤ[X]) = X + C 1 by simp, natDegree_X_add_C, mul_one,
natDegree_cyclotomic, Nat.totient_prime hp.out] at hi
simp only [hi.trans_le (Nat.sub_le _ _), sum_ite_eq', mem_range, if_true,
Ideal.submodule_span_eq, Ideal.mem_span_singleton, Int.natCast_dvd_natCast]
exact hp.out.dvd_choose_self i.succ_ne_zero (lt_tsub_iff_right.1 hi)
· rw [coeff_zero_eq_eval_zero, eval_comp, cyclotomic_prime, eval_add, eval_X, eval_one, zero_add,
eval_geom_sum, one_geom_sum, Ideal.submodule_span_eq, Ideal.span_singleton_pow,
Ideal.mem_span_singleton]
intro h
obtain ⟨k, hk⟩ := Int.natCast_dvd_natCast.1 h
rw [mul_assoc, mul_comm 1, mul_one] at hk
nth_rw 1 [← Nat.mul_one p] at hk
rw [mul_right_inj' hp.out.ne_zero] at hk
exact Nat.Prime.not_dvd_one hp.out (Dvd.intro k hk.symm)
theorem cyclotomic_prime_pow_comp_X_add_one_isEisensteinAt [hp : Fact p.Prime] (n : ℕ) :
((cyclotomic (p ^ (n + 1)) ℤ).comp (X + 1)).IsEisensteinAt 𝓟 := by
refine Monic.isEisensteinAt_of_mem_of_notMem ?_
(Ideal.IsPrime.ne_top <| (Ideal.span_singleton_prime (mod_cast hp.out.ne_zero)).2 <|
Nat.prime_iff_prime_int.1 hp.out) ?_ ?_
· rw [show (X + 1 : ℤ[X]) = X + C 1 by simp]
refine (cyclotomic.monic _ ℤ).comp (monic_X_add_C 1) fun h => ?_
rw [natDegree_X_add_C] at h
exact zero_ne_one h.symm
· induction n with
| zero =>
intro i hi
rw [Nat.zero_add, pow_one] at hi ⊢
exact (cyclotomic_comp_X_add_one_isEisensteinAt p).mem hi
| succ n hn =>
intro i hi
rw [Ideal.submodule_span_eq, Ideal.mem_span_singleton, ← ZMod.intCast_zmod_eq_zero_iff_dvd,
show ↑(_ : ℤ) = Int.castRingHom (ZMod p) _ by rfl, ← coeff_map, map_comp, map_cyclotomic,
Polynomial.map_add, map_X, Polynomial.map_one, pow_add, pow_one,
cyclotomic_mul_prime_dvd_eq_pow, pow_comp, ← ZMod.expand_card, coeff_expand hp.out.pos]
· simp only [ite_eq_right_iff]
rintro ⟨k, hk⟩
rw [natDegree_comp, show (X + 1 : ℤ[X]) = X + C 1 by simp, natDegree_X_add_C, mul_one,
natDegree_cyclotomic, Nat.totient_prime_pow hp.out (Nat.succ_pos _), Nat.add_one_sub_one]
at hn hi
rw [hk, pow_succ', mul_assoc] at hi
rw [hk, mul_comm, Nat.mul_div_cancel _ hp.out.pos]
replace hn := hn (lt_of_mul_lt_mul_left' hi)
rw [Ideal.submodule_span_eq, Ideal.mem_span_singleton, ← ZMod.intCast_zmod_eq_zero_iff_dvd,
show ↑(_ : ℤ) = Int.castRingHom (ZMod p) _ by rfl, ← coeff_map] at hn
simpa [map_comp] using hn
· exact ⟨p ^ n, by rw [pow_succ']⟩
· rw [coeff_zero_eq_eval_zero, eval_comp, cyclotomic_prime_pow_eq_geom_sum hp.out, eval_add,
eval_X, eval_one, zero_add, eval_finset_sum]
simp only [eval_pow, eval_X, one_pow, sum_const, card_range, Nat.smul_one_eq_cast,
submodule_span_eq, Ideal.submodule_span_eq, Ideal.span_singleton_pow,
Ideal.mem_span_singleton]
intro h
obtain ⟨k, hk⟩ := Int.natCast_dvd_natCast.1 h
rw [mul_assoc, mul_comm 1, mul_one] at hk
nth_rw 1 [← Nat.mul_one p] at hk
rw [mul_right_inj' hp.out.ne_zero] at hk
exact Nat.Prime.not_dvd_one hp.out (Dvd.intro k hk.symm)
end Cyclotomic
section IsIntegral
variable {K : Type v} {L : Type z} {p : R} [CommRing R] [Field K] [Field L]
variable [Algebra K L] [Algebra R L] [Algebra R K] [IsScalarTower R K L]
variable [IsDomain R] [IsFractionRing R K] [IsIntegrallyClosed R]
local notation "𝓟" => Submodule.span R {(p : R)}
open IsIntegrallyClosed PowerBasis Nat Polynomial IsScalarTower
/-- Let `K` be the field of fraction of an integrally closed domain `R` and let `L` be an extension
of `K`, generated by an integral power basis `B` such that the minimal polynomial of `B.gen` is
Eisenstein at `p`. Given `z : L` integral over `R`, if `Q : R[X]` is such that
`aeval B.gen Q = p • z`, then `p ∣ Q.coeff 0`. -/
theorem dvd_coeff_zero_of_aeval_eq_prime_smul_of_minpoly_isEisensteinAt {B : PowerBasis K L}
(hp : Prime p) (hBint : IsIntegral R B.gen) {z : L} {Q : R[X]} (hQ : aeval B.gen Q = p • z)
(hzint : IsIntegral R z) (hei : (minpoly R B.gen).IsEisensteinAt 𝓟) : p ∣ Q.coeff 0 := by
-- First define some abbreviations.
letI := B.finite
let P := minpoly R B.gen
obtain ⟨n, hn⟩ := Nat.exists_eq_succ_of_ne_zero B.dim_pos.ne'
have finrank_K_L : Module.finrank K L = B.dim := B.finrank
have deg_K_P : (minpoly K B.gen).natDegree = B.dim := B.natDegree_minpoly
have deg_R_P : P.natDegree = B.dim := by
rw [← deg_K_P, minpoly.isIntegrallyClosed_eq_field_fractions' K hBint,
(minpoly.monic hBint).natDegree_map (algebraMap R K)]
choose! f hf using
hei.isWeaklyEisensteinAt.exists_mem_adjoin_mul_eq_pow_natDegree_le (minpoly.aeval R B.gen)
(minpoly.monic hBint)
simp only [P, (minpoly.monic hBint).natDegree_map, deg_R_P] at hf
-- The Eisenstein condition shows that `p` divides `Q.coeff 0`
-- if `p^n.succ` divides the following multiple of `Q.coeff 0^n.succ`:
suffices
p ^ n.succ ∣ Q.coeff 0 ^ n.succ * ((-1) ^ (n.succ * n) * (minpoly R B.gen).coeff 0 ^ n) by
have hndiv : ¬p ^ 2 ∣ (minpoly R B.gen).coeff 0 := fun h =>
hei.notMem ((span_singleton_pow p 2).symm ▸ Ideal.mem_span_singleton.2 h)
refine @Prime.dvd_of_pow_dvd_pow_mul_pow_of_square_not_dvd R _ _ _ _ n hp (?_ : _ ∣ _) hndiv
convert (IsUnit.dvd_mul_right ⟨(-1) ^ (n.succ * n), rfl⟩).mpr this using 1
push_cast
ring_nf
rw [mul_comm _ 2, pow_mul, neg_one_sq, one_pow, mul_one]
-- We claim the quotient of `Q^n * _` by `p^n` is the following `r`:
have aux : ∀ i ∈ (range (Q.natDegree + 1)).erase 0, B.dim ≤ i + n := by grind
have hintsum :
IsIntegral R
(z * B.gen ^ n - ∑ x ∈ (range (Q.natDegree + 1)).erase 0, Q.coeff x • f (x + n)) := by
refine (hzint.mul (hBint.pow _)).sub (.sum _ fun i hi => .smul _ ?_)
exact adjoin_le_integralClosure hBint (hf _ (aux i hi)).1
obtain ⟨r, hr⟩ := isIntegral_iff.1 (isIntegral_norm K hintsum)
use r
-- Do the computation in `K` so we can work in terms of `z` instead of `r`.
apply IsFractionRing.injective R K
simp only [map_mul, map_pow, map_neg, map_one]
-- Both sides are actually norms:
calc
_ = norm K (Q.coeff 0 • B.gen ^ n) := ?_
_ = norm K (p • (z * B.gen ^ n) -
∑ x ∈ (range (Q.natDegree + 1)).erase 0, p • Q.coeff x • f (x + n)) :=
(congr_arg (norm K) (eq_sub_of_add_eq ?_))
_ = _ := ?_
· simp only [Algebra.smul_def, algebraMap_apply R K L, Algebra.norm_algebraMap, map_mul,
map_pow, finrank_K_L, PowerBasis.norm_gen_eq_coeff_zero_minpoly,
minpoly.isIntegrallyClosed_eq_field_fractions' K hBint, coeff_map, ← hn]
ring
swap
· simp_rw [← smul_sum, ← smul_sub, Algebra.smul_def p, algebraMap_apply R K L, map_mul,
Algebra.norm_algebraMap, finrank_K_L, hr, ← hn]
calc
_ = (Q.coeff 0 • ↑1 + ∑ x ∈ (range (Q.natDegree + 1)).erase 0, Q.coeff x • B.gen ^ x) *
B.gen ^ n := ?_
_ = (Q.coeff 0 • B.gen ^ 0 +
∑ x ∈ (range (Q.natDegree + 1)).erase 0, Q.coeff x • B.gen ^ x) * B.gen ^ n := by
rw [pow_zero]
_ = aeval B.gen Q * B.gen ^ n := ?_
_ = _ := by rw [hQ, Algebra.smul_mul_assoc]
· have : ∀ i ∈ (range (Q.natDegree + 1)).erase 0,
Q.coeff i • (B.gen ^ i * B.gen ^ n) = p • Q.coeff i • f (i + n) := by
intro i hi
rw [← pow_add, ← (hf _ (aux i hi)).2, ← Algebra.smul_def, smul_smul, mul_comm _ p, smul_smul]
simp only [add_mul, smul_mul_assoc, one_mul, sum_mul, sum_congr rfl this]
· rw [aeval_eq_sum_range,
Finset.add_sum_erase (range (Q.natDegree + 1)) fun i => Q.coeff i • B.gen ^ i]
simp
theorem mem_adjoin_of_dvd_coeff_of_dvd_aeval {A B : Type*} [CommSemiring A] [Ring B]
[Algebra A B] [NoZeroSMulDivisors A B] {Q : A[X]} {p : A} {x z : B} (hp : p ≠ 0)
(hQ : ∀ i ∈ range (Q.natDegree + 1), p ∣ Q.coeff i) (hz : aeval x Q = p • z) :
z ∈ adjoin A ({x} : Set B) := by
choose! f hf using hQ
rw [aeval_eq_sum_range, sum_range] at hz
conv_lhs at hz =>
congr
next => skip
ext i
rw [hf i (mem_range.2 (Fin.is_lt i)), ← smul_smul]
rw [← smul_sum] at hz
rw [← smul_right_injective _ hp hz]
exact
Subalgebra.sum_mem _ fun _ _ =>
Subalgebra.smul_mem _ (Subalgebra.pow_mem _ (subset_adjoin (Set.mem_singleton _)) _) _
/-- Let `K` be the field of fraction of an integrally closed domain `R` and let `L` be an extension
of `K`, generated by an integral power basis `B` such that the minimal polynomial of `B.gen` is
Eisenstein at `p`. Given `z : L` integral over `R`, if `p • z ∈ adjoin R {B.gen}`, then
`z ∈ adjoin R {B.gen}`. -/
theorem mem_adjoin_of_smul_prime_smul_of_minpoly_isEisensteinAt {B : PowerBasis K L}
(hp : Prime p) (hBint : IsIntegral R B.gen) {z : L} (hzint : IsIntegral R z)
(hz : p • z ∈ adjoin R ({B.gen} : Set L)) (hei : (minpoly R B.gen).IsEisensteinAt 𝓟) :
z ∈ adjoin R ({B.gen} : Set L) := by
-- First define some abbreviations.
have hndiv : ¬p ^ 2 ∣ (minpoly R B.gen).coeff 0 := fun h =>
hei.notMem ((span_singleton_pow p 2).symm ▸ Ideal.mem_span_singleton.2 h)
have := B.finite
set P := minpoly R B.gen with hP
obtain ⟨n, hn⟩ := Nat.exists_eq_succ_of_ne_zero B.dim_pos.ne'
haveI : NoZeroSMulDivisors R L := NoZeroSMulDivisors.trans_faithfulSMul R K L
let _ := P.map (algebraMap R L)
-- There is a polynomial `Q` such that `p • z = aeval B.gen Q`. We can assume that
-- `Q.degree < P.degree` and `Q ≠ 0`.
rw [adjoin_singleton_eq_range_aeval] at hz
obtain ⟨Q₁, hQ⟩ := hz
set Q := Q₁ %ₘ P with hQ₁
replace hQ : aeval B.gen Q = p • z := by
rw [← modByMonic_add_div Q₁ (minpoly.monic hBint)] at hQ
simpa using hQ
by_cases hQzero : Q = 0
· simp only [hQzero, Algebra.smul_def, zero_eq_mul, aeval_zero] at hQ
rcases hQ with H | H₁
· have : Function.Injective (algebraMap R L) := by
rw [algebraMap_eq R K L]
exact (algebraMap K L).injective.comp (IsFractionRing.injective R K)
exfalso
exact hp.ne_zero ((injective_iff_map_eq_zero _).1 this _ H)
· rw [H₁]
exact Subalgebra.zero_mem _
-- It is enough to prove that all coefficients of `Q` are divisible by `p`, by induction.
-- The base case is `dvd_coeff_zero_of_aeval_eq_prime_smul_of_minpoly_isEisensteinAt`.
refine mem_adjoin_of_dvd_coeff_of_dvd_aeval hp.ne_zero (fun i => ?_) hQ
induction i using Nat.case_strong_induction_on with
| hz =>
intro
exact dvd_coeff_zero_of_aeval_eq_prime_smul_of_minpoly_isEisensteinAt hp hBint hQ hzint hei
| hi j hind =>
intro hj
convert hp.dvd_of_pow_dvd_pow_mul_pow_of_square_not_dvd (n := n) _ hndiv
-- Two technical results we will need about `P.natDegree` and `Q.natDegree`.
have H := degree_modByMonic_lt Q₁ (minpoly.monic hBint)
rw [← hQ₁, ← hP] at H
replace H := Nat.lt_iff_add_one_le.1
(lt_of_lt_of_le
(lt_of_le_of_lt (Nat.lt_iff_add_one_le.1 (Nat.lt_of_succ_lt_succ (mem_range.1 hj)))
(lt_succ_self _)) (Nat.lt_iff_add_one_le.1 ((natDegree_lt_natDegree_iff hQzero).2 H)))
have Hj : Q.natDegree + 1 = j + 1 + (Q.natDegree - j) := by
rw [← add_comm 1, ← add_comm 1, add_assoc, add_right_inj,
← Nat.add_sub_assoc (Nat.lt_of_succ_lt_succ (mem_range.1 hj)).le, add_comm,
Nat.add_sub_cancel]
-- By induction hypothesis we can find `g : ℕ → R` such that
-- `k ∈ range (j + 1) → Q.coeff k • B.gen ^ k = (algebraMap R L) p * g k • B.gen ^ k`-
choose! g hg using hind
replace hg : ∀ k ∈ range (j + 1), Q.coeff k • B.gen ^ k =
algebraMap R L p * g k • B.gen ^ k := by
intro k hk
rw [hg k (mem_range_succ_iff.1 hk)
(mem_range_succ_iff.2
(le_trans (mem_range_succ_iff.1 hk) (succ_le_iff.1 (mem_range_succ_iff.1 hj)).le)),
Algebra.smul_def, Algebra.smul_def, RingHom.map_mul, mul_assoc]
-- Since `minpoly R B.gen` is Eisenstein, we can find `f : ℕ → L` such that
-- `(map (algebraMap R L) (minpoly R B.gen)).nat_degree ≤ i` implies `f i ∈ adjoin R {B.gen}`
-- and `(algebraMap R L) p * f i = B.gen ^ i`. We will also need `hf₁`, a reformulation of this
-- property.
choose! f hf using
IsWeaklyEisensteinAt.exists_mem_adjoin_mul_eq_pow_natDegree_le (minpoly.aeval R B.gen)
(minpoly.monic hBint) hei.isWeaklyEisensteinAt
have hf₁ : ∀ k ∈ (range (Q.natDegree - j)).erase 0,
Q.coeff (j + 1 + k) • B.gen ^ (j + 1 + k) * B.gen ^ (P.natDegree - (j + 2)) =
(algebraMap R L) p * Q.coeff (j + 1 + k) • f (k + P.natDegree - 1) := by
intro k hk
rw [smul_mul_assoc, ← pow_add, ← Nat.add_sub_assoc H, add_comm (j + 1) 1,
add_assoc (j + 1), add_comm _ (k + P.natDegree), Nat.add_sub_add_right,
← (hf (k + P.natDegree - 1) _).2, mul_smul_comm]
rw [(minpoly.monic hBint).natDegree_map, add_comm, Nat.add_sub_assoc, le_add_iff_nonneg_right]
· exact Nat.zero_le _
· refine one_le_iff_ne_zero.2 fun h => ?_
rw [h] at hk
simp at hk
-- The Eisenstein condition shows that `p` divides `Q.coeff j`
-- if `p^n.succ` divides the following multiple of `Q.coeff (succ j)^n.succ`:
suffices
p ^ n.succ ∣ Q.coeff (succ j) ^ n.succ *
(minpoly R B.gen).coeff 0 ^ (succ j + (P.natDegree - (j + 2))) by
convert this
rw [Nat.succ_eq_add_one, add_assoc, ← Nat.add_sub_assoc H, add_comm (j + 1),
Nat.add_sub_add_left, ← Nat.add_sub_assoc, Nat.add_sub_add_left, hP, ←
(minpoly.monic hBint).natDegree_map (algebraMap R K), ←
minpoly.isIntegrallyClosed_eq_field_fractions' K hBint, natDegree_minpoly, hn, Nat.sub_one,
Nat.pred_succ]
cutsat
-- Using `hQ : aeval B.gen Q = p • z`, we write `p • z` as a sum of terms of degree less than
-- `j+1`, that are multiples of `p` by induction, and terms of degree at least `j+1`.
rw [aeval_eq_sum_range, Hj, range_add, sum_union (disjoint_range_addLeftEmbedding _ _),
sum_congr rfl hg, add_comm] at hQ
-- We multiply this equality by `B.gen ^ (P.natDegree-(j+2))`, so we can use `hf₁` on the terms
-- we didn't know were multiples of `p`, and we take the norm on both sides.
replace hQ := congr_arg (fun x => x * B.gen ^ (P.natDegree - (j + 2))) hQ
simp_rw [sum_map, addLeftEmbedding_apply, add_mul, sum_mul, mul_assoc] at hQ
rw [← insert_erase
(mem_range.2 (tsub_pos_iff_lt.2 <| Nat.lt_of_succ_lt_succ <| mem_range.1 hj)),
sum_insert (notMem_erase 0 _), add_zero, sum_congr rfl hf₁, ← mul_sum, ← mul_sum, add_assoc,
← mul_add, smul_mul_assoc, ← pow_add, Algebra.smul_def] at hQ
replace hQ := congr_arg (norm K) (eq_sub_of_add_eq hQ)
-- We obtain an equality of elements of `K`, but everything is integral, so we can move to `R`
-- and simplify `hQ`.
have hintsum : IsIntegral R (z * B.gen ^ (P.natDegree - (j + 2)) -
(∑ x ∈ (range (Q.natDegree - j)).erase 0,
Q.coeff (j + 1 + x) • f (x + P.natDegree - 1) +
∑ x ∈ range (j + 1), g x • B.gen ^ x * B.gen ^ (P.natDegree - (j + 2)))) := by
refine (hzint.mul (hBint.pow _)).sub
(.add (.sum _ fun k hk => .smul _ ?_)
(.sum _ fun k _ => .mul (.smul _ (.pow hBint _)) (hBint.pow _)))
refine adjoin_le_integralClosure hBint (hf _ ?_).1
rw [(minpoly.monic hBint).natDegree_map (algebraMap R L)]
rw [add_comm, Nat.add_sub_assoc, le_add_iff_nonneg_right]
· exact _root_.zero_le _
· refine one_le_iff_ne_zero.2 fun h => ?_
rw [h] at hk
simp at hk
obtain ⟨r, hr⟩ := isIntegral_iff.1 (isIntegral_norm K hintsum)
rw [Algebra.smul_def, mul_assoc, ← mul_sub, map_mul, algebraMap_apply R K L, map_pow,
Algebra.norm_algebraMap, map_mul, algebraMap_apply R K L, Algebra.norm_algebraMap,
finrank B, ← hr, PowerBasis.norm_gen_eq_coeff_zero_minpoly,
minpoly.isIntegrallyClosed_eq_field_fractions' K hBint, coeff_map,
show (-1 : K) = algebraMap R K (-1) by simp, ← map_pow, ← map_pow, ← map_mul, ←
map_pow, ← map_mul, ← map_pow, ← map_mul] at hQ
-- We can now finish the proof.
have hppdiv : p ^ B.dim ∣ p ^ B.dim * r := dvd_mul_of_dvd_left dvd_rfl _
rwa [← IsFractionRing.injective R K hQ, mul_comm, ← Units.coe_neg_one, mul_pow, ←
Units.val_pow_eq_pow_val, ← Units.val_pow_eq_pow_val, mul_assoc,
Units.dvd_mul_left, mul_comm, ← Nat.succ_eq_add_one, hn] at hppdiv
/-- Let `K` be the field of fraction of an integrally closed domain `R` and let `L` be an extension
of `K`, generated by an integral power basis `B` such that the minimal polynomial of `B.gen` is
Eisenstein at `p`. Given `z : L` integral over `R`, if `p ^ n • z ∈ adjoin R {B.gen}`, then
`z ∈ adjoin R {B.gen}`. Together with `Algebra.discr_mul_isIntegral_mem_adjoin` this result often
allows to compute the ring of integers of `L`. -/
theorem mem_adjoin_of_smul_prime_pow_smul_of_minpoly_isEisensteinAt {B : PowerBasis K L}
(hp : Prime p) (hBint : IsIntegral R B.gen) {n : ℕ} {z : L} (hzint : IsIntegral R z)
(hz : p ^ n • z ∈ adjoin R ({B.gen} : Set L)) (hei : (minpoly R B.gen).IsEisensteinAt 𝓟) :
z ∈ adjoin R ({B.gen} : Set L) := by
induction n with
| zero => simpa using hz
| succ n hn =>
rw [_root_.pow_succ', mul_smul] at hz
exact
hn (mem_adjoin_of_smul_prime_smul_of_minpoly_isEisensteinAt hp hBint (hzint.smul _) hz hei)
end IsIntegral |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Eisenstein/Distinguished.lean | import Mathlib.RingTheory.Polynomial.Eisenstein.Basic
import Mathlib.RingTheory.PowerSeries.Order
/-!
# Distinguished polynomial
In this file we define the predicate `Polynomial.IsDistinguishedAt`
and develop the most basic lemmas about it.
-/
open scoped Polynomial
open PowerSeries Ideal Quotient
variable {R : Type*} [CommRing R]
/--
Given an ideal `I` of a commutative ring `R`, we say that a polynomial `f : R[X]`
is *Distinguished at `I`* if `f` is monic and `IsWeaklyEisensteinAt I`.
i.e. `f` is of the form `xⁿ + a₁xⁿ⁻¹ + ⋯ + aₙ` with `aᵢ ∈ I` for all `i`.
-/
structure Polynomial.IsDistinguishedAt (f : R[X]) (I : Ideal R) : Prop
extends f.IsWeaklyEisensteinAt I where
monic : f.Monic
namespace Polynomial.IsDistinguishedAt
lemma mul {f f' : R[X]} {I : Ideal R} (hf : f.IsDistinguishedAt I) (hf' : f'.IsDistinguishedAt I) :
(f * f').IsDistinguishedAt I :=
⟨hf.toIsWeaklyEisensteinAt.mul hf'.toIsWeaklyEisensteinAt, hf.monic.mul hf'.monic⟩
lemma map_eq_X_pow {f : R[X]} {I : Ideal R} (distinguish : f.IsDistinguishedAt I) :
f.map (Ideal.Quotient.mk I) = Polynomial.X ^ f.natDegree := by
ext i
by_cases ne : i = f.natDegree
· simp [ne, distinguish.monic]
· rcases lt_or_gt_of_ne ne with lt | gt
· simpa [ne, eq_zero_iff_mem] using (distinguish.mem lt)
· simp [ne, Polynomial.coeff_eq_zero_of_natDegree_lt gt]
@[deprecated (since := "2025-04-27")]
alias _root_.IsDistinguishedAt.map_eq_X_pow := map_eq_X_pow
section degree_eq_order_map
variable {I : Ideal R} (f h : R⟦X⟧) {g : R[X]}
lemma map_ne_zero_of_eq_mul (distinguish : g.IsDistinguishedAt I)
(notMem : PowerSeries.constantCoeff h ∉ I) (eq : f = g * h) :
f.map (Ideal.Quotient.mk I) ≠ 0 := fun H ↦ by
have mapf : f.map (Ideal.Quotient.mk I) = (Polynomial.X ^ g.natDegree : (R ⧸ I)[X]) *
h.map (Ideal.Quotient.mk I) := by
simp [← map_eq_X_pow distinguish, eq]
apply_fun PowerSeries.coeff g.natDegree at H
simp [mapf, PowerSeries.coeff_X_pow_mul', eq_zero_iff_mem, notMem] at H
lemma degree_eq_coe_lift_order_map (distinguish : g.IsDistinguishedAt I)
(notMem : PowerSeries.constantCoeff h ∉ I) (eq : f = g * h) :
g.degree = (f.map (Ideal.Quotient.mk I)).order.lift
(order_finite_iff_ne_zero.2 (distinguish.map_ne_zero_of_eq_mul f h notMem eq)) := by
have : Nontrivial R := _root_.nontrivial_iff.mpr
⟨0, PowerSeries.constantCoeff h, ne_of_mem_of_not_mem I.zero_mem notMem⟩
rw [Polynomial.degree_eq_natDegree distinguish.monic.ne_zero, Nat.cast_inj, ← ENat.coe_inj,
ENat.coe_lift, Eq.comm, PowerSeries.order_eq_nat]
have mapf : f.map (Ideal.Quotient.mk I) = (Polynomial.X ^ g.natDegree : (R ⧸ I)[X]) *
h.map (Ideal.Quotient.mk I) := by
simp [← map_eq_X_pow distinguish, eq]
constructor
· simp [mapf, PowerSeries.coeff_X_pow_mul', eq_zero_iff_mem, notMem]
· intro i hi
simp [mapf, PowerSeries.coeff_X_pow_mul', hi]
@[deprecated (since := "2025-04-27")]
alias _root_.IsDistinguishedAt.degree_eq_order_map := degree_eq_coe_lift_order_map
@[deprecated (since := "2025-05-19")]
alias degree_eq_order_map := degree_eq_coe_lift_order_map
lemma coe_natDegree_eq_order_map (distinguish : g.IsDistinguishedAt I)
(notMem : PowerSeries.constantCoeff h ∉ I) (eq : f = g * h) :
g.natDegree = (f.map (Ideal.Quotient.mk I)).order := by
rw [natDegree, distinguish.degree_eq_coe_lift_order_map f h notMem eq]
exact ENat.coe_lift _ <| order_finite_iff_ne_zero.2 <|
distinguish.map_ne_zero_of_eq_mul f h notMem eq
end degree_eq_order_map
end Polynomial.IsDistinguishedAt |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Eisenstein/Generalized.lean | import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Polynomial.Content
import Mathlib.RingTheory.Ideal.Quotient.Defs
deprecated_module "Auto-generated deprecation" (since := "2025-04-11") |
.lake/packages/mathlib/Mathlib/RingTheory/Polynomial/Resultant/Basic.lean | import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
/-!
# Resultant of two polynomials
This file contains basic facts about resultant of two polynomials over commutative rings.
## Main definitions
* `Polynomial.resultant`: The resultant of two polynomials `p` and `q` is defined as the determinant
of the Sylvester matrix of `p` and `q`.
* `Polynomial.discr`: The discriminant of a polynomial `f` is defined as the resultant of `f` and
`f.derivative`, modified by factoring out a sign and a power of the leading term.
## TODO
* The eventual goal is to prove the following property:
`resultant (∏ a ∈ s, (X - C a)) f = ∏ a ∈ s, f.eval a`.
This allows us to write the `resultant f g` as the product of terms of the form `a - b` where `a`
is a root of `f` and `b` is a root of `g`.
* A smaller intermediate goal is to show that the Sylvester matrix corresponds to the linear map
that we will call the Sylvester map, which is `R[X]_n × R[X]_m →ₗ[R] R[X]_(n + m)` given by
`(p, q) ↦ f * p + g * q`, where `R[X]_n` is
`Polynomial.degreeLT` in `Mathlib.RingTheory.Polynomial.Basic`.
* Resultant of two binary forms (i.e. homogeneous polynomials in two variables), after binary forms
are implemented.
-/
open Set
namespace Polynomial
section sylvester
variable {R : Type*} [Semiring R]
/-- The Sylvester matrix of two polynomials `f` and `g` of degrees `m` and `n` respectively is a
`(n+m) × (n+m)` matrix with the coefficients of `f` and `g` arranged in a specific way. Here, `m`
and `n` are free variables, not necessarily equal to the actual degrees of the polynomials `f` and
`g`. -/
def sylvester (f g : R[X]) (m n : ℕ) : Matrix (Fin (n + m)) (Fin (n + m)) R :=
.of fun i j ↦ j.addCases
(fun j₁ ↦ if (i : ℕ) ∈ Set.Icc (j₁ : ℕ) (j₁ + m) then f.coeff (i - j₁) else 0)
(fun j₁ ↦ if (i : ℕ) ∈ Set.Icc (j₁ : ℕ) (j₁ + n) then g.coeff (i - j₁) else 0)
variable (f g : R[X]) (m n : ℕ)
@[simp] theorem sylvester_C_right (a : R) :
sylvester f (C a) m 0 = Matrix.diagonal (fun _ ↦ a) :=
Matrix.ext fun i j ↦ j.addCases nofun fun j ↦ by
rw [sylvester, Matrix.of_apply, Fin.addCases_right, Matrix.diagonal_apply]
split_ifs <;> simp_all [Fin.ext_iff]
/--
The Sylvester matrix for `f` and `f.derivative`, modified by dividing the bottom row by
the leading coefficient of `f`. Important because its determinant is (up to a sign) the
discriminant of `f`.
-/
noncomputable def
sylvesterDeriv (f : R[X]) :
Matrix (Fin (f.natDegree - 1 + f.natDegree)) (Fin (f.natDegree - 1 + f.natDegree)) R :=
letI n := f.natDegree
if hn : n = 0 then 0
else (f.sylvester f.derivative n (n - 1)).updateRow ⟨2 * n - 2, by cutsat⟩
(fun j ↦ if ↑j = n - 2 then 1 else (if ↑j = 2 * n - 2 then n else 0))
/-- We can get the usual Sylvester matrix of `f` and `f.derivative` back from the modified one
by multiplying the last row by the leading coefficient of `f`. -/
lemma sylvesterDeriv_updateRow (f : R[X]) (hf : 0 < f.natDegree) :
(sylvesterDeriv f).updateRow ⟨2 * f.natDegree - 2, by cutsat⟩
(f.leadingCoeff • (sylvesterDeriv f ⟨2 * f.natDegree - 2, by cutsat⟩)) =
(sylvester f f.derivative f.natDegree (f.natDegree - 1)) := by
by_cases hn : f.natDegree = 0
· ext ⟨i, hi⟩; cutsat
ext ⟨i, hi⟩ ⟨j, hj⟩
rw [sylvesterDeriv, dif_neg hn]
rcases ne_or_eq i (2 * f.natDegree - 2) with hi' | rfl
· -- Top part of matrix
rw [Matrix.updateRow_ne (Fin.ne_of_val_ne hi'),
Matrix.updateRow_ne (Fin.ne_of_val_ne hi')]
· -- Bottom row
simp only [sylvester, Fin.addCases, mem_Icc, coeff_derivative, eq_rec_constant, leadingCoeff,
Matrix.updateRow_self, Matrix.updateRow_apply, ↓reduceIte, Pi.smul_apply, smul_eq_mul,
mul_ite, mul_one, mul_zero, Matrix.of_apply, Fin.castLT_mk, tsub_le_iff_right, Fin.cast_mk,
Fin.subNat_mk, dite_eq_ite]
split_ifs
on_goal 2 => rw [show f.natDegree = 1 by cutsat]
on_goal 3 =>
rw [← Nat.cast_one (R := R), ← Nat.cast_add, show f.natDegree = 1 by cutsat]
norm_num
on_goal 6 =>
rw [← Nat.cast_one (R := R), ← Nat.cast_add]
#adaptation_note
/--
Prior to nightly-2025-09-09,
these two steps were not needed (i.e. `grind` just finished from here)
-/
have : 2 * f.natDegree - 2 - (j - (f.natDegree - 1)) + 1 = f.natDegree := by grind
simp [this]
all_goals grind
end sylvester
section resultant
variable {R : Type*} [CommRing R]
/-- The resultant of two polynomials `f` and `g` is the determinant of the Sylvester matrix of `f`
and `g`. The size arguments `m` and `n` are implemented as `optParam`, meaning that the default
values are `f.natDegree` and `g.natDegree` respectively, but they can also be specified to be
other values. -/
def resultant (f g : R[X]) (m : ℕ := f.natDegree) (n : ℕ := g.natDegree) : R :=
(sylvester f g m n).det
variable (f g : R[X]) (m n : ℕ)
/-- For polynomial `f` and constant `a`, `Res(f, a) = a ^ m`. -/
@[simp]
theorem resultant_C_zero_right (a : R) : resultant f (C a) m 0 = a ^ m := by simp [resultant]
/-- For polynomial `f` and constant `a`, `Res(f, a) = a ^ m`. -/
theorem resultant_C_right (a : R) : resultant f (C a) m = a ^ m := by simp
end resultant
section disc
variable {R : Type*} [CommRing R]
/-- The discriminant of a polynomial, defined as the determinant of `f.sylvesterDeriv` modified
by a sign. The sign is chosen so polynomials over `ℝ` with all roots real have non-negative
discriminant. -/
noncomputable def discr (f : R[X]) : R :=
f.sylvesterDeriv.det * (-1) ^ (f.natDegree * (f.natDegree - 1) / 2)
@[deprecated (since := "2025-10-20")] alias disc := discr
/-- The discriminant of a constant polynomial is `1`. -/
@[simp] lemma discr_C (r : R) : discr (C r) = 1 := by
let e : Fin ((C r).natDegree - 1 + (C r).natDegree) ≃ Fin 0 := finCongr (by simp)
simp [discr, ← Matrix.det_reindex_self e]
/-- The discriminant of a linear polynomial is `1`. -/
lemma discr_of_degree_eq_one {f : R[X]} (hf : f.degree = 1) : discr f = 1 := by
rw [← Nat.cast_one, degree_eq_iff_natDegree_eq_of_pos one_pos] at hf
let e : Fin (f.natDegree - 1 + f.natDegree) ≃ Fin 1 := finCongr (by cutsat)
have : f.sylvesterDeriv.reindex e e = !![1] := by
have : NeZero (f.natDegree - 1 + f.natDegree) := ⟨by cutsat⟩
ext ⟨i, hi⟩ ⟨j, hj⟩
obtain ⟨rfl⟩ : i = 0 := by cutsat
obtain ⟨rfl⟩ : j = 0 := by cutsat
simp [e, sylvesterDeriv, mul_comm, hf]
simp [discr, ← Matrix.det_reindex_self e, this, hf]
/-- Standard formula for the discriminant of a quadratic polynomial. -/
lemma discr_of_degree_eq_two {f : R[X]} (hf : f.degree = 2) :
discr f = f.coeff 1 ^ 2 - 4 * f.coeff 0 * f.coeff 2 := by
rw [← Nat.cast_two, degree_eq_iff_natDegree_eq_of_pos two_pos] at hf
let e : Fin (f.natDegree - 1 + f.natDegree) ≃ Fin 3 := finCongr (by cutsat)
rw [discr, ← Matrix.det_reindex_self e]
have : f.sylvesterDeriv.reindex e e =
!![f.coeff 0, f.coeff 1, 0;
f.coeff 1, 2 * f.coeff 2, f.coeff 1;
1, 0, 2] := by
ext i j
fin_cases i <;> fin_cases j <;>
simp [e, sylvesterDeriv, sylvester, coeff_derivative, mul_comm, Fin.addCases,
one_add_one_eq_two, hf, Fin.cast]
simp only [this, Matrix.det_fin_three, Matrix.of_apply, Matrix.cons_val', Matrix.cons_val_zero,
Matrix.cons_val_fin_one, Matrix.cons_val_one, Matrix.cons_val, hf]
ring_nf
@[deprecated (since := "2025-10-20")] alias disc_C := discr_C
@[deprecated (since := "2025-10-20")] alias disc_of_degree_eq_one := discr_of_degree_eq_one
@[deprecated (since := "2025-10-20")] alias disc_of_degree_eq_two := discr_of_degree_eq_two
/-- Relation between the resultant and the discriminant.
(Note this is actually false when `f` is a constant polynomial not equal to 1, so the assumption on
the degree is genuinely needed.) -/
lemma resultant_deriv {f : R[X]} (hf : 0 < f.degree) :
resultant f f.derivative f.natDegree (f.natDegree - 1) =
(-1) ^ (f.natDegree * (f.natDegree - 1) / 2) * f.leadingCoeff * f.discr := by
rw [← natDegree_pos_iff_degree_pos] at hf
rw [resultant, ← sylvesterDeriv_updateRow f hf, Matrix.det_updateRow_smul,
Matrix.updateRow_eq_self, discr]
suffices ∀ (r s : R), s * r = s * r * (-1) ^ (f.natDegree * (f.natDegree - 1) / 2 * 2) by
ring_nf
apply this
simp only [mul_comm _ 2, pow_mul, neg_one_sq, one_pow, mul_one, implies_true]
private lemma sylvesterDeriv_of_natDegree_eq_three {f : R[X]} (hf : f.natDegree = 3) :
f.sylvesterDeriv.reindex (finCongr <| by rw [hf]) (finCongr <| by rw [hf]) =
!![ f.coeff 0, 0, 1 * f.coeff 1, 0, 0;
f.coeff 1, f.coeff 0, 2 * f.coeff 2, 1 * f.coeff 1, 0;
f.coeff 2, f.coeff 1, 3 * f.coeff 3, 2 * f.coeff 2, 1 * f.coeff 1;
f.coeff 3, f.coeff 2, 0, 3 * f.coeff 3, 2 * f.coeff 2;
0, 1, 0, 0, 3] := by
ext ⟨i, hi⟩ ⟨j, hj⟩
-- In this proof we do as much as possible of the `simp` work before drilling down into the
-- `fin_cases` constructs. This means the simps are not terminal, so they are not squeezed;
-- but the proof runs much faster this way.
simp only [sylvesterDeriv, hf, OfNat.ofNat_ne_zero, ↓reduceDIte, sylvester, Fin.addCases,
Nat.add_one_sub_one, Fin.coe_castLT, mem_Icc, Fin.val_fin_le, Fin.coe_subNat, Fin.coe_cast,
tsub_le_iff_right, coeff_derivative, eq_rec_constant, dite_eq_ite, Nat.reduceMul, Nat.reduceSub,
Nat.cast_ofNat, Matrix.reindex_apply, finCongr_symm, Matrix.submatrix_apply, finCongr_apply,
Fin.cast_mk, Matrix.updateRow_apply, Fin.mk.injEq, Matrix.of_apply, Fin.mk_le_mk, one_mul,
Matrix.cons_val', Matrix.cons_val_fin_one]
have hi' : i ∈ Finset.range 5 := Finset.mem_range.mpr hi
have hj' : j ∈ Finset.range 5 := Finset.mem_range.mpr hj
fin_cases hi' <;>
· simp only [and_true, Fin.isValue, Fin.mk_one, Fin.reduceFinMk, Fin.zero_eta,
le_add_iff_nonneg_left, Matrix.cons_val_one, Matrix.cons_val_zero, Matrix.cons_val,
mul_one, Nat.cast_zero, Nat.reduceAdd, Nat.reduceEqDiff, Nat.reduceLeDiff, nonpos_iff_eq_zero,
OfNat.one_ne_ofNat, OfNat.zero_ne_ofNat, ↓reduceIte, zero_add, zero_le, zero_tsub]
fin_cases hj' <;> simp [mul_comm, one_add_one_eq_two, (by norm_num : (2 : R) + 1 = 3)]
/-- Standard formula for the discriminant of a cubic polynomial. -/
lemma discr_of_degree_eq_three {f : R[X]} (hf : f.degree = 3) :
discr f = f.coeff 2 ^ 2 * f.coeff 1 ^ 2
- 4 * f.coeff 3 * f.coeff 1 ^ 3
- 4 * f.coeff 2 ^ 3 * f.coeff 0
- 27 * f.coeff 3 ^ 2 * f.coeff 0 ^ 2
+ 18 * f.coeff 3 * f.coeff 2 * f.coeff 1 * f.coeff 0 := by
apply natDegree_eq_of_degree_eq_some at hf
let e : Fin ((f.natDegree - 1) + f.natDegree) ≃ Fin 5 := finCongr (by rw [hf])
rw [discr, ← Matrix.det_reindex_self e, sylvesterDeriv_of_natDegree_eq_three hf]
simp [Matrix.det_succ_row_zero (n := 4), Matrix.det_succ_row_zero (n := 3), Fin.succAbove,
Matrix.det_fin_three, Finset.sum_fin_eq_sum_range, Finset.sum_range_succ, hf]
ring_nf
@[deprecated (since := "2025-10-20")] alias disc_of_degree_eq_three := discr_of_degree_eq_three
end disc
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraicIndependent/RankAndCardinality.lean | import Mathlib.FieldTheory.IntermediateField.Adjoin.Basic
import Mathlib.FieldTheory.MvRatFunc.Rank
import Mathlib.RingTheory.Algebraic.Cardinality
import Mathlib.RingTheory.AlgebraicIndependent.Adjoin
import Mathlib.RingTheory.AlgebraicIndependent.Transcendental
import Mathlib.RingTheory.AlgebraicIndependent.TranscendenceBasis
/-!
# Cardinality of a transcendence basis
This file concerns the cardinality of a transcendence basis.
## References
* [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D)
## TODO
Define the transcendence degree and show it is independent of the choice of a
transcendence basis.
## Tags
transcendence basis, transcendence degree, transcendence
-/
noncomputable section
open Function Set Subalgebra MvPolynomial Algebra
universe u v w
open AlgebraicIndependent
open Cardinal
theorem IsTranscendenceBasis.lift_cardinalMk_eq_max_lift
{F : Type u} {E : Type v} [CommRing F] [Nontrivial F] [CommRing E] [IsDomain E] [Algebra F E]
{ι : Type w} {x : ι → E} [Nonempty ι] (hx : IsTranscendenceBasis F x) :
lift.{max u w} #E = lift.{max v w} #F ⊔ lift.{max u v} #ι ⊔ ℵ₀ := by
let K := Algebra.adjoin F (Set.range x)
suffices #E = #K by simp [K, this, ← lift_mk_eq'.2 ⟨hx.1.aevalEquiv.toEquiv⟩]
haveI : Algebra.IsAlgebraic K E := hx.isAlgebraic
refine le_antisymm ?_ (mk_le_of_injective Subtype.val_injective)
haveI : Infinite K := hx.1.aevalEquiv.infinite_iff.1 inferInstance
simpa only [sup_eq_left.2 (aleph0_le_mk K)] using Algebra.IsAlgebraic.cardinalMk_le_max K E
theorem IsTranscendenceBasis.lift_rank_eq_max_lift
{F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E]
{ι : Type w} {x : ι → E} [Nonempty ι] (hx : IsTranscendenceBasis F x) :
lift.{max u w} (Module.rank F E) = lift.{max v w} #F ⊔ lift.{max u v} #ι ⊔ ℵ₀ := by
let K := IntermediateField.adjoin F (Set.range x)
haveI : Algebra.IsAlgebraic K E := hx.isAlgebraic_field
rw [← rank_mul_rank F K E, lift_mul, ← hx.1.aevalEquivField.toLinearEquiv.lift_rank_eq,
MvRatFunc.rank_eq_max_lift, lift_max, lift_max, lift_lift, lift_lift, lift_aleph0]
refine mul_eq_left le_sup_right ((lift_le.2 ((rank_le_card K E).trans
(Algebra.IsAlgebraic.cardinalMk_le_max K E))).trans_eq ?_) (by simp [rank_pos.ne'])
simp [K, ← lift_mk_eq'.2 ⟨hx.1.aevalEquivField.toEquiv⟩]
theorem Algebra.Transcendental.rank_eq_cardinalMk
(F : Type u) (E : Type v) [Field F] [Field E] [Algebra F E] [Algebra.Transcendental F E] :
Module.rank F E = #E := by
obtain ⟨ι, x, hx⟩ := exists_isTranscendenceBasis' F E
haveI := hx.nonempty_iff_transcendental.2 ‹_›
simpa [← hx.lift_cardinalMk_eq_max_lift] using hx.lift_rank_eq_max_lift
theorem IntermediateField.rank_sup_le
{F : Type u} {E : Type v} [Field F] [Field E] [Algebra F E] (A B : IntermediateField F E) :
Module.rank F ↥(A ⊔ B) ≤ Module.rank F A * Module.rank F B := by
by_cases hA : Algebra.IsAlgebraic F A
· exact rank_sup_le_of_isAlgebraic A B (Or.inl hA)
by_cases hB : Algebra.IsAlgebraic F B
· exact rank_sup_le_of_isAlgebraic A B (Or.inr hB)
rw [← Algebra.transcendental_iff_not_isAlgebraic] at hA hB
haveI : Algebra.Transcendental F ↥(A ⊔ B) := .ringHom_of_comp_eq (RingHom.id F)
(inclusion le_sup_left) Function.surjective_id (inclusion_injective _) rfl
haveI := Algebra.Transcendental.infinite F A
haveI := Algebra.Transcendental.infinite F B
simp_rw [Algebra.Transcendental.rank_eq_cardinalMk]
rw [sup_def, mul_mk_eq_max, ← Cardinal.lift_le.{u}]
refine (lift_cardinalMk_adjoin_le _ _).trans ?_
calc
_ ≤ Cardinal.lift.{v} #F ⊔ Cardinal.lift.{u} (#A ⊔ #B) ⊔ ℵ₀ := by
gcongr
rw [Cardinal.lift_le]
exact (mk_union_le _ _).trans_eq (by simp)
_ = _ := by
simp [lift_mk_le_lift_mk_of_injective (algebraMap F A).injective] |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraicIndependent/AlgebraicClosure.lean | import Mathlib.FieldTheory.AlgebraicClosure
import Mathlib.RingTheory.Algebraic.Integral
import Mathlib.RingTheory.AlgebraicIndependent.Transcendental
/-!
# Algebraic independence persists to the algebraic closure
## Main results
* `AlgebraicIndependent.extendScalars`: if A/S/R is a tower of algebras with S/R algebraic,
then a family of elements in A that are algebraically independent over R remains algebraically
independent over S, provided that S has no zero divisors.
* `AlgebraicIndependent.algebraicClosure`: an algebraically independent family remains
algebraically independent over the algebraic closure.
-/
open Function Algebra
section
variable {ι R S A : Type*} {x : ι → A} (S)
variable [CommRing R] [CommRing S] [CommRing A]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
variable [NoZeroDivisors S] (hx : AlgebraicIndependent R x)
include hx
namespace AlgebraicIndependent
theorem extendScalars [alg : Algebra.IsAlgebraic R S] : AlgebraicIndependent S x := by
refine algebraicIndependent_of_finite_type'
(Algebra.IsAlgebraic.injective_tower_top S hx.algebraMap_injective) fun t fin ind i hi ↦ ?_
let Rt := adjoin R (x '' t)
let St := adjoin S (x '' t)
let _ : Algebra Rt St :=
(Rt.inclusion (T := St.restrictScalars R) <| adjoin_le <| by exact subset_adjoin).toAlgebra
have : IsScalarTower Rt St A := .of_algebraMap_eq fun ⟨y, _⟩ ↦ show y = y from rfl
have : NoZeroDivisors St := (Set.image_eq_range _ _ ▸ ind.aevalEquiv)
|>.symm.injective.noZeroDivisors _ (map_zero _) (map_mul _)
have : NoZeroDivisors Rt := (Subalgebra.inclusion_injective _).noZeroDivisors
(algebraMap Rt St) (map_zero _) (map_mul _)
have : Algebra.IsAlgebraic Rt St := ⟨fun ⟨y, hy⟩ ↦ by
rw [← isAlgebraic_algHom_iff (IsScalarTower.toAlgHom Rt St A) Subtype.val_injective]
change IsAlgebraic Rt y
have := Algebra.IsAlgebraic.nontrivial R S
have := hx.algebraMap_injective.nontrivial
exact adjoin_induction (fun _ h ↦ isAlgebraic_algebraMap (⟨_, subset_adjoin h⟩ : Rt))
(fun z ↦ ((alg.1 z).algHom (IsScalarTower.toAlgHom R S A)).extendScalars fun _ _ eq ↦ by
exact hx.algebraMap_injective congr($eq.1)) (fun _ _ _ _ ↦ .add) (fun _ _ _ _ ↦ .mul) hy⟩
change Transcendental St (x i)
exact (hx.transcendental_adjoin hi).extendScalars _
theorem extendScalars_of_isIntegral [Algebra.IsIntegral R S] : AlgebraicIndependent S x := by
nontriviality S
have := Module.nontrivial R S
exact hx.extendScalars S
theorem subalgebraAlgebraicClosure [IsDomain R] [NoZeroDivisors A] :
AlgebraicIndependent (Subalgebra.algebraicClosure R A) x :=
hx.extendScalars _
protected theorem integralClosure [NoZeroDivisors A] :
AlgebraicIndependent (integralClosure R A) x :=
hx.extendScalars_of_isIntegral _
omit hx in
protected theorem algebraicClosure {F E : Type*} [Field F] [Field E] [Algebra F E] {x : ι → E}
(hx : AlgebraicIndependent F x) : AlgebraicIndependent (algebraicClosure F E) x :=
hx.extendScalars _
end AlgebraicIndependent
namespace Algebra
variable (R) [FaithfulSMul R S]
omit hx
protected theorem IsIntegral.algebraicIndependent_iff [Algebra.IsIntegral R S] :
AlgebraicIndependent R x ↔ AlgebraicIndependent S x :=
⟨(·.extendScalars_of_isIntegral _),
(·.restrictScalars (FaithfulSMul.algebraMap_injective R S))⟩
protected theorem IsIntegral.isTranscendenceBasis_iff [Algebra.IsIntegral R S] :
IsTranscendenceBasis R x ↔ IsTranscendenceBasis S x := by
simp_rw [IsTranscendenceBasis, IsIntegral.algebraicIndependent_iff R S]
protected theorem IsAlgebraic.algebraicIndependent_iff [Algebra.IsAlgebraic R S] :
AlgebraicIndependent R x ↔ AlgebraicIndependent S x :=
⟨(·.extendScalars _), (·.restrictScalars (FaithfulSMul.algebraMap_injective R S))⟩
protected theorem IsAlgebraic.isTranscendenceBasis_iff [Algebra.IsAlgebraic R S] :
IsTranscendenceBasis R x ↔ IsTranscendenceBasis S x := by
simp_rw [IsTranscendenceBasis, IsAlgebraic.algebraicIndependent_iff R S]
end Algebra
end
namespace IntermediateField
variable {ι F E R S : Type*} {s : Set E}
variable [Field F] [Field E] [Algebra F E]
variable [CommRing R] [Algebra R F] [Algebra R E] [IsScalarTower R F E]
open scoped algebraAdjoinAdjoin
section Ring
variable [Ring S] [Algebra E S]
theorem isAlgebraic_adjoin_iff {x : S} :
IsAlgebraic (adjoin F s) x ↔ IsAlgebraic (Algebra.adjoin F s) x :=
(IsAlgebraic.isAlgebraic_iff ..).symm
theorem isAlgebraic_adjoin_iff_top :
Algebra.IsAlgebraic (adjoin F s) S ↔ Algebra.IsAlgebraic (Algebra.adjoin F s) S :=
(IsAlgebraic.isAlgebraic_iff_top ..).symm
theorem isAlgebraic_adjoin_iff_bot :
Algebra.IsAlgebraic R (adjoin F s) ↔ Algebra.IsAlgebraic R (Algebra.adjoin F s) :=
IsAlgebraic.isAlgebraic_iff_bot ..
theorem transcendental_adjoin_iff {x : S} :
Transcendental (adjoin F s) x ↔ Transcendental (Algebra.adjoin F s) x :=
(IsAlgebraic.transcendental_iff ..).symm
end Ring
variable [CommRing S] [Algebra E S]
theorem algebraicIndependent_adjoin_iff {x : ι → S} :
AlgebraicIndependent (adjoin F s) x ↔ AlgebraicIndependent (Algebra.adjoin F s) x :=
(Algebra.IsAlgebraic.algebraicIndependent_iff ..).symm
theorem isTranscendenceBasis_adjoin_iff {x : ι → S} :
IsTranscendenceBasis (adjoin F s) x ↔ IsTranscendenceBasis (Algebra.adjoin F s) x :=
(Algebra.IsAlgebraic.isTranscendenceBasis_iff ..).symm
end IntermediateField |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraicIndependent/Basic.lean | import Mathlib.Algebra.Algebra.Subalgebra.Tower
import Mathlib.Algebra.MvPolynomial.Equiv
import Mathlib.Algebra.MvPolynomial.Monad
import Mathlib.Algebra.MvPolynomial.Supported
import Mathlib.RingTheory.AlgebraicIndependent.Defs
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.MvPolynomial.Basic
/-!
# Algebraic Independence
This file contains basic results on algebraic independence of a family of elements of an `R`-algebra
## References
* [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D)
## Tags
transcendence basis, transcendence degree, transcendence
-/
noncomputable section
open Function Set Subalgebra MvPolynomial Algebra
universe u v v'
variable {ι : Type u} {ι' R : Type*} {A : Type v} {A' : Type v'} {x : ι → A}
variable [CommRing R] [CommRing A] [CommRing A'] [Algebra R A] [Algebra R A']
variable (R A) in
/-- The transcendence degree of a commutative algebra `A` over a commutative ring `R` is
defined to be the maximal cardinality of an `R`-algebraically independent set in `A`. -/
@[stacks 030G] def Algebra.trdeg : Cardinal.{v} :=
⨆ ι : { s : Set A // AlgebraicIndepOn R _root_.id s }, Cardinal.mk ι.1
theorem algebraicIndependent_iff_ker_eq_bot :
AlgebraicIndependent R x ↔
RingHom.ker (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A).toRingHom = ⊥ :=
RingHom.injective_iff_ker_eq_bot _
@[simp]
theorem algebraicIndependent_empty_type_iff [IsEmpty ι] :
AlgebraicIndependent R x ↔ Injective (algebraMap R A) := by
rw [algebraicIndependent_iff_injective_aeval, MvPolynomial.aeval_injective_iff_of_isEmpty]
instance [FaithfulSMul R A] : Nonempty { s : Set A // AlgebraicIndepOn R id s } :=
⟨∅, algebraicIndependent_empty_type_iff.mpr <| FaithfulSMul.algebraMap_injective R A⟩
namespace AlgebraicIndependent
variable (hx : AlgebraicIndependent R x)
include hx
theorem algebraMap_injective : Injective (algebraMap R A) := by
simpa [Function.comp_def] using
(Injective.of_comp_iff (algebraicIndependent_iff_injective_aeval.1 hx) MvPolynomial.C).2
(MvPolynomial.C_injective _ _)
theorem linearIndependent : LinearIndependent R x := by
rw [linearIndependent_iff_injective_finsuppLinearCombination]
have : Finsupp.linearCombination R x =
(MvPolynomial.aeval x).toLinearMap.comp (Finsupp.linearCombination R X) := by
ext
simp
rw [this]
refine (algebraicIndependent_iff_injective_aeval.mp hx).comp ?_
rw [← linearIndependent_iff_injective_finsuppLinearCombination]
exact linearIndependent_X _ _
protected theorem injective [Nontrivial R] : Injective x :=
hx.linearIndependent.injective
theorem ne_zero [Nontrivial R] (i : ι) : x i ≠ 0 :=
hx.linearIndependent.ne_zero i
theorem map {f : A →ₐ[R] A'} (hf_inj : Set.InjOn f (adjoin R (range x))) :
AlgebraicIndependent R (f ∘ x) := by
have : aeval (f ∘ x) = f.comp (aeval x) := by ext; simp
have h : ∀ p : MvPolynomial ι R, aeval x p ∈ (@aeval R _ _ _ _ _ ((↑) : range x → A)).range := by
intro p
rw [AlgHom.mem_range]
refine ⟨MvPolynomial.rename (codRestrict x (range x) mem_range_self) p, ?_⟩
simp [Function.comp_def, aeval_rename]
intro x y hxy
rw [this] at hxy
rw [adjoin_eq_range] at hf_inj
exact hx (hf_inj (h x) (h y) hxy)
theorem map' {f : A →ₐ[R] A'} (hf_inj : Injective f) : AlgebraicIndependent R (f ∘ x) :=
hx.map hf_inj.injOn
/-- If `x = {x_i : A | i : ι}` and `f = {f_i : MvPolynomial ι R | i : ι}` are algebraically
independent over `R`, then `{f_i(x) | i : ι}` is also algebraically independent over `R`.
For the partial converse, see `AlgebraicIndependent.of_aeval`. -/
theorem aeval_of_algebraicIndependent
{f : ι → MvPolynomial ι R} (hf : AlgebraicIndependent R f) :
AlgebraicIndependent R fun i ↦ aeval x (f i) := by
rw [algebraicIndependent_iff] at hx hf ⊢
intro p hp
exact hf _ (hx _ (by rwa [← aeval_comp_bind₁, AlgHom.comp_apply] at hp))
omit hx in
/-- If `{f_i(x) | i : ι}` is algebraically independent over `R`, then
`{f_i : MvPolynomial ι R | i : ι}` is also algebraically independent over `R`.
In fact, the `x = {x_i : A | i : ι}` is also transcendental over `R` provided that `R`
is a field and `ι` is finite; the proof needs transcendence degree. -/
theorem of_aeval {f : ι → MvPolynomial ι R}
(H : AlgebraicIndependent R fun i ↦ aeval x (f i)) :
AlgebraicIndependent R f := by
rw [algebraicIndependent_iff] at H ⊢
intro p hp
exact H p (by rw [← aeval_comp_bind₁, AlgHom.comp_apply, bind₁, hp, map_zero])
end AlgebraicIndependent
theorem isEmpty_algebraicIndependent (h : ¬ Injective (algebraMap R A)) :
IsEmpty { s : Set A // AlgebraicIndepOn R id s } where
false s := h s.2.algebraMap_injective
theorem trdeg_eq_zero_of_not_injective (h : ¬ Injective (algebraMap R A)) : trdeg R A = 0 := by
have := isEmpty_algebraicIndependent h
rw [trdeg, ciSup_of_empty, bot_eq_zero]
theorem MvPolynomial.algebraicIndependent_X (σ R : Type*) [CommRing R] :
AlgebraicIndependent R (X (R := R) (σ := σ)) := by
rw [AlgebraicIndependent, aeval_X_left]
exact injective_id
open AlgebraicIndependent
theorem AlgHom.algebraicIndependent_iff (f : A →ₐ[R] A') (hf : Injective f) :
AlgebraicIndependent R (f ∘ x) ↔ AlgebraicIndependent R x :=
⟨fun h => h.of_comp f, fun h => h.map hf.injOn⟩
@[nontriviality]
theorem AlgebraicIndependent.of_subsingleton [Subsingleton R] : AlgebraicIndependent R x :=
algebraicIndependent_iff.2 fun _ _ => Subsingleton.elim _ _
theorem isTranscendenceBasis_iff_of_subsingleton [Subsingleton R] (x : ι → A) :
IsTranscendenceBasis R x ↔ Nonempty ι := by
have := Module.subsingleton R A
refine ⟨fun h ↦ ?_, fun h ↦ ⟨.of_subsingleton, fun s hs hx ↦
hx.antisymm fun a _ ↦ ⟨Classical.arbitrary _, Subsingleton.elim ..⟩⟩⟩
by_contra! hι
have := h.2 {0} .of_subsingleton
simp [range_eq_empty, eq_comm (a := ∅)] at this
@[nontriviality] theorem IsTranscendenceBasis.of_subsingleton [Subsingleton R] [Nonempty ι] :
IsTranscendenceBasis R x :=
(isTranscendenceBasis_iff_of_subsingleton x).mpr ‹_›
@[nontriviality] theorem trdeg_subsingleton [Subsingleton R] : trdeg R A = 1 :=
have := Module.subsingleton R A
(ciSup_le' fun s ↦ by simpa using Set.subsingleton_of_subsingleton).antisymm <| le_ciSup_of_le
(Cardinal.bddAbove_range _) ⟨{0}, .of_subsingleton⟩ (by simp)
theorem algebraicIndependent_adjoin (hs : AlgebraicIndependent R x) :
@AlgebraicIndependent ι R (adjoin R (range x))
(fun i : ι => ⟨x i, subset_adjoin (mem_range_self i)⟩) _ _ _ :=
AlgebraicIndependent.of_comp (adjoin R (range x)).val hs
/-- A set of algebraically independent elements in an algebra `A` over a ring `K` is also
algebraically independent over a subring `R` of `K`. -/
theorem AlgebraicIndependent.restrictScalars {K : Type*} [CommRing K] [Algebra R K] [Algebra K A]
[IsScalarTower R K A] (hinj : Function.Injective (algebraMap R K))
(ai : AlgebraicIndependent K x) : AlgebraicIndependent R x := by
have : (aeval x : MvPolynomial ι K →ₐ[K] A).toRingHom.comp (MvPolynomial.map (algebraMap R K)) =
(aeval x : MvPolynomial ι R →ₐ[R] A).toRingHom := by
ext <;> simp [algebraMap_eq_smul_one]
change Injective (aeval x).toRingHom
rw [← this, RingHom.coe_comp]
exact Injective.comp ai (MvPolynomial.map_injective _ hinj)
section RingHom
variable {S B FRS FAB : Type*} [CommRing S] [CommRing B] [Algebra S B]
section
variable [FunLike FRS R S] [RingHomClass FRS R S] [FunLike FAB A B] [RingHomClass FAB A B]
(f : FRS) (g : FAB)
theorem AlgebraicIndependent.of_ringHom_of_comp_eq (H : AlgebraicIndependent S (g ∘ x))
(hf : Function.Injective f)
(h : RingHom.comp (algebraMap S B) f = RingHom.comp g (algebraMap R A)) :
AlgebraicIndependent R x := by
rw [algebraicIndependent_iff] at H ⊢
intro p hp
have := H (p.map f) <| by
have : (g : A →+* B) _ = _ := congr(g $hp)
rwa [map_zero, map_aeval, ← h, ← eval₂Hom_map_hom, ← aeval_eq_eval₂Hom] at this
exact map_injective (f : R →+* S) hf (by rwa [map_zero])
theorem AlgebraicIndependent.ringHom_of_comp_eq (H : AlgebraicIndependent R x)
(hf : Function.Surjective f) (hg : Function.Injective g)
(h : RingHom.comp (algebraMap S B) f = RingHom.comp g (algebraMap R A)) :
AlgebraicIndependent S (g ∘ x) := by
rw [algebraicIndependent_iff] at H ⊢
intro p hp
obtain ⟨q, rfl⟩ := map_surjective (f : R →+* S) hf p
rw [H q (hg (by rwa [map_zero, ← RingHom.coe_coe g, map_aeval, ← h, ← eval₂Hom_map_hom,
← aeval_eq_eval₂Hom])), map_zero]
end
section
variable [EquivLike FRS R S] [RingEquivClass FRS R S] [FunLike FAB A B] [RingHomClass FAB A B]
(f : FRS) (g : FAB)
theorem algebraicIndependent_ringHom_iff_of_comp_eq
(hg : Function.Injective g)
(h : RingHom.comp (algebraMap S B) f = RingHom.comp g (algebraMap R A)) :
AlgebraicIndependent S (g ∘ x) ↔ AlgebraicIndependent R x :=
⟨fun H ↦ H.of_ringHom_of_comp_eq f g (EquivLike.injective f) h,
fun H ↦ H.ringHom_of_comp_eq f g (EquivLike.surjective f) hg h⟩
end
end RingHom
/-- Every finite subset of an algebraically independent set is algebraically independent. -/
theorem algebraicIndependent_finset_map_embedding_subtype (s : Set A)
(li : AlgebraicIndependent R ((↑) : s → A)) (t : Finset s) :
AlgebraicIndependent R ((↑) : Finset.map (Embedding.subtype s) t → A) := by
let f : t.map (Embedding.subtype s) → s := fun x =>
⟨x.1, by
obtain ⟨x, h⟩ := x
rw [Finset.mem_map] at h
obtain ⟨a, _, rfl⟩ := h
simp only [Subtype.coe_prop, Embedding.coe_subtype]⟩
convert AlgebraicIndependent.comp li f _
rintro ⟨x, hx⟩ ⟨y, hy⟩
rw [Finset.mem_map] at hx hy
obtain ⟨a, _, rfl⟩ := hx
obtain ⟨b, _, rfl⟩ := hy
simp only [f, imp_self, Subtype.mk_eq_mk]
/-- If every finite set of algebraically independent element has cardinality at most `n`,
then the same is true for arbitrary sets of algebraically independent elements. -/
theorem algebraicIndependent_bounded_of_finset_algebraicIndependent_bounded {n : ℕ}
(H : ∀ s : Finset A, (AlgebraicIndependent R fun i : s => (i : A)) → s.card ≤ n) :
∀ s : Set A, AlgebraicIndependent R ((↑) : s → A) → Cardinal.mk s ≤ n := by
intro s li
apply Cardinal.card_le_of
intro t
rw [← Finset.card_map (Embedding.subtype s)]
apply H
apply algebraicIndependent_finset_map_embedding_subtype _ li
section Subtype
theorem AlgebraicIndependent.restrict_of_comp_subtype {s : Set ι}
(hs : AlgebraicIndependent R (x ∘ (↑) : s → A)) : AlgebraicIndependent R (s.restrict x) :=
hs
variable (R A)
theorem algebraicIndependent_empty_iff :
AlgebraicIndependent R ((↑) : (∅ : Set A) → A) ↔ Injective (algebraMap R A) := by simp
end Subtype
theorem AlgebraicIndependent.to_subtype_range (hx : AlgebraicIndependent R x) :
AlgebraicIndependent R ((↑) : range x → A) := by
nontriviality R
rwa [algebraicIndependent_subtype_range hx.injective]
theorem AlgebraicIndependent.to_subtype_range' (hx : AlgebraicIndependent R x) {t}
(ht : range x = t) : AlgebraicIndependent R ((↑) : t → A) :=
ht ▸ hx.to_subtype_range
theorem IsTranscendenceBasis.to_subtype_range (hx : IsTranscendenceBasis R x) :
IsTranscendenceBasis R ((↑) : range x → A) := by
cases subsingleton_or_nontrivial R
· rw [isTranscendenceBasis_iff_of_subsingleton] at hx ⊢; infer_instance
· rwa [isTranscendenceBasis_subtype_range hx.1.injective]
theorem IsTranscendenceBasis.to_subtype_range' (hx : IsTranscendenceBasis R x) {t}
(ht : range x = t) : IsTranscendenceBasis R ((↑) : t → A) :=
ht ▸ hx.to_subtype_range
lemma IsTranscendenceBasis.of_comp {x : ι → A} (f : A →ₐ[R] A') (h : Function.Injective f)
(H : IsTranscendenceBasis R (f ∘ x)) :
IsTranscendenceBasis R x := by
refine ⟨(AlgHom.algebraicIndependent_iff f h).mp H.1, ?_⟩
intro s hs hs'
have := H.2 (f '' s)
((algebraicIndependent_image h.injOn).mp ((AlgHom.algebraicIndependent_iff f h).mpr hs))
(by rw [Set.range_comp]; exact Set.image_mono hs')
rwa [Set.range_comp, (Set.image_injective.mpr h).eq_iff] at this
lemma IsTranscendenceBasis.of_comp_algebraMap [Algebra A A'] [IsScalarTower R A A']
[FaithfulSMul A A'] {x : ι → A} (H : IsTranscendenceBasis R (algebraMap A A' ∘ x)) :
IsTranscendenceBasis R x :=
.of_comp (IsScalarTower.toAlgHom R A A') (FaithfulSMul.algebraMap_injective A A') H
/-- Also see `IsTranscendenceBasis.algebraMap_comp`
for the composition with a algebraic extension. -/
theorem AlgEquiv.isTranscendenceBasis (e : A ≃ₐ[R] A') (hx : IsTranscendenceBasis R x) :
IsTranscendenceBasis R (e ∘ x) :=
.of_comp e.symm.toAlgHom e.symm.injective (by convert hx; ext; simp)
theorem AlgEquiv.isTranscendenceBasis_iff (e : A ≃ₐ[R] A') :
IsTranscendenceBasis R (e ∘ x) ↔ IsTranscendenceBasis R x :=
⟨fun hx ↦ by convert e.symm.isTranscendenceBasis hx; ext; simp, e.isTranscendenceBasis⟩
section trdeg
open Cardinal
theorem AlgebraicIndependent.lift_cardinalMk_le_trdeg [Nontrivial R]
(hx : AlgebraicIndependent R x) : lift.{v} #ι ≤ lift.{u} (trdeg R A) := by
rw [lift_mk_eq'.mpr ⟨.ofInjective _ hx.injective⟩, lift_le]
exact le_ciSup_of_le (bddAbove_range _) ⟨_, hx.to_subtype_range⟩ le_rfl
theorem AlgebraicIndependent.cardinalMk_le_trdeg [Nontrivial R] {ι : Type v} {x : ι → A}
(hx : AlgebraicIndependent R x) : #ι ≤ trdeg R A := by
rw [← (#ι).lift_id, ← (trdeg R A).lift_id]; exact hx.lift_cardinalMk_le_trdeg
theorem lift_trdeg_le_of_injective (f : A →ₐ[R] A') (hf : Injective f) :
lift.{v'} (trdeg R A) ≤ lift.{v} (trdeg R A') := by
nontriviality R
rw [trdeg, lift_iSup (bddAbove_range _)]
exact ciSup_le' fun i ↦ (i.2.map' hf).lift_cardinalMk_le_trdeg
theorem trdeg_le_of_injective {A' : Type v} [CommRing A'] [Algebra R A'] (f : A →ₐ[R] A')
(hf : Injective f) : trdeg R A ≤ trdeg R A' := by
rw [← (trdeg R A).lift_id, ← (trdeg R A').lift_id]; exact lift_trdeg_le_of_injective f hf
theorem lift_trdeg_le_of_surjective (f : A →ₐ[R] A') (hf : Surjective f) :
lift.{v} (trdeg R A') ≤ lift.{v'} (trdeg R A) := by
nontriviality R
rw [trdeg, lift_iSup (bddAbove_range _)]
refine ciSup_le' fun i ↦ (lift_cardinalMk_le_trdeg (x := fun a : i.1 ↦ (⇑f).invFun a) <|
of_comp f ?_)
convert i.2; simp [invFun_eq (hf _)]
theorem trdeg_le_of_surjective {A' : Type v} [CommRing A'] [Algebra R A'] (f : A →ₐ[R] A')
(hf : Surjective f) : trdeg R A' ≤ trdeg R A := by
rw [← (trdeg R A).lift_id, ← (trdeg R A').lift_id]; exact lift_trdeg_le_of_surjective f hf
theorem AlgEquiv.lift_trdeg_eq (e : A ≃ₐ[R] A') :
lift.{v'} (trdeg R A) = lift.{v} (trdeg R A') :=
(lift_trdeg_le_of_injective e.toAlgHom e.injective).antisymm
(lift_trdeg_le_of_surjective e.toAlgHom e.surjective)
theorem AlgEquiv.trdeg_eq {A' : Type v} [CommRing A'] [Algebra R A'] (e : A ≃ₐ[R] A') :
trdeg R A = trdeg R A' := by
rw [← (trdeg R A).lift_id, e.lift_trdeg_eq, lift_id]
end trdeg
theorem algebraicIndependent_comp_subtype {s : Set ι} :
AlgebraicIndependent R (x ∘ (↑) : s → A) ↔
∀ p ∈ MvPolynomial.supported R s, aeval x p = 0 → p = 0 := by
have : (aeval (x ∘ (↑) : s → A) : _ →ₐ[R] _) = (aeval x).comp (rename (↑)) := by ext; simp
have : ∀ p : MvPolynomial s R, rename ((↑) : s → ι) p = 0 ↔ p = 0 :=
(injective_iff_map_eq_zero' (rename ((↑) : s → ι) : MvPolynomial s R →ₐ[R] _).toRingHom).1
(rename_injective _ Subtype.val_injective)
simp [algebraicIndependent_iff, supported_eq_range_rename, *]
theorem algebraicIndependent_subtype {s : Set A} :
AlgebraicIndependent R ((↑) : s → A) ↔
∀ p : MvPolynomial A R, p ∈ MvPolynomial.supported R s → aeval id p = 0 → p = 0 := by
apply @algebraicIndependent_comp_subtype _ _ _ id
theorem algebraicIndependent_of_finite (s : Set A)
(H : ∀ t ⊆ s, t.Finite → AlgebraicIndependent R ((↑) : t → A)) :
AlgebraicIndependent R ((↑) : s → A) :=
algebraicIndependent_subtype.2 fun p hp ↦
algebraicIndependent_subtype.1 (H _ (mem_supported.1 hp) (Finset.finite_toSet _)) _ (by simp)
theorem algebraicIndependent_of_finite_type
(H : ∀ t : Set ι, t.Finite → AlgebraicIndependent R fun i : t ↦ x i) :
AlgebraicIndependent R x :=
(injective_iff_map_eq_zero _).mpr fun p ↦
algebraicIndependent_comp_subtype.1 (H _ p.vars.finite_toSet) _ p.mem_supported_vars
theorem AlgebraicIndependent.image_of_comp {ι ι'} (s : Set ι) (f : ι → ι') (g : ι' → A)
(hs : AlgebraicIndependent R fun x : s => g (f x)) :
AlgebraicIndependent R fun x : f '' s => g x := by
nontriviality R
have : InjOn f s := injOn_iff_injective.2 hs.injective.of_comp
exact (algebraicIndependent_equiv' (Equiv.Set.imageOfInjOn f s this) rfl).1 hs
theorem AlgebraicIndependent.image {ι} {s : Set ι} {f : ι → A}
(hs : AlgebraicIndependent R fun x : s => f x) :
AlgebraicIndependent R fun x : f '' s => (x : A) := by
convert AlgebraicIndependent.image_of_comp s f id hs
theorem algebraicIndependent_iUnion_of_directed {η : Type*} [Nonempty η] {s : η → Set A}
(hs : Directed (· ⊆ ·) s) (h : ∀ i, AlgebraicIndependent R ((↑) : s i → A)) :
AlgebraicIndependent R ((↑) : (⋃ i, s i) → A) := by
refine algebraicIndependent_of_finite (⋃ i, s i) fun t ht ft => ?_
rcases finite_subset_iUnion ft ht with ⟨I, fi, hI⟩
rcases hs.finset_le fi.toFinset with ⟨i, hi⟩
exact (h i).mono (Subset.trans hI <| iUnion₂_subset fun j hj => hi j (fi.mem_toFinset.2 hj))
theorem algebraicIndependent_sUnion_of_directed {s : Set (Set A)} (hsn : s.Nonempty)
(hs : DirectedOn (· ⊆ ·) s) (h : ∀ a ∈ s, AlgebraicIndependent R ((↑) : a → A)) :
AlgebraicIndependent R ((↑) : ⋃₀ s → A) := by
letI : Nonempty s := Nonempty.to_subtype hsn
rw [sUnion_eq_iUnion]
exact algebraicIndependent_iUnion_of_directed hs.directed_val (by simpa using h)
theorem exists_maximal_algebraicIndependent (s t : Set A) (hst : s ⊆ t)
(hs : AlgebraicIndepOn R id s) : ∃ u, s ⊆ u ∧
Maximal (fun (x : Set A) ↦ AlgebraicIndepOn R id x ∧ x ⊆ t) u := by
refine zorn_subset_nonempty { u : Set A | AlgebraicIndependent R ((↑) : u → A) ∧ u ⊆ t}
(fun c hc chainc hcn ↦ ⟨⋃₀ c, ⟨?_, ?_⟩, fun _ ↦ subset_sUnion_of_mem⟩) s ⟨hs, hst⟩
· exact algebraicIndependent_sUnion_of_directed hcn chainc.directedOn (fun x hxc ↦ (hc hxc).1)
exact fun x ⟨w, hyc, hwy⟩ ↦ (hc hyc).2 hwy
theorem AlgebraicIndependent.repr_ker (hx : AlgebraicIndependent R x) :
RingHom.ker (hx.repr : adjoin R (range x) →+* MvPolynomial ι R) = ⊥ :=
(RingHom.injective_iff_ker_eq_bot _).1 (AlgEquiv.injective _)
-- TODO - make this an `AlgEquiv`
/-- The isomorphism between `MvPolynomial (Option ι) R` and the polynomial ring over
the algebra generated by an algebraically independent family. -/
def AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin (hx : AlgebraicIndependent R x) :
MvPolynomial (Option ι) R ≃+* Polynomial (adjoin R (Set.range x)) :=
(MvPolynomial.optionEquivLeft _ _).toRingEquiv.trans
(Polynomial.mapEquiv hx.aevalEquiv.toRingEquiv)
@[simp]
theorem AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin_apply
(hx : AlgebraicIndependent R x) (y) :
hx.mvPolynomialOptionEquivPolynomialAdjoin y =
Polynomial.map (hx.aevalEquiv : MvPolynomial ι R →+* adjoin R (range x))
(aeval (fun o : Option ι => o.elim Polynomial.X fun s : ι => Polynomial.C (X s)) y) :=
rfl
/-- `simp`-normal form of `mvPolynomialOptionEquivPolynomialAdjoin_C` -/
@[simp]
theorem AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin_C'
(hx : AlgebraicIndependent R x) (r) :
Polynomial.C (hx.aevalEquiv (C r)) = Polynomial.C (algebraMap _ _ r) := by
congr
apply_fun Subtype.val using Subtype.val_injective
simp
theorem AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin_C
(hx : AlgebraicIndependent R x) (r) :
hx.mvPolynomialOptionEquivPolynomialAdjoin (C r) = Polynomial.C (algebraMap _ _ r) := by
simp
theorem AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin_X_none
(hx : AlgebraicIndependent R x) :
hx.mvPolynomialOptionEquivPolynomialAdjoin (X none) = Polynomial.X := by
rw [AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin_apply, aeval_X, Option.elim,
Polynomial.map_X]
theorem AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin_X_some
(hx : AlgebraicIndependent R x) (i) :
hx.mvPolynomialOptionEquivPolynomialAdjoin (X (some i)) =
Polynomial.C (hx.aevalEquiv (X i)) := by
rw [AlgebraicIndependent.mvPolynomialOptionEquivPolynomialAdjoin_apply, aeval_X, Option.elim,
Polynomial.map_C, RingHom.coe_coe]
theorem AlgebraicIndependent.aeval_comp_mvPolynomialOptionEquivPolynomialAdjoin
(hx : AlgebraicIndependent R x) (a : A) :
RingHom.comp
(↑(Polynomial.aeval a : Polynomial (adjoin R (Set.range x)) →ₐ[_] A) :
Polynomial (adjoin R (Set.range x)) →+* A)
hx.mvPolynomialOptionEquivPolynomialAdjoin.toRingHom =
↑(MvPolynomial.aeval fun o : Option ι => o.elim a x : MvPolynomial (Option ι) R →ₐ[R] A) := by
refine MvPolynomial.ringHom_ext ?_ ?_ <;>
simp only [RingHom.comp_apply, RingEquiv.toRingHom_eq_coe, RingEquiv.coe_toRingHom,
AlgHom.coe_toRingHom, AlgHom.coe_toRingHom]
· intro r
rw [hx.mvPolynomialOptionEquivPolynomialAdjoin_C, aeval_C, Polynomial.aeval_C,
IsScalarTower.algebraMap_apply R (adjoin R (range x)) A]
· rintro (⟨⟩ | ⟨i⟩)
· rw [hx.mvPolynomialOptionEquivPolynomialAdjoin_X_none, aeval_X, Polynomial.aeval_X,
Option.elim]
· rw [hx.mvPolynomialOptionEquivPolynomialAdjoin_X_some, Polynomial.aeval_C,
hx.algebraMap_aevalEquiv, aeval_X, aeval_X, Option.elim]
section Field
variable {K : Type*} [Field K] [Algebra K A]
theorem algebraicIndependent_empty_type [IsEmpty ι] [Nontrivial A] : AlgebraicIndependent K x := by
rw [algebraicIndependent_empty_type_iff]
exact RingHom.injective _
theorem algebraicIndependent_empty [Nontrivial A] :
AlgebraicIndependent K ((↑) : (∅ : Set A) → A) :=
algebraicIndependent_empty_type
end Field |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraicIndependent/Defs.lean | import Mathlib.Algebra.MvPolynomial.CommRing
/-!
# Algebraic Independence
This file defines algebraic independence of a family of elements of an `R` algebra.
## Main definitions
* `AlgebraicIndependent` - `AlgebraicIndependent R x` states the family of elements `x`
is algebraically independent over `R`, meaning that the canonical map out of the multivariable
polynomial ring is injective.
* `AlgebraicIndependent.aevalEquiv` - The canonical isomorphism from the polynomial ring to the
subalgebra generated by an algebraic independent family.
* `AlgebraicIndependent.repr` - The canonical map from the subalgebra generated by an
algebraic independent family into the polynomial ring. It is the inverse of
`AlgebraicIndependent.aevalEquiv`.
* `IsTranscendenceBasis R x` - a family `x` is a transcendence basis over `R` if it is a maximal
algebraically independent subset.
## Main results
We show that algebraic independence is preserved under injective maps of the indices.
## References
* [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D)
-/
noncomputable section
open Function Set Subalgebra MvPolynomial Algebra
variable {ι ι' : Type*} (R : Type*) {K A A' : Type*} (x : ι → A)
variable [CommRing R] [CommRing A] [CommRing A'] [Algebra R A] [Algebra R A']
/-- `AlgebraicIndependent R x` states the family of elements `x`
is algebraically independent over `R`, meaning that the canonical
map out of the multivariable polynomial ring is injective. -/
@[stacks 030E "(1)"] def AlgebraicIndependent : Prop :=
Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A)
/-- `AlgebraicIndepOn R v s` states that the elements in the family `v` that are indexed by the
elements of `s` are algebraically independent over `R`. -/
abbrev AlgebraicIndepOn (s : Set ι) : Prop := AlgebraicIndependent R fun i : s ↦ x i
variable {R} {x}
theorem algebraicIndependent_iff :
AlgebraicIndependent R x ↔
∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 :=
injective_iff_map_eq_zero _
theorem AlgebraicIndependent.eq_zero_of_aeval_eq_zero (h : AlgebraicIndependent R x) :
∀ p : MvPolynomial ι R, MvPolynomial.aeval (x : ι → A) p = 0 → p = 0 :=
algebraicIndependent_iff.1 h
theorem algebraicIndependent_iff_injective_aeval :
AlgebraicIndependent R x ↔ Injective (MvPolynomial.aeval x : MvPolynomial ι R →ₐ[R] A) :=
Iff.rfl
namespace AlgebraicIndependent
theorem of_comp (f : A →ₐ[R] A') (hfv : AlgebraicIndependent R (f ∘ x)) :
AlgebraicIndependent R x := by
have : aeval (f ∘ x) = f.comp (aeval x) := by ext; simp
rw [AlgebraicIndependent, this, AlgHom.coe_comp] at hfv
exact hfv.of_comp
variable (hx : AlgebraicIndependent R x)
include hx
theorem comp (f : ι' → ι) (hf : Function.Injective f) : AlgebraicIndependent R (x ∘ f) := by
intro p q
simpa [aeval_rename, (rename_injective f hf).eq_iff] using @hx (rename f p) (rename f q)
theorem coe_range : AlgebraicIndependent R ((↑) : range x → A) := by
simpa using hx.comp _ (rangeSplitting_injective x)
end AlgebraicIndependent
open AlgebraicIndependent
theorem algebraicIndependent_equiv (e : ι ≃ ι') {f : ι' → A} :
AlgebraicIndependent R (f ∘ e) ↔ AlgebraicIndependent R f :=
⟨fun h => Function.comp_id f ▸ e.self_comp_symm ▸ h.comp _ e.symm.injective,
fun h => h.comp _ e.injective⟩
theorem algebraicIndependent_equiv' (e : ι ≃ ι') {f : ι' → A} {g : ι → A} (h : f ∘ e = g) :
AlgebraicIndependent R g ↔ AlgebraicIndependent R f :=
h ▸ algebraicIndependent_equiv e
theorem algebraicIndependent_subtype_range {ι} {f : ι → A} (hf : Injective f) :
AlgebraicIndependent R ((↑) : range f → A) ↔ AlgebraicIndependent R f :=
Iff.symm <| algebraicIndependent_equiv' (Equiv.ofInjective f hf) rfl
alias ⟨AlgebraicIndependent.of_subtype_range, _⟩ := algebraicIndependent_subtype_range
theorem algebraicIndependent_image {ι} {s : Set ι} {f : ι → A} (hf : Set.InjOn f s) :
(AlgebraicIndependent R fun x : s => f x) ↔ AlgebraicIndependent R fun x : f '' s => (x : A) :=
algebraicIndependent_equiv' (Equiv.Set.imageOfInjOn _ _ hf) rfl
namespace AlgebraicIndependent
theorem mono {t s : Set A} (h : t ⊆ s)
(hx : AlgebraicIndependent R ((↑) : s → A)) : AlgebraicIndependent R ((↑) : t → A) := by
simpa [Function.comp] using hx.comp (inclusion h) (inclusion_injective h)
section repr
variable (hx : AlgebraicIndependent R x)
include hx
/-- Canonical isomorphism between polynomials and the subalgebra generated by
algebraically independent elements. -/
@[simps! apply_coe]
def aevalEquiv : MvPolynomial ι R ≃ₐ[R] Algebra.adjoin R (range x) :=
(AlgEquiv.ofInjective (aeval x) (algebraicIndependent_iff_injective_aeval.1 hx)).trans
(Subalgebra.equivOfEq _ _ (Algebra.adjoin_range_eq_range_aeval R x).symm)
@[simp]
theorem algebraMap_aevalEquiv (p : MvPolynomial ι R) :
algebraMap (Algebra.adjoin R (range x)) A (hx.aevalEquiv p) = aeval x p :=
rfl
/-- The canonical map from the subalgebra generated by an algebraic independent family
into the polynomial ring. -/
def repr : Algebra.adjoin R (range x) →ₐ[R] MvPolynomial ι R :=
hx.aevalEquiv.symm
@[simp]
theorem aeval_repr (p) : aeval x (hx.repr p) = p :=
Subtype.ext_iff.1 (AlgEquiv.apply_symm_apply hx.aevalEquiv p)
theorem aeval_comp_repr : (aeval x).comp hx.repr = Subalgebra.val _ :=
AlgHom.ext hx.aeval_repr
end repr
end AlgebraicIndependent
variable (R) in
/-- A family is a transcendence basis if it is a maximal algebraically independent subset. -/
@[stacks 030E "(4)"] def IsTranscendenceBasis (x : ι → A) : Prop :=
AlgebraicIndependent R x ∧
∀ (s : Set A) (_ : AlgebraicIndepOn R id s) (_ : range x ⊆ s), range x = s
theorem isTranscendenceBasis_iff_maximal {s : Set A} :
IsTranscendenceBasis R ((↑) : s → A) ↔ Maximal (AlgebraicIndepOn R id) s := by
rw [IsTranscendenceBasis, maximal_iff, Subtype.range_val]; rfl
theorem isTranscendenceBasis_equiv (e : ι ≃ ι') {f : ι' → A} :
IsTranscendenceBasis R (f ∘ e) ↔ IsTranscendenceBasis R f := by
simp_rw [IsTranscendenceBasis, algebraicIndependent_equiv, EquivLike.range_comp]
alias ⟨_, IsTranscendenceBasis.comp_equiv⟩ := isTranscendenceBasis_equiv
theorem isTranscendenceBasis_equiv' (e : ι ≃ ι') {f : ι' → A} {g : ι → A} (h : f ∘ e = g) :
IsTranscendenceBasis R g ↔ IsTranscendenceBasis R f :=
h ▸ isTranscendenceBasis_equiv e
theorem isTranscendenceBasis_subtype_range {ι} {f : ι → A} (hf : Injective f) :
IsTranscendenceBasis R ((↑) : range f → A) ↔ IsTranscendenceBasis R f :=
.symm <| isTranscendenceBasis_equiv' (Equiv.ofInjective f hf) rfl
alias ⟨IsTranscendenceBasis.of_subtype_range, _⟩ := isTranscendenceBasis_subtype_range
theorem isTranscendenceBasis_image {ι} {s : Set ι} {f : ι → A} (hf : Set.InjOn f s) :
IsTranscendenceBasis R (fun x : s ↦ f x) ↔ IsTranscendenceBasis R fun x : f '' s ↦ (x : A) :=
isTranscendenceBasis_equiv' (Equiv.Set.imageOfInjOn _ _ hf) rfl |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraicIndependent/Transcendental.lean | import Mathlib.Data.Fin.Tuple.Reflection
import Mathlib.RingTheory.Algebraic.MvPolynomial
import Mathlib.RingTheory.AlgebraicIndependent.Basic
/-!
# Algebraic Independence
This file relates algebraic independence and transcendence (or algebraicity) of elements.
## References
* [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D)
## Tags
transcendence
-/
noncomputable section
open Function Set Subalgebra MvPolynomial Algebra
universe u v
variable {ι ι' R : Type*} {S : Type u} {A : Type v} {x : ι → A}
variable [CommRing R] [CommRing S] [CommRing A]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
/-- A one-element family `x` is algebraically independent if and only if
its element is transcendental. -/
@[simp]
theorem algebraicIndependent_unique_type_iff [Unique ι] :
AlgebraicIndependent R x ↔ Transcendental R (x default) := by
rw [transcendental_iff_injective, algebraicIndependent_iff_injective_aeval]
let i := (renameEquiv R (Equiv.equivPUnit.{_, 1} ι)).trans (pUnitAlgEquiv R)
have key : aeval (R := R) x = (Polynomial.aeval (R := R) (x default)).comp i := by
ext y
simp [i, Subsingleton.elim y default]
simp [key]
theorem algebraicIndependent_singleton_iff [Subsingleton ι] (i : ι) :
AlgebraicIndependent R x ↔ Transcendental R (x i) :=
letI := uniqueOfSubsingleton i
algebraicIndependent_unique_type_iff
/-- The one-element family `![x]` is algebraically independent if and only if
`x` is transcendental. -/
theorem algebraicIndependent_iff_transcendental {x : A} :
AlgebraicIndependent R ![x] ↔ Transcendental R x := by
simp
namespace AlgebraicIndependent
variable (hx : AlgebraicIndependent R x)
include hx
/-- If a family `x` is algebraically independent, then any of its element is transcendental. -/
theorem transcendental (i : ι) : Transcendental R (x i) := by
have := hx.comp ![i] (Function.injective_of_subsingleton _)
have : AlgebraicIndependent R ![x i] := by rwa [← FinVec.map_eq] at this
rwa [← algebraicIndependent_iff_transcendental]
/-- If `A/R` is algebraic, then all algebraically independent families are empty. -/
theorem isEmpty_of_isAlgebraic [Algebra.IsAlgebraic R A] : IsEmpty ι := by
rcases isEmpty_or_nonempty ι with h | ⟨⟨i⟩⟩
· exact h
exact False.elim (hx.transcendental i (Algebra.IsAlgebraic.isAlgebraic _))
end AlgebraicIndependent
theorem trdeg_eq_zero [Algebra.IsAlgebraic R A] : trdeg R A = 0 :=
bot_unique <| ciSup_le' fun s ↦ have := s.2.isEmpty_of_isAlgebraic; (Cardinal.mk_eq_zero _).le
variable (R A) in
theorem trdeg_pos [Algebra.Transcendental R A] : 0 < trdeg R A :=
have ⟨x, hx⟩ := Algebra.Transcendental.transcendental (R := R) (A := A)
zero_lt_one.trans_le <| le_ciSup_of_le (Cardinal.bddAbove_range _)
⟨{x}, algebraicIndependent_unique_type_iff.mpr hx⟩ (by simp)
theorem trdeg_eq_zero_iff : trdeg R A = 0 ↔ Algebra.IsAlgebraic R A := by
by_cases h : Algebra.IsAlgebraic R A
· exact iff_of_true trdeg_eq_zero h
rw [← not_iff_not]
rw [← Algebra.transcendental_iff_not_isAlgebraic] at h ⊢
exact iff_of_true (trdeg_pos R A).ne' h
theorem trdeg_ne_zero_iff : trdeg R A ≠ 0 ↔ Algebra.Transcendental R A := by
rw [Algebra.transcendental_iff_not_isAlgebraic, Ne, trdeg_eq_zero_iff]
open AlgebraicIndependent
theorem AlgebraicIndependent.option_iff_transcendental (hx : AlgebraicIndependent R x) (a : A) :
AlgebraicIndependent R (fun o : Option ι ↦ o.elim a x) ↔
Transcendental (adjoin R (range x)) a := by
rw [algebraicIndependent_iff_injective_aeval, transcendental_iff_injective,
← AlgHom.coe_toRingHom, ← hx.aeval_comp_mvPolynomialOptionEquivPolynomialAdjoin,
RingHom.coe_comp]
exact Injective.of_comp_iff' (Polynomial.aeval a)
(mvPolynomialOptionEquivPolynomialAdjoin hx).bijective
theorem AlgebraicIndependent.option_iff {a : A} :
AlgebraicIndependent R (fun o : Option ι ↦ o.elim a x) ↔
AlgebraicIndependent R x ∧ Transcendental (adjoin R (range x)) a :=
⟨fun h ↦ have := h.comp _ (Option.some_injective _); ⟨this,
(this.option_iff_transcendental _).mp h⟩, fun h ↦ (h.1.option_iff_transcendental _).mpr h.2⟩
theorem AlgebraicIndepOn.insert_iff {s : Set ι} {i : ι} (h : i ∉ s) :
AlgebraicIndepOn R x (insert i s) ↔
AlgebraicIndepOn R x s ∧ Transcendental (adjoin R (x '' s)) (x i) := by
classical simp_rw [← algebraicIndependent_equiv (subtypeInsertEquivOption h).symm,
AlgebraicIndepOn]
convert option_iff (x := fun i : s ↦ x i) (a := x i) using 2
· ext (_ | _) <;> rfl
· rw [Set.image_eq_range]
protected theorem AlgebraicIndepOn.insert {s : Set ι} {i : ι} (hs : AlgebraicIndepOn R x s)
(hi : Transcendental (adjoin R (x '' s)) (x i)) : AlgebraicIndepOn R x (insert i s) := by
nontriviality R
have := hs.algebraMap_injective.nontrivial
exact (insert_iff fun h ↦ hi <| isAlgebraic_algebraMap
(⟨_, subset_adjoin ⟨i, h, rfl⟩⟩ : adjoin R (x '' s))).mpr ⟨hs, hi⟩
theorem algebraicIndependent_of_set_of_finite (s : Set ι)
(ind : AlgebraicIndependent R fun i : s ↦ x i)
(H : ∀ t : Set ι, t.Finite → AlgebraicIndependent R (fun i : t ↦ x i) →
∀ i ∉ s, i ∉ t → Transcendental (adjoin R (x '' t)) (x i)) :
AlgebraicIndependent R x := by
classical
refine algebraicIndependent_of_finite_type fun t hfin ↦ ?_
suffices AlgebraicIndependent R fun i : ↥(t ∩ s ∪ t \ s) ↦ x i from
this.comp (Equiv.setCongr (t.inter_union_diff s).symm) (Equiv.injective _)
refine hfin.diff.induction_on_subset _ (ind.comp (inclusion <| by simp) (inclusion_injective _))
fun {a u} ha hu ha' h ↦ ?_
have : a ∉ t ∩ s ∪ u := (·.elim (ha.2 ·.2) ha')
convert (((image_eq_range .. ▸ h.option_iff_transcendental <| x a).2 <| H _ (hfin.subset
(union_subset inter_subset_left <| hu.trans diff_subset)) h a ha.2 this).comp _
(subtypeInsertEquivOption this).injective).comp
(Equiv.setCongr union_insert) (Equiv.injective _) with x
by_cases h : ↑x = a <;> simp [h, Set.subtypeInsertEquivOption]
/-- Variant of `algebraicIndependent_of_finite_type` using `Transcendental`. -/
theorem algebraicIndependent_of_finite_type'
(hinj : Injective (algebraMap R A))
(H : ∀ t : Set ι, t.Finite → AlgebraicIndependent R (fun i : t ↦ x i) →
∀ i ∉ t, Transcendental (adjoin R (x '' t)) (x i)) :
AlgebraicIndependent R x :=
algebraicIndependent_of_set_of_finite ∅ (algebraicIndependent_empty_type_iff.mpr hinj)
fun t ht ind i _ ↦ H t ht ind i
/-- Variant of `algebraicIndependent_of_finite` using `Transcendental`. -/
theorem algebraicIndependent_of_finite' (s : Set A)
(hinj : Injective (algebraMap R A))
(H : ∀ t ⊆ s, t.Finite → AlgebraicIndependent R ((↑) : t → A) →
∀ a ∈ s, a ∉ t → Transcendental (adjoin R t) a) :
AlgebraicIndependent R ((↑) : s → A) :=
algebraicIndependent_of_finite_type' hinj fun t hfin h i hi ↦ H _
(by rintro _ ⟨x, _, rfl⟩; exact x.2) (hfin.image _) h.image _ i.2
(mt Subtype.val_injective.mem_set_image.mp hi)
namespace AlgebraicIndependent
theorem sumElim_iff {ι'} {y : ι' → A} : AlgebraicIndependent R (Sum.elim y x) ↔
AlgebraicIndependent R x ∧ AlgebraicIndependent (adjoin R (range x)) y := by
by_cases hx : AlgebraicIndependent R x; swap
· exact ⟨fun h ↦ (hx <| by apply h.comp _ Sum.inr_injective).elim, fun h ↦ (hx h.1).elim⟩
let e := (sumAlgEquiv R ι' ι).trans (mapAlgEquiv _ hx.aevalEquiv)
have : aeval (Sum.elim y x) = ((aeval y).restrictScalars R).comp e.toAlgHom := by
ext (_ | _) <;> simp [e]
simp_rw [hx, AlgebraicIndependent, this]; simp
theorem iff_adjoin_image (s : Set ι) :
AlgebraicIndependent R x ↔ AlgebraicIndependent R (fun i : s ↦ x i) ∧
AlgebraicIndepOn (adjoin R (x '' s)) x sᶜ := by
rw [show x '' s = range fun i : s ↦ x i by ext; simp]
convert ← sumElim_iff
classical apply algebraicIndependent_equiv' ((Equiv.sumComm ..).trans (Equiv.Set.sumCompl ..))
ext (_ | _) <;> rfl
theorem iff_adjoin_image_compl (s : Set ι) :
AlgebraicIndependent R x ↔ AlgebraicIndependent R (fun i : ↥sᶜ ↦ x i) ∧
AlgebraicIndepOn (adjoin R (x '' sᶜ)) x s := by
convert ← iff_adjoin_image _; apply compl_compl
theorem iff_transcendental_adjoin_image (i : ι) :
AlgebraicIndependent R x ↔ AlgebraicIndependent R (fun j : {j // j ≠ i} ↦ x j) ∧
Transcendental (adjoin R (x '' {i}ᶜ)) (x i) :=
(iff_adjoin_image_compl _).trans <| and_congr_right
fun _ ↦ algebraicIndependent_unique_type_iff (ι := {j // j = i})
variable (hx : AlgebraicIndependent R x)
include hx
theorem sumElim {ι'} {y : ι' → A} (hy : AlgebraicIndependent (adjoin R (range x)) y) :
AlgebraicIndependent R (Sum.elim y x) :=
sumElim_iff.mpr ⟨hx, hy⟩
theorem sumElim_of_tower {ι'} {y : ι' → A} (hxS : range x ⊆ range (algebraMap S A))
(hy : AlgebraicIndependent S y) : AlgebraicIndependent R (Sum.elim y x) := by
let e := AlgEquiv.ofInjective (IsScalarTower.toAlgHom R S A) hy.algebraMap_injective
set Rx := adjoin R (range x)
let _ : Algebra Rx S :=
(e.symm.toAlgHom.comp <| Subalgebra.inclusion <| adjoin_le hxS).toAlgebra
have : IsScalarTower Rx S A := .of_algebraMap_eq fun x ↦ show _ = (e (e.symm _)).1 by simp
refine hx.sumElim (hy.restrictScalars (e.symm.injective.comp ?_))
simpa only [AlgHom.coe_toRingHom] using Subalgebra.inclusion_injective _
omit hx in
theorem sumElim_comp {ι'} {x : ι → S} {y : ι' → A} (hx : AlgebraicIndependent R x)
(hy : AlgebraicIndependent S y) : AlgebraicIndependent R (Sum.elim y (algebraMap S A ∘ x)) :=
(hx.map' (f := IsScalarTower.toAlgHom R S A) hy.algebraMap_injective).sumElim_of_tower
(range_comp_subset_range ..) hy
theorem adjoin_of_disjoint {s t : Set ι} (h : Disjoint s t) :
AlgebraicIndependent (adjoin R (x '' s)) fun i : t ↦ x i :=
((iff_adjoin_image s).mp hx).2.comp (inclusion _) (inclusion_injective h.subset_compl_left)
theorem adjoin_iff_disjoint [Nontrivial A] {s t : Set ι} :
(AlgebraicIndependent (adjoin R (x '' s)) fun i : t ↦ x i) ↔ Disjoint s t := by
refine ⟨fun ind ↦ of_not_not fun ndisj ↦ ?_, adjoin_of_disjoint hx⟩
have ⟨i, hs, ht⟩ := Set.not_disjoint_iff.mp ndisj
refine ind.transcendental ⟨i, ht⟩ (isAlgebraic_algebraMap (⟨_, subset_adjoin ?_⟩ : adjoin R _))
exact ⟨i, hs, rfl⟩
theorem transcendental_adjoin {s : Set ι} {i : ι} (hi : i ∉ s) :
Transcendental (adjoin R (x '' s)) (x i) := by
convert ← hx.adjoin_of_disjoint (Set.disjoint_singleton_right.mpr hi)
rw [algebraicIndependent_singleton_iff ⟨i, rfl⟩]
theorem transcendental_adjoin_iff [Nontrivial A] {s : Set ι} {i : ι} :
Transcendental (adjoin R (x '' s)) (x i) ↔ i ∉ s := by
rw [← Set.disjoint_singleton_right]
convert ← hx.adjoin_iff_disjoint (t := {i})
rw [algebraicIndependent_singleton_iff ⟨i, rfl⟩]
end AlgebraicIndependent
open Cardinal in
theorem lift_trdeg_add_le [Nontrivial R] [FaithfulSMul R S] [FaithfulSMul S A] :
lift.{v} (trdeg R S) + lift.{u} (trdeg S A) ≤ lift.{u} (trdeg R A) := by
simp_rw [trdeg, lift_iSup (bddAbove_range _)]
simp_rw [Cardinal.ciSup_add_ciSup _ (bddAbove_range _) _ (bddAbove_range _),
add_comm (lift.{v, u} _), ← mk_sum]
refine ciSup_le fun ⟨s, hs⟩ ↦ ciSup_le fun ⟨t, ht⟩ ↦ ?_
have := hs.sumElim_comp ht
refine le_ciSup_of_le (bddAbove_range _) ⟨_, this.to_subtype_range⟩ ?_
rw [← lift_umax, mk_range_eq_of_injective this.injective, lift_id']
theorem trdeg_add_le [Nontrivial R] {A : Type u} [CommRing A] [Algebra R A] [Algebra S A]
[FaithfulSMul R S] [FaithfulSMul S A] [IsScalarTower R S A] :
trdeg R S + trdeg S A ≤ trdeg R A := by
rw [← (trdeg R S).lift_id, ← (trdeg S A).lift_id, ← (trdeg R A).lift_id]
exact lift_trdeg_add_le
/-- If for each `i : ι`, `f_i : R[X]` is transcendental over `R`, then `{f_i(X_i) | i : ι}`
in `MvPolynomial ι R` is algebraically independent over `R`. -/
theorem MvPolynomial.algebraicIndependent_polynomial_aeval_X
(f : ι → Polynomial R) (hf : ∀ i, Transcendental R (f i)) :
AlgebraicIndependent R fun i ↦ Polynomial.aeval (X i : MvPolynomial ι R) (f i) := by
set x := fun i ↦ Polynomial.aeval (X i : MvPolynomial ι R) (f i)
refine algebraicIndependent_of_finite_type' (C_injective _ _) fun t _ _ i hi ↦ ?_
have hle : adjoin R (x '' t) ≤ supported R t := by
rw [Algebra.adjoin_le_iff, Set.image_subset_iff]
intro _ h
rw [Set.mem_preimage]
refine Algebra.adjoin_mono ?_ (Polynomial.aeval_mem_adjoin_singleton R _)
simp_rw [singleton_subset_iff, Set.mem_image_of_mem _ h]
exact (transcendental_supported_polynomial_aeval_X R hi (hf i)).of_tower_top_of_subalgebra_le hle
/-- If `{x_i : A | i : ι}` is algebraically independent over `R`, and for each `i`,
`f_i : R[X]` is transcendental over `R`, then `{f_i(x_i) | i : ι}` is also
algebraically independent over `R`. -/
theorem AlgebraicIndependent.polynomial_aeval_of_transcendental
(hx : AlgebraicIndependent R x)
{f : ι → Polynomial R} (hf : ∀ i, Transcendental R (f i)) :
AlgebraicIndependent R fun i ↦ Polynomial.aeval (x i) (f i) := by
convert aeval_of_algebraicIndependent hx (algebraicIndependent_polynomial_aeval_X _ hf)
rw [← AlgHom.comp_apply]
congr 1; ext1; simp |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraicIndependent/TranscendenceBasis.lean | import Mathlib.Combinatorics.Matroid.IndepAxioms
import Mathlib.Combinatorics.Matroid.Rank.Cardinal
import Mathlib.FieldTheory.IntermediateField.Adjoin.Algebra
import Mathlib.RingTheory.AlgebraicIndependent.Transcendental
/-!
# Transcendence basis
This file defines the transcendence basis as a maximal algebraically independent subset.
## Main results
* `exists_isTranscendenceBasis`: a ring extension has a transcendence basis
* `IsTranscendenceBasis.lift_cardinalMk_eq`: any two transcendence bases of a domain have the
same cardinality.
## References
* [Stacks: Transcendence](https://stacks.math.columbia.edu/tag/030D)
## TODO
Define the transcendence degree and show it is independent of the choice of a
transcendence basis.
## Tags
transcendence basis, transcendence degree, transcendence
-/
noncomputable section
open Function Set Subalgebra MvPolynomial Algebra
universe u u' v w
variable {ι : Type u} {ι' : Type u'} (R : Type*) {S : Type v} {A : Type w}
variable {x : ι → A} {y : ι' → A}
variable [CommRing R] [CommRing S] [CommRing A]
variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
open AlgebraicIndependent
variable {R} in
theorem exists_isTranscendenceBasis_superset {s : Set A}
(hs : AlgebraicIndepOn R id s) :
∃ t, s ⊆ t ∧ IsTranscendenceBasis R ((↑) : t → A) := by
simpa [← isTranscendenceBasis_iff_maximal]
using exists_maximal_algebraicIndependent s _ (subset_univ _) hs
variable (A)
theorem exists_isTranscendenceBasis [FaithfulSMul R A] :
∃ s : Set A, IsTranscendenceBasis R ((↑) : s → A) := by
simpa using exists_isTranscendenceBasis_superset
((algebraicIndependent_empty_iff R A).mpr (FaithfulSMul.algebraMap_injective R A))
/-- `Type` version of `exists_isTranscendenceBasis`. -/
theorem exists_isTranscendenceBasis' [FaithfulSMul R A] :
∃ (ι : Type w) (x : ι → A), IsTranscendenceBasis R x :=
have ⟨s, h⟩ := exists_isTranscendenceBasis R A
⟨s, Subtype.val, h⟩
variable {A}
open Cardinal in
theorem trdeg_eq_iSup_cardinalMk_isTranscendenceBasis :
trdeg R A = ⨆ ι : { s : Set A // IsTranscendenceBasis R ((↑) : s → A) }, #ι.1 := by
refine (ciSup_le' fun s ↦ ?_).antisymm
(ciSup_le' fun s ↦ le_ciSup_of_le (bddAbove_range _) ⟨s, s.2.1⟩ le_rfl)
choose t ht using exists_isTranscendenceBasis_superset s.2
exact le_ciSup_of_le (bddAbove_range _) ⟨t, ht.2⟩ (mk_le_mk_of_subset ht.1)
variable {R}
theorem AlgebraicIndependent.isTranscendenceBasis_iff [Nontrivial R]
(i : AlgebraicIndependent R x) :
IsTranscendenceBasis R x ↔
∀ (κ : Type w) (w : κ → A) (_ : AlgebraicIndependent R w) (j : ι → κ) (_ : w ∘ j = x),
Surjective j := by
fconstructor
· rintro p κ w i' j rfl
have p := p.2 (range w) i'.coe_range (range_comp_subset_range _ _)
rw [range_comp, ← @image_univ _ _ w] at p
exact range_eq_univ.mp (image_injective.mpr i'.injective p)
· intro p
use i
intro w i' h
specialize p w ((↑) : w → A) i' (fun i => ⟨x i, range_subset_iff.mp h i⟩) (by ext; simp)
have q := congr_arg (fun s => ((↑) : w → A) '' s) p.range_eq
dsimp at q
rw [← image_univ, image_image] at q
simpa using q
theorem IsTranscendenceBasis.isAlgebraic [Nontrivial R] (hx : IsTranscendenceBasis R x) :
Algebra.IsAlgebraic (adjoin R (range x)) A := by
constructor
intro a
rw [← not_iff_comm.1 (hx.1.option_iff_transcendental _).symm]
intro ai
have h₁ : range x ⊆ range fun o : Option ι => o.elim a x := by
rintro x ⟨y, rfl⟩
exact ⟨some y, rfl⟩
have h₂ : range x ≠ range fun o : Option ι => o.elim a x := by
intro h
have : a ∈ range x := by
rw [h]
exact ⟨none, rfl⟩
rcases this with ⟨b, rfl⟩
have : some b = none := ai.injective rfl
simpa
exact h₂ (hx.2 (Set.range fun o : Option ι => o.elim a x)
((algebraicIndependent_subtype_range ai.injective).2 ai) h₁)
theorem AlgebraicIndependent.isTranscendenceBasis_iff_isAlgebraic
[Nontrivial R] (ind : AlgebraicIndependent R x) :
IsTranscendenceBasis R x ↔ Algebra.IsAlgebraic (adjoin R (range x)) A := by
refine ⟨(·.isAlgebraic), fun alg ↦ ⟨ind, fun s ind_s hxs ↦ of_not_not fun hxs' ↦ ?_⟩⟩
have : ¬ s ⊆ range x := (hxs' <| hxs.antisymm ·)
have ⟨a, has, hax⟩ := not_subset.mp this
rw [show range x = Subtype.val '' range (Set.inclusion hxs) by
rw [← range_comp, val_comp_inclusion, Subtype.range_val]] at alg
refine ind_s.transcendental_adjoin (s := range (inclusion hxs)) (i := ⟨a, has⟩) ?_ (alg.1 _)
simpa using hax
theorem isTranscendenceBasis_iff_algebraicIndependent_isAlgebraic [Nontrivial R] :
IsTranscendenceBasis R x ↔
AlgebraicIndependent R x ∧ Algebra.IsAlgebraic (adjoin R (range x)) A :=
⟨fun h ↦ ⟨h.1, h.1.isTranscendenceBasis_iff_isAlgebraic.mp h⟩,
fun ⟨ind, alg⟩ ↦ ind.isTranscendenceBasis_iff_isAlgebraic.mpr alg⟩
lemma IsTranscendenceBasis.algebraMap_comp
[Nontrivial R] [NoZeroDivisors S] [Algebra.IsAlgebraic S A] [FaithfulSMul S A]
{x : ι → S} (hx : IsTranscendenceBasis R x) : IsTranscendenceBasis R (algebraMap S A ∘ x) := by
let f := IsScalarTower.toAlgHom R S A
refine hx.1.map (f := f) (FaithfulSMul.algebraMap_injective S A).injOn
|>.isTranscendenceBasis_iff_isAlgebraic.mpr ?_
rw [Set.range_comp, ← AlgHom.map_adjoin]
set Rx := adjoin R (range x)
let e := Rx.equivMapOfInjective f (FaithfulSMul.algebraMap_injective S A)
letI := e.toRingHom.toAlgebra
haveI : IsScalarTower Rx (Rx.map f) A := .of_algebraMap_eq fun x ↦ rfl
have : Algebra.IsAlgebraic Rx S := hx.isAlgebraic
have : Algebra.IsAlgebraic Rx A := .trans _ S _
exact .extendScalars e.injective
lemma IsTranscendenceBasis.isAlgebraic_iff [IsDomain S] [NoZeroDivisors A]
{ι : Type*} {v : ι → A} (hv : IsTranscendenceBasis R v) :
Algebra.IsAlgebraic S A ↔ ∀ i, IsAlgebraic S (v i) := by
refine ⟨fun _ i ↦ Algebra.IsAlgebraic.isAlgebraic (v i), fun H ↦ ?_⟩
let Rv := adjoin R (range v)
let Sv := adjoin S (range v)
have : Algebra.IsAlgebraic S Sv := by
simpa [Sv, ← Subalgebra.isAlgebraic_iff, isAlgebraic_adjoin_iff]
have le : Rv ≤ Sv.restrictScalars R := by
rw [Subalgebra.restrictScalars_adjoin]; exact le_sup_right
letI : Algebra Rv Sv := (Subalgebra.inclusion le).toAlgebra
have : IsScalarTower Rv Sv A := .of_algebraMap_eq fun x ↦ rfl
have := (algebraMap R S).domain_nontrivial
have := hv.isAlgebraic
have : Algebra.IsAlgebraic Sv A := .extendScalars (Subalgebra.inclusion_injective le)
exact .trans _ Sv _
variable (ι R)
theorem IsTranscendenceBasis.mvPolynomial [Nontrivial R] :
IsTranscendenceBasis R (X (R := R) (σ := ι)) := by
refine isTranscendenceBasis_iff_algebraicIndependent_isAlgebraic.2 ⟨algebraicIndependent_X .., ?_⟩
rw [adjoin_range_X]
set A := MvPolynomial ι R
have := Algebra.isIntegral_of_surjective (R := (⊤ : Subalgebra R A)) (B := A) (⟨⟨·, ⟨⟩⟩, rfl⟩)
infer_instance
theorem IsTranscendenceBasis.mvPolynomial' [Nonempty ι] :
IsTranscendenceBasis R (X (R := R) (σ := ι)) := by nontriviality R; exact .mvPolynomial ι R
theorem IsTranscendenceBasis.polynomial [Nonempty ι] [Subsingleton ι] :
IsTranscendenceBasis R fun _ : ι ↦ (.X : Polynomial R) := by
nontriviality R
have := (nonempty_unique ι).some
refine (isTranscendenceBasis_equiv (Equiv.equivPUnit.{_, 1} _).symm).mp <|
(MvPolynomial.pUnitAlgEquiv R).symm.isTranscendenceBasis_iff.mp ?_
convert IsTranscendenceBasis.mvPolynomial PUnit R
ext; simp
variable {ι R}
theorem IsTranscendenceBasis.sumElim_comp [NoZeroDivisors A] {x : ι → S} {y : ι' → A}
(hx : IsTranscendenceBasis R x) (hy : IsTranscendenceBasis S y) :
IsTranscendenceBasis R (Sum.elim y (algebraMap S A ∘ x)) := by
cases subsingleton_or_nontrivial R
· rw [isTranscendenceBasis_iff_of_subsingleton] at hx ⊢; infer_instance
rw [(hx.1.sumElim_comp hy.1).isTranscendenceBasis_iff_isAlgebraic]
set Rx := adjoin R (range x)
let Rxy := adjoin Rx (range y)
rw [show adjoin R (range <| Sum.elim y (algebraMap S A ∘ x)) = Rxy.restrictScalars R by
rw [← adjoin_algebraMap_image_union_eq_adjoin_adjoin, Sum.elim_range, union_comm, range_comp]]
change Algebra.IsAlgebraic Rxy A
have := hx.1.algebraMap_injective.nontrivial
have := hy.1.algebraMap_injective.nontrivial
have := hy.isAlgebraic
set Sy := adjoin S (range y)
let _ : Algebra Rxy Sy := by
refine (Subalgebra.inclusion (T := Sy.restrictScalars Rx) <| adjoin_le ?_).toAlgebra
rintro _ ⟨i, rfl⟩; exact subset_adjoin (s := range y) ⟨i, rfl⟩
have : IsScalarTower Rxy Sy A := .of_algebraMap_eq fun ⟨a, _⟩ ↦ show a = _ from rfl
have : IsScalarTower Rx Rxy Sy := .of_algebraMap_eq fun ⟨a, _⟩ ↦ Subtype.ext rfl
have : Algebra.IsAlgebraic Rxy Sy := by
refine ⟨fun ⟨a, ha⟩ ↦ adjoin_induction ?_ (fun _ ↦ .extendScalars (R := Rx) ?_ ?_)
(fun _ _ _ _ ↦ .add) (fun _ _ _ _ ↦ .mul) ha⟩
· rintro _ ⟨i, rfl⟩; exact isAlgebraic_algebraMap (⟨y i, subset_adjoin ⟨i, rfl⟩⟩ : Rxy)
· exact fun _ _ ↦ (Subtype.ext <| hy.1.algebraMap_injective <| Subtype.ext_iff.mp ·)
· exact (hx.isAlgebraic.1 _).algHom (IsScalarTower.toAlgHom Rx S Sy)
exact .trans _ Sy _
/-- If `x` is a transcendence basis of `A/R`, then it is empty if and only if
`A/R` is algebraic. -/
theorem IsTranscendenceBasis.isEmpty_iff_isAlgebraic [Nontrivial R]
(hx : IsTranscendenceBasis R x) :
IsEmpty ι ↔ Algebra.IsAlgebraic R A := by
refine ⟨fun _ ↦ ?_, fun _ ↦ hx.1.isEmpty_of_isAlgebraic⟩
have := hx.isAlgebraic
rw [Set.range_eq_empty x, adjoin_empty] at this
exact algebra_isAlgebraic_of_algebra_isAlgebraic_bot_left R A
/-- If `x` is a transcendence basis of `A/R`, then it is not empty if and only if
`A/R` is transcendental. -/
theorem IsTranscendenceBasis.nonempty_iff_transcendental [Nontrivial R]
(hx : IsTranscendenceBasis R x) :
Nonempty ι ↔ Algebra.Transcendental R A := by
rw [← not_isEmpty_iff, Algebra.transcendental_iff_not_isAlgebraic, hx.isEmpty_iff_isAlgebraic]
theorem IsTranscendenceBasis.isAlgebraic_field {F E : Type*} {x : ι → E}
[Field F] [Field E] [Algebra F E] (hx : IsTranscendenceBasis F x) :
Algebra.IsAlgebraic (IntermediateField.adjoin F (range x)) E := by
haveI := hx.isAlgebraic
set S := range x
letI : Algebra (adjoin F S) (IntermediateField.adjoin F S) :=
(Subalgebra.inclusion (IntermediateField.algebra_adjoin_le_adjoin F S)).toRingHom.toAlgebra
haveI : IsScalarTower (adjoin F S) (IntermediateField.adjoin F S) E :=
IsScalarTower.of_algebraMap_eq (congrFun rfl)
exact Algebra.IsAlgebraic.extendScalars (R := adjoin F S) (Subalgebra.inclusion_injective _)
namespace AlgebraicIndependent
variable (R A) [FaithfulSMul R A]
section
variable [NoZeroDivisors A]
private def indepMatroid : IndepMatroid A where
E := univ
Indep := AlgebraicIndepOn R id
indep_empty := (algebraicIndependent_empty_iff ..).mpr (FaithfulSMul.algebraMap_injective R A)
indep_subset _ _ := (·.mono)
indep_aug I B I_ind h B_base := by
contrapose! h
rw [← isTranscendenceBasis_iff_maximal] at B_base ⊢
cases subsingleton_or_nontrivial R
· rw [isTranscendenceBasis_iff_of_subsingleton] at B_base ⊢
by_contra this
have ⟨b, hb⟩ := B_base
exact h b ⟨hb, fun hbI ↦ this ⟨b, hbI⟩⟩ .of_subsingleton
apply I_ind.isTranscendenceBasis_iff_isAlgebraic.mpr
replace B_base := B_base.isAlgebraic
simp_rw [id_eq]
rw [Subtype.range_val] at B_base ⊢
refine ⟨fun a ↦ (B_base.1 a).adjoin_of_forall_isAlgebraic fun x hx ↦ ?_⟩
contrapose! h
exact ⟨x, hx, I_ind.insert <| by rwa [image_id]⟩
indep_maximal X _ I ind hIX := exists_maximal_algebraicIndependent I X hIX ind
subset_ground _ _ := subset_univ _
/-- If `R` is a commutative ring and `A` is a commutative `R`-algebra with injective algebra map
and no zero-divisors, then the `R`-algebraic independent subsets of `A` form a matroid. -/
def matroid : Matroid A := (indepMatroid R A).matroid.copyBase univ
(fun s ↦ IsTranscendenceBasis R ((↑) : s → A)) rfl
(fun B ↦ by simp_rw [Matroid.isBase_iff_maximal_indep, isTranscendenceBasis_iff_maximal]; rfl)
instance : (matroid R A).Finitary where
indep_of_forall_finite := algebraicIndependent_of_finite
@[simp] theorem matroid_e : (matroid R A).E = univ := rfl
theorem matroid_cRank_eq : (matroid R A).cRank = trdeg R A :=
(trdeg_eq_iSup_cardinalMk_isTranscendenceBasis _).symm
variable {R A}
theorem matroid_indep_iff {s : Set A} :
(matroid R A).Indep s ↔ AlgebraicIndepOn R id s := Iff.rfl
theorem matroid_isBase_iff {s : Set A} :
(matroid R A).IsBase s ↔ IsTranscendenceBasis R ((↑) : s → A) := Iff.rfl
end
variable {R A}
theorem matroid_isBasis_iff [IsDomain A] {s t : Set A} : (matroid R A).IsBasis s t ↔
AlgebraicIndepOn R id s ∧ s ⊆ t ∧ ∀ a ∈ t, IsAlgebraic (adjoin R s) a := by
rw [Matroid.IsBasis, maximal_iff_forall_insert fun s t h hst ↦ ⟨h.1.subset hst, hst.trans h.2⟩]
simp_rw [matroid_indep_iff, ← and_assoc, matroid_e, subset_univ, and_true]
exact and_congr_right fun h ↦ ⟨fun max a ha ↦ of_not_not fun tr ↦ max _
(fun ha ↦ tr (isAlgebraic_algebraMap (⟨a, subset_adjoin ha⟩ : adjoin R s)))
⟨.insert h.1 (by rwa [image_id]), insert_subset ha h.2⟩,
fun alg a ha h ↦ ((AlgebraicIndepOn.insert_iff ha).mp h.1).2 <| by
rw [image_id]; exact alg _ <| h.2 <| mem_insert ..⟩
open Subsingleton in
theorem matroid_isBasis_iff_of_subsingleton [Subsingleton A] {s t : Set A} :
(matroid R A).IsBasis s t ↔ s = t := by
have := (FaithfulSMul.algebraMap_injective R A).subsingleton
simp_rw [Matroid.IsBasis, matroid_indep_iff, of_subsingleton, true_and,
matroid_e, subset_univ, and_true, ← le_iff_subset, maximal_le_iff]
theorem isAlgebraic_adjoin_iff_of_matroid_isBasis [NoZeroDivisors A] {s t : Set A} {a : A}
(h : (matroid R A).IsBasis s t) : IsAlgebraic (adjoin R s) a ↔ IsAlgebraic (adjoin R t) a := by
cases subsingleton_or_nontrivial A
· apply iff_of_false <;> apply is_transcendental_of_subsingleton
have := (isDomain_iff_noZeroDivisors_and_nontrivial A).mpr ⟨inferInstance, inferInstance⟩
exact ⟨(·.adjoin_of_forall_isAlgebraic fun x hx ↦ (hx.2 <| h.1.1.2 hx.1).elim),
(·.adjoin_of_forall_isAlgebraic fun x hx ↦ (matroid_isBasis_iff.mp h).2.2 _ hx.1)⟩
theorem matroid_closure_eq [IsDomain A] {s : Set A} :
(matroid R A).closure s = algebraicClosure (adjoin R s) A := by
have ⟨B, hB⟩ := (matroid R A).exists_isBasis s
simp_rw [← hB.closure_eq_closure, hB.1.1.1.closure_eq_setOf_isBasis_insert, Set.ext_iff,
mem_setOf, matroid_isBasis_iff, ← matroid_indep_iff, hB.1.1.1, subset_insert, true_and,
SetLike.mem_coe, mem_algebraicClosure, ← isAlgebraic_adjoin_iff_of_matroid_isBasis hB,
forall_mem_insert]
exact fun _ ↦ and_iff_left fun x hx ↦ isAlgebraic_algebraMap (⟨x, subset_adjoin hx⟩ : adjoin R B)
theorem matroid_isFlat_iff [IsDomain A] {s : Set A} :
(matroid R A).IsFlat s ↔ ∃ S : Subalgebra R A, S = s ∧ ∀ a : A, IsAlgebraic S a → a ∈ s := by
rw [Matroid.isFlat_iff_closure_eq, matroid_closure_eq]
set S := algebraicClosure (adjoin R s) A
refine ⟨fun eq ↦ ⟨S.restrictScalars R, eq, fun a (h : IsAlgebraic S _) ↦ ?_⟩, ?_⟩
· rw [← eq]; exact h.restrictScalars (adjoin R s)
rintro ⟨s, rfl, hs⟩
refine Set.ext fun a ↦ ⟨(hs _ <| adjoin_eq s ▸ ·), fun h ↦ ?_⟩
exact isAlgebraic_algebraMap (A := A) (by exact (⟨a, subset_adjoin h⟩ : adjoin R s))
theorem matroid_spanning_iff [IsDomain A] {s : Set A} :
(matroid R A).Spanning s ↔ Algebra.IsAlgebraic (adjoin R s) A := by
simp_rw [Matroid.spanning_iff, matroid_e, subset_univ, and_true, eq_univ_iff_forall,
matroid_closure_eq, SetLike.mem_coe, mem_algebraicClosure, Algebra.isAlgebraic_def]
open Subsingleton -- brings the Subsingleton.to_noZeroDivisors instance into scope
theorem matroid_isFlat_of_subsingleton [Subsingleton A] (s : Set A) : (matroid R A).IsFlat s := by
simp_rw [Matroid.isFlat_iff, matroid_e, subset_univ,
and_true, matroid_isBasis_iff_of_subsingleton]
exact fun I X hIs hIX ↦ (hIX.symm.trans hIs).subset
theorem matroid_closure_of_subsingleton [Subsingleton A] (s : Set A) :
(matroid R A).closure s = s := by
simp_rw [Matroid.closure, matroid_isFlat_of_subsingleton, true_and, matroid_e, inter_univ]
exact subset_antisymm (sInter_subset_of_mem <| subset_refl s) (subset_sInter fun _ ↦ id)
theorem matroid_spanning_iff_of_subsingleton [Subsingleton A] {s : Set A} :
(matroid R A).Spanning s ↔ s = univ := by
simp_rw [Matroid.spanning_iff, matroid_closure_of_subsingleton, matroid_e, subset_univ, and_true]
end AlgebraicIndependent
/-- If `s ⊆ t` are subsets in an `R`-algebra `A` such that `s` is algebraically independent over
`R`, and `A` is algebraic over the `R`-algebra generated by `t`, then there is a transcendence
basis of `A` over `R` between `s` and `t`, provided that `A` is a domain.
This may fail if only `R` is assumed to be a domain but `A` is not, because of failure of
transitivity of algebraicity: there may exist `a : A` such that `S := R[a]` is algebraic over
`R` and `A` is algebraic over `S`, but `A` nonetheless contains a transcendental element over `R`.
The only `R`-algebraically independent subset of `{a}` is `∅`, which is not a transcendence basis.
See the docstring of `IsAlgebraic.restrictScalars_of_isIntegral` for an example. -/
theorem exists_isTranscendenceBasis_between [NoZeroDivisors A] (s t : Set A) (hst : s ⊆ t)
(hs : AlgebraicIndepOn R id s) [ht : Algebra.IsAlgebraic (adjoin R t) A] :
∃ u, s ⊆ u ∧ u ⊆ t ∧ IsTranscendenceBasis R ((↑) : u → A) := by
have := ht.nontrivial
have := Subtype.val_injective (p := (· ∈ adjoin R t)).nontrivial
have := (isDomain_iff_noZeroDivisors_and_nontrivial A).mpr ⟨inferInstance, inferInstance⟩
have := (faithfulSMul_iff_algebraMap_injective R A).mpr hs.algebraMap_injective
rw [← matroid_spanning_iff] at ht
rw [← matroid_indep_iff] at hs
have ⟨B, base, hsB, hBt⟩ := hs.exists_isBase_subset_spanning ht hst
exact ⟨B, hsB, hBt, base⟩
theorem exists_isTranscendenceBasis_subset [NoZeroDivisors A] [FaithfulSMul R A]
(s : Set A) [Algebra.IsAlgebraic (adjoin R s) A] :
∃ t, t ⊆ s ∧ IsTranscendenceBasis R ((↑) : t → A) := by
have ⟨t, _, ht⟩ := exists_isTranscendenceBasis_between ∅ s (empty_subset _)
((algebraicIndependent_empty_iff ..).mpr <| FaithfulSMul.algebraMap_injective R A)
exact ⟨t, ht⟩
theorem isAlgebraic_iff_exists_isTranscendenceBasis_subset
[IsDomain A] [FaithfulSMul R A] {s : Set A} :
Algebra.IsAlgebraic (adjoin R s) A ↔ ∃ t, t ⊆ s ∧ IsTranscendenceBasis R ((↑) : t → A) := by
simp_rw [← matroid_spanning_iff, ← matroid_isBase_iff, and_comm (a := _ ⊆ _)]
exact Matroid.spanning_iff_exists_isBase_subset (subset_univ _)
open Cardinal AlgebraicIndependent
namespace IsTranscendenceBasis
variable [Nontrivial R] [NoZeroDivisors A]
theorem lift_cardinalMk_eq_trdeg (hx : IsTranscendenceBasis R x) :
lift.{w} #ι = lift.{u} (trdeg R A) := by
have := (faithfulSMul_iff_algebraMap_injective R A).mpr hx.1.algebraMap_injective
rw [← matroid_cRank_eq, ← ((matroid_isBase_iff).mpr hx.to_subtype_range).cardinalMk_eq_cRank,
lift_mk_eq'.mpr ⟨.ofInjective _ hx.1.injective⟩]
theorem cardinalMk_eq_trdeg {ι : Type w} {x : ι → A} (hx : IsTranscendenceBasis R x) :
#ι = trdeg R A := by
rw [← lift_id #ι, lift_cardinalMk_eq_trdeg hx, lift_id]
/-- Any two transcendence bases of a domain `A` have the same cardinality.
May fail if `A` is not a domain; see https://mathoverflow.net/a/144580. -/
@[stacks 030F]
theorem lift_cardinalMk_eq (hx : IsTranscendenceBasis R x) (hy : IsTranscendenceBasis R y) :
lift.{u'} #ι = lift.{u} #ι' := by
rw [← lift_inj.{_, w}, lift_lift, lift_lift, ← lift_lift.{w, u'}, hx.lift_cardinalMk_eq_trdeg,
← lift_lift.{w, u}, hy.lift_cardinalMk_eq_trdeg, lift_lift, lift_lift]
@[stacks 030F] theorem cardinalMk_eq {ι' : Type u} {y : ι' → A}
(hx : IsTranscendenceBasis R x) (hy : IsTranscendenceBasis R y) :
#ι = #ι' := by
rw [← lift_id #ι, lift_cardinalMk_eq hx hy, lift_id]
end IsTranscendenceBasis
-- TODO: generalize to Nontrivial S
@[simp]
theorem MvPolynomial.trdeg_of_isDomain [IsDomain S] : trdeg S (MvPolynomial ι S) = lift.{v} #ι := by
have := (IsTranscendenceBasis.mvPolynomial ι S).lift_cardinalMk_eq_trdeg.symm
rwa [lift_id', ← lift_lift.{u}, lift_id] at this
-- TODO: generalize to Nontrivial R
@[simp]
theorem Polynomial.trdeg_of_isDomain [IsDomain R] : trdeg R (Polynomial R) = 1 := by
simpa using (IsTranscendenceBasis.polynomial Unit R).lift_cardinalMk_eq_trdeg.symm
-- TODO: generalize to Nontrivial S
theorem trdeg_lt_aleph0 [IsDomain R] [fin : FiniteType R S] : trdeg R S < ℵ₀ :=
have ⟨n, f, surj⟩ := FiniteType.iff_quotient_mvPolynomial''.mp fin
lift_lt.mp <| (lift_trdeg_le_of_surjective f surj).trans_lt <| by
simpa using Cardinal.nat_lt_aleph0 _
namespace Algebra.IsAlgebraic
variable (R x) (s : Set A)
variable [NoZeroDivisors A]
lemma isDomain_of_adjoin_range [Algebra.IsAlgebraic (adjoin R s) A] : IsDomain A :=
have := Algebra.IsAlgebraic.nontrivial (adjoin R s) A
(isDomain_iff_noZeroDivisors_and_nontrivial _).mpr
⟨‹_›, (Subtype.val_injective (p := (· ∈ adjoin R s))).nontrivial⟩
theorem trdeg_le_cardinalMk [alg : Algebra.IsAlgebraic (adjoin R s) A] : trdeg R A ≤ #s := by
by_cases h : Injective (algebraMap R A)
on_goal 2 => simp [trdeg_eq_zero_of_not_injective h]
have := isDomain_of_adjoin_range R s
have := (faithfulSMul_iff_algebraMap_injective R A).mpr h
rw [← matroid_spanning_iff, ← matroid_cRank_eq] at *
exact alg.cRank_le_cardinalMk
variable [FaithfulSMul R A]
theorem isTranscendenceBasis_of_lift_le_trdeg_of_finite
[Finite ι] [alg : Algebra.IsAlgebraic (adjoin R (range x)) A]
(le : lift.{w} #ι ≤ lift.{u} (trdeg R A)) : IsTranscendenceBasis R x := by
have ⟨_, h⟩ := lift_mk_le'.mp (le.trans <| lift_le.mpr <| trdeg_le_cardinalMk R (range x))
have := rangeFactorization_surjective.bijective_of_nat_card_le (Nat.card_le_card_of_injective _ h)
refine .of_subtype_range (fun _ _ ↦ (this.1 <| Subtype.ext ·)) ?_
have := isDomain_of_adjoin_range R (range x)
rw [← matroid_spanning_iff, ← matroid_cRank_eq] at *
exact alg.isBase_of_le_cRank_of_finite (lift_le.mp <| mk_range_le_lift.trans le) (finite_range x)
theorem isTranscendenceBasis_of_le_trdeg_of_finite {ι : Type w} [Finite ι] (x : ι → A)
[Algebra.IsAlgebraic (adjoin R (range x)) A] (le : #ι ≤ trdeg R A) :
IsTranscendenceBasis R x :=
isTranscendenceBasis_of_lift_le_trdeg_of_finite R x (by rwa [lift_id, lift_id])
theorem isTranscendenceBasis_of_lift_le_trdeg [Algebra.IsAlgebraic (adjoin R (range x)) A]
(fin : trdeg R A < ℵ₀) (le : lift.{w} #ι ≤ lift.{u} (trdeg R A)) :
IsTranscendenceBasis R x :=
have := mk_lt_aleph0_iff.mp (lift_lt.mp <| le.trans_lt <| (lift_lt.mpr fin).trans_eq <| by simp)
isTranscendenceBasis_of_lift_le_trdeg_of_finite R x le
theorem isTranscendenceBasis_of_le_trdeg {ι : Type w} (x : ι → A)
[Algebra.IsAlgebraic (adjoin R (range x)) A] (fin : trdeg R A < ℵ₀)
(le : #ι ≤ trdeg R A) : IsTranscendenceBasis R x :=
isTranscendenceBasis_of_lift_le_trdeg R x fin (by rwa [lift_id, lift_id])
end Algebra.IsAlgebraic
namespace AlgebraicIndependent
variable [Nontrivial R] [NoZeroDivisors A]
theorem isTranscendenceBasis_of_lift_trdeg_le (hx : AlgebraicIndependent R x)
(fin : trdeg R A < ℵ₀) (le : lift.{u} (trdeg R A) ≤ lift.{w} #ι) :
IsTranscendenceBasis R x := by
have := (faithfulSMul_iff_algebraMap_injective R A).mpr hx.algebraMap_injective
rw [← matroid_cRank_eq, ← Matroid.rankFinite_iff_cRank_lt_aleph0] at fin
exact .of_subtype_range hx.injective <| matroid_indep_iff.mpr hx.to_subtype_range
|>.isBase_of_cRank_le <| lift_le.mp <| (matroid_cRank_eq R A ▸ le).trans_eq
(mk_range_eq_of_injective hx.injective).symm
theorem isTranscendenceBasis_of_trdeg_le {ι : Type w} {x : ι → A} (hx : AlgebraicIndependent R x)
(fin : trdeg R A < ℵ₀) (le : trdeg R A ≤ #ι) : IsTranscendenceBasis R x :=
isTranscendenceBasis_of_lift_trdeg_le hx fin (by rwa [lift_id, lift_id])
theorem isTranscendenceBasis_of_lift_trdeg_le_of_finite [Finite ι] (hx : AlgebraicIndependent R x)
(le : lift.{u} (trdeg R A) ≤ lift.{w} #ι) : IsTranscendenceBasis R x :=
isTranscendenceBasis_of_lift_trdeg_le hx
(lift_lt.mp <| le.trans_lt <| by simp) le
theorem isTranscendenceBasis_of_trdeg_le_of_finite {ι : Type w} [Finite ι] {x : ι → A}
(hx : AlgebraicIndependent R x) (le : trdeg R A ≤ #ι) : IsTranscendenceBasis R x :=
isTranscendenceBasis_of_lift_trdeg_le_of_finite hx (by rwa [lift_id, lift_id])
end AlgebraicIndependent
variable (R S A)
@[stacks 030H] theorem lift_trdeg_add_eq [Nontrivial R] [NoZeroDivisors A] [FaithfulSMul R S]
[FaithfulSMul S A] : lift.{w} (trdeg R S) + lift.{v} (trdeg S A) = lift.{v} (trdeg R A) := by
have ⟨s, hs⟩ := exists_isTranscendenceBasis R S
have ⟨t, ht⟩ := exists_isTranscendenceBasis S A
have := (FaithfulSMul.algebraMap_injective S A).noZeroDivisors _ (map_zero _) (map_mul _)
have := (FaithfulSMul.algebraMap_injective R S).nontrivial
rw [← hs.cardinalMk_eq_trdeg, ← ht.cardinalMk_eq_trdeg, ← lift_umax.{w}, add_comm,
← (hs.sumElim_comp ht).lift_cardinalMk_eq_trdeg, mk_sum, lift_add, lift_lift, lift_lift]
@[stacks 030H] theorem trdeg_add_eq [Nontrivial R] {A : Type v} [CommRing A] [NoZeroDivisors A]
[Algebra R A] [Algebra S A] [FaithfulSMul R S] [FaithfulSMul S A] [IsScalarTower R S A] :
trdeg R S + trdeg S A = trdeg R A := by
rw [← (trdeg R S).lift_id, ← (trdeg S A).lift_id, ← (trdeg R A).lift_id]
exact lift_trdeg_add_eq R S A |
.lake/packages/mathlib/Mathlib/RingTheory/AlgebraicIndependent/Adjoin.lean | import Mathlib.FieldTheory.IntermediateField.Adjoin.Algebra
import Mathlib.RingTheory.AlgebraicIndependent.Defs
/-!
# Algebraic Independence
This file concerns adjoining an algebraic independent family to a field.
## Main definitions
* `AlgebraicIndependent.aevalEquivField` - The canonical isomorphism from the rational function
field ring to the intermediate field generated by an algebraic independent family.
* `AlgebraicIndependent.reprField` - The canonical map from the intermediate field generated by an
algebraic independent family into the rational function field. It is the inverse of
`AlgebraicIndependent.aevalEquivField`.
-/
noncomputable section
open Function Set Subalgebra MvPolynomial Algebra
namespace AlgebraicIndependent
variable {ι : Type*}
variable {F E : Type*} {x : ι → E} [Field F] [Field E] [Algebra F E] (hx : AlgebraicIndependent F x)
include hx
/-- Canonical isomorphism between rational function field and the
intermediate field generated by algebraically independent elements. -/
def aevalEquivField :
FractionRing (MvPolynomial ι F) ≃ₐ[F] ↥(IntermediateField.adjoin F (range x)) :=
let i := IsFractionRing.liftAlgHom (K := FractionRing (MvPolynomial ι F))
(algebraicIndependent_iff_injective_aeval.2 hx)
(show _ ≃ₐ[F] i.fieldRange from AlgEquiv.ofInjectiveField i).trans <|
IntermediateField.equivOfEq <|
IsFractionRing.algHom_fieldRange_eq_of_comp_eq_of_range_eq (g := aeval x) (f := i)
(by ext <;> simp [i]) (Algebra.adjoin_range_eq_range_aeval F x).symm
@[simp]
theorem aevalEquivField_apply_coe (a : FractionRing (MvPolynomial ι F)) :
hx.aevalEquivField a =
IsFractionRing.lift (algebraicIndependent_iff_injective_aeval.2 hx) a := rfl
theorem aevalEquivField_algebraMap_apply_coe (a : MvPolynomial ι F) :
hx.aevalEquivField (algebraMap _ _ a) = aeval x a := by
simp
/-- The canonical map from the intermediate field generated by an algebraic independent family
into the rational function field. -/
def reprField : IntermediateField.adjoin F (range x) →ₐ[F] FractionRing (MvPolynomial ι F) :=
hx.aevalEquivField.symm
@[simp]
theorem lift_reprField (p) :
IsFractionRing.lift (algebraicIndependent_iff_injective_aeval.2 hx) (hx.reprField p) = p :=
Subtype.ext_iff.1 (AlgEquiv.apply_symm_apply hx.aevalEquivField p)
theorem liftAlgHom_comp_reprField :
(IsFractionRing.liftAlgHom (algebraicIndependent_iff_injective_aeval.2 hx)).comp hx.reprField =
IntermediateField.val _ :=
AlgHom.ext <| hx.lift_reprField
end AlgebraicIndependent |
.lake/packages/mathlib/Mathlib/RingTheory/TwoSidedIdeal/Instances.lean | import Mathlib.Algebra.Ring.Defs
import Mathlib.RingTheory.NonUnitalSubring.Defs
import Mathlib.RingTheory.TwoSidedIdeal.Basic
/-!
# Additional instances for two-sided ideals.
-/
instance {R} [NonUnitalNonAssocRing R] : NonUnitalSubringClass (TwoSidedIdeal R) R where
mul_mem _ hb := TwoSidedIdeal.mul_mem_left _ _ _ hb |
.lake/packages/mathlib/Mathlib/RingTheory/TwoSidedIdeal/Basic.lean | import Mathlib.Tactic.Abel
import Mathlib.Algebra.Ring.Opposite
import Mathlib.GroupTheory.GroupAction.SubMulAction
import Mathlib.RingTheory.Congruence.Opposite
/-!
# Two Sided Ideals
In this file, for any `Ring R`, we reinterpret `I : RingCon R` as a two-sided-ideal of a ring.
## Main definitions and results
* `TwoSidedIdeal`: For any `NonUnitalNonAssocRing R`, `TwoSidedIdeal R` is a wrapper around
`RingCon R`.
* `TwoSidedIdeal.setLike`: Every `I : TwoSidedIdeal R` can be interpreted as a set of `R` where
`x ∈ I` if and only if `I.ringCon x 0`.
* `TwoSidedIdeal.addCommGroup`: Every `I : TwoSidedIdeal R` is an abelian group.
-/
assert_not_exists LinearMap
open MulOpposite
section definitions
/--
A two-sided ideal of a ring `R` is a subset of `R` that contains `0` and is closed under addition,
negation, and absorbs multiplication on both sides.
-/
structure TwoSidedIdeal (R : Type*) [NonUnitalNonAssocRing R] where
/-- every two-sided-ideal is induced by a congruence relation on the ring. -/
ringCon : RingCon R
end definitions
namespace TwoSidedIdeal
section NonUnitalNonAssocRing
variable {R : Type*} [NonUnitalNonAssocRing R] (I : TwoSidedIdeal R)
instance [Nontrivial R] : Nontrivial (TwoSidedIdeal R) := by
obtain ⟨I, J, h⟩ : Nontrivial (RingCon R) := inferInstance
exact ⟨⟨I⟩, ⟨J⟩, by contrapose! h; aesop⟩
instance setLike : SetLike (TwoSidedIdeal R) R where
coe t := {r | t.ringCon r 0}
coe_injective' := by
rintro ⟨t₁⟩ ⟨t₂⟩ (h : {x | _} = {x | _})
congr 1
refine RingCon.ext fun a b ↦ ⟨fun H ↦ ?_, fun H ↦ ?_⟩
· have H' : a - b ∈ {x | t₁ x 0} := sub_self b ▸ t₁.sub H (t₁.refl b)
rw [h] at H'
convert t₂.add H' (t₂.refl b) using 1 <;> abel
· have H' : a - b ∈ {x | t₂ x 0} := sub_self b ▸ t₂.sub H (t₂.refl b)
rw [← h] at H'
convert t₁.add H' (t₁.refl b) using 1 <;> abel
lemma mem_iff (x : R) : x ∈ I ↔ I.ringCon x 0 := Iff.rfl
@[simp]
lemma mem_mk {x : R} {c : RingCon R} : x ∈ mk c ↔ c x 0 := Iff.rfl
@[simp, norm_cast]
lemma coe_mk {c : RingCon R} : (mk c : Set R) = {x | c x 0} := rfl
lemma rel_iff (x y : R) : I.ringCon x y ↔ x - y ∈ I := by
rw [mem_iff]
constructor
· intro h; convert I.ringCon.sub h (I.ringCon.refl y); abel
· intro h; convert I.ringCon.add h (I.ringCon.refl y) <;> abel
/--
the coercion from two-sided-ideals to sets is an order embedding
-/
@[simps]
def coeOrderEmbedding : TwoSidedIdeal R ↪o Set R where
toFun := SetLike.coe
inj' := SetLike.coe_injective
map_rel_iff' {I J} := ⟨fun (h : (I : Set R) ⊆ (J : Set R)) _ h' ↦ h h', fun h _ h' ↦ h h'⟩
lemma le_iff {I J : TwoSidedIdeal R} : I ≤ J ↔ (I : Set R) ⊆ (J : Set R) := Iff.rfl
/-- Two-sided-ideals corresponds to congruence relations on a ring. -/
@[simps apply symm_apply]
def orderIsoRingCon : TwoSidedIdeal R ≃o RingCon R where
toFun := TwoSidedIdeal.ringCon
invFun := .mk
map_rel_iff' {I J} := Iff.symm <| le_iff.trans ⟨fun h x y r => by rw [rel_iff] at r ⊢; exact h r,
fun h x hx => by rw [SetLike.mem_coe, mem_iff] at hx ⊢; exact h hx⟩
lemma ringCon_injective : Function.Injective (TwoSidedIdeal.ringCon (R := R)) := by
rintro ⟨x⟩ ⟨y⟩ rfl; rfl
lemma ringCon_le_iff {I J : TwoSidedIdeal R} : I ≤ J ↔ I.ringCon ≤ J.ringCon :=
orderIsoRingCon.map_rel_iff.symm
@[ext]
lemma ext {I J : TwoSidedIdeal R} (h : ∀ x, x ∈ I ↔ x ∈ J) : I = J :=
coeOrderEmbedding.injective (Set.ext h)
lemma lt_iff (I J : TwoSidedIdeal R) : I < J ↔ (I : Set R) ⊂ (J : Set R) := by
rw [lt_iff_le_and_ne, Set.ssubset_iff_subset_ne, le_iff]
simp
lemma zero_mem : 0 ∈ I := I.ringCon.refl 0
lemma add_mem {x y} (hx : x ∈ I) (hy : y ∈ I) : x + y ∈ I := by simpa using I.ringCon.add hx hy
lemma neg_mem {x} (hx : x ∈ I) : -x ∈ I := by simpa using I.ringCon.neg hx
instance : AddSubgroupClass (TwoSidedIdeal R) R where
zero_mem := zero_mem
add_mem := @add_mem _ _
neg_mem := @neg_mem _ _
lemma sub_mem {x y} (hx : x ∈ I) (hy : y ∈ I) : x - y ∈ I := _root_.sub_mem hx hy
lemma mul_mem_left (x y) (hy : y ∈ I) : x * y ∈ I := by
simpa using I.ringCon.mul (I.ringCon.refl x) hy
lemma mul_mem_right (x y) (hx : x ∈ I) : x * y ∈ I := by
simpa using I.ringCon.mul hx (I.ringCon.refl y)
lemma nsmul_mem {x} (n : ℕ) (hx : x ∈ I) : n • x ∈ I := _root_.nsmul_mem hx _
lemma zsmul_mem {x} (n : ℤ) (hx : x ∈ I) : n • x ∈ I := _root_.zsmul_mem hx _
/--
The "set-theoretic-way" of constructing a two-sided ideal by providing:
- the underlying set `S`;
- a proof that `0 ∈ S`;
- a proof that `x + y ∈ S` if `x ∈ S` and `y ∈ S`;
- a proof that `-x ∈ S` if `x ∈ S`;
- a proof that `x * y ∈ S` if `y ∈ S`;
- a proof that `x * y ∈ S` if `x ∈ S`.
-/
def mk' (carrier : Set R)
(zero_mem : 0 ∈ carrier)
(add_mem : ∀ {x y}, x ∈ carrier → y ∈ carrier → x + y ∈ carrier)
(neg_mem : ∀ {x}, x ∈ carrier → -x ∈ carrier)
(mul_mem_left : ∀ {x y}, y ∈ carrier → x * y ∈ carrier)
(mul_mem_right : ∀ {x y}, x ∈ carrier → x * y ∈ carrier) : TwoSidedIdeal R where
ringCon :=
{ r := fun x y ↦ x - y ∈ carrier
iseqv :=
{ refl := fun x ↦ by simpa using zero_mem
symm := fun h ↦ by simpa using neg_mem h
trans := fun {x y z} h1 h2 ↦ by
simpa only [show x - z = (x - y) + (y - z) by abel] using add_mem h1 h2 }
mul' := fun {a b c d} (h1 : a - b ∈ carrier) (h2 : c - d ∈ carrier) ↦ show _ ∈ carrier by
rw [show a * c - b * d = a * (c - d) + (a - b) * d by rw [mul_sub, sub_mul]; abel]
exact add_mem (mul_mem_left h2) (mul_mem_right h1)
add' := fun {a b c d} (h1 : a - b ∈ carrier) (h2 : c - d ∈ carrier) ↦ show _ ∈ carrier by
rw [show a + c - (b + d) = (a - b) + (c - d) by abel]
exact add_mem h1 h2 }
@[simp]
lemma mem_mk' (carrier : Set R) (zero_mem add_mem neg_mem mul_mem_left mul_mem_right) (x : R) :
x ∈ mk' carrier zero_mem add_mem neg_mem mul_mem_left mul_mem_right ↔ x ∈ carrier := by
rw [mem_iff]
simp [mk']
set_option linter.docPrime false in
@[simp]
lemma coe_mk' (carrier : Set R) (zero_mem add_mem neg_mem mul_mem_left mul_mem_right) :
(mk' carrier zero_mem add_mem neg_mem mul_mem_left mul_mem_right : Set R) = carrier :=
Set.ext <| mem_mk' carrier zero_mem add_mem neg_mem mul_mem_left mul_mem_right
instance : SMulMemClass (TwoSidedIdeal R) R R where
smul_mem _ _ h := TwoSidedIdeal.mul_mem_left _ _ _ h
instance : SMulMemClass (TwoSidedIdeal R) Rᵐᵒᵖ R where
smul_mem _ _ h := TwoSidedIdeal.mul_mem_right _ _ _ h
instance : Add I where add x y := ⟨x.1 + y.1, I.add_mem x.2 y.2⟩
instance : Zero I where zero := ⟨0, I.zero_mem⟩
instance : SMul ℕ I where smul n x := ⟨n • x.1, I.nsmul_mem n x.2⟩
instance : Neg I where neg x := ⟨-x.1, I.neg_mem x.2⟩
instance : Sub I where sub x y := ⟨x.1 - y.1, I.sub_mem x.2 y.2⟩
instance : SMul ℤ I where smul n x := ⟨n • x.1, I.zsmul_mem n x.2⟩
instance addCommGroup : AddCommGroup I :=
Function.Injective.addCommGroup _ Subtype.coe_injective
rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
/-- The coercion into the ring as a `AddMonoidHom` -/
@[simps]
def coeAddMonoidHom : I →+ R where
toFun := (↑)
map_zero' := rfl
map_add' _ _ := rfl
/-- If `I` is a two-sided ideal of `R`, then `{op x | x ∈ I}` is a two-sided ideal in `Rᵐᵒᵖ`. -/
@[simps]
def op (I : TwoSidedIdeal R) : TwoSidedIdeal Rᵐᵒᵖ where
ringCon := I.ringCon.op
@[simp]
lemma mem_op_iff {I : TwoSidedIdeal R} {x : Rᵐᵒᵖ} : x ∈ I.op ↔ x.unop ∈ I :=
I.ringCon.comm'
@[simp, norm_cast]
lemma coe_op {I : TwoSidedIdeal R} : (I.op : Set Rᵐᵒᵖ) = MulOpposite.unop ⁻¹' I :=
Set.ext fun _ => mem_op_iff
/-- If `I` is a two-sided ideal of `Rᵐᵒᵖ`, then `{x.unop | x ∈ I}` is a two-sided ideal in `R`. -/
@[simps]
def unop (I : TwoSidedIdeal Rᵐᵒᵖ) : TwoSidedIdeal R where
ringCon := I.ringCon.unop
@[simp]
lemma mem_unop_iff {I : TwoSidedIdeal Rᵐᵒᵖ} {x : R} : x ∈ I.unop ↔ MulOpposite.op x ∈ I :=
I.ringCon.comm'
@[simp, norm_cast]
lemma coe_unop {I : TwoSidedIdeal Rᵐᵒᵖ} : (I.unop : Set R) = MulOpposite.op ⁻¹' I :=
Set.ext fun _ => mem_unop_iff
/--
Two-sided-ideals of `A` and that of `Aᵒᵖ` corresponds bijectively to each other.
-/
@[simps]
def opOrderIso : TwoSidedIdeal R ≃o TwoSidedIdeal Rᵐᵒᵖ where
toFun := op
invFun := unop
map_rel_iff' {I' J'} := by simpa [ringCon_le_iff] using RingCon.opOrderIso.map_rel_iff
end NonUnitalNonAssocRing
end TwoSidedIdeal |
.lake/packages/mathlib/Mathlib/RingTheory/TwoSidedIdeal/Operations.lean | import Mathlib.Algebra.Group.Subgroup.Map
import Mathlib.Algebra.Module.Opposite
import Mathlib.Algebra.Module.Submodule.Lattice
import Mathlib.RingTheory.Congruence.Opposite
import Mathlib.RingTheory.Ideal.Defs
import Mathlib.RingTheory.TwoSidedIdeal.Lattice
import Mathlib.Algebra.Group.Pointwise.Set.Basic
/-!
# Operations on two-sided ideals
This file defines operations on two-sided ideals of a ring `R`.
## Main definitions and results
- `TwoSidedIdeal.span`: the span of `s ⊆ R` is the smallest two-sided ideal containing the set.
- `TwoSidedIdeal.mem_span_iff_mem_addSubgroup_closure_nonunital`: in an associative but non-unital
ring, an element `x` is in the two-sided ideal spanned by `s` if and only if `x` is in the closure
of `s ∪ {y * a | y ∈ s, a ∈ R} ∪ {a * y | y ∈ s, a ∈ R} ∪ {a * y * b | y ∈ s, a, b ∈ R}` as an
additive subgroup.
- `TwoSidedIdeal.mem_span_iff_mem_addSubgroup_closure`: in a unital and associative ring, an
element `x` is in the two-sided ideal spanned by `s` if and only if `x` is in the closure of
`{a*y*b | a, b ∈ R, y ∈ s}` as an additive subgroup.
- `TwoSidedIdeal.comap`: pullback of a two-sided ideal; defined as the preimage of a
two-sided ideal.
- `TwoSidedIdeal.map`: pushforward of a two-sided ideal; defined as the span of the image of a
two-sided ideal.
- `TwoSidedIdeal.ker`: the kernel of a ring homomorphism as a two-sided ideal.
- `TwoSidedIdeal.gc`: `fromIdeal` and `asIdeal` form a Galois connection where
`fromIdeal : Ideal R → TwoSidedIdeal R` is defined as the smallest two-sided ideal containing an
ideal and `asIdeal : TwoSidedIdeal R → Ideal R` the inclusion map.
-/
namespace TwoSidedIdeal
section NonUnitalNonAssocRing
variable {R S : Type*} [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S]
variable {F : Type*} [FunLike F R S]
variable (f : F)
/--
The smallest two-sided ideal containing a set.
-/
abbrev span (s : Set R) : TwoSidedIdeal R :=
{ ringCon := ringConGen (fun a b ↦ a - b ∈ s) }
lemma subset_span {s : Set R} : s ⊆ (span s : Set R) := by
intro x hx
rw [SetLike.mem_coe, mem_iff]
exact RingConGen.Rel.of _ _ (by simpa using hx)
lemma mem_span_iff {s : Set R} {x} :
x ∈ span s ↔ ∀ (I : TwoSidedIdeal R), s ⊆ I → x ∈ I := by
refine ⟨?_, fun h => h _ subset_span⟩
delta span
rw [RingCon.ringConGen_eq]
intro h I hI
refine sInf_le (α := RingCon R) ?_ h
intro x y hxy
specialize hI hxy
rwa [SetLike.mem_coe, ← rel_iff] at hI
lemma span_mono {s t : Set R} (h : s ⊆ t) : span s ≤ span t := by
intro x hx
rw [mem_span_iff] at hx ⊢
exact fun I hI => hx I <| h.trans hI
lemma span_le {s : Set R} {I : TwoSidedIdeal R} : span s ≤ I ↔ s ⊆ I := by
rw [TwoSidedIdeal.ringCon_le_iff, RingCon.gi _ |>.gc]
exact ⟨fun h x hx ↦ by aesop, fun h x y hxy ↦ (rel_iff I x y).mpr (h hxy)⟩
/-- An induction principle for span membership.
If `p` holds for 0 and all elements of `s`,
and is preserved under addition and left and right multiplication,
then `p` holds for all elements of the span of `s`. -/
@[elab_as_elim]
theorem span_induction {s : Set R}
{p : (x : R) → x ∈ TwoSidedIdeal.span s → Prop}
(mem : ∀ (x) (h : x ∈ s), p x (subset_span h))
(zero : p 0 (zero_mem _))
(add : ∀ x y hx hy, p x hx → p y hy → p (x + y) (add_mem _ hx hy))
(neg : ∀ x hx, p x hx → p (-x) (neg_mem _ hx))
(left_absorb : ∀ a x hx, p x hx → p (a * x) (mul_mem_left _ _ _ hx))
(right_absorb : ∀ b x hx, p x hx → p (x * b) (mul_mem_right _ _ _ hx))
{x : R} (hx : x ∈ span s) : p x hx :=
let J : TwoSidedIdeal R := .mk'
{x | ∃ hx, p x hx}
⟨zero_mem _, zero⟩
(fun ⟨hx1, hx2⟩ ⟨hy1, hy2⟩ ↦ ⟨add_mem _ hx1 hy1, add _ _ hx1 hy1 hx2 hy2⟩)
(fun ⟨hx1, hx2⟩ ↦ ⟨neg_mem _ hx1, neg _ hx1 hx2⟩)
(fun {x' y'} ⟨hy1, hy2⟩ ↦ ⟨mul_mem_left _ _ _ hy1, left_absorb _ _ _ hy2⟩)
(fun {x' y'} ⟨hx1, hx2⟩ ↦ ⟨mul_mem_right _ _ _ hx1, right_absorb _ _ _ hx2⟩)
span_le (s := s) (I := J) |>.2
(fun x hx ↦ ⟨by simpa using (mem_span_iff.2 fun I a ↦ a hx), by simp_all⟩) hx
|>.elim fun _ ↦ by simp
/--
Pushout of a two-sided ideal. Defined as the span of the image of a two-sided ideal under a ring
homomorphism.
-/
def map (I : TwoSidedIdeal R) : TwoSidedIdeal S :=
span (f '' I)
lemma map_mono {I J : TwoSidedIdeal R} (h : I ≤ J) :
map f I ≤ map f J :=
span_mono <| Set.image_mono h
variable [NonUnitalRingHomClass F R S]
/--
Preimage of a two-sided ideal, as a two-sided ideal. -/
def comap : TwoSidedIdeal S →o TwoSidedIdeal R where
toFun I := ⟨I.ringCon.comap f⟩
monotone' := by
intro I J h
rw [le_iff] at h
intro x
specialize @h (f x)
simpa [mem_iff, RingCon.comap]
lemma comap_le_comap {I J : TwoSidedIdeal S} (h : I ≤ J) :
comap f I ≤ comap f J :=
(comap f).monotone h
lemma mem_comap {I : TwoSidedIdeal S} {x : R} :
x ∈ I.comap f ↔ f x ∈ I := by
simp [comap, RingCon.comap, mem_iff]
/--
If `R` and `S` are isomorphic as rings, then two-sided ideals of `R` and two-sided ideals of `S` are
order isomorphic.
-/
def _root_.RingEquiv.mapTwoSidedIdeal (e : R ≃+* S) : TwoSidedIdeal R ≃o TwoSidedIdeal S :=
OrderIso.ofHomInv (comap e.symm) (comap e) (by ext; simp [mem_comap])
(by ext; simp [mem_comap])
lemma _root_.RingEquiv.mapTwoSidedIdeal_apply (e : R ≃+* S) (I : TwoSidedIdeal R) :
e.mapTwoSidedIdeal I = I.comap e.symm := rfl
lemma _root_.RingEquiv.mapTwoSidedIdeal_symm (e : R ≃+* S) :
e.mapTwoSidedIdeal.symm = e.symm.mapTwoSidedIdeal := rfl
end NonUnitalNonAssocRing
section NonAssocRing
variable {R S T : Type*}
variable [NonAssocRing R] [NonAssocRing S] [NonAssocRing T]
lemma comap_comap (I : TwoSidedIdeal T) (f : R →+* S) (g : S →+* T) :
(I.comap g).comap f = I.comap (g.comp f) := by
ext; simp [mem_comap]
end NonAssocRing
section NonUnitalRing
variable {R : Type*} [NonUnitalRing R]
open AddSubgroup in
/-- If `s : Set R` is absorbing under multiplication, then its `TwoSidedIdeal.span` coincides with
its `AddSubgroup.closure`, as sets. -/
lemma mem_span_iff_mem_addSubgroup_closure_absorbing {s : Set R}
(h_left : ∀ x y, y ∈ s → x * y ∈ s) (h_right : ∀ y x, y ∈ s → y * x ∈ s) {z : R} :
z ∈ span s ↔ z ∈ closure s := by
have h_left' {x y} (hy : y ∈ closure s) : x * y ∈ closure s := by
have := (AddMonoidHom.mulLeft x).map_closure s ▸ mem_map_of_mem _ hy
refine closure_mono ?_ this
rintro - ⟨y, hy, rfl⟩
exact h_left x y hy
have h_right' {y x} (hy : y ∈ closure s) : y * x ∈ closure s := by
have := (AddMonoidHom.mulRight x).map_closure s ▸ mem_map_of_mem _ hy
refine closure_mono ?_ this
rintro - ⟨y, hy, rfl⟩
exact h_right y x hy
let I : TwoSidedIdeal R := .mk' (closure s) (AddSubgroup.zero_mem _)
(AddSubgroup.add_mem _) (AddSubgroup.neg_mem _) h_left' h_right'
suffices z ∈ span s ↔ z ∈ I by simpa only [I, mem_mk', SetLike.mem_coe]
rw [mem_span_iff]
-- Suppose that for every ideal `J` with `s ⊆ J`, then `z ∈ J`. Apply this to `I` to get `z ∈ I`.
refine ⟨fun h ↦ h I fun x hx ↦ ?mem_closure_of_forall, fun hz J hJ ↦ ?mem_ideal_of_subset⟩
case mem_closure_of_forall => simpa only [I, SetLike.mem_coe, mem_mk'] using subset_closure hx
/- Conversely, suppose that `z ∈ I` and that `J` is any ideal containing `s`. Then by the
induction principle for `AddSubgroup`, we must also have `z ∈ J`. -/
case mem_ideal_of_subset =>
simp only [I, SetLike.mem_coe, mem_mk'] at hz
induction hz using closure_induction with
| mem x hx => exact hJ hx
| zero => exact zero_mem _
| add x y _ _ hx hy => exact J.add_mem hx hy
| neg x _ hx => exact J.neg_mem hx
open Pointwise Set
lemma set_mul_subset {s : Set R} {I : TwoSidedIdeal R} (h : s ⊆ I) (t : Set R) :
t * s ⊆ I := by
rintro - ⟨r, -, x, hx, rfl⟩
exact mul_mem_left _ _ _ (h hx)
lemma subset_mul_set {s : Set R} {I : TwoSidedIdeal R} (h : s ⊆ I) (t : Set R) :
s * t ⊆ I := by
rintro - ⟨x, hx, r, -, rfl⟩
exact mul_mem_right _ _ _ (h hx)
lemma mem_span_iff_mem_addSubgroup_closure_nonunital {s : Set R} {z : R} :
z ∈ span s ↔ z ∈ AddSubgroup.closure (s ∪ s * univ ∪ univ * s ∪ univ * s * univ) := by
trans z ∈ span (s ∪ s * univ ∪ univ * s ∪ univ * s * univ)
· refine ⟨(span_mono (by simp only [Set.union_assoc, Set.subset_union_left]) ·), fun h ↦ ?_⟩
refine mem_span_iff.mp h (span s) ?_
simp only [union_subset_iff, union_assoc]
exact ⟨subset_span, subset_mul_set subset_span _, set_mul_subset subset_span _,
subset_mul_set (set_mul_subset subset_span _) _⟩
· refine mem_span_iff_mem_addSubgroup_closure_absorbing ?_ ?_
· rintro x y (((hy | ⟨y, hy, r, -, rfl⟩) | ⟨r, -, y, hy, rfl⟩) |
⟨-, ⟨r', -, y, hy, rfl⟩, r, -, rfl⟩)
· exact .inl <| .inr <| ⟨x, mem_univ _, y, hy, rfl⟩
· exact .inr <| ⟨x * y, ⟨x, mem_univ _, y, hy, rfl⟩, r, mem_univ _, mul_assoc ..⟩
· exact .inl <| .inr <| ⟨x * r, mem_univ _, y, hy, mul_assoc ..⟩
· refine .inr <| ⟨x * r' * y, ⟨x * r', mem_univ _, y, hy, ?_⟩, ⟨r, mem_univ _, ?_⟩⟩
all_goals simp [mul_assoc]
· rintro y x (((hy | ⟨y, hy, r, -, rfl⟩) | ⟨r, -, y, hy, rfl⟩) |
⟨-, ⟨r', -, y, hy, rfl⟩, r, -, rfl⟩)
· exact .inl <| .inl <| .inr ⟨y, hy, x, mem_univ _, rfl⟩
· exact .inl <| .inl <| .inr ⟨y, hy, r * x, mem_univ _, (mul_assoc ..).symm⟩
· exact .inr <| ⟨r * y, ⟨r, mem_univ _, y, hy, rfl⟩, x, mem_univ _, rfl⟩
· refine .inr <| ⟨r' * y, ⟨r', mem_univ _, y, hy, rfl⟩, r * x, mem_univ _, ?_⟩
simp [mul_assoc]
end NonUnitalRing
section Ring
variable {R : Type*} [Ring R]
open Pointwise Set in
lemma mem_span_iff_mem_addSubgroup_closure {s : Set R} {z : R} :
z ∈ span s ↔ z ∈ AddSubgroup.closure (univ * s * univ) := by
trans z ∈ span (univ * s * univ)
· refine ⟨(span_mono (fun x hx ↦ ?_) ·), fun hz ↦ ?_⟩
· exact ⟨1 * x, ⟨1, mem_univ _, x, hx, rfl⟩, 1, mem_univ _, by simp⟩
· exact mem_span_iff.mp hz (span s) <| subset_mul_set (set_mul_subset subset_span _) _
· refine mem_span_iff_mem_addSubgroup_closure_absorbing ?_ ?_
· intro x y hy
rw [mul_assoc] at hy ⊢
obtain ⟨r, -, y, hy, rfl⟩ := hy
exact ⟨x * r, mem_univ _, y, hy, mul_assoc ..⟩
· rintro - x ⟨y, hy, r, -, rfl⟩
exact ⟨y, hy, r * x, mem_univ _, (mul_assoc ..).symm⟩
variable (I : TwoSidedIdeal R)
instance : SMul R I where smul r x := ⟨r • x.1, I.mul_mem_left _ _ x.2⟩
instance : SMul Rᵐᵒᵖ I where smul r x := ⟨r • x.1, I.mul_mem_right _ _ x.2⟩
instance leftModule : Module R I :=
Function.Injective.module _ (coeAddMonoidHom I) Subtype.coe_injective fun _ _ ↦ rfl
@[simp]
lemma coe_smul {r : R} {x : I} : (r • x : R) = r * (x : R) := rfl
instance rightModule : Module Rᵐᵒᵖ I :=
Function.Injective.module _ (coeAddMonoidHom I) Subtype.coe_injective fun _ _ ↦ rfl
@[simp]
lemma coe_mop_smul {r : Rᵐᵒᵖ} {x : I} : (r • x : R) = (x : R) * r.unop := rfl
instance : SMulCommClass R Rᵐᵒᵖ I where
smul_comm r s x := Subtype.ext <| smul_comm r s x.1
/--
For any `I : RingCon R`, when we view it as an ideal, `I.subtype` is the injective `R`-linear map
`I → R`.
-/
@[simps]
def subtype : I →ₗ[R] R where
toFun x := x.1
map_add' _ _ := rfl
map_smul' _ _ := rfl
theorem subtype_injective : Function.Injective (subtype I) :=
Subtype.coe_injective
@[simp]
theorem coe_subtype : ⇑(subtype I) = Subtype.val :=
rfl
/--
For any `RingCon R`, when we view it as an ideal in `Rᵒᵖ`, `subtype` is the injective `Rᵐᵒᵖ`-linear
map `I → Rᵐᵒᵖ`.
-/
@[simps]
def subtypeMop : I →ₗ[Rᵐᵒᵖ] Rᵐᵒᵖ where
toFun x := MulOpposite.op x.1
map_add' _ _ := rfl
map_smul' _ _ := rfl
theorem subtypeMop_injective : Function.Injective (subtypeMop I) :=
MulOpposite.op_injective.comp Subtype.coe_injective
/-- Given an ideal `I`, `span I` is the smallest two-sided ideal containing `I`. -/
def fromIdeal : Ideal R →o TwoSidedIdeal R where
toFun I := span I
monotone' _ _ := span_mono
lemma mem_fromIdeal {I : Ideal R} {x : R} :
x ∈ fromIdeal I ↔ x ∈ span I := by simp [fromIdeal]
/-- Every two-sided ideal is also a left ideal. -/
def asIdeal : TwoSidedIdeal R →o Ideal R where
toFun I :=
{ carrier := I
add_mem' := I.add_mem
zero_mem' := I.zero_mem
smul_mem' := fun r x hx => I.mul_mem_left r x hx }
monotone' _ _ h _ h' := h h'
@[simp]
lemma mem_asIdeal {I : TwoSidedIdeal R} {x : R} :
x ∈ asIdeal I ↔ x ∈ I := by simp [asIdeal]
lemma gc : GaloisConnection fromIdeal (asIdeal (R := R)) :=
fun I J => ⟨fun h x hx ↦ h <| mem_span_iff.2 fun _ H ↦ H hx, fun h x hx ↦ by
simp only [fromIdeal, OrderHom.coe_mk, mem_span_iff] at hx
exact hx _ h⟩
@[simp]
lemma coe_asIdeal {I : TwoSidedIdeal R} : (asIdeal I : Set R) = I := rfl
@[simp] lemma bot_asIdeal : (⊥ : TwoSidedIdeal R).asIdeal = ⊥ := rfl
@[simp] lemma top_asIdeal : (⊤ : TwoSidedIdeal R).asIdeal = ⊤ := rfl
instance (I : TwoSidedIdeal R) : I.asIdeal.IsTwoSided :=
⟨fun _ ↦ by simpa using I.mul_mem_right _ _⟩
/-- Every two-sided ideal is also a right ideal. -/
def asIdealOpposite : TwoSidedIdeal R →o Ideal Rᵐᵒᵖ where
toFun I := asIdeal ⟨I.ringCon.op⟩
monotone' I J h x h' := by
simp only [mem_asIdeal, mem_iff, RingCon.op_iff, MulOpposite.unop_zero] at h' ⊢
exact J.rel_iff _ _ |>.2 <| h <| I.rel_iff 0 x.unop |>.1 h'
lemma mem_asIdealOpposite {I : TwoSidedIdeal R} {x : Rᵐᵒᵖ} :
x ∈ asIdealOpposite I ↔ x.unop ∈ I := by
simpa [asIdealOpposite, asIdeal, TwoSidedIdeal.mem_iff, RingCon.op_iff] using
⟨I.ringCon.symm, I.ringCon.symm⟩
end Ring
section CommRing
variable {R : Type*} [CommRing R]
/--
When the ring is commutative, two-sided ideals are exactly the same as left ideals.
-/
def orderIsoIdeal : TwoSidedIdeal R ≃o Ideal R where
toFun := asIdeal
invFun := fromIdeal
map_rel_iff' := ⟨fun h _ hx ↦ h hx, fun h ↦ asIdeal.monotone' h⟩
left_inv _ := SetLike.ext fun _ ↦ mem_span_iff.trans <| by aesop
right_inv J := SetLike.ext fun x ↦ mem_span_iff.trans
⟨fun h ↦ mem_mk' _ _ _ _ _ _ _ |>.1 <| h (mk'
J J.zero_mem J.add_mem J.neg_mem (J.mul_mem_left _) (J.mul_mem_right _))
(fun x => by simp), by aesop⟩
end CommRing
end TwoSidedIdeal
namespace Ideal
variable {R : Type*} [Ring R]
/-- Bundle an `Ideal` that is already two-sided as a `TwoSidedIdeal`. -/
def toTwoSided (I : Ideal R) [I.IsTwoSided] : TwoSidedIdeal R :=
TwoSidedIdeal.mk' I I.zero_mem I.add_mem I.neg_mem (I.smul_mem _) (I.mul_mem_right _)
@[simp]
lemma mem_toTwoSided {I : Ideal R} [I.IsTwoSided] {x : R} :
x ∈ I.toTwoSided ↔ x ∈ I := by
simp [toTwoSided]
@[simp]
lemma coe_toTwoSided (I : Ideal R) [I.IsTwoSided] : (I.toTwoSided : Set R) = I := by
simp [toTwoSided]
@[simp]
lemma toTwoSided_asIdeal (I : TwoSidedIdeal R) : I.asIdeal.toTwoSided = I :=
by ext; simp
@[simp]
lemma asIdeal_toTwoSided (I : Ideal R) [I.IsTwoSided] : I.toTwoSided.asIdeal = I := by
ext
simp
instance : CanLift (Ideal R) (TwoSidedIdeal R) TwoSidedIdeal.asIdeal (·.IsTwoSided) where
prf I _ := ⟨I.toTwoSided, asIdeal_toTwoSided ..⟩
end Ideal
/-- A two-sided ideal is simply a left ideal that is two-sided. -/
@[simps] def TwoSidedIdeal.orderIsoIsTwoSided {R : Type*} [Ring R] :
TwoSidedIdeal R ≃o {I : Ideal R // I.IsTwoSided} where
toFun I := ⟨I.asIdeal, inferInstance⟩
invFun I := have := I.2; I.1.toTwoSided
left_inv _ := by simp
right_inv I := by simp
map_rel_iff' {I I'} := by simp [SetLike.le_def] |
.lake/packages/mathlib/Mathlib/RingTheory/TwoSidedIdeal/BigOperators.lean | import Mathlib.RingTheory.Congruence.BigOperators
import Mathlib.RingTheory.TwoSidedIdeal.Basic
/-!
# Interactions between `∑, ∏` and two-sided ideals
-/
namespace TwoSidedIdeal
section sum
variable {R : Type*} [NonUnitalNonAssocRing R] (I : TwoSidedIdeal R)
lemma listSum_mem {ι : Type*} (l : List ι) (f : ι → R) (hl : ∀ x ∈ l, f x ∈ I) :
(l.map f).sum ∈ I := by
rw [mem_iff, ← List.sum_map_zero]
exact I.ringCon.listSum l hl
lemma multisetSum_mem {ι : Type*} (s : Multiset ι) (f : ι → R) (hs : ∀ x ∈ s, f x ∈ I) :
(s.map f).sum ∈ I := by
rw [mem_iff, ← Multiset.sum_map_zero]
exact I.ringCon.multisetSum s hs
lemma finsetSum_mem {ι : Type*} (s : Finset ι) (f : ι → R) (hs : ∀ x ∈ s, f x ∈ I) :
s.sum f ∈ I := by
rw [mem_iff, ← Finset.sum_const_zero]
exact I.ringCon.finsetSum s hs
end sum
section prod
section ring
variable {R : Type*} [Ring R] (I : TwoSidedIdeal R)
lemma listProd_mem {ι : Type*} (l : List ι) (f : ι → R) (hl : ∃ x ∈ l, f x ∈ I) :
(l.map f).prod ∈ I := by
induction l with
| nil => simp only [List.not_mem_nil, false_and, exists_false] at hl
| cons x l ih =>
simp only [List.mem_cons, exists_eq_or_imp] at hl
rcases hl with h | hal
· simpa only [List.map_cons, List.prod_cons] using I.mul_mem_right _ _ h
· simpa only [List.map_cons, List.prod_cons] using I.mul_mem_left _ _ <| ih hal
end ring
section commRing
variable {R : Type*} [CommRing R] (I : TwoSidedIdeal R)
lemma multiSetProd_mem {ι : Type*} (s : Multiset ι) (f : ι → R) (hs : ∃ x ∈ s, f x ∈ I) :
(s.map f).prod ∈ I := by
rcases s
simpa using listProd_mem (hl := hs)
lemma finsetProd_mem {ι : Type*} (s : Finset ι) (f : ι → R) (hs : ∃ x ∈ s, f x ∈ I) :
s.prod f ∈ I := by
rcases s
simpa using multiSetProd_mem (hs := hs)
end commRing
end prod
end TwoSidedIdeal |
.lake/packages/mathlib/Mathlib/RingTheory/TwoSidedIdeal/Kernel.lean | import Mathlib.RingTheory.TwoSidedIdeal.Basic
import Mathlib.RingTheory.TwoSidedIdeal.Lattice
/-!
# Kernel of a ring homomorphism as a two-sided ideal
In this file we define the kernel of a ring homomorphism `f : R → S` as a two-sided ideal of `R`.
We put this in a separate file so that we could import it in `SimpleRing/Basic.lean` without
importing any finiteness result.
-/
assert_not_exists Finset
namespace TwoSidedIdeal
section ker
variable {R S : Type*} [NonUnitalNonAssocRing R] [NonUnitalNonAssocSemiring S]
variable {F : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S]
variable (f : F)
/--
The kernel of a ring homomorphism, as a two-sided ideal.
-/
def ker : TwoSidedIdeal R :=
.mk
{ r := fun x y ↦ f x = f y
iseqv := by constructor <;> aesop
mul' := by intro; simp_all
add' := by intro; simp_all }
@[simp]
lemma ker_ringCon {x y : R} : (ker f).ringCon x y ↔ f x = f y := Iff.rfl
lemma mem_ker {x : R} : x ∈ ker f ↔ f x = 0 := by
rw [mem_iff, ker_ringCon, map_zero]
lemma ker_eq_bot : ker f = ⊥ ↔ Function.Injective f := by
fconstructor
· intro h x y hxy
simpa [h, rel_iff, mem_bot, sub_eq_zero] using show (ker f).ringCon x y from hxy
· exact fun h ↦ eq_bot_iff.2 fun x hx => h hx
section NonAssocRing
variable {R : Type*} [NonAssocRing R]
/--
The kernel of the ring homomorphism `R → R⧸I` is `I`.
-/
@[simp]
lemma ker_ringCon_mk' (I : TwoSidedIdeal R) : ker I.ringCon.mk' = I :=
le_antisymm
(fun _ h => by simpa using I.rel_iff _ _ |>.1 (Quotient.eq'.1 h))
(fun _ h => Quotient.sound' <| I.rel_iff _ _ |>.2 (by simpa using h))
end NonAssocRing
end ker
end TwoSidedIdeal |
.lake/packages/mathlib/Mathlib/RingTheory/TwoSidedIdeal/Lattice.lean | import Mathlib.RingTheory.TwoSidedIdeal.Basic
/-!
# The complete lattice structure on two-sided ideals
-/
namespace TwoSidedIdeal
variable (R : Type*) [NonUnitalNonAssocRing R]
instance : SemilatticeSup (TwoSidedIdeal R) where
sup I J := { ringCon := I.ringCon ⊔ J.ringCon }
le_sup_left I J := by rw [ringCon_le_iff]; exact le_sup_left
le_sup_right I J := by rw [ringCon_le_iff]; exact le_sup_right
sup_le I J K h1 h2 := by rw [ringCon_le_iff] at h1 h2 ⊢; exact sup_le h1 h2
lemma sup_ringCon (I J : TwoSidedIdeal R) : (I ⊔ J).ringCon = I.ringCon ⊔ J.ringCon := rfl
section sup
variable {R}
lemma mem_sup_left {I J : TwoSidedIdeal R} {x : R} (h : x ∈ I) :
x ∈ I ⊔ J :=
(show I ≤ I ⊔ J from le_sup_left) h
lemma mem_sup_right {I J : TwoSidedIdeal R} {x : R} (h : x ∈ J) :
x ∈ I ⊔ J :=
(show J ≤ I ⊔ J from le_sup_right) h
lemma mem_sup {I J : TwoSidedIdeal R} {x : R} :
x ∈ I ⊔ J ↔ ∃ y ∈ I, ∃ z ∈ J, y + z = x := by
constructor
· let s : TwoSidedIdeal R := .mk'
{x | ∃ y ∈ I, ∃ z ∈ J, y + z = x}
⟨0, ⟨zero_mem _, ⟨0, ⟨zero_mem _, zero_add _⟩⟩⟩⟩
(by rintro _ _ ⟨x, ⟨hx, ⟨y, ⟨hy, rfl⟩⟩⟩⟩ ⟨a, ⟨ha, ⟨b, ⟨hb, rfl⟩⟩⟩⟩;
exact ⟨x + a, ⟨add_mem _ hx ha, ⟨y + b, ⟨add_mem _ hy hb, by abel⟩⟩⟩⟩)
(by rintro _ ⟨x, ⟨hx, ⟨y, ⟨hy, rfl⟩⟩⟩⟩
exact ⟨-x, ⟨neg_mem _ hx, ⟨-y, ⟨neg_mem _ hy, by abel⟩⟩⟩⟩)
(by rintro r _ ⟨x, ⟨hx, ⟨y, ⟨hy, rfl⟩⟩⟩⟩
exact ⟨_, ⟨mul_mem_left _ _ _ hx, ⟨_, ⟨mul_mem_left _ _ _ hy, mul_add _ _ _ |>.symm⟩⟩⟩⟩)
(by rintro r _ ⟨x, ⟨hx, ⟨y, ⟨hy, rfl⟩⟩⟩⟩
exact ⟨_, ⟨mul_mem_right _ _ _ hx, ⟨_, ⟨mul_mem_right _ _ _ hy, add_mul _ _ _ |>.symm⟩⟩⟩⟩)
suffices (I.ringCon ⊔ J.ringCon) ≤ s.ringCon by
intro h; convert this h; rw [rel_iff, sub_zero, mem_mk']; rfl
refine sup_le (fun x y h => ?_) (fun x y h => ?_) <;> rw [rel_iff] at h ⊢ <;> rw [mem_mk']
exacts [⟨_, ⟨h, ⟨0, ⟨zero_mem _, add_zero _⟩⟩⟩⟩, ⟨0, ⟨zero_mem _, ⟨_, ⟨h, zero_add _⟩⟩⟩⟩]
· rintro ⟨y, ⟨hy, ⟨z, ⟨hz, rfl⟩⟩⟩⟩; exact add_mem _ (mem_sup_left hy) (mem_sup_right hz)
end sup
instance : SemilatticeInf (TwoSidedIdeal R) where
inf I J := { ringCon := I.ringCon ⊓ J.ringCon }
inf_le_left I J := by rw [ringCon_le_iff]; exact inf_le_left
inf_le_right I J := by rw [ringCon_le_iff]; exact inf_le_right
le_inf I J K h1 h2 := by rw [ringCon_le_iff] at h1 h2 ⊢; exact le_inf h1 h2
lemma inf_ringCon (I J : TwoSidedIdeal R) : (I ⊓ J).ringCon = I.ringCon ⊓ J.ringCon := rfl
lemma mem_inf {I J : TwoSidedIdeal R} {x : R} :
x ∈ I ⊓ J ↔ x ∈ I ∧ x ∈ J :=
Iff.rfl
instance : SupSet (TwoSidedIdeal R) where
sSup s := { ringCon := sSup <| TwoSidedIdeal.ringCon '' s }
lemma sSup_ringCon (S : Set (TwoSidedIdeal R)) :
(sSup S).ringCon = sSup (TwoSidedIdeal.ringCon '' S) := rfl
lemma iSup_ringCon {ι : Type*} (I : ι → TwoSidedIdeal R) :
(⨆ i, I i).ringCon = ⨆ i, (I i).ringCon := by
simp only [iSup, sSup_ringCon]; congr; ext; simp
instance : CompleteSemilatticeSup (TwoSidedIdeal R) where
sSup_le s I h := by simp_rw [ringCon_le_iff] at h ⊢; exact sSup_le <| by aesop
le_sSup s I hI := by rw [ringCon_le_iff]; exact le_sSup <| by aesop
instance : InfSet (TwoSidedIdeal R) where
sInf s := { ringCon := sInf <| TwoSidedIdeal.ringCon '' s }
lemma sInf_ringCon (S : Set (TwoSidedIdeal R)) :
(sInf S).ringCon = sInf (TwoSidedIdeal.ringCon '' S) := rfl
lemma iInf_ringCon {ι : Type*} (I : ι → TwoSidedIdeal R) :
(⨅ i, I i).ringCon = ⨅ i, (I i).ringCon := by
simp only [iInf, sInf_ringCon]; congr!; ext; simp
instance : CompleteSemilatticeInf (TwoSidedIdeal R) where
le_sInf s I h := by simp_rw [ringCon_le_iff] at h ⊢; exact le_sInf <| by aesop
sInf_le s I hI := by rw [ringCon_le_iff]; exact sInf_le <| by aesop
lemma mem_iInf {ι : Type*} {I : ι → TwoSidedIdeal R} {x : R} :
x ∈ iInf I ↔ ∀ i, x ∈ I i :=
show (∀ _, _) ↔ _ by simp [mem_iff]
lemma mem_sInf {S : Set (TwoSidedIdeal R)} {x : R} :
x ∈ sInf S ↔ ∀ I ∈ S, x ∈ I :=
show (∀ _, _) ↔ _ by simp [mem_iff]
instance : Top (TwoSidedIdeal R) where
top := { ringCon := ⊤ }
lemma top_ringCon : (⊤ : TwoSidedIdeal R).ringCon = ⊤ := rfl
@[simp]
lemma mem_top {x : R} : x ∈ (⊤ : TwoSidedIdeal R) := trivial
instance : Bot (TwoSidedIdeal R) where
bot := { ringCon := ⊥ }
lemma bot_ringCon : (⊥ : TwoSidedIdeal R).ringCon = ⊥ := rfl
@[simp]
lemma mem_bot {x : R} : x ∈ (⊥ : TwoSidedIdeal R) ↔ x = 0 :=
Iff.rfl
instance : CompleteLattice (TwoSidedIdeal R) where
__ := (inferInstance : SemilatticeSup (TwoSidedIdeal R))
__ := (inferInstance : SemilatticeInf (TwoSidedIdeal R))
__ := (inferInstance : CompleteSemilatticeSup (TwoSidedIdeal R))
__ := (inferInstance : CompleteSemilatticeInf (TwoSidedIdeal R))
le_top _ := by rw [ringCon_le_iff]; exact le_top
bot_le _ := by rw [ringCon_le_iff]; exact bot_le
@[simp]
lemma coe_bot : ((⊥ : TwoSidedIdeal R) : Set R) = {0} := rfl
@[simp]
lemma coe_top : ((⊤ : TwoSidedIdeal R) : Set R) = Set.univ := rfl
lemma one_mem_iff {R : Type*} [NonAssocRing R] (I : TwoSidedIdeal R) :
(1 : R) ∈ I ↔ I = ⊤ :=
⟨fun h => eq_top_iff.2 fun x _ => by simpa using I.mul_mem_left x _ h, fun h ↦ h.symm ▸ trivial⟩
alias ⟨eq_top, one_mem⟩ := one_mem_iff
end TwoSidedIdeal |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.