@@ -10,7 +10,7 @@ public import Mathlib.Data.ENat.Basic
1010public import Mathlib.RingTheory.UniqueFactorizationDomain.Defs
1111
1212/-!
13- # Basic results un unique factorization monoids
13+ # Basic results on unique factorization monoids
1414
1515## Main results
1616* `prime_factors_unique`: the prime factors of an element in a cancellative
@@ -185,31 +185,33 @@ theorem irreducible_iff_prime_of_existsUnique_irreducible_factors [CommMonoidWit
185185
186186namespace UniqueFactorizationMonoid
187187
188+ open Multiset
189+
188190variable [CommMonoidWithZero α]
189191variable [UniqueFactorizationMonoid α]
190192
191193@[simp]
192194theorem factors_one : factors (1 : α) = 0 := by
193195 nontriviality α using factors
194- rw [← Multiset. rel_zero_right]
195- refine factors_unique irreducible_of_factor (fun x hx => (Multiset. notMem_zero x hx).elim) ?_
196- rw [Multiset. prod_zero]
196+ rw [← rel_zero_right]
197+ refine factors_unique irreducible_of_factor (fun x hx => (notMem_zero x hx).elim) ?_
198+ rw [prod_zero]
197199 exact factors_prod one_ne_zero
198200
199201theorem exists_mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0 ) (hp : Irreducible p) :
200202 p ∣ a → ∃ q ∈ factors a, p ~ᵤ q := fun ⟨b, hb⟩ =>
201203 have hb0 : b ≠ 0 := fun hb0 => by simp_all
202- have : Multiset. Rel Associated (p ::ₘ factors b) (factors a) :=
204+ have : Rel Associated (p ::ₘ factors b) (factors a) :=
203205 factors_unique
204- (fun _ hx => (Multiset. mem_cons.1 hx).elim (fun h => h.symm ▸ hp) (irreducible_of_factor _))
206+ (fun _ hx => (mem_cons.1 hx).elim (fun h => h.symm ▸ hp) (irreducible_of_factor _))
205207 irreducible_of_factor
206208 (Associated.symm <|
207209 calc
208- Multiset. prod (factors a) ~ᵤ a := factors_prod ha0
210+ prod (factors a) ~ᵤ a := factors_prod ha0
209211 _ = p * b := hb
210- _ ~ᵤ Multiset. prod (p ::ₘ factors b) := by
211- rw [Multiset. prod_cons]; exact (factors_prod hb0).symm.mul_left _)
212- Multiset. exists_mem_of_rel_of_mem this (by simp)
212+ _ ~ᵤ prod (p ::ₘ factors b) := by
213+ rw [prod_cons]; exact (factors_prod hb0).symm.mul_left _)
214+ exists_mem_of_rel_of_mem this (by simp)
213215
214216theorem exists_mem_factors {x : α} (hx : x ≠ 0 ) (h : ¬IsUnit x) : ∃ p, p ∈ factors x := by
215217 obtain ⟨p', hp', hp'x⟩ := WfDvdMonoid.exists_irreducible_factor h hx
@@ -224,40 +226,27 @@ theorem factors_eq_singleton_of_irreducible {a : α} (ha : Irreducible a) :
224226
225227open Classical in
226228theorem factors_mul {x y : α} (hx : x ≠ 0 ) (hy : y ≠ 0 ) :
227- Multiset. Rel Associated (factors (x * y)) (factors x + factors y) := by
229+ Rel Associated (factors (x * y)) (factors x + factors y) := by
228230 refine
229231 factors_unique irreducible_of_factor
230232 (fun a ha =>
231- (Multiset. mem_add.mp ha).by_cases (irreducible_of_factor _) (irreducible_of_factor _))
233+ (mem_add.mp ha).by_cases (irreducible_of_factor _) (irreducible_of_factor _))
232234 ((factors_prod (mul_ne_zero hx hy)).trans ?_)
233- rw [Multiset. prod_add]
235+ rw [prod_add]
234236 exact (Associated.mul_mul (factors_prod hx) (factors_prod hy)).symm
235237
236238theorem factors_pow {x : α} (n : ℕ) :
237- Multiset. Rel Associated (factors (x ^ n)) (n • factors x) := by
239+ Rel Associated (factors (x ^ n)) (n • factors x) := by
238240 match n with
239- | 0 => rw [zero_nsmul, pow_zero, factors_one, Multiset. rel_zero_right]
241+ | 0 => rw [zero_nsmul, pow_zero, factors_one, rel_zero_right]
240242 | n + 1 =>
241243 by_cases h0 : x = 0
242244 · simp [h0, zero_pow n.succ_ne_zero, nsmul_zero]
243245 · rw [pow_succ', succ_nsmul']
244- refine Multiset. Rel.trans _ (factors_mul h0 (pow_ne_zero n h0)) ?_
245- refine Multiset. Rel.add ?_ <| factors_pow n
246- exact Multiset. rel_refl_of_refl_on fun y _ => Associated.refl _
246+ refine Rel.trans _ (factors_mul h0 (pow_ne_zero n h0)) ?_
247+ refine Rel.add ?_ <| factors_pow n
248+ exact rel_refl_of_refl_on fun y _ => Associated.refl _
247249
248- @[simp]
249- theorem factors_pos (x : α) (hx : x ≠ 0 ) : 0 < factors x ↔ ¬IsUnit x := by
250- constructor
251- · intro h hx
252- obtain ⟨p, hp⟩ := Multiset.exists_mem_of_ne_zero h.ne'
253- exact (prime_of_factor _ hp).not_unit (isUnit_of_dvd_unit (dvd_of_mem_factors hp) hx)
254- · intro h
255- obtain ⟨p, hp⟩ := exists_mem_factors hx h
256- exact
257- bot_lt_iff_ne_bot.mpr
258- (mt Multiset.eq_zero_iff_forall_notMem.mp (not_forall.mpr ⟨p, not_not.mpr hp⟩))
259-
260- open Multiset in
261250theorem factors_pow_count_prod [DecidableEq α] {x : α} (hx : x ≠ 0 ) :
262251 (∏ p ∈ (factors x).toFinset, p ^ (factors x).count p) ~ᵤ x :=
263252 calc
@@ -267,12 +256,24 @@ theorem factors_pow_count_prod [DecidableEq α] {x : α} (hx : x ≠ 0) :
267256 _ ~ᵤ x := factors_prod hx
268257
269258theorem factors_rel_of_associated {a b : α} (h : Associated a b) :
270- Multiset. Rel Associated (factors a) (factors b) := by
259+ Rel Associated (factors a) (factors b) := by
271260 rcases iff_iff_and_or_not_and_not.mp h.eq_zero_iff with (⟨rfl, rfl⟩ | ⟨ha, hb⟩)
272261 · simp
273262 · refine factors_unique irreducible_of_factor irreducible_of_factor ?_
274263 exact ((factors_prod ha).trans h).trans (factors_prod hb).symm
275264
265+ theorem factors_of_isUnit {x : α} (hx : IsUnit x) : factors x = 0 := by
266+ simpa using factors_rel_of_associated (associated_one_iff_isUnit.mpr hx)
267+
268+ @[simp]
269+ theorem factors_eq_zero {x : α} (hx : x ≠ 0 ) : factors x = 0 ↔ IsUnit x :=
270+ ⟨fun h ↦ by contrapose! h; simpa [eq_zero_iff_forall_notMem] using exists_mem_factors hx h,
271+ factors_of_isUnit⟩
272+
273+ @[simp]
274+ theorem factors_pos {x : α} (hx : x ≠ 0 ) : 0 < factors x ↔ ¬IsUnit x :=
275+ bot_lt_iff_ne_bot.trans (not_iff_not.mpr (factors_eq_zero hx))
276+
276277end UniqueFactorizationMonoid
277278
278279namespace Associates
0 commit comments