Theorem: Nat.factors_count_eq
File: Mathlib/Data/Nat/Factorization/Basic.lean

tactic: rcases n.eq_zero_or_pos with (rfl | hn0)
state_before: a b m n✝ p✝ n p : ℕ
⊢ count p n.factors = n.factorization p
state_after: case inl
a b m n p✝ p : ℕ
⊢ count p (factors 0) = (factorization 0) p

case inr
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
⊢ count p n.factors = n.factorization p

tactic: if pp : p.Prime then ?_ else
  rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)]
  simp [factorization, pp]
state_before: case inr
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
⊢ count p n.factors = n.factorization p
state_after: case inr
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ count p n.factors = n.factorization p

tactic: simp only [factorization_def _ pp]
state_before: case inr
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ count p n.factors = n.factorization p
state_after: case inr
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ count p n.factors = padicValNat p n

tactic: apply _root_.le_antisymm
state_before: case inr
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ count p n.factors = padicValNat p n
state_after: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ count p n.factors ≤ padicValNat p n

case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ padicValNat p n ≤ count p n.factors

tactic: simp [factorization, count]
state_before: case inl
a b m n p✝ p : ℕ
⊢ count p (factors 0) = (factorization 0) p
state_after: no goals

tactic: rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)]
state_before: a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : ¬Prime p
⊢ count p n.factors = n.factorization p
state_after: a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : ¬Prime p
⊢ 0 = n.factorization p

tactic: simp [factorization, pp]
state_before: a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : ¬Prime p
⊢ 0 = n.factorization p
state_after: no goals

tactic: rw [le_padicValNat_iff_replicate_subperm_factors pp hn0.ne']
state_before: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ count p n.factors ≤ padicValNat p n
state_after: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ replicate (count p n.factors) p <+~ n.factors

tactic: exact List.le_count_iff_replicate_sublist.mp le_rfl |>.subperm
state_before: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ replicate (count p n.factors) p <+~ n.factors
state_after: no goals

tactic: rw [← Nat.lt_add_one_iff, lt_iff_not_ge, ge_iff_le,
  le_padicValNat_iff_replicate_subperm_factors pp hn0.ne']
state_before: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ padicValNat p n ≤ count p n.factors
state_after: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ ¬replicate (count p n.factors + 1) p <+~ n.factors

tactic: intro h
state_before: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
⊢ ¬replicate (count p n.factors + 1) p <+~ n.factors
state_after: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
h : replicate (count p n.factors + 1) p <+~ n.factors
⊢ False

tactic: have := h.count_le p
state_before: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
h : replicate (count p n.factors + 1) p <+~ n.factors
⊢ False
state_after: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
h : replicate (count p n.factors + 1) p <+~ n.factors
this : count p (replicate (count p n.factors + 1) p) ≤ count p n.factors
⊢ False

tactic: simp at this
state_before: case inr.a
a b m n✝ p✝ n p : ℕ
hn0 : n > 0
pp : Prime p
h : replicate (count p n.factors + 1) p <+~ n.factors
this : count p (replicate (count p n.factors + 1) p) ≤ count p n.factors
⊢ False
state_after: no goals