4747section
4848
4949variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {startPos : Pos s}
50- {visited : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)} {update' visited'}
50+ {visited : BitMatrix nfa.size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)} {update' visited'}
5151
5252def StackInv (wf : nfa.WellFormed) (bvpos : BVPos startPos) (stack : List (StackEntry (HistoryStrategy s) nfa startPos)) : Prop :=
5353 ∀ entry ∈ stack, Path nfa wf bvpos.current entry.pos.current entry.state entry.update
@@ -137,7 +137,7 @@ end StackInv
137137
138138theorem path_done_of_some {bvpos} (hres : captureNextAux (HistoryStrategy s) nfa wf startPos visited stack = (.some update', visited'))
139139 (inv : StackInv wf bvpos stack) :
140- ∃ (state : Fin nfa.nodes. size) (bvpos' : BVPos startPos),
140+ ∃ (state : Fin nfa.size) (bvpos' : BVPos startPos),
141141 nfa[state] = .done ∧ bvpos ≤ bvpos' ∧ Path nfa wf bvpos.current bvpos'.current state update' := by
142142 induction visited, stack using captureNextAux.induct' (HistoryStrategy s) nfa wf startPos with
143143 | base visited => simp [captureNextAux_base] at hres
@@ -157,10 +157,10 @@ end
157157section
158158
159159variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {startPos : Pos s}
160- {bvpos₀ : BVPos startPos} {visited : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
160+ {bvpos₀ : BVPos startPos} {visited : BitMatrix nfa.size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
161161
162- def ClosureInv (bvpos₀ : BVPos startPos) (visited : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )) (stack : List (StackEntry (HistoryStrategy s) nfa startPos)) : Prop :=
163- ∀ (state : Fin nfa.nodes. size) (bvpos : BVPos startPos) (state' : Fin nfa.nodes .size) (bvpos' : BVPos startPos) (update : Option (Nat × Pos s)),
162+ def ClosureInv (bvpos₀ : BVPos startPos) (visited : BitMatrix nfa.size (startPos.remainingBytes + 1 )) (stack : List (StackEntry (HistoryStrategy s) nfa startPos)) : Prop :=
163+ ∀ (state : Fin nfa.size) (bvpos : BVPos startPos) (state' : Fin nfa.size) (bvpos' : BVPos startPos) (update : Option (Nat × Pos s)),
164164 bvpos₀ ≤ bvpos →
165165 visited.get state bvpos.index →
166166 nfa.Step 0 state bvpos.current state' bvpos'.current update →
@@ -171,7 +171,7 @@ namespace ClosureInv
171171-- Preservation of the non-visited cases
172172theorem preserves' {entry stack'} (inv : ClosureInv bvpos₀ visited (entry :: stack))
173173 (nextEntries : List (StackEntry (HistoryStrategy s) nfa startPos)) (hstack : stack' = nextEntries ++ stack)
174- (hnext : ∀ (state' : Fin nfa.nodes. size) (bvpos' : BVPos startPos) (update : Option (Nat × Pos s)),
174+ (hnext : ∀ (state' : Fin nfa.size) (bvpos' : BVPos startPos) (update : Option (Nat × Pos s)),
175175 nfa.Step 0 entry.state entry.pos.current state' bvpos'.current update →
176176 ∃ entry' ∈ nextEntries, entry'.state = state' ∧ entry'.pos = bvpos') :
177177 ClosureInv bvpos₀ (visited.set entry.state entry.pos.index) stack' := by
@@ -310,29 +310,29 @@ theorem step_closure {bvpos₀ bvpos : BVPos startPos} {result} (hres : captureN
310310 simp [captureNextAux_next mem hn] at hres
311311 exact ih hres (cinv.preserves wf hn) stinv.preserves
312312
313- def StepClosure (bvpos₀ : BVPos startPos) (visited : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )) : Prop :=
314- ∀ (state : Fin nfa.nodes. size) (bvpos : BVPos startPos) (state' : Fin nfa.nodes .size) (bvpos' : BVPos startPos) (update : Option (Nat × Pos s)),
313+ def StepClosure (bvpos₀ : BVPos startPos) (visited : BitMatrix nfa.size (startPos.remainingBytes + 1 )) : Prop :=
314+ ∀ (state : Fin nfa.size) (bvpos : BVPos startPos) (state' : Fin nfa.size) (bvpos' : BVPos startPos) (update : Option (Nat × Pos s)),
315315 bvpos₀ ≤ bvpos →
316316 visited.get state bvpos.index →
317317 nfa.Step 0 state bvpos.current state' bvpos'.current update →
318318 visited.get state' bvpos'.index
319319
320- def PathClosure (bvpos₀ : BVPos startPos) (visited : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )) : Prop :=
321- ∀ (state : Fin nfa.nodes. size) (bvpos : BVPos startPos) (state' : Fin nfa.nodes .size) (bvpos' : BVPos startPos) (update : List (Nat × Pos s)),
320+ def PathClosure (bvpos₀ : BVPos startPos) (visited : BitMatrix nfa.size (startPos.remainingBytes + 1 )) : Prop :=
321+ ∀ (state : Fin nfa.size) (bvpos : BVPos startPos) (state' : Fin nfa.size) (bvpos' : BVPos startPos) (update : List (Nat × Pos s)),
322322 bvpos₀ ≤ bvpos →
323323 visited.get state bvpos.index →
324324 nfa.Path 0 state bvpos.current state' bvpos'.current update →
325325 visited.get state' bvpos'.index
326326
327327namespace PathClosure
328328
329- theorem zero : PathClosure bvpos₀ (BitMatrix.zero nfa.nodes. size (startPos.remainingBytes + 1 )) := by
329+ theorem zero : PathClosure bvpos₀ (BitMatrix.zero nfa.size (startPos.remainingBytes + 1 )) := by
330330 intro state bvpos state' bvpos' update reaches hmem path
331331 simp at hmem
332332
333333theorem of_step_closure {bvpos₀ : BVPos startPos} (wf : nfa.WellFormed) (h : StepClosure bvpos₀ visited) : PathClosure bvpos₀ visited := by
334334 let motive (i : Nat) (pos : Pos s) : Prop :=
335- ∃ (isLt : i < nfa.nodes. size) (bvpos : BVPos startPos), bvpos₀ ≤ bvpos ∧ pos = bvpos.current ∧ visited.get ⟨i, isLt⟩ bvpos.index
335+ ∃ (isLt : i < nfa.size) (bvpos : BVPos startPos), bvpos₀ ≤ bvpos ∧ pos = bvpos.current ∧ visited.get ⟨i, isLt⟩ bvpos.index
336336 have cls i pos j pos' update (base : motive i pos) (step : nfa.Step 0 i pos j pos' update) : motive j pos' := by
337337 have ⟨_, bvpos, le, hbvpos, hmem⟩ := base
338338
@@ -370,10 +370,10 @@ end
370370section
371371
372372variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {startPos : Pos s} {bvpos₀ bvpos : BVPos startPos}
373- {visited visited' : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
373+ {visited visited' : BitMatrix nfa.size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
374374
375- def VisitedInv (wf : nfa.WellFormed) (bvpos₀ bvpos : BVPos startPos) (visited visited' : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )) : Prop :=
376- ∀ (state' : Fin nfa.nodes. size) (bvpos' : BVPos startPos),
375+ def VisitedInv (wf : nfa.WellFormed) (bvpos₀ bvpos : BVPos startPos) (visited visited' : BitMatrix nfa.size (startPos.remainingBytes + 1 )) : Prop :=
376+ ∀ (state' : Fin nfa.size) (bvpos' : BVPos startPos),
377377 bvpos₀ ≤ bvpos' →
378378 visited'.get state' bvpos'.index →
379379 visited.get state' bvpos'.index ∨ ∃ update, Path nfa wf bvpos.current bvpos'.current state' update
@@ -384,7 +384,7 @@ theorem rfl (wf : nfa.WellFormed) (bvpos₀ bvpos : BVPos startPos) : VisitedInv
384384 intro state bvpos _ hmem
385385 exact .inl hmem
386386
387- theorem preserves {bvpos' : BVPos startPos} {state : Fin nfa.nodes. size}
387+ theorem preserves {bvpos' : BVPos startPos} {state : Fin nfa.size}
388388 (inv : VisitedInv wf bvpos₀ bvpos visited visited')
389389 (update : List (Nat × Pos s)) (path : Path nfa wf bvpos.current bvpos'.current state update) :
390390 VisitedInv wf bvpos₀ bvpos visited (visited'.set state bvpos'.index) := by
@@ -423,16 +423,16 @@ end
423423
424424section
425425
426- variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {startPos : Pos s} {bvpos₀ bvpos : BVPos startPos} {visited : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
426+ variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {startPos : Pos s} {bvpos₀ bvpos : BVPos startPos} {visited : BitMatrix nfa.size (startPos.remainingBytes + 1 )} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
427427
428- def NotDoneInv (visited : BitMatrix nfa.nodes. size (startPos.remainingBytes + 1 )) : Prop :=
429- ∀ (state : Fin nfa.nodes. size) (bvpos : BVPos startPos),
428+ def NotDoneInv (visited : BitMatrix nfa.size (startPos.remainingBytes + 1 )) : Prop :=
429+ ∀ (state : Fin nfa.size) (bvpos : BVPos startPos),
430430 visited.get state bvpos.index →
431431 nfa[state] ≠ .done
432432
433433namespace NotDoneInv
434434
435- theorem zero : NotDoneInv (BitMatrix.zero nfa.nodes. size (startPos.remainingBytes + 1 )) := by
435+ theorem zero : NotDoneInv (BitMatrix.zero nfa.size (startPos.remainingBytes + 1 )) := by
436436 intro state bvpos hmem
437437 simp at hmem
438438
0 commit comments