Theorem: Regex.VM.captureNext_spec
Proof state before:
case refine_1
nfa : NFA
it : String.Iterator
saveSize : ℕ
matched : Option (Array (Option String.Pos))
v : it.Valid
hsome : matched.isSome = true
saveSlots✝ : Vec (Array (Option String.Pos)) nfa.nodes.size
_hs : (Vec.ofFn fun x => captureNext.initSave saveSize) = saveSlots✝
init : Option (Array (Option String.Pos)) × SparseSet nfa.nodes.size × Vec (Array (Option String.Pos)) nfa.nodes.size
matched' : Option (Array (Option String.Pos))
init' : SparseSet nfa.nodes.size
saveSlots : Vec (Array (Option String.Pos)) nfa.nodes.size
he :
  exploreεClosure nfa it.i SparseSet.empty (captureNext.initSave saveSize) none saveSlots✝ nfa.start #[] =
    (matched', init', saveSlots)
h : captureNext.go nfa saveSize it init' SparseSet.empty saveSlots matched' = matched
hnotMem : ∀ (i : Fin nfa.nodes.size), i ∉ SparseSet.empty
⊢ ∀ i ∈ init',
    ∃ s l m r, Substring.ValidFor l m r s ∧ String.Iterator.ValidFor (m.reverse ++ l.reverse) r it ∧ nfa.reaches i m

case refine_2
nfa : NFA
it : String.Iterator
saveSize : ℕ
matched : Option (Array (Option String.Pos))
v : it.Valid
hsome : matched.isSome = true
saveSlots✝ : Vec (Array (Option String.Pos)) nfa.nodes.size
_hs : (Vec.ofFn fun x => captureNext.initSave saveSize) = saveSlots✝
init : Option (Array (Option String.Pos)) × SparseSet nfa.nodes.size × Vec (Array (Option String.Pos)) nfa.nodes.size
matched' : Option (Array (Option String.Pos))
init' : SparseSet nfa.nodes.size
saveSlots : Vec (Array (Option String.Pos)) nfa.nodes.size
he :
  exploreεClosure nfa it.i SparseSet.empty (captureNext.initSave saveSize) none saveSlots✝ nfa.start #[] =
    (matched', init', saveSlots)
h : captureNext.go nfa saveSize it init' SparseSet.empty saveSlots matched' = matched
hnotMem : ∀ (i : Fin nfa.nodes.size), i ∉ SparseSet.empty
⊢ matched'.isSome = true →
    ∃ s l m r,
      Substring.ValidFor l m r s ∧ it.toString = { data := l ++ m ++ r } ∧ ∃ i, nfa.reaches i m ∧ nfa[i] = Node.done
Tactic:
. intro i hi
  have ⟨l, r, v'⟩ := v.validFor
  let pos : String.Pos := ⟨String.utf8Len l⟩
  refine ⟨⟨it.toString, pos, pos⟩, l.reverse, [], r, ?_, by simp [v'], .nil ?_⟩
  . apply Substring.ValidFor.of_eq <;> simp [v'.toString, List.reverseAux_eq]
  . have := (exploreεClosure_spec.mem_next_iff he (by simp only [hnotMem]; simp) i).mp hi
    simp only [hnotMem] at this
    simp at this
    exact this
Proof state after:
case refine_2
nfa : NFA
it : String.Iterator
saveSize : ℕ
matched : Option (Array (Option String.Pos))
v : it.Valid
hsome : matched.isSome = true
saveSlots✝ : Vec (Array (Option String.Pos)) nfa.nodes.size
_hs : (Vec.ofFn fun x => captureNext.initSave saveSize) = saveSlots✝
init : Option (Array (Option String.Pos)) × SparseSet nfa.nodes.size × Vec (Array (Option String.Pos)) nfa.nodes.size
matched' : Option (Array (Option String.Pos))
init' : SparseSet nfa.nodes.size
saveSlots : Vec (Array (Option String.Pos)) nfa.nodes.size
he :
  exploreεClosure nfa it.i SparseSet.empty (captureNext.initSave saveSize) none saveSlots✝ nfa.start #[] =
    (matched', init', saveSlots)
h : captureNext.go nfa saveSize it init' SparseSet.empty saveSlots matched' = matched
hnotMem : ∀ (i : Fin nfa.nodes.size), i ∉ SparseSet.empty
⊢ matched'.isSome = true →
    ∃ s l m r,
      Substring.ValidFor l m r s ∧ it.toString = { data := l ++ m ++ r } ∧ ∃ i, nfa.reaches i m ∧ nfa[i] = Node.done