Searching a block-aligned string for a block #
⚠️ Unreviewed by Bolton
A search that keeps its visited set as a run of fixed-width records must be able to ask whether a record is already there. This file supplies that test as a polynomial-time function: one scan, one block per step, accumulating a flag.
The scan is written as an iteration rather than a recursion, because that is the
shape Cobham.iterate_mem_FP consumes — the state is a packed
pair (pair u f) rest, and one step compares u against the leading block of
rest and drops it.
Main definitions #
Complexity.scanStep— one step of the scan, on the unpacked stateComplexity.memStep— the same on the packed stateComplexity.memFlag— the verdict of a full scan
Main results #
Complexity.memStep_iterate— the packed iteration tracks the unpacked oneComplexity.memFlag_eq_true_iff— what the scan decides
The scan, on the unpacked state #
One step of the membership scan: compare u against the leading record.
Equations
Instances For
The scan, packed #
The packed scan state: the ruler, then the sought block, the flag and the
remaining string. Everything the step needs travels inside the state, which is
what Cobham.iterate_mem_FP iterates.
Equations
- Complexity.memPack R u f rest = Complexity.pair R (Complexity.pair (Complexity.pair u f) rest)
Instances For
The verdict #
Does the block u occur in the block-aligned string V?