Skip to content

Commit

Permalink
feat(RingTheory/UniqueFactorizationDomain): add `WfDvdMonoid.max_powe…
Browse files Browse the repository at this point in the history
…r_factor[']` and `multiplicity.finite_of_not_isUnit` (#11066)

- makes `UniqueFactorizationMonoid.max_power_factor` obsolete
- makes the proof of `multiplicity.finite_prime_left` trivial
- relax the condition of `exists_reduced_fraction'`

Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>
  • Loading branch information
acmepjz and alreadydone committed Mar 1, 2024
1 parent 2a07395 commit c7394bf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
19 changes: 2 additions & 17 deletions Mathlib/Algebra/Squarefree/Basic.lean
Expand Up @@ -130,23 +130,8 @@ section CancelCommMonoidWithZero

variable [CancelCommMonoidWithZero R] [WfDvdMonoid R]

theorem finite_prime_left {a b : R} (ha : Prime a) (hb : b ≠ 0) : multiplicity.Finite a b := by
classical
revert hb
refine'
WfDvdMonoid.induction_on_irreducible b (fun c => c.irrefl.elim) (fun u hu _ => _)
fun b p hb hp ih _ => _
· rw [multiplicity.finite_iff_dom, multiplicity.isUnit_right ha.not_unit hu]
exact PartENat.dom_natCast 0
· refine'
multiplicity.finite_mul ha
(multiplicity.finite_iff_dom.mpr
(PartENat.dom_of_le_natCast (show multiplicity a p ≤ ↑1 from _)))
(ih hb)
norm_cast
exact
((multiplicity.squarefree_iff_multiplicity_le_one p).mp hp.squarefree a).resolve_right
ha.not_unit
theorem finite_prime_left {a b : R} (ha : Prime a) (hb : b ≠ 0) : multiplicity.Finite a b :=
finite_of_not_isUnit ha.not_unit hb
#align multiplicity.finite_prime_left multiplicity.finite_prime_left

end CancelCommMonoidWithZero
Expand Down
7 changes: 3 additions & 4 deletions Mathlib/RingTheory/Localization/Away/Basic.lean
Expand Up @@ -176,7 +176,7 @@ variable {R : Type*} [CommRing R]

section NumDen

open UniqueFactorizationMonoid IsLocalization
open IsLocalization

variable (x : R)

Expand Down Expand Up @@ -281,7 +281,7 @@ theorem selfZPow_pow_sub (a : R) (b : B) (m d : ℤ) :
rwa [mul_comm _ b, mul_assoc b _ _, selfZPow_mul_neg, mul_one] at this
#align self_zpow_pow_sub selfZPow_pow_sub

variable [IsDomain R] [NormalizationMonoid R] [UniqueFactorizationMonoid R]
variable [IsDomain R] [WfDvdMonoid R]

theorem exists_reduced_fraction' {b : B} (hb : b ≠ 0) (hx : Irreducible x) :
∃ (a : R) (n : ℤ), ¬x ∣ a ∧ selfZPow x B n * algebraMap R B a = b := by
Expand All @@ -301,8 +301,7 @@ theorem exists_reduced_fraction' {b : B} (hb : b ≠ 0) (hx : Irreducible x) :
(mem_nonZeroDivisors_iff_ne_zero.mpr hx.ne_zero)
exact IsLocalization.injective B (powers_le_nonZeroDivisors_of_noZeroDivisors hx.ne_zero)
simp only [← hy] at H
classical
obtain ⟨m, a, hyp1, hyp2⟩ := max_power_factor ha₀ hx
obtain ⟨m, a, hyp1, hyp2⟩ := WfDvdMonoid.max_power_factor ha₀ hx
refine' ⟨a, m - d, _⟩
rw [← mk'_one (M := Submonoid.powers x) B, selfZPow_pow_sub, selfZPow_coe_nat, selfZPow_coe_nat,
← map_pow _ _ d, mul_comm _ b, H, hyp2, map_mul, map_pow _ _ m]
Expand Down
33 changes: 21 additions & 12 deletions Mathlib/RingTheory/UniqueFactorizationDomain.lean
Expand Up @@ -148,6 +148,23 @@ theorem WfDvdMonoid.iff_wellFounded_associates [CancelCommMonoidWithZero α] :
by apply WfDvdMonoid.wellFounded_associates, WfDvdMonoid.of_wellFounded_associates⟩
#align wf_dvd_monoid.iff_well_founded_associates WfDvdMonoid.iff_wellFounded_associates

theorem 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 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_unit

theorem multiplicity.finite_of_not_isUnit [CancelCommMonoidWithZero α] [WfDvdMonoid α]
{a b : α} (ha : ¬IsUnit a) (hb : b ≠ 0) : multiplicity.Finite 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)]⟩

section Prio

-- set_option default_priority 100
Expand Down Expand Up @@ -1046,20 +1063,12 @@ theorem count_normalizedFactors_eq' [DecidableEq R] {p x : R} (hp : p = 0 ∨ Ir
· exact count_normalizedFactors_eq hp hnorm hle hlt
#align unique_factorization_monoid.count_normalized_factors_eq' UniqueFactorizationMonoid.count_normalizedFactors_eq'


theorem max_power_factor {a₀ : R} {x : R} (h : a₀ ≠ 0) (hx : Irreducible x) :
∃ n : ℕ, ∃ a : R, ¬x ∣ a ∧ a₀ = x ^ n * a := by
classical
let n := (normalizedFactors a₀).count (normalize x)
obtain ⟨a, ha1, ha2⟩ := @exists_eq_pow_mul_and_not_dvd R _ _ x a₀
(ne_top_iff_finite.mp (PartENat.ne_top_iff.mpr
-- Porting note: this was a hole that was filled at the end of the proof with `use`:
⟨n, multiplicity_eq_count_normalizedFactors hx h⟩))
simp_rw [← (multiplicity_eq_count_normalizedFactors hx h).symm] at ha1
use n, a, ha2, ha1
/-- Deprecated. Use `WfDvdMonoid.max_power_factor` instead. -/
@[deprecated WfDvdMonoid.max_power_factor]
theorem max_power_factor {a₀ x : R} (h : a₀ ≠ 0) (hx : Irreducible x) :
∃ n : ℕ, ∃ a : R, ¬x ∣ a ∧ a₀ = x ^ n * a := WfDvdMonoid.max_power_factor h hx
#align unique_factorization_monoid.max_power_factor UniqueFactorizationMonoid.max_power_factor


end multiplicity

section Multiplicative
Expand Down

0 comments on commit c7394bf

Please sign in to comment.