Theorem: Nat.ofDigits_digits
File: Mathlib/Data/Nat/Digits.lean

tactic: cases' b with b
state_before: n✝ b n : ℕ
⊢ ofDigits b (digits b n) = n

tactic: cases' n with n
state_before: case zero
n✝ n : ℕ
⊢ ofDigits zero (digits zero n) = n

tactic: rfl
state_before: case zero.zero
n : ℕ
⊢ ofDigits zero (digits zero zero) = zero

tactic: change ofDigits 0 [n + 1] = n + 1
state_before: case zero.succ
n✝ n : ℕ
⊢ ofDigits zero (digits zero (succ n)) = succ n

tactic: dsimp [ofDigits]
state_before: case zero.succ
n✝ n : ℕ
⊢ ofDigits 0 [n + 1] = n + 1

tactic: cases' b with b
state_before: case succ
n✝ n b : ℕ
⊢ ofDigits (succ b) (digits (succ b) n) = n

tactic: induction' n with n ih
state_before: case succ.zero
n✝ n : ℕ
⊢ ofDigits (succ zero) (digits (succ zero) n) = n

tactic: rfl
state_before: case succ.zero.zero
n : ℕ
⊢ ofDigits (succ zero) (digits (succ zero) zero) = zero

tactic: rw[show succ zero = 1 by rfl] at ih ⊢
state_before: case succ.zero.succ
n✝ n : ℕ
ih : ofDigits (succ zero) (digits (succ zero) n) = n
⊢ ofDigits (succ zero) (digits (succ zero) (succ n)) = succ n

tactic: simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
state_before: case succ.zero.succ
n✝ n : ℕ
ih : ofDigits 1 (digits 1 n) = n
⊢ ofDigits 1 (digits 1 (succ n)) = succ n

tactic: rfl
state_before: n✝ n : ℕ
ih : ofDigits 1 (digits 1 n) = n
⊢ succ zero = 1

tactic: apply Nat.strongInductionOn n _
state_before: case succ.succ
n✝ n b : ℕ
⊢ ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

tactic: clear n
state_before: n✝ n b : ℕ
⊢ ∀ (n : ℕ),
    (∀ (m : ℕ), m < n → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m) →
      ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

tactic: intro n h
state_before: n b : ℕ
⊢ ∀ (n : ℕ),
    (∀ (m : ℕ), m < n → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m) →
      ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

tactic: cases n
state_before: n✝ b n : ℕ
h : ∀ (m : ℕ), m < n → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

tactic: rw [digits_zero]
state_before: case zero
n b : ℕ
h : ∀ (m : ℕ), m < zero → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (succ (succ b)) (digits (succ (succ b)) zero) = zero

tactic: rfl
state_before: case zero
n b : ℕ
h : ∀ (m : ℕ), m < zero → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (succ (succ b)) [] = zero

tactic: simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
state_before: case succ
n b n✝ : ℕ
h : ∀ (m : ℕ), m < succ n✝ → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (succ (succ b)) (digits (succ (succ b)) (succ n✝)) = succ n✝

tactic: dsimp [ofDigits]
state_before: case succ
n b n✝ : ℕ
h : ∀ (m : ℕ), m < succ n✝ → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (b + 1 + 1) ((n✝ + 1) % (b + 2) :: digits (b + 2) ((n✝ + 1) / (b + 2))) = n✝ + 1

tactic: rw [h _ (Nat.div_lt_self' _ b)]
state_before: case succ
n b n✝ : ℕ
h : ∀ (m : ℕ), m < succ n✝ → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ (n✝ + 1) % (b + 2) + (b + 1 + 1) * ofDigits (b + 1 + 1) (digits (b + 2) ((n✝ + 1) / (b + 2))) = n✝ + 1

tactic: rw [Nat.mod_add_div]
state_before: case succ
n b n✝ : ℕ
h : ∀ (m : ℕ), m < succ n✝ → ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ (n✝ + 1) % (b + 2) + (b + 1 + 1) * ((n✝ + 1) / (b + 2)) = n✝ + 1