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 α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ Nat.find ⋯ = p.count a.factors
state_after: case a
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ Nat.find ⋯ ≤ p.count a.factors

case a
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ p.count a.factors ≤ Nat.find ⋯

tactic: refine Nat.find_le ⟨1, ?_⟩
state_before: case a
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ Nat.find ⋯ ≤ p.count a.factors
state_after: case a
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ p ^ p.count a.factors = a * 1

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

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

tactic: exact eq_pow_count_factors_of_dvd_pow hp h
state_before: case a
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ a = p ^ p.count a.factors
state_after: no goals

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 α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
⊢ p.count a.factors ≤ Nat.find ⋯
state_after: case a
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
⊢ p.count a.factors ≤ Nat.find ⋯

tactic: cases' subsingleton_or_nontrivial α with hα hα
state_before: case a
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
⊢ p.count a.factors ≤ Nat.find ⋯
state_after: case a.inl
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
hα : Subsingleton α
⊢ p.count a.factors ≤ Nat.find ⋯

case a.inr
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
hα : Nontrivial α
⊢ p.count a.factors ≤ Nat.find ⋯

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 α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
hα : Nontrivial α
⊢ p.count a.factors ≤ Nat.find ⋯
state_after: case h.e'_4
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
hα : Nontrivial α
⊢ Nat.find ⋯ = p.count (p ^ Nat.find ⋯).factors

tactic: rw [count_pow hp.ne_zero hp, count_self hp, mul_one]
state_before: case h.e'_4
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
hα : Nontrivial α
⊢ Nat.find ⋯ = p.count (p ^ Nat.find ⋯).factors
state_after: no goals

tactic: simp [eq_iff_true_of_subsingleton] at hph
state_before: case a.inl
α : Type u_1
inst✝⁵ : CancelCommMonoidWithZero α
inst✝⁴ : UniqueFactorizationMonoid α
inst✝³ : DecidableEq (Associates α)
inst✝² : (p : Associates α) → Decidable (Irreducible p)
inst✝¹ : DecidableEq (Associates α)
a p : Associates α
hp : Irreducible p
inst✝ : (n : ℕ) → Decidable (a ∣ p ^ n)
n : ℕ
h : a ∣ p ^ n
hph : p ^ Nat.find ⋯ ≠ 0
hα : Subsingleton α
⊢ p.count a.factors ≤ Nat.find ⋯
state_after: no goals