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

tactic: induction f with (intro n c tl; simp only [Nat.toDigitsCore, List.length])
| succ f ih =>
  if hnb : (n / b) = 0 then
    simp only [hnb, if_true, List.length]
  else
    generalize hx: Nat.digitChar (n % b) = x
    simp only [hx, hnb, if_false] at ih
    simp only [hnb, if_false]
    specialize ih (n / b) c (x :: tl)
    rw [← ih]
    have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
    apply toDigitsCore_lens_eq_aux
    exact lens_eq
state_before: n b f : ℕ
⊢ ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
state_after: no goals

tactic: intro n c tl
state_before: case zero
n b : ℕ
⊢ ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore 0 n (c :: tl)).length = (b.toDigitsCore 0 n tl).length + 1
state_after: case zero
n✝ b n : ℕ
c : Char
tl : List Char
⊢ (b.toDigitsCore 0 n (c :: tl)).length = (b.toDigitsCore 0 n tl).length + 1

tactic: simp only [Nat.toDigitsCore, List.length]
state_before: case zero
n✝ b n : ℕ
c : Char
tl : List Char
⊢ (b.toDigitsCore 0 n (c :: tl)).length = (b.toDigitsCore 0 n tl).length + 1
state_after: no goals

tactic: if hnb : (n / b) = 0 then
  simp only [hnb, if_true, List.length]
else
  generalize hx: Nat.digitChar (n % b) = x
  simp only [hx, hnb, if_false] at ih
  simp only [hnb, if_false]
  specialize ih (n / b) c (x :: tl)
  rw [← ih]
  have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
  apply toDigitsCore_lens_eq_aux
  exact lens_eq
state_before: case succ
n✝ b f : ℕ
ih : ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
n : ℕ
c : Char
tl : List Char
⊢ (if n / b = 0 then (n % b).digitChar :: c :: tl else b.toDigitsCore f (n / b) ((n % b).digitChar :: c :: tl)).length =
    (if n / b = 0 then (n % b).digitChar :: tl else b.toDigitsCore f (n / b) ((n % b).digitChar :: tl)).length + 1
state_after: no goals

tactic: simp only [hnb, if_true, List.length]
state_before: n✝ b f : ℕ
ih : ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
n : ℕ
c : Char
tl : List Char
hnb : n / b = 0
⊢ (if n / b = 0 then (n % b).digitChar :: c :: tl else b.toDigitsCore f (n / b) ((n % b).digitChar :: c :: tl)).length =
    (if n / b = 0 then (n % b).digitChar :: tl else b.toDigitsCore f (n / b) ((n % b).digitChar :: tl)).length + 1
state_after: no goals

tactic: generalize hx: Nat.digitChar (n % b) = x
state_before: n✝ b f : ℕ
ih : ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
⊢ (if n / b = 0 then (n % b).digitChar :: c :: tl else b.toDigitsCore f (n / b) ((n % b).digitChar :: c :: tl)).length =
    (if n / b = 0 then (n % b).digitChar :: tl else b.toDigitsCore f (n / b) ((n % b).digitChar :: tl)).length + 1
state_after: n✝ b f : ℕ
ih : ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
⊢ (if n / b = 0 then x :: c :: tl else b.toDigitsCore f (n / b) (x :: c :: tl)).length =
    (if n / b = 0 then x :: tl else b.toDigitsCore f (n / b) (x :: tl)).length + 1

tactic: simp only [hnb, if_false]
state_before: n✝ b f : ℕ
ih : ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
⊢ (if n / b = 0 then x :: c :: tl else b.toDigitsCore f (n / b) (x :: c :: tl)).length =
    (if n / b = 0 then x :: tl else b.toDigitsCore f (n / b) (x :: tl)).length + 1
state_after: n✝ b f : ℕ
ih : ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1

tactic: specialize ih (n / b) c (x :: tl)
state_before: n✝ b f : ℕ
ih : ∀ (n : ℕ) (c : Char) (tl : List Char), (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
state_after: n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1

tactic: rw [← ih]
state_before: n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
state_after: n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (c :: x :: tl)).length

tactic: have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
state_before: n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (c :: x :: tl)).length
state_after: n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
lens_eq : (x :: c :: tl).length = (c :: x :: tl).length
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (c :: x :: tl)).length

tactic: apply toDigitsCore_lens_eq_aux
state_before: n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
lens_eq : (x :: c :: tl).length = (c :: x :: tl).length
⊢ (b.toDigitsCore f (n / b) (x :: c :: tl)).length = (b.toDigitsCore f (n / b) (c :: x :: tl)).length
state_after: case a
n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
lens_eq : (x :: c :: tl).length = (c :: x :: tl).length
⊢ (x :: c :: tl).length = (c :: x :: tl).length

tactic: exact lens_eq
state_before: case a
n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
lens_eq : (x :: c :: tl).length = (c :: x :: tl).length
⊢ (x :: c :: tl).length = (c :: x :: tl).length
state_after: no goals

tactic: simp
state_before: n✝ b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : (n % b).digitChar = x
ih : (b.toDigitsCore f (n / b) (c :: x :: tl)).length = (b.toDigitsCore f (n / b) (x :: tl)).length + 1
⊢ (x :: c :: tl).length = (c :: x :: tl).length
state_after: no goals