Documentation

CslibFrontier.Computability.QueryComplexity.Randomized.DeutschJozsa

Randomized query algorithms for Deutsch–Jozsa #

Deterministically, the Deutsch–Jozsa promise problem over N = 2m positions needs m + 1 queries (CslibFrontier/Computability/QueryComplexity/DeutschJozsa.lean). With randomness and a small error it needs only a constant number. de Wolf, §2.4.1 observes that querying two random positions and answering "constant" exactly when the two bits agree is always correct on constant inputs and correct with probability 1/2 on balanced inputs. So the quantum–classical separation for this problem holds only for exact algorithms.

Here the randomized algorithm Cslib.QueryComplexity.randomDeutschJozsa k draws k positions independently and uniformly, with replacement, queries them, and answers whether the bits read are all equal. It makes at most k queries. It never errs on a constant input. On a balanced input it errs exactly when all k positions fall among the N/2 true positions or all among the N/2 false ones, which has probability 2 · (1/2)^k = 2/2^k for k ≥ 1 (Cslib.QueryComplexity.errorProb_randomDeutschJozsa_of_isBalanced). For k = 2 this is the error 1/2 of de Wolf's remark. For k = 3 the error 1/4 is below the usual bounded-error threshold 1/3, against m + 1 deterministic queries (Cslib.QueryComplexity.randomDeutschJozsa_separation).

The library's Cslib.QueryComplexity.randomizedComplexity asks for small error on every input, while the Deutsch–Jozsa problem is a promise problem. So these bounds are stated for the error on the promise inputs, as in the deterministic module.

Main definitions #

Main results #

References #

Query k positions drawn independently and uniformly at random, and answer whether the bits read are all equal.

The algorithm randomDeutschJozsa k makes at most k queries.

theorem Cslib.QueryComplexity.errorProb_randomDeutschJozsa_const {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] (k : ℕ) {F : (ι → Bool) → Bool} (hF : SolvesDeutschJozsa F) (b : Bool) :
((randomDeutschJozsa k).errorProb F fun (x : ι) => b) = 0

randomDeutschJozsa k never errs on a constant input.

theorem Cslib.QueryComplexity.card_filter_eval_deutschJozsaTree {ι : Type u_1} [Fintype ι] [DecidableEq ι] {k : ℕ} (hk : 0 < k) {x : ι → Bool} (hx : BitString.IsBalanced x) :
{l : Fin k → ι | (deutschJozsaTree (List.ofFn l)).eval x = true}.card = 2 * BitString.weight x ^ k

On a balanced input x, 2 · weight(x)^k of the (2 · weight(x))^k position tuples read bits that are all equal.

theorem Cslib.QueryComplexity.errorProb_randomDeutschJozsa_of_isBalanced {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {k : ℕ} (hk : 0 < k) {F : (ι → Bool) → Bool} (hF : SolvesDeutschJozsa F) {x : ι → Bool} (hx : BitString.IsBalanced x) :

The error on balanced inputs: for k ≥ 1, randomDeutschJozsa k errs on a balanced input with probability exactly 2/2^k. For k = 2 this is the error 1/2 of de Wolf, §2.4.1.

theorem Cslib.QueryComplexity.errorProb_randomDeutschJozsa_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] (k : ℕ) {F : (ι → Bool) → Bool} (hF : SolvesDeutschJozsa F) {x : ι → Bool} (hx : (∃ (c : Bool), x = fun (x : ι) => c) ∨ BitString.IsBalanced x) :

The error on the promise: randomDeutschJozsa k errs with probability at most 2/2^k on every constant or balanced input.

theorem Cslib.QueryComplexity.randomDeutschJozsa_separation {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {m : ℕ} (hι : Fintype.card ι = 2 * m) :
(randomDeutschJozsa 3).depth ≤ 3 ∧ (∀ (F : (ι → Bool) → Bool), SolvesDeutschJozsa F → ∀ (x : ι → Bool), (∃ (c : Bool), x = fun (x : ι) => c) ∨ BitString.IsBalanced x → (randomDeutschJozsa 3).errorProb F x ≤ 1 / 4) ∧ ∀ (F : (ι → Bool) → Bool), SolvesDeutschJozsa F → m + 1 ≤ DecisionTree.complexity F

Deutsch–Jozsa is easy with bounded error de Wolf, §2.4.1: over N = 2m positions, three random queries solve the promise problem with error at most 1/4 < 1/3, while every deterministic decision tree needs m + 1 queries.