Theorem: UniqueFactorizationMonoid.squarefree_iff_nodup_normalizedFactors
File: Mathlib/Algebra/Squarefree.lean

tactic: have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
state_before: R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
⊢ Squarefree x ↔ Multiset.Nodup (normalizedFactors x)

tactic: rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
state_before: R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
⊢ Squarefree x ↔ Multiset.Nodup (normalizedFactors x)

tactic: haveI := nontrivial_of_ne x 0 x0
state_before: R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
⊢ (∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1) ↔ ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1

tactic: constructor <;> intro h a
state_before: R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
⊢ (∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1) ↔ ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1

tactic: classical infer_instance
state_before: R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
⊢ DecidableRel Dvd.dvd

tactic: infer_instance
state_before: R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
⊢ DecidableRel Dvd.dvd

tactic: by_cases hmem : a ∈ normalizedFactors x
state_before: case mp
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
⊢ Multiset.count a (normalizedFactors x) ≤ 1

tactic: have ha := irreducible_of_normalized_factor _ hmem
state_before: case pos
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : a ∈ normalizedFactors x
⊢ Multiset.count a (normalizedFactors x) ≤ 1

tactic: rcases h a with (h | h)
state_before: case pos
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : a ∈ normalizedFactors x
ha : Irreducible a
⊢ Multiset.count a (normalizedFactors x) ≤ 1

tactic: rw [← normalize_normalized_factor _ hmem]
state_before: case pos.inl
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h✝ : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : a ∈ normalizedFactors x
ha : Irreducible a
h : multiplicity a x ≤ 1
⊢ Multiset.count a (normalizedFactors x) ≤ 1

tactic: rw [multiplicity_eq_count_normalizedFactors ha x0] at h
state_before: case pos.inl
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h✝ : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : a ∈ normalizedFactors x
ha : Irreducible a
h : multiplicity a x ≤ 1
⊢ Multiset.count (↑normalize a) (normalizedFactors x) ≤ 1

tactic: assumption_mod_cast
state_before: case pos.inl
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h✝ : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : a ∈ normalizedFactors x
ha : Irreducible a
h : ↑(Multiset.count (↑normalize a) (normalizedFactors x)) ≤ 1
⊢ Multiset.count (↑normalize a) (normalizedFactors x) ≤ 1

tactic: have := ha.1
state_before: case pos.inr
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h✝ : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : a ∈ normalizedFactors x
ha : Irreducible a
h : IsUnit a
⊢ Multiset.count a (normalizedFactors x) ≤ 1

tactic: contradiction
state_before: case pos.inr
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this✝ : Nontrivial R
h✝ : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : a ∈ normalizedFactors x
ha : Irreducible a
h : IsUnit a
this : ¬IsUnit a
⊢ Multiset.count a (normalizedFactors x) ≤ 1

tactic: simp [Multiset.count_eq_zero_of_not_mem hmem]
state_before: case neg
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1
a : R
hmem : ¬a ∈ normalizedFactors x
⊢ Multiset.count a (normalizedFactors x) ≤ 1

tactic: rw [or_iff_not_imp_right]
state_before: case mpr
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
⊢ multiplicity a x ≤ 1 ∨ IsUnit a

tactic: intro hu
state_before: case mpr
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
⊢ ¬IsUnit a → multiplicity a x ≤ 1

tactic: by_cases h0 : a = 0
state_before: case mpr
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
hu : ¬IsUnit a
⊢ multiplicity a x ≤ 1

tactic: rcases WfDvdMonoid.exists_irreducible_factor hu h0 with ⟨b, hib, hdvd⟩
state_before: case neg
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
hu : ¬IsUnit a
h0 : ¬a = 0
⊢ multiplicity a x ≤ 1

tactic: apply le_trans (multiplicity.multiplicity_le_multiplicity_of_dvd_left hdvd)
state_before: case neg.intro.intro
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
hu : ¬IsUnit a
h0 : ¬a = 0
b : R
hib : Irreducible b
hdvd : b ∣ a
⊢ multiplicity a x ≤ 1

tactic: rw [multiplicity_eq_count_normalizedFactors hib x0]
state_before: case neg.intro.intro
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
hu : ¬IsUnit a
h0 : ¬a = 0
b : R
hib : Irreducible b
hdvd : b ∣ a
⊢ multiplicity b x ≤ 1

tactic: specialize h (normalize b)
state_before: case neg.intro.intro
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
hu : ¬IsUnit a
h0 : ¬a = 0
b : R
hib : Irreducible b
hdvd : b ∣ a
⊢ ↑(Multiset.count (↑normalize b) (normalizedFactors x)) ≤ 1

tactic: assumption_mod_cast
state_before: case neg.intro.intro
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
a : R
hu : ¬IsUnit a
h0 : ¬a = 0
b : R
hib : Irreducible b
hdvd : b ∣ a
h : Multiset.count (↑normalize b) (normalizedFactors x) ≤ 1
⊢ ↑(Multiset.count (↑normalize b) (normalizedFactors x)) ≤ 1

tactic: simp [h0, x0]
state_before: case pos
R : Type u_1
inst✝³ : CancelCommMonoidWithZero R
inst✝² : UniqueFactorizationMonoid R
inst✝¹ : NormalizationMonoid R
inst✝ : DecidableEq R
x : R
x0 : x ≠ 0
drel : DecidableRel Dvd.dvd
this : Nontrivial R
h : ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1
a : R
hu : ¬IsUnit a
h0 : a = 0
⊢ multiplicity a x ≤ 1