The tape of Savitch's stack machine #
⚠️ Unreviewed by Bolton
Savitch's procedure is a recursion of polynomial depth, so it is a stack machine whose stack is polynomially bounded. This file fixes how that stack is written on a single bitstring, and gives every field's reader and writer inside the polynomial-time algebra.
A frame carries the subproblem a level of the recursion is working on:
kind—[false]for isvreachable fromu,[true]for is some accepting configuration reachable fromu;ph—[false]while the first half of the interval is being tried,[true]while the second is;lvl— the level, in unary:2 ^ |lvl|steps are allowed;u,v— the two endpoints (vis unused by an acceptance frame);m— the midpoint being tried, which doubles as the enumeration's counter.
A stack is a right-nested chain of pairs, empty stack being the empty string;
pair is never empty, so the two are told apart by a single flag.
The state carries the done flag (which is the bit Complexity.SpaceIter
watches), the answer, the block ruler the codes are written against, the value a
finished subcall is returning ([] while descending), and the stack.
Main definitions #
Complexity.mkFrameandComplexity.frKind, … — a frame and its fieldsComplexity.encStack,Complexity.stkTop,Complexity.stkRest— the stackComplexity.mkStandComplexity.stDone, … — the state and its fields
Main results #
- the
_mksimp lemmas — every reader inverts the constructor Complexity.mkFrameFn_mem_FP,Complexity.mkStFn_mem_FP, and the readers' — all of it is inFP
Frames #
A frame of Savitch's recursion.
Equations
- Complexity.mkFrame kind ph lvl u v m = Complexity.pair kind (Complexity.pair ph (Complexity.pair lvl (Complexity.pair u (Complexity.pair v m))))
Instances For
Which subproblem the frame is working on.
Equations
Instances For
Which half of the interval the frame is trying.
Equations
Instances For
The frame's level, in unary.
Equations
Instances For
The frame's source endpoint.
Equations
Instances For
The frame's target endpoint.
Equations
Instances For
The midpoint the frame is trying.
Equations
Instances For
Stacks #
A stack of frames, top first.
Equations
- Complexity.encStack [] = []
- Complexity.encStack (f :: fs) = Complexity.pair f (Complexity.encStack fs)
Instances For
The frame on top of the stack.
Equations
Instances For
The stack below the top frame.
Equations
Instances For
The state #
The machine's state: the done flag, the answer, the block ruler, the value a finished subcall is returning, and the stack.
Equations
- Complexity.mkSt d a R ret stk = Complexity.pair d (Complexity.pair a (Complexity.pair R (Complexity.pair ret stk)))
Instances For
The done flag — the bit the iteration watches.
Equations
Instances For
The answer, once the recursion has produced one.
Equations
Instances For
The block ruler the configuration codes are written against.
Equations
Instances For
The value a finished subcall is returning; [] while descending.
Equations
Instances For
The stack.