l3lab/ntp-mathlib huggingface dataset:
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  case neg => simp [hp]
  

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
hp : Prime p
⊢ p ^ (factorization n) p ∣ n

Next tactic:
rw [← factors_count_eq]
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  case neg => simp [hp]
  rw [← factors_count_eq]
  

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
hp : Prime p
⊢ p ^ count p (factors n) ∣ n

Next tactic:
apply dvd_of_factors_subperm (pow_ne_zero _ hp.ne_zero)
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  case neg => simp [hp]
  rw [← factors_count_eq]
  apply dvd_of_factors_subperm (pow_ne_zero _ hp.ne_zero)
  

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
hp : Prime p
⊢ factors (p ^ count p (factors n)) <+~ factors n

Next tactic:
rw [hp.factors_pow, List.subperm_ext_iff]
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  case neg => simp [hp]
  rw [← factors_count_eq]
  apply dvd_of_factors_subperm (pow_ne_zero _ hp.ne_zero)
  rw [hp.factors_pow, List.subperm_ext_iff]
  

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
hp : Prime p
⊢ ∀ x ∈ replicate (count p (factors n)) p, count x (replicate (count p (factors n)) p) ≤ count x (factors n)

Next tactic:
intro q hq
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  case neg => simp [hp]
  rw [← factors_count_eq]
  apply dvd_of_factors_subperm (pow_ne_zero _ hp.ne_zero)
  rw [hp.factors_pow, List.subperm_ext_iff]
  intro q hq
  

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
hp : Prime p
q : ℕ
hq : q ∈ replicate (count p (factors n)) p
⊢ count q (replicate (count p (factors n)) p) ≤ count q (factors n)

Next tactic:
simp [List.eq_of_mem_replicate hq]
theorem ord_proj_pos (n p : ℕ) : 0 < ord_proj[p] n := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
⊢ 0 < p ^ (factorization n) p

Next tactic:
by_cases pp : p.Prime
theorem ord_proj_pos (n p : ℕ) : 0 < ord_proj[p] n := by
  by_cases pp : p.Prime
  · 

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
pp : Prime p
⊢ 0 < p ^ (factorization n) p

Next tactic:
simp [pow_pos pp.pos]
theorem ord_proj_pos (n p : ℕ) : 0 < ord_proj[p] n := by
  by_cases pp : p.Prime
  · simp [pow_pos pp.pos]
  · 

Proof state:
case neg
a b m n✝ p✝ n p : ℕ
pp : ¬Prime p
⊢ 0 < p ^ (factorization n) p

Next tactic:
simp [pp]
theorem ord_compl_pos {n : ℕ} (p : ℕ) (hn : n ≠ 0) : 0 < ord_compl[p] n := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
⊢ 0 < n / p ^ (factorization n) p

Next tactic:
cases' em' p.Prime with pp pp
theorem ord_compl_pos {n : ℕ} (p : ℕ) (hn : n ≠ 0) : 0 < ord_compl[p] n := by
  cases' em' p.Prime with pp pp
  · 

Proof state:
case inl
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
pp : ¬Prime p
⊢ 0 < n / p ^ (factorization n) p

Next tactic:
simpa [Nat.factorization_eq_zero_of_non_prime n pp] using hn.bot_lt
theorem ord_compl_pos {n : ℕ} (p : ℕ) (hn : n ≠ 0) : 0 < ord_compl[p] n := by
  cases' em' p.Prime with pp pp
  · simpa [Nat.factorization_eq_zero_of_non_prime n pp] using hn.bot_lt
  

Proof state:
case inr
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
pp : Prime p
⊢ 0 < n / p ^ (factorization n) p

Next tactic:
exact Nat.div_pos (ord_proj_le p hn) (ord_proj_pos n p)
theorem ord_proj_mul {a b : ℕ} (p : ℕ) (ha : a ≠ 0) (hb : b ≠ 0) :
    ord_proj[p] (a * b) = ord_proj[p] a * ord_proj[p] b := by
  

Proof state:
a✝ b✝ m n p✝ a b p : ℕ
ha : a ≠ 0
hb : b ≠ 0
⊢ p ^ (factorization (a * b)) p = p ^ (factorization a) p * p ^ (factorization b) p

Next tactic:
simp [factorization_mul ha hb, pow_add]
theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by
  

Proof state:
a✝ b✝ m n p✝ a b p : ℕ
⊢ a * b / p ^ (factorization (a * b)) p = a / p ^ (factorization a) p * (b / p ^ (factorization b) p)

Next tactic:
rcases eq_or_ne a 0 with (rfl | ha)
theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · 

Proof state:
case inl
a b✝ m n p✝ b p : ℕ
⊢ 0 * b / p ^ (factorization (0 * b)) p = 0 / p ^ (factorization 0) p * (b / p ^ (factorization b) p)

Next tactic:
simp
theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · simp
  

Proof state:
case inr
a✝ b✝ m n p✝ a b p : ℕ
ha : a ≠ 0
⊢ a * b / p ^ (factorization (a * b)) p = a / p ^ (factorization a) p * (b / p ^ (factorization b) p)

Next tactic:
rcases eq_or_ne b 0 with (rfl | hb)
theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · simp
  rcases eq_or_ne b 0 with (rfl | hb)
  · 

Proof state:
case inr.inl
a✝ b m n p✝ a p : ℕ
ha : a ≠ 0
⊢ a * 0 / p ^ (factorization (a * 0)) p = a / p ^ (factorization a) p * (0 / p ^ (factorization 0) p)

Next tactic:
simp
theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · simp
  rcases eq_or_ne b 0 with (rfl | hb)
  · simp
  

Proof state:
case inr.inr
a✝ b✝ m n p✝ a b p : ℕ
ha : a ≠ 0
hb : b ≠ 0
⊢ a * b / p ^ (factorization (a * b)) p = a / p ^ (factorization a) p * (b / p ^ (factorization b) p)

Next tactic:
simp only [ord_proj_mul p ha hb]
theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · simp
  rcases eq_or_ne b 0 with (rfl | hb)
  · simp
  simp only [ord_proj_mul p ha hb]
  

Proof state:
case inr.inr
a✝ b✝ m n p✝ a b p : ℕ
ha : a ≠ 0
hb : b ≠ 0
⊢ a * b / (p ^ (factorization a) p * p ^ (factorization b) p) =
    a / p ^ (factorization a) p * (b / p ^ (factorization b) p)

Next tactic:
rw [mul_div_mul_comm_of_dvd_dvd (ord_proj_dvd a p) (ord_proj_dvd b p)]
/-- A crude upper bound on `n.factorization p` -/
theorem factorization_lt {n : ℕ} (p : ℕ) (hn : n ≠ 0) : n.factorization p < n := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
⊢ (factorization n) p < n

Next tactic:
by_cases pp : p.Prime
/-- A crude upper bound on `n.factorization p` -/
theorem factorization_lt {n : ℕ} (p : ℕ) (hn : n ≠ 0) : n.factorization p < n := by
  by_cases pp : p.Prime
  · 

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
pp : Prime p
⊢ (factorization n) p < n

Next tactic:
exact (pow_lt_pow_iff_right pp.one_lt).1 $ (ord_proj_le p hn).trans_lt $ lt_pow_self pp.one_lt _
/-- A crude upper bound on `n.factorization p` -/
theorem factorization_lt {n : ℕ} (p : ℕ) (hn : n ≠ 0) : n.factorization p < n := by
  by_cases pp : p.Prime
  · exact (pow_lt_pow_iff_right pp.one_lt).1 $ (ord_proj_le p hn).trans_lt $ lt_pow_self pp.one_lt _
  · 

Proof state:
case neg
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
pp : ¬Prime p
⊢ (factorization n) p < n

Next tactic:
simpa only [factorization_eq_zero_of_non_prime n pp] using hn.bot_lt
/-- An upper bound on `n.factorization p` -/
theorem factorization_le_of_le_pow {n p b : ℕ} (hb : n ≤ p ^ b) : n.factorization p ≤ b := by
  

Proof state:
a b✝ m n✝ p✝ n p b : ℕ
hb : n ≤ p ^ b
⊢ (factorization n) p ≤ b

Next tactic:
rcases eq_or_ne n 0 with (rfl | hn)
/-- An upper bound on `n.factorization p` -/
theorem factorization_le_of_le_pow {n p b : ℕ} (hb : n ≤ p ^ b) : n.factorization p ≤ b := by
  rcases eq_or_ne n 0 with (rfl | hn)
  · 

Proof state:
case inl
a b✝ m n p✝ p b : ℕ
hb : 0 ≤ p ^ b
⊢ (factorization 0) p ≤ b

Next tactic:
simp
/-- An upper bound on `n.factorization p` -/
theorem factorization_le_of_le_pow {n p b : ℕ} (hb : n ≤ p ^ b) : n.factorization p ≤ b := by
  rcases eq_or_ne n 0 with (rfl | hn)
  · simp
  

Proof state:
case inr
a b✝ m n✝ p✝ n p b : ℕ
hb : n ≤ p ^ b
hn : n ≠ 0
⊢ (factorization n) p ≤ b

Next tactic:
by_cases pp : p.Prime
/-- An upper bound on `n.factorization p` -/
theorem factorization_le_of_le_pow {n p b : ℕ} (hb : n ≤ p ^ b) : n.factorization p ≤ b := by
  rcases eq_or_ne n 0 with (rfl | hn)
  · simp
  by_cases pp : p.Prime
  · 

Proof state:
case pos
a b✝ m n✝ p✝ n p b : ℕ
hb : n ≤ p ^ b
hn : n ≠ 0
pp : Prime p
⊢ (factorization n) p ≤ b

Next tactic:
exact (pow_le_pow_iff_right pp.one_lt).1 ((ord_proj_le p hn).trans hb)
/-- An upper bound on `n.factorization p` -/
theorem factorization_le_of_le_pow {n p b : ℕ} (hb : n ≤ p ^ b) : n.factorization p ≤ b := by
  rcases eq_or_ne n 0 with (rfl | hn)
  · simp
  by_cases pp : p.Prime
  · exact (pow_le_pow_iff_right pp.one_lt).1 ((ord_proj_le p hn).trans hb)
  · 

Proof state:
case neg
a b✝ m n✝ p✝ n p b : ℕ
hb : n ≤ p ^ b
hn : n ≠ 0
pp : ¬Prime p
⊢ (factorization n) p ≤ b

Next tactic:
simp [factorization_eq_zero_of_non_prime n pp]
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  

Proof state:
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
⊢ factorization d ≤ factorization n ↔ d ∣ n

Next tactic:
constructor
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  constructor
  · 

Proof state:
case mp
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
⊢ factorization d ≤ factorization n → d ∣ n

Next tactic:
intro hdn
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  constructor
  · intro hdn
    

Proof state:
case mp
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
hdn : factorization d ≤ factorization n
⊢ d ∣ n

Next tactic:
set K := n.factorization - d.factorization with hK
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  constructor
  · intro hdn
    set K := n.factorization - d.factorization with hK
    

Proof state:
case mp
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
hdn : factorization d ≤ factorization n
K : ℕ →₀ ℕ := factorization n - factorization d
hK : K = factorization n - factorization d
⊢ d ∣ n

Next tactic:
use K.prod (· ^ ·)
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  constructor
  · intro hdn
    set K := n.factorization - d.factorization with hK
    use K.prod (· ^ ·)
    

Proof state:
case h
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
hdn : factorization d ≤ factorization n
K : ℕ →₀ ℕ := factorization n - factorization d
hK : K = factorization n - factorization d
⊢ n = d * Finsupp.prod K fun x x_1 => x ^ x_1

Next tactic:
rw [← factorization_prod_pow_eq_self hn, ← factorization_prod_pow_eq_self hd,
        ← Finsupp.prod_add_index' pow_zero pow_add, hK, add_tsub_cancel_of_le hdn]
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  constructor
  · intro hdn
    set K := n.factorization - d.factorization with hK
    use K.prod (· ^ ·)
    rw [← factorization_prod_pow_eq_self hn, ← factorization_prod_pow_eq_self hd,
        ← Finsupp.prod_add_index' pow_zero pow_add, hK, add_tsub_cancel_of_le hdn]
  · 

Proof state:
case mpr
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
⊢ d ∣ n → factorization d ≤ factorization n

Next tactic:
rintro ⟨c, rfl⟩
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  constructor
  · intro hdn
    set K := n.factorization - d.factorization with hK
    use K.prod (· ^ ·)
    rw [← factorization_prod_pow_eq_self hn, ← factorization_prod_pow_eq_self hd,
        ← Finsupp.prod_add_index' pow_zero pow_add, hK, add_tsub_cancel_of_le hdn]
  · rintro ⟨c, rfl⟩
    

Proof state:
case mpr.intro
a b m n p d : ℕ
hd : d ≠ 0
c : ℕ
hn : d * c ≠ 0
⊢ factorization d ≤ factorization (d * c)

Next tactic:
rw [factorization_mul hd (right_ne_zero_of_mul hn)]
theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n := by
  constructor
  · intro hdn
    set K := n.factorization - d.factorization with hK
    use K.prod (· ^ ·)
    rw [← factorization_prod_pow_eq_self hn, ← factorization_prod_pow_eq_self hd,
        ← Finsupp.prod_add_index' pow_zero pow_add, hK, add_tsub_cancel_of_le hdn]
  · rintro ⟨c, rfl⟩
    rw [factorization_mul hd (right_ne_zero_of_mul hn)]
    

Proof state:
case mpr.intro
a b m n p d : ℕ
hd : d ≠ 0
c : ℕ
hn : d * c ≠ 0
⊢ factorization d ≤ factorization d + factorization c

Next tactic:
simp
theorem factorization_prime_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    (∀ p : ℕ, p.Prime → d.factorization p ≤ n.factorization p) ↔ d ∣ n := by
  

Proof state:
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
⊢ (∀ (p : ℕ), Prime p → (factorization d) p ≤ (factorization n) p) ↔ d ∣ n

Next tactic:
rw [← factorization_le_iff_dvd hd hn]
theorem factorization_prime_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    (∀ p : ℕ, p.Prime → d.factorization p ≤ n.factorization p) ↔ d ∣ n := by
  rw [← factorization_le_iff_dvd hd hn]
  

Proof state:
a b m n✝ p d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
⊢ (∀ (p : ℕ), Prime p → (factorization d) p ≤ (factorization n) p) ↔ factorization d ≤ factorization n

Next tactic:
refine' ⟨fun h p => (em p.Prime).elim (h p) fun hp => _, fun h p _ => h p⟩
theorem factorization_prime_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    (∀ p : ℕ, p.Prime → d.factorization p ≤ n.factorization p) ↔ d ∣ n := by
  rw [← factorization_le_iff_dvd hd hn]
  refine' ⟨fun h p => (em p.Prime).elim (h p) fun hp => _, fun h p _ => h p⟩
  

Proof state:
a b m n✝ p✝ d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
h : ∀ (p : ℕ), Prime p → (factorization d) p ≤ (factorization n) p
p : ℕ
hp : ¬Prime p
⊢ (factorization d) p ≤ (factorization n) p

Next tactic:
simp_rw [factorization_eq_zero_of_non_prime _ hp]
theorem factorization_prime_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    (∀ p : ℕ, p.Prime → d.factorization p ≤ n.factorization p) ↔ d ∣ n := by
  rw [← factorization_le_iff_dvd hd hn]
  refine' ⟨fun h p => (em p.Prime).elim (h p) fun hp => _, fun h p _ => h p⟩
  simp_rw [factorization_eq_zero_of_non_prime _ hp]
  

Proof state:
a b m n✝ p✝ d n : ℕ
hd : d ≠ 0
hn : n ≠ 0
h : ∀ (p : ℕ), Prime p → (factorization d) p ≤ (factorization n) p
p : ℕ
hp : ¬Prime p
⊢ 0 ≤ 0

Next tactic:
rfl
theorem pow_succ_factorization_not_dvd {n p : ℕ} (hn : n ≠ 0) (hp : p.Prime) :
    ¬p ^ (n.factorization p + 1) ∣ n := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
hp : Prime p
⊢ ¬p ^ ((factorization n) p + 1) ∣ n

Next tactic:
intro h
theorem pow_succ_factorization_not_dvd {n p : ℕ} (hn : n ≠ 0) (hp : p.Prime) :
    ¬p ^ (n.factorization p + 1) ∣ n := by
  intro h
  

Proof state:
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
hp : Prime p
h : p ^ ((factorization n) p + 1) ∣ n
⊢ False

Next tactic:
rw [← factorization_le_iff_dvd (pow_pos hp.pos _).ne' hn] at h
theorem pow_succ_factorization_not_dvd {n p : ℕ} (hn : n ≠ 0) (hp : p.Prime) :
    ¬p ^ (n.factorization p + 1) ∣ n := by
  intro h
  rw [← factorization_le_iff_dvd (pow_pos hp.pos _).ne' hn] at h
  

Proof state:
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
hp : Prime p
h : factorization (p ^ ((factorization n) p + 1)) ≤ factorization n
⊢ False

Next tactic:
simpa [hp.factorization] using h p
theorem factorization_le_factorization_mul_left {a b : ℕ} (hb : b ≠ 0) :
    a.factorization ≤ (a * b).factorization := by
  

Proof state:
a✝ b✝ m n p a b : ℕ
hb : b ≠ 0
⊢ factorization a ≤ factorization (a * b)

Next tactic:
rcases eq_or_ne a 0 with (rfl | ha)
theorem factorization_le_factorization_mul_left {a b : ℕ} (hb : b ≠ 0) :
    a.factorization ≤ (a * b).factorization := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · 

Proof state:
case inl
a b✝ m n p b : ℕ
hb : b ≠ 0
⊢ factorization 0 ≤ factorization (0 * b)

Next tactic:
simp
theorem factorization_le_factorization_mul_left {a b : ℕ} (hb : b ≠ 0) :
    a.factorization ≤ (a * b).factorization := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · simp
  

Proof state:
case inr
a✝ b✝ m n p a b : ℕ
hb : b ≠ 0
ha : a ≠ 0
⊢ factorization a ≤ factorization (a * b)

Next tactic:
rw [factorization_le_iff_dvd ha <| mul_ne_zero ha hb]
theorem factorization_le_factorization_mul_left {a b : ℕ} (hb : b ≠ 0) :
    a.factorization ≤ (a * b).factorization := by
  rcases eq_or_ne a 0 with (rfl | ha)
  · simp
  rw [factorization_le_iff_dvd ha <| mul_ne_zero ha hb]
  

Proof state:
case inr
a✝ b✝ m n p a b : ℕ
hb : b ≠ 0
ha : a ≠ 0
⊢ a ∣ a * b

Next tactic:
exact Dvd.intro b rfl
theorem factorization_le_factorization_mul_right {a b : ℕ} (ha : a ≠ 0) :
    b.factorization ≤ (a * b).factorization := by
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha : a ≠ 0
⊢ factorization b ≤ factorization (a * b)

Next tactic:
rw [mul_comm]
theorem factorization_le_factorization_mul_right {a b : ℕ} (ha : a ≠ 0) :
    b.factorization ≤ (a * b).factorization := by
  rw [mul_comm]
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha : a ≠ 0
⊢ factorization b ≤ factorization (b * a)

Next tactic:
apply factorization_le_factorization_mul_left ha
theorem Prime.pow_dvd_iff_le_factorization {p k n : ℕ} (pp : Prime p) (hn : n ≠ 0) :
    p ^ k ∣ n ↔ k ≤ n.factorization p := by
  

Proof state:
a b m n✝ p✝ p k n : ℕ
pp : Prime p
hn : n ≠ 0
⊢ p ^ k ∣ n ↔ k ≤ (Nat.factorization n) p

Next tactic:
rw [← factorization_le_iff_dvd (pow_pos pp.pos k).ne' hn, pp.factorization_pow, single_le_iff]
theorem Prime.pow_dvd_iff_dvd_ord_proj {p k n : ℕ} (pp : Prime p) (hn : n ≠ 0) :
    p ^ k ∣ n ↔ p ^ k ∣ ord_proj[p] n := by
  

Proof state:
a b m n✝ p✝ p k n : ℕ
pp : Prime p
hn : n ≠ 0
⊢ p ^ k ∣ n ↔ p ^ k ∣ p ^ (Nat.factorization n) p

Next tactic:
rw [pow_dvd_pow_iff_le_right pp.one_lt, pp.pow_dvd_iff_le_factorization hn]
theorem Prime.dvd_iff_one_le_factorization {p n : ℕ} (pp : Prime p) (hn : n ≠ 0) :
    p ∣ n ↔ 1 ≤ n.factorization p :=
  Iff.trans (by 

Proof state:
a b m n✝ p✝ p n : ℕ
pp : Prime p
hn : n ≠ 0
⊢ p ∣ n ↔ p ^ 1 ∣ n

Next tactic:
simp
theorem exists_factorization_lt_of_lt {a b : ℕ} (ha : a ≠ 0) (hab : a < b) :
    ∃ p : ℕ, a.factorization p < b.factorization p := by
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha : a ≠ 0
hab : a < b
⊢ ∃ p, (factorization a) p < (factorization b) p

Next tactic:
have hb : b ≠ 0 := (ha.bot_lt.trans hab).ne'
theorem exists_factorization_lt_of_lt {a b : ℕ} (ha : a ≠ 0) (hab : a < b) :
    ∃ p : ℕ, a.factorization p < b.factorization p := by
  have hb : b ≠ 0 := (ha.bot_lt.trans hab).ne'
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha : a ≠ 0
hab : a < b
hb : b ≠ 0
⊢ ∃ p, (factorization a) p < (factorization b) p

Next tactic:
contrapose! hab
theorem exists_factorization_lt_of_lt {a b : ℕ} (ha : a ≠ 0) (hab : a < b) :
    ∃ p : ℕ, a.factorization p < b.factorization p := by
  have hb : b ≠ 0 := (ha.bot_lt.trans hab).ne'
  contrapose! hab
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha : a ≠ 0
hb : b ≠ 0
hab : ∀ (p : ℕ), (factorization b) p ≤ (factorization a) p
⊢ b ≤ a

Next tactic:
rw [← Finsupp.le_def, factorization_le_iff_dvd hb ha] at hab
theorem exists_factorization_lt_of_lt {a b : ℕ} (ha : a ≠ 0) (hab : a < b) :
    ∃ p : ℕ, a.factorization p < b.factorization p := by
  have hb : b ≠ 0 := (ha.bot_lt.trans hab).ne'
  contrapose! hab
  rw [← Finsupp.le_def, factorization_le_iff_dvd hb ha] at hab
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha : a ≠ 0
hb : b ≠ 0
hab : b ∣ a
⊢ b ≤ a

Next tactic:
exact le_of_dvd ha.bot_lt hab
@[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization := by
  

Proof state:
a b m n✝ p d n : ℕ
h : d ∣ n
⊢ factorization (n / d) = factorization n - factorization d

Next tactic:
rcases eq_or_ne d 0 with (rfl | hd)
@[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization := by
  rcases eq_or_ne d 0 with (rfl | hd); · 

Proof state:
case inl
a b m n✝ p n : ℕ
h : 0 ∣ n
⊢ factorization (n / 0) = factorization n - factorization 0

Next tactic:
simp [zero_dvd_iff.mp h]
@[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization := by
  rcases eq_or_ne d 0 with (rfl | hd); · simp [zero_dvd_iff.mp h]
  

Proof state:
case inr
a b m n✝ p d n : ℕ
h : d ∣ n
hd : d ≠ 0
⊢ factorization (n / d) = factorization n - factorization d

Next tactic:
rcases eq_or_ne n 0 with (rfl | hn)
@[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization := by
  rcases eq_or_ne d 0 with (rfl | hd); · simp [zero_dvd_iff.mp h]
  rcases eq_or_ne n 0 with (rfl | hn); · 

Proof state:
case inr.inl
a b m n p d : ℕ
hd : d ≠ 0
h : d ∣ 0
⊢ factorization (0 / d) = factorization 0 - factorization d

Next tactic:
simp
@[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization := by
  rcases eq_or_ne d 0 with (rfl | hd); · simp [zero_dvd_iff.mp h]
  rcases eq_or_ne n 0 with (rfl | hn); · simp
  

Proof state:
case inr.inr
a b m n✝ p d n : ℕ
h : d ∣ n
hd : d ≠ 0
hn : n ≠ 0
⊢ factorization (n / d) = factorization n - factorization d

Next tactic:
apply add_left_injective d.factorization
@[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization := by
  rcases eq_or_ne d 0 with (rfl | hd); · simp [zero_dvd_iff.mp h]
  rcases eq_or_ne n 0 with (rfl | hn); · simp
  apply add_left_injective d.factorization
  

Proof state:
case inr.inr.a
a b m n✝ p d n : ℕ
h : d ∣ n
hd : d ≠ 0
hn : n ≠ 0
⊢ (fun x => x + factorization d) (factorization (n / d)) =
    (fun x => x + factorization d) (factorization n - factorization d)

Next tactic:
simp only
@[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization := by
  rcases eq_or_ne d 0 with (rfl | hd); · simp [zero_dvd_iff.mp h]
  rcases eq_or_ne n 0 with (rfl | hn); · simp
  apply add_left_injective d.factorization
  simp only
  

Proof state:
case inr.inr.a
a b m n✝ p d n : ℕ
h : d ∣ n
hd : d ≠ 0
hn : n ≠ 0
⊢ factorization (n / d) + factorization d = factorization n - factorization d + factorization d

Next tactic:
rw [tsub_add_cancel_of_le <| (Nat.factorization_le_iff_dvd hd hn).mpr h, ←
    Nat.factorization_mul (Nat.div_pos (Nat.le_of_dvd hn.bot_lt h) hd.bot_lt).ne' hd,
    Nat.div_mul_cancel h]
theorem not_dvd_ord_compl {n p : ℕ} (hp : Prime p) (hn : n ≠ 0) : ¬p ∣ ord_compl[p] n := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
hp : Prime p
hn : n ≠ 0
⊢ ¬p ∣ n / p ^ (factorization n) p

Next tactic:
rw [Nat.Prime.dvd_iff_one_le_factorization hp (ord_compl_pos p hn).ne']
theorem not_dvd_ord_compl {n p : ℕ} (hp : Prime p) (hn : n ≠ 0) : ¬p ∣ ord_compl[p] n := by
  rw [Nat.Prime.dvd_iff_one_le_factorization hp (ord_compl_pos p hn).ne']
  

Proof state:
a b m n✝ p✝ n p : ℕ
hp : Prime p
hn : n ≠ 0
⊢ ¬1 ≤ (factorization (n / p ^ (factorization n) p)) p

Next tactic:
rw [Nat.factorization_div (Nat.ord_proj_dvd n p)]
theorem not_dvd_ord_compl {n p : ℕ} (hp : Prime p) (hn : n ≠ 0) : ¬p ∣ ord_compl[p] n := by
  rw [Nat.Prime.dvd_iff_one_le_factorization hp (ord_compl_pos p hn).ne']
  rw [Nat.factorization_div (Nat.ord_proj_dvd n p)]
  

Proof state:
a b m n✝ p✝ n p : ℕ
hp : Prime p
hn : n ≠ 0
⊢ ¬1 ≤ (factorization n - factorization (p ^ (factorization n) p)) p

Next tactic:
simp [hp.factorization]
theorem factorization_ord_compl (n p : ℕ) :
    (ord_compl[p] n).factorization = n.factorization.erase p := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
⊢ factorization (n / p ^ (factorization n) p) = Finsupp.erase p (factorization n)

Next tactic:
rcases eq_or_ne n 0 with (rfl | hn)
theorem factorization_ord_compl (n p : ℕ) :
    (ord_compl[p] n).factorization = n.factorization.erase p := by
  rcases eq_or_ne n 0 with (rfl | hn); · 

Proof state:
case inl
a b m n p✝ p : ℕ
⊢ factorization (0 / p ^ (factorization 0) p) = Finsupp.erase p (factorization 0)

Next tactic:
simp
theorem factorization_ord_compl (n p : ℕ) :
    (ord_compl[p] n).factorization = n.factorization.erase p := by
  rcases eq_or_ne n 0 with (rfl | hn); · simp
  

Proof state:
case inr
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
⊢ factorization (n / p ^ (factorization n) p) = Finsupp.erase p (factorization n)

Next tactic:
by_cases pp : p.Prime