Theorem: Nat.maxPowDiv.pow_dvd
File: Mathlib/Data/Nat/MaxPowDiv.lean

tactic: dsimp [maxPowDiv]
state_before: p n : ℕ
⊢ p ^ p.maxPowDiv n ∣ n
state_after: p n : ℕ
⊢ p ^ go 0 p n ∣ n

tactic: rw [go]
state_before: p n : ℕ
⊢ p ^ go 0 p n ∣ n
state_after: p n : ℕ
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n

tactic: by_cases h : (1 < p ∧ 0 < n ∧ n % p = 0)
state_before: p n : ℕ
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n
state_after: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n

case neg
p n : ℕ
h : ¬(1 < p ∧ 0 < n ∧ n % p = 0)
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n

tactic: have : n / p < n := by apply Nat.div_lt_self <;> aesop
state_before: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n
state_after: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n

tactic: rw [if_pos h]
state_before: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n
state_after: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
⊢ p ^ go (0 + 1) p (n / p) ∣ n

tactic: have ⟨c,hc⟩ := pow_dvd p (n / p)
state_before: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
⊢ p ^ go (0 + 1) p (n / p) ∣ n
state_after: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go (0 + 1) p (n / p) ∣ n

tactic: rw [go_succ, pow_succ]
state_before: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go (0 + 1) p (n / p) ∣ n
state_after: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go 0 p (n / p) * p ∣ n

tactic: nth_rw 2 [← mod_add_div' n p]
state_before: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go 0 p (n / p) * p ∣ n
state_after: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go 0 p (n / p) * p ∣ n % p + n / p * p

tactic: rw [h.right.right, zero_add]
state_before: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go 0 p (n / p) * p ∣ n % p + n / p * p
state_after: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go 0 p (n / p) * p ∣ n / p * p

tactic: exact ⟨c,by nth_rw 1 [hc]; ac_rfl⟩
state_before: case pos
p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ go 0 p (n / p) * p ∣ n / p * p
state_after: no goals

tactic: apply Nat.div_lt_self <;> aesop
state_before: p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
⊢ n / p < n
state_after: no goals

tactic: nth_rw 1 [hc]
state_before: p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ n / p * p = p ^ go 0 p (n / p) * p * c
state_after: p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ p.maxPowDiv (n / p) * c * p = p ^ go 0 p (n / p) * p * c

tactic: ac_rfl
state_before: p n : ℕ
h : 1 < p ∧ 0 < n ∧ n % p = 0
this : n / p < n
c : ℕ
hc : n / p = p ^ p.maxPowDiv (n / p) * c
⊢ p ^ p.maxPowDiv (n / p) * c * p = p ^ go 0 p (n / p) * p * c
state_after: no goals

tactic: rw [if_neg h]
state_before: case neg
p n : ℕ
h : ¬(1 < p ∧ 0 < n ∧ n % p = 0)
⊢ (p ^ if 1 < p ∧ 0 < n ∧ n % p = 0 then go (0 + 1) p (n / p) else 0) ∣ n
state_after: case neg
p n : ℕ
h : ¬(1 < p ∧ 0 < n ∧ n % p = 0)
⊢ p ^ 0 ∣ n

tactic: simp
state_before: case neg
p n : ℕ
h : ¬(1 < p ∧ 0 < n ∧ n % p = 0)
⊢ p ^ 0 ∣ n
state_after: no goals