next => exact exploreεClosure_mem_done_iff h (inv' (by simp [hn]))
case inl
nfa : NFA
pos : String.Pos
next : SparseSet nfa.nodes.size
currentSave : Array (Option String.Pos)
matched : Option (Array (Option String.Pos))
saveSlots : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
target : Fin nfa.nodes.size
stack : Array (StackEntry nfa.nodes.size)
matched' : Option (Array (Option String.Pos))
next' : SparseSet nfa.nodes.size
saveSlots' : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
inv : (∃ i ∈ next, nfa[i] = Node.done) ↔ matched.isSome = true
hmem : target ∉ next
inv' : nfa[target] ≠ Node.done → ((∃ i ∈ next.insert target, nfa[i] = Node.done) ↔ matched.isSome = true)
offset✝ target'✝ : ℕ
hn : nfa[↑target] = Node.save offset✝ target'✝
h✝ : offset✝ < currentSave.size
h :
  exploreεClosure nfa pos (next.insert target) (currentSave.set ⟨offset✝, ⋯⟩ (some pos)) matched saveSlots ⟨target'✝, ⋯⟩
      (stack.push (StackEntry.restore currentSave)) =
    (matched', next', saveSlots')
⊢ (∃ i ∈ next', nfa[i] = Node.done) ↔ matched'.isSome = true

case inr
nfa : NFA
pos : String.Pos
next : SparseSet nfa.nodes.size
currentSave : Array (Option String.Pos)
matched : Option (Array (Option String.Pos))
saveSlots : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
target : Fin nfa.nodes.size
stack : Array (StackEntry nfa.nodes.size)
matched' : Option (Array (Option String.Pos))
next' : SparseSet nfa.nodes.size
saveSlots' : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
inv : (∃ i ∈ next, nfa[i] = Node.done) ↔ matched.isSome = true
hmem : target ∉ next
inv' : nfa[target] ≠ Node.done → ((∃ i ∈ next.insert target, nfa[i] = Node.done) ↔ matched.isSome = true)
offset✝ target'✝ : ℕ
hn : nfa[↑target] = Node.save offset✝ target'✝
h✝ : ¬offset✝ < currentSave.size
h :
  exploreεClosure nfa pos (next.insert target) currentSave matched saveSlots ⟨target'✝, ⋯⟩ stack =
    (matched', next', saveSlots')
⊢ (∃ i ∈ next', nfa[i] = Node.done) ↔ matched'.isSome = true
case inr
nfa : NFA
pos : String.Pos
next : SparseSet nfa.nodes.size
currentSave : Array (Option String.Pos)
matched : Option (Array (Option String.Pos))
saveSlots : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
target : Fin nfa.nodes.size
stack : Array (StackEntry nfa.nodes.size)
matched' : Option (Array (Option String.Pos))
next' : SparseSet nfa.nodes.size
saveSlots' : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
inv : (∃ i ∈ next, nfa[i] = Node.done) ↔ matched.isSome = true
hmem : target ∉ next
inv' : nfa[target] ≠ Node.done → ((∃ i ∈ next.insert target, nfa[i] = Node.done) ↔ matched.isSome = true)
offset✝ target'✝ : ℕ
hn : nfa[↑target] = Node.save offset✝ target'✝
h✝ : ¬offset✝ < currentSave.size
h :
  exploreεClosure nfa pos (next.insert target) currentSave matched saveSlots ⟨target'✝, ⋯⟩ stack =
    (matched', next', saveSlots')
⊢ (∃ i ∈ next', nfa[i] = Node.done) ↔ matched'.isSome = true