l3lab/ntp-mathlib huggingface dataset:
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
    (w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
  induction' L with d L ih
  · dsimp [ofDigits]
    simp
  · dsimp [ofDigits]
    replace w₂ := w₂ (by simp)
    rw [digits_add b h]
    · rw [ih]
      · intro l m
        apply w₁
        exact List.mem_cons_of_mem _ m
      · intro h
        · rw [List.getLast_cons h] at w₂
          convert w₂
    · exact w₁ d (List.mem_cons_self _ _)
    · by_cases h' : L = []
      · rcases h' with rfl
        left
        

Proof state:
case pos.h
n b : ℕ
h : 1 < b
d : ℕ
ih : (∀ l ∈ [], l < b) → (∀ (h : [] ≠ []), List.getLast [] h ≠ 0) → digits b (ofDigits b []) = []
w₁ : ∀ l ∈ [d], l < b
w₂ : List.getLast [d] (_ : ¬[d] = []) ≠ 0
⊢ d ≠ 0

Next tactic:
simpa using w₂
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
    (w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
  induction' L with d L ih
  · dsimp [ofDigits]
    simp
  · dsimp [ofDigits]
    replace w₂ := w₂ (by simp)
    rw [digits_add b h]
    · rw [ih]
      · intro l m
        apply w₁
        exact List.mem_cons_of_mem _ m
      · intro h
        · rw [List.getLast_cons h] at w₂
          convert w₂
    · exact w₁ d (List.mem_cons_self _ _)
    · by_cases h' : L = []
      · rcases h' with rfl
        left
        simpa using w₂
      · 

Proof state:
case neg
n b : ℕ
h : 1 < b
d : ℕ
L : List ℕ
ih : (∀ l ∈ L, l < b) → (∀ (h : L ≠ []), List.getLast L h ≠ 0) → digits b (ofDigits b L) = L
w₁ : ∀ l ∈ d :: L, l < b
w₂ : List.getLast (d :: L) (_ : ¬d :: L = []) ≠ 0
h' : ¬L = []
⊢ d ≠ 0 ∨ ofDigits b L ≠ 0

Next tactic:
right
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
    (w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
  induction' L with d L ih
  · dsimp [ofDigits]
    simp
  · dsimp [ofDigits]
    replace w₂ := w₂ (by simp)
    rw [digits_add b h]
    · rw [ih]
      · intro l m
        apply w₁
        exact List.mem_cons_of_mem _ m
      · intro h
        · rw [List.getLast_cons h] at w₂
          convert w₂
    · exact w₁ d (List.mem_cons_self _ _)
    · by_cases h' : L = []
      · rcases h' with rfl
        left
        simpa using w₂
      · right
        

Proof state:
case neg.h
n b : ℕ
h : 1 < b
d : ℕ
L : List ℕ
ih : (∀ l ∈ L, l < b) → (∀ (h : L ≠ []), List.getLast L h ≠ 0) → digits b (ofDigits b L) = L
w₁ : ∀ l ∈ d :: L, l < b
w₂ : List.getLast (d :: L) (_ : ¬d :: L = []) ≠ 0
h' : ¬L = []
⊢ ofDigits b L ≠ 0

Next tactic:
contrapose! w₂
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
    (w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
  induction' L with d L ih
  · dsimp [ofDigits]
    simp
  · dsimp [ofDigits]
    replace w₂ := w₂ (by simp)
    rw [digits_add b h]
    · rw [ih]
      · intro l m
        apply w₁
        exact List.mem_cons_of_mem _ m
      · intro h
        · rw [List.getLast_cons h] at w₂
          convert w₂
    · exact w₁ d (List.mem_cons_self _ _)
    · by_cases h' : L = []
      · rcases h' with rfl
        left
        simpa using w₂
      · right
        contrapose! w₂
        

Proof state:
case neg.h
n b : ℕ
h : 1 < b
d : ℕ
L : List ℕ
ih : (∀ l ∈ L, l < b) → (∀ (h : L ≠ []), List.getLast L h ≠ 0) → digits b (ofDigits b L) = L
w₁ : ∀ l ∈ d :: L, l < b
h' : ¬L = []
w₂ : ofDigits b L = 0
⊢ List.getLast (d :: L) (_ : ¬d :: L = []) = 0

Next tactic:
refine' digits_zero_of_eq_zero h.ne_bot w₂ _ _
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
    (w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
  induction' L with d L ih
  · dsimp [ofDigits]
    simp
  · dsimp [ofDigits]
    replace w₂ := w₂ (by simp)
    rw [digits_add b h]
    · rw [ih]
      · intro l m
        apply w₁
        exact List.mem_cons_of_mem _ m
      · intro h
        · rw [List.getLast_cons h] at w₂
          convert w₂
    · exact w₁ d (List.mem_cons_self _ _)
    · by_cases h' : L = []
      · rcases h' with rfl
        left
        simpa using w₂
      · right
        contrapose! w₂
        refine' digits_zero_of_eq_zero h.ne_bot w₂ _ _
        

Proof state:
case neg.h
n b : ℕ
h : 1 < b
d : ℕ
L : List ℕ
ih : (∀ l ∈ L, l < b) → (∀ (h : L ≠ []), List.getLast L h ≠ 0) → digits b (ofDigits b L) = L
w₁ : ∀ l ∈ d :: L, l < b
h' : ¬L = []
w₂ : ofDigits b L = 0
⊢ List.getLast (d :: L) (_ : ¬d :: L = []) ∈ L

Next tactic:
rw [List.getLast_cons h']
theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
    (w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L := by
  induction' L with d L ih
  · dsimp [ofDigits]
    simp
  · dsimp [ofDigits]
    replace w₂ := w₂ (by simp)
    rw [digits_add b h]
    · rw [ih]
      · intro l m
        apply w₁
        exact List.mem_cons_of_mem _ m
      · intro h
        · rw [List.getLast_cons h] at w₂
          convert w₂
    · exact w₁ d (List.mem_cons_self _ _)
    · by_cases h' : L = []
      · rcases h' with rfl
        left
        simpa using w₂
      · right
        contrapose! w₂
        refine' digits_zero_of_eq_zero h.ne_bot w₂ _ _
        rw [List.getLast_cons h']
        

Proof state:
case neg.h
n b : ℕ
h : 1 < b
d : ℕ
L : List ℕ
ih : (∀ l ∈ L, l < b) → (∀ (h : L ≠ []), List.getLast L h ≠ 0) → digits b (ofDigits b L) = L
w₁ : ∀ l ∈ d :: L, l < b
h' : ¬L = []
w₂ : ofDigits b L = 0
⊢ List.getLast L h' ∈ L

Next tactic:
exact List.getLast_mem h'
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  

Proof state:
n✝ b n : ℕ
⊢ ofDigits b (digits b n) = n

Next tactic:
cases' b with b
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · 

Proof state:
case zero
n✝ n : ℕ
⊢ ofDigits zero (digits zero n) = n

Next tactic:
cases' n with n
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · 

Proof state:
case zero.zero
n : ℕ
⊢ ofDigits zero (digits zero zero) = zero

Next tactic:
rfl
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · 

Proof state:
case zero.succ
n✝ n : ℕ
⊢ ofDigits zero (digits zero (succ n)) = succ n

Next tactic:
change ofDigits 0 [n + 1] = n + 1
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      

Proof state:
case zero.succ
n✝ n : ℕ
⊢ ofDigits 0 [n + 1] = n + 1

Next tactic:
dsimp [ofDigits]
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · 

Proof state:
case succ
n✝ n b : ℕ
⊢ ofDigits (succ b) (digits (succ b) n) = n

Next tactic:
cases' b with b
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · 

Proof state:
case succ.zero
n✝ n : ℕ
⊢ ofDigits (succ zero) (digits (succ zero) n) = n

Next tactic:
induction' n with n ih
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · 

Proof state:
case succ.zero.zero
n : ℕ
⊢ ofDigits (succ zero) (digits (succ zero) zero) = zero

Next tactic:
rfl
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · 

Proof state:
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

Next tactic:
rw[show succ zero = 1 by rfl] at ih ⊢
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by 

Proof state:
n✝ n : ℕ
ih : ofDigits (succ zero) (digits (succ zero) n) = n
⊢ succ zero = 1

Next tactic:
rfl
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by 

Proof state:
n✝ n : ℕ
ih : ofDigits 1 (digits 1 n) = n
⊢ succ zero = 1

Next tactic:
rfl
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        

Proof state:
case succ.zero.succ
n✝ n : ℕ
ih : ofDigits 1 (digits 1 n) = n
⊢ ofDigits 1 (digits 1 (succ n)) = succ n

Next tactic:
simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · 

Proof state:
case succ.succ
n✝ n b : ℕ
⊢ ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

Next tactic:
apply Nat.strongInductionOn n _
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      

Proof state:
n✝ n b : ℕ
⊢ ∀ (n : ℕ),
    (∀ m < n, ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m) →
      ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

Next tactic:
clear n
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      

Proof state:
n b : ℕ
⊢ ∀ (n : ℕ),
    (∀ m < n, ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m) →
      ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

Next tactic:
intro n h
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      intro n h
      

Proof state:
n✝ b n : ℕ
h : ∀ m < n, ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (succ (succ b)) (digits (succ (succ b)) n) = n

Next tactic:
cases n
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      intro n h
      cases n
      · 

Proof state:
case zero
n b : ℕ
h : ∀ m < zero, ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (succ (succ b)) (digits (succ (succ b)) zero) = zero

Next tactic:
rw [digits_zero]
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      intro n h
      cases n
      · rw [digits_zero]
        

Proof state:
case zero
n b : ℕ
h : ∀ m < zero, ofDigits (succ (succ b)) (digits (succ (succ b)) m) = m
⊢ ofDigits (succ (succ b)) [] = zero

Next tactic:
rfl
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      intro n h
      cases n
      · rw [digits_zero]
        rfl
      · 

Proof state:
case succ
n b n✝ : ℕ
h : ∀ 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✝

Next tactic:
simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      intro n h
      cases n
      · rw [digits_zero]
        rfl
      · simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
        

Proof state:
case succ
n b n✝ : ℕ
h : ∀ 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

Next tactic:
dsimp [ofDigits]
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      intro n h
      cases n
      · rw [digits_zero]
        rfl
      · simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
        dsimp [ofDigits]
        

Proof state:
case succ
n b n✝ : ℕ
h : ∀ 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

Next tactic:
rw [h _ (Nat.div_lt_self' _ b)]
theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n := by
  cases' b with b
  · cases' n with n
    · rfl
    · change ofDigits 0 [n + 1] = n + 1
      dsimp [ofDigits]
  · cases' b with b
    · induction' n with n ih
      · rfl
      · rw[show succ zero = 1 by rfl] at ih ⊢
        simp only [ih, add_comm 1, ofDigits_one_cons, Nat.cast_id, digits_one_succ]
    · apply Nat.strongInductionOn n _
      clear n
      intro n h
      cases n
      · rw [digits_zero]
        rfl
      · simp only [Nat.succ_eq_add_one, digits_add_two_add_one]
        dsimp [ofDigits]
        rw [h _ (Nat.div_lt_self' _ b)]
        

Proof state:
case succ
n b n✝ : ℕ
h : ∀ 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

Next tactic:
rw [Nat.mod_add_div]
theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum := by
  

Proof state:
n : ℕ
L : List ℕ
⊢ ofDigits 1 L = List.sum L

Next tactic:
induction' L with _ _ ih
theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum := by
  induction' L with _ _ ih
  · 

Proof state:
case nil
n : ℕ
⊢ ofDigits 1 [] = List.sum []

Next tactic:
rfl
theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum := by
  induction' L with _ _ ih
  · rfl
  · 

Proof state:
case cons
n head✝ : ℕ
tail✝ : List ℕ
ih : ofDigits 1 tail✝ = List.sum tail✝
⊢ ofDigits 1 (head✝ :: tail✝) = List.sum (head✝ :: tail✝)

Next tactic:
simp [ofDigits, List.sum_cons, ih]
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  

Proof state:
n✝ b n : ℕ
⊢ digits b n = [] ↔ n = 0

Next tactic:
constructor
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  constructor
  · 

Proof state:
case mp
n✝ b n : ℕ
⊢ digits b n = [] → n = 0

Next tactic:
intro h
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  constructor
  · intro h
    

Proof state:
case mp
n✝ b n : ℕ
h : digits b n = []
⊢ n = 0

Next tactic:
have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  constructor
  · intro h
    have : ofDigits b (digits b n) = ofDigits b [] := by 

Proof state:
n✝ b n : ℕ
h : digits b n = []
⊢ ofDigits b (digits b n) = ofDigits b []

Next tactic:
rw [h]
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  constructor
  · intro h
    have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
    

Proof state:
case mp
n✝ b n : ℕ
h : digits b n = []
this : ofDigits b (digits b n) = ofDigits b []
⊢ n = 0

Next tactic:
convert this
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  constructor
  · intro h
    have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
    convert this
    

Proof state:
case h.e'_2
n✝ b n : ℕ
h : digits b n = []
this : ofDigits b (digits b n) = ofDigits b []
⊢ n = ofDigits b (digits b n)

Next tactic:
rw [ofDigits_digits]
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  constructor
  · intro h
    have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
    convert this
    rw [ofDigits_digits]
  · 

Proof state:
case mpr
n✝ b n : ℕ
⊢ n = 0 → digits b n = []

Next tactic:
rintro rfl
theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by
  constructor
  · intro h
    have : ofDigits b (digits b n) = ofDigits b [] := by rw [h]
    convert this
    rw [ofDigits_digits]
  · rintro rfl
    

Proof state:
case mpr
n b : ℕ
⊢ digits b 0 = []

Next tactic:
simp
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
    digits b n = (n % b) :: digits b (n / b) := by
  

Proof state:
n✝ b n : ℕ
h : 1 < b
w : n ≠ 0
⊢ digits b n = n % b :: digits b (n / b)

Next tactic:
rcases b with (_ | _ | b)
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
    digits b n = (n % b) :: digits b (n / b) := by
  rcases b with (_ | _ | b)
  · 

Proof state:
case zero
n✝ n : ℕ
w : n ≠ 0
h : 1 < zero
⊢ digits zero n = n % zero :: digits zero (n / zero)

Next tactic:
rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
    digits b n = (n % b) :: digits b (n / b) := by
  rcases b with (_ | _ | b)
  · rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
  · 

Proof state:
case succ.zero
n✝ n : ℕ
w : n ≠ 0
h : 1 < succ zero
⊢ digits (succ zero) n = n % succ zero :: digits (succ zero) (n / succ zero)

Next tactic:
norm_num at h
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
    digits b n = (n % b) :: digits b (n / b) := by
  rcases b with (_ | _ | b)
  · rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
  · norm_num at h
  

Proof state:
case succ.succ
n✝ n : ℕ
w : n ≠ 0
b : ℕ
h : 1 < succ (succ b)
⊢ digits (succ (succ b)) n = n % succ (succ b) :: digits (succ (succ b)) (n / succ (succ b))

Next tactic:
rcases n with (_ | n)
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
    digits b n = (n % b) :: digits b (n / b) := by
  rcases b with (_ | _ | b)
  · rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
  · norm_num at h
  rcases n with (_ | n)
  · 

Proof state:
case succ.succ.zero
n b : ℕ
h : 1 < succ (succ b)
w : zero ≠ 0
⊢ digits (succ (succ b)) zero = zero % succ (succ b) :: digits (succ (succ b)) (zero / succ (succ b))

Next tactic:
norm_num at w
theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
    digits b n = (n % b) :: digits b (n / b) := by
  rcases b with (_ | _ | b)
  · rw [digits_zero_succ' w, Nat.mod_zero, Nat.div_zero, Nat.digits_zero_zero]
  · norm_num at h
  rcases n with (_ | n)
  · norm_num at w
  · 

Proof state:
case succ.succ.succ
n✝ b : ℕ
h : 1 < succ (succ b)
n : ℕ
w : succ n ≠ 0
⊢ digits (succ (succ b)) (succ n) = succ n % succ (succ b) :: digits (succ (succ b)) (succ n / succ (succ b))

Next tactic:
simp only [digits_add_two_add_one, ne_eq]
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
    (digits b m).getLast p = (digits b (m / b)).getLast q := by
  

Proof state:
n b m : ℕ
h : 1 < b
p : digits b m ≠ []
q : digits b (m / b) ≠ []
⊢ List.getLast (digits b m) p = List.getLast (digits b (m / b)) q

Next tactic:
by_cases hm : m = 0
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
    (digits b m).getLast p = (digits b (m / b)).getLast q := by
  by_cases hm : m = 0
  · 

Proof state:
case pos
n b m : ℕ
h : 1 < b
p : digits b m ≠ []
q : digits b (m / b) ≠ []
hm : m = 0
⊢ List.getLast (digits b m) p = List.getLast (digits b (m / b)) q

Next tactic:
simp [hm]
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
    (digits b m).getLast p = (digits b (m / b)).getLast q := by
  by_cases hm : m = 0
  · simp [hm]
  

Proof state:
case neg
n b m : ℕ
h : 1 < b
p : digits b m ≠ []
q : digits b (m / b) ≠ []
hm : ¬m = 0
⊢ List.getLast (digits b m) p = List.getLast (digits b (m / b)) q

Next tactic:
simp only [digits_eq_cons_digits_div h hm]
theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
    (digits b m).getLast p = (digits b (m / b)).getLast q := by
  by_cases hm : m = 0
  · simp [hm]
  simp only [digits_eq_cons_digits_div h hm]
  

Proof state:
case neg
n b m : ℕ
h : 1 < b
p : digits b m ≠ []
q : digits b (m / b) ≠ []
hm : ¬m = 0
⊢ List.getLast (m % b :: digits b (m / b)) (_ : m % b :: digits b (m / b) ≠ []) = List.getLast (digits b (m / b)) q

Next tactic:
rw [List.getLast_cons]
theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by
  

Proof state:
n✝ b n : ℕ
hb : 1 < b
hn : n ≠ 0
⊢ List.length (digits b n) = log b n + 1

Next tactic:
induction' n using Nat.strong_induction_on with n IH
theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by
  induction' n using Nat.strong_induction_on with n IH
  

Proof state:
case h
n✝ b : ℕ
hb : 1 < b
n : ℕ
IH : ∀ m < n, m ≠ 0 → List.length (digits b m) = log b m + 1
hn : n ≠ 0
⊢ List.length (digits b n) = log b n + 1

Next tactic:
rw [digits_eq_cons_digits_div hb hn, List.length]
theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by
  induction' n using Nat.strong_induction_on with n IH
  rw [digits_eq_cons_digits_div hb hn, List.length]
  

Proof state:
case h
n✝ b : ℕ
hb : 1 < b
n : ℕ
IH : ∀ m < n, m ≠ 0 → List.length (digits b m) = log b m + 1
hn : n ≠ 0
⊢ List.length (digits b (n / b)) + 1 = log b n + 1

Next tactic:
by_cases h : n / b = 0