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 #
Cslib.QueryComplexity.NandTree.directionalTree: the directional algorithm for fixed coins.Cslib.QueryComplexity.NandTree.directional: the randomized directional algorithm.
Main results #
Cslib.QueryComplexity.NandTree.expectedCost_directional_succ: the expected-cost recurrence.Cslib.QueryComplexity.NandTree.expectedCost_directional_le: the3 ^ kbound.Cslib.QueryComplexity.NandTree.expectedCost_directional_le_cond_rate: the sharpα ^ dbound.Cslib.QueryComplexity.zeroErrorComplexity_nandTree_le_rate:R₀ ≤ (α - 1 / 2) α ^ dfor the NAND tree of depthd.Cslib.QueryComplexity.exists_computes_zero_expectedCost_andOrTree_le: an always-correct randomized decision tree forT_{2,k}with at most3 ^ kexpected queries on every input.Cslib.QueryComplexity.zeroErrorComplexity_andOrTree_lt_complexity:R₀(T_{2,k}) < D(T_{2,k})fork ≥ 1.
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.
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.
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.
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.
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 α² = α + 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}) ≤ 3 ^ k.
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.