l3lab/ntp-mathlib huggingface dataset:
theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
    digits b (x + b * y) = x :: digits b y := by
  rcases exists_eq_add_of_le' h with ⟨b, rfl : _ = _ + 2⟩
  cases y
  · simp [hxb, hxy.resolve_right (absurd rfl)]
  dsimp [digits]
  rw [digitsAux_def]
  · congr
    · simp [Nat.add_mod, mod_eq_of_lt hxb]
    · simp [add_mul_div_left, div_eq_of_lt hxb]
  · 

Proof state:
case intro.succ.w
n x b : ℕ
h : 1 < b + 2
hxb : x < b + 2
n✝ : ℕ
hxy : x ≠ 0 ∨ succ n✝ ≠ 0
⊢ 0 < x + (b + 2) * succ n✝

Next tactic:
apply Nat.succ_pos
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
    ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
  

Proof state:
n : ℕ
α : Type u_1
inst✝ : Semiring α
b : α
L : List ℕ
⊢ ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L

Next tactic:
induction' L with d L ih
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
    ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
  induction' L with d L ih
  · 

Proof state:
case nil
n : ℕ
α : Type u_1
inst✝ : Semiring α
b : α
⊢ ofDigits b [] = List.foldr (fun x y => ↑x + b * y) 0 []

Next tactic:
rfl
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
    ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
  induction' L with d L ih
  · rfl
  · 

Proof state:
case cons
n : ℕ
α : Type u_1
inst✝ : Semiring α
b : α
d : ℕ
L : List ℕ
ih : ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L
⊢ ofDigits b (d :: L) = List.foldr (fun x y => ↑x + b * y) 0 (d :: L)

Next tactic:
dsimp [ofDigits]
theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
    ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    

Proof state:
case cons
n : ℕ
α : Type u_1
inst✝ : Semiring α
b : α
d : ℕ
L : List ℕ
ih : ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L
⊢ ↑d + b * ofDigits b L = ↑d + b * List.foldr (fun x y => ↑x + b * y) 0 L

Next tactic:
rw [ih]
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
    ((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
      b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
  

Proof state:
n b : ℕ
l : List ℕ
⊢ List.sum (List.zipWith (fun i a => a * b ^ (i + 1)) (List.range (List.length l)) l) =
    b * List.sum (List.zipWith (fun i a => a * b ^ i) (List.range (List.length l)) l)

Next tactic:
suffices
    (List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
      (List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
    by simp [this]
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
    ((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
      b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
  suffices
    (List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
      (List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
    by 

Proof state:
n b : ℕ
l : List ℕ
this :
  List.zipWith (fun i a => a * b ^ (i + 1)) (List.range (List.length l)) l =
    List.zipWith (fun i a => b * (a * b ^ i)) (List.range (List.length l)) l
⊢ List.sum (List.zipWith (fun i a => a * b ^ (i + 1)) (List.range (List.length l)) l) =
    b * List.sum (List.zipWith (fun i a => a * b ^ i) (List.range (List.length l)) l)

Next tactic:
simp [this]
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
    ((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
      b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
  suffices
    (List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
      (List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
    by simp [this]
  

Proof state:
n b : ℕ
l : List ℕ
⊢ List.zipWith (fun i a => a * b ^ (i + 1)) (List.range (List.length l)) l =
    List.zipWith (fun i a => b * (a * b ^ i)) (List.range (List.length l)) l

Next tactic:
congr
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
    ((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
      b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
  suffices
    (List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
      (List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
    by simp [this]
  congr; 

Proof state:
case e_f
n b : ℕ
l : List ℕ
⊢ (fun i a => a * b ^ (i + 1)) = fun i a => b * (a * b ^ i)

Next tactic:
ext
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
    ((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
      b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
  suffices
    (List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
      (List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
    by simp [this]
  congr; ext; 

Proof state:
case e_f.h.h
n b : ℕ
l : List ℕ
x✝¹ x✝ : ℕ
⊢ x✝ * b ^ (x✝¹ + 1) = b * (x✝ * b ^ x✝¹)

Next tactic:
simp [pow_succ]
theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
    ((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
      b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum := by
  suffices
    (List.range l.length).zipWith (fun i a : ℕ => a * b ^ (i + 1)) l =
      (List.range l.length).zipWith (fun i a => b * (a * b ^ i)) l
    by simp [this]
  congr; ext; simp [pow_succ]; 

Proof state:
case e_f.h.h
n b : ℕ
l : List ℕ
x✝¹ x✝ : ℕ
⊢ x✝ * (b ^ x✝¹ * b) = b * (x✝ * b ^ x✝¹)

Next tactic:
ring
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
    ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
  

Proof state:
n b : ℕ
L : List ℕ
⊢ ofDigits b L = List.sum (List.mapIdx (fun i a => a * b ^ i) L)

Next tactic:
rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
    ofDigits_eq_foldr]
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
    ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
  rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
    ofDigits_eq_foldr]
  

Proof state:
n b : ℕ
L : List ℕ
⊢ List.foldr (fun x y => ↑x + b * y) 0 L = List.sum (List.zipWith (fun i a => a * b ^ i) (List.range (List.length L)) L)

Next tactic:
induction' L with hd tl hl
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
    ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
  rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
    ofDigits_eq_foldr]
  induction' L with hd tl hl
  · 

Proof state:
case nil
n b : ℕ
⊢ List.foldr (fun x y => ↑x + b * y) 0 [] =
    List.sum (List.zipWith (fun i a => a * b ^ i) (List.range (List.length [])) [])

Next tactic:
simp
theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
    ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by
  rw [List.mapIdx_eq_enum_map, List.enum_eq_zip_range, List.map_uncurry_zip_eq_zipWith,
    ofDigits_eq_foldr]
  induction' L with hd tl hl
  · simp
  · 

Proof state:
case cons
n b hd : ℕ
tl : List ℕ
hl :
  List.foldr (fun x y => ↑x + b * y) 0 tl =
    List.sum (List.zipWith (fun i a => a * b ^ i) (List.range (List.length tl)) tl)
⊢ List.foldr (fun x y => ↑x + b * y) 0 (hd :: tl) =
    List.sum (List.zipWith (fun i a => a * b ^ i) (List.range (List.length (hd :: tl))) (hd :: tl))

Next tactic:
simpa [List.range_succ_eq_map, List.zipWith_map_left, ofDigits_eq_sum_map_with_index_aux] using
      Or.inl hl
@[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n := by 

Proof state:
n✝ b n : ℕ
⊢ ofDigits b [n] = n

Next tactic:
simp [ofDigits]
@[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
    ofDigits (1 : α) (h :: L) = h + ofDigits 1 L := by 

Proof state:
n : ℕ
α : Type u_1
inst✝ : Semiring α
h : ℕ
L : List ℕ
⊢ ofDigits 1 (h :: L) = ↑h + ofDigits 1 L

Next tactic:
simp [ofDigits]
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
    ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
  

Proof state:
n b : ℕ
l1 l2 : List ℕ
⊢ ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ List.length l1 * ofDigits b l2

Next tactic:
induction' l1 with hd tl IH
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
    ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
  induction' l1 with hd tl IH
  · 

Proof state:
case nil
n b : ℕ
l2 : List ℕ
⊢ ofDigits b ([] ++ l2) = ofDigits b [] + b ^ List.length [] * ofDigits b l2

Next tactic:
simp [ofDigits]
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
    ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
  induction' l1 with hd tl IH
  · simp [ofDigits]
  · 

Proof state:
case cons
n b : ℕ
l2 : List ℕ
hd : ℕ
tl : List ℕ
IH : ofDigits b (tl ++ l2) = ofDigits b tl + b ^ List.length tl * ofDigits b l2
⊢ ofDigits b (hd :: tl ++ l2) = ofDigits b (hd :: tl) + b ^ List.length (hd :: tl) * ofDigits b l2

Next tactic:
rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
    ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 := by
  induction' l1 with hd tl IH
  · simp [ofDigits]
  · rw [ofDigits, List.cons_append, ofDigits, IH, List.length_cons, pow_succ']
    

Proof state:
case cons
n b : ℕ
l2 : List ℕ
hd : ℕ
tl : List ℕ
IH : ofDigits b (tl ++ l2) = ofDigits b tl + b ^ List.length tl * ofDigits b l2
⊢ ↑hd + b * (ofDigits b tl + b ^ List.length tl * ofDigits b l2) =
    ↑hd + b * ofDigits b tl + b * b ^ List.length tl * ofDigits b l2

Next tactic:
ring
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
    ((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
  

Proof state:
n : ℕ
α : Type u_1
inst✝ : Semiring α
b : ℕ
L : List ℕ
⊢ ↑(ofDigits b L) = ofDigits (↑b) L

Next tactic:
induction' L with d L ih
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
    ((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
  induction' L with d L ih
  · 

Proof state:
case nil
n : ℕ
α : Type u_1
inst✝ : Semiring α
b : ℕ
⊢ ↑(ofDigits b []) = ofDigits ↑b []

Next tactic:
simp [ofDigits]
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
    ((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
  induction' L with d L ih
  · simp [ofDigits]
  · 

Proof state:
case cons
n : ℕ
α : Type u_1
inst✝ : Semiring α
b d : ℕ
L : List ℕ
ih : ↑(ofDigits b L) = ofDigits (↑b) L
⊢ ↑(ofDigits b (d :: L)) = ofDigits (↑b) (d :: L)

Next tactic:
dsimp [ofDigits]
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
    ((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
  induction' L with d L ih
  · simp [ofDigits]
  · dsimp [ofDigits]; 

Proof state:
case cons
n : ℕ
α : Type u_1
inst✝ : Semiring α
b d : ℕ
L : List ℕ
ih : ↑(ofDigits b L) = ofDigits (↑b) L
⊢ ↑(d + b * ofDigits b L) = ↑d + ↑b * ofDigits (↑b) L

Next tactic:
push_cast
@[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
    ((ofDigits b L : ℕ) : α) = ofDigits (b : α) L := by
  induction' L with d L ih
  · simp [ofDigits]
  · dsimp [ofDigits]; push_cast; 

Proof state:
case cons
n : ℕ
α : Type u_1
inst✝ : Semiring α
b d : ℕ
L : List ℕ
ih : ↑(ofDigits b L) = ofDigits (↑b) L
⊢ ↑d + ↑b * ↑(ofDigits b L) = ↑d + ↑b * ofDigits (↑b) L

Next tactic:
rw [ih]
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
  

Proof state:
n b : ℕ
L : List ℕ
⊢ ↑(ofDigits b L) = ofDigits (↑b) L

Next tactic:
induction' L with d L _
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
  induction' L with d L _
  · 

Proof state:
case nil
n b : ℕ
⊢ ↑(ofDigits b []) = ofDigits ↑b []

Next tactic:
rfl
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
  induction' L with d L _
  · rfl
  · 

Proof state:
case cons
n b d : ℕ
L : List ℕ
tail_ih✝ : ↑(ofDigits b L) = ofDigits (↑b) L
⊢ ↑(ofDigits b (d :: L)) = ofDigits (↑b) (d :: L)

Next tactic:
dsimp [ofDigits]
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
  induction' L with d L _
  · rfl
  · dsimp [ofDigits]; 

Proof state:
case cons
n b d : ℕ
L : List ℕ
tail_ih✝ : ↑(ofDigits b L) = ofDigits (↑b) L
⊢ ↑(d + b * ofDigits b L) = ↑d + ↑b * ofDigits (↑b) L

Next tactic:
push_cast
@[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L := by
  induction' L with d L _
  · rfl
  · dsimp [ofDigits]; push_cast; 

Proof state:
case cons
n b d : ℕ
L : List ℕ
tail_ih✝ : ↑(ofDigits b L) = ofDigits (↑b) L
⊢ ↑d + ↑b * ofDigits (↑b) L = ↑d + ↑b * ofDigits (↑b) L

Next tactic:
simp only
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
  

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

Next tactic:
induction' L with d L ih
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
  · 

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

Next tactic:
dsimp [ofDigits]
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]
    

Proof state:
case nil
n b : ℕ
h : 1 < b
w₁ : ∀ l ∈ [], l < b
w₂ : ∀ (h : [] ≠ []), List.getLast [] h ≠ 0
⊢ digits b 0 = []

Next tactic:
simp
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
  · 

Proof state:
case cons
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₂ : ∀ (h : d :: L ≠ []), List.getLast (d :: L) h ≠ 0
⊢ digits b (ofDigits b (d :: L)) = d :: L

Next tactic:
dsimp [ofDigits]
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]
    

Proof state:
case cons
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₂ : ∀ (h : d :: L ≠ []), List.getLast (d :: L) h ≠ 0
⊢ digits b (d + b * ofDigits b L) = d :: L

Next tactic:
replace w₂ := w₂ (by simp)
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 

Proof state:
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₂ : ∀ (h : d :: L ≠ []), List.getLast (d :: L) h ≠ 0
⊢ d :: L ≠ []

Next tactic:
simp
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)
    

Proof state:
case cons
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
⊢ digits b (d + b * ofDigits b L) = d :: L

Next tactic:
rw [digits_add b 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]
    · 

Proof state:
case cons
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
⊢ d :: digits b (ofDigits b L) = d :: L

Next tactic:
rw [ih]
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]
      · 

Proof state:
case cons.w₁
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
⊢ ∀ l ∈ L, l < b

Next tactic:
intro l m
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
        

Proof state:
case cons.w₁
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
l : ℕ
m : l ∈ L
⊢ l < b

Next tactic:
apply 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₁
        

Proof state:
case cons.w₁.a
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
l : ℕ
m : l ∈ L
⊢ l ∈ d :: L

Next tactic:
exact List.mem_cons_of_mem _ m
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
      · 

Proof state:
case cons.w₂
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 ≠ []), List.getLast L h ≠ 0

Next tactic:
intro 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
        · 

Proof state:
case cons.w₂
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 ≠ []
⊢ List.getLast L h ≠ 0

Next tactic:
rw [List.getLast_cons h] at 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₂
          

Proof state:
case cons.w₂
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₂ : List.getLast L h ≠ 0
⊢ List.getLast L h ≠ 0

Next tactic:
convert 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₂
    · 

Proof state:
case cons.hxb
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
⊢ d < b

Next tactic:
exact w₁ d (List.mem_cons_self _ _)
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 _ _)
    · 

Proof state:
case cons.hxy
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
⊢ d ≠ 0 ∨ ofDigits b L ≠ 0

Next tactic:
by_cases h' : L = []
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 = []
      · 

Proof state:
case pos
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:
rcases h' with rfl
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
        

Proof state:
case pos
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 ∨ ofDigits b [] ≠ 0

Next tactic:
left