fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
map_subtype_coe_factors' {a : α} : (factors' a).map (↑) = (factors a).map Associates.mk := by simp [factors', Multiset.map_pmap, Multiset.pmap_eq_map]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
map_subtype_coe_factors'
null
factors'_cong {a b : α} (h : a ~ᵤ b) : factors' a = factors' b := by obtain rfl | hb := eq_or_ne b 0 · rw [associated_zero_iff_eq_zero] at h rw [h] have ha : a ≠ 0 := by contrapose! hb with ha rw [← associated_zero_iff_eq_zero, ← ha] exact h.symm rw [← Multiset.map_eq_map Subtype.coe_injective, map_subtype_coe_factors', map_subtype_coe_factors', ← rel_associated_iff_map_eq_map] exact factors_unique irreducible_of_factor irreducible_of_factor ((factors_prod ha).trans <| h.trans <| (factors_prod hb).symm)
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors'_cong
null
noncomputable factors (a : Associates α) : FactorSet α := by classical refine if h : a = 0 then ⊤ else Quotient.hrecOn a (fun x _ => factors' x) ?_ h intro a b hab apply Function.hfunext · have : a ~ᵤ 0 ↔ b ~ᵤ 0 := Iff.intro (fun ha0 => hab.symm.trans ha0) fun hb0 => hab.trans hb0 simp only [associated_zero_iff_eq_zero] at this simp only [quotient_mk_eq_mk, this, mk_eq_zero] exact fun ha hb _ => heq_of_eq <| congr_arg some <| factors'_cong hab @[simp]
def
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors
This returns the multiset of irreducible factors of an associate as a `FactorSet`, a multiset of irreducible associates `WithTop`.
factors_zero : (0 : Associates α).factors = ⊤ := dif_pos rfl @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_zero
null
factors_mk (a : α) (h : a ≠ 0) : (Associates.mk a).factors = factors' a := by classical apply dif_neg apply mt mk_eq_zero.1 h @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_mk
null
factors_prod (a : Associates α) : a.factors.prod = a := by rcases Associates.mk_surjective a with ⟨a, rfl⟩ rcases eq_or_ne a 0 with rfl | ha · simp · simp [ha, prod_mk, mk_eq_mk_iff_associated, UniqueFactorizationMonoid.factors_prod, -Quotient.eq] @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_prod
null
prod_factors [Nontrivial α] (s : FactorSet α) : s.prod.factors = s := FactorSet.unique <| factors_prod _ @[nontriviality]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
prod_factors
null
factors_subsingleton [Subsingleton α] {a : Associates α} : a.factors = ⊤ := by have : Subsingleton (Associates α) := inferInstance convert factors_zero
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_subsingleton
null
factors_eq_top_iff_zero {a : Associates α} : a.factors = ⊤ ↔ a = 0 := by nontriviality α exact ⟨fun h ↦ by rwa [← factors_prod a, FactorSet.prod_eq_zero_iff], fun h ↦ h ▸ factors_zero⟩
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_eq_top_iff_zero
null
factors_eq_some_iff_ne_zero {a : Associates α} : (∃ s : Multiset { p : Associates α // Irreducible p }, a.factors = s) ↔ a ≠ 0 := by simp_rw [@eq_comm _ a.factors, ← WithTop.ne_top_iff_exists] exact factors_eq_top_iff_zero.not
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_eq_some_iff_ne_zero
null
eq_of_factors_eq_factors {a b : Associates α} (h : a.factors = b.factors) : a = b := by have : a.factors.prod = b.factors.prod := by rw [h] rwa [factors_prod, factors_prod] at this
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
eq_of_factors_eq_factors
null
eq_of_prod_eq_prod [Nontrivial α] {a b : FactorSet α} (h : a.prod = b.prod) : a = b := by have : a.prod.factors = b.prod.factors := by rw [h] rwa [prod_factors, prod_factors] at this @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
eq_of_prod_eq_prod
null
factors_mul (a b : Associates α) : (a * b).factors = a.factors + b.factors := by nontriviality α refine eq_of_prod_eq_prod <| eq_of_factors_eq_factors ?_ rw [prod_add, factors_prod, factors_prod, factors_prod] @[gcongr]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_mul
null
factors_mono : ∀ {a b : Associates α}, a ≤ b → a.factors ≤ b.factors | s, t, ⟨d, eq⟩ => by rw [eq, factors_mul]; exact le_add_of_nonneg_right bot_le @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_mono
null
factors_le {a b : Associates α} : a.factors ≤ b.factors ↔ a ≤ b := by refine ⟨fun h ↦ ?_, factors_mono⟩ have : a.factors.prod ≤ b.factors.prod := prod_mono h rwa [factors_prod, factors_prod] at this
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_le
null
eq_factors_of_eq_counts {a b : Associates α} (ha : a ≠ 0) (hb : b ≠ 0) (h : ∀ p : Associates α, Irreducible p → p.count a.factors = p.count b.factors) : a.factors = b.factors := by obtain ⟨sa, h_sa⟩ := factors_eq_some_iff_ne_zero.mpr ha obtain ⟨sb, h_sb⟩ := factors_eq_some_iff_ne_zero.mpr hb rw [h_sa, h_sb] at h ⊢ rw [WithTop.coe_eq_coe] have h_count : ∀ (p : Associates α) (hp : Irreducible p), sa.count ⟨p, hp⟩ = sb.count ⟨p, hp⟩ := by intro p hp rw [← count_some, ← count_some, h p hp] apply Multiset.toFinsupp.injective ext ⟨p, hp⟩ rw [Multiset.toFinsupp_apply, Multiset.toFinsupp_apply, h_count p hp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
eq_factors_of_eq_counts
null
eq_of_eq_counts {a b : Associates α} (ha : a ≠ 0) (hb : b ≠ 0) (h : ∀ p : Associates α, Irreducible p → p.count a.factors = p.count b.factors) : a = b := eq_of_factors_eq_factors (eq_factors_of_eq_counts ha hb h)
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
eq_of_eq_counts
null
count_le_count_of_factors_le {a b p : Associates α} (hb : b ≠ 0) (hp : Irreducible p) (h : a.factors ≤ b.factors) : p.count a.factors ≤ p.count b.factors := by by_cases ha : a = 0 · simp_all obtain ⟨sa, h_sa⟩ := factors_eq_some_iff_ne_zero.mpr ha obtain ⟨sb, h_sb⟩ := factors_eq_some_iff_ne_zero.mpr hb rw [h_sa, h_sb] at h ⊢ rw [count_some hp, count_some hp]; rw [WithTop.coe_le_coe] at h exact Multiset.count_le_of_le _ h
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_le_count_of_factors_le
null
count_le_count_of_le {a b p : Associates α} (hb : b ≠ 0) (hp : Irreducible p) (h : a ≤ b) : p.count a.factors ≤ p.count b.factors := count_le_count_of_factors_le hb hp <| factors_mono h
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_le_count_of_le
null
prod_le [Nontrivial α] {a b : FactorSet α} : a.prod ≤ b.prod ↔ a ≤ b := by refine ⟨fun h ↦ ?_, prod_mono⟩ have : a.prod.factors ≤ b.prod.factors := factors_mono h rwa [prod_factors, prod_factors] at this open Classical in
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
prod_le
null
sup_mul_inf (a b : Associates α) : (a ⊔ b) * (a ⊓ b) = a * b := show (a.factors ⊔ b.factors).prod * (a.factors ⊓ b.factors).prod = a * b by nontriviality α refine eq_of_factors_eq_factors ?_ rw [← prod_add, prod_factors, factors_mul, FactorSet.sup_add_inf_eq_add]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
sup_mul_inf
null
dvd_of_mem_factors {a p : Associates α} (hm : p ∈ factors a) : p ∣ a := by rcases eq_or_ne a 0 with rfl | ha0 · exact dvd_zero p obtain ⟨a0, nza, ha'⟩ := exists_non_zero_rep ha0 rw [← Associates.factors_prod a] rw [← ha', factors_mk a0 nza] at hm ⊢ rw [prod_coe] apply Multiset.dvd_prod; apply Multiset.mem_map.mpr exact ⟨⟨p, irreducible_of_mem_factorSet hm⟩, mem_factorSet_some.mp hm, rfl⟩
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
dvd_of_mem_factors
null
dvd_of_mem_factors' {a : α} {p : Associates α} {hp : Irreducible p} {hz : a ≠ 0} (h_mem : Subtype.mk p hp ∈ factors' a) : p ∣ Associates.mk a := by haveI := Classical.decEq (Associates α) apply dvd_of_mem_factors rw [factors_mk _ hz] apply mem_factorSet_some.2 h_mem
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
dvd_of_mem_factors'
null
mem_factors'_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) (hd : p ∣ a) : Subtype.mk (Associates.mk p) (irreducible_mk.2 hp) ∈ factors' a := by obtain ⟨q, hq, hpq⟩ := exists_mem_factors_of_dvd ha0 hp hd apply Multiset.mem_pmap.mpr; use q; use hq exact Subtype.eq (Eq.symm (mk_eq_mk_iff_associated.mpr hpq))
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
mem_factors'_of_dvd
null
mem_factors'_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) : Subtype.mk (Associates.mk p) (irreducible_mk.2 hp) ∈ factors' a ↔ p ∣ a := by constructor · rw [← mk_dvd_mk] apply dvd_of_mem_factors' apply ha0 · apply mem_factors'_of_dvd ha0 hp
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
mem_factors'_iff_dvd
null
mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) (hd : p ∣ a) : Associates.mk p ∈ factors (Associates.mk a) := by rw [factors_mk _ ha0] exact mem_factorSet_some.mpr (mem_factors'_of_dvd ha0 hp hd)
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
mem_factors_of_dvd
null
mem_factors_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) : Associates.mk p ∈ factors (Associates.mk a) ↔ p ∣ a := by constructor · rw [← mk_dvd_mk] apply dvd_of_mem_factors · apply mem_factors_of_dvd ha0 hp open Classical in
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
mem_factors_iff_dvd
null
exists_prime_dvd_of_not_inf_one {a b : α} (ha : a ≠ 0) (hb : b ≠ 0) (h : Associates.mk a ⊓ Associates.mk b ≠ 1) : ∃ p : α, Prime p ∧ p ∣ a ∧ p ∣ b := by have hz : factors (Associates.mk a) ⊓ factors (Associates.mk b) ≠ 0 := by contrapose! h with hf change (factors (Associates.mk a) ⊓ factors (Associates.mk b)).prod = 1 rw [hf] exact Multiset.prod_zero rw [factors_mk a ha, factors_mk b hb, ← WithTop.coe_inf] at hz obtain ⟨⟨p0, p0_irr⟩, p0_mem⟩ := Multiset.exists_mem_of_ne_zero ((mt WithTop.coe_eq_coe.mpr) hz) rw [Multiset.inf_eq_inter] at p0_mem obtain ⟨p, rfl⟩ : ∃ p, Associates.mk p = p0 := Quot.exists_rep p0 refine ⟨p, ?_, ?_, ?_⟩ · rw [← UniqueFactorizationMonoid.irreducible_iff_prime, ← irreducible_mk] exact p0_irr · apply dvd_of_mk_le_mk apply dvd_of_mem_factors' (Multiset.mem_inter.mp p0_mem).left apply ha · apply dvd_of_mk_le_mk apply dvd_of_mem_factors' (Multiset.mem_inter.mp p0_mem).right apply hb
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
exists_prime_dvd_of_not_inf_one
null
coprime_iff_inf_one {a b : α} (ha0 : a ≠ 0) (hb0 : b ≠ 0) : Associates.mk a ⊓ Associates.mk b = 1 ↔ ∀ {d : α}, d ∣ a → d ∣ b → ¬Prime d := by constructor · intro hg p ha hb hp refine (Associates.prime_mk.mpr hp).not_unit (isUnit_of_dvd_one ?_) rw [← hg] exact le_inf (mk_le_mk_of_dvd ha) (mk_le_mk_of_dvd hb) · contrapose intro hg hc obtain ⟨p, hp, hpa, hpb⟩ := exists_prime_dvd_of_not_inf_one ha0 hb0 hg exact hc hpa hpb hp
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
coprime_iff_inf_one
null
factors_self [Nontrivial α] {p : Associates α} (hp : Irreducible p) : p.factors = WithTop.some {⟨p, hp⟩} := eq_of_prod_eq_prod (by rw [factors_prod, FactorSet.prod.eq_def]; dsimp; rw [prod_singleton])
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_self
null
factors_prime_pow [Nontrivial α] {p : Associates α} (hp : Irreducible p) (k : ℕ) : factors (p ^ k) = WithTop.some (Multiset.replicate k ⟨p, hp⟩) := eq_of_prod_eq_prod (by rw [Associates.factors_prod, FactorSet.prod.eq_def] dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate, Subtype.coe_mk])
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_prime_pow
null
prime_pow_le_iff_le_bcount [DecidableEq (Associates α)] {m p : Associates α} (h₁ : m ≠ 0) (h₂ : Irreducible p) {k : ℕ} : p ^ k ≤ m ↔ k ≤ bcount ⟨p, h₂⟩ m.factors := by rcases Associates.exists_non_zero_rep h₁ with ⟨m, hm, rfl⟩ have := nontrivial_of_ne _ _ hm rw [bcount.eq_def, factors_mk, Multiset.le_count_iff_replicate_le, ← factors_le, factors_prime_pow, factors_mk, WithTop.coe_le_coe] <;> assumption @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
prime_pow_le_iff_le_bcount
null
factors_one [Nontrivial α] : factors (1 : Associates α) = 0 := by apply eq_of_prod_eq_prod rw [Associates.factors_prod] exact Multiset.prod_zero @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
factors_one
null
pow_factors [Nontrivial α] {a : Associates α} {k : ℕ} : (a ^ k).factors = k • a.factors := by induction k with | zero => rw [zero_nsmul, pow_zero]; exact factors_one | succ n h => rw [pow_succ, succ_nsmul, factors_mul, h]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
pow_factors
null
prime_pow_dvd_iff_le {m p : Associates α} (h₁ : m ≠ 0) (h₂ : Irreducible p) {k : ℕ} : p ^ k ≤ m ↔ k ≤ count p m.factors := by rw [count, dif_pos h₂, prime_pow_le_iff_le_bcount h₁]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
prime_pow_dvd_iff_le
null
le_of_count_ne_zero {m p : Associates α} (h0 : m ≠ 0) (hp : Irreducible p) : count p m.factors ≠ 0 → p ≤ m := by nontriviality α rw [← pos_iff_ne_zero] intro h rw [← pow_one p] apply (prime_pow_dvd_iff_le h0 hp).2 simpa only
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
le_of_count_ne_zero
null
count_ne_zero_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) : (Associates.mk p).count (Associates.mk a).factors ≠ 0 ↔ p ∣ a := by nontriviality α rw [← Associates.mk_le_mk_iff_dvd] refine ⟨fun h => Associates.le_of_count_ne_zero (Associates.mk_ne_zero.mpr ha0) (Associates.irreducible_mk.mpr hp) h, fun h => ?_⟩ rw [← pow_one (Associates.mk p), Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero.mpr ha0) (Associates.irreducible_mk.mpr hp)] at h exact (zero_lt_one.trans_le h).ne'
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_ne_zero_iff_dvd
null
count_self [Nontrivial α] {p : Associates α} (hp : Irreducible p) : p.count p.factors = 1 := by simp [factors_self hp, Associates.count_some hp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_self
null
count_eq_zero_of_ne {p q : Associates α} (hp : Irreducible p) (hq : Irreducible q) (h : p ≠ q) : p.count q.factors = 0 := not_ne_iff.mp fun h' ↦ h <| associated_iff_eq.mp <| hp.associated_of_dvd hq <| le_of_count_ne_zero hq.ne_zero hp h'
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_eq_zero_of_ne
null
count_mul {a : Associates α} (ha : a ≠ 0) {b : Associates α} (hb : b ≠ 0) {p : Associates α} (hp : Irreducible p) : count p (factors (a * b)) = count p a.factors + count p b.factors := by obtain ⟨a0, nza, rfl⟩ := exists_non_zero_rep ha obtain ⟨b0, nzb, rfl⟩ := exists_non_zero_rep hb rw [factors_mul, factors_mk a0 nza, factors_mk b0 nzb, ← FactorSet.coe_add, count_some hp, Multiset.count_add, count_some hp, count_some hp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_mul
null
count_of_coprime {a : Associates α} (ha : a ≠ 0) {b : Associates α} (hb : b ≠ 0) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) {p : Associates α} (hp : Irreducible p) : count p a.factors = 0 ∨ count p b.factors = 0 := by rw [or_iff_not_imp_left, ← Ne] intro hca contrapose! hab with hcb exact ⟨p, le_of_count_ne_zero ha hp hca, le_of_count_ne_zero hb hp hcb, UniqueFactorizationMonoid.irreducible_iff_prime.mp hp⟩
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_of_coprime
null
count_mul_of_coprime {a : Associates α} {b : Associates α} (hb : b ≠ 0) {p : Associates α} (hp : Irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) : count p a.factors = 0 ∨ count p a.factors = count p (a * b).factors := by by_cases ha : a = 0 · simp [ha] rcases count_of_coprime ha hb hab hp with hz | hb0; · tauto apply Or.intro_right rw [count_mul ha hb hp, hb0, add_zero]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_mul_of_coprime
null
count_mul_of_coprime' {a b : Associates α} {p : Associates α} (hp : Irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) : count p (a * b).factors = count p a.factors ∨ count p (a * b).factors = count p b.factors := by by_cases ha : a = 0 · simp [ha] by_cases hb : b = 0 · simp [hb] rw [count_mul ha hb hp] rcases count_of_coprime ha hb hab hp with ha0 | hb0 · apply Or.intro_right rw [ha0, zero_add] · apply Or.intro_left rw [hb0, add_zero]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_mul_of_coprime'
null
dvd_count_of_dvd_count_mul {a b : Associates α} (hb : b ≠ 0) {p : Associates α} (hp : Irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) {k : ℕ} (habk : k ∣ count p (a * b).factors) : k ∣ count p a.factors := by by_cases ha : a = 0 · simpa [*] using habk rcases count_of_coprime ha hb hab hp with hz | h · rw [hz] exact dvd_zero k · rw [count_mul ha hb hp, h] at habk exact habk
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
dvd_count_of_dvd_count_mul
null
count_pow [Nontrivial α] {a : Associates α} (ha : a ≠ 0) {p : Associates α} (hp : Irreducible p) (k : ℕ) : count p (a ^ k).factors = k * count p a.factors := by induction k with | zero => rw [pow_zero, factors_one, zero_mul, count_zero hp] | succ n h => rw [pow_succ', count_mul ha (pow_ne_zero _ ha) hp, h]; ring
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_pow
null
dvd_count_pow [Nontrivial α] {a : Associates α} (ha : a ≠ 0) {p : Associates α} (hp : Irreducible p) (k : ℕ) : k ∣ count p (a ^ k).factors := by rw [count_pow ha hp] apply dvd_mul_right
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
dvd_count_pow
null
is_pow_of_dvd_count {a : Associates α} (ha : a ≠ 0) {k : ℕ} (hk : ∀ p : Associates α, Irreducible p → k ∣ count p a.factors) : ∃ b : Associates α, a = b ^ k := by nontriviality α obtain ⟨a0, hz, rfl⟩ := exists_non_zero_rep ha rw [factors_mk a0 hz] at hk have hk' : ∀ p, p ∈ factors' a0 → k ∣ (factors' a0).count p := by rintro p - have pp : p = ⟨p.val, p.2⟩ := by simp only [Subtype.coe_eta] rw [pp, ← count_some p.2] exact hk p.val p.2 obtain ⟨u, hu⟩ := Multiset.exists_smul_of_dvd_count _ hk' use FactorSet.prod (u : FactorSet α) apply eq_of_factors_eq_factors rw [pow_factors, prod_factors, factors_mk a0 hz, hu] exact WithBot.coe_nsmul u k
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
is_pow_of_dvd_count
null
eq_pow_count_factors_of_dvd_pow {p a : Associates α} (hp : Irreducible p) {n : ℕ} (h : a ∣ p ^ n) : a = p ^ p.count a.factors := by nontriviality α have hph := pow_ne_zero n hp.ne_zero have ha := ne_zero_of_dvd_ne_zero hph h apply eq_of_eq_counts ha (pow_ne_zero _ hp.ne_zero) have eq_zero_of_ne : ∀ q : Associates α, Irreducible q → q ≠ p → _ = 0 := fun q hq h' => Nat.eq_zero_of_le_zero <| by convert count_le_count_of_le hph hq h symm rw [count_pow hp.ne_zero hq, count_eq_zero_of_ne hq hp h', mul_zero] intro q hq rw [count_pow hp.ne_zero hq] by_cases h : q = p · rw [h, count_self hp, mul_one] · rw [count_eq_zero_of_ne hq hp h, mul_zero, eq_zero_of_ne q hq h]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
eq_pow_count_factors_of_dvd_pow
The only divisors of prime powers are prime powers. See `eq_pow_find_of_dvd_irreducible_pow` for an explicit expression as a p-power (without using `count`).
count_factors_eq_find_of_dvd_pow {a p : Associates α} (hp : Irreducible p) [∀ n : ℕ, Decidable (a ∣ p ^ n)] {n : ℕ} (h : a ∣ p ^ n) : @Nat.find (fun n => a ∣ p ^ n) _ ⟨n, h⟩ = p.count a.factors := by apply le_antisymm · refine Nat.find_le ⟨1, ?_⟩ rw [mul_one] symm exact eq_pow_count_factors_of_dvd_pow hp h · have hph := pow_ne_zero (@Nat.find (fun n => a ∣ p ^ n) _ ⟨n, h⟩) hp.ne_zero rcases subsingleton_or_nontrivial α with hα | hα · simp [eq_iff_true_of_subsingleton] at hph convert count_le_count_of_le hph hp (@Nat.find_spec (fun n => a ∣ p ^ n) _ ⟨n, h⟩) rw [count_pow hp.ne_zero hp, count_self hp, mul_one]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
count_factors_eq_find_of_dvd_pow
null
eq_pow_of_mul_eq_pow {a b c : Associates α} (ha : a ≠ 0) (hb : b ≠ 0) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) {k : ℕ} (h : a * b = c ^ k) : ∃ d : Associates α, a = d ^ k := by classical nontriviality α by_cases hk0 : k = 0 · use 1 rw [hk0, pow_zero] at h ⊢ apply (mul_eq_one.1 h).1 · refine is_pow_of_dvd_count ha fun p hp ↦ ?_ apply dvd_count_of_dvd_count_mul hb hp hab rw [h] apply dvd_count_pow _ hp rintro rfl rw [zero_pow hk0] at h cases mul_eq_zero.mp h <;> contradiction
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
eq_pow_of_mul_eq_pow
null
eq_pow_find_of_dvd_irreducible_pow {a p : Associates α} (hp : Irreducible p) [∀ n : ℕ, Decidable (a ∣ p ^ n)] {n : ℕ} (h : a ∣ p ^ n) : a = p ^ @Nat.find (fun n => a ∣ p ^ n) _ ⟨n, h⟩ := by classical rw [count_factors_eq_find_of_dvd_pow hp, ← eq_pow_count_factors_of_dvd_pow hp h] exact h
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic", "Mathlib.Tactic.Ring" ]
Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean
eq_pow_find_of_dvd_irreducible_pow
The only divisors of prime powers are prime powers.
noncomputable fintypeSubtypeDvd {M : Type*} [CancelCommMonoidWithZero M] [UniqueFactorizationMonoid M] [Fintype Mˣ] (y : M) (hy : y ≠ 0) : Fintype { x // x ∣ y } := by haveI : Nontrivial M := ⟨⟨y, 0, hy⟩⟩ haveI : NormalizationMonoid M := UniqueFactorizationMonoid.normalizationMonoid haveI := Classical.decEq M haveI := Classical.decEq (Associates M) refine Fintype.ofFinset (((normalizedFactors y).powerset.toFinset ×ˢ (Finset.univ : Finset Mˣ)).image fun s => (s.snd : M) * s.fst.prod) fun x => ?_ simp only [Finset.mem_image, Finset.mem_product, Finset.mem_univ, and_true, Multiset.mem_toFinset, Multiset.mem_powerset] constructor · rintro ⟨s, hs, rfl⟩ change (s.snd : M) * s.fst.prod ∣ y rw [(unit_associated_one.mul_right s.fst.prod).dvd_iff_dvd_left, one_mul, ← (prod_normalizedFactors hy).dvd_iff_dvd_right] exact Multiset.prod_dvd_prod_of_le hs · rintro (h : x ∣ y) have hx : x ≠ 0 := by refine mt (fun hx => ?_) hy rwa [hx, zero_dvd_iff] at h obtain ⟨u, hu⟩ := prod_normalizedFactors hx refine ⟨⟨normalizedFactors x, u⟩, ?_, (mul_comm _ _).trans hu⟩ exact (dvd_iff_normalizedFactors_le_normalizedFactors hx hy).mp h
def
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finite.lean
fintypeSubtypeDvd
If `y` is a nonzero element of a unique factorization monoid with finitely many units (e.g. `ℤ`, `Ideal (ring_of_integers K)`), it has finitely many divisors.
noncomputable factorization (n : α) : α →₀ ℕ := Multiset.toFinsupp (normalizedFactors n)
def
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
factorization
This returns the multiset of irreducible factors as a `Finsupp`.
factorization_eq_count {n p : α} : factorization n p = Multiset.count p (normalizedFactors n) := by simp [factorization] @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
factorization_eq_count
null
factorization_zero : factorization (0 : α) = 0 := by simp [factorization] @[simp]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
factorization_zero
null
factorization_one : factorization (1 : α) = 0 := by simp [factorization]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
factorization_one
null
@[simp] support_factorization {n : α} : (factorization n).support = (normalizedFactors n).toFinset := by simp [factorization, Multiset.toFinsupp_support]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
support_factorization
The support of `factorization n` is exactly the Finset of normalized factors
@[simp] factorization_mul {a b : α} (ha : a ≠ 0) (hb : b ≠ 0) : factorization (a * b) = factorization a + factorization b := by simp [factorization, normalizedFactors_mul ha hb]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
factorization_mul
For nonzero `a` and `b`, the power of `p` in `a * b` is the sum of the powers in `a` and `b`
factorization_pow {x : α} {n : ℕ} : factorization (x ^ n) = n • factorization x := by ext simp [factorization]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
factorization_pow
For any `p`, the power of `p` in `x^n` is `n` times the power in `x`
associated_of_factorization_eq (a b : α) (ha : a ≠ 0) (hb : b ≠ 0) (h : factorization a = factorization b) : Associated a b := by simp_rw [factorization, AddEquiv.apply_eq_iff_eq] at h rwa [associated_iff_normalizedFactors_eq_normalizedFactors ha hb]
theorem
RingTheory
[ "Mathlib.Data.Finsupp.Multiset", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Finsupp.lean
associated_of_factorization_eq
null
noncomputable UniqueFactorizationMonoid.toGCDMonoid (α : Type*) [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α] : GCDMonoid α where gcd a b := Quot.out (Associates.mk a ⊓ Associates.mk b : Associates α) lcm a b := Quot.out (Associates.mk a ⊔ Associates.mk b : Associates α) gcd_dvd_left a b := by rw [← mk_dvd_mk, Associates.quot_out, congr_fun₂ dvd_eq_le] exact inf_le_left gcd_dvd_right a b := by rw [← mk_dvd_mk, Associates.quot_out, congr_fun₂ dvd_eq_le] exact inf_le_right dvd_gcd {a b c} hac hab := by rw [← mk_dvd_mk, Associates.quot_out, congr_fun₂ dvd_eq_le, le_inf_iff, mk_le_mk_iff_dvd, mk_le_mk_iff_dvd] exact ⟨hac, hab⟩ lcm_zero_left a := by simp lcm_zero_right a := by simp gcd_mul_lcm a b := by rw [← mk_eq_mk_iff_associated, ← Associates.mk_mul_mk, ← associated_iff_eq, Associates.quot_out, Associates.quot_out, mul_comm, sup_mul_inf, Associates.mk_mul_mk]
def
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.FactorSet", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/GCDMonoid.lean
UniqueFactorizationMonoid.toGCDMonoid
`toGCDMonoid` constructs a GCD monoid out of a unique factorization domain.
noncomputable UniqueFactorizationMonoid.toNormalizedGCDMonoid (α : Type*) [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α] [NormalizationMonoid α] : NormalizedGCDMonoid α := { ‹NormalizationMonoid α› with gcd := fun a b => (Associates.mk a ⊓ Associates.mk b).out lcm := fun a b => (Associates.mk a ⊔ Associates.mk b).out gcd_dvd_left := fun a b => (out_dvd_iff a (Associates.mk a ⊓ Associates.mk b)).2 <| inf_le_left gcd_dvd_right := fun a b => (out_dvd_iff b (Associates.mk a ⊓ Associates.mk b)).2 <| inf_le_right dvd_gcd := fun {a} {b} {c} hac hab => show a ∣ (Associates.mk c ⊓ Associates.mk b).out by rw [dvd_out_iff, le_inf_iff, mk_le_mk_iff_dvd, mk_le_mk_iff_dvd] exact ⟨hac, hab⟩ lcm_zero_left := fun a => show (⊤ ⊔ Associates.mk a).out = 0 by simp lcm_zero_right := fun a => show (Associates.mk a ⊔ ⊤).out = 0 by simp gcd_mul_lcm := fun a b => by rw [← out_mul, mul_comm, sup_mul_inf, mk_mul_mk, out_mk] exact normalize_associated (a * b) normalize_gcd := fun a b => by apply normalize_out _ normalize_lcm := fun a b => by apply normalize_out _ }
def
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.FactorSet", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/GCDMonoid.lean
UniqueFactorizationMonoid.toNormalizedGCDMonoid
`toNormalizedGCDMonoid` constructs a GCD monoid out of a normalization on a unique factorization domain.
Ideal.IsPrime.exists_mem_prime_of_ne_bot {R : Type*} [CommSemiring R] [IsDomain R] [UniqueFactorizationMonoid R] {I : Ideal R} (hI₂ : I.IsPrime) (hI : I ≠ ⊥) : ∃ x ∈ I, Prime x := by classical obtain ⟨a : R, ha₁ : a ∈ I, ha₂ : a ≠ 0⟩ := Submodule.exists_mem_ne_zero_of_ne_bot hI replace ha₁ : (factors a).prod ∈ I := by obtain ⟨u : Rˣ, hu : (factors a).prod * u = a⟩ := factors_prod ha₂ rwa [← hu, mul_unit_mem_iff_mem _ u.isUnit] at ha₁ obtain ⟨p : R, hp₁ : p ∈ factors a, hp₂ : p ∈ I⟩ := (hI₂.multiset_prod_mem_iff_exists_mem <| factors a).1 ha₁ exact ⟨p, hp₂, prime_of_factor p hp₁⟩
theorem
RingTheory
[ "Mathlib.RingTheory.Ideal.Operations", "Mathlib.RingTheory.UniqueFactorizationDomain.Defs" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Ideal.lean
Ideal.IsPrime.exists_mem_prime_of_ne_bot
Every non-zero prime ideal in a unique factorization domain contains a prime element.
Ideal.setOf_isPrincipal_wellFoundedOn_gt [CommSemiring α] [WfDvdMonoid α] [IsDomain α] : {I : Ideal α | I.IsPrincipal}.WellFoundedOn (· > ·) := by have : {I : Ideal α | I.IsPrincipal} = ((fun a ↦ Ideal.span {a}) '' Set.univ) := by ext simp [Submodule.isPrincipal_iff, eq_comm] rw [this, Set.wellFoundedOn_image, Set.wellFoundedOn_univ] convert wellFounded_dvdNotUnit (α := α) ext exact Ideal.span_singleton_lt_span_singleton
lemma
RingTheory
[ "Mathlib.RingTheory.Ideal.Operations", "Mathlib.RingTheory.UniqueFactorizationDomain.Defs" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Ideal.lean
Ideal.setOf_isPrincipal_wellFoundedOn_gt
The ascending chain condition on principal ideals holds in a `WfDvdMonoid` domain.
WfDvdMonoid.of_setOf_isPrincipal_wellFoundedOn_gt [CommSemiring α] [IsDomain α] (h : {I : Ideal α | I.IsPrincipal}.WellFoundedOn (· > ·)) : WfDvdMonoid α := by have : WellFounded (α := {I : Ideal α // I.IsPrincipal}) (· > ·) := h constructor convert InvImage.wf (fun a => ⟨Ideal.span ({a} : Set α), _, rfl⟩) this ext exact Ideal.span_singleton_lt_span_singleton.symm
lemma
RingTheory
[ "Mathlib.RingTheory.Ideal.Operations", "Mathlib.RingTheory.UniqueFactorizationDomain.Defs" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Ideal.lean
WfDvdMonoid.of_setOf_isPrincipal_wellFoundedOn_gt
The ascending chain condition on principal ideals in a domain is sufficient to prove that the domain is `WfDvdMonoid`.
prime_pow_coprime_prod_of_coprime_insert [DecidableEq α] {s : Finset α} (i : α → ℕ) (p : α) (hps : p ∉ s) (is_prime : ∀ q ∈ insert p s, Prime q) (is_coprime : ∀ᵉ (q ∈ insert p s) (q' ∈ insert p s), q ∣ q' → q = q') : IsRelPrime (p ^ i p) (∏ p' ∈ s, p' ^ i p') := by have hp := is_prime _ (Finset.mem_insert_self _ _) refine (isRelPrime_iff_no_prime_factors <| pow_ne_zero _ hp.ne_zero).mpr ?_ intro d hdp hdprod hd apply hps replace hdp := hd.dvd_of_dvd_pow hdp obtain ⟨q, q_mem', hdq⟩ := hd.exists_mem_multiset_dvd hdprod obtain ⟨q, q_mem, rfl⟩ := Multiset.mem_map.mp q_mem' replace hdq := hd.dvd_of_dvd_pow hdq have : p ∣ q := dvd_trans (hd.irreducible.dvd_symm hp.irreducible hdp) hdq convert q_mem using 0 rw [Finset.mem_val, is_coprime _ (Finset.mem_insert_self p s) _ (Finset.mem_insert_of_mem q_mem) this]
theorem
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean
prime_pow_coprime_prod_of_coprime_insert
null
@[elab_as_elim] induction_on_prime_power {P : α → Prop} (s : Finset α) (i : α → ℕ) (is_prime : ∀ p ∈ s, Prime p) (is_coprime : ∀ᵉ (p ∈ s) (q ∈ s), p ∣ q → p = q) (h1 : ∀ {x}, IsUnit x → P x) (hpr : ∀ {p} (i : ℕ), Prime p → P (p ^ i)) (hcp : ∀ {x y}, IsRelPrime x y → P x → P y → P (x * y)) : P (∏ p ∈ s, p ^ i p) := by letI := Classical.decEq α induction s using Finset.induction_on with | empty => simpa using h1 isUnit_one | insert p f' hpf' ih => rw [Finset.prod_insert hpf'] exact hcp (prime_pow_coprime_prod_of_coprime_insert i p hpf' is_prime is_coprime) (hpr (i p) (is_prime _ (Finset.mem_insert_self _ _))) (ih (fun q hq => is_prime _ (Finset.mem_insert_of_mem hq)) fun q hq q' hq' => is_coprime _ (Finset.mem_insert_of_mem hq) _ (Finset.mem_insert_of_mem hq'))
theorem
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean
induction_on_prime_power
If `P` holds for units and powers of primes, and `P x ∧ P y` for coprime `x, y` implies `P (x * y)`, then `P` holds on a product of powers of distinct primes.
@[elab_as_elim] induction_on_coprime {P : α → Prop} (a : α) (h0 : P 0) (h1 : ∀ {x}, IsUnit x → P x) (hpr : ∀ {p} (i : ℕ), Prime p → P (p ^ i)) (hcp : ∀ {x y}, IsRelPrime x y → P x → P y → P (x * y)) : P a := by letI := Classical.decEq α have P_of_associated : ∀ {x y}, Associated x y → P x → P y := by rintro x y ⟨u, rfl⟩ hx exact hcp (fun p _ hpx => isUnit_of_dvd_unit hpx u.isUnit) hx (h1 u.isUnit) by_cases ha0 : a = 0 · rwa [ha0] haveI : Nontrivial α := ⟨⟨_, _, ha0⟩⟩ letI : NormalizationMonoid α := UniqueFactorizationMonoid.normalizationMonoid refine P_of_associated (prod_normalizedFactors ha0) ?_ rw [← (normalizedFactors a).map_id, Finset.prod_multiset_map_count] refine induction_on_prime_power _ _ ?_ ?_ @h1 @hpr @hcp <;> simp only [Multiset.mem_toFinset] · apply prime_of_normalized_factor · apply normalizedFactors_eq_of_dvd
theorem
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean
induction_on_coprime
If `P` holds for `0`, units and powers of primes, and `P x ∧ P y` for coprime `x, y` implies `P (x * y)`, then `P` holds on all `a : α`.
multiplicative_prime_power {f : α → β} (s : Finset α) (i j : α → ℕ) (is_prime : ∀ p ∈ s, Prime p) (is_coprime : ∀ᵉ (p ∈ s) (q ∈ s), p ∣ q → p = q) (h1 : ∀ {x y}, IsUnit y → f (x * y) = f x * f y) (hpr : ∀ {p} (i : ℕ), Prime p → f (p ^ i) = f p ^ i) (hcp : ∀ {x y}, IsRelPrime x y → f (x * y) = f x * f y) : f (∏ p ∈ s, p ^ (i p + j p)) = f (∏ p ∈ s, p ^ i p) * f (∏ p ∈ s, p ^ j p) := by letI := Classical.decEq α induction s using Finset.induction_on with | empty => simpa using h1 isUnit_one | insert p s hps ih => have hpr_p := is_prime _ (Finset.mem_insert_self _ _) have hpr_s : ∀ p ∈ s, Prime p := fun p hp => is_prime _ (Finset.mem_insert_of_mem hp) have hcp_p := fun i => prime_pow_coprime_prod_of_coprime_insert i p hps is_prime is_coprime have hcp_s : ∀ᵉ (p ∈ s) (q ∈ s), p ∣ q → p = q := fun p hp q hq => is_coprime p (Finset.mem_insert_of_mem hp) q (Finset.mem_insert_of_mem hq) rw [Finset.prod_insert hps, Finset.prod_insert hps, Finset.prod_insert hps, hcp (hcp_p _), hpr _ hpr_p, hcp (hcp_p _), hpr _ hpr_p, hcp (hcp_p (fun p => i p + j p)), hpr _ hpr_p, ih hpr_s hcp_s, pow_add, mul_assoc, mul_left_comm (f p ^ j p), mul_assoc]
theorem
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean
multiplicative_prime_power
If `f` maps `p ^ i` to `(f p) ^ i` for primes `p`, and `f` is multiplicative on coprime elements, then `f` is multiplicative on all products of primes.
multiplicative_of_coprime (f : α → β) (a b : α) (h0 : f 0 = 0) (h1 : ∀ {x y}, IsUnit y → f (x * y) = f x * f y) (hpr : ∀ {p} (i : ℕ), Prime p → f (p ^ i) = f p ^ i) (hcp : ∀ {x y}, IsRelPrime x y → f (x * y) = f x * f y) : f (a * b) = f a * f b := by letI := Classical.decEq α by_cases ha0 : a = 0 · rw [ha0, zero_mul, h0, zero_mul] by_cases hb0 : b = 0 · rw [hb0, mul_zero, h0, mul_zero] by_cases hf1 : f 1 = 0 · calc f (a * b) = f (a * b * 1) := by rw [mul_one] _ = 0 := by simp only [h1 isUnit_one, hf1, mul_zero] _ = f a * f (b * 1) := by simp only [h1 isUnit_one, hf1, mul_zero] _ = f a * f b := by rw [mul_one] haveI : Nontrivial α := ⟨⟨_, _, ha0⟩⟩ letI : NormalizationMonoid α := UniqueFactorizationMonoid.normalizationMonoid suffices f (∏ p ∈ (normalizedFactors a).toFinset ∪ (normalizedFactors b).toFinset, p ^ ((normalizedFactors a).count p + (normalizedFactors b).count p)) = f (∏ p ∈ (normalizedFactors a).toFinset ∪ (normalizedFactors b).toFinset, p ^ (normalizedFactors a).count p) * f (∏ p ∈ (normalizedFactors a).toFinset ∪ (normalizedFactors b).toFinset, p ^ (normalizedFactors b).count p) by obtain ⟨ua, a_eq⟩ := prod_normalizedFactors ha0 obtain ⟨ub, b_eq⟩ := prod_normalizedFactors hb0 rw [← a_eq, ← b_eq, mul_right_comm (Multiset.prod (normalizedFactors a)) ua (Multiset.prod (normalizedFactors b) * ub), h1 ua.isUnit, h1 ub.isUnit, h1 ua.isUnit, ← mul_assoc, h1 ub.isUnit, mul_right_comm _ (f ua), ← mul_assoc] congr rw [← (normalizedFactors a).map_id, ← (normalizedFactors b).map_id, Finset.prod_multiset_map_count, Finset.prod_multiset_map_count, Finset.prod_subset (Finset.subset_union_left (s₂ := (normalizedFactors b).toFinset)), Finset.prod_subset (Finset.subset_union_right (s₂ := (normalizedFactors b).toFinset)), ← Finset.prod_mul_distrib] · simp_rw [id, ← pow_add, this] all_goals simp only [Multiset.mem_toFinset] · intro p _ hpb simp [hpb] · intro p _ hpa simp [hpa] refine multiplicative_prime_power _ _ _ ?_ ?_ @h1 @hpr @hcp all_goals simp only [Multiset.mem_toFinset, Finset.mem_union] · rintro p (hpa | hpb) <;> apply prime_of_normalized_factor <;> assumption · rintro p (hp | hp) q (hq | hq) hdvd <;> rw [← normalize_normalized_factor _ hp, ← normalize_normalized_factor _ hq] <;> exact normalize_eq_normalize hdvd ((prime_of_normalized_factor _ hp).irreducible.dvd_symm (prime_of_normalized_factor _ hq).irreducible hdvd) ...
theorem
RingTheory
[ "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean
multiplicative_of_coprime
If `f` maps `p ^ i` to `(f p) ^ i` for primes `p`, and `f` is multiplicative on coprime elements, then `f` is multiplicative everywhere.
WfDvdMonoid.max_power_factor' [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α} (h : a₀ ≠ 0) (hx : ¬IsUnit x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a := by obtain ⟨a, ⟨n, rfl⟩, hm⟩ := wellFounded_dvdNotUnit.has_min {a | ∃ n, x ^ n * a = a₀} ⟨a₀, 0, by rw [pow_zero, one_mul]⟩ refine ⟨n, a, ?_, rfl⟩; rintro ⟨d, rfl⟩ exact hm d ⟨n + 1, by rw [pow_succ, mul_assoc]⟩ ⟨(right_ne_zero_of_mul <| right_ne_zero_of_mul h), x, hx, mul_comm _ _⟩
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
WfDvdMonoid.max_power_factor'
null
WfDvdMonoid.max_power_factor [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α} (h : a₀ ≠ 0) (hx : Irreducible x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a := max_power_factor' h hx.not_isUnit
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
WfDvdMonoid.max_power_factor
null
FiniteMultiplicity.of_not_isUnit [CancelCommMonoidWithZero α] [WfDvdMonoid α] {a b : α} (ha : ¬IsUnit a) (hb : b ≠ 0) : FiniteMultiplicity a b := by obtain ⟨n, c, ndvd, rfl⟩ := WfDvdMonoid.max_power_factor' hb ha exact ⟨n, by rwa [pow_succ, mul_dvd_mul_iff_left (left_ne_zero_of_mul hb)]⟩
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
FiniteMultiplicity.of_not_isUnit
null
FiniteMultiplicity.of_prime_left [CancelCommMonoidWithZero α] [WfDvdMonoid α] {a b : α} (ha : Prime a) (hb : b ≠ 0) : FiniteMultiplicity a b := .of_not_isUnit ha.not_unit hb
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
FiniteMultiplicity.of_prime_left
null
le_emultiplicity_iff_replicate_le_normalizedFactors {a b : R} {n : ℕ} (ha : Irreducible a) (hb : b ≠ 0) : ↑n ≤ emultiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by rw [← pow_dvd_iff_le_emultiplicity] revert b induction n with | zero => simp | succ n ih => ?_ intro b hb constructor · rintro ⟨c, rfl⟩ rw [Ne, pow_succ', mul_assoc, mul_eq_zero, not_or] at hb rw [pow_succ', mul_assoc, normalizedFactors_mul hb.1 hb.2, replicate_succ, normalizedFactors_irreducible ha, singleton_add, cons_le_cons_iff, ← ih hb.2] apply Dvd.intro _ rfl · rw [Multiset.le_iff_exists_add] rintro ⟨u, hu⟩ rw [← (prod_normalizedFactors hb).dvd_iff_dvd_right, hu, prod_add, prod_replicate] exact (Associated.pow_pow <| associated_normalize a).dvd.trans (Dvd.intro u.prod rfl)
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
le_emultiplicity_iff_replicate_le_normalizedFactors
null
emultiplicity_eq_count_normalizedFactors [DecidableEq R] {a b : R} (ha : Irreducible a) (hb : b ≠ 0) : emultiplicity a b = (normalizedFactors b).count (normalize a) := by apply le_antisymm · apply Order.le_of_lt_add_one rw [← Nat.cast_one, ← Nat.cast_add, lt_iff_not_ge, le_emultiplicity_iff_replicate_le_normalizedFactors ha hb, ← le_count_iff_replicate_le] simp rw [le_emultiplicity_iff_replicate_le_normalizedFactors ha hb, ← le_count_iff_replicate_le]
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
emultiplicity_eq_count_normalizedFactors
The multiplicity of an irreducible factor of a nonzero element is exactly the number of times the normalized factor occurs in the `normalizedFactors`. See also `count_normalizedFactors_eq` which expands the definition of `multiplicity` to produce a specification for `count (normalizedFactors _) _`..
count_normalizedFactors_eq [DecidableEq R] {p x : R} (hp : Irreducible p) (hnorm : normalize p = p) {n : ℕ} (hle : p ^ n ∣ x) (hlt : ¬p ^ (n + 1) ∣ x) : (normalizedFactors x).count p = n := by classical by_cases hx0 : x = 0 · simp [hx0] at hlt apply Nat.cast_injective (R := ℕ∞) convert (emultiplicity_eq_count_normalizedFactors hp hx0).symm · exact hnorm.symm exact (emultiplicity_eq_coe.mpr ⟨hle, hlt⟩).symm
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
count_normalizedFactors_eq
The number of times an irreducible factor `p` appears in `normalizedFactors x` is defined by the number of times it divides `x`. See also `multiplicity_eq_count_normalizedFactors` if `n` is given by `multiplicity p x`.
count_normalizedFactors_eq' [DecidableEq R] {p x : R} (hp : p = 0 ∨ Irreducible p) (hnorm : normalize p = p) {n : ℕ} (hle : p ^ n ∣ x) (hlt : ¬p ^ (n + 1) ∣ x) : (normalizedFactors x).count p = n := by rcases hp with (rfl | hp) · cases n · exact count_eq_zero.2 (zero_notMem_normalizedFactors _) · rw [zero_pow (Nat.succ_ne_zero _)] at hle hlt exact absurd hle hlt · exact count_normalizedFactors_eq hp hnorm hle hlt
theorem
RingTheory
[ "Mathlib.RingTheory.Multiplicity", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean
count_normalizedFactors_eq'
The number of times an irreducible factor `p` appears in `normalizedFactors x` is defined by the number of times it divides `x`. This is a slightly more general version of `UniqueFactorizationMonoid.count_normalizedFactors_eq` that allows `p = 0`. See also `multiplicity_eq_count_normalizedFactors` if `n` is given by `multiplicity p x`.
instWfDvdMonoid : WfDvdMonoid ℕ where wf := by refine RelHomClass.wellFounded (⟨fun x : ℕ => if x = 0 then (⊤ : ℕ∞) else x, ?_⟩ : DvdNotUnit →r (· < ·)) wellFounded_lt intro a b h rcases a with - | a · exfalso revert h simp [DvdNotUnit] cases b · simp obtain ⟨h1, h2⟩ := dvd_and_not_dvd_iff.2 h simp only [succ_ne_zero, cast_lt, if_false] refine lt_of_le_of_ne (Nat.le_of_dvd (Nat.succ_pos _) h1) fun con => h2 ?_ rw [con]
instance
RingTheory
[ "Mathlib.Data.ENat.Basic", "Mathlib.Data.Nat.Factors", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Nat.lean
instWfDvdMonoid
null
instUniqueFactorizationMonoid : UniqueFactorizationMonoid ℕ where irreducible_iff_prime := Nat.irreducible_iff_prime open UniqueFactorizationMonoid
instance
RingTheory
[ "Mathlib.Data.ENat.Basic", "Mathlib.Data.Nat.Factors", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Nat.lean
instUniqueFactorizationMonoid
null
factors_eq : ∀ n : ℕ, normalizedFactors n = n.primeFactorsList | 0 => by simp | n + 1 => by rw [← Multiset.rel_eq, ← associated_eq_eq] apply UniqueFactorizationMonoid.factors_unique irreducible_of_normalized_factor _ · rw [Multiset.prod_coe, Nat.prod_primeFactorsList n.succ_ne_zero] exact prod_normalizedFactors n.succ_ne_zero · intro x hx rw [Nat.irreducible_iff_prime, ← Nat.prime_iff] exact Nat.prime_of_mem_primeFactorsList hx
lemma
RingTheory
[ "Mathlib.Data.ENat.Basic", "Mathlib.Data.Nat.Factors", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Nat.lean
factors_eq
null
factors_multiset_prod_of_irreducible {s : Multiset ℕ} (h : ∀ x : ℕ, x ∈ s → Irreducible x) : normalizedFactors s.prod = s := by rw [← Multiset.rel_eq, ← associated_eq_eq] apply UniqueFactorizationMonoid.factors_unique irreducible_of_normalized_factor h (prod_normalizedFactors _) rw [Ne, Multiset.prod_eq_zero_iff] exact fun con ↦ not_irreducible_zero (h 0 con)
lemma
RingTheory
[ "Mathlib.Data.ENat.Basic", "Mathlib.Data.Nat.Factors", "Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors" ]
Mathlib/RingTheory/UniqueFactorizationDomain/Nat.lean
factors_multiset_prod_of_irreducible
null
noncomputable normalizedFactors (a : α) : Multiset α := Multiset.map normalize <| factors a
def
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors
Noncomputably determines the multiset of prime factors.
@[simp] factors_eq_normalizedFactors {M : Type*} [CancelCommMonoidWithZero M] [UniqueFactorizationMonoid M] [Subsingleton Mˣ] (x : M) : factors x = normalizedFactors x := by unfold normalizedFactors convert (Multiset.map_id (factors x)).symm ext p exact normalize_eq p
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
factors_eq_normalizedFactors
An arbitrary choice of factors of `x : M` is exactly the (unique) normalized set of factors, if `M` has a trivial group of units.
prod_normalizedFactors {a : α} (ane0 : a ≠ 0) : Associated (normalizedFactors a).prod a := by rw [normalizedFactors, factors, dif_neg ane0] refine Associated.trans ?_ (Classical.choose_spec (exists_prime_factors a ane0)).2 rw [← Associates.mk_eq_mk_iff_associated, ← Associates.prod_mk, ← Associates.prod_mk, Multiset.map_map] congr 2 ext rw [Function.comp_apply, Associates.mk_normalize]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
prod_normalizedFactors
null
prod_normalizedFactors_eq {a : α} (ane0 : a ≠ 0) : (normalizedFactors a).prod = normalize a := by trans normalize (normalizedFactors a).prod · rw [normalizedFactors, ← map_multiset_prod, normalize_idem] · exact normalize_eq_normalize_iff.mpr (dvd_dvd_iff_associated.mpr (prod_normalizedFactors ane0))
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
prod_normalizedFactors_eq
null
prime_of_normalized_factor {a : α} : ∀ x : α, x ∈ normalizedFactors a → Prime x := by rw [normalizedFactors, factors] split_ifs with ane0; · simp intro x hx; rcases Multiset.mem_map.1 hx with ⟨y, ⟨hy, rfl⟩⟩ rw [(normalize_associated _).prime_iff] exact (Classical.choose_spec (UniqueFactorizationMonoid.exists_prime_factors a ane0)).1 y hy
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
prime_of_normalized_factor
null
irreducible_of_normalized_factor {a : α} : ∀ x : α, x ∈ normalizedFactors a → Irreducible x := fun x h => (prime_of_normalized_factor x h).irreducible
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
irreducible_of_normalized_factor
null
normalize_normalized_factor {a : α} : ∀ x : α, x ∈ normalizedFactors a → normalize x = x := by rw [normalizedFactors, factors] split_ifs with h; · simp intro x hx obtain ⟨y, _, rfl⟩ := Multiset.mem_map.1 hx apply normalize_idem
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalize_normalized_factor
null
normalizedFactors_irreducible {a : α} (ha : Irreducible a) : normalizedFactors a = {normalize a} := by obtain ⟨p, a_assoc, hp⟩ := prime_factors_irreducible ha ⟨prime_of_normalized_factor, prod_normalizedFactors ha.ne_zero⟩ have p_mem : p ∈ normalizedFactors a := by rw [hp] exact Multiset.mem_singleton_self _ convert hp rwa [← normalize_normalized_factor p p_mem, normalize_eq_normalize_iff, dvd_dvd_iff_associated]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors_irreducible
null
normalizedFactors_eq_of_dvd (a : α) : ∀ᵉ (p ∈ normalizedFactors a) (q ∈ normalizedFactors a), p ∣ q → p = q := by intro p hp q hq hdvd convert normalize_eq_normalize hdvd ((prime_of_normalized_factor _ hp).irreducible.dvd_symm (prime_of_normalized_factor _ hq).irreducible hdvd) <;> apply (normalize_normalized_factor _ ‹_›).symm
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors_eq_of_dvd
null
exists_mem_normalizedFactors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) : p ∣ a → ∃ q ∈ normalizedFactors a, p ~ᵤ q := fun ⟨b, hb⟩ => have hb0 : b ≠ 0 := fun hb0 => by simp_all have : Multiset.Rel Associated (p ::ₘ normalizedFactors b) (normalizedFactors a) := factors_unique (fun _ hx => (Multiset.mem_cons.1 hx).elim (fun h => h.symm ▸ hp) (irreducible_of_normalized_factor _)) irreducible_of_normalized_factor (Associated.symm <| calc Multiset.prod (normalizedFactors a) ~ᵤ a := prod_normalizedFactors ha0 _ = p * b := hb _ ~ᵤ Multiset.prod (p ::ₘ normalizedFactors b) := by rw [Multiset.prod_cons] exact (prod_normalizedFactors hb0).symm.mul_left _ ) Multiset.exists_mem_of_rel_of_mem this (by simp)
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
exists_mem_normalizedFactors_of_dvd
null
exists_mem_normalizedFactors {x : α} (hx : x ≠ 0) (h : ¬IsUnit x) : ∃ p, p ∈ normalizedFactors x := by obtain ⟨p', hp', hp'x⟩ := WfDvdMonoid.exists_irreducible_factor h hx obtain ⟨p, hp, _⟩ := exists_mem_normalizedFactors_of_dvd hx hp' hp'x exact ⟨p, hp⟩ @[simp]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
exists_mem_normalizedFactors
null
normalizedFactors_zero : normalizedFactors (0 : α) = 0 := by simp [normalizedFactors, factors] @[simp]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors_zero
null
normalizedFactors_one : normalizedFactors (1 : α) = 0 := by rcases subsingleton_or_nontrivial α with h | h · dsimp [normalizedFactors, factors] simp [Subsingleton.elim (1 : α) 0] · rw [← Multiset.rel_zero_right] apply factors_unique irreducible_of_normalized_factor · intro x hx exfalso apply Multiset.notMem_zero x hx · apply prod_normalizedFactors one_ne_zero @[simp]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors_one
null
normalizedFactors_mul {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) : normalizedFactors (x * y) = normalizedFactors x + normalizedFactors y := by have h : (normalize : α → α) = Associates.out ∘ Associates.mk := by ext rw [Function.comp_apply, Associates.out_mk] rw [← Multiset.map_id' (normalizedFactors (x * y)), ← Multiset.map_id' (normalizedFactors x), ← Multiset.map_id' (normalizedFactors y), ← Multiset.map_congr rfl normalize_normalized_factor, ← Multiset.map_congr rfl normalize_normalized_factor, ← Multiset.map_congr rfl normalize_normalized_factor, ← Multiset.map_add, h, ← Multiset.map_map Associates.out, eq_comm, ← Multiset.map_map Associates.out] refine congr rfl ?_ apply Multiset.map_mk_eq_map_mk_of_rel apply factors_unique · intro x hx rcases Multiset.mem_add.1 hx with (hx | hx) <;> exact irreducible_of_normalized_factor x hx · exact irreducible_of_normalized_factor · rw [Multiset.prod_add] exact ((prod_normalizedFactors hx).mul_mul (prod_normalizedFactors hy)).trans (prod_normalizedFactors (mul_ne_zero hx hy)).symm @[simp]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors_mul
null
normalizedFactors_pow {x : α} (n : ℕ) : normalizedFactors (x ^ n) = n • normalizedFactors x := by induction n with | zero => simp [zero_nsmul] | succ n ih => by_cases h0 : x = 0 · simp [h0, zero_pow n.succ_ne_zero, nsmul_zero] rw [pow_succ', succ_nsmul', normalizedFactors_mul h0 (pow_ne_zero _ h0), ih]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors_pow
null
_root_.Irreducible.normalizedFactors_pow {p : α} (hp : Irreducible p) (k : ℕ) : normalizedFactors (p ^ k) = Multiset.replicate k (normalize p) := by rw [UniqueFactorizationMonoid.normalizedFactors_pow, normalizedFactors_irreducible hp, Multiset.nsmul_singleton]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
_root_.Irreducible.normalizedFactors_pow
null
normalizedFactors_prod_eq (s : Multiset α) (hs : ∀ a ∈ s, Irreducible a) : normalizedFactors s.prod = s.map normalize := by induction s using Multiset.induction with | empty => rw [Multiset.prod_zero, normalizedFactors_one, Multiset.map_zero] | cons a s ih => have ia := hs a (Multiset.mem_cons_self a _) have ib := fun b h => hs b (Multiset.mem_cons_of_mem h) obtain rfl | ⟨b, hb⟩ := s.empty_or_exists_mem · rw [Multiset.cons_zero, Multiset.prod_singleton, Multiset.map_singleton, normalizedFactors_irreducible ia] haveI := nontrivial_of_ne b 0 (ib b hb).ne_zero rw [Multiset.prod_cons, Multiset.map_cons, normalizedFactors_mul ia.ne_zero (Multiset.prod_ne_zero fun h => (ib 0 h).ne_zero rfl), normalizedFactors_irreducible ia, ih ib, Multiset.singleton_add]
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
normalizedFactors_prod_eq
null
dvd_iff_normalizedFactors_le_normalizedFactors {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) : x ∣ y ↔ normalizedFactors x ≤ normalizedFactors y := by constructor · rintro ⟨c, rfl⟩ simp [hx, right_ne_zero_of_mul hy] · rw [← (prod_normalizedFactors hx).dvd_iff_dvd_left, ← (prod_normalizedFactors hy).dvd_iff_dvd_right] apply Multiset.prod_dvd_prod_of_le
theorem
RingTheory
[ "Mathlib.Algebra.GCDMonoid.Basic", "Mathlib.Data.Multiset.OrderedMonoid", "Mathlib.RingTheory.UniqueFactorizationDomain.Basic" ]
Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean
dvd_iff_normalizedFactors_le_normalizedFactors
null