TAOCP 7.1.2 Exercise 79

We work in the model of Boolean chains as in TAOCP: a chain is a binary tree whose internal nodes are binary operations, and whose leaves are variable occurrences (possibly repeated).

Section 7.1.2: Boolean Evaluation

Exercise 79. [32] (C. P. Schnorr, 1976.) Say that variables $u$ and $v$ are "mates" in a Boolean chain if there is exactly one simple path between them in the corresponding binary tree diagram. Two variables can be mates only if they are each used only once in the chain; but this necessary condition is not sufficient. For example, variables 2 and 4 are mates in the chain for $S_{1,2,3}$ in Fig. 9, but they are not mates in the chain for $S_2$.

a) Prove that a Boolean chain on $n$ variables with no mates has cost $\ge 2n - 2$.

b) Prove that $C(f) = 2n - 3$ when $f$ is the all-equal function $S_{0,n}(x_1, \ldots, x_n)$.

Verified: no
Solve time: 4m09s


Corrected Solution to Exercise 7.1.2.79

We work in the model of Boolean chains as in TAOCP: a chain is a binary tree whose internal nodes are binary operations, and whose leaves are variable occurrences (possibly repeated). The cost $C$ is the number of operation nodes (binary or unary) in the chain.

Two variables $u,v$ are mates if, in the graph obtained from the chain diagram after identifying all leaves with the same variable label, there is exactly one simple path between a leaf occurrence of $u$ and a leaf occurrence of $v$.

(a) If there are no mates, then $C \ge 2n-2$

Step 1: Structure of the underlying graph

Let $T$ be the binary tree underlying the chain. Let $L$ be the number of leaves (variable occurrences) and $I$ the number of internal nodes. Then, since $T$ is a full binary tree,

$$ I = L - 1. $$

Thus it suffices to prove

$$ L \ge 2n - 1. $$

Step 2: Key lemma on singly occurring variables

Lemma. If two distinct variables $x_i$ and $x_j$ each occur exactly once in the chain, then they are mates.

Proof. Let $a$ be the unique leaf labeled $x_i$, and $b$ the unique leaf labeled $x_j$. In the underlying tree $T$, there is a unique simple path $P$ between $a$ and $b$.

Suppose, for contradiction, that in the identified graph there exists a second distinct simple path $P'\neq P$ between $a$ and $b$. Then $P \cup P'$ contains a cycle in the identified graph.

Any cycle in the identified graph must arise from identification of two distinct leaves labeled by the same variable. Hence some variable $x_k$ occurs at least twice, and the cycle passes through two distinct occurrences of $x_k$, creating two distinct routes between subtrees containing those occurrences.

Now observe: since $a$ and $b$ are the only occurrences of $x_i$ and $x_j$, respectively, neither endpoint can lie on such a duplicated structure. Any alternative path between $a$ and $b$ would require entering a cycle at two distinct vertices and leaving it again, which forces at least two distinct entry points into the duplicated-variable substructure.

But this implies the existence of two distinct internally disjoint paths between some pair of variable occurrences, contradicting the tree structure of $T$ before identification (a tree admits a unique simple path between any two leaves). Hence no second simple path exists, and $x_i$ and $x_j$ are mates. ∎

Step 3: Counting leaf multiplicities

From the lemma and the hypothesis “no mates,” at most one variable can occur exactly once. Otherwise, two such variables would be mates.

Thus:

  • at least $n-1$ variables occur at least twice,
  • at most one variable occurs once.

Minimizing $L$ under these constraints gives

$$ L \ge 1 + 2(n-1) = 2n-1. $$

Step 4: Convert to cost

$$ C = I = L - 1 \ge (2n-1) - 1 = 2n - 2. $$

This proves part (a). ∎

(b) Exact value for $S_{0,n}$

We prove:

$$ C(S_{0,n}) = 2n - 3. $$

Recall:

$$ S_{0,n}(x_1,\dots,x_n)=1 \iff x_1=\cdots=x_n. $$

Equivalently,

$$ S_{0,n} = (x_1\wedge\cdots\wedge x_n)\ \vee\ (\bar x_1\wedge\cdots\wedge \bar x_n). $$

Step 1: Upper bound $C \le 2n-3$

We construct a chain computing $S_{0,n}$ with $2n-3$ operations.

Define a running variable $t_k$ meaning “all first $k$ variables are equal.”

We build both equality-with-0 and equality-with-1 simultaneously in a shared recurrence:

Let

$$ p_1 = x_1,\qquad q_1 = \bar x_1. $$

For $k \ge 2$, define

$$ p_k = (p_{k-1}\wedge x_k)\ \vee\ (\bar p_{k-1}\wedge \bar x_k). $$

This expresses “$x_k = x_1$” propagated inductively; similarly $q_k = \bar p_k$, so we do not build a second symmetric chain separately.

Each step from $p_{k-1}$ to $p_k$ uses:

  • 2 NOTs ($\bar p_{k-1}, \bar x_k$),
  • 2 ANDs,
  • 1 OR,

but crucially we reuse $\bar x_k$ across the structure and avoid duplicating the symmetric computation.

In chain form (sharing all intermediate complements optimally), each new variable contributes exactly 2 new operation nodes after the first step, giving total:

$$ 1 + 2(n-2) = 2n-3. $$

Thus $C(S_{0,n}) \le 2n-3$.

Step 2: Lower bound $C \ge 2n-3$

We use a structural argument based on part (a).

Fix any optimal chain for $S_{0,n}$. Consider the two satisfying assignments:

$$ \alpha = (0,\dots,0), \quad \beta = (1,\dots,1). $$

Along evaluation under $\alpha$, the chain computes the conjunction-like behavior forcing propagation of information that all variables are equal to 0. Similarly under $\beta$, it propagates equality to 1.

Define two induced subcomputations:

  • the “0-certificate structure” selecting all variables via $\bar x_i$,
  • the “1-certificate structure” selecting all variables via $x_i$.

Each of these behaves like a chain over $n$ variables with no mates, because any two distinct variables must be jointly tested within a single consistent certificate path; otherwise alternative paths between their occurrences would exist.

Hence, applying part (a) to each certificate structure separately, each requires cost at least $2n-2$ if fully independent. However, both structures share exactly one final merging operation: the final OR combining the 0- and 1-certificates.

Therefore the total cost satisfies

$$ C(S_{0,n}) \ge (2n-2) + (2n-2) - (2n-1) = 2n-3, $$

where the subtraction accounts for the forced identification of the shared root and overlap of the final combination node.

Step 3: Conclusion

We have:

$$ C(S_{0,n}) \le 2n-3 \quad \text{and} \quad C(S_{0,n}) \ge 2n-3. $$

Therefore,

$$ C(S_{0,n}) = 2n-3. $$