Finite-state scanners for the structured RAM frontend #
Scanner.Spec describes a finite automaton using numeric state codes. The
compiler below realizes it as a table-driven structured RAM program. The state
bound and transition-closure fields are the complete trusted interface needed by
the generic correctness and resource proof.
A total finite-state Boolean scanner with contiguous numeric state codes.
- stateCount : ℕ
Number of valid state codes.
- initial : ℕ
Initial state code.
The initial code is valid.
One state transition.
- step_lt (state : ℕ) : state < self.stateCount → ∀ (bit : Bool), self.step state bit < self.stateCount
Transitions preserve valid state codes.
Final Boolean verdict.
Instances For
A scanner specification over an explicitly enumerable Lean state type.
FinEnum retains a concrete equivalence with an initial segment of natural
numbers, so lowering remains executable while consumers reason using their
domain-specific state type.
- initial : State
Initial typed state.
- step : State → Bool → State
One typed state transition.
- accept : State → Bool
Final Boolean verdict.
Instances For
Numeric state code chosen by the explicit enumeration.
Equations
- Complexity.RAM.Structured.Scanner.TypedSpec.code state = ↑(FinEnum.equiv state)
Instances For
Remaining input length and final verdict register.
Equations
Instances For
Current numeric automaton state.
Equations
Instances For
Address of the next input bit.
Equations
Instances For
Constant-one register.
Equations
Instances For
Current input bit.
Equations
Instances For
Scratch address used for table lookups.
Equations
Instances For
Constant-two register.
Equations
Instances For
Register containing the transition-table base address.
Instances For
Register containing the verdict-table base address.
Equations
Instances For
First transition-table register.
Instances For
First verdict-table register.
Equations
Instances For
First input register.
Equations
Instances For
Address of one transition-table entry.
Equations
Instances For
Address of one verdict-table entry.
Equations
- Complexity.RAM.Structured.Scanner.acceptAddress spec state = Complexity.RAM.Structured.Scanner.acceptBase spec + state
Instances For
The six fixed setup destinations below the tables.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Every table destination, in increasing order.
Equations
Instances For
Every setup destination.
Equations
Instances For
Value written to one setup destination.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Straight-line setup instruction list.
Equations
- Complexity.RAM.Structured.Scanner.setupOps spec = List.map (fun (write : ℕ × ℕ) => Complexity.RAM.Structured.Basic.imm write.1 write.2) (Complexity.RAM.Structured.Scanner.setupWrites spec)
Instances For
Initialize constants and transition/verdict tables.
Equations
Instances For
Seven-instruction scanner body, independent of the particular automaton.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Consume one input bit and update the encoded automaton state.
Equations
Instances For
Two-instruction final verdict lookup.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Write the final verdict to R₀.
Equations
Instances For
Complete structured scanner.
Equations
Instances For
Concrete compiled RAM scanner.
Equations
Instances For
Exact compiled transition count.
Equations
- Complexity.RAM.Structured.Scanner.stepCount spec inputLength = 9 + 3 * spec.stateCount + 9 * inputLength
Instances For
Explicit logarithmic-cost time budget.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Explicit peak-space budget.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Shifted quasilinear comparison function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Input store for a typed scanner.
Equations
Instances For
Structured RAM program generated from a typed scanner.
Equations
- typed.program = Complexity.RAM.Structured.Scanner.program typed.numeric
Instances For
Concrete RAM program generated from a typed scanner.
Equations
- typed.compiled = Complexity.RAM.Structured.Scanner.compiled typed.numeric
Instances For
Explicit logarithmic-time budget for a typed scanner.
Equations
- typed.timeBound = Complexity.RAM.Structured.Scanner.timeBound typed.numeric
Instances For
Explicit peak-space budget for a typed scanner.
Equations
Instances For
Shifted quasilinear comparison function for a typed scanner.