Documentation

CslibFrontier.Computability.QueryComplexity.AndOrTree.Randomized

Evaluating the AND–OR tree with zero error in n ^ (log₄ 3) expected queries #

The directional algorithm evaluates a NAND node by evaluating a uniformly random child first, and stops if that child is false, the node then being true; otherwise it evaluates the other child and outputs its negation. Fixing all coin tosses, one per internal node (QueryComplexity.NandTree.DirectionalCoins), gives a deterministic decision tree (QueryComplexity.NandTree.directionalTree) computing the NAND tree, and the algorithm is the uniform mixture of these trees (QueryComplexity.NandTree.directional). It is always correct (QueryComplexity.NandTree.directional_computes).

Its expected cost on an input satisfies an exact recurrence over the two subtrees (QueryComplexity.NandTree.expectedCost_directional_succ): with E₀, E₁ the expected costs on the subtrees and v₀, v₁ their values, it is (E₀ + E₁ + [v₀] E₁ + [v₁] E₀) / 2. By the joint induction on 0- and 1-valued subtrees, the expected cost is at most 3 ^ k at depth 2k, and at depth 2k + 1 at most (3 / 2) 3 ^ k on value true and 2 · 3 ^ k on value false (QueryComplexity.NandTree.expectedCost_directional_le) Motwani and Raghavan, Theorem 2.1.

The same recurrence gives the sharp rate of the directional algorithm, due to Snir Snir. Let α = (1 + √33) / 4 ≈ 1.6861 be the positive root of 2 α² = α + 4 (QueryComplexity.NandTree.directionalRate). By a single induction, the expected cost at depth d is at most α ^ d on value true and (α - 1 / 2) α ^ d on value false (QueryComplexity.NandTree.expectedCost_directional_le_cond_rate). So the NAND tree on n = 2 ^ d leaves has R₀ ≤ (α - 1 / 2) n ^ (log₂ α), with log₂ α ≈ 0.7537 (QueryComplexity.zeroErrorComplexity_nandTree_le_rate).

The OR–AND tree of depth 2k is the NAND tree, and the AND–OR tree T_{2,k} of Motwani and Raghavan, with AND at the root, is its dual, evaluated by the dual trees (DecisionTree.dual) with the same costs on complemented inputs. So on T_{2,k} with n = 4 ^ k leaves the zero-error randomized complexity is at most 3 ^ k = n ^ (log₄ 3) ≈ n ^ 0.793 (QueryComplexity.zeroErrorComplexity_andOrTree_le, QueryComplexity.zeroErrorComplexity_andOrTree_le_rpow), below the deterministic complexity n (QueryComplexity.zeroErrorComplexity_andOrTree_lt_complexity). The sharp rate gives R₀(T_{2,k}) ≤ (α - 1 / 2) n ^ (log₂ α) (QueryComplexity.zeroErrorComplexity_andOrTree_le_rpow_rate).

Saks and Wigderson Saks and Wigderson proved the matching lower bound R₀ = Ω(n ^ (log₂ α)) for the NAND tree, so the directional algorithm is optimal up to a constant factor. That lower bound is not formalized here.

Main definitions #

Main results #

References #

The coin tosses of the directional algorithm on the NAND tree of depth d: at depth d + 1, which child to evaluate first, and the coin tosses for the two subtrees.

Instances For

    The coins at depth d + 1: which child goes first, and the coins of the two subtrees.

    Run l; if it outputs false, output true, and otherwise run r and output its negation. This computes the NAND of l and r, short-circuiting on a false first argument.

    @[simp]
    theorem Cslib.QueryComplexity.NandTree.eval_nandThen {ι : Type u_1} (l r : DecisionTree ι Bool) (x : ι → Bool) :
    (nandThen l r).eval x = !(l.eval x && r.eval x)
    theorem Cslib.QueryComplexity.NandTree.cost_nandThen {ι : Type u_1} (l r : DecisionTree ι Bool) (x : ι → Bool) :
    (nandThen l r).cost x = l.cost x + bif l.eval x then r.cost x else 0

    The directional algorithm on the NAND tree of depth d for fixed coin tosses: at a node, evaluate the left child first if the node's coin is false, and the right child first otherwise.

    For every choice of coins the directional algorithm computes the NAND tree.

    theorem Cslib.QueryComplexity.NandTree.cost_directionalTree_succ (d : ℕ) (b : Bool) (ω₀ ω₁ : DirectionalCoins d) (x : (Fin (d + 1) → Bool) → Bool) :
    ↑((directionalTree (d + 1) ((coinsEquiv d).symm (b, ω₀, ω₁))).cost x) = bif b then ↑((directionalTree d ω₁).cost fun (p : Fin d → Bool) => x (Fin.cons true p)) + bif nandTree d fun (p : Fin d → Bool) => x (Fin.cons true p) then ↑((directionalTree d ω₀).cost fun (p : Fin d → Bool) => x (Fin.cons false p)) else 0 else ↑((directionalTree d ω₀).cost fun (p : Fin d → Bool) => x (Fin.cons false p)) + bif nandTree d fun (p : Fin d → Bool) => x (Fin.cons false p) then ↑((directionalTree d ω₁).cost fun (p : Fin d → Bool) => x (Fin.cons true p)) else 0

    The cost of the directional algorithm at depth d + 1 for fixed coins: the cost on the subtree evaluated first, plus the cost on the other subtree if the first one is true.

    The directional algorithm: evaluate a uniformly random child first and short-circuit.

    The directional algorithm is always correct.

    At depth 0 the directional algorithm reads the single leaf.

    theorem Cslib.QueryComplexity.NandTree.expectedCost_directional_succ (d : ℕ) (x : (Fin (d + 1) → Bool) → Bool) :
    (directional (d + 1)).expectedCost x = (((((directional d).expectedCost fun (p : Fin d → Bool) => x (Fin.cons false p)) + (directional d).expectedCost fun (p : Fin d → Bool) => x (Fin.cons true p)) + bif nandTree d fun (p : Fin d → Bool) => x (Fin.cons false p) then (directional d).expectedCost fun (p : Fin d → Bool) => x (Fin.cons true p) else 0) + bif nandTree d fun (p : Fin d → Bool) => x (Fin.cons true p) then (directional d).expectedCost fun (p : Fin d → Bool) => x (Fin.cons false p) else 0) / 2

    The expected-cost recurrence of the directional algorithm: with E₀, E₁ the expected costs on the left and right subtrees and v₀, v₁ their values, the expected cost at depth d + 1 is (E₀ + E₁ + [v₀] E₁ + [v₁] E₀) / 2.

    theorem Cslib.QueryComplexity.NandTree.expectedCost_directional_le (k : ℕ) :
    (∀ (x : (Fin (2 * k) → Bool) → Bool), (directional (2 * k)).expectedCost x ≤ 3 ^ k) ∧ ∀ (x : (Fin (2 * k + 1) → Bool) → Bool), (directional (2 * k + 1)).expectedCost x ≤ bif nandTree (2 * k + 1) x then 3 / 2 * 3 ^ k else 2 * 3 ^ k

    The 3 ^ k bound Motwani and Raghavan, Theorem 2.1, by joint induction over the values of the subtrees: the directional algorithm makes at most 3 ^ k queries in expectation at depth 2k, and at depth 2k + 1 at most (3 / 2) 3 ^ k if the value is true and 2 · 3 ^ k if it is false.

    The sharp rate #

    The growth rate α = (1 + √33) / 4 ≈ 1.6861 per level of the directional algorithm on the NAND tree: the positive root of 2 α² = α + 4.

    α ^ 2 < 3, so the sharp rate improves on the 3 ^ k bound at even depth 2k.

    The sharp bound for the directional algorithm, after Snir Snir: with α = directionalRate, the expected cost at depth d is at most α ^ d on value true and (α - 1 / 2) α ^ d on value false. With A = α ^ d, the induction step needs α A ≥ (α - 1 / 2) A when both subtrees are false, α A = (α - 1 / 2) A + A / 2 when one subtree is false, and (α - 1 / 2) α A = 2 A when both are true (2 α² = α + 4).

    The sharp bound on every input: at most (α - 1 / 2) α ^ d expected queries at depth d.

    The OR–AND tree of depth 2k has a zero-error randomized decision tree making at most 3 ^ k queries in expectation on every input: the directional algorithm.

    The AND–OR tree has a zero-error randomized decision tree with 3 ^ k expected queries Motwani and Raghavan, Theorem 2.1: the directional algorithm, run on the dual trees (DecisionTree.dual) to evaluate AND at the root, computes T_{2,k} without error and makes at most 3 ^ k queries in expectation on every input.

    R₀(T_{2,k}) ≤ n ^ (log₄ 3) ≈ n ^ 0.793 for the AND–OR tree T_{2,k} on n = 4 ^ k leaves.

    Randomness helps for the AND–OR tree: R₀(T_{2,k}) < D(T_{2,k}) for k ≥ 1.

    R₀ ≤ 3 ^ k for the OR–AND tree of depth 2k.

    The sharp rate for the NAND tree Snir: R₀ ≤ (α - 1 / 2) α ^ d on the NAND tree of depth d, that is (α - 1 / 2) n ^ (log₂ α) ≈ n ^ 0.7537 on n = 2 ^ d leaves.

    The sharp rate for the AND–OR tree: R₀(T_{2,k}) ≤ (α - 1 / 2) α ^ (2k).

    The sharp rate for T_{2,k} on n = 4 ^ k leaves: R₀ ≤ (α - 1 / 2) n ^ (log₂ α), where log₂ α ≈ 0.7537.