Documentation

CslibFrontier.Computability.Complexity.Classes.LogSpace.Randomized.Amplification

Amplification for randomized logarithmic space with one-sided error #

Running an RL machine again on fresh coins when it does not accept (Turing.MultiTapePTM.orElse) multiplies the probabilities of not accepting. Counted on coin strings, the probability that first.orElse second does not accept is the product of those of first and second (Turing.MultiTapePTM.acceptCoins_orElse); in particular it accepts nothing when neither machine accepts anything. Repeating an RL machine r + 1 times therefore accepts members on at least a 1 - 2 ^ (-r) fraction of the coin strings and non-members on none, in logarithmic space and with every branch halting. Only a fixed number of repetitions is needed, so the extra work tapes and control states are a constant overhead.

This is the error reduction for one-sided error Arora and Barak, Section 7.4.1, carried out for logspace fair-coin machines with read-once coins. The acceptance threshold 1/2 in the definition of Cslib.Complexity.RL can be replaced by any threshold 1 - 2 ^ (-r) with r ≥ 1 (Cslib.Complexity.mem_RL_iff_error_le); with r = 2, members are accepted with probability at least 3/4 ≥ 2/3, which gives RL ⊆ BPL.

Main results #

References #

theorem Turing.MultiTapePTM.runsInTime_toNTM_iff {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) {input : List Bool} {t : ℕ} :
machine.toNTM.RunsInTime input t ↔ ∀ final ∈ (machine.runClosedConfigFrom t (MultiTapeMachine.initialConfig machine input)).eval.support, final.tapes.state = none

Halting on every branch, in distribution. The nondeterministic view halts within t steps exactly when every configuration supported by the closed fair-coin run with clock t is halted.

theorem Turing.MultiTapePTM.acceptCoins_eq_mul_eval {k : ℕ} {State : Type} (machine : MultiTapePTM k Bool State) {input : List Bool} {t : ℕ} (ht : machine.toNTM.RunsInTime input t) :
↑(machine.acceptCoins input t) = 2 ^ t * (machine.runClosed t input).eval [true]

The accepting coin strings measure the acceptance probability: once every branch halts within t steps, acceptCoins input t / 2 ^ t is the probability that the closed fair-coin run outputs [true].

theorem Turing.MultiTapePTM.runsInTime_toNTM_orElse {k₁ k₂ : ℕ} {S₁ S₂ : Type} (first : MultiTapePTM k₁ Bool S₁) (second : MultiTapePTM k₂ Bool S₂) {input : List Bool} {t₁ t₂ : ℕ} (h₁ : first.toNTM.RunsInTime input t₁) (h₂ : second.toNTM.RunsInTime input t₂) :
(first.orElse second).toNTM.RunsInTime input (t₁ + (input.length + 2 + t₂))

first.orElse second halts on every branch within t₁ + (n + 2 + t₂) steps, where n is the input length.

theorem Turing.MultiTapePTM.eval_runClosed_orElse_apply {k₁ k₂ : ℕ} {S₁ S₂ : Type} (first : MultiTapePTM k₁ Bool S₁) (second : MultiTapePTM k₂ Bool S₂) {input : List Bool} {t₁ t₂ : ℕ} (h₁ : first.toNTM.RunsInTime input t₁) (h₂ : second.toNTM.RunsInTime input t₂) :
((first.orElse second).runClosed (t₁ + (input.length + 2 + t₂)) input).eval [true] = (second.runClosed t₂ input).eval [true] + (first.runClosed t₁ input).eval [true] * (1 - (second.runClosed t₂ input).eval [true])

The acceptance probability of first.orElse second is q + p * (1 - q), where p and q are those of first and second.

theorem Turing.MultiTapePTM.acceptCoins_orElse {k₁ k₂ : ℕ} {S₁ S₂ : Type} (first : MultiTapePTM k₁ Bool S₁) (second : MultiTapePTM k₂ Bool S₂) {input : List Bool} {t₁ t₂ : ℕ} (h₁ : first.toNTM.RunsInTime input t₁) (h₂ : second.toNTM.RunsInTime input t₂) :
(2 ^ (t₁ + (input.length + 2 + t₂)) - (first.orElse second).acceptCoins input (t₁ + (input.length + 2 + t₂))) * (2 ^ t₁ * 2 ^ t₂) = (2 ^ t₁ - first.acceptCoins input t₁) * (2 ^ t₂ - second.acceptCoins input t₂) * 2 ^ (t₁ + (input.length + 2 + t₂))

Rejections multiply under orElse. Counted on coin strings, the probability that first.orElse second does not accept is the product of the probabilities that first and second do not accept: with T = t₁ + (n + 2 + t₂), (2 ^ T - acc) / 2 ^ T = (2 ^ t₁ - acc₁) / 2 ^ t₁ * (2 ^ t₂ - acc₂) / 2 ^ t₂.

theorem Cslib.Complexity.mem_RL_iff_error_le {α : Type} {enc : α ↪ List Bool} {A : Set α} {r : ℕ} (hr : 1 ≤ r) :
A ∈ RL enc ↔ ∃ (k : ℕ) (State : Type) (_ : Finite State) (M : Turing.MultiTapePTM k Bool State) (c : ℕ), ∀ (a : α), M.toNTM.RunsInSpace (enc a) (c * ((enc a).length.log2 + 1)) ∧ ∃ (t : ℕ), M.toNTM.RunsInTime (enc a) t ∧ (a ∈ A → (2 ^ r - 1) * 2 ^ t ≤ 2 ^ r * M.acceptCoins (enc a) t) ∧ (a ∉ A → M.acceptCoins (enc a) t = 0)

One-sided error amplification for RL Arora and Barak, Section 7.4.1: for every r ≥ 1, a language is in RL exactly when some logspace fair-coin machine that halts on every branch accepts members on at least a 1 - 2 ^ (-r) fraction of the coin strings and non-members on none. The machine for r runs an RL machine r + 1 times on fresh work tapes and fresh coins and accepts if some run accepts (Turing.MultiTapePTM.orElse).

theorem Cslib.Complexity.RL_subset_BPL {α : Type} {enc : α ↪ List Bool} :
RL enc ⊆ BPL enc

RL is within BPL: amplifying an RL machine to error at most 1/4 gives acceptance probability at least 3/4 ≥ 2/3 on members, and 0 ≤ 1/3 on non-members.