Iterating a probabilistic oracle machine while its result is non-empty #
tm.iterateWhile mark applies the tidy probabilistic oracle machine tm to its input, then to
the result, and so on, until tm produces the empty word, and then outputs the last word before
the empty one. The machine keeps the current word on one work tape and the next word on another.
A round copies the next word to the current tape and computes the new next word from it with tm.
Rounds are repeated by Turing.MultiTapePTM.repeatUntilBlank until the next word is empty.
The tape layout helpers are module-private, as in the deterministic construction.
Each round makes exactly the oracle calls of tm on the current word, with the external oracle
state left by the previous round. The final round's program returns the empty word, and the loop
then halts; no further round is executed.
Main definitions #
Turing.MultiTapePTM.iterateWhileRound: one round of the iteration.Turing.MultiTapePTM.iterateWhile: the iterating machine.
Main results #
Turing.MultiTapePTM.ComputesTidily.iterateWhile: iftmtidily computesstep wfrom every wordwreached in the firstrrounds and the empty word in roundr, thentm.iterateWhile marktidily computesOracleComp.iterate r step, preserving the joint law of the result and the external oracle state.
References #
Adapts Combinators/IterateWhile (vendored crei:crei/tidy-universal @7f7c0696), by Christian
Reitwiessner, and cslib's Plumbing/RepeatUntilBlank to probabilistic oracle machines.
The tapes #
The deterministic phases #
The states of Turing.MultiTapePTM.IterateWhile.prepareRound.
Instances For
The states of Turing.MultiTapePTM.IterateWhile.finish.
Instances For
The machine #
One round: move the next word to the current tape, then apply tm from the current tape to
the next tape, using mark to flag the left end of words.
Instances For
tm, applied repeatedly while its result is non-empty, using mark to flag the left end of
words: load the input to the next tape, repeat rounds until the next tape is empty, then output
the current word and clear its tape.
Instances For
If tm tidily computes step w within t steps from every word w reached after n < r
rounds, and the empty word from every word reached after r rounds, all these words having length
at most L, then tm.iterateWhile mark tidily computes OracleComp.iterate r step. Each round
makes exactly the oracle calls of tm on its word, with the external oracle state left by the
previous round, and no round follows the one producing the empty word.