TCSLib

35 Boolean Analysis — Switching

35.1 Overview

This module assembles Håstad’s Switching Lemma. Building on the Razborov-style encoder and the canonical decision tree, it develops the combinatorial machinery needed to count the restrictions \(\rho \) under which a width-\(w\) DNF \(f\) restricts to a function of large decision-tree depth, proves the path-consumption and free-variable invariants of the encoder, and concludes both the DNF and (by De Morgan duality) the CNF versions of the switching lemma together with their representation-size corollaries.

35.2 Declarations

Definition 35.1 Parse an aux list into triples
#

Parses a low-level aux list of \((\mathbb {N} \times \mathrm{Bool})\) entries into a list of triples \((\mathrm{pos}, \mathrm{dir}, \mathrm{hasMarker})\) with \(\mathrm{pos} : \mathrm{Fin}\, w\), where \(\mathrm{hasMarker}\) records whether the entry is immediately followed by a \((w, \mathrm{false})\) termination marker. Entries with index \(\geq w\) that do not follow a real entry are dropped.

Definition 35.2 Triples back to an aux list
#

The inverse direction of SwitchingLemma2.parseAux: converts a list of triples back into an aux list of \((\mathbb {N} \times \mathrm{Bool})\) entries, emitting a \((w, \mathrm{false})\) termination marker after each triple whose marker flag is true.

Lemma 35.3 parseAux on an entry followed by a marker
#

Equational lemma: if an entry \((idx, dir)\) with \(idx \lt w\) is immediately followed by the marker \((w, \mathrm{false})\), then \(\mathrm{parseAux}\) emits the triple \((\langle idx, h\rangle , dir, \mathrm{true})\) followed by the parse of the rest.

Lemma 35.4 parseAux on an entry followed by a non-marker

Equational lemma: if an entry \((idx, dir)\) is immediately followed by another in-range entry \((idx', dir')\), then \(\mathrm{parseAux}\) emits the triple \((\langle idx, h\rangle , dir, \mathrm{false})\) followed by the parse of the remaining list starting at \((idx', dir')\).

Lemma 35.5 parseAux on a single entry
#

Equational lemma: a single in-range entry \((idx, dir)\) parses to the singleton \([(\langle idx, h\rangle , dir, \mathrm{false})]\).

Lemma 35.6 parseAux on the empty list
#

Equational lemma: \(\mathrm{parseAux}\) of the empty list is the empty list.

Lemma 35.7 parseAux inverts triplesToAux

Round-trip identity: for every triple list \(ts\), applying \(\mathrm{triplesToAux}\) and then \(\mathrm{parseAux}\) recovers \(ts\).

Lemma 35.8 triplesToAux distributes over append
#

\(\mathrm{triplesToAux}\, (ts_1 \mathbin {+\! \! +} ts_2) = \mathrm{triplesToAux}\, ts_1 \mathbin {+\! \! +} \mathrm{triplesToAux}\, ts_2\).

Lemma 35.9 Combined length bound for processClauseLits

The aux output length of \(\mathrm{processClauseLits}\) plus the remaining path length never exceeds the initial path length.

Definition 35.10 Mark the last entry of a block
#

Builds a triple list from a \(\mathrm{Fin}\, w \times \mathrm{Bool}\) block by setting the marker flag to true on the last entry only and to false on all others.

Lemma 35.11 triplesToAux of markLast

On a nonempty block, \(\mathrm{triplesToAux}(\mathrm{markLast}\, block)\) equals the block mapped into \(\mathbb {N} \times \mathrm{Bool}\) followed by a single \((w, \mathrm{false})\) termination marker.

Lemma 35.12 markLast of a nonempty list is nonempty
#

If \(block \neq []\) then \(\mathrm{markLast}\, block \neq []\).

Lemma 35.13 markLast preserves length
#

\((\mathrm{markLast}\, block).\mathrm{length} = block.\mathrm{length}\).

Lemma 35.14 Last entry of markLast is marked

On a nonempty block, the last element of \(\mathrm{markLast}\, block\) has marker flag equal to true.

Definition 35.15 Cast an in-range aux list into Fin blocks
#

Casts a list of \((\mathbb {N} \times \mathrm{Bool})\) entries, all of whose first coordinates are \(\lt w\), into a list of \((\mathrm{Fin}\, w \times \mathrm{Bool})\).

Lemma 35.16 toFinBlock preserves length
#

\((\mathrm{toFinBlock}\, w\, l\, h).\mathrm{length} = l.\mathrm{length}\).

Lemma 35.17 toFinBlock map recovers the original list
#

Mapping the \(\mathrm{Fin}\) blocks back to \((\mathbb {N} \times \mathrm{Bool})\) via \(p \mapsto (p.1.\mathrm{val}, p.2)\) recovers the original list \(l\).

Lemma 35.18 toFinBlock is nonempty for nonempty input
#

If \(l \neq []\) then \(\mathrm{toFinBlock}\, w\, l\, h \neq []\).

Lemma 35.19 Aux indices bounded by term length

When the processed literals come from \(t.\mathrm{zipIdx}\), every entry of the aux output of \(\mathrm{processClauseLits}\) has first coordinate strictly less than \(t.\mathrm{length}\).

The aux output of \(\mathrm{razborovEncode.go}\) (started with empty accumulator) can be written as \(\mathrm{triplesToAux}\, w\, ts\) for some triple list \(ts\) whose length is bounded by the path length and whose last element, if any, has marker flag true. This is the main structural invariant of the encoder.

There exists a function \(g\) from aux lists into \(\mathrm{Fin}\, d \to \mathrm{Fin}\, w \times \mathrm{Bool} \times \mathrm{Bool}\) that is injective on the image of the Razborov encoder over bad \(s\)-restrictions with fixed \(\gamma \). This isolates the combinatorial encoding of each of the \(d\) path steps as a triple \((\mathrm{position}, \mathrm{direction}, \mathrm{hasMarker})\).

The number of distinct aux lists produced by the Razborov encoder on bad restrictions with a fixed first component \(\gamma \) is at most \((4w)^d\).

The number of bad \(s\)-restrictions \(\rho \) mapping to a fixed \(\gamma \) under the encoder is at most \((4w)^d\), since each of the \(d\) path steps carries \(w \cdot 2 \cdot 2 = 4w\) possibilities.

Lemma 35.24 Number of restrictions with \(k\) free variables

The number of restrictions of \(\{ 0,\dots ,n-1\} \) with exactly \(k\) free variables equals \(\binom {n}{k} \cdot 2^{\, n-k}\).

Lemma 35.25 Updating a free variable decreases numFree by one

If \(\rho \, v = \mathrm{none}\), then updating \(\rho \) at \(v\) to \(\mathrm{some}\, b\) decreases \(\mathrm{numFree}\) by exactly one: \(\mathrm{numFree}(\rho [v \mapsto b]) + 1 = \rho .\mathrm{numFree}\).

Lemma 35.26 processClauseLits preserves free-variable agreement

If \(\rho _0\) and \(\sigma \) have the same free variables, then after \(\mathrm{processClauseLits}\) the updated \(\rho _0\) and \(\sigma \) components still agree on which variables are free.

Lemma 35.27 Free-variable count of \(\sigma \) after processClauseLits

Under the invariants that \(\rho _0\) and \(\sigma \) share free variables and each processed literal’s variable is free in \(\rho _0\), the \(\sigma \)-component of \(\mathrm{processClauseLits}\) has \(\mathrm{numFree}\) decreased by exactly \(\min (\mathrm{lits.length}, \mathrm{path.length})\).

If \(\rho \) is a bad restriction (so \(\mathrm{dtDepth}(f|_\rho ) \gt d\)), then the deepest path of the canonical decision tree \(\mathrm{canonicalDTree}\, f\, \rho \) has length strictly greater than \(d\).

Lemma 35.29 Encoder path length equals \(d\) on bad restrictions

When \(\rho \) is bad, the prefix \((\mathrm{canonicalDTree}\, f\, \rho ).\mathrm{deepPath}.\mathrm{take}\, d\) used by the encoder has length exactly \(d\).

Lemma 35.30 Path length consumed by processClauseLits

\(\mathrm{processClauseLits}\) consumes exactly \(\min (\mathrm{lits.length}, \mathrm{path.length})\) path entries; the remaining path length plus this minimum equals the original path length.

Lemma 35.31 Updating to some decreases numFree by at most one

Updating \(\rho \) at \(v\) to \(\mathrm{some}\, b\) decreases \(\mathrm{numFree}\) by at most one: \(\mathrm{numFree}(\rho [v \mapsto b]) + 1 \geq \rho .\mathrm{numFree}\).

Lemma 35.32 Remaining path bounded by remaining free variables

If the initial path length is at most \(\rho _0.\mathrm{numFree}\), then after \(\mathrm{processClauseLits}\) the remaining path length is at most the updated \(\rho _0\)’s \(\mathrm{numFree}\).

Lemma 35.33 Canonical tree has depth zero when all clauses killed

If every clause of \(f\) is killed by \(\rho \), the canonical decision tree for \(f|_\rho \) is the leaf \(\mathrm{false}\) and hence has depth \(0\).

Lemma 35.34 Canonical tree has depth zero when a clause is fixed

If some clause of \(f\) is fixed (satisfied) by \(\rho \), the canonical decision tree for \(f|_\rho \) is the leaf \(\mathrm{true}\) and hence has depth \(0\).

Definition 35.35 Canonical path predicate

\(\mathrm{IsCanonicalPath}\, f\, \rho \, \mathrm{path}\) holds when \(\mathrm{path}\) is an initial segment of the canonical decision tree’s deepest root-to-leaf path for \(f|_\rho \), i.e. \(\mathrm{path} = (\mathrm{canonicalDTree}\, f\, \rho ).\mathrm{deepPath}.\mathrm{take}\, (\mathrm{path.length})\). This is the invariant carried by the Razborov encoder.

Lemma 35.36 Filtered zipIdx preserves length

Filtering \(t.\mathrm{zipIdx}\) by a predicate on the literal component has the same length as filtering the original term \(t\) by the same predicate.

Lemma 35.37 Filtered zipIdx first component

The literal component of the \(k\)-th element of the filtered \(t.\mathrm{zipIdx}\) equals the \(k\)-th element of the filtered term \(t\).

When \(f.\mathrm{find?}\) returns an alive clause \(t\) and \(\mathrm{flis}\) is the filtered (zipIdx) list of \(t\)’s free literals under \(\rho \), the variable at position \(k\) of \((\mathrm{canonicalDTree}\, f\, \rho ).\mathrm{deepPath}\) equals the variable of the \(k\)-th free literal, since the canonical tree branches on the free literals of \(t\) in clause order.

Lemma 35.39 Remaining path is a drop

The remaining path returned by \(\mathrm{processClauseLits}\) equals \(\mathrm{path}.\mathrm{drop}(\min (\mathrm{lits.length}, \mathrm{path.length}))\).

Lemma 35.40 Free-variable count of \(\rho _0\) after processClauseLits

Provided each literal’s variable is free in \(\rho _0\) and the variables are pairwise distinct, the \(\rho _0\)-component of \(\mathrm{processClauseLits}\) loses exactly \(\min (\mathrm{lits.length}, \mathrm{path.length})\) free variables.

Dropping the free-literal prefix from \((\mathrm{termSubTree}\, t\, \rho _0\, \mathrm{cont}).\mathrm{deepPath}\) yields the deep path of the continuation evaluated at the \(\mathrm{processClauseLits}\)-updated restriction, connecting the canonical tree structure to the encoder’s restriction update.

When the literals are the free literals of the first alive clause and the input path is canonical, \(\mathrm{IsCanonicalPath}\) is preserved by \(\mathrm{processClauseLits}\): the remaining path is again a canonical path for the updated restriction, and its length is at most the depth of the updated canonical tree.

Lemma 35.43 Free literals have pairwise distinct variables

If \(t\) has no duplicate literals and any two literals of \(t\) with the same variable are equal, then the free-variable filter of \(t.\mathrm{zipIdx}\) has pairwise distinct variables.

When the canonical tree depth is at least the path length, \(\mathrm{razborovEncode.go}\) fully consumes the path (never terminating early), and the resulting \(\sigma \) has \(\mathrm{numFree}\) decreased by exactly the initial path length: \((\mathrm{go}\, \dots ).1.\mathrm{numFree} + \mathrm{path.length} = \sigma .\mathrm{numFree}\).

For a bad \(s\)-restriction \(\rho \) with \(d \leq s\), the first component (the \(\gamma \)-output) of \(\mathrm{razborovEncode}\, f\, w\, d\, \rho \) is an \((s-d)\)-restriction, since the encoder fixes exactly \(d\) previously free variables.

For \(d \leq s\), the number of bad \(s\)-restrictions is at most \(\binom {n}{s-d}\, 2^{\, n-(s-d)}\, (4w)^d\): every bad \(s\)-restriction is mapped by \(\mathrm{razborovEncode}\) to a \(\gamma \) with exactly \(s-d\) free variables, each fiber of this map has size at most \((4w)^d\), and there are \(\binom {n}{s-d}\, 2^{\, n-(s-d)}\) possible values of \(\gamma \).

Lemma 35.47 No bad restrictions when \(s \leq d\)

If \(s \leq d\), the set of restrictions that are simultaneously \(s\)-restrictions and bad restrictions for depth \(d\) is empty.

Definition 35.48 Decision tree to DNF
#

Converts a decision tree into a DNF whose terms are the conjunctions of literals along each root-to-leaf path ending in a \(\mathrm{true}\) leaf.

Definition 35.49 Decision tree to CNF
#

Converts a decision tree into a CNF whose clauses are the disjunctions of negated literals along each root-to-leaf path ending in a \(\mathrm{false}\) leaf.

Lemma 35.50 Decision-tree-depth witness tree

For any Boolean function \(f\) there exists a decision tree \(T\) computing \(f\) with depth at most \(\mathrm{dtDepth}\, f\).

If \(\mathrm{dtDepth}\, f \leq d\), then \(f\) is computed by a DNF of width at most \(d\) and by a CNF of width at most \(d\).

Definition 35.52 Flip a literal’s polarity
#

Negates a literal by flipping its polarity bit while keeping its variable.

Lemma 35.53 flipNeg negates the literal value

\((l.\mathrm{flipNeg}).\mathrm{eval}\, x = \lnot \, (l.\mathrm{eval}\, x)\).

Lemma 35.54 flipNeg preserves the variable
#

\((l.\mathrm{flipNeg}).\mathrm{var} = l.\mathrm{var}\).

Lemma 35.55 flipNeg is injective
#

The map \(\mathrm{Literal.flipNeg}\) is injective.

Definition 35.56 CNF to De Morgan dual DNF

Converts a CNF \(\psi \) to its De Morgan dual DNF by negating every literal, so each clause (a disjunction) becomes a term (a conjunction) of negated literals: \(\lnot \bigl(\bigwedge _i \bigvee _j l_{ij}\bigr) = \bigvee _i \bigl(\bigwedge _j \lnot l_{ij}\bigr)\).

Lemma 35.57 cnfToDualDNF preserves width

\((\mathrm{cnfToDualDNF}\, \psi ).\mathrm{width} = \psi .\mathrm{width}\).

Lemma 35.58 cnfToDualDNF negates the value

\((\mathrm{cnfToDualDNF}\, \psi ).\mathrm{eval}\, x = \lnot \, (\psi .\mathrm{eval}\, x)\).

Definition 35.59 Negate decision tree leaves
#

Negates every leaf of a decision tree, leaving its branching structure unchanged.

Lemma 35.60 negateLeaves negates the value

\(T.\mathrm{negateLeaves}.\mathrm{eval}\, x = \lnot \, (T.\mathrm{eval}\, x)\).

Lemma 35.61 negateLeaves preserves depth

\(T.\mathrm{negateLeaves}.\mathrm{depth} = T.\mathrm{depth}\).

Lemma 35.62 Decision-tree depth is invariant under negation

\(\mathrm{dtDepth}(\lnot f) = \mathrm{dtDepth}\, f\).

Lemma 35.63 Restriction commutes with negation

\(\mathrm{restrictFn}(\lnot f)\, \rho = \lnot \, (\mathrm{restrictFn}\, f\, \rho )\), pointwise.

Lemma 35.64 Bad restriction is invariant under negation

\(\mathrm{IsBadRestriction}(\lnot f)\, d\, \rho \iff \mathrm{IsBadRestriction}\, f\, d\, \rho \).

Lemma 35.65 Dual DNF preserves no-duplicate clauses

If every clause of \(\psi \) has no duplicate literals, then every term of \(\mathrm{cnfToDualDNF}\, \psi \) has no duplicate literals.

Lemma 35.66 Dual DNF preserves variable-distinctness

If within each clause of \(\psi \) any two literals with the same variable are equal, then the same holds within every term of \(\mathrm{cnfToDualDNF}\, \psi \).

For a CNF \(\psi \) of width at most \(w\) on \(n\) variables with \(5s \leq n\) and clauses free of duplicate or conflicting variables, the number of \(s\)-restrictions \(\rho \) under which \(\psi |_\rho \) has decision-tree depth \(\gt d\) satisfies

\[ \left\lvert \{ \rho : \mathrm{IsRestriction}\, s\, \rho \wedge \mathrm{IsBadRestriction}\, \psi .\mathrm{eval}\, d\, \rho \} \right\rvert \cdot n^d \; \leq \; \mathrm{numSRestrictions}\, n\, s \cdot (10\, s\, w)^d . \]

For a CNF \(\psi \) of width at most \(w\) with \(5s \leq n\) and well-formed clauses, the number of \(s\)-restrictions \(\rho \) for which \(\psi |_\rho \) cannot be represented by a DNF of width \(\leq w\) satisfies

\[ \left\lvert \{ \rho : \mathrm{IsRestriction}\, s\, \rho \wedge \lnot \, \exists \varphi ,\ \varphi .\mathrm{width} \leq w \wedge \varphi \equiv \psi |_\rho \} \right\rvert \cdot n^w \; \leq \; \mathrm{numSRestrictions}\, n\, s \cdot (10\, s\, w)^w . \]

35.3 Additional declarations

Lemma 35.69 Binomial-times-power counting inequality
#

For natural numbers \(n, s, d\) with \(5s \leq n\) and \(d \leq s\),

\[ \binom {n}{s-d} \cdot (4n)^d \; \leq \; \binom {n}{s} \cdot (5s)^d . \]

This is the purely combinatorial inequality used to convert the bad-restriction count into the final \((10\, s\, w)^d\) form of the switching lemma.