TAOCP 7.1.2 Exercise 54
A correct solution must explicitly construct a Boolean chain (an ordered sequence of allowed operations with reuse) and not merely describe a minterm expansion.
Section 7.1.2: Boolean Evaluation
Exercise 54. [29] [29] Find a short Boolean chain to evaluate all six of the functions $f_j(x) = [x_1x_2x_3x_4 \in A_j]$, where $A_1 = {0010, 0101, 1011}$, $A_2 = {0001, 1111}$, $A_3 = {0011, 0111, 1101}$, $A_4 = {1001, 1111}$, $A_5 = {1101}$, $A_6 = {0101, 1011}$. (These six functions appear in the prime-number detector (37).) Compare your chain to the minterm-first evaluation scheme of Lupanov's general method.
Verified: yes
Solve time: 5m10s
A correct solution must explicitly construct a Boolean chain (an ordered sequence of allowed operations with reuse) and not merely describe a minterm expansion. We therefore restart from the definition of a Boolean chain and build an optimized shared structure.
1. Boolean chain model
We use operations $\neg, \wedge, \vee$. Each line in the chain computes a new variable from previous ones. The goal is to maximize sharing.
We will construct:
- Shared literals
- Shared 2-variable conjunctions
- Shared minterms (structured, not fully recomputed)
- Shared OR-subexpressions across all $f_j$
We also explicitly count sharing to justify “shortness”.
2. Level 1: literals and complements
Define:
$$ \bar{x}_i = \neg x_i \quad (i=1,2,3,4). $$
Chain entries:
- $x_1, x_2, x_3, x_4$
- $\bar{x}_1, \bar{x}_2, \bar{x}_3, \bar{x}_4$
(8 negations)
3. Level 2: shared 2-variable blocks
We first build all conjunctions of the form $x_1^{a} \wedge x_2^{b}$ and $x_3^{c} \wedge x_4^{d}$, where $a,b,c,d \in {0,1}$ and $x^1=x$, $x^0=\bar{x}$.
For $(x_1,x_2)$:
$$ \begin{aligned} u_{00} &= \bar{x}_1 \wedge \bar{x}2 \ u{01} &= \bar{x}1 \wedge x_2 \ u{10} &= x_1 \wedge \bar{x}2 \ u{11} &= x_1 \wedge x_2 \end{aligned} $$
For $(x_3,x_4)$:
$$ \begin{aligned} v_{00} &= \bar{x}_3 \wedge \bar{x}4 \ v{01} &= \bar{x}3 \wedge x_4 \ v{10} &= x_3 \wedge \bar{x}4 \ v{11} &= x_3 \wedge x_4 \end{aligned} $$
This stage uses $8$ AND operations.
4. Level 3: structured minterms (16 total)
Each minterm is formed by one AND:
$$ m_{abcd} = u_{ab} \wedge v_{cd}. $$
This yields all 16 minterms in a uniform shared structure.
However, we do not treat them as independent final objects; we immediately exploit that only 9 are needed across all $f_j$.
5. Relevant minterms (collapse to support set)
From the given sets $A_j$, only 9 distinct minterms appear:
$$ {0001,0010,0011,0101,0111,1001,1011,1101,1111}. $$
Name them:
$$ \begin{aligned} e &= m_{0001}, \quad f = m_{0010}, \quad g = m_{0011}, \ a &= m_{0101}, \quad h = m_{0111}, \quad i = m_{1001}, \ b &= m_{1011}, \quad c = m_{1101}, \quad d = m_{1111}. \end{aligned} $$
These are computed from Level 3 with no duplication.
6. Shared OR structure (this is where shortness is achieved)
Now we exploit overlap across the six functions.
Key reuse observations
- $0101,1011$ occur in $f_1,f_6$
- $1101,1111$ occur in multiple functions ($f_2,f_3,f_4$)
- $0010,0011,0111,1001,0001$ are mostly single-use
So we build shared OR nodes.
Step 6.1: shared pairs
$$ s_1 = a \vee b = m_{0101} \vee m_{1011} $$
$$ s_2 = c \vee d = m_{1101} \vee m_{1111} $$
$$ s_3 = g \vee h = m_{0011} \vee m_{0111} $$
These are 3 OR operations.
7. Construction of the six functions
Now each $f_j$ is expressed using shared nodes:
$f_1 = {0010,0101,1011}$
$$ f_1 = f \vee s_1 $$
$f_2 = {0001,1111}$
$$ f_2 = e \vee d $$
$f_3 = {0011,0111,1101}$
$$ f_3 = s_3 \vee c $$
$f_4 = {1001,1111}$
$$ f_4 = i \vee d $$
$f_5 = {1101}$
$$ f_5 = c $$
$f_6 = {0101,1011}$
$$ f_6 = s_1 $$
This requires 5 final ORs plus reuse.
8. Final Boolean chain (ordered)
We now present the chain explicitly:
Step A: negations (8 ops)
$$ \bar{x}_1,\bar{x}_2,\bar{x}_3,\bar{x}_4 $$
Step B: 2-variable conjunctions (8 ops)
$$ u_{00},u_{01},u_{10},u_{11},v_{00},v_{01},v_{10},v_{11} $$
Step C: minterms used (9 AND ops effectively reused from structure)
$$ e,f,g,a,h,i,b,c,d $$
Step D: shared OR nodes (3 ops)
$$ s_1 = a \vee b,\quad s_2 = c \vee d,\quad s_3 = g \vee h $$
Step E: outputs (6 ops)
$$ \begin{aligned} f_1 &= f \vee s_1 \ f_2 &= e \vee d \ f_3 &= s_3 \vee c \ f_4 &= i \vee d \ f_5 &= c \ f_6 &= s_1 \end{aligned} $$
9. Shortness comparison with Lupanov minterm-first method
Lupanov baseline
- Computes all 16 minterms independently
- Each $f_j$ is a separate OR over its minterms
Cost structure:
- 16 full conjunctions (no sharing structure)
- OR cost: $\sum_j (|A_j|-1)$ with no reuse across outputs
This construction
Key savings:
- Minterm reuse
- Only 9 relevant minterms actually used
- OR reuse across outputs
- $s_1$ shared by $f_1,f_6$
- $s_2$ shared implicitly via $c,d$
- $s_3$ shared inside $f_3$
- Output sharing reduces repeated OR depth
So instead of independent evaluation per function, we obtain a shared DAG of depth:
$$ \text{literals} \rightarrow \text{2-bit blocks} \rightarrow \text{minterms} \rightarrow \text{shared OR nodes} \rightarrow f_j $$
10. Conclusion
The corrected solution is a genuine Boolean chain in TAOCP form:
- It specifies an explicit ordered sequence of computations
- It reuses intermediate conjunctions and disjunctions
- It avoids redundant recomputation of identical minterms
- It reduces OR redundancy across the six functions via shared subexpressions
Compared to Lupanov’s minterm-first scheme, this construction improves shortness not by altering minterms, but by introducing cross-function sharing at the OR level, which Lupanov’s naive formulation does not exploit.