Theorem: Nat.factorization_choose_of_lt_three_mul
File: Mathlib/Data/Nat/Choose/Factorization.lean

tactic: cases' em' p.Prime with hp hp
state_before: p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
⊢ ↑(factorization (choose n k)) p = 0

tactic: cases' lt_or_le n k with hnk hkn
state_before: case inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
⊢ ↑(factorization (choose n k)) p = 0

tactic: rw [factorization_def _ hp, @padicValNat_def _ ⟨hp⟩ _ (choose_pos hkn)]
state_before: case inr.inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
⊢ ↑(factorization (choose n k)) p = 0

tactic: simp only [hp.multiplicity_choose hkn (lt_add_one _), PartENat.get_natCast, Finset.card_eq_zero,
  Finset.filter_eq_empty_iff, not_le]
state_before: case inr.inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
⊢ Part.get (multiplicity p (choose n k)) (_ : multiplicity.Finite p (choose n k)) = 0

tactic: intro i hi
state_before: case inr.inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
⊢ ∀ (x : ℕ), x ∈ Finset.Ico 1 (log p n + 1) → k % p ^ x + (n - k) % p ^ x < p ^ x

tactic: rcases eq_or_lt_of_le (Finset.mem_Ico.mp hi).1 with (rfl | hi)
state_before: case inr.inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
i : ℕ
hi : i ∈ Finset.Ico 1 (log p n + 1)
⊢ k % p ^ i + (n - k) % p ^ i < p ^ i

tactic: exact factorization_eq_zero_of_non_prime (choose n k) hp
state_before: case inl
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : ¬Prime p
⊢ ↑(factorization (choose n k)) p = 0

tactic: simp [choose_eq_zero_of_lt hnk]
state_before: case inr.inl
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hnk : n < k
⊢ ↑(factorization (choose n k)) p = 0

tactic: rw [pow_one, ← add_lt_add_iff_left (2 * p), ← succ_mul, two_mul, add_add_add_comm]
state_before: case inr.inr.inl
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
hi : 1 ∈ Finset.Ico 1 (log p n + 1)
⊢ k % p ^ 1 + (n - k) % p ^ 1 < p ^ 1

tactic: exact
  lt_of_le_of_lt
    (add_le_add
      (add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk)) (k % p))
      (add_le_add_right (le_mul_of_one_le_right' ((one_le_div_iff hp.pos).mpr hk'))
        ((n - k) % p)))
    (by rwa [div_add_mod, div_add_mod, add_tsub_cancel_of_le hkn])
state_before: case inr.inr.inl
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
hi : 1 ∈ Finset.Ico 1 (log p n + 1)
⊢ p + k % p + (p + (n - k) % p) < succ 2 * p

tactic: rwa [div_add_mod, div_add_mod, add_tsub_cancel_of_le hkn]
state_before: p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
hi : 1 ∈ Finset.Ico 1 (log p n + 1)
⊢ p * (k / p) + k % p + (p * ((n - k) / p) + (n - k) % p) < succ 2 * p

tactic: replace hn : n < p ^ i
state_before: case inr.inr.inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
i : ℕ
hi✝ : i ∈ Finset.Ico 1 (log p n + 1)
hi : 1 < i
⊢ k % p ^ i + (n - k) % p ^ i < p ^ i

tactic: have : 3 ≤ p := lt_of_le_of_ne hp.two_le hp'.symm
state_before: case hn
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
i : ℕ
hi✝ : i ∈ Finset.Ico 1 (log p n + 1)
hi : 1 < i
⊢ n < p ^ i

case inr.inr.inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hp : Prime p
hkn : k ≤ n
i : ℕ
hi✝ : i ∈ Finset.Ico 1 (log p n + 1)
hi : 1 < i
hn : n < p ^ i
⊢ k % p ^ i + (n - k) % p ^ i < p ^ i

tactic: rwa [mod_eq_of_lt (lt_of_le_of_lt hkn hn), mod_eq_of_lt (lt_of_le_of_lt tsub_le_self hn),
  add_tsub_cancel_of_le hkn]
state_before: case inr.inr.inr
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hp : Prime p
hkn : k ≤ n
i : ℕ
hi✝ : i ∈ Finset.Ico 1 (log p n + 1)
hi : 1 < i
hn : n < p ^ i
⊢ k % p ^ i + (n - k) % p ^ i < p ^ i

tactic: calc
  n < 3 * p := hn
  _ ≤ p * p := mul_le_mul_right' this p
  _ = p ^ 2 := (sq p).symm
  _ ≤ p ^ i := pow_le_pow hp.one_lt.le hi
state_before: case hn
p n k : ℕ
hp' : p ≠ 2
hk : p ≤ k
hk' : p ≤ n - k
hn : n < 3 * p
hp : Prime p
hkn : k ≤ n
i : ℕ
hi✝ : i ∈ Finset.Ico 1 (log p n + 1)
hi : 1 < i
this : 3 ≤ p
⊢ n < p ^ i