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

tactic: apply le_antisymm
state_before: α : Type u_1
inst✝² : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n) = count p (factors a)

tactic: refine' Nat.find_le ⟨1, _⟩
state_before: case a
α : Type u_1
inst✝² : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n) ≤ count p (factors a)

tactic: rw [mul_one]
state_before: case a
α : Type u_1
inst✝² : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ p ^ count p (factors a) = a * 1

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

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

tactic: have hph := pow_ne_zero (@Nat.find (fun n => a ∣ p ^ n) _ ⟨n, h⟩) hp.ne_zero
state_before: case a
α : Type u_1
inst✝² : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ count p (factors a) ≤ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n)

tactic: cases' subsingleton_or_nontrivial α with hα hα
state_before: case a
α : Type u_1
inst✝² : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n) ≠ 0
⊢ count p (factors a) ≤ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n)

tactic: convert count_le_count_of_le hph hp (@Nat.find_spec (fun n => a ∣ p ^ n) _ ⟨n, h⟩)
state_before: case a.inr
α : Type u_1
inst✝² : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n) ≠ 0
hα : Nontrivial α
⊢ count p (factors a) ≤ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n)

tactic: rw [count_pow hp.ne_zero hp, count_self hp, mul_one]
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 α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n) ≠ 0
hα : Nontrivial α
⊢ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n) = count p (factors (p ^ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n)))

tactic: simp at hph
state_before: case a.inl
α : Type u_1
inst✝² : CancelCommMonoidWithZero α
dec_irr : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : UniqueFactorizationMonoid α
dec : DecidableEq α
dec' : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n) ≠ 0
hα : Subsingleton α
⊢ count p (factors a) ≤ Nat.find (_ : ∃ n, (fun n => a ∣ p ^ n) n)