Skip to content

Commit 47dfe20

Browse files
authored
Do not expose nfa.nodes.size (#161)
* Do not expose nfa.nodes.size * Simpify proofs
1 parent 2e314f8 commit 47dfe20

32 files changed

Lines changed: 536 additions & 508 deletions

File tree

correctness/RegexCorrectness/Backtracker/Basic.lean

Lines changed: 40 additions & 40 deletions
Large diffs are not rendered by default.

correctness/RegexCorrectness/Backtracker/Compile.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ theorem capture_of_some_compile {s e pos update} (hres : captureNext (HistoryStr
3232
exact ⟨pos', pos'', groups, le, c, eqv⟩
3333

3434
theorem ne_done_of_path_of_none {s nfa wf pos} (hres : captureNext (HistoryStrategy s) nfa wf pos = .none) :
35-
∀ (pos' pos'' : Pos s) (state : Fin nfa.nodes.size) (update : List (Nat × Pos s)),
35+
∀ (pos' pos'' : Pos s) (state : Fin nfa.size) (update : List (Nat × Pos s)),
3636
pos ≤ pos' →
3737
Path nfa wf pos' pos'' state update →
3838
nfa[state] ≠ .done := by
3939
dsimp [captureNext] at hres
4040

4141
let bvpos : BVPos pos := ⟨pos, Pos.le_refl _⟩
42-
let visited := BitMatrix.zero nfa.nodes.size (pos.remainingBytes + 1)
42+
let visited := BitMatrix.zero nfa.size (pos.remainingBytes + 1)
4343

4444
have h := go.ne_done_of_path_of_none hres (BVPos.le_refl _) go.Inv.zero captureNextAux.NotDoneInv.zero
4545

@@ -55,7 +55,7 @@ theorem not_captures_of_none_compile {s e pos} (hres : captureNext (HistoryStrat
5555
intro c
5656
have ⟨update, _, path⟩ := NFA.path_of_captures_compile rfl c
5757

58-
let zero : Fin (NFA.compile e).nodes.size := ⟨0, NFA.lt_zero_size_compile rfl⟩
58+
let zero : Fin (NFA.compile e).size := ⟨0, NFA.lt_zero_size_compile rfl⟩
5959
have hne := ne_done_of_path_of_none hres pos' pos'' zero update le (Path.of_nfaPath (path.liftBound (by decide)))
6060
have hn := (NFA.done_iff_zero_compile (e := e) rfl zero).mpr (by simp [zero])
6161
exact hne hn

correctness/RegexCorrectness/Backtracker/Path.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ open Regex.Data (BVPos)
88

99
namespace Regex.Backtracker
1010

11-
inductive Path {s : String} (nfa : NFA) (wf : nfa.WellFormed) (pos : Pos s) : Pos s → Fin nfa.nodes.size → List (Nat × Pos s) → Prop where
11+
inductive Path {s : String} (nfa : NFA) (wf : nfa.WellFormed) (pos : Pos s) : Pos s → Fin nfa.size → List (Nat × Pos s) → Prop where
1212
| init : Path nfa wf pos pos ⟨nfa.start, wf.start_lt⟩ []
13-
| more {i j : Fin nfa.nodes.size} {pos' pos'' update₁ update₂ update₃} (prev : Path nfa wf pos pos' i update₁) (step : nfa.Step 0 i pos' j pos'' update₂)
13+
| more {i j : Fin nfa.size} {pos' pos'' update₁ update₂ update₃} (prev : Path nfa wf pos pos' i update₁) (step : nfa.Step 0 i pos' j pos'' update₂)
1414
(equpdate : update₃ = update₁ ++ List.ofOption update₂) :
1515
Path nfa wf pos pos'' j update₃
1616

1717
namespace Path
1818

19-
variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {pos pos' pos'' : Pos s} {i j : Fin nfa.nodes.size}
19+
variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {pos pos' pos'' : Pos s} {i j : Fin nfa.size}
2020
{update update₁ update₂ update₃ : List (Nat × Pos s)}
2121

2222
theorem le (path : Path nfa wf pos pos' i update) :
@@ -43,7 +43,7 @@ theorem nfaPath_of_ne (path : Path nfa wf pos pos' i update) (ne : i.val ≠ nfa
4343
nfa.Path 0 nfa.start pos i pos' update := by
4444
simpa [ne] using eq_or_nfaPath path
4545

46-
theorem concat_nfaPath {i j : Nat} (isLt : i < nfa.nodes.size)
46+
theorem concat_nfaPath {i j : Nat} (isLt : i < nfa.size)
4747
(path₁ : Path nfa wf pos pos' ⟨i, isLt⟩ update₁) (path₂ : nfa.Path 0 i pos' j pos'' update₂) (equpdate : update₃ = update₁ ++ update₂) :
4848
Path nfa wf pos pos'' ⟨j, path₂.lt_right wf⟩ update₃ := by
4949
induction path₂ generalizing update₁ with

correctness/RegexCorrectness/Backtracker/Refinement.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ theorem materializeStack.nil : materializeStack [] = ([] : List (StackEntry (Buf
2525
theorem materializeStack.cons {entryH stackH} :
2626
materializeStack (entryH :: stackH) = (StackEntry.materialize entryH :: materializeStack stackH : List (StackEntry (BufferStrategy s bufferSize) nfa startPos)) := rfl
2727

28-
def materializeResultAux (resultH : Option (List (Nat × Pos s)) × BitMatrix nfa.nodes.size (startPos.remainingBytes + 1)) : Option (Buffer s bufferSize) × BitMatrix nfa.nodes.size (startPos.remainingBytes + 1) :=
28+
def materializeResultAux (resultH : Option (List (Nat × Pos s)) × BitMatrix nfa.size (startPos.remainingBytes + 1)) : Option (Buffer s bufferSize) × BitMatrix nfa.size (startPos.remainingBytes + 1) :=
2929
⟨resultH.1.map (materializeUpdates bufferSize), resultH.2
3030

3131
def materializeResult (resultH : Option (List (Nat × Pos s))) : Option (Buffer s bufferSize) :=

correctness/RegexCorrectness/Backtracker/Traversal/Invariants.lean

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747
section
4848

4949
variable {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

5252
def 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

138138
theorem 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
157157
section
158158

159159
variable {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
172172
theorem 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

327327
namespace 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

333333
theorem 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
370370
section
371371

372372
variable {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

424424
section
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

433433
namespace 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

correctness/RegexCorrectness/Backtracker/Traversal/Lemmas.lean

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Regex.Backtracker
1010
namespace captureNextAux
1111

1212
variable {s : String} {nfa : NFA} {wf : nfa.WellFormed} {startPos : Pos s} {bvpos₀ bvpos : BVPos startPos}
13-
{visited : BitMatrix nfa.nodes.size (startPos.remainingBytes + 1)} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
13+
{visited : BitMatrix nfa.size (startPos.remainingBytes + 1)} {stack : List (StackEntry (HistoryStrategy s) nfa startPos)}
1414

1515
theorem mem_or_path_of_mem_of_none {result} (hres : captureNextAux (HistoryStrategy s) nfa wf startPos visited [⟨(HistoryStrategy s).empty, ⟨nfa.start, wf.start_lt⟩, bvpos⟩] = result)
1616
(isNone : result.1 = .none) :
@@ -27,7 +27,7 @@ theorem PathClosure.preserves {result} (hres : captureNextAux (HistoryStrategy s
2727

2828
theorem mem_of_path_of_none {result} (hres : captureNextAux (HistoryStrategy s) nfa wf startPos visited [⟨(HistoryStrategy s).empty, ⟨nfa.start, wf.start_lt⟩, bvpos⟩] = result)
2929
(isNone : result.1 = .none) (le₀ : bvpos₀ ≤ bvpos) (cls : PathClosure bvpos₀ visited)
30-
(bvpos' : BVPos startPos) (state : Fin nfa.nodes.size) (update : List (Nat × Pos s)) (path : Path nfa wf bvpos.current bvpos'.current state update) :
30+
(bvpos' : BVPos startPos) (state : Fin nfa.size) (update : List (Nat × Pos s)) (path : Path nfa wf bvpos.current bvpos'.current state update) :
3131
result.2.get state bvpos'.index := by
3232
have mem_start : result.2.get ⟨nfa.start, wf.start_lt⟩ bvpos.index := hres ▸ mem_stack_top ⟨(HistoryStrategy s).empty, ⟨nfa.start, wf.start_lt⟩, bvpos⟩ [] rfl
3333
match path.eq_or_nfaPath with
@@ -40,7 +40,7 @@ theorem mem_of_path_of_none {result} (hres : captureNextAux (HistoryStrategy s)
4040

4141
theorem mem_iff_mem_or_path_of_none {result} (hres : captureNextAux (HistoryStrategy s) nfa wf startPos visited [⟨(HistoryStrategy s).empty, ⟨nfa.start, wf.start_lt⟩, bvpos⟩] = result)
4242
(isNone : result.1 = .none) (le₀ : bvpos₀ ≤ bvpos) (cls : PathClosure bvpos₀ visited)
43-
(bvpos' : BVPos startPos) (state : Fin nfa.nodes.size) (le₀' : bvpos₀ ≤ bvpos') :
43+
(bvpos' : BVPos startPos) (state : Fin nfa.size) (le₀' : bvpos₀ ≤ bvpos') :
4444
result.2.get state bvpos'.index ↔ visited.get state bvpos'.index ∨ ∃ update, Path nfa wf bvpos.current bvpos'.current state update := by
4545
apply Iff.intro
4646
. intro mem
@@ -56,27 +56,27 @@ namespace captureNext.go
5656

5757
open captureNextAux (StackInv NotDoneInv PathClosure)
5858

59-
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)}
59+
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)}
6060

61-
structure Inv (wf : nfa.WellFormed) (bvpos₀ bvpos : BVPos startPos) (visited : BitMatrix nfa.nodes.size (startPos.remainingBytes + 1)) : Prop where
61+
structure Inv (wf : nfa.WellFormed) (bvpos₀ bvpos : BVPos startPos) (visited : BitMatrix nfa.size (startPos.remainingBytes + 1)) : Prop where
6262
closure : PathClosure bvpos₀ visited
63-
mem_iff_path : ∀ (state' : Fin nfa.nodes.size) (bvpos' : BVPos startPos),
63+
mem_iff_path : ∀ (state' : Fin nfa.size) (bvpos' : BVPos startPos),
6464
bvpos₀ ≤ bvpos' →
6565
(visited.get state' bvpos'.index ↔
6666
∃ (bvposPrev : BVPos startPos) (update : List (Nat × Pos s)),
6767
bvpos₀ ≤ bvposPrev ∧ bvposPrev < bvpos ∧ Path nfa wf bvposPrev.current bvpos'.current state' update)
6868

6969
namespace Inv
7070

71-
theorem zero : Inv wf bvpos₀ bvpos₀ (BitMatrix.zero nfa.nodes.size (startPos.remainingBytes + 1)) := by
71+
theorem zero : Inv wf bvpos₀ bvpos₀ (BitMatrix.zero nfa.size (startPos.remainingBytes + 1)) := by
7272
refine ⟨PathClosure.zero, ?_⟩
7373
simp only [BitMatrix.get_zero, Bool.false_eq_true, exists_and_left, false_iff, not_exists, not_and]
7474
intro _ _ _ bvpos le lt
7575
exact (BVPos.not_lt_of_le le lt).elim
7676

7777
theorem mem_iff_of_aux_none {result} (haux : captureNextAux (HistoryStrategy s) nfa wf startPos visited [⟨(HistoryStrategy s).empty, ⟨nfa.start, wf.start_lt⟩, bvpos⟩] = result)
7878
(isNone : result.1 = .none) (le₀ : bvpos₀ ≤ bvpos) (inv : Inv wf bvpos₀ bvpos visited)
79-
(state' : Fin nfa.nodes.size) (bvpos' : BVPos startPos) (le₀' : bvpos₀ ≤ bvpos') :
79+
(state' : Fin nfa.size) (bvpos' : BVPos startPos) (le₀' : bvpos₀ ≤ bvpos') :
8080
result.2.get state' bvpos'.index ↔
8181
(∃ (bvposPrev : BVPos startPos) (update : List (Nat × Pos s)), bvpos₀ ≤ bvposPrev ∧ bvposPrev < bvpos ∧ Path nfa wf bvposPrev.current bvpos'.current state' update) ∨
8282
∃ (update : List (Nat × Pos s)), Path nfa wf bvpos.current bvpos'.current state' update := by
@@ -95,7 +95,7 @@ theorem preservesAux {result} (haux : captureNextAux (HistoryStrategy s) nfa wf
9595
theorem mem_iff_path_of_aux_none_endBVPos {result}
9696
(haux : captureNextAux (HistoryStrategy s) nfa wf startPos visited [⟨(HistoryStrategy s).empty, ⟨nfa.start, wf.start_lt⟩, s.endBVPos startPos⟩] = result)
9797
(isNone : result.1 = .none) (inv : Inv wf bvpos₀ (s.endBVPos startPos) visited)
98-
(state' : Fin nfa.nodes.size) (bvpos' : BVPos startPos) (le₀' : bvpos₀ ≤ bvpos') :
98+
(state' : Fin nfa.size) (bvpos' : BVPos startPos) (le₀' : bvpos₀ ≤ bvpos') :
9999
result.2.get state' bvpos'.index ↔
100100
∃ (bvposPrev : BVPos startPos) (update : List (Nat × Pos s)), bvpos₀ ≤ bvposPrev ∧ Path nfa wf bvposPrev.current bvpos'.current state' update := by
101101
rw [inv.mem_iff_of_aux_none haux isNone bvpos₀.le_endBVPos state' bvpos' le₀']
@@ -114,7 +114,7 @@ end Inv
114114
theorem ne_done_of_path_of_none (hres : go (HistoryStrategy s) nfa wf startPos bvpos visited = .none)
115115
(le₀ : bvpos₀ ≤ bvpos)
116116
(inv : Inv wf bvpos₀ bvpos visited) (ndinv : NotDoneInv visited) :
117-
∀ (bvpos' bvpos'' : BVPos startPos) (state : Fin nfa.nodes.size) (update : List (Nat × Pos s)),
117+
∀ (bvpos' bvpos'' : BVPos startPos) (state : Fin nfa.size) (update : List (Nat × Pos s)),
118118
bvpos₀ ≤ bvpos' →
119119
Path nfa wf bvpos'.current bvpos''.current state update →
120120
nfa[state] ≠ .done := by
@@ -140,7 +140,7 @@ theorem ne_done_of_path_of_none (hres : go (HistoryStrategy s) nfa wf startPos b
140140
exact ndinv' state bvpos'' mem hn
141141

142142
theorem path_done_of_some {update} (hres : go (HistoryStrategy s) nfa wf startPos bvpos visited = .some update) :
143-
∃ (state : Fin nfa.nodes.size) (bvpos' bvpos'' : BVPos startPos),
143+
∃ (state : Fin nfa.size) (bvpos' bvpos'' : BVPos startPos),
144144
nfa[state] = .done ∧ bvpos ≤ bvpos' ∧ Path nfa wf bvpos'.current bvpos''.current state update := by
145145
induction bvpos, visited using go.induct' (HistoryStrategy s) nfa wf startPos with
146146
| found bvpos visited update visited' haux =>

correctness/RegexCorrectness/Display/NFADisplay.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ def nfaToSubstance (regex : Regex) : String := Id.run do
6262
Let TRUE := True()
6363
Let FALSE := False()
6464
"###
65-
for i in [0:regex.nfa.nodes.size] do
65+
for i in [0:regex.nfa.size] do
6666
sub := sub ++ createNode i
6767
if i > 0 then sub := sub ++ relateSuccessorNodes i
6868

6969
sub := sub ++ declareStartNode regex.nfa.start
7070

71-
for h : i in [0:regex.nfa.nodes.size] do
72-
let node := regex.nfa.nodes[i]
71+
for h : i in [0:regex.nfa.size] do
72+
let node := regex.nfa[i]
7373
match node with
7474
| .done =>
7575
sub := sub ++ labelNode i "done"

0 commit comments

Comments
 (0)