The counting loop's test #
⚠️ Unreviewed by Bolton
TM.loopTM stops when its test machine leaves 1 in the output tape's verdict cell. The
counting loop stops when its counter reaches the horizon, so its test compares the counter
against a register holding that horizon and publishes the answer.
The comparison itself is TM.binaryEqTM, which deposits its verdict as a bit on a scratch work
tape and leaves the output alone; the remaining three stages move that bit where the loop can see
it. Two of them exist only because of where heads end up: TM.binaryEqTM leaves its operands'
heads wherever the scan stopped, and TM.writeOutputBitTM publishes whatever is under a head,
so the operands must be rewound before the verdict can be read off.
Main results #
TM.testTailTM— rewind, publish the verdict, clear the scratch bitTM.testTailTM_hoareTime— its contract, through fully pinned tape statesTM.tallyTestTM,TM.tallyTestTM_hoareTime— the whole test, leaving its bank as it found itNTM.tallyTestTM_hoareTime_tallyPost— the same contract in the shapeNTM.tallyLoop_hoareTime_of_hoareasks forTM.Parked.write_ne_start— a frame fact the assembly needs
The work bank after every compared tape has been rewound to cell one.
Equations
- Complexity.TM.rewoundBank cIdx nIdx resIdx W j = if j ∈ Complexity.TM.testTargets cIdx nIdx resIdx then { head := 1, cells := (W j).cells } else W j
Instances For
The tail of the counting loop's test. Rewind the compared tapes, publish the scratch bit onto the output, then clear the scratch tape for the next iteration.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The contract of the test's tail. From a bank in which the compared tapes carry their markers and the scratch tape carries the verdict bit, the three stages land on a fully named bank — every compared tape at cell one, the scratch tape blank — with the verdict on the output.
The counting loop's test. Compare the counter against the horizon register, then move
the verdict where TM.loopTM looks for it.
Equations
- Complexity.TM.tallyTestTM cIdx nIdx resIdx = (Complexity.TM.binaryEqTM cIdx nIdx resIdx).seqTM (Complexity.TM.testTailTM cIdx nIdx resIdx)
Instances For
The test's contract. The bank comes back exactly as it went in — the comparison is non-destructive and the scratch tape is cleared — and the output gains the verdict bit.
The blank verdict slot is the blank tape — the same object under two names, which is what lets the wipe's precondition and the loop's invariant meet.
Reading a cell back as a writable symbol turns it into 1 exactly when it was 1.
The body's publishing stage. With the verdict tape rewound to cell one, its symbol is
copied into the output slot, where TM.ifTM can branch on it.
The counting loop's test meets its obligation. With the horizon parked on nIdx and a
blank scratch tape on resIdx, TM.tallyTestTM carries the state the body leaves — the bank at
index w and a blank verdict slot — to NTM.tallyPost at that index.