l3lab/ntp-mathlib huggingface dataset:
/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing
out their common factor `c'` gives `a'` and `b'` with no factors in common. -/
theorem exists_reduced_factors :
    ∀ a ≠ (0 : R), ∀ b,
      ∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → IsUnit d) ∧ c' * a' = a ∧ c' * b' = b := by
  haveI := Classical.propDecidable
  intro a
  refine' induction_on_prime a _ _ _
  · intros
    contradiction
  · intro a a_unit _ b
    use a, b, 1
    constructor
    · intro p p_dvd_a _
      exact isUnit_of_dvd_unit p_dvd_a a_unit
    · simp
  · intro a p a_ne_zero p_prime ih_a pa_ne_zero b
    by_cases h : p ∣ b
    · rcases h with ⟨b, rfl⟩
      obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b
      refine' ⟨a', b', p * c', @no_factor, _, _⟩
      · rw [mul_assoc, ha']
      · rw [mul_assoc, hb']
    · obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b
      refine' ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩
      

Proof state:
case neg.intro.intro.intro.intro.intro
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
this : (a : Prop) → Decidable a
a p : R
p_prime : Prime p
a' b' c' : R
coprime : ∀ {d : R}, d ∣ a' → d ∣ b' → IsUnit d
a_ne_zero : c' * a' ≠ 0
ih_a :
  c' * a' ≠ 0 →
    ∀ (b : R), ∃ a'_1 b' c'_1, (∀ {d : R}, d ∣ a'_1 → d ∣ b' → IsUnit d) ∧ c'_1 * a'_1 = c' * a' ∧ c'_1 * b' = b
pa_ne_zero : p * (c' * a') ≠ 0
h : ¬p ∣ c' * b'
⊢ ∀ {d : R}, d ∣ p * a' → d ∣ b' → IsUnit d

Next tactic:
intro q q_dvd_pa' q_dvd_b'
/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing
out their common factor `c'` gives `a'` and `b'` with no factors in common. -/
theorem exists_reduced_factors :
    ∀ a ≠ (0 : R), ∀ b,
      ∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → IsUnit d) ∧ c' * a' = a ∧ c' * b' = b := by
  haveI := Classical.propDecidable
  intro a
  refine' induction_on_prime a _ _ _
  · intros
    contradiction
  · intro a a_unit _ b
    use a, b, 1
    constructor
    · intro p p_dvd_a _
      exact isUnit_of_dvd_unit p_dvd_a a_unit
    · simp
  · intro a p a_ne_zero p_prime ih_a pa_ne_zero b
    by_cases h : p ∣ b
    · rcases h with ⟨b, rfl⟩
      obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b
      refine' ⟨a', b', p * c', @no_factor, _, _⟩
      · rw [mul_assoc, ha']
      · rw [mul_assoc, hb']
    · obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b
      refine' ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩
      intro q q_dvd_pa' q_dvd_b'
      

Proof state:
case neg.intro.intro.intro.intro.intro
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
this : (a : Prop) → Decidable a
a p : R
p_prime : Prime p
a' b' c' : R
coprime : ∀ {d : R}, d ∣ a' → d ∣ b' → IsUnit d
a_ne_zero : c' * a' ≠ 0
ih_a :
  c' * a' ≠ 0 →
    ∀ (b : R), ∃ a'_1 b' c'_1, (∀ {d : R}, d ∣ a'_1 → d ∣ b' → IsUnit d) ∧ c'_1 * a'_1 = c' * a' ∧ c'_1 * b' = b
pa_ne_zero : p * (c' * a') ≠ 0
h : ¬p ∣ c' * b'
q : R
q_dvd_pa' : q ∣ p * a'
q_dvd_b' : q ∣ b'
⊢ IsUnit q

Next tactic:
cases' p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a'
/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing
out their common factor `c'` gives `a'` and `b'` with no factors in common. -/
theorem exists_reduced_factors :
    ∀ a ≠ (0 : R), ∀ b,
      ∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → IsUnit d) ∧ c' * a' = a ∧ c' * b' = b := by
  haveI := Classical.propDecidable
  intro a
  refine' induction_on_prime a _ _ _
  · intros
    contradiction
  · intro a a_unit _ b
    use a, b, 1
    constructor
    · intro p p_dvd_a _
      exact isUnit_of_dvd_unit p_dvd_a a_unit
    · simp
  · intro a p a_ne_zero p_prime ih_a pa_ne_zero b
    by_cases h : p ∣ b
    · rcases h with ⟨b, rfl⟩
      obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b
      refine' ⟨a', b', p * c', @no_factor, _, _⟩
      · rw [mul_assoc, ha']
      · rw [mul_assoc, hb']
    · obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b
      refine' ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩
      intro q q_dvd_pa' q_dvd_b'
      cases' p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a'
      · 

Proof state:
case neg.intro.intro.intro.intro.intro.inl
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
this : (a : Prop) → Decidable a
a p : R
p_prime : Prime p
a' b' c' : R
coprime : ∀ {d : R}, d ∣ a' → d ∣ b' → IsUnit d
a_ne_zero : c' * a' ≠ 0
ih_a :
  c' * a' ≠ 0 →
    ∀ (b : R), ∃ a'_1 b' c'_1, (∀ {d : R}, d ∣ a'_1 → d ∣ b' → IsUnit d) ∧ c'_1 * a'_1 = c' * a' ∧ c'_1 * b' = b
pa_ne_zero : p * (c' * a') ≠ 0
h : ¬p ∣ c' * b'
q : R
q_dvd_pa' : q ∣ p * a'
q_dvd_b' : q ∣ b'
p_dvd_q : p ∣ q
⊢ IsUnit q

Next tactic:
have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _
/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing
out their common factor `c'` gives `a'` and `b'` with no factors in common. -/
theorem exists_reduced_factors :
    ∀ a ≠ (0 : R), ∀ b,
      ∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → IsUnit d) ∧ c' * a' = a ∧ c' * b' = b := by
  haveI := Classical.propDecidable
  intro a
  refine' induction_on_prime a _ _ _
  · intros
    contradiction
  · intro a a_unit _ b
    use a, b, 1
    constructor
    · intro p p_dvd_a _
      exact isUnit_of_dvd_unit p_dvd_a a_unit
    · simp
  · intro a p a_ne_zero p_prime ih_a pa_ne_zero b
    by_cases h : p ∣ b
    · rcases h with ⟨b, rfl⟩
      obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b
      refine' ⟨a', b', p * c', @no_factor, _, _⟩
      · rw [mul_assoc, ha']
      · rw [mul_assoc, hb']
    · obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b
      refine' ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩
      intro q q_dvd_pa' q_dvd_b'
      cases' p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a'
      · have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _
        

Proof state:
case neg.intro.intro.intro.intro.intro.inl
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
this✝ : (a : Prop) → Decidable a
a p : R
p_prime : Prime p
a' b' c' : R
coprime : ∀ {d : R}, d ∣ a' → d ∣ b' → IsUnit d
a_ne_zero : c' * a' ≠ 0
ih_a :
  c' * a' ≠ 0 →
    ∀ (b : R), ∃ a'_1 b' c'_1, (∀ {d : R}, d ∣ a'_1 → d ∣ b' → IsUnit d) ∧ c'_1 * a'_1 = c' * a' ∧ c'_1 * b' = b
pa_ne_zero : p * (c' * a') ≠ 0
h : ¬p ∣ c' * b'
q : R
q_dvd_pa' : q ∣ p * a'
q_dvd_b' : q ∣ b'
p_dvd_q : p ∣ q
this : p ∣ c' * b'
⊢ IsUnit q

Next tactic:
contradiction
/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing
out their common factor `c'` gives `a'` and `b'` with no factors in common. -/
theorem exists_reduced_factors :
    ∀ a ≠ (0 : R), ∀ b,
      ∃ a' b' c', (∀ {d}, d ∣ a' → d ∣ b' → IsUnit d) ∧ c' * a' = a ∧ c' * b' = b := by
  haveI := Classical.propDecidable
  intro a
  refine' induction_on_prime a _ _ _
  · intros
    contradiction
  · intro a a_unit _ b
    use a, b, 1
    constructor
    · intro p p_dvd_a _
      exact isUnit_of_dvd_unit p_dvd_a a_unit
    · simp
  · intro a p a_ne_zero p_prime ih_a pa_ne_zero b
    by_cases h : p ∣ b
    · rcases h with ⟨b, rfl⟩
      obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b
      refine' ⟨a', b', p * c', @no_factor, _, _⟩
      · rw [mul_assoc, ha']
      · rw [mul_assoc, hb']
    · obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b
      refine' ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩
      intro q q_dvd_pa' q_dvd_b'
      cases' p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a'
      · have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _
        contradiction
      

Proof state:
case neg.intro.intro.intro.intro.intro.inr
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
this : (a : Prop) → Decidable a
a p : R
p_prime : Prime p
a' b' c' : R
coprime : ∀ {d : R}, d ∣ a' → d ∣ b' → IsUnit d
a_ne_zero : c' * a' ≠ 0
ih_a :
  c' * a' ≠ 0 →
    ∀ (b : R), ∃ a'_1 b' c'_1, (∀ {d : R}, d ∣ a'_1 → d ∣ b' → IsUnit d) ∧ c'_1 * a'_1 = c' * a' ∧ c'_1 * b' = b
pa_ne_zero : p * (c' * a') ≠ 0
h : ¬p ∣ c' * b'
q : R
q_dvd_pa' : q ∣ p * a'
q_dvd_b' : q ∣ b'
q_dvd_a' : q ∣ a'
⊢ IsUnit q

Next tactic:
exact coprime q_dvd_a' q_dvd_b'
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
⊢ Function.Injective fun x => a ^ x

Next tactic:
letI := Classical.decEq R
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this : DecidableEq R := Classical.decEq R
⊢ Function.Injective fun x => a ^ x

Next tactic:
intro i j hij
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  intro i j hij
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this : DecidableEq R := Classical.decEq R
i j : ℕ
hij : (fun x => a ^ x) i = (fun x => a ^ x) j
⊢ i = j

Next tactic:
letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  intro i j hij
  letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this✝ : DecidableEq R := Classical.decEq R
i j : ℕ
hij : (fun x => a ^ x) i = (fun x => a ^ x) j
this : Nontrivial R := { exists_pair_ne := Exists.intro a (Exists.intro 0 ha0) }
⊢ i = j

Next tactic:
letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  intro i j hij
  letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
  letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
  

Proof state:
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this✝¹ : DecidableEq R := Classical.decEq R
i j : ℕ
hij : (fun x => a ^ x) i = (fun x => a ^ x) j
this✝ : Nontrivial R := { exists_pair_ne := Exists.intro a (Exists.intro 0 ha0) }
this : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
⊢ i = j

Next tactic:
obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  intro i j hij
  letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
  letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
  obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0
  

Proof state:
case intro.intro
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this✝¹ : DecidableEq R := Classical.decEq R
i j : ℕ
hij : (fun x => a ^ x) i = (fun x => a ^ x) j
this✝ : Nontrivial R := { exists_pair_ne := Exists.intro a (Exists.intro 0 ha0) }
this : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
p' : R
hp' : Irreducible p'
dvd' : p' ∣ a
⊢ i = j

Next tactic:
obtain ⟨p, mem, _⟩ := exists_mem_normalizedFactors_of_dvd ha0 hp' dvd'
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  intro i j hij
  letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
  letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
  obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0
  obtain ⟨p, mem, _⟩ := exists_mem_normalizedFactors_of_dvd ha0 hp' dvd'
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this✝¹ : DecidableEq R := Classical.decEq R
i j : ℕ
hij : (fun x => a ^ x) i = (fun x => a ^ x) j
this✝ : Nontrivial R := { exists_pair_ne := Exists.intro a (Exists.intro 0 ha0) }
this : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
p' : R
hp' : Irreducible p'
dvd' : p' ∣ a
p : R
mem : p ∈ normalizedFactors a
right✝ : p' ~ᵤ p
⊢ i = j

Next tactic:
have := congr_arg (fun x => Multiset.count p (normalizedFactors x)) hij
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  intro i j hij
  letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
  letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
  obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0
  obtain ⟨p, mem, _⟩ := exists_mem_normalizedFactors_of_dvd ha0 hp' dvd'
  have := congr_arg (fun x => Multiset.count p (normalizedFactors x)) hij
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this✝² : DecidableEq R := Classical.decEq R
i j : ℕ
hij : (fun x => a ^ x) i = (fun x => a ^ x) j
this✝¹ : Nontrivial R := { exists_pair_ne := Exists.intro a (Exists.intro 0 ha0) }
this✝ : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
p' : R
hp' : Irreducible p'
dvd' : p' ∣ a
p : R
mem : p ∈ normalizedFactors a
right✝ : p' ~ᵤ p
this :
  (fun x => Multiset.count p (normalizedFactors x)) ((fun x => a ^ x) i) =
    (fun x => Multiset.count p (normalizedFactors x)) ((fun x => a ^ x) j)
⊢ i = j

Next tactic:
simp only [normalizedFactors_pow, Multiset.count_nsmul] at this
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
    Function.Injective (a ^ · : ℕ → R) := by
  letI := Classical.decEq R
  intro i j hij
  letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
  letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
  obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0
  obtain ⟨p, mem, _⟩ := exists_mem_normalizedFactors_of_dvd ha0 hp' dvd'
  have := congr_arg (fun x => Multiset.count p (normalizedFactors x)) hij
  simp only [normalizedFactors_pow, Multiset.count_nsmul] at this
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
R : Type u_2
inst✝¹ : CancelCommMonoidWithZero R
inst✝ : UniqueFactorizationMonoid R
a : R
ha0 : a ≠ 0
ha1 : ¬IsUnit a
this✝² : DecidableEq R := Classical.decEq R
i j : ℕ
hij : (fun x => a ^ x) i = (fun x => a ^ x) j
this✝¹ : Nontrivial R := { exists_pair_ne := Exists.intro a (Exists.intro 0 ha0) }
this✝ : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
p' : R
hp' : Irreducible p'
dvd' : p' ∣ a
p : R
mem : p ∈ normalizedFactors a
right✝ : p' ~ᵤ p
this : i * Multiset.count p (normalizedFactors a) = j * Multiset.count p (normalizedFactors a)
⊢ i = j

Next tactic:
exact mul_right_cancel₀ (Multiset.count_ne_zero.mpr mem) this
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  

Proof state:
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a b : R
n : ℕ
ha : Irreducible a
hb : b ≠ 0
⊢ ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b

Next tactic:
rw [← pow_dvd_iff_le_multiplicity]
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  

Proof state:
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a b : R
n : ℕ
ha : Irreducible a
hb : b ≠ 0
⊢ a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b

Next tactic:
revert b
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  

Proof state:
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
n : ℕ
ha : Irreducible a
⊢ ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)

Next tactic:
induction' n with n ih
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · 

Proof state:
case zero
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
⊢ ∀ {b : R}, b ≠ 0 → (a ^ Nat.zero ∣ b ↔ replicate Nat.zero (normalize a) ≤ normalizedFactors b)

Next tactic:
simp
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · simp
  

Proof state:
case succ
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
n : ℕ
ih : ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)
⊢ ∀ {b : R}, b ≠ 0 → (a ^ Nat.succ n ∣ b ↔ replicate (Nat.succ n) (normalize a) ≤ normalizedFactors b)

Next tactic:
intro b hb
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · simp
  intro b hb
  

Proof state:
case succ
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
n : ℕ
ih : ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)
b : R
hb : b ≠ 0
⊢ a ^ Nat.succ n ∣ b ↔ replicate (Nat.succ n) (normalize a) ≤ normalizedFactors b

Next tactic:
constructor
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · simp
  intro b hb
  constructor
  · 

Proof state:
case succ.mp
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
n : ℕ
ih : ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)
b : R
hb : b ≠ 0
⊢ a ^ Nat.succ n ∣ b → replicate (Nat.succ n) (normalize a) ≤ normalizedFactors b

Next tactic:
rintro ⟨c, rfl⟩
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · simp
  intro b hb
  constructor
  · rintro ⟨c, rfl⟩
    

Proof state:
case succ.mp.intro
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
n : ℕ
ih : ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)
c : R
hb : a ^ Nat.succ n * c ≠ 0
⊢ replicate (Nat.succ n) (normalize a) ≤ normalizedFactors (a ^ Nat.succ n * c)

Next tactic:
rw [Ne.def, pow_succ, mul_assoc, mul_eq_zero, not_or] at hb
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · simp
  intro b hb
  constructor
  · rintro ⟨c, rfl⟩
    rw [Ne.def, pow_succ, mul_assoc, mul_eq_zero, not_or] at hb
    

Proof state:
case succ.mp.intro
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
n : ℕ
ih : ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)
c : R
hb : ¬a = 0 ∧ ¬a ^ n * c = 0
⊢ replicate (Nat.succ n) (normalize a) ≤ normalizedFactors (a ^ Nat.succ n * c)

Next tactic:
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]
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · simp
  intro b hb
  constructor
  · rintro ⟨c, rfl⟩
    rw [Ne.def, 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]
    

Proof state:
case succ.mp.intro
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
n : ℕ
ih : ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)
c : R
hb : ¬a = 0 ∧ ¬a ^ n * c = 0
⊢ a ^ n ∣ a ^ n * c

Next tactic:
apply Dvd.intro _ rfl
theorem le_multiplicity_iff_replicate_le_normalizedFactors [DecidableEq R] {a b : R} {n : ℕ}
    (ha : Irreducible a) (hb : b ≠ 0) :
    ↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
  rw [← pow_dvd_iff_le_multiplicity]
  revert b
  induction' n with n ih; · simp
  intro b hb
  constructor
  · rintro ⟨c, rfl⟩
    rw [Ne.def, 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
  · 

Proof state:
case succ.mpr
α : Type u_1
R : Type u_2
inst✝⁴ : CancelCommMonoidWithZero R
inst✝³ : UniqueFactorizationMonoid R
inst✝² : Nontrivial R
inst✝¹ : NormalizationMonoid R
dec_dvd : DecidableRel Dvd.dvd
inst✝ : DecidableEq R
a : R
ha : Irreducible a
n : ℕ
ih : ∀ {b : R}, b ≠ 0 → (a ^ n ∣ b ↔ replicate n (normalize a) ≤ normalizedFactors b)
b : R
hb : b ≠ 0
⊢ replicate (Nat.succ n) (normalize a) ≤ normalizedFactors b → a ^ Nat.succ n ∣ b

Next tactic:
rw [Multiset.le_iff_exists_add]