. intro hj
  cases (mem_next_iff j).mp hj with
  | inl hj => exact .inl hj
  | inr hj =>
    refine .inr ⟨target', ?_, hj⟩
    simp [charStep, Node.charStep, hn, hc]
case mp
nfa : NFA
c : Char
pos : String.Pos
next : SparseSet nfa.nodes.size
saveSlots : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
target : Fin 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 j : Fin nfa.nodes.size), i ∈ next → ↑j ∈ nfa.εStep ↑i → j ∈ next
cs : Data.Classes
target' : ℕ
hn : nfa[↑target] = Node.sparse cs target'
hc : c ∈ cs
h :
  exploreεClosure nfa pos next (saveSlots.get ↑target ⋯) none saveSlots ⟨target', ⋯⟩ #[] = (matched', next', saveSlots')
mem_next_iff : ∀ (i : Fin nfa.nodes.size), i ∈ next' ↔ i ∈ next ∨ ↑i ∈ nfa.εClosure ↑⟨target', ⋯⟩
j : Fin nfa.nodes.size
⊢ j ∈ next' → j ∈ next ∨ ∃ i ∈ nfa.charStep (↑target) c, ↑j ∈ nfa.εClosure i

case mpr
nfa : NFA
c : Char
pos : String.Pos
next : SparseSet nfa.nodes.size
saveSlots : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
target : Fin 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 j : Fin nfa.nodes.size), i ∈ next → ↑j ∈ nfa.εStep ↑i → j ∈ next
cs : Data.Classes
target' : ℕ
hn : nfa[↑target] = Node.sparse cs target'
hc : c ∈ cs
h :
  exploreεClosure nfa pos next (saveSlots.get ↑target ⋯) none saveSlots ⟨target', ⋯⟩ #[] = (matched', next', saveSlots')
mem_next_iff : ∀ (i : Fin nfa.nodes.size), i ∈ next' ↔ i ∈ next ∨ ↑i ∈ nfa.εClosure ↑⟨target', ⋯⟩
j : Fin nfa.nodes.size
⊢ (j ∈ next ∨ ∃ i ∈ nfa.charStep (↑target) c, ↑j ∈ nfa.εClosure i) → j ∈ next'
case mpr
nfa : NFA
c : Char
pos : String.Pos
next : SparseSet nfa.nodes.size
saveSlots : Data.Vec (Array (Option String.Pos)) nfa.nodes.size
target : Fin 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 j : Fin nfa.nodes.size), i ∈ next → ↑j ∈ nfa.εStep ↑i → j ∈ next
cs : Data.Classes
target' : ℕ
hn : nfa[↑target] = Node.sparse cs target'
hc : c ∈ cs
h :
  exploreεClosure nfa pos next (saveSlots.get ↑target ⋯) none saveSlots ⟨target', ⋯⟩ #[] = (matched', next', saveSlots')
mem_next_iff : ∀ (i : Fin nfa.nodes.size), i ∈ next' ↔ i ∈ next ∨ ↑i ∈ nfa.εClosure ↑⟨target', ⋯⟩
j : Fin nfa.nodes.size
⊢ (j ∈ next ∨ ∃ i ∈ nfa.charStep (↑target) c, ↑j ∈ nfa.εClosure i) → j ∈ next'