Theorem: Substring.ValidFor.nextn
File: .lake/packages/batteries/Batteries/Data/String/Lemmas.lean

tactic: simp [Substring.nextn]
state_before: l m₁ m₂ r : List Char
x✝¹ : Substring
x✝ : ValidFor l (m₁ ++ m₂) r x✝¹
⊢ x✝¹.nextn 0 { byteIdx := utf8Len m₁ } = { byteIdx := utf8Len m₁ + utf8Len (List.take 0 m₂) }
state_after: no goals

tactic: simp only [Substring.nextn]
state_before: l m₁ m₂ r : List Char
s : Substring
h : ValidFor l (m₁ ++ m₂) r s
n : Nat
⊢ s.nextn (n + 1) { byteIdx := utf8Len m₁ } = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) m₂) }
state_after: l m₁ m₂ r : List Char
s : Substring
h : ValidFor l (m₁ ++ m₂) r s
n : Nat
⊢ s.nextn n (s.next { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) m₂) }

tactic: match m₂ with
| [] => simp at h; simp [h.next_stop, h.nextn_stop]
| c::m₂ =>
  rw [h.next]
  have := @nextn l (m₁ ++ [c]) m₂ r s (by simp [h]) n
  simp at this; rw [this]; simp [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm]
state_before: l m₁ m₂ r : List Char
s : Substring
h : ValidFor l (m₁ ++ m₂) r s
n : Nat
⊢ s.nextn n (s.next { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) m₂) }
state_after: no goals

tactic: simp at h
state_before: l m₁ m₂ r : List Char
s : Substring
n : Nat
h : ValidFor l (m₁ ++ []) r s
⊢ s.nextn n (s.next { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) []) }
state_after: l m₁ m₂ r : List Char
s : Substring
n : Nat
h : ValidFor l m₁ r s
⊢ s.nextn n (s.next { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) []) }

tactic: simp [h.next_stop, h.nextn_stop]
state_before: l m₁ m₂ r : List Char
s : Substring
n : Nat
h : ValidFor l m₁ r s
⊢ s.nextn n (s.next { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) []) }
state_after: no goals

tactic: rw [h.next]
state_before: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
⊢ s.nextn n (s.next { byteIdx := utf8Len m₁ }) = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }
state_after: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
⊢ s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }

tactic: have := @nextn l (m₁ ++ [c]) m₂ r s (by simp [h]) n
state_before: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
⊢ s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }
state_after: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
this : s.nextn n { byteIdx := utf8Len (m₁ ++ [c]) } = { byteIdx := utf8Len (m₁ ++ [c]) + utf8Len (List.take n m₂) }
⊢ s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }

tactic: simp at this
state_before: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
this : s.nextn n { byteIdx := utf8Len (m₁ ++ [c]) } = { byteIdx := utf8Len (m₁ ++ [c]) + utf8Len (List.take n m₂) }
⊢ s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }
state_after: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
this :
  s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + c.utf8Size + utf8Len (List.take n m₂) }
⊢ s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }

tactic: rw [this]
state_before: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
this :
  s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + c.utf8Size + utf8Len (List.take n m₂) }
⊢ s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }
state_after: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
this :
  s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + c.utf8Size + utf8Len (List.take n m₂) }
⊢ { byteIdx := utf8Len m₁ + c.utf8Size + utf8Len (List.take n m₂) } =
    { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }

tactic: simp [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm]
state_before: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
this :
  s.nextn n { byteIdx := utf8Len m₁ + c.utf8Size } = { byteIdx := utf8Len m₁ + c.utf8Size + utf8Len (List.take n m₂) }
⊢ { byteIdx := utf8Len m₁ + c.utf8Size + utf8Len (List.take n m₂) } =
    { byteIdx := utf8Len m₁ + utf8Len (List.take (n + 1) (c :: m₂)) }
state_after: no goals

tactic: simp [h]
state_before: l m₁ m₂✝ r : List Char
s : Substring
n : Nat
c : Char
m₂ : List Char
h : ValidFor l (m₁ ++ c :: m₂) r s
⊢ ValidFor l (m₁ ++ [c] ++ m₂) r s
state_after: no goals