Theorem: String.splitAux_of_valid
File: .lake/packages/batteries/Batteries/Data/String/Lemmas.lean

tactic: unfold splitAux
state_before: p : Char → Bool
l m r : List Char
acc : List String
⊢ { data := l ++ m ++ r }.splitAux p { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } acc =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)
state_after: p : Char → Bool
l m r : List Char
acc : List String
⊢ (if h : { data := l ++ m ++ r }.atEnd { byteIdx := utf8Len l + utf8Len m } = true then
      let r := { data := l ++ m ++ r }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc;
      r.reverse
    else
      let_fun this := ⋯;
      if p ({ data := l ++ m ++ r }.get { byteIdx := utf8Len l + utf8Len m }) = true then
        let i' := { data := l ++ m ++ r }.next { byteIdx := utf8Len l + utf8Len m };
        { data := l ++ m ++ r }.splitAux p i' i'
          ({ data := l ++ m ++ r }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
      else
        { data := l ++ m ++ r }.splitAux p { byteIdx := utf8Len l }
          ({ data := l ++ m ++ r }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)

tactic: simp only [List.append_assoc, atEnd_iff, endPos_eq, utf8Len_append, Pos.mk_le_mk, by
  simpa using atEnd_of_valid (l ++ m) r, List.reverse_cons, dite_eq_ite]
state_before: p : Char → Bool
l m r : List Char
acc : List String
⊢ (if h : { data := l ++ m ++ r }.atEnd { byteIdx := utf8Len l + utf8Len m } = true then
      let r := { data := l ++ m ++ r }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc;
      r.reverse
    else
      let_fun this := ⋯;
      if p ({ data := l ++ m ++ r }.get { byteIdx := utf8Len l + utf8Len m }) = true then
        let i' := { data := l ++ m ++ r }.next { byteIdx := utf8Len l + utf8Len m };
        { data := l ++ m ++ r }.splitAux p i' i'
          ({ data := l ++ m ++ r }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
      else
        { data := l ++ m ++ r }.splitAux p { byteIdx := utf8Len l }
          ({ data := l ++ m ++ r }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)
state_after: p : Char → Bool
l m r : List Char
acc : List String
⊢ (if r = [] then
      acc.reverse ++ [{ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m }]
    else
      if p ({ data := l ++ (m ++ r) }.get { byteIdx := utf8Len l + utf8Len m }) = true then
        { data := l ++ (m ++ r) }.splitAux p ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
          ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
          ({ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
      else
        { data := l ++ (m ++ r) }.splitAux p { byteIdx := utf8Len l }
          ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)

tactic: split
state_before: p : Char → Bool
l m r : List Char
acc : List String
⊢ (if r = [] then
      acc.reverse ++ [{ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m }]
    else
      if p ({ data := l ++ (m ++ r) }.get { byteIdx := utf8Len l + utf8Len m }) = true then
        { data := l ++ (m ++ r) }.splitAux p ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
          ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
          ({ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
      else
        { data := l ++ (m ++ r) }.splitAux p { byteIdx := utf8Len l }
          ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)
state_after: case isTrue
p : Char → Bool
l m r : List Char
acc : List String
h✝ : r = []
⊢ acc.reverse ++ [{ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m }] =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)

case isFalse
p : Char → Bool
l m r : List Char
acc : List String
h✝ : ¬r = []
⊢ (if p ({ data := l ++ (m ++ r) }.get { byteIdx := utf8Len l + utf8Len m }) = true then
      { data := l ++ (m ++ r) }.splitAux p ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
    else
      { data := l ++ (m ++ r) }.splitAux p { byteIdx := utf8Len l }
        ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)

tactic: simpa using atEnd_of_valid (l ++ m) r
state_before: p : Char → Bool
l m r : List Char
acc : List String
⊢ ?m.79861
state_after: no goals

tactic: subst r
state_before: case isTrue
p : Char → Bool
l m r : List Char
acc : List String
h✝ : r = []
⊢ acc.reverse ++ [{ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m }] =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)
state_after: case isTrue
p : Char → Bool
l m : List Char
acc : List String
⊢ acc.reverse ++ [{ data := l ++ (m ++ []) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m }] =
    acc.reverse ++ List.map mk (List.splitOnP.go p [] m.reverse)

tactic: simpa [List.splitOnP.go] using extract_of_valid l m []
state_before: case isTrue
p : Char → Bool
l m : List Char
acc : List String
⊢ acc.reverse ++ [{ data := l ++ (m ++ []) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m }] =
    acc.reverse ++ List.map mk (List.splitOnP.go p [] m.reverse)
state_after: no goals

tactic: obtain ⟨c, r, rfl⟩ := r.exists_cons_of_ne_nil ‹_›
state_before: case isFalse
p : Char → Bool
l m r : List Char
acc : List String
h✝ : ¬r = []
⊢ (if p ({ data := l ++ (m ++ r) }.get { byteIdx := utf8Len l + utf8Len m }) = true then
      { data := l ++ (m ++ r) }.splitAux p ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
    else
      { data := l ++ (m ++ r) }.splitAux p { byteIdx := utf8Len l }
        ({ data := l ++ (m ++ r) }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p r m.reverse)
state_after: case isFalse.intro.intro
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝ : ¬c :: r = []
⊢ (if p ({ data := l ++ (m ++ c :: r) }.get { byteIdx := utf8Len l + utf8Len m }) = true then
      { data := l ++ (m ++ c :: r) }.splitAux p
        ({ data := l ++ (m ++ c :: r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ c :: r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ c :: r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
    else
      { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l }
        ({ data := l ++ (m ++ c :: r) }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p (c :: r) m.reverse)

tactic: simp only [by
  simpa using
    (⟨get_of_valid (l ++ m) (c :: r), next_of_valid (l ++ m) c r,
        extract_of_valid l m (c :: r)⟩ :
      _ ∧ _ ∧ _),
  List.splitOnP.go, List.reverse_reverse]
state_before: case isFalse.intro.intro
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝ : ¬c :: r = []
⊢ (if p ({ data := l ++ (m ++ c :: r) }.get { byteIdx := utf8Len l + utf8Len m }) = true then
      { data := l ++ (m ++ c :: r) }.splitAux p
        ({ data := l ++ (m ++ c :: r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ c :: r) }.next { byteIdx := utf8Len l + utf8Len m })
        ({ data := l ++ (m ++ c :: r) }.extract { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m } :: acc)
    else
      { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l }
        ({ data := l ++ (m ++ c :: r) }.next { byteIdx := utf8Len l + utf8Len m }) acc) =
    acc.reverse ++ List.map mk (List.splitOnP.go p (c :: r) m.reverse)
state_after: case isFalse.intro.intro
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝ : ¬c :: r = []
⊢ (if p c = true then
      { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l + utf8Len m + c.utf8Size }
        { byteIdx := utf8Len l + utf8Len m + c.utf8Size } ({ data := m } :: acc)
    else
      { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l }
        { byteIdx := utf8Len l + utf8Len m + c.utf8Size } acc) =
    acc.reverse ++
      List.map mk (if p c = true then m :: List.splitOnP.go p r [] else List.splitOnP.go p r (c :: m.reverse))

tactic: split
state_before: case isFalse.intro.intro
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝ : ¬c :: r = []
⊢ (if p c = true then
      { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l + utf8Len m + c.utf8Size }
        { byteIdx := utf8Len l + utf8Len m + c.utf8Size } ({ data := m } :: acc)
    else
      { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l }
        { byteIdx := utf8Len l + utf8Len m + c.utf8Size } acc) =
    acc.reverse ++
      List.map mk (if p c = true then m :: List.splitOnP.go p r [] else List.splitOnP.go p r (c :: m.reverse))
state_after: case isFalse.intro.intro.isTrue
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝¹ : ¬c :: r = []
h✝ : p c = true
⊢ { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l + utf8Len m + c.utf8Size }
      { byteIdx := utf8Len l + utf8Len m + c.utf8Size } ({ data := m } :: acc) =
    acc.reverse ++ List.map mk (m :: List.splitOnP.go p r [])

case isFalse.intro.intro.isFalse
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝¹ : ¬c :: r = []
h✝ : ¬p c = true
⊢ { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m + c.utf8Size }
      acc =
    acc.reverse ++ List.map mk (List.splitOnP.go p r (c :: m.reverse))

tactic: simpa using
  (⟨get_of_valid (l ++ m) (c :: r), next_of_valid (l ++ m) c r,
      extract_of_valid l m (c :: r)⟩ :
    _ ∧ _ ∧ _)
state_before: p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝ : ¬c :: r = []
⊢ ?m.81420
state_after: no goals

tactic: simpa [Nat.add_assoc] using splitAux_of_valid p (l++m++[c]) [] r (⟨m⟩::acc)
state_before: case isFalse.intro.intro.isTrue
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝¹ : ¬c :: r = []
h✝ : p c = true
⊢ { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l + utf8Len m + c.utf8Size }
      { byteIdx := utf8Len l + utf8Len m + c.utf8Size } ({ data := m } :: acc) =
    acc.reverse ++ List.map mk (m :: List.splitOnP.go p r [])
state_after: no goals

tactic: simpa [Nat.add_assoc] using splitAux_of_valid p l (m++[c]) r acc
state_before: case isFalse.intro.intro.isFalse
p : Char → Bool
l m : List Char
acc : List String
c : Char
r : List Char
h✝¹ : ¬c :: r = []
h✝ : ¬p c = true
⊢ { data := l ++ (m ++ c :: r) }.splitAux p { byteIdx := utf8Len l } { byteIdx := utf8Len l + utf8Len m + c.utf8Size }
      acc =
    acc.reverse ++ List.map mk (List.splitOnP.go p r (c :: m.reverse))
state_after: no goals