The transition table of the simulating machine #
The control of the machine M(c) of PCP-HARDNESS.md §2.8, as one
deterministic step function
DescriptiveComplexity.HaltHard.simStep : SimQ c → SimSym c → Option (SimSym c × SimQ c × Bool)
(the Boolean is “move right”). Determinism is what makes the backward
direction of the simulation a case analysis rather than an invariant hunt,
and the drawn machine's transition relations are read off the graph of this
function.
The tape layout is the one of Tags.lean: frames left of the fixed
separator mid, bounded by the movable endL; the value mirrored right
of mid, its head block ending at the movable endR, so that every
operation on the head of the value works at endR and grows into the blank
half-tape – no marker ever crosses a letter. The states fall into walk
families between the unique letters endL/mid/endR/headers:
retL/retR– seek the top frame (or accept onmid);retLdoubles as the start state, the head starting onendL;nSeekL p/nSeekR p– walk tomidand dispatch on the shape ofcodeAt p;zGo/zEnd–zero': append a separator atendR;suScan/suE₁/suE₂/suGo/suEnd/suBack/suKill–succ: append a digit (a separator and a digit, if the value was empty), then erase every block but the head one;tlGo/tlLook/tlOnes/tlRest–tail: erase the head block atendR;caGo p/caLook p/caRest p–case: inspect and consume the head atendR, then dispatch a child;cpFetch p/cpCar₁ p/cpCarC p/cpEndS p/cpBack p/cpHdr p/cpHdrS p/cpUnp p/cpUnp₂ p– the one non-destructive copy (theconspush), priming letters and writing atendLby the endL-shift;coHdr p/coHdrS p,fiHdr p/fiHdrS p– the bare header pushes;fxGo p/fxLook p/fxOnes p/fxRest p/fxDropL/fxDropR– thefixpop: inspect the flag atendR, then keep or drop the frame;swGo/swPeek/swCar₁/swCarC/swEndS/swRest/swHdr/swHdrS/swOut/swScan/swLast/swApp₁/swAppC/swAppS/swBack– thecons₁pop: move the value into a freshcons₂frame (consuming it atendR, so the frame stores it mirrored), then move the stored value out (consuming the frame at its right end, so the value region gets it mirrored);ppGo/ppShift/ppBack/ppFind/ppScan/ppLast/ppCar/ppCarS/ppKill– thecons₂pop: append a separator, transfer the digits of the frame's head block (sitting at the frame's right end, since the frame is mirrored), and discard the rest.
The states of the simulating machine; see the module docstring for the role of each family.
- retL
{c : Turing.ToPartrec.Code}
: SimQ c
Walk left to
endL, then look for the top frame. - retR
{c : Turing.ToPartrec.Code}
: SimQ c
Walk right over the gap to the top frame; accept on
mid. - acc
{c : Turing.ToPartrec.Code}
: SimQ c
The accepting state.
- nSeekL
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
Walk left to
midand dispatchstepNormal (codeAt p). - nSeekR
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
Walk right to
midand dispatchstepNormal (codeAt p). - zGo
{c : Turing.ToPartrec.Code}
: SimQ c
zero': walk right toendR. - zEnd
{c : Turing.ToPartrec.Code}
: SimQ c
zero': re-writeendRone cell right of the appended separator. - suScan
{c : Turing.ToPartrec.Code}
: SimQ c
succ: frommid, look whether the value is empty. - suE₁
{c : Turing.ToPartrec.Code}
: SimQ c
succon an empty value: a separator is appended; write the digit. - suE₂
{c : Turing.ToPartrec.Code}
: SimQ c
succon an empty value: re-writeendR. - suGo
{c : Turing.ToPartrec.Code}
: SimQ c
succ: walk right toendR. - suEnd
{c : Turing.ToPartrec.Code}
: SimQ c
succ: re-writeendRone cell right of the appended digit. - suBack
{c : Turing.ToPartrec.Code}
: SimQ c
succ: walk left over the head block's digits. - suKill
{c : Turing.ToPartrec.Code}
: SimQ c
succ: erase everything between the head block andmid. - tlGo
{c : Turing.ToPartrec.Code}
: SimQ c
tail: walk right toendR. - tlLook
{c : Turing.ToPartrec.Code}
: SimQ c
tail: look at the last letter of the value. - tlOnes
{c : Turing.ToPartrec.Code}
: SimQ c
tail: erase the head block's digits, then landendRon its separator. - tlRest
{c : Turing.ToPartrec.Code}
: SimQ c
tailon an empty value: re-write the erasedendR. - caGo
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
case: walk right toendR. - caLook
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
case: look at the last letter of the value. - caRest
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
caseon an empty value: re-write the erasedendR. - cpFetch
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: find the next unprimed letter of the value. - cpCar₁
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: carry a digit toendL. - cpCarC
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: carry a separator toendL. - cpEndS
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: re-writeendLone cell left. - cpBack
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: walk right back tomidbefore resuming the scan. - cpHdr
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: walk left toendLto write the frame header. - cpHdrS
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: re-writeendLleft of the header. - cpUnp
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: walk right tomidbefore unpriming. - cpUnp₂
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
conspush: unprime the copied value. - coHdr
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
comppush: walk left toendL. - coHdrS
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
comppush: re-writeendLleft of the header. - fiHdr
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
fixpush: walk left toendL. - fiHdrS
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
fixpush: re-writeendLleft of the header. - fxGo
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
fixpop: walk right toendR. - fxLook
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
fixpop: look at the last letter of the value. - fxOnes
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
fixpop, nonzero flag: erase the head block's digits. - fxRest
{c : Turing.ToPartrec.Code}
: CPos c → SimQ c
fixpop on an empty value: re-write the erasedendR. - fxDropL
{c : Turing.ToPartrec.Code}
: SimQ c
fixpop, zero flag: walk left toendLto drop the frame. - fxDropR
{c : Turing.ToPartrec.Code}
: SimQ c
fixpop, zero flag: walk right to the frame header and erase it. - swGo
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: walk right toendR. - swPeek
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: look at the last letter of the value. - swCar₁
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: carry a digit toendL. - swCarC
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: carry a separator toendL. - swEndS
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: re-writeendLone cell left. - swRest
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: the value is spent; re-write the erasedendR. - swHdr
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: walk left toendLto write thecons₂header. - swHdrS
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: re-writeendLleft of the header. - swOut
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: walk right to the old frame's header. - swScan
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: walk right over the old frame's content. - swLast
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: consume the old frame's last letter. - swApp₁
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: carry a digit toendR. - swAppC
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: carry a separator toendR. - swAppS
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: re-writeendRone cell right. - swBack
{c : Turing.ToPartrec.Code}
: SimQ c
cons₁pop: walk left toendLbefore re-entering the frame. - ppGo
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: walk right toendRto append the separator. - ppShift
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: re-writeendRone cell right. - ppBack
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: walk left toendL. - ppFind
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: walk right over the gap to the frame. - ppScan
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: walk right over the frame's content. - ppLast
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: consume the frame's last letter. - ppCar
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: carry a digit toendR. - ppCarS
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: re-writeendRone cell right. - ppKill
{c : Turing.ToPartrec.Code}
: SimQ c
cons₂pop: erase the spent frame.
Instances For
Dependency graph
Dependency graph
The states are finitely many: CPos c is finite and every family is
indexed by at most one position.
Dependency graph
The dispatch of stepNormal (codeAt p), with the head reading mid:
the first action of each shape's handler.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The deterministic step table (none = no move; the Boolean is “move
right”). The docstring of the file names each family; within a family the
letter-specific actions come first and the walk catch-alls after.