Theorem: Associates.eq_pow_count_factors_of_dvd_pow
File: Mathlib/RingTheory/UniqueFactorizationDomain.lean

tactic: nontriviality α
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
⊢ a = p ^ count p (factors a)

tactic: have hph := pow_ne_zero n hp.ne_zero
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
⊢ a = p ^ count p (factors a)

tactic: have ha := ne_zero_of_dvd_ne_zero hph h
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
⊢ a = p ^ count p (factors a)

tactic: apply eq_of_eq_counts ha (pow_ne_zero _ hp.ne_zero)
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
⊢ a = p ^ count p (factors a)

tactic: have eq_zero_of_ne : ∀ q : Associates α, Irreducible q → q ≠ p → _ = 0 := fun q hq h' =>
  Nat.eq_zero_of_le_zero <| by
    convert count_le_count_of_le hph hq h
    symm
    rw [count_pow hp.ne_zero hq, count_eq_zero_of_ne hq hp h', MulZeroClass.mul_zero]
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
⊢ ∀ (p_1 : Associates α), Irreducible p_1 → count p_1 (factors a) = count p_1 (factors (p ^ count p (factors a)))

tactic: intro q hq
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
eq_zero_of_ne : ∀ (q : Associates α), Irreducible q → q ≠ p → count q (factors a) = 0
⊢ ∀ (p_1 : Associates α), Irreducible p_1 → count p_1 (factors a) = count p_1 (factors (p ^ count p (factors a)))

tactic: rw [count_pow hp.ne_zero hq]
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
eq_zero_of_ne : ∀ (q : Associates α), Irreducible q → q ≠ p → count q (factors a) = 0
q : Associates α
hq : Irreducible q
⊢ count q (factors a) = count q (factors (p ^ count p (factors a)))

tactic: by_cases h : q = p
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
eq_zero_of_ne : ∀ (q : Associates α), Irreducible q → q ≠ p → count q (factors a) = 0
q : Associates α
hq : Irreducible q
⊢ count q (factors a) = count p (factors a) * count q (factors p)

tactic: convert count_le_count_of_le hph hq h
state_before: α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
q : Associates α
hq : Irreducible q
h' : q ≠ p
⊢ ?m.2897509 q ≤ 0

tactic: symm
state_before: case h.e'_4
α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
q : Associates α
hq : Irreducible q
h' : q ≠ p
⊢ 0 = count q (factors (p ^ n))

tactic: rw [count_pow hp.ne_zero hq, count_eq_zero_of_ne hq hp h', MulZeroClass.mul_zero]
state_before: case h.e'_4
α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
q : Associates α
hq : Irreducible q
h' : q ≠ p
⊢ count q (factors (p ^ n)) = 0

tactic: rw [h, count_self hp, mul_one]
state_before: case pos
α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h✝ : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
eq_zero_of_ne : ∀ (q : Associates α), Irreducible q → q ≠ p → count q (factors a) = 0
q : Associates α
hq : Irreducible q
h : q = p
⊢ count q (factors a) = count p (factors a) * count q (factors p)

tactic: rw [count_eq_zero_of_ne hq hp h, MulZeroClass.mul_zero, eq_zero_of_ne q hq h]
state_before: case neg
α : Type u_1
inst✝¹ : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
p a : Associates α
hp : Irreducible p
n : ℕ
h✝ : a ∣ p ^ n
✝ : Nontrivial α
hph : p ^ n ≠ 0
ha : a ≠ 0
eq_zero_of_ne : ∀ (q : Associates α), Irreducible q → q ≠ p → count q (factors a) = 0
q : Associates α
hq : Irreducible q
h : ¬q = p
⊢ count q (factors a) = count p (factors a) * count q (factors p)