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

tactic: refine ⟨factorization_div, ?_⟩
state_before: a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
⊢ d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization
state_after: a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
⊢ (n / d).factorization = n.factorization - d.factorization → d ∣ n

tactic: rcases eq_or_lt_of_le hdn with (rfl | hd_lt_n)
state_before: a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
⊢ (n / d).factorization = n.factorization - d.factorization → d ∣ n
state_after: case inl
a b m n p d : ℕ
hd : d ≠ 0
hdn : d ≤ d
⊢ (d / d).factorization = d.factorization - d.factorization → d ∣ d

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

tactic: have h1 : n / d ≠ 0 := fun H => Nat.lt_asymm hd_lt_n ((Nat.div_eq_zero_iff hd.bot_lt).mp H)
state_before: case inr
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
hd_lt_n : d < n
⊢ (n / d).factorization = n.factorization - d.factorization → d ∣ n
state_after: case inr
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
hd_lt_n : d < n
h1 : n / d ≠ 0
⊢ (n / d).factorization = n.factorization - d.factorization → d ∣ n

tactic: intro h
state_before: case inr
a b m n✝ p d n : ℕ
hd : d ≠ 0
hdn : d ≤ n
hd_lt_n : d < n
h1 : n / d ≠ 0
⊢ (n / d).factorization = n.factorization - d.factorization → d ∣ n
state_after: 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 : (n / d).factorization = n.factorization - d.factorization
⊢ d ∣ n

tactic: rw [dvd_iff_le_div_mul n d]
state_before: 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 : (n / d).factorization = n.factorization - d.factorization
⊢ d ∣ n
state_after: 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 : (n / d).factorization = n.factorization - d.factorization
⊢ n ≤ n / d * d

tactic: by_contra h2
state_before: 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 : (n / d).factorization = n.factorization - d.factorization
⊢ n ≤ n / d * d
state_after: 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 : (n / d).factorization = n.factorization - d.factorization
h2 : ¬n ≤ n / d * d
⊢ False

tactic: cases' exists_factorization_lt_of_lt (mul_ne_zero h1 hd) (not_le.mp h2) with p hp
state_before: 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 : (n / d).factorization = n.factorization - d.factorization
h2 : ¬n ≤ n / d * d
⊢ False
state_after: 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 : (n / d).factorization = n.factorization - d.factorization
h2 : ¬n ≤ n / d * d
p : ℕ
hp : (n / d * d).factorization p < n.factorization p
⊢ False

tactic: rwa [factorization_mul h1 hd, add_apply, ← lt_tsub_iff_right, h, tsub_apply,
 lt_self_iff_false] at hp
state_before: 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 : (n / d).factorization = n.factorization - d.factorization
h2 : ¬n ≤ n / d * d
p : ℕ
hp : (n / d * d).factorization p < n.factorization p
⊢ False
state_after: no goals

tactic: simp
state_before: case inl
a b m n p d : ℕ
hd : d ≠ 0
hdn : d ≤ d
⊢ (d / d).factorization = d.factorization - d.factorization → d ∣ d
state_after: no goals