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

Proof steps:
state_before: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
⊢ ValidFor l (List.take n m) (List.drop n m ++ r) (s.take n)
state_after: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this :
  { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n { byteIdx := utf8Len [] } =
    { byteIdx := utf8Len [] + utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r) (s.take n)
tactic: have : Substring.nextn {..} .. = _ := h.nextn (m₁ := []) n
state_before: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this :
  { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n { byteIdx := utf8Len [] } =
    { byteIdx := utf8Len [] + utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r) (s.take n)
state_after: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r) (s.take n)
tactic: simp at this
state_before: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r) (s.take n)
state_after: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r)
    { str := s.str, startPos := s.startPos, stopPos := s.startPos + { byteIdx := utf8Len (List.take n m) } }
tactic: simp only [Substring.take, this]
state_before: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r)
    { str := s.str, startPos := s.startPos, stopPos := s.startPos + { byteIdx := utf8Len (List.take n m) } }
state_after: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r)
    { str := { data := l ++ (m ++ r) }, startPos := { byteIdx := utf8Len l },
      stopPos := { byteIdx := utf8Len l } + { byteIdx := utf8Len (List.take n m) } }
tactic: simp only [h.str, List.append_assoc, h.startPos]
state_before: l m r : List Char
s : Substring
h : ValidFor l m r s
n : Nat
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r)
    { str := { data := l ++ (m ++ r) }, startPos := { byteIdx := utf8Len l },
      stopPos := { byteIdx := utf8Len l } + { byteIdx := utf8Len (List.take n m) } }
state_after: l m r : List Char
s : Substring
n : Nat
h : ValidFor l (List.take n m ++ List.drop n m) r s
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r)
    { str := { data := l ++ (m ++ r) }, startPos := { byteIdx := utf8Len l },
      stopPos := { byteIdx := utf8Len l } + { byteIdx := utf8Len (List.take n m) } }
tactic: rw [← List.take_append_drop n m] at h
state_before: l m r : List Char
s : Substring
n : Nat
h : ValidFor l (List.take n m ++ List.drop n m) r s
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ ValidFor l (List.take n m) (List.drop n m ++ r)
    { str := { data := l ++ (m ++ r) }, startPos := { byteIdx := utf8Len l },
      stopPos := { byteIdx := utf8Len l } + { byteIdx := utf8Len (List.take n m) } }
state_after: l m r : List Char
s : Substring
n : Nat
h : ValidFor l (List.take n m ++ List.drop n m) r s
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ { str := { data := l ++ (m ++ r) }, startPos := { byteIdx := utf8Len l },
          stopPos := { byteIdx := utf8Len l } + { byteIdx := utf8Len (List.take n m) } }.str.data =
    l ++ List.take n m ++ (List.drop n m ++ r)
tactic: refine .of_eq _ ?_ (by simp) (by simp)
state_before: l m r : List Char
s : Substring
n : Nat
h : ValidFor l (List.take n m ++ List.drop n m) r s
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ { str := { data := l ++ (m ++ r) }, startPos := { byteIdx := utf8Len l },
          stopPos := { byteIdx := utf8Len l } + { byteIdx := utf8Len (List.take n m) } }.str.data =
    l ++ List.take n m ++ (List.drop n m ++ r)
state_after: l m r : List Char
s : Substring
n : Nat
h : ValidFor l (List.take n m ++ List.drop n m) r s
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ { str := { data := l ++ (List.take n m ++ List.drop n m ++ r) }, startPos := { byteIdx := utf8Len l },
          stopPos :=
            { byteIdx := utf8Len l } +
              { byteIdx := utf8Len (List.take n (List.take n m ++ List.drop n m)) } }.str.data =
    l ++ List.take n m ++ (List.drop n m ++ r)
tactic: conv => lhs; rw [← List.take_append_drop n m]
state_before: l m r : List Char
s : Substring
n : Nat
h : ValidFor l (List.take n m ++ List.drop n m) r s
this : { str := s.str, startPos := s.startPos, stopPos := s.stopPos }.nextn n 0 = { byteIdx := utf8Len (List.take n m) }
⊢ { str := { data := l ++ (List.take n m ++ List.drop n m ++ r) }, startPos := { byteIdx := utf8Len l },
          stopPos :=
            { byteIdx := utf8Len l } +
              { byteIdx := utf8Len (List.take n (List.take n m ++ List.drop n m)) } }.str.data =
    l ++ List.take n m ++ (List.drop n m ++ r)
state_after: no goals
tactic: simp [-List.take_append_drop, Nat.add_assoc]