Documentation

CslibFrontier.Computability.DecisionTree.Dual

The dual of a decision tree #

The dual of a Boolean function f is x ↦ ¬ f(¬ x), with ¬ x the bitwise complement. The dual of a decision tree (DecisionTree.dual) swaps the two children of every node and negates every leaf. On x it follows the path of the original tree on ¬ x, with the same queries (DecisionTree.queries_dual, DecisionTree.cost_dual), and outputs the negated leaf (DecisionTree.eval_dual). So it computes the dual of the function computed by the original tree (DecisionTree.Computes.dual), and a function and its dual have the same decision tree complexity (DecisionTree.complexity_dual). For example, De Morgan duality turns OR into AND, so lower and upper bounds for an OR-rooted formula transfer to the AND-rooted one.

Main definitions #

Main results #

The dual of a decision tree: swap the two children of every node and negate every leaf.

@[simp]
theorem Cslib.DecisionTree.dual_leaf {ι : Type u_1} (b : Bool) :
@[simp]
theorem Cslib.DecisionTree.dual_node {ι : Type u_1} (i : ι) (t₀ t₁ : DecisionTree ι Bool) :
(node i t₀ t₁).dual = node i t₁.dual t₀.dual
@[simp]
theorem Cslib.DecisionTree.dual_dual {ι : Type u_1} (t : DecisionTree ι Bool) :
t.dual.dual = t
@[simp]
theorem Cslib.DecisionTree.eval_dual {ι : Type u_1} (t : DecisionTree ι Bool) (x : ι → Bool) :
t.dual.eval x = !t.eval fun (i : ι) => !x i

On x, the dual tree outputs the negation of the original tree's output on ¬ x.

@[simp]
@[simp]
theorem Cslib.DecisionTree.weightedCost_dual {ι : Type u_1} (t : DecisionTree ι Bool) (w : ι → ℕ) (x : ι → Bool) :
t.dual.weightedCost w x = t.weightedCost w fun (i : ι) => !x i

On x, the dual tree pays the original tree's query costs on ¬ x.

@[simp]
theorem Cslib.DecisionTree.cost_dual {ι : Type u_1} (t : DecisionTree ι Bool) (x : ι → Bool) :
t.dual.cost x = t.cost fun (i : ι) => !x i

On x, the dual tree makes as many queries as the original tree on ¬ x.

@[simp]
theorem Cslib.DecisionTree.queries_dual {ι : Type u_1} [DecidableEq ι] (t : DecisionTree ι Bool) (x : ι → Bool) :
t.dual.queries x = t.queries fun (i : ι) => !x i

On x, the dual tree queries the variables that the original tree queries on ¬ x.

theorem Cslib.DecisionTree.Computes.dual {ι : Type u_1} {t : DecisionTree ι Bool} {f : (ι → Bool) → Bool} (ht : t.Computes f) :
t.dual.Computes fun (x : ι → Bool) => !f fun (i : ι) => !x i

The dual tree computes the dual function x ↦ ¬ f(¬ x).

theorem Cslib.DecisionTree.complexity_dual {ι : Type u_1} [Finite ι] (f : (ι → Bool) → Bool) :
(complexity fun (x : ι → Bool) => !f fun (i : ι) => !x i) = complexity f

A function and its dual have the same decision tree complexity.