cases Array.mem_pop_or_eq_of_mem _ _ hemp hmem with
| inl hmem =>
  split at h
  next => exact mem_stack_mem_exploreεClosure h hmem
  next => exact mem_stack_mem_εClosure h hmem
| inr heq =>
  split at h
  next target heq' =>
    rw [heq'] at heq
    have : target = i := by
      simp at heq
      rw [heq]
    rw [this] at h
    exact target_mem_exploreεClosure h
  next _ heq' =>
    rw [heq'] at heq
    contradiction
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
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
i : Fin nfa.nodes.size
hmem : StackEntry.explore i ∈ stack
hemp : ¬stack.isEmpty = true
h :
  (match stack.back' hemp with
    | StackEntry.explore target => exploreεClosure nfa pos next currentSave matched saveSlots target stack.pop
    | StackEntry.restore save => εClosure nfa pos next save matched saveSlots stack.pop) =
    (matched', next', saveSlots')
this : stack.pop.size < stack.size
⊢ i ∈ next'
no goals