Running a second fair-coin machine when the first does not accept #
first.orElse second runs first on its own block of work tapes, with its output suppressed and
summarized in the control state by Turing.MultiTapeNTM.outputClass. If first halts with
output [true], the machine outputs true and halts. Otherwise it moves the input head back to
the first input symbol and runs second on a separate, blank block of work tapes, with fresh coins.
One more work tape holds a flag recording that first accepted; the two phases are joined by
Turing.MultiTapePTM.seq. Both machines use the Boolean alphabet and no oracle channels.
If first and second halt on every branch within t₁ and t₂ steps on an input of length n,
then first.orElse second halts on every branch within t₁ + (n + 2 + t₂) steps: rewinding the
input head takes at most n + 2 steps. Its output distribution is that of the program "run
first; if it outputs [true], output [true], and otherwise run second". Since both phases
halt, this is exact, not a bound. Every work-tape head stays within the cells that first or
second alone would use, so a space bound for both machines gives one for the combination.
The phases are analysed through two general rules for fair-coin machines without oracle channels: a map of configurations commuting with each coin's step maps the configuration distribution, and a step that ignores its coin is taken with certainty.
Main definitions #
Turing.MultiTapePTM.orElse: runsecondiffirstdoes not accept.
Main results #
Turing.MultiTapePTM.runClosedConfigFromCoins_map,Turing.MultiTapePTM.eval_runClosedConfigFrom_map: one-step simulation of coin replays and of configuration distributions.Turing.MultiTapePTM.eval_runClosedConfigFrom_succ_of_step: a step that does not depend on the coin is taken with certainty.Turing.MultiTapePTM.step_withCoin_seq_left,Turing.MultiTapePTM.step_withCoin_seq_right: steps of a sequential machine under a fixed coin.Turing.MultiTapePTM.orElse_halted: the combined halting time.Turing.MultiTapePTM.eval_runClosed_orElse: the output distribution.Turing.MultiTapePTM.runsInSpace_toNTM_orElse: the space bound of the nondeterministic view.
References #
Repeating a one-sided-error algorithm and accepting when some run accepts is the standard error
reduction for one-sided error Arora and Barak, Section 7.4.1; see
Cslib.Complexity.mem_RL_iff_error_le for its use in randomized logarithmic space.
A map of configurations that commutes with each coin's step commutes with every replay.
One-step simulation. A map of configurations that commutes with each coin's step maps the closed configuration distribution.
A step that does not depend on the coin is taken with certainty.
With a fixed coin, a running first phase of a sequential machine steps as the first machine.
With a fixed coin, the second phase of a sequential machine steps as the second machine.
Tape layout #
Output classes #
The first phase #
The second phase #
Run a second machine if the first does not accept. The machine runs first on its own
work tapes, with its output suppressed and summarized in the control state. If first halts
with output [true], it outputs true and halts. Otherwise it moves the input head back to the
first input symbol and runs second on fresh work tapes, with fresh coins. One additional work
tape holds a flag recording the outcome of first.
Instances For
Space #
Space of first.orElse second. If every computation path of first and of second
visits at most s₁ and s₂ work-tape cells, then every head of the combined machine stays in the
window [-max s₁ s₂, max s₁ s₂], so each of its k₁ + k₂ + 1 work tapes uses at most
2 * max s₁ s₂ + 1 cells.
first.orElse second halts on every branch within t₁ + (n + 2 + t₂) steps when first
halts within t₁ and second within t₂ steps, where n is the input length.
The output distribution of first.orElse second: run first; if it outputs [true],
output [true], and otherwise run second with fresh coins. Both machines must halt on every
branch within their clocks.