l3lab/ntp-mathlib huggingface dataset:
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]
  by_cases h : n / b = 0
  · 

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

Next tactic:
have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
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]
  by_cases h : n / b = 0
  · have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
    

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

Next tactic:
simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
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]
  by_cases h : n / b = 0
  · have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
    simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
  · 

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

Next tactic:
have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
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]
  by_cases h : n / b = 0
  · have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
    simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
  · have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
    

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

Next tactic:
rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
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]
  by_cases h : n / b = 0
  · have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
    simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
  · have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
    rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
    

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

Next tactic:
refine' Nat.succ_le_of_lt (log_pos hb _)
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]
  by_cases h : n / b = 0
  · have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
    simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
  · have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
    rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
    refine' Nat.succ_le_of_lt (log_pos hb _)
    

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

Next tactic:
contrapose! h
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]
  by_cases h : n / b = 0
  · have hb0 : b ≠ 0 := (Nat.succ_le_iff.1 hb).ne_bot
    simp [h, log_eq_zero_iff, ← Nat.div_eq_zero_iff hb0.bot_lt]
  · have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb
    rw [IH _ this h, log_div_base, tsub_add_cancel_of_le]
    refine' Nat.succ_le_of_lt (log_pos hb _)
    contrapose! h
    

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

Next tactic:
exact div_eq_of_lt h
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  

Proof state:
n b m : ℕ
hm : m ≠ 0
⊢ List.getLast (digits b m) (_ : digits b m ≠ []) ≠ 0

Next tactic:
rcases b with (_ | _ | b)
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · 

Proof state:
case zero
n m : ℕ
hm : m ≠ 0
⊢ List.getLast (digits zero m) (_ : digits zero m ≠ []) ≠ 0

Next tactic:
cases m
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · 

Proof state:
case zero.zero
n : ℕ
hm : zero ≠ 0
⊢ List.getLast (digits zero zero) (_ : digits zero zero ≠ []) ≠ 0

Next tactic:
cases hm rfl
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · 

Proof state:
case zero.succ
n n✝ : ℕ
hm : succ n✝ ≠ 0
⊢ List.getLast (digits zero (succ n✝)) (_ : digits zero (succ n✝) ≠ []) ≠ 0

Next tactic:
simp
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · 

Proof state:
case succ.zero
n m : ℕ
hm : m ≠ 0
⊢ List.getLast (digits (succ zero) m) (_ : digits (succ zero) m ≠ []) ≠ 0

Next tactic:
cases m
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · 

Proof state:
case succ.zero.zero
n : ℕ
hm : zero ≠ 0
⊢ List.getLast (digits (succ zero) zero) (_ : digits (succ zero) zero ≠ []) ≠ 0

Next tactic:
cases hm rfl
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    

Proof state:
case succ.zero.succ
n n✝ : ℕ
hm : succ n✝ ≠ 0
⊢ List.getLast (digits (succ zero) (succ n✝)) (_ : digits (succ zero) (succ n✝) ≠ []) ≠ 0

Next tactic:
rename ℕ => m
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    

Proof state:
case succ.zero.succ
n m : ℕ
hm : succ m ≠ 0
⊢ List.getLast (digits (succ zero) (succ m)) (_ : digits (succ zero) (succ m) ≠ []) ≠ 0

Next tactic:
simp only [digits_one, List.getLast_replicate_succ m 1]
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    

Proof state:
case succ.zero.succ
n m : ℕ
hm : succ m ≠ 0
⊢ 1 ≠ 0

Next tactic:
exact Nat.one_ne_zero
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  

Proof state:
case succ.succ
n m : ℕ
hm : m ≠ 0
b : ℕ
⊢ List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0

Next tactic:
revert hm
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  

Proof state:
case succ.succ
n m b : ℕ
⊢ ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0

Next tactic:
apply Nat.strongInductionOn m
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  apply Nat.strongInductionOn m
  

Proof state:
case succ.succ
n m b : ℕ
⊢ ∀ (n : ℕ),
    (∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0) →
      ∀ (hm : n ≠ 0), List.getLast (digits (succ (succ b)) n) (_ : digits (succ (succ b)) n ≠ []) ≠ 0

Next tactic:
intro n IH hn
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  apply Nat.strongInductionOn m
  intro n IH hn
  

Proof state:
case succ.succ
n✝ m b n : ℕ
IH : ∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0
hn : n ≠ 0
⊢ List.getLast (digits (succ (succ b)) n) (_ : digits (succ (succ b)) n ≠ []) ≠ 0

Next tactic:
by_cases hnb : n < b + 2
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  apply Nat.strongInductionOn m
  intro n IH hn
  by_cases hnb : n < b + 2
  · 

Proof state:
case pos
n✝ m b n : ℕ
IH : ∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0
hn : n ≠ 0
hnb : n < b + 2
⊢ List.getLast (digits (succ (succ b)) n) (_ : digits (succ (succ b)) n ≠ []) ≠ 0

Next tactic:
simpa only [digits_of_lt (b + 2) n hn hnb]
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  apply Nat.strongInductionOn m
  intro n IH hn
  by_cases hnb : n < b + 2
  · simpa only [digits_of_lt (b + 2) n hn hnb]
  · 

Proof state:
case neg
n✝ m b n : ℕ
IH : ∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0
hn : n ≠ 0
hnb : ¬n < b + 2
⊢ List.getLast (digits (succ (succ b)) n) (_ : digits (succ (succ b)) n ≠ []) ≠ 0

Next tactic:
rw [digits_getLast n (le_add_left 2 b)]
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  apply Nat.strongInductionOn m
  intro n IH hn
  by_cases hnb : n < b + 2
  · simpa only [digits_of_lt (b + 2) n hn hnb]
  · rw [digits_getLast n (le_add_left 2 b)]
    

Proof state:
case neg
n✝ m b n : ℕ
IH : ∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0
hn : n ≠ 0
hnb : ¬n < b + 2
⊢ List.getLast (digits (b + 2) (n / (b + 2))) ?neg.q✝ ≠ 0
case neg.q
n✝ m b n : ℕ
IH : ∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0
hn : n ≠ 0
hnb : ¬n < b + 2
⊢ digits (b + 2) (n / (b + 2)) ≠ []

Next tactic:
refine' IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) _
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  apply Nat.strongInductionOn m
  intro n IH hn
  by_cases hnb : n < b + 2
  · simpa only [digits_of_lt (b + 2) n hn hnb]
  · rw [digits_getLast n (le_add_left 2 b)]
    refine' IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) _
    · 

Proof state:
case neg
n✝ m b n : ℕ
IH : ∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0
hn : n ≠ 0
hnb : ¬n < b + 2
⊢ n / succ (succ b) ≠ 0

Next tactic:
rw [← pos_iff_ne_zero]
theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by
  rcases b with (_ | _ | b)
  · cases m
    · cases hm rfl
    · simp
  · cases m
    · cases hm rfl
    rename ℕ => m
    simp only [digits_one, List.getLast_replicate_succ m 1]
    exact Nat.one_ne_zero
  revert hm
  apply Nat.strongInductionOn m
  intro n IH hn
  by_cases hnb : n < b + 2
  · simpa only [digits_of_lt (b + 2) n hn hnb]
  · rw [digits_getLast n (le_add_left 2 b)]
    refine' IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) _
    · rw [← pos_iff_ne_zero]
      

Proof state:
case neg
n✝ m b n : ℕ
IH : ∀ m < n, ∀ (hm : m ≠ 0), List.getLast (digits (succ (succ b)) m) (_ : digits (succ (succ b)) m ≠ []) ≠ 0
hn : n ≠ 0
hnb : ¬n < b + 2
⊢ 0 < n / succ (succ b)

Next tactic:
exact Nat.div_pos (le_of_not_lt hnb) (zero_lt_succ (succ b))
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  

Proof state:
n b m : ℕ
⊢ ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2

Next tactic:
apply Nat.strongInductionOn m
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  

Proof state:
n b m : ℕ
⊢ ∀ (n : ℕ), (∀ m < n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2) → ∀ {d : ℕ}, d ∈ digits (b + 2) n → d < b + 2

Next tactic:
intro n IH d hd
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  

Proof state:
n✝ b m n : ℕ
IH : ∀ m < n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
d : ℕ
hd : d ∈ digits (b + 2) n
⊢ d < b + 2

Next tactic:
cases' n with n
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · 

Proof state:
case zero
n b m d : ℕ
IH : ∀ m < zero, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
hd : d ∈ digits (b + 2) zero
⊢ d < b + 2

Next tactic:
rw [digits_zero] at hd
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    

Proof state:
case zero
n b m d : ℕ
IH : ∀ m < zero, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
hd : d ∈ []
⊢ d < b + 2

Next tactic:
cases hd
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  

Proof state:
case succ
n✝ b m d n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
hd : d ∈ digits (b + 2) (succ n)
⊢ d < b + 2

Next tactic:
rw [digits_add_two_add_one] at hd
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  

Proof state:
case succ
n✝ b m d n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
hd : d ∈ (n + 1) % (b + 2) :: digits (b + 2) ((n + 1) / (b + 2))
⊢ d < b + 2

Next tactic:
cases hd
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  cases hd
  · 

Proof state:
case succ.head
n✝ b m n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
⊢ (n + 1) % (b + 2) < b + 2

Next tactic:
exact n.succ.mod_lt (by simp)
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  cases hd
  · exact n.succ.mod_lt (by 

Proof state:
n✝ b m n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
⊢ b + 2 > 0

Next tactic:
simp
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  cases hd
  · exact n.succ.mod_lt (by simp)
  -- Porting note: Previous code (single line) contained linarith.
  -- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
  · 

Proof state:
case succ.tail
n✝ b m d n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
a✝ : List.Mem d (digits (b + 2) ((n + 1) / (b + 2)))
⊢ d < b + 2

Next tactic:
apply IH ((n + 1) / (b + 2))
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  cases hd
  · exact n.succ.mod_lt (by simp)
  -- Porting note: Previous code (single line) contained linarith.
  -- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
  · apply IH ((n + 1) / (b + 2))
    · 

Proof state:
case succ.tail.a
n✝ b m d n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
a✝ : List.Mem d (digits (b + 2) ((n + 1) / (b + 2)))
⊢ (n + 1) / (b + 2) < succ n

Next tactic:
apply Nat.div_lt_self
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  cases hd
  · exact n.succ.mod_lt (by simp)
  -- Porting note: Previous code (single line) contained linarith.
  -- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
  · apply IH ((n + 1) / (b + 2))
    · apply Nat.div_lt_self <;> 

Proof state:
case succ.tail.a.hLtN
n✝ b m d n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
a✝ : List.Mem d (digits (b + 2) ((n + 1) / (b + 2)))
⊢ 0 < n + 1

Next tactic:
simp
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  cases hd
  · exact n.succ.mod_lt (by simp)
  -- Porting note: Previous code (single line) contained linarith.
  -- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
  · apply IH ((n + 1) / (b + 2))
    · apply Nat.div_lt_self <;> 

Proof state:
case succ.tail.a.hLtK
n✝ b m d n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
a✝ : List.Mem d (digits (b + 2) ((n + 1) / (b + 2)))
⊢ 1 < b + 2

Next tactic:
simp
/-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 := by
  apply Nat.strongInductionOn m
  intro n IH d hd
  cases' n with n
  · rw [digits_zero] at hd
    cases hd
  -- base b+2 expansion of 0 has no digits
  rw [digits_add_two_add_one] at hd
  cases hd
  · exact n.succ.mod_lt (by simp)
  -- Porting note: Previous code (single line) contained linarith.
  -- . exact IH _ (Nat.div_lt_self (Nat.succ_pos _) (by linarith)) hd
  · apply IH ((n + 1) / (b + 2))
    · apply Nat.div_lt_self <;> simp
    · 

Proof state:
case succ.tail.a
n✝ b m d n : ℕ
IH : ∀ m < succ n, ∀ {d : ℕ}, d ∈ digits (b + 2) m → d < b + 2
a✝ : List.Mem d (digits (b + 2) ((n + 1) / (b + 2)))
⊢ d ∈ digits (b + 2) ((n + 1) / (b + 2))

Next tactic:
assumption
/-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
  

Proof state:
n b m d : ℕ
hb : 1 < b
hd : d ∈ digits b m
⊢ d < b

Next tactic:
rcases b with (_ | _ | b)
/-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
  rcases b with (_ | _ | b) <;> 

Proof state:
case zero
n m d : ℕ
hb : 1 < zero
hd : d ∈ digits zero m
⊢ d < zero

Next tactic:
try simp_all
/-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
  rcases b with (_ | _ | b) <;> try 

Proof state:
case zero
n m d : ℕ
hb : 1 < zero
hd : d ∈ digits zero m
⊢ d < zero

Next tactic:
simp_all
/-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
  rcases b with (_ | _ | b) <;> 

Proof state:
case succ.zero
n m d : ℕ
hb : 1 < succ zero
hd : d ∈ digits (succ zero) m
⊢ d < succ zero

Next tactic:
try simp_all
/-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
  rcases b with (_ | _ | b) <;> try 

Proof state:
case succ.zero
n m d : ℕ
hb : 1 < succ zero
hd : d ∈ digits (succ zero) m
⊢ d < succ zero

Next tactic:
simp_all
/-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
  rcases b with (_ | _ | b) <;> 

Proof state:
case succ.succ
n m d b : ℕ
hb : 1 < succ (succ b)
hd : d ∈ digits (succ (succ b)) m
⊢ d < succ (succ b)

Next tactic:
try simp_all
/-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b := by
  rcases b with (_ | _ | b) <;> try 

Proof state:
case succ.succ
n m d b : ℕ
hb : 1 < succ (succ b)
hd : d ∈ digits (succ (succ b)) m
⊢ d < succ (succ b)

Next tactic:
simp_all