Documentation

CslibFrontier.Computability.Complexity.Classes.RelaxedError

Error thresholds of BPP, RP and ZPP #

The thresholds 2 / 3 of BPP (Cslib.Complexity.BPP) and 1 / 2 of RP and ZPP (Cslib.Complexity.RP, Cslib.Complexity.ZPP) can be replaced by any threshold that is inverse-polynomially better than a coin flip, and by thresholds exponentially close to certainty. The relaxed classes take the threshold as a function of the length n of the encoded instance:

As everywhere in this library, the machines are deterministic polynomial-time verifiers reading a random string of polynomial length p(n), and probabilities are counts over these strings (Cslib.Complexity.acceptCount). Thresholds are real numbers.

Weak-gap amplification #

The strict majority of 2 q(n) ^ 2 runs on independent blocks of random bits (Cslib.Complexity.repeatMajority) turns success probability 1 / 2 + 1 / q(n) into success probability 4 / 5: by the exponential-moment bound Cslib.five_mul_card_filter_card_filter_le_sq_le, at most a fifth of the random strings give at most q(n) ^ 2 right runs (Cslib.Complexity.boundedErrorAt_repeatMajority_sq). The disjunction of q(n) runs (Cslib.Complexity.repeatAny) turns acceptance probability 1 / q(n) into acceptance probability 1 / 2, since (1 - 1 / q) ^ q ≤ 1 / 2 (Cslib.Complexity.two_pow_le_two_mul_acceptCount_repeatAny). Both trial counts depend on the input length through the polynomial q. Combined with the exponential error reduction for BPP and RP and with ZPP = RP ∩ coRP, this gives the following.

Main results #

Corrections of the sources #

References #

The relaxed classes #

def Cslib.Complexity.DecidesWithErrorAtMost {α : Type} (enc : α ↪ List Bool) (ε : ℕ → ℝ) (p : Polynomial ℕ) (V : α × List Bool → Bool) (A : Set α) :

V decides A with error at most ε(n), using random strings whose length is p evaluated at the length n of the encoded instance: members are accepted, and non-members rejected, on all but at most an ε(n) fraction of the random strings.

def Cslib.Complexity.BPPWithError {α : Type} (enc : α ↪ List Bool) (ε : ℕ → ℝ) :
Set (Set α)

The problems decided with error at most ε(n) by polynomial-time machines reading polynomially long random strings, where n is the length of the encoded instance: the class BPP_ε of Goldreich, Exercise 6.4.

def Cslib.Complexity.DecidesWithOneSidedSuccess {α : Type} (enc : α ↪ List Bool) (ρ : ℕ → ℝ) (p : Polynomial ℕ) (V : α × List Bool → Bool) (A : Set α) :

V decides A with one-sided error and success probability at least ρ(n), using random strings whose length is p evaluated at the length n of the encoded instance: members are accepted on at least a ρ(n) fraction of the random strings, and non-members on none.

def Cslib.Complexity.RPWithSuccess {α : Type} (enc : α ↪ List Bool) (ρ : ℕ → ℝ) :
Set (Set α)

The problems decided with one-sided error and success probability at least ρ(n) by polynomial-time machines reading polynomially long random strings: the class RP_ρ of Goldreich, Exercise 6.5.

def Cslib.Complexity.DecidesWithZeroErrorSuccess {α : Type} (enc : α ↪ List Bool) (ρ : ℕ → ℝ) (p : Polynomial ℕ) (V : α × List Bool → Option Bool) (A : Set α) :

V decides A with zero error and success probability at least ρ(n), using random strings whose length is p evaluated at the length n of the encoded instance: an answer some b is always right, b = true exactly when a ∈ A, and at least a ρ(n) fraction of the random strings give an answer.

def Cslib.Complexity.ZPPWithSuccess {α : Type} (enc : α ↪ List Bool) (ρ : ℕ → ℝ) :
Set (Set α)

The problems decided with zero error and success probability at least ρ(n) by polynomial-time machines reading polynomially long random strings: the class ZPP_ρ of Goldreich, Exercise 6.6.

Numeric bridges #

BPP #

theorem Cslib.Complexity.boundedErrorAt_repeatMajority_sq {α : Type} {enc : α ↪ List Bool} {q p : Polynomial ℕ} {V : α × List Bool → Bool} {a : α} {b : Bool} (h : 2 * 2 ^ Polynomial.eval (enc a).length p ≤ Polynomial.eval (enc a).length q * (2 * {r : Fin (Polynomial.eval (enc a).length p) → Bool | V (a, List.ofFn r) = b}.card - 2 ^ Polynomial.eval (enc a).length p)) :
BoundedErrorAt enc (2 * q ^ 2 * p) (repeatMajority enc (q ^ 2) p V) a b

Weak-gap majority at one instance. If a single run of V gives b on a fraction at least 1 / 2 + 1 / q(n) of the random strings, that is 2 · 2 ^ p(n) ≤ q(n) (2 G - 2 ^ p(n)) for the number G of such strings, then the strict majority of 2 q(n) ^ 2 runs on independent blocks of random bits gives b with bounded error.

theorem Cslib.Complexity.BPPWithError_subset_BPP {α : Type} {enc : α ↪ List Bool} {ε : ℕ → ℝ} (q : Polynomial ℕ) (hq : ∀ᶠ (n : ℕ) in Filter.atTop, 0 < Polynomial.eval n q ∧ ε n ≤ 1 / 2 - 1 / ↑(Polynomial.eval n q)) :
BPPWithError enc ε ⊆ BPP enc

Weak-gap amplification for BPP. If, at all sufficiently large lengths n, the error bound ε(n) is at most 1 / 2 - 1 / q(n) for a polynomial q, then BPP_ε ⊆ BPP. The strict majority of 2 q(n) ^ 2 runs decides the problem with bounded error at these lengths, and the finitely many instances of the other lengths are decided by table lookup.

theorem Cslib.Complexity.BPP_subset_BPPWithError {α : Type} {enc : α ↪ List Bool} {ε : ℕ → ℝ} (q : Polynomial ℕ) (hq : ∀ (n : ℕ), (2 ^ Polynomial.eval n q)⁻¹ ≤ ε n) :
BPP enc ⊆ BPPWithError enc ε

Exponential error reduction into BPP_ε. If 2 ^ (-q(n)) ≤ ε(n) for a polynomial q, then BPP ⊆ BPP_ε.

theorem Cslib.Complexity.BPPWithError_eq_BPP {α : Type} {enc : α ↪ List Bool} {p : Polynomial ℕ} (hp : ∀ (n : ℕ), 2 < Polynomial.eval n p) :
(BPPWithError enc fun (n : ℕ) => 1 / 2 - 1 / ↑(Polynomial.eval n p)) = BPP enc

Goldreich, Exercise 6.4(1): for a polynomial p with p(n) > 2 for every n, and ε(n) = 1 / 2 - 1 / p(n), the class BPP_ε equals BPP, for every encoding of the instances. Goldreich states the exercise for every positive polynomial; for p = 2 the class BPP_0 is P, and the equality would assert the open P = BPP; we assume p(n) > 2.

theorem Cslib.Complexity.setOf_exists_BPPWithError_rpow_eq_BPP {α : Type} {enc : α ↪ List Bool} {c : ℝ} (hc : 0 < c) :
{A : Set α | ∃ (N : ℕ), A ∈ BPPWithError enc fun (n : ℕ) => if n < N then 1 else 1 / 2 - ↑n ^ (-c)} = BPP enc

Arora–Barak, Lemma 7.9, with the printed bound from some length on: for c > 0, the problems decided in polynomial time with success probability at least 1 / 2 + n ^ (-c) on all instances of every length n ≥ N, for some N, are exactly BPP, for every encoding of the instances. The draft requires the bound on every string, which is impossible whenever n ^ c < 2; below N nothing is required here (error at most 1).

theorem Cslib.Complexity.setOf_exists_BPPWithError_rpow_subset_two_rpow {α : Type} {enc : α ↪ List Bool} {c : ℝ} (hc : 0 < c) (d : ℝ) :
{A : Set α | ∃ (N : ℕ), A ∈ BPPWithError enc fun (n : ℕ) => if n < N then 1 else 1 / 2 - ↑n ^ (-c)} ⊆ BPPWithError enc fun (n : ℕ) => 2 ^ (-(↑n + 1) ^ d)

Arora–Barak, Theorem 7.10 (error reduction), with the hypothesis of Lemma 7.9 read from some length on (Cslib.Complexity.setOf_exists_BPPWithError_rpow_eq_BPP): for c > 0, a problem decided in polynomial time with success probability at least 1 / 2 + n ^ (-c) on all instances of every length n ≥ N is, for every d, decided in polynomial time with success probability at least 1 - 2 ^ (-(n + 1) ^ d) on every instance, where n is the length of the encoded instance. The draft states the error 2 ^ (-|x| ^ d), which is trivial at length 0.

RP #

theorem Cslib.Complexity.two_pow_le_two_mul_acceptCount_repeatAny {α : Type} {enc : α ↪ List Bool} {q p : Polynomial ℕ} {V : α × List Bool → Bool} {a : α} (h : 2 ^ Polynomial.eval (enc a).length p ≤ Polynomial.eval (enc a).length q * acceptCount V a (Polynomial.eval (enc a).length p)) :
2 ^ Polynomial.eval (enc a).length (q * p) ≤ 2 * acceptCount (repeatAny enc q p V) a (Polynomial.eval (enc a).length (q * p))

Repetition at inverse-polynomial success. If a single run of V accepts a on at least a 1 / q(n) fraction of the random strings, the disjunction of q(n) runs on independent blocks of random bits accepts on at least half of them, since (1 - 1 / q) ^ q ≤ 1 / 2.

theorem Cslib.Complexity.RPWithSuccess_subset_RP {α : Type} {enc : α ↪ List Bool} {ρ : ℕ → ℝ} (q : Polynomial ℕ) (hq : ∀ (n : ℕ), 0 < Polynomial.eval n q ∧ 1 / ↑(Polynomial.eval n q) ≤ ρ n) :
RPWithSuccess enc ρ ⊆ RP enc

Inverse-polynomial success gives RP. If ρ(n) ≥ 1 / q(n) > 0 for a polynomial q, then RP_ρ ⊆ RP: the disjunction of q(n) runs accepts members on at least half of the random strings.

theorem Cslib.Complexity.RP_subset_RPWithSuccess {α : Type} {enc : α ↪ List Bool} {ρ : ℕ → ℝ} (q : Polynomial ℕ) (hq : ∀ (n : ℕ), ρ n ≤ 1 - (2 ^ Polynomial.eval n q)⁻¹) :
RP enc ⊆ RPWithSuccess enc ρ

Exponential error reduction into RP_ρ. If ρ(n) ≤ 1 - 2 ^ (-q(n)) for a polynomial q, then RP ⊆ RP_ρ.

theorem Cslib.Complexity.RPWithSuccess_inv_eq_RP {α : Type} {enc : α ↪ List Bool} {p : Polynomial ℕ} (hp : ∀ (n : ℕ), 2 ≤ Polynomial.eval n p) :
(RPWithSuccess enc fun (n : ℕ) => 1 / ↑(Polynomial.eval n p)) = RP enc

Goldreich, Exercise 6.5(1): for a polynomial p with p(n) ≥ 2 for every n, the class RP_{1/p} equals RP, for every encoding of the instances. Goldreich states the exercise for every positive polynomial; for p = 1 the class RP_1 is P, and the equality would assert the open P = RP; we assume p(n) ≥ 2.

theorem Cslib.Complexity.RPWithSuccess_succ_rpow_subset_one_sub_two_rpow {α : Type} {enc : α ↪ List Bool} (c d : ℝ) :
(RPWithSuccess enc fun (n : ℕ) => (↑n + 1) ^ (-c)) ⊆ RPWithSuccess enc fun (n : ℕ) => 1 - 2 ^ (-(↑n + 1) ^ d)

Arora–Barak, Theorem 7.12 (error reduction for RP): a problem decided in polynomial time with one-sided error and success probability at least (n + 1) ^ (-c) is, for every d, decided in polynomial time with one-sided error and success probability at least 1 - 2 ^ (-(n + 1) ^ d), where n is the length of the encoded instance. The draft writes n in place of n + 1; at n = 0 its bounds are undefined, resp. trivial.

ZPP #

Accepting exactly on the answer some true decides the problem with one-sided error and the same success probability: ZPP_ρ ⊆ RP_ρ.

theorem Cslib.Complexity.compl_mem_ZPPWithSuccess {α : Type} {enc : α ↪ List Bool} {ρ : ℕ → ℝ} {A : Set α} (hA : A ∈ ZPPWithSuccess enc ρ) :

ZPP_ρ is closed under complement: negate the answers.

theorem Cslib.Complexity.ZPPWithSuccess_subset_ZPP {α : Type} {enc : α ↪ List Bool} {ρ : ℕ → ℝ} (q : Polynomial ℕ) (hq : ∀ (n : ℕ), 0 < Polynomial.eval n q ∧ 1 / ↑(Polynomial.eval n q) ≤ ρ n) :
ZPPWithSuccess enc ρ ⊆ ZPP enc

Inverse-polynomial success gives ZPP. If ρ(n) ≥ 1 / q(n) > 0 for a polynomial q, then ZPP_ρ ⊆ ZPP: the problem and its complement are in RP_ρ ⊆ RP, and ZPP = RP ∩ coRP.

theorem Cslib.Complexity.ZPP_subset_ZPPWithSuccess {α : Type} {enc : α ↪ List Bool} {ρ : ℕ → ℝ} (q : Polynomial ℕ) (hq : ∀ (n : ℕ), ρ n ≤ 1 - (2 ^ Polynomial.eval n q)⁻¹) :
ZPP enc ⊆ ZPPWithSuccess enc ρ

Exponential error reduction into ZPP_ρ. If ρ(n) ≤ 1 - 2 ^ (-q(n)) for a polynomial q, then ZPP ⊆ ZPP_ρ (Cslib.Complexity.exists_zeroError_errorExponent_of_mem_RP_inter_coRP).

theorem Cslib.Complexity.ZPPWithSuccess_inv_eq_ZPP {α : Type} {enc : α ↪ List Bool} {p : Polynomial ℕ} (hp : ∀ (n : ℕ), 2 ≤ Polynomial.eval n p) :
(ZPPWithSuccess enc fun (n : ℕ) => 1 / ↑(Polynomial.eval n p)) = ZPP enc

Goldreich, Exercise 6.6(1): for a polynomial p with p(n) ≥ 2 for every n, the class ZPP_{1/p} equals ZPP, for every encoding of the instances. Goldreich states the exercise for every positive polynomial; for p = 1 the class ZPP_1 is P, and the equality would assert the open P = ZPP; we assume p(n) ≥ 2.

theorem Cslib.Complexity.ZPP_eq_ZPPWithSuccess {α : Type} {enc : α ↪ List Bool} {p : Polynomial ℕ} (hp : ∀ (n : ℕ), 0 < Polynomial.eval n p) :
ZPP enc = ZPPWithSuccess enc fun (n : ℕ) => 1 - (2 ^ Polynomial.eval n p)⁻¹

Goldreich, Exercise 6.6(2): for every positive polynomial p, the class ZPP equals ZPP_ρ for ρ(n) = 1 - 2 ^ (-p(n)), for every encoding of the instances.