l3lab/ntp-mathlib huggingface dataset:
theorem IsRadical.squarefree {x : R} (h0 : x ≠ 0) (h : IsRadical x) : Squarefree x := by
  

Proof state:
R : Type u_1
inst✝ : CancelCommMonoidWithZero R
x : R
h0 : x ≠ 0
h : IsRadical x
⊢ Squarefree x

Next tactic:
rintro z ⟨w, rfl⟩
theorem IsRadical.squarefree {x : R} (h0 : x ≠ 0) (h : IsRadical x) : Squarefree x := by
  rintro z ⟨w, rfl⟩
  

Proof state:
case intro
R : Type u_1
inst✝ : CancelCommMonoidWithZero R
z w : R
h0 : z * z * w ≠ 0
h : IsRadical (z * z * w)
⊢ IsUnit z

Next tactic:
specialize h 2 (z * w) ⟨w, by simp_rw [pow_two, mul_left_comm, ← mul_assoc]⟩
theorem IsRadical.squarefree {x : R} (h0 : x ≠ 0) (h : IsRadical x) : Squarefree x := by
  rintro z ⟨w, rfl⟩
  specialize h 2 (z * w) ⟨w, by 

Proof state:
R : Type u_1
inst✝ : CancelCommMonoidWithZero R
z w : R
h0 : z * z * w ≠ 0
h : IsRadical (z * z * w)
⊢ (z * w) ^ 2 = z * z * w * w

Next tactic:
simp_rw [pow_two, mul_left_comm, ← mul_assoc]
theorem IsRadical.squarefree {x : R} (h0 : x ≠ 0) (h : IsRadical x) : Squarefree x := by
  rintro z ⟨w, rfl⟩
  specialize h 2 (z * w) ⟨w, by simp_rw [pow_two, mul_left_comm, ← mul_assoc]⟩
  

Proof state:
case intro
R : Type u_1
inst✝ : CancelCommMonoidWithZero R
z w : R
h0 : z * z * w ≠ 0
h : z * z * w ∣ z * w
⊢ IsUnit z

Next tactic:
rwa [← one_mul (z * w), mul_assoc, mul_dvd_mul_iff_right, ← isUnit_iff_dvd_one] at h
theorem IsRadical.squarefree {x : R} (h0 : x ≠ 0) (h : IsRadical x) : Squarefree x := by
  rintro z ⟨w, rfl⟩
  specialize h 2 (z * w) ⟨w, by simp_rw [pow_two, mul_left_comm, ← mul_assoc]⟩
  rwa [← one_mul (z * w), mul_assoc, mul_dvd_mul_iff_right, ← isUnit_iff_dvd_one] at h
  

Proof state:
case intro
R : Type u_1
inst✝ : CancelCommMonoidWithZero R
z w : R
h0 : z * z * w ≠ 0
h : z * (z * w) ∣ 1 * (z * w)
⊢ z * w ≠ 0

Next tactic:
rw [mul_assoc, mul_ne_zero_iff] at h0
theorem IsRadical.squarefree {x : R} (h0 : x ≠ 0) (h : IsRadical x) : Squarefree x := by
  rintro z ⟨w, rfl⟩
  specialize h 2 (z * w) ⟨w, by simp_rw [pow_two, mul_left_comm, ← mul_assoc]⟩
  rwa [← one_mul (z * w), mul_assoc, mul_dvd_mul_iff_right, ← isUnit_iff_dvd_one] at h
  rw [mul_assoc, mul_ne_zero_iff] at h0; 

Proof state:
case intro
R : Type u_1
inst✝ : CancelCommMonoidWithZero R
z w : R
h0 : z ≠ 0 ∧ z * w ≠ 0
h : z * (z * w) ∣ 1 * (z * w)
⊢ z * w ≠ 0

Next tactic:
exact h0.2
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          

Proof state:
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
hy : x ∣ y ^ 2
⊢ x ∣ gcd x y

Next tactic:
by_cases h : gcd x y = 0
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · 

Proof state:
case pos
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
hy : x ∣ y ^ 2
h : gcd x y = 0
⊢ x ∣ gcd x y

Next tactic:
rw [h]
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            

Proof state:
case pos
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
hy : x ∣ y ^ 2
h : gcd x y = 0
⊢ x ∣ 0

Next tactic:
apply dvd_zero
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            apply dvd_zero
          

Proof state:
case neg
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
hy : x ∣ y ^ 2
h : ¬gcd x y = 0
⊢ x ∣ gcd x y

Next tactic:
replace hy := ((dvd_gcd_iff x x _).2 ⟨dvd_rfl, hy⟩).trans gcd_pow_right_dvd_pow_gcd
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            apply dvd_zero
          replace hy := ((dvd_gcd_iff x x _).2 ⟨dvd_rfl, hy⟩).trans gcd_pow_right_dvd_pow_gcd
          

Proof state:
case neg
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
h : ¬gcd x y = 0
hy : x ∣ gcd x y ^ 2
⊢ x ∣ gcd x y

Next tactic:
obtain ⟨z, hz⟩ := gcd_dvd_left x y
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            apply dvd_zero
          replace hy := ((dvd_gcd_iff x x _).2 ⟨dvd_rfl, hy⟩).trans gcd_pow_right_dvd_pow_gcd
          obtain ⟨z, hz⟩ := gcd_dvd_left x y
          

Proof state:
case neg.intro
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
h : ¬gcd x y = 0
hy : x ∣ gcd x y ^ 2
z : R
hz : x = gcd x y * z
⊢ x ∣ gcd x y

Next tactic:
nth_rw 1 [hz] at hy ⊢
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            apply dvd_zero
          replace hy := ((dvd_gcd_iff x x _).2 ⟨dvd_rfl, hy⟩).trans gcd_pow_right_dvd_pow_gcd
          obtain ⟨z, hz⟩ := gcd_dvd_left x y
          nth_rw 1 [hz] at hy ⊢
          

Proof state:
case neg.intro
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
h : ¬gcd x y = 0
z : R
hy : gcd x y * z ∣ gcd x y ^ 2
hz : x = gcd x y * z
⊢ gcd x y * z ∣ gcd x y

Next tactic:
rw [pow_two, mul_dvd_mul_iff_left h] at hy
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            apply dvd_zero
          replace hy := ((dvd_gcd_iff x x _).2 ⟨dvd_rfl, hy⟩).trans gcd_pow_right_dvd_pow_gcd
          obtain ⟨z, hz⟩ := gcd_dvd_left x y
          nth_rw 1 [hz] at hy ⊢
          rw [pow_two, mul_dvd_mul_iff_left h] at hy
          

Proof state:
case neg.intro
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
h : ¬gcd x y = 0
z : R
hy : z ∣ gcd x y
hz : x = gcd x y * z
⊢ gcd x y * z ∣ gcd x y

Next tactic:
obtain ⟨w, hw⟩ := hy
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            apply dvd_zero
          replace hy := ((dvd_gcd_iff x x _).2 ⟨dvd_rfl, hy⟩).trans gcd_pow_right_dvd_pow_gcd
          obtain ⟨z, hz⟩ := gcd_dvd_left x y
          nth_rw 1 [hz] at hy ⊢
          rw [pow_two, mul_dvd_mul_iff_left h] at hy
          obtain ⟨w, hw⟩ := hy
          

Proof state:
case neg.intro.intro
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
h : ¬gcd x y = 0
z : R
hz : x = gcd x y * z
w : R
hw : gcd x y = z * w
⊢ gcd x y * z ∣ gcd x y

Next tactic:
exact (hx z ⟨w, by rwa [mul_right_comm, ← hw]⟩).mul_right_dvd.2 dvd_rfl
theorem Squarefree.isRadical {x : R} (hx : Squarefree x) : IsRadical x :=
  (isRadical_iff_pow_one_lt 2 one_lt_two).2 fun y hy =>
    And.right <|
      (dvd_gcd_iff x x y).1
        (by
          by_cases h : gcd x y = 0
          · rw [h]
            apply dvd_zero
          replace hy := ((dvd_gcd_iff x x _).2 ⟨dvd_rfl, hy⟩).trans gcd_pow_right_dvd_pow_gcd
          obtain ⟨z, hz⟩ := gcd_dvd_left x y
          nth_rw 1 [hz] at hy ⊢
          rw [pow_two, mul_dvd_mul_iff_left h] at hy
          obtain ⟨w, hw⟩ := hy
          exact (hx z ⟨w, by 

Proof state:
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
hx : Squarefree x
y : R
h : ¬gcd x y = 0
z : R
hz : x = gcd x y * z
w : R
hw : gcd x y = z * w
⊢ x = z * z * w

Next tactic:
rwa [mul_right_comm, ← hw]
theorem isRadical_iff_squarefree_or_zero {x : R} : IsRadical x ↔ Squarefree x ∨ x = 0 :=
  ⟨fun hx => (em <| x = 0).elim Or.inr fun h => Or.inl <| hx.squarefree h,
    Or.rec Squarefree.isRadical <| by
      

Proof state:
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
x : R
⊢ x = 0 → IsRadical x

Next tactic:
rintro rfl
theorem isRadical_iff_squarefree_or_zero {x : R} : IsRadical x ↔ Squarefree x ∨ x = 0 :=
  ⟨fun hx => (em <| x = 0).elim Or.inr fun h => Or.inl <| hx.squarefree h,
    Or.rec Squarefree.isRadical <| by
      rintro rfl
      

Proof state:
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
⊢ IsRadical 0

Next tactic:
rw [zero_isRadical_iff]
theorem isRadical_iff_squarefree_or_zero {x : R} : IsRadical x ↔ Squarefree x ∨ x = 0 :=
  ⟨fun hx => (em <| x = 0).elim Or.inr fun h => Or.inl <| hx.squarefree h,
    Or.rec Squarefree.isRadical <| by
      rintro rfl
      rw [zero_isRadical_iff]
      

Proof state:
R : Type u_1
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : GCDMonoid R
⊢ IsReduced R

Next tactic:
infer_instance
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  

Proof state:
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)

Next tactic:
have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by 

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

Next tactic:
classical infer_instance
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical 

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

Next tactic:
infer_instance
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  

Proof state:
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)

Next tactic:
rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  

Proof state:
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

Next tactic:
haveI := nontrivial_of_ne x 0 x0
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  

Proof state:
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

Next tactic:
constructor
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> 

Proof state:
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
⊢ (∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1) → ∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1

Next tactic:
intro h a
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> 

Proof state:
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
⊢ (∀ (a : R), Multiset.count a (normalizedFactors x) ≤ 1) → ∀ (x_1 : R), multiplicity x_1 x ≤ 1 ∨ IsUnit x_1

Next tactic:
intro h a
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · 

Proof state:
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

Next tactic:
by_cases hmem : a ∈ normalizedFactors x
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · 

Proof state:
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

Next tactic:
have ha := irreducible_of_normalized_factor _ hmem
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · have ha := irreducible_of_normalized_factor _ hmem
      

Proof state:
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

Next tactic:
rcases h a with (h | h)
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · have ha := irreducible_of_normalized_factor _ hmem
      rcases h a with (h | h)
      · 

Proof state:
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

Next tactic:
rw [← normalize_normalized_factor _ hmem]
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · have ha := irreducible_of_normalized_factor _ hmem
      rcases h a with (h | h)
      · rw [← normalize_normalized_factor _ hmem]
        

Proof state:
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

Next tactic:
rw [multiplicity_eq_count_normalizedFactors ha x0] at h
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · have ha := irreducible_of_normalized_factor _ hmem
      rcases h a with (h | h)
      · rw [← normalize_normalized_factor _ hmem]
        rw [multiplicity_eq_count_normalizedFactors ha x0] at h
        

Proof state:
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

Next tactic:
assumption_mod_cast
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · have ha := irreducible_of_normalized_factor _ hmem
      rcases h a with (h | h)
      · rw [← normalize_normalized_factor _ hmem]
        rw [multiplicity_eq_count_normalizedFactors ha x0] at h
        assumption_mod_cast
      · 

Proof state:
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

Next tactic:
have := ha.1
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · have ha := irreducible_of_normalized_factor _ hmem
      rcases h a with (h | h)
      · rw [← normalize_normalized_factor _ hmem]
        rw [multiplicity_eq_count_normalizedFactors ha x0] at h
        assumption_mod_cast
      · have := ha.1
        

Proof state:
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

Next tactic:
contradiction
theorem squarefree_iff_nodup_normalizedFactors [NormalizationMonoid R] [DecidableEq R] {x : R}
    (x0 : x ≠ 0) : Squarefree x ↔ Multiset.Nodup (normalizedFactors x) := by
  have drel : DecidableRel (Dvd.dvd : R → R → Prop) := by classical infer_instance
  rw [multiplicity.squarefree_iff_multiplicity_le_one, Multiset.nodup_iff_count_le_one]
  haveI := nontrivial_of_ne x 0 x0
  constructor <;> intro h a
  · by_cases hmem : a ∈ normalizedFactors x
    · have ha := irreducible_of_normalized_factor _ hmem
      rcases h a with (h | h)
      · rw [← normalize_normalized_factor _ hmem]
        rw [multiplicity_eq_count_normalizedFactors ha x0] at h
        assumption_mod_cast
      · have := ha.1
        contradiction
    · 

Proof state:
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

Next tactic:
simp [Multiset.count_eq_zero_of_not_mem hmem]