l3lab/ntp-mathlib huggingface dataset:
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
  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 ^ (factorization n) p) = Finsupp.erase p (factorization n)
case neg
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
pp : ¬Prime p
⊢ factorization (n / p ^ (factorization n) p) = Finsupp.erase p (factorization n)

Next tactic:
case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
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
  by_cases pp : p.Prime
  

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

Next tactic:
case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    

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

Next tactic:
rw [Finsupp.erase_of_not_mem_support]
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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> 

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

Next tactic:
simp [pp]
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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> 

Proof state:
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
pp : ¬Prime p
⊢ p ∉ (factorization n).support

Next tactic:
simp [pp]
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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
  

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

Next tactic:
ext q
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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
  ext q
  

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

Next tactic:
rcases eq_or_ne q p with (rfl | hqp)
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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
  ext q
  rcases eq_or_ne q p with (rfl | hqp)
  · 

Proof state:
case pos.h.inl
a b m n✝ p n : ℕ
hn : n ≠ 0
q : ℕ
pp : Prime q
⊢ (factorization (n / q ^ (factorization n) q)) q = (Finsupp.erase q (factorization n)) q

Next tactic:
simp only [Finsupp.erase_same, factorization_eq_zero_iff, not_dvd_ord_compl pp 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); · simp
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
  ext q
  rcases eq_or_ne q p with (rfl | hqp)
  · simp only [Finsupp.erase_same, factorization_eq_zero_iff, not_dvd_ord_compl pp hn]
    

Proof state:
case pos.h.inl
a b m n✝ p n : ℕ
hn : n ≠ 0
q : ℕ
pp : Prime q
⊢ ¬Prime q ∨ ¬False ∨ n / q ^ (factorization n) q = 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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
  ext q
  rcases eq_or_ne q p with (rfl | hqp)
  · simp only [Finsupp.erase_same, factorization_eq_zero_iff, not_dvd_ord_compl pp hn]
    simp
  · 

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

Next tactic:
rw [Finsupp.erase_ne hqp, factorization_div (ord_proj_dvd n p)]
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
  by_cases pp : p.Prime
  case neg =>
    -- porting note: needed to solve side goal explicitly
    rw [Finsupp.erase_of_not_mem_support] <;> simp [pp]
  ext q
  rcases eq_or_ne q p with (rfl | hqp)
  · simp only [Finsupp.erase_same, factorization_eq_zero_iff, not_dvd_ord_compl pp hn]
    simp
  · rw [Finsupp.erase_ne hqp, factorization_div (ord_proj_dvd n p)]
    

Proof state:
case pos.h.inr
a b m n✝ p✝ n p : ℕ
hn : n ≠ 0
pp : Prime p
q : ℕ
hqp : q ≠ p
⊢ (factorization n - factorization (p ^ (factorization n) p)) q = (factorization n) q

Next tactic:
simp [pp.factorization, hqp.symm]
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  

Proof state:
a b m n✝ p✝ p d n : ℕ
hdn : d ∣ n
hpd : ¬p ∣ d
⊢ d ∣ n / p ^ (factorization n) p

Next tactic:
rcases eq_or_ne n 0 with (rfl | hn0)
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · 

Proof state:
case inl
a b m n p✝ p d : ℕ
hpd : ¬p ∣ d
hdn : d ∣ 0
⊢ d ∣ 0 / p ^ (factorization 0) p

Next tactic:
simp
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · simp
  

Proof state:
case inr
a b m n✝ p✝ p d n : ℕ
hdn : d ∣ n
hpd : ¬p ∣ d
hn0 : n ≠ 0
⊢ d ∣ n / p ^ (factorization n) p

Next tactic:
rcases eq_or_ne d 0 with (rfl | hd0)
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · simp
  rcases eq_or_ne d 0 with (rfl | hd0);
  · 

Proof state:
case inr.inl
a b m n✝ p✝ p n : ℕ
hn0 : n ≠ 0
hdn : 0 ∣ n
hpd : ¬p ∣ 0
⊢ 0 ∣ n / p ^ (factorization n) p

Next tactic:
simp at hpd
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · simp
  rcases eq_or_ne d 0 with (rfl | hd0);
  · simp at hpd
  

Proof state:
case inr.inr
a b m n✝ p✝ p d n : ℕ
hdn : d ∣ n
hpd : ¬p ∣ d
hn0 : n ≠ 0
hd0 : d ≠ 0
⊢ d ∣ n / p ^ (factorization n) p

Next tactic:
rw [← factorization_le_iff_dvd hd0 (ord_compl_pos p hn0).ne', factorization_ord_compl]
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · simp
  rcases eq_or_ne d 0 with (rfl | hd0);
  · simp at hpd
  rw [← factorization_le_iff_dvd hd0 (ord_compl_pos p hn0).ne', factorization_ord_compl]
  

Proof state:
case inr.inr
a b m n✝ p✝ p d n : ℕ
hdn : d ∣ n
hpd : ¬p ∣ d
hn0 : n ≠ 0
hd0 : d ≠ 0
⊢ factorization d ≤ Finsupp.erase p (factorization n)

Next tactic:
intro q
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · simp
  rcases eq_or_ne d 0 with (rfl | hd0);
  · simp at hpd
  rw [← factorization_le_iff_dvd hd0 (ord_compl_pos p hn0).ne', factorization_ord_compl]
  intro q
  

Proof state:
case inr.inr
a b m n✝ p✝ p d n : ℕ
hdn : d ∣ n
hpd : ¬p ∣ d
hn0 : n ≠ 0
hd0 : d ≠ 0
q : ℕ
⊢ (factorization d) q ≤ (Finsupp.erase p (factorization n)) q

Next tactic:
rcases eq_or_ne q p with (rfl | hqp)
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · simp
  rcases eq_or_ne d 0 with (rfl | hd0);
  · simp at hpd
  rw [← factorization_le_iff_dvd hd0 (ord_compl_pos p hn0).ne', factorization_ord_compl]
  intro q
  rcases eq_or_ne q p with (rfl | hqp)
  · 

Proof state:
case inr.inr.inl
a b m n✝ p d n : ℕ
hdn : d ∣ n
hn0 : n ≠ 0
hd0 : d ≠ 0
q : ℕ
hpd : ¬q ∣ d
⊢ (factorization d) q ≤ (Finsupp.erase q (factorization n)) q

Next tactic:
simp [factorization_eq_zero_iff, hpd]
theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n := by
  rcases eq_or_ne n 0 with (rfl | hn0); · simp
  rcases eq_or_ne d 0 with (rfl | hd0);
  · simp at hpd
  rw [← factorization_le_iff_dvd hd0 (ord_compl_pos p hn0).ne', factorization_ord_compl]
  intro q
  rcases eq_or_ne q p with (rfl | hqp)
  · simp [factorization_eq_zero_iff, hpd]
  · 

Proof state:
case inr.inr.inr
a b m n✝ p✝ p d n : ℕ
hdn : d ∣ n
hpd : ¬p ∣ d
hn0 : n ≠ 0
hd0 : d ≠ 0
q : ℕ
hqp : q ≠ p
⊢ (factorization d) q ≤ (Finsupp.erase p (factorization n)) q

Next tactic:
simp [hqp, (factorization_le_iff_dvd hd0 hn0).2 hdn q]
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  

Proof state:
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
⊢ d ∣ n ↔ factorization (n / d) = factorization n - factorization d

Next tactic:
refine' ⟨factorization_div, _⟩
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  

Proof state:
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
⊢ factorization (n / d) = factorization n - factorization d → d ∣ n

Next tactic:
rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n)
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n); · 

Proof state:
case inl
a b m n p d : ℕ
hd : d ≠ 0
hdn : d ≤ d
⊢ factorization (d / d) = factorization d - factorization d → d ∣ d

Next tactic:
simp
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n); · simp
  

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

Next tactic:
have h1 : n / d ≠ 0 := fun H => Nat.lt_asymm hd_lt_n ((Nat.div_eq_zero_iff hd.bot_lt).mp H)
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n); · simp
  have h1 : n / d ≠ 0 := fun H => Nat.lt_asymm hd_lt_n ((Nat.div_eq_zero_iff hd.bot_lt).mp H)
  

Proof state:
case inr
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
hd_lt_n : d < n
h1 : n / d ≠ 0
⊢ factorization (n / d) = factorization n - factorization d → d ∣ n

Next tactic:
intro h
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n); · simp
  have h1 : n / d ≠ 0 := fun H => Nat.lt_asymm hd_lt_n ((Nat.div_eq_zero_iff hd.bot_lt).mp H)
  intro h
  

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

Next tactic:
rw [dvd_iff_le_div_mul n d]
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n); · simp
  have h1 : n / d ≠ 0 := fun H => Nat.lt_asymm hd_lt_n ((Nat.div_eq_zero_iff hd.bot_lt).mp H)
  intro h
  rw [dvd_iff_le_div_mul n d]
  

Proof state:
case inr
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
hd_lt_n : d < n
h1 : n / d ≠ 0
h : factorization (n / d) = factorization n - factorization d
⊢ n ≤ n / d * d

Next tactic:
by_contra h2
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n); · simp
  have h1 : n / d ≠ 0 := fun H => Nat.lt_asymm hd_lt_n ((Nat.div_eq_zero_iff hd.bot_lt).mp H)
  intro h
  rw [dvd_iff_le_div_mul n d]
  by_contra h2
  

Proof state:
case inr
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
hd_lt_n : d < n
h1 : n / d ≠ 0
h : factorization (n / d) = factorization n - factorization d
h2 : ¬n ≤ n / d * d
⊢ False

Next tactic:
cases' exists_factorization_lt_of_lt (mul_ne_zero h1 hd) (not_le.mp h2) with p hp
theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization := by
  refine' ⟨factorization_div, _⟩
  rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n); · simp
  have h1 : n / d ≠ 0 := fun H => Nat.lt_asymm hd_lt_n ((Nat.div_eq_zero_iff hd.bot_lt).mp H)
  intro h
  rw [dvd_iff_le_div_mul n d]
  by_contra h2
  cases' exists_factorization_lt_of_lt (mul_ne_zero h1 hd) (not_le.mp h2) with p hp
  

Proof state:
case inr.intro
a b m n✝ p✝ d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
hd_lt_n : d < n
h1 : n / d ≠ 0
h : factorization (n / d) = factorization n - factorization d
h2 : ¬n ≤ n / d * d
p : ℕ
hp : (factorization (n / d * d)) p < (factorization n) p
⊢ False

Next tactic:
rwa [factorization_mul h1 hd, add_apply, ← lt_tsub_iff_right, h, tsub_apply,
   lt_self_iff_false] at hp
theorem ord_proj_dvd_ord_proj_of_dvd {a b : ℕ} (hb0 : b ≠ 0) (hab : a ∣ b) (p : ℕ) :
    ord_proj[p] a ∣ ord_proj[p] b := by
  

Proof state:
a✝ b✝ m n p✝ a b : ℕ
hb0 : b ≠ 0
hab : a ∣ b
p : ℕ
⊢ p ^ (factorization a) p ∣ p ^ (factorization b) p

Next tactic:
rcases em' p.Prime with (pp | pp)
theorem ord_proj_dvd_ord_proj_of_dvd {a b : ℕ} (hb0 : b ≠ 0) (hab : a ∣ b) (p : ℕ) :
    ord_proj[p] a ∣ ord_proj[p] b := by
  rcases em' p.Prime with (pp | pp); · 

Proof state:
case inl
a✝ b✝ m n p✝ a b : ℕ
hb0 : b ≠ 0
hab : a ∣ b
p : ℕ
pp : ¬Prime p
⊢ p ^ (factorization a) p ∣ p ^ (factorization b) p

Next tactic:
simp [pp]
theorem ord_proj_dvd_ord_proj_of_dvd {a b : ℕ} (hb0 : b ≠ 0) (hab : a ∣ b) (p : ℕ) :
    ord_proj[p] a ∣ ord_proj[p] b := by
  rcases em' p.Prime with (pp | pp); · simp [pp]
  

Proof state:
case inr
a✝ b✝ m n p✝ a b : ℕ
hb0 : b ≠ 0
hab : a ∣ b
p : ℕ
pp : Prime p
⊢ p ^ (factorization a) p ∣ p ^ (factorization b) p

Next tactic:
rcases eq_or_ne a 0 with (rfl | ha0)
theorem ord_proj_dvd_ord_proj_of_dvd {a b : ℕ} (hb0 : b ≠ 0) (hab : a ∣ b) (p : ℕ) :
    ord_proj[p] a ∣ ord_proj[p] b := by
  rcases em' p.Prime with (pp | pp); · simp [pp]
  rcases eq_or_ne a 0 with (rfl | ha0); · 

Proof state:
case inr.inl
a b✝ m n p✝ b : ℕ
hb0 : b ≠ 0
p : ℕ
pp : Prime p
hab : 0 ∣ b
⊢ p ^ (factorization 0) p ∣ p ^ (factorization b) p

Next tactic:
simp
theorem ord_proj_dvd_ord_proj_of_dvd {a b : ℕ} (hb0 : b ≠ 0) (hab : a ∣ b) (p : ℕ) :
    ord_proj[p] a ∣ ord_proj[p] b := by
  rcases em' p.Prime with (pp | pp); · simp [pp]
  rcases eq_or_ne a 0 with (rfl | ha0); · simp
  

Proof state:
case inr.inr
a✝ b✝ m n p✝ a b : ℕ
hb0 : b ≠ 0
hab : a ∣ b
p : ℕ
pp : Prime p
ha0 : a ≠ 0
⊢ p ^ (factorization a) p ∣ p ^ (factorization b) p

Next tactic:
rw [pow_dvd_pow_iff_le_right pp.one_lt]
theorem ord_proj_dvd_ord_proj_of_dvd {a b : ℕ} (hb0 : b ≠ 0) (hab : a ∣ b) (p : ℕ) :
    ord_proj[p] a ∣ ord_proj[p] b := by
  rcases em' p.Prime with (pp | pp); · simp [pp]
  rcases eq_or_ne a 0 with (rfl | ha0); · simp
  rw [pow_dvd_pow_iff_le_right pp.one_lt]
  

Proof state:
case inr.inr
a✝ b✝ m n p✝ a b : ℕ
hb0 : b ≠ 0
hab : a ∣ b
p : ℕ
pp : Prime p
ha0 : a ≠ 0
⊢ (factorization a) p ≤ (factorization b) p

Next tactic:
exact (factorization_le_iff_dvd ha0 hb0).2 hab p
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
⊢ (∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p) ↔ a ∣ b

Next tactic:
refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
h : ∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p
⊢ a ∣ b

Next tactic:
rw [← factorization_le_iff_dvd ha0 hb0]
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
  rw [← factorization_le_iff_dvd ha0 hb0]
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
h : ∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p
⊢ factorization a ≤ factorization b

Next tactic:
intro q
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
  rw [← factorization_le_iff_dvd ha0 hb0]
  intro q
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
h : ∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p
q : ℕ
⊢ (factorization a) q ≤ (factorization b) q

Next tactic:
rcases le_or_lt q 1 with (hq_le | hq1)
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
  rw [← factorization_le_iff_dvd ha0 hb0]
  intro q
  rcases le_or_lt q 1 with (hq_le | hq1)
  · 

Proof state:
case inl
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
h : ∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p
q : ℕ
hq_le : q ≤ 1
⊢ (factorization a) q ≤ (factorization b) q

Next tactic:
interval_cases q
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
  rw [← factorization_le_iff_dvd ha0 hb0]
  intro q
  rcases le_or_lt q 1 with (hq_le | hq1)
  · interval_cases q <;> 

Proof state:
case inl.«0»
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
h : ∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p
q : ℕ
hq_le : 0 ≤ 1
⊢ (factorization a) 0 ≤ (factorization b) 0

Next tactic:
simp
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
  rw [← factorization_le_iff_dvd ha0 hb0]
  intro q
  rcases le_or_lt q 1 with (hq_le | hq1)
  · interval_cases q <;> 

Proof state:
case inl.«1»
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
h : ∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p
q : ℕ
hq_le : 1 ≤ 1
⊢ (factorization a) 1 ≤ (factorization b) 1

Next tactic:
simp
theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b := by
  refine' ⟨fun h => _, fun hab p => ord_proj_dvd_ord_proj_of_dvd hb0 hab p⟩
  rw [← factorization_le_iff_dvd ha0 hb0]
  intro q
  rcases le_or_lt q 1 with (hq_le | hq1)
  · interval_cases q <;> simp
  

Proof state:
case inr
a✝ b✝ m n p a b : ℕ
ha0 : a ≠ 0
hb0 : b ≠ 0
h : ∀ (p : ℕ), p ^ (factorization a) p ∣ p ^ (factorization b) p
q : ℕ
hq1 : 1 < q
⊢ (factorization a) q ≤ (factorization b) q

Next tactic:
exact (pow_dvd_pow_iff_le_right hq1).1 (h q)
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  

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

Next tactic:
rcases em' p.Prime with (pp | pp)
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  rcases em' p.Prime with (pp | pp)
  · 

Proof state:
case inl
a✝ b✝ m n p✝ a b : ℕ
hab : a ∣ b
p : ℕ
pp : ¬Prime p
⊢ a / p ^ (factorization a) p ∣ b / p ^ (factorization b) p

Next tactic:
simp [pp, hab]
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  rcases em' p.Prime with (pp | pp)
  · simp [pp, hab]
  

Proof state:
case inr
a✝ b✝ m n p✝ a b : ℕ
hab : a ∣ b
p : ℕ
pp : Prime p
⊢ a / p ^ (factorization a) p ∣ b / p ^ (factorization b) p

Next tactic:
rcases eq_or_ne b 0 with (rfl | hb0)
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  rcases em' p.Prime with (pp | pp)
  · simp [pp, hab]
  rcases eq_or_ne b 0 with (rfl | hb0)
  · 

Proof state:
case inr.inl
a✝ b m n p✝ a p : ℕ
pp : Prime p
hab : a ∣ 0
⊢ a / p ^ (factorization a) p ∣ 0 / p ^ (factorization 0) p

Next tactic:
simp
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  rcases em' p.Prime with (pp | pp)
  · simp [pp, hab]
  rcases eq_or_ne b 0 with (rfl | hb0)
  · simp
  

Proof state:
case inr.inr
a✝ b✝ m n p✝ a b : ℕ
hab : a ∣ b
p : ℕ
pp : Prime p
hb0 : b ≠ 0
⊢ a / p ^ (factorization a) p ∣ b / p ^ (factorization b) p

Next tactic:
rcases eq_or_ne a 0 with (rfl | ha0)
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  rcases em' p.Prime with (pp | pp)
  · simp [pp, hab]
  rcases eq_or_ne b 0 with (rfl | hb0)
  · simp
  rcases eq_or_ne a 0 with (rfl | ha0)
  · 

Proof state:
case inr.inr.inl
a b✝ m n p✝ b p : ℕ
pp : Prime p
hb0 : b ≠ 0
hab : 0 ∣ b
⊢ 0 / p ^ (factorization 0) p ∣ b / p ^ (factorization b) p

Next tactic:
cases hb0 (zero_dvd_iff.1 hab)
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  rcases em' p.Prime with (pp | pp)
  · simp [pp, hab]
  rcases eq_or_ne b 0 with (rfl | hb0)
  · simp
  rcases eq_or_ne a 0 with (rfl | ha0)
  · cases hb0 (zero_dvd_iff.1 hab)
  

Proof state:
case inr.inr.inr
a✝ b✝ m n p✝ a b : ℕ
hab : a ∣ b
p : ℕ
pp : Prime p
hb0 : b ≠ 0
ha0 : a ≠ 0
⊢ a / p ^ (factorization a) p ∣ b / p ^ (factorization b) p

Next tactic:
have ha := (Nat.div_pos (ord_proj_le p ha0) (ord_proj_pos a p)).ne'
theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b := by
  rcases em' p.Prime with (pp | pp)
  · simp [pp, hab]
  rcases eq_or_ne b 0 with (rfl | hb0)
  · simp
  rcases eq_or_ne a 0 with (rfl | ha0)
  · cases hb0 (zero_dvd_iff.1 hab)
  have ha := (Nat.div_pos (ord_proj_le p ha0) (ord_proj_pos a p)).ne'
  

Proof state:
case inr.inr.inr
a✝ b✝ m n p✝ a b : ℕ
hab : a ∣ b
p : ℕ
pp : Prime p
hb0 : b ≠ 0
ha0 : a ≠ 0
ha : a / p ^ (factorization a) p ≠ 0
⊢ a / p ^ (factorization a) p ∣ b / p ^ (factorization b) p

Next tactic:
have hb := (Nat.div_pos (ord_proj_le p hb0) (ord_proj_pos b p)).ne'