Documentation

CslibFrontier.Computability.QueryComplexity.Randomized

Randomized decision trees #

A randomized decision tree tosses coins, uses them to pick a deterministic decision tree, and runs it. We represent it by the distribution over decision trees that it draws from, a finitely supported probability distribution Convexity.StdSimplex ℝ (DecisionTree ι β) (RandomizedDecisionTree). Its depth is the largest depth of a tree it can draw: the number of queries it makes in the worst case over the inputs and the coins (RandomizedDecisionTree.depth). It computes f with error ε when on every input the tree it draws outputs a wrong value with probability at most ε (RandomizedDecisionTree.errorProb, RandomizedDecisionTree.Computes). The randomized decision tree complexity R_ε(f) is the least depth of a randomized decision tree computing f with error ε (QueryComplexity.randomizedComplexity) [BdW02]; the bounded-error complexity R(f) of the literature is R_{1/3}(f).

Deterministic trees are randomized trees that draw one tree, so R_ε(f) ≤ D(f) for ε ≥ 0 (DecisionTree.randomizedComplexity_le_complexity). With error 0 every tree that can be drawn computes f, so R_0(f) = D(f) (QueryComplexity.randomizedComplexity_zero); zero-error complexity in the literature usually counts the expected number of queries instead, which can be smaller. A fair coin guesses a Boolean value correctly with probability 1/2, so R_ε(f) = 0 for Boolean-valued f and ε ≥ 1/2 (QueryComplexity.randomizedComplexity_eq_zero_of_le).

If a randomized tree computes f with error ε, then for every distribution ν on the inputs some tree that it can draw errs with probability at most ε on inputs drawn from ν (RandomizedDecisionTree.Computes.exists_distributionalError_le, from Convexity.StdSimplex.exists_mem_support_le_sum_mul in CslibFrontier.Probability.Minimax). This averaging argument is the easy direction of Yao's principle [Yao77]; the converse follows from the minimax theorem (QueryComplexity.exists_computes_of_forall_exists_distributionalError_le).

Post-processing the output with a function g (RandomizedDecisionTree.mapOutput) makes no further queries and errs against g ∘ f at most as often as the original tree errs against f (RandomizedDecisionTree.errorProb_mapOutput_le); so lower bounds for computing g ∘ f are lower bounds for computing f. More generally, a transformation φ of the drawn tree (RandomizedDecisionTree.mapTree), such as appending a verification to every leaf, adds the queries that φ adds (RandomizedDecisionTree.depth_mapTree_le) and no error when φ preserves correctness (RandomizedDecisionTree.errorProb_mapTree_le).

Main definitions #

Main results #

References #

@[reducible, inline]
abbrev Cslib.RandomizedDecisionTree (ι : Type u_1) (β : Type u_2) :
Type (max u_2 u_1)

A randomized decision tree over Boolean variables indexed by ι, with outputs in β: a finitely supported probability distribution over decision trees. It draws a tree from this distribution and runs it.

def Cslib.DecisionTree.randomizedCost (ι : Type u_1) (β : Type u_2) :
RandomizedCost (DecisionTree ι β) (ι → Bool) β

Deterministic decision trees as a RandomizedCost model with evaluation DecisionTree.eval and worst-case cost DecisionTree.depth.

noncomputable def Cslib.DecisionTree.distributionalError {ι : Type u_1} {β : Type u_2} (t : DecisionTree ι β) (ν : Convexity.StdSimplex ℝ (ι → Bool)) (f : (ι → Bool) → β) :

The error of a decision tree t on inputs drawn from ν: the probability that on an input x drawn from ν it outputs a value other than f x.

theorem Cslib.DecisionTree.distributionalError_eq_sum {ι : Type u_1} {β : Type u_2} [DecidableEq β] (t : DecisionTree ι β) (ν : Convexity.StdSimplex ℝ (ι → Bool)) (f : (ι → Bool) → β) :
t.distributionalError ν f = ν.sum fun (x : ι → Bool) (w : ℝ) => w * if t.eval x = f x then 0 else 1

distributionalError with any decidable equality on the outputs.

theorem Cslib.DecisionTree.distributionalError_nonneg {ι : Type u_1} {β : Type u_2} {t : DecisionTree ι β} {ν : Convexity.StdSimplex ℝ (ι → Bool)} {f : (ι → Bool) → β} :
theorem Cslib.DecisionTree.Computes.distributionalError_eq_zero {ι : Type u_1} {β : Type u_2} {t : DecisionTree ι β} {ν : Convexity.StdSimplex ℝ (ι → Bool)} {f : (ι → Bool) → β} (ht : t.Computes f) :

A decision tree computing f has error 0 on every distribution.

The depth of a randomized decision tree: the largest depth of a tree that it can draw, so the number of queries it makes in the worst case over the inputs and the coins.

noncomputable def Cslib.RandomizedDecisionTree.errorProb {ι : Type u_1} {β : Type u_2} (μ : RandomizedDecisionTree ι β) (f : (ι → Bool) → β) (x : ι → Bool) :

The probability that the tree drawn from μ outputs on x a value other than f x.

def Cslib.RandomizedDecisionTree.Computes {ι : Type u_1} {β : Type u_2} (μ : RandomizedDecisionTree ι β) (ε : ℝ) (f : (ι → Bool) → β) :

A randomized decision tree μ computes f with error ε when on every input the tree drawn from μ outputs a wrong value with probability at most ε.

theorem Cslib.RandomizedDecisionTree.errorProb_eq_sum {ι : Type u_1} {β : Type u_2} [DecidableEq β] (μ : RandomizedDecisionTree ι β) (f : (ι → Bool) → β) (x : ι → Bool) :
μ.errorProb f x = μ.sum fun (t : DecisionTree ι β) (w : ℝ) => w * if t.eval x = f x then 0 else 1

errorProb with any decidable equality on the outputs.

theorem Cslib.RandomizedDecisionTree.depth_le_iff {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {d : ℕ} :
μ.depth ≤ d ↔ ∀ t ∈ μ.support, t.depth ≤ d
theorem Cslib.RandomizedDecisionTree.depth_le_depth {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {t : DecisionTree ι β} (ht : t ∈ μ.support) :
theorem Cslib.RandomizedDecisionTree.errorProb_nonneg {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {f : (ι → Bool) → β} {x : ι → Bool} :
0 ≤ μ.errorProb f x
theorem Cslib.RandomizedDecisionTree.errorProb_le_one {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {f : (ι → Bool) → β} {x : ι → Bool} :
μ.errorProb f x ≤ 1
theorem Cslib.RandomizedDecisionTree.errorProb_eq_zero_iff {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {f : (ι → Bool) → β} {x : ι → Bool} :
μ.errorProb f x = 0 ↔ ∀ t ∈ μ.support, t.eval x = f x
theorem Cslib.RandomizedDecisionTree.Computes.mono {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {f : (ι → Bool) → β} {ε ε' : ℝ} (h : μ.Computes ε f) (hε : ε ≤ ε') :
μ.Computes ε' f
theorem Cslib.RandomizedDecisionTree.Computes.nonneg {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {f : (ι → Bool) → β} {ε : ℝ} (h : μ.Computes ε f) :
0 ≤ ε

A randomized decision tree can only compute with nonnegative error.

theorem Cslib.RandomizedDecisionTree.computes_single {ι : Type u_1} {β : Type u_2} {f : (ι → Bool) → β} {t : DecisionTree ι β} {ε : ℝ} (ht : t.Computes f) (hε : 0 ≤ ε) :

A deterministic decision tree computing f computes it with any nonnegative error.

theorem Cslib.RandomizedDecisionTree.computes_zero_iff {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {f : (ι → Bool) → β} :
μ.Computes 0 f ↔ ∀ t ∈ μ.support, t.Computes f

A randomized decision tree computes f with error 0 exactly when every tree it can draw computes f.

theorem Cslib.RandomizedDecisionTree.Computes.exists_distributionalError_le {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {f : (ι → Bool) → β} {ε : ℝ} (h : μ.Computes ε f) (ν : Convexity.StdSimplex ℝ (ι → Bool)) :
∃ t ∈ μ.support, t.distributionalError ν f ≤ ε

The averaging argument, the easy direction of Yao's principle: if μ computes f with error ε, then for every distribution ν on the inputs some tree that μ can draw errs with probability at most ε on inputs drawn from ν.

Transforming the drawn tree #

noncomputable def Cslib.RandomizedDecisionTree.mapTree {ι : Type u_1} {β : Type u_2} {γ : Type u_3} (φ : DecisionTree ι β → DecisionTree ι γ) (μ : RandomizedDecisionTree ι β) :

Transform the tree drawn from μ by φ: draw a tree t from μ and run φ t.

theorem Cslib.RandomizedDecisionTree.exists_of_mem_support_mapTree {ι : Type u_1} {β : Type u_2} {μ : RandomizedDecisionTree ι β} {γ : Type u_3} {φ : DecisionTree ι β → DecisionTree ι γ} {u : DecisionTree ι γ} (hu : u ∈ (mapTree φ μ).support) :
∃ t ∈ μ.support, φ t = u

Every tree that mapTree φ μ can draw is φ t for a tree t that μ can draw.

theorem Cslib.RandomizedDecisionTree.depth_mapTree_le {ι : Type u_1} {β : Type u_2} {γ : Type u_3} (φ : DecisionTree ι β → DecisionTree ι γ) (μ : RandomizedDecisionTree ι β) {d : ℕ} (hφ : ∀ (t : DecisionTree ι β), (φ t).depth ≤ t.depth + d) :
(mapTree φ μ).depth ≤ μ.depth + d

If φ adds at most d queries to every tree, then so does mapTree φ.

theorem Cslib.RandomizedDecisionTree.errorProb_mapTree_le {ι : Type u_1} {β : Type u_2} {γ : Type u_3} (φ : DecisionTree ι β → DecisionTree ι γ) (μ : RandomizedDecisionTree ι β) (f : (ι → Bool) → β) (g : (ι → Bool) → γ) (x : ι → Bool) (hφ : ∀ (t : DecisionTree ι β), t.eval x = f x → (φ t).eval x = g x) :
(mapTree φ μ).errorProb g x ≤ μ.errorProb f x

If φ turns every tree that outputs f x on x into one that outputs g x on x, then mapTree φ μ errs against g on x at most as often as μ errs against f.

theorem Cslib.RandomizedDecisionTree.errorProb_mapTree_eq_zero {ι : Type u_1} {β : Type u_2} {γ : Type u_3} (φ : DecisionTree ι β → DecisionTree ι γ) (μ : RandomizedDecisionTree ι β) (g : (ι → Bool) → γ) (x : ι → Bool) (hφ : ∀ (t : DecisionTree ι β), (φ t).eval x = g x) :
(mapTree φ μ).errorProb g x = 0

If φ turns every tree into one that outputs g x on x, then mapTree φ μ never errs against g on x.

Post-processing the output #

noncomputable def Cslib.RandomizedDecisionTree.mapOutput {ι : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (μ : RandomizedDecisionTree ι β) :

Post-process the output of a randomized decision tree with g: draw a tree from μ and relabel its leaves with g (DecisionTree.map).

theorem Cslib.RandomizedDecisionTree.depth_mapOutput_le {ι : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (μ : RandomizedDecisionTree ι β) :

Post-processing makes no further queries.

theorem Cslib.RandomizedDecisionTree.errorProb_mapOutput_le {ι : Type u_1} {β : Type u_2} {γ : Type u_3} (g : β → γ) (μ : RandomizedDecisionTree ι β) (f : (ι → Bool) → β) (x : ι → Bool) :
(mapOutput g μ).errorProb (g ∘ f) x ≤ μ.errorProb f x

Post-processing does not increase the error: the tree drawn from mapOutput g μ errs against g ∘ f at most as often as the tree drawn from μ errs against f.

noncomputable def Cslib.QueryComplexity.randomizedComplexity {ι : Type u_1} {β : Type u_2} [Finite ι] (ε : NNReal) (f : (ι → Bool) → β) :

The randomized decision tree complexity R_ε(f): the least depth of a randomized decision tree computing f with nonnegative error budget ε over finitely many variables. These restrictions ensure that a feasible tree exists.

theorem Cslib.QueryComplexity.randomizedComplexity_le_depth {ι : Type u_1} {β : Type u_2} {f : (ι → Bool) → β} {μ : RandomizedDecisionTree ι β} {ε : NNReal} [Finite ι] (h : μ.Computes (↑ε) f) :
theorem Cslib.QueryComplexity.exists_computes_depth_eq_randomizedComplexity {ι : Type u_1} {β : Type u_2} {ε : NNReal} [Finite ι] (f : (ι → Bool) → β) :
∃ (μ : RandomizedDecisionTree ι β), μ.Computes (↑ε) f ∧ μ.depth = randomizedComplexity ε f

For ε ≥ 0 the randomized complexity is attained: some randomized decision tree of depth R_ε(f) computes f with error ε.

theorem Cslib.QueryComplexity.randomizedComplexity_le_iff {ι : Type u_1} {β : Type u_2} {f : (ι → Bool) → β} {ε : NNReal} {d : ℕ} [Finite ι] :
randomizedComplexity ε f ≤ d ↔ ∃ (μ : RandomizedDecisionTree ι β), μ.Computes (↑ε) f ∧ μ.depth ≤ d
theorem Cslib.QueryComplexity.le_randomizedComplexity_iff {ι : Type u_1} {β : Type u_2} {f : (ι → Bool) → β} {ε : NNReal} {d : ℕ} [Finite ι] :
d ≤ randomizedComplexity ε f ↔ ∀ (μ : RandomizedDecisionTree ι β), μ.Computes (↑ε) f → d ≤ μ.depth

Lower bounds on R_ε(f) are lower bounds on the depth of every randomized decision tree computing f with error ε.

theorem Cslib.QueryComplexity.randomizedComplexity_antitone {ι : Type u_1} {β : Type u_2} {f : (ι → Bool) → β} {ε ε' : NNReal} [Finite ι] (hεε' : ε ≤ ε') :

R_ε(f) decreases as ε grows.

With error 0 randomness does not help: R_0(f) = D(f). The cost here is the worst case over the coins, unlike the expected number of queries of zero-error (Las Vegas) complexity.

theorem Cslib.QueryComplexity.exists_computes_depth_zero_of_le {ι : Type u_1} {ε : ℝ} (hε : 1 / 2 ≤ ε) (f : (ι → Bool) → Bool) :
∃ (μ : RandomizedDecisionTree ι Bool), μ.Computes ε f ∧ μ.depth = 0

A fair coin computes any Boolean-valued function with error at most 1/2, without a query. This witness is available even for infinitely many coordinates.

theorem Cslib.QueryComplexity.randomizedComplexity_eq_zero_of_le {ι : Type u_1} {ε : NNReal} [Finite ι] (hε : 1 / 2 ≤ ↑ε) (f : (ι → Bool) → Bool) :

From ε = 1/2 on, a fair coin computes every Boolean-valued function: R_ε(f) = 0.

Randomness does not hurt: R_ε(f) ≤ D(f) for ε ≥ 0.

R_ε(f) is at most the number of variables for ε ≥ 0.