pairBuildTM: construct pair x y on a work tape #
The DTM pairBuildTM k yIdx pIdx assumes:
xlives on the input tape (standard layout: head 0 on ▷,xin cells 1..|x|, blanks beyond),ylives on work tapeyIdx(same layout: head 0 on ▷,yin cells 1..|y|, blanks beyond),- work tape
pIdxis the emptyTape.init [].
After running, work tape pIdx carries pair x y — the doubled-bits
encoding of x followed by the [false, true] separator followed by
y verbatim — with head positioned at cell 1, matching the convention
used by the other rewindWorkTM-based subroutines.
Phase structure #
init advance every ▷-reading tape past ▷ (one step)
copyX1 if input blank → writeSep1; else write bit to pIdx, advance pIdx
copyX2 write the same bit to pIdx, advance input *and* pIdx
writeSep1 write `false` to pIdx, advance pIdx
writeSep2 write `true` to pIdx, advance pIdx
copyY if y blank → rewindP1; else write y-bit to pIdx, advance y+pIdx
rewindP1 if pIdx reads ▷ → rewindP2; else move pIdx left
rewindP2 one extra right step, transition to done (leaves pIdx head=1)
done halt
Total running time: linear in |x| + |y| (see pairBuildTM_hoareTime).
Status #
Everything in this file is fully proved (no sorry). The main contents:
- Machine:
pairBuildTM(withδ_right_of_start), the phase typePairBuildPhase, and the running-time boundpairBuildTime. - Init-step variants for phase composition:
pairBuild_init_step_started(pair tape still fresh at head 0) andpairBuild_init_step_all_started(all tracked tapes already past▷). - Tape helper:
Tape.eq_init_move_right_of_binary, identifying a head-1 binary tape with a standardTape.initmoved right once. - Main correctness:
pairBuildTM_hoareTime, aHoareTimetriple stating that fromxon the input tape,yon work tapeyIdx, and an empty work tapepIdx, the machine halts withinpairBuildTime |x| |y|steps withpair x yon tapepIdx. - Corollaries:
pairBuildTM_hoareTime_initTape_move_right(the pair tape equalsTape.initof the encoding moved right once),pairBuildTM_hoareTime_all_started_initTape_move_right(same, from the all-started layout), its NTM liftpairBuildTM_toNTM_hoareTime_all_started_initTape_move_right, andpairBuildTM_hoareTime_hasOutput(Tape.HasOutputform). - Frame lemmas for NTM traces:
pairBuildTM_trace_one_preserves_output/pairBuildTM_trace_preserves_output(the output tape is untouched) andpairBuildTM_trace_one_preserves_other_work/pairBuildTM_trace_preserves_other_work(work tapes other thanyIdxandpIdxare untouched), each assuming the tape's head is past▷.
Control states of pairBuildTM, one per phase of the construction:
advance past ▷ (init), double each input bit onto the pair tape
(copyX1/copyX2), write the [false, true] separator
(writeSep1/writeSep2), copy the witness verbatim (copyY), rewind
the pair tape to cell 1 (rewindP1/rewindP2), and halt (done).
- init : PairBuildPhase
- copyX1 : PairBuildPhase
- copyX2 : PairBuildPhase
- writeSep1 : PairBuildPhase
- writeSep2 : PairBuildPhase
- copyY : PairBuildPhase
- rewindP1 : PairBuildPhase
- rewindP2 : PairBuildPhase
- done : PairBuildPhase
Instances For
Equations
- One or more equations did not get rendered due to their size.
Build pair x y on work tape pIdx, reading x from the input tape
and y from work tape yIdx. Requires yIdx ≠ pIdx for the
construction to make sense; the definition itself is valid for any
indices.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Variant of the init step for phase composition: input and witness tapes may already be positioned at their first data cells, while the pair tape is still the fresh head-0 tape.
Variant of the init step for fully-started phase composition: input,
witness, and pair tapes may all already be positioned past ▷.
Running-time bound: pairBuildTM finishes in 4·|x| + 2·|y| + 10 steps.
Breakdown:
init: 1 step.copyX1+copyX2: 2·|x| + 1 steps (one finalcopyX1detects blank).writeSep1+writeSep2: 2 steps.copyY: |y| + 1 steps.rewindP1: one step per cell left from2|x|+2+|y|+1to0, so2|x|+|y|+3steps; plus therewindP2step; plus thedonetransition step.
Instances For
A tape with head at cell 1, a start marker at cell 0, binary contents
bits, and a blank tail is exactly the standard initialized tape for
bits, moved right once.
pairBuildTM correctness. Given x on the input tape and y on
work tape yIdx (with yIdx ≠ pIdx), pairBuildTM yIdx pIdx halts
leaving work tape pIdx carrying pair x y (in the cells indexed
1..|pair x y|), blank thereafter, with head at cell 1, within
pairBuildTime steps.
A compact corollary of pairBuildTM_hoareTime: the pair tape satisfies
exact equality with the standard initialized pair tape, moved to cell 1.
pairBuildTM correctness for phase composition where input, witness,
and pair tapes have already passed the start marker. This is the layout
produced by earlier setup phases that idle untouched tapes once from ▷
to cell 1.
Nondeterministic lift of
pairBuildTM_hoareTime_all_started_initTape_move_right.
One pair-builder step preserves a non-active work tape once that tape's head is past the start marker.
Pair-builder traces preserve a non-active work tape once that tape's head is past the start marker.
A compact corollary of pairBuildTM_hoareTime: the pair tape satisfies
the standard Tape.HasOutput predicate for pair x y.