@@ -72,7 +72,14 @@ theorem εClosure.refines (resultB resultH)
7272 induction matchedH, nextH, stackH using εClosure.induct' (HistoryStrategy s) nfa wf pos generalizing matchedB nextB stackB resultB resultH with
7373 | base matchedH nextH =>
7474 simp [εStack.materialize] at refStack
75- grind [εClosure.base, materializeResult]
75+ subst stackB
76+ simp [εClosure.base] at h'
77+ subst h'
78+ -- h : εClosure (BufferStrategy...) ... [] = resultB, hbase gives εClosure [] = (matched, next)
79+ have hbase : εClosure (BufferStrategy s bufferSize) nfa wf pos matchedB nextB [] = (matchedB, nextB) := εClosure.base
80+ have hresB : resultB = (matchedB, nextB) := h.symm.trans hbase
81+ subst hresB
82+ simp [materializeResult, refState, refMatched]
7683 | visited matched' next' update state' stack' mem ih =>
7784 simp only [εStack.materialize.cons] at refStack
7885 subst stackB
@@ -94,14 +101,19 @@ theorem εClosure.refines (resultB resultH)
94101 h
95102 rw [εClosure.not_visited (refState ▸ mem)] at h
96103 refine ih resultB resultH h h' ?_ ?_ ?_
97- . split
98- next eq => simp +instances [matched'', node, eq, ←refMatched]; grind only
99- next eq =>
100- simp at eq
101- simp [matched'', node, eq, refMatched]
104+ . dsimp [matched'', node]
105+ split
106+ next =>
107+ clear ih h h'
108+ cases matched' <;> simp [←refMatched] <;> rfl
109+ next =>
110+ clear ih h h'
111+ simp [←refMatched]
102112 . simp [SearchState.materialize] at refState
103- simp [SearchState.materialize, states'', ←refState]
104- split <;> grind
113+ simp [SearchState.materialize, states'', ← refState, updates'', node]
114+ split
115+ · grind only [HistoryStrategy.update_def, Vector.map_set]
116+ · grind only
105117 . exact pushNext.refines wf rfl rfl
106118
107119theorem stepChar.refines {currentUpdatesH currentUpdatesB state} (resultB resultH)
@@ -114,11 +126,17 @@ theorem stepChar.refines {currentUpdatesH currentUpdatesB state} (resultB result
114126 split at h'
115127 next state' hn =>
116128 simp [hn] at h
117- exact εClosure.refines resultB resultH h h' rfl refState (by simp [εStack.materialize, ←refUpdates]; grind)
129+ have refStack : εStack.materialize [(currentUpdatesH[state], state')] = [(currentUpdatesB[state], state')] := by
130+ have h_eq : (currentUpdatesH.map (materializeUpdates bufferSize))[state] = currentUpdatesB[state] :=
131+ congrArg (fun v => v[state]) refUpdates
132+ simp at h_eq
133+ exact congrArg (fun x => [(x, state')]) h_eq
134+ exact εClosure.refines resultB resultH h h' rfl refState refStack
118135 next hn =>
119136 simp [hn] at h
120- simp [←h', ←h, materializeResult]
121- grind
137+ rw [←h', ←h]
138+ simp [materializeResult, refState]
139+ rfl
122140
123141theorem eachStepChar.go.refines {currentH currentB i hleB hleH} (resultB resultH)
124142 (h : eachStepChar.go (BufferStrategy s bufferSize) nfa wf pos ne currentB i hleB nextB = resultB)
@@ -156,7 +174,7 @@ theorem eachStepChar.go.refines {currentH currentB i hleB hleH} (resultB resultH
156174 simp [materializeResult] at refResult
157175
158176 have isSomeB : matchedB.isSome := by
159- simpa [←refResult.1 ] using isSomeH
177+ simpa [←refResult.1 , HistoryStrategy.update_def ] using isSomeH
160178
161179 simp [eachStepChar.go_found hltH hnH hstepH isSomeH] at h'
162180 simp [eachStepChar.go_found hltB hnB hstepB isSomeB] at h
@@ -176,7 +194,7 @@ theorem eachStepChar.go.refines {currentH currentB i hleB hleH} (resultB resultH
176194 simp [materializeResult] at refResult
177195
178196 have isSomeB : ¬matchedB.isSome := by
179- simpa [←refResult.1 ] using isSomeH
197+ simpa [←refResult.1 , HistoryStrategy.update_def ] using isSomeH
180198
181199 simp [eachStepChar.go_not_found hltH hnH hstepH isSomeH] at h'
182200 simp [eachStepChar.go_not_found hltB hnB hstepB isSomeB] at h
@@ -206,7 +224,7 @@ theorem captureNext.go.refines {currentH currentB resultB resultH}
206224 have isEmptyB : currentB.states.isEmpty := by
207225 simpa [←refCurrent] using isEmptyH
208226 have isSomeB : matchedB.isSome := by
209- simpa [←refMatched] using isSomeH
227+ simpa [←refMatched, HistoryStrategy.update_def ] using isSomeH
210228 rw [captureNext.go_found atEnd isEmptyH isSomeH] at h'
211229 rw [captureNext.go_found atEnd isEmptyB isSomeB] at h
212230 simp [←h', ←h, refMatched]
@@ -218,9 +236,9 @@ theorem captureNext.go.refines {currentH currentB resultB resultH}
218236 have refStepped := eachStepChar.refines steppedB steppedH rfl rfl refCurrent refNext
219237 have refExpanded := εClosure.refines expandedB expandedH rfl rfl rfl (by simp [←refStepped, materializeResult]) rfl
220238 have isNoneB₁ : matchedB = .none := by
221- simpa [←refMatched] using isNoneH₁
239+ simpa [←refMatched, HistoryStrategy.update_def ] using isNoneH₁
222240 have isNoneB₂ : steppedB.1 = .none := by
223- simpa [←refStepped, materializeResult] using isNoneH₂
241+ simpa [←refStepped, materializeResult, HistoryStrategy.update_def ] using isNoneH₂
224242
225243 rw [captureNext.go_ind_not_found steppedH expandedH rfl rfl isNoneH₁ isNoneH₂] at h'
226244 rw [captureNext.go_ind_not_found steppedB expandedB rfl rfl isNoneB₁ isNoneB₂] at h
@@ -238,7 +256,7 @@ theorem captureNext.go.refines {currentH currentB resultB resultH}
238256 simp [←refMatched] at h
239257 exact refCurrent ▸ hempH h
240258 have isSomeB : matchedB.isSome ∨ steppedB.1 .isSome := by
241- simpa [←refMatched, ←refStepped, materializeResult] using isSomeH
259+ simpa [←refMatched, ←refStepped, materializeResult, HistoryStrategy.update_def ] using isSomeH
242260
243261 rw [captureNext.go_ind_found steppedH rfl hempH isSomeH] at h'
244262 rw [captureNext.go_ind_found steppedB rfl hempB isSomeB] at h
0 commit comments