Karchmer–Wigderson games #
A De Morgan formula has literal and constant leaves and binary AND and OR
gates. The Karchmer–Wigderson game of f gives Alice an input x with
f x = 1 and Bob an input y with f y = 0; they must agree on a coordinate
where x and y differ. A deterministic protocol is a binary tree whose internal
nodes are owned by one player and branch on that player's input, and whose
leaves name a coordinate.
The Karchmer–Wigderson theorem says that formulas and protocols are the same
trees: an OR gate is a node where Alice says which side of the disjunction
her input satisfies, an AND gate is a node where Bob says which side his
input violates, and a literal leaf names its coordinate
(Formula.toProtocol). Conversely a protocol induces, at every node, a
rectangle of inputs still consistent with the transcript, and the formula
built with OR at Alice's nodes and AND at Bob's nodes is 1 on Alice's side
and 0 on Bob's side of every rectangle (Protocol.toFormula). Depth and
leaf count are preserved in both directions, so for n ≥ 1 the minimum formula
depth of f equals the minimum protocol depth of its game
(formulaDepth_eq_protocolDepth), and likewise for leaf size
(formulaSize_eq_protocolSize). Both need [NeZero n]: with no coordinates
there is no protocol at all (a leaf must name a coordinate), so the protocol
measures are ⊤, while a constant formula has depth 0.
De Morgan formulas #
A De Morgan formula: literal leaves, constants, binary AND and OR.
- lit
{n : ℕ}
(index : Fin n)
(positive : Bool)
: Formula n
The literal
x_iwhenpositive, otherwise¬ x_i. - const
{n : ℕ}
(value : Bool)
: Formula n
A Boolean constant.
- and
{n : ℕ}
(left right : Formula n)
: Formula n
Conjunction.
- or
{n : ℕ}
(left right : Formula n)
: Formula n
Disjunction.
Instances For
Evaluate a formula.
Equations
Instances For
The number of leaves, counting literals and constants, so every formula has
at least one leaf. This differs from Algebraic.Binary.Formula.leaves, which
counts only variable leaves and gives constants leaf size 0; formulaSize and
the KRW statements use this convention.
Equations
Instances For
The De Morgan dual, computing the negation with the same shape.
Equations
Instances For
Protocols #
A deterministic two-party protocol whose leaves name a coordinate. Each internal node is owned by Alice or Bob and branches on the owner's input.
- answer
{n : ℕ}
(index : Fin n)
: Protocol n
Output a coordinate.
- alice
{n : ℕ}
(choose : (Fin n → Bool) → Bool)
(left right : Protocol n)
: Protocol n
Alice branches on her input;
trueselects the right child. - bob
{n : ℕ}
(choose : (Fin n → Bool) → Bool)
(left right : Protocol n)
: Protocol n
Bob branches on his input;
trueselects the right child.
Instances For
The coordinate output on inputs x for Alice and y for Bob.
Equations
Instances For
The depth: the longest root-to-leaf path.
Equations
Instances For
The number of leaves.
Equations
- (Algebraic.KW.Protocol.answer index).leaves = 1
- (Algebraic.KW.Protocol.alice choose l r).leaves = l.leaves + r.leaves
- (Algebraic.KW.Protocol.bob choose l r).leaves = l.leaves + r.leaves
Instances For
The protocol solves the game on the rectangle A × B: on inputs from
A for Alice and B for Bob, the output coordinate distinguishes them.
Instances For
From formulas to protocols #
The protocol of a formula: Bob resolves conjunctions, Alice resolves
disjunctions, literals name their coordinate. A constant leaf, which can only
be reached on an empty rectangle, answers the default coordinate i₀.
Equations
- Algebraic.KW.Formula.toProtocol i₀ (Algebraic.KW.Formula.lit index positive) = Algebraic.KW.Protocol.answer index
- Algebraic.KW.Formula.toProtocol i₀ (Algebraic.KW.Formula.const value) = Algebraic.KW.Protocol.answer i₀
- Algebraic.KW.Formula.toProtocol i₀ (l.and r) = Algebraic.KW.Protocol.bob (fun (y : Fin n → Bool) => l.eval y) (Algebraic.KW.Formula.toProtocol i₀ l) (Algebraic.KW.Formula.toProtocol i₀ r)
- Algebraic.KW.Formula.toProtocol i₀ (l.or r) = Algebraic.KW.Protocol.alice (fun (x : Fin n → Bool) => !l.eval x) (Algebraic.KW.Formula.toProtocol i₀ l) (Algebraic.KW.Formula.toProtocol i₀ r)
Instances For
From protocols to formulas #
The formula of a protocol, relative to the rectangle A × B of inputs
reaching the current node: OR at Alice's nodes, AND at Bob's nodes, and at a
leaf naming i the literal that is 1 on A and 0 on B.
Equations
- One or more equations did not get rendered due to their size.
- (Algebraic.KW.Protocol.alice c l r).toFormula x✝¹ x✝ = (l.toFormula (fun (x : Fin n → Bool) => x✝¹ x ∧ c x = false) x✝).or (r.toFormula (fun (x : Fin n → Bool) => x✝¹ x ∧ c x = true) x✝)
- (Algebraic.KW.Protocol.bob c l r).toFormula x✝¹ x✝ = (l.toFormula x✝¹ fun (y : Fin n → Bool) => x✝ y ∧ c y = false).and (r.toFormula x✝¹ fun (y : Fin n → Bool) => x✝ y ∧ c y = true)
Instances For
The Karchmer–Wigderson theorem #
The minimum depth of a formula computing f.
Equations
- Algebraic.KW.formulaDepth f = ⨅ (F : { F : Algebraic.KW.Formula n // F.Computes f }), ↑(↑F).depth
Instances For
The minimum number of leaves of a formula computing f.
Equations
- Algebraic.KW.formulaSize f = ⨅ (F : { F : Algebraic.KW.Formula n // F.Computes f }), ↑(↑F).leaves
Instances For
The minimum depth of a protocol for the game of f.
Equations
- Algebraic.KW.protocolDepth f = ⨅ (P : { P : Algebraic.KW.Protocol n // P.SolvesKW f }), ↑(↑P).depth
Instances For
The minimum number of leaves of a protocol for the game of f.
Equations
- Algebraic.KW.protocolSize f = ⨅ (P : { P : Algebraic.KW.Protocol n // P.SolvesKW f }), ↑(↑P).leaves
Instances For
Karchmer–Wigderson, depth. For n ≥ 1, the minimum formula depth of f
is the minimum depth of a protocol for its game.
Karchmer–Wigderson, size. For n ≥ 1, the minimum leaf size of a formula
for f is the minimum number of leaves of a protocol for its game.