#taocp
TAOCP 7.2.2.2 Exercise 99
Section 7.2.2.2: Satisfiability Exercise 99. [ 25 ] Th. Dekker devised the first correct mutual-exclusion protocol in 1965: A0. Maybe go to A1. B0. Maybe go to B1. A1. Set $a \leftarrow 1$, go to A2. B1. Set $b \leftarrow 1$, go to B2. A2. If $b$ go to A3, else to A6. B2. If $a$ go to B3, else to B6. A3. If $f$ go to A3, else to...
TAOCP 7.2.2.2 Exercise 98
Section 7.2.2.2: Satisfiability Exercise 98. ▶ [ M23 ] This exercise is about proving the nonexistence of starvation cycles (47). a) A cycle of states is called "pure" if one of the players is never bumped, and "simple" if no state is repeated. Prove that every starvation cycle, if any, is either simple or consists of two simple pure cycles that share a common state. b) If Alice is starved...
TAOCP 7.2.2.2 Exercise 97
Section 7.2.2.2: Satisfiability Exercise 97. [ 20 ] Can states A6 and B6 occur simultaneously in Peterson's protocol (49)? Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each $x_i$ to...
TAOCP 7.2.2.2 Exercise 96
Section 7.2.2.2: Satisfiability Exercise 96. [ 22 ] Find all solutions to (52) when $r = 2$. Also illustrate the fact that invariants are extremely helpful, by finding a solution with distinct states $X_0, X_1, \ldots, X_r$ and with $r$ substantially greater than 2, if the clauses involving $\Phi$ are removed. Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating...
TAOCP 7.2.2.2 Exercise 95
Section 7.2.2.2: Satisfiability Exercise 95. [ 20 ] Using invariants like (50), prove that (45) and (46) provide mutual exclusion. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each $x_i$...
TAOCP 7.2.2.2 Exercise 94
Section 7.2.2.2: Satisfiability Exercise 94. ▶ [ 21 ] Suppose we know that $(X_0 \to X_1 \to \cdots \to X_r) \land \neg\Phi(X_r)$ is unsatisfiable for $0 \le r \le k$. What clauses will guarantee that $\Phi$ is invariant? (The case $k = 1$ is (51).) Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff...
TAOCP 7.2.2.2 Exercise 93
Section 7.2.2.2: Satisfiability Exercise 93. [ 20 ] What clauses correspond to the term $\neg\Phi(X^r)$ in (51)? Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each $x_i$ to have exactly...
TAOCP 7.2.2.2 Exercise 92
Section 7.2.2.2: Satisfiability Exercise 92. [ 20 ] Suggest $O(r^2)$ clauses with which we can determine whether or not a mutual exclusion protocol permits a path $X_0 \to X_1 \to \cdots \to X_r$ of distinct states. Verified: no Solve time: 3m41s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$...
TAOCP 7.2.2.2 Exercise 91
Section 7.2.2.2: Satisfiability Exercise 91. [ M21 ] Formally speaking, Alice is said to "starve" if there is (i) an infinite sequence of transitions $X_0 \to X_1 \to \cdots$ starting from the state $X_0$, and (ii) an infinite sequence $\theta_0, \theta_1, \ldots$ of Boolean "bumps" that changes infinitely often, such that (iii) Alice is in a "maybe" or "critical" state only a finite number of times. Prove that this can...
TAOCP 7.2.2.2 Exercise 90
Section 7.2.2.2: Satisfiability Exercise 90. [ 20 ] Show that (43), (45), and (46) permit starvation, by satisfying (47) and (48). Verified: no Solve time: 3m51s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each...
TAOCP 7.2.2.2 Exercise 89
Section 7.2.2.2: Satisfiability Exercise 89. [ 21 ] Here's a mutual-exclusion protocol once recommended in 1966. Does it work? A0. Maybe go to A1. B0. Maybe go to B1. A1. Set $a \leftarrow 1$, go to A2. B1. Set $b \leftarrow 1$, go to B2. A2. If $f$ go to A3, else to A5. B2. If $f$ go to B5, else to B3. A3. If $b$ go to B3, else...
TAOCP 7.2.2.2 Exercise 88
Section 7.2.2.2: Satisfiability Exercise 88. [ 15 ] Satisfy (41) and (42) for $0 \le t < 6$, and the $20 \times 6$ additional binary clauses that exclude multiple states, along with the "embarrassing" unit clauses $(A3_6) \land (B3_6)$. Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and...
TAOCP 7.2.2.2 Exercise 87
Section 7.2.2.2: Satisfiability Exercise 87. [ 21 ] Explain why the clauses (42) represent Alice and Bob's programs (40), and give a general recipe for converting such programs into equivalent sets of clauses. Verified: no Solve time: 3m50s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 86
Section 7.2.2.2: Satisfiability Exercise 86. [ M29 ] How many Life predecessors does a random $10 \times 10$ bitmap have, on average? Verified: no Solve time: 3m49s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 85
Section 7.2.2.2: Satisfiability Exercise 85. ▶ [ 39 ] A Garden of Eden is a state of Life that has no predecessor. a) If an array of 92 cells illustrated here occurs anywhere within a bitmap $X$, verify that $X$ is a Garden of Eden. (The gray cells can be either dead or alive.) b) The orphan pattern found, with a SAT solver's help, is the smallest that is currently...
TAOCP 7.2.2.2 Exercise 84
Section 7.2.2.2: Satisfiability Exercise 84. [ 33 ] Prove that $f^*(i,j) = f(i,j)$ in the following cases when $j > 0$: (a) $i = j$, $i = j + 1$, (b) (i) $i = 0$ and $i = -1$. (c) $i = 1 - j$. (d) $i = -2$. Verified: no Solve time: 3m40s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible...
TAOCP 7.2.2.2 Exercise 83
Section 7.2.2.2: Satisfiability Exercise 83. [ 21 ] According to the previous exercise, the earliest possible time that cell $(i, j)$ can become alive, if all initial life is confined to the lower left quadrant of the plane, is at least $$f(i, j) = i[i \ge 0] + j[j \ge 0] + |i \ge 0| + |i + j \ge 0| \cdot |i + j \ge 0|$$ For example, when...
TAOCP 7.2.2.2 Exercise 82
Section 7.2.2.2: Satisfiability Exercise 82. ▶ [ 22 ] (Light speed.) Imagine Life on an infinite plane, with all cells dead at time 0 except in the lower left quadrant. More precisely, suppose $X_t = (x_{tij})$ is defined for all $t \ge 0$ and all integers $-\infty < i, j < +\infty$, and that $x_{0ij} = 0$ whenever $i > 0$ or $j > 0$. a) Prove that $x_{tij} =...
TAOCP 7.2.2.2 Exercise 81
Section 7.2.2.2: Satisfiability Exercise 81. [ 21 ] Conway discovered a remarkable "spaceship," where $X_4$ is $X_0$ shifted up 2: $$X_0 = \raisebox{0pt}{\includegraphics[height=1em]{fig_spaceship_x0}} \to \cdots \to X_4 = \raisebox{0pt}{\includegraphics[height=1em]{fig_spaceship_x4}}$$ Is there a left-right symmetrical version? (Such spaceships would eat any such spaceships?) Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where...
TAOCP 7.2.2.2 Exercise 80
Section 7.2.2.2: Satisfiability Exercise 80. [ 21 ] To counteract the problem in the previous exercise, find an eater that is symmetrical when reflected about a diagonal, so that it eats both ▶ and ▼. (You'll have to go larger than $8 \times 8$, and you'll have to wait longer for digestion.) Verified: no Solve time: 3m41s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables...
TAOCP 7.2.2.2 Exercise 79
Section 7.2.2.2: Satisfiability Exercise 79. [ 29 ] What happens if the glider meets the eater of (39) in its opposite phase (namely, ▶ instead of ▼)? Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding...
TAOCP 7.2.2.2 Exercise 78
Section 7.2.2.2: Satisfiability Exercise 78. [ 21 ] Find a solution to the four-step eater problem in (38) that works on a $7 \times n$ grid, for some $n$, instead of $8 \times 8$. Verified: no Solve time: 3m47s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the...
TAOCP 7.2.2.2 Exercise 77
Section 7.2.2.2: Satisfiability Exercise 77. [ 20 ] "Step $X_{-1}$," which precedes $X_0$ in (38), has the glider configuration ▶ instead of ▼. What conditions on the still life $X_S$ will ensure that state $X_0$ is indeed reached? (We don't want digestion to begin prematurely.) Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff...
TAOCP 7.2.2.2 Exercise 76
Section 7.2.2.2: Satisfiability Exercise 76. [ 41 ] Construct a mobile Life oscillator of period 3. Verified: no Solve time: 3m40s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each $x_i$ to have exactly one...
TAOCP 7.2.2.2 Exercise 75
Section 7.2.2.2: Satisfiability Exercise 75. [ M22 ] $[M22]$ (Stephen Silver, 2000.) Show that a finite, mobile oscillator of period $p \ge 3$ must have some cell that is alive more than once during the cycle. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$...
TAOCP 7.2.2.2 Exercise 74
Section 7.2.2.2: Satisfiability Exercise 74. [ M28 ] $[M28]$ Continuing the previous exercise, prove that no nonblank cell of a finite mobile flipflop has more than one neighbor of its own type. (This fact greatly speeds up the search for finite mobile flipflops.) Can two type A cells be diagonally adjacent? Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating...
TAOCP 7.2.2.2 Exercise 73
Section 7.2.2.2: Satisfiability Exercise 73. ▶ [ 21 ] $[21]$ (Mobile flipflops.) An oscillator of period 2 is called a flipflop , and the Life patterns of mobile flipflops are particularly appealing: Each cell is either blank (dead at every time $t$) or type A (alive when $t$ is even) or type B (alive when $t$ is odd). Every nonblank cell (i) has exactly three neighbors of the other type,...
TAOCP 7.2.2.2 Exercise 72
Section 7.2.2.2: Satisfiability Exercise 72. [ 28 ] $[28]$ Oscillators of period 3 are particularly intriguing, because Life seems so inherently binary. a) What are the smallest such oscillators (in terms of bounding box)? b) Find period-3 oscillators of sizes $9 \times n$ and $10 \times n$, with $n$ odd, that have "fourfold symmetry": The patterns are unchanged after left-right and/or up-down reflection. (Such patterns are not only pleasant to...
TAOCP 7.2.2.2 Exercise 71
Section 7.2.2.2: Satisfiability Exercise 71. ▶ [ 22 ] $[22]$ When looking for sequences of Life transition on a square grid, an asymmetrical solution will appear in eight different forms, because the grid has eight different symmetries. Furthermore, an asymmetrical periodic solution will appear in $8r$ different forms, if $r$ is the length of the period. Explain how to add further clauses so that essentially equivalent solutions will occur only...
TAOCP 7.2.2.2 Exercise 70
Section 7.2.2.2: Satisfiability Exercise 70. [ 21 ] $[21]$ The live cells of an oscillator are divided into a rotor (those that change) and a stator (those that stay alive). a) Show that the rotor cannot be just a single cell. b) Find the smallest example of an oscillator whose rotor is $\leftrightarrow \blacksquare$. c) Similarly, find the smallest oscillators of period 3 whose rotors have the following forms: $\to...
TAOCP 7.2.2.2 Exercise 69
Section 7.2.2.2: Satisfiability Exercise 69. [ 23 ] $[23]$ Find all (a) still lifes and (b) oscillators of period $> 1$ that live in a $4 \times 4$ board. Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The...
TAOCP 7.2.2.2 Exercise 68
Section 7.2.2.2: Satisfiability Exercise 68. [ 39 ] $[39]$ Find a maximum-length mobile path in which 6 to 10 cells are always alive. Verified: no Solve time: 3m40s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses...
TAOCP 7.2.2.2 Exercise 67
Section 7.2.2.2: Satisfiability Exercise 67. [**] $[2\frac{1}{2}]$ Find a mobile chessboard path $X_0 \to X_1 \to \cdots \to X_{21}$ with no more than five cells alive in each $X_i$. (The glider in (37) leaves the board after $X_{20}$.) How about $X_{22}$? Verified: no Solve time: 3m41s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le...
TAOCP 7.2.2.2 Exercise 66
Section 7.2.2.2: Satisfiability Exercise 66. [ 24 ] $[24]$ Use a SAT solver to find short counterparts to Fig. 35 in which (a) $N_1 = \mathbf{LIFE}$; (b) $X_2 = \mathbf{LIFE}$. In each case $X_0$ should have the smallest possible number of live cells. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$...
TAOCP 7.2.2.2 Exercise 65
Section 7.2.2.2: Satisfiability Exercise 65. ▶ [ 28 ] $[28]$ Describe encodings of the Life transition function (35) into clauses. a) Use only the variables $x' {ij}$ and $x {ij}$. b) Use auxiliary variables with the Bailleux and Boufkhad encoding (20)–(21), sharing intermediate results between neighboring cells as discussed in the text. Verified: no Solve time: 2m21s Setup Let $x_{ij}$ denote the state of cell $(i,j)$ before a Life transition,...
TAOCP 7.2.2.2 Exercise 64
Section 7.2.2.2: Satisfiability Exercise 64. [ 26 ] $[26]$ The exact minimum time $\hat{T}(n)$ of a sorting network for $n$ elements is a famous unsolved problem, and the fact that $\hat{T}(9) = 7$ was first established in 1987 by running a highly optimized program for many hours on a Cray 2 supercomputer. Show that this result can now be proved with a SAT solver in less than a second(!). Verified:...
TAOCP 7.2.2.2 Exercise 63
Section 7.2.2.2: Satisfiability Exercise 63. ▶ [ 29 ] $[29]$ Given an $n$-network $\alpha = [i_1 : j_1][i_2 : j_2] \cdots [i_r : j_r]$, as defined in the exercises for Section 5.3.4, explain how to use a SAT solver to test whether or not $\alpha$ is a sorting network. Hint: Use Theorem 5.3.4Z. Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean...
TAOCP 7.2.2.2 Exercise 62
Section 7.2.2.2: Satisfiability Exercise 62. [ 29 ] $[29]$ Try to learn a secret small-DNF function with $N$-bit training sets $x^{(0)}, x^{(1)}, x^{(2)}, \ldots$, where $x^{(0)}$ is random but each bit of $x^{(k)} \oplus x^{(k-1)}$ for $k > 0$ is 1 with probability $p$. (Thus, if $p$ is small, successive data points will tend to be near each other.) Do such sets turn out to be more efficient in practice...
TAOCP 7.2.2.2 Exercise 61
Section 7.2.2.2: Satisfiability Exercise 61. [ 30 ] $[30]$ Explain how to test when a set of clauses generated from a training set via (29)–(31) is satisfiable only by the function $f(x)$ in (27). Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the...
TAOCP 7.2.2.2 Exercise 60
Section 7.2.2.2: Satisfiability Exercise 60. [ 24 ] $[24]$ Experiment with the problem of learning $f(x)$ in (27) from training sets of sizes 32 and 64. Use a SAT solver to find a conjectured function, $\hat{f}(x)$; then use BDD methods to determine the probability that this $\hat{f}(x)$ differs from $f(x)$ for random $x$. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean...
TAOCP 7.2.2.2 Exercise 59
Section 7.2.2.2: Satisfiability Exercise 59. [ M20 ] $[M20]$ Compute the exact probability that $f(x)$ in (32) differs from $f(x)$ in (27). Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 58
Section 7.2.2.2: Satisfiability Exercise 58. ▶ [ 20 ] $[20]$ Discuss adding the clauses $\bar{p} {i,j} \vee \bar{q} {i,j}$ to (29), (30), and (31). Verified: no Solve time: 3m41s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the...
TAOCP 7.2.2.2 Exercise 57
Section 7.2.2.2: Satisfiability Exercise 57. [ 29 ] $[29]$ Combining the previous exercise with the methods of Section 7.1.2, exhibit a function $f$ for Table 2 that can be evaluated with only six Boolean operations(!). Verified: no Solve time: 6m33s The data supplied is insufficient to produce a correct solution to this exercise. Exercise 7.2.2.2.57 does not define the target function by itself. It refers to “Table 2”, which contains...
TAOCP 7.2.2.2 Exercise 56
Section 7.2.2.2: Satisfiability Exercise 56. ▶ [ 22 ] $[22]$ Equation (27) exhibits a function matching Table 2 that depends on only 8 of the 20 variables. Use a SAT solver to show that we can actually find a suitable $f$ that depends on only five of the $x_j$. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible...
TAOCP 7.2.2.2 Exercise 55
Section 7.2.2.2: Satisfiability Exercise 55. [ 21 ] $[21]$ Find an equation analogous to (27) that is consistent with Table 2 and has every variable complemented. (Thus the resulting function is monotone decreasing.) Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 54
Section 7.2.2.2: Satisfiability Exercise 54. ▶ [ 29 ] $[29]$ Extend Table 2 using the rule in the previous exercise. How many rows are needed before $f(x)$ has no $M$-term representation in DNF, when $M = 3$, 4, and 5? Verified: no Solve time: 4m07s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$...
TAOCP 7.2.2.2 Exercise 53
Section 7.2.2.2: Satisfiability Exercise 53. ▶ [ M20 ] $[M20]$ The numbers in Table 2 are definitely nonrandom. Can you see why? Verified: no Solve time: 3m50s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 526
Section 7.2.2.2: Satisfiability Exercise 526. [ M25 ] (David S. Johnson, 1974.) If $F$ has $m$ clauses, all of size $\ge k$, prove that some assignment leaves at most $m/2^k$ clauses unsatisfied. Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has...
TAOCP 7.2.2.2 Exercise 525
Section 7.2.2.2: Satisfiability Exercise 525. ▶ [ 40 ] Find the most difficult 3SAT problem you can that has at most 100 variables. Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses...
TAOCP 7.2.2.2 Exercise 524
Section 7.2.2.2: Satisfiability Exercise 524. ▶ [ 22 ] Find all Hamiltonian paths of the cube $P_3 \mathbin{\square} P_3 \mathbin{\square} P_3$ that have loopless shadows. Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains...
TAOCP 7.2.2.2 Exercise 523
Section 7.2.2.2: Satisfiability Exercise 523. [ 20 ] Prove that, for any $m$ or $n$, no cycle of the graph $P_m \mathbin{\square} P_n \mathbin{\square} P_2$ has loopless shadows. Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct...
TAOCP 7.2.2.2 Exercise 522
Section 7.2.2.2: Satisfiability Exercise 522. ▶ [ 26 ] (Loopless shadows.) A cyclic path within the cube $P_3 \mathbin{\square} P_3 \mathbin{\square} P_3$ is shown here, together with the three "shadows" that appear when it is projected onto each coordinate plane. Notice that the shadow at the bottom contains a loop, but the other two shadows do not. Does this cube contain a cycle whose three shadows are entirely without loops?...
TAOCP 7.2.2.2 Exercise 521
Section 7.2.2.2: Satisfiability Exercise 521. [ 30 ] Experiment with the following idea, which is much simpler than the clause-purging method described in the text: "Forget a learned clause of length $k$ with probability $p_k$," where $p_1 \ge p_2 \ge p_3 \ge \cdots$ is a tunable sequence of probabilities. Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible...
TAOCP 7.2.2.2 Exercise 520
Section 7.2.2.2: Satisfiability Exercise 520. ▶ [ 24 ] Every instance of SAT corresponds in a natural way to an integer programming feasibility problem: To find, if possible, integers $x_1, \ldots, x_n$ that satisfy the linear inequalities $0 \le x_j \le 1$ for $1 \le j \le n$ and $$l_1 + l_2 + \cdots + l_k \ge 1 \qquad \text{for each clause } C = (l_1 \vee l_2 \vee \cdots...
TAOCP 7.2.2.2 Exercise 52
Section 7.2.2.2: Satisfiability Exercise 52. [ 15 ] $[15]$ What clauses correspond to (29) and (30) when the second case on the left of Table 2, $f(1, 0, 1, 0, \ldots, 1) = 1$, is taken into account? Verified: no Solve time: 3m47s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le...
TAOCP 7.2.2.2 Exercise 519
Section 7.2.2.2: Satisfiability Exercise 519. [ 20 ] Table 7 shows inconclusive results in a race for factoring between factor.fifo and factor.lifo . What is the comparable performance of factor.rand $(m, n, z, 314159)$? Verified: no Solve time: 2m37s Solution The statement of the exercise depends on numerical data from Table 7, but that table is not included in the supplied context. The names factor.fifo , factor.lifo , and factor.rand...
TAOCP 7.2.2.2 Exercise 518
Section 7.2.2.2: Satisfiability Exercise 518. [ M32 ] [M32] Given a 3SAT problem with $m$ clauses and $n$ variables, we shall construct a $(6m + n) \times (6m + n)$ matrix $M$ of integers such that the permanent , per $M$, is zero if and only if the clauses are unsatisfiable. For example, the solvable problem (7) corresponds to the $46 \times 46$ matrix indicated here; each shaded box stands...
TAOCP 7.2.2.2 Exercise 517
Section 7.2.2.2: Satisfiability Exercise 517. [ 25 ] [25] Given clauses $C_1, \ldots, C_m$, the one-per-clause satisfiability problem asks if there is a Boolean assignment $x_1, \ldots, x_n$ such that every clause is satisfied by a unique literal. In other words, we want to solve the simultaneous equations $\Sigma C_j = 1$ for $1 \le j \le m$, where $\Sigma C_j$ is the sum of the literals of clause $C_j$....
TAOCP 7.2.2.2 Exercise 516
Section 7.2.2.2: Satisfiability Exercise 516. [ M9 ] [M9] Prove or disprove the strong exponential time hypothesis : "If $\tau < 2$, there is an integer $k$ such that no randomized algorithm can solve every $k$SAT problem in fewer than $\tau^n$ steps, where $n$ is the number of variables." Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible...
TAOCP 7.2.2.2 Exercise 515
Section 7.2.2.2: Satisfiability Exercise 515. ▶ [ 23 ] [23] ( Hard sudoku. ) Specify SAT clauses with which a designer of sudoku puzzles can meet the following specifications: (i) If cell $(i, j)$ of the puzzle is blank, so is cell $(10-i, 10-j)$, for $1 \le i, j \le 9$. (ii) Every row, every column, and every box contains at least one blank. ("Box" means one of sudoku's nine...
TAOCP 7.2.2.2 Exercise 514
Section 7.2.2.2: Satisfiability Exercise 514. [ 24 ] $[24]$ The timings quoted in the text for Algorithm W, for problems in Table 6, are based on the median of nine runs using the parameters $p = A$ and $N = 50n$, restarting from scratch if necessary until a solution is found. Those parameters worked fine in most cases, unless Algorithm W was unsuited to the task. But problem C9 was...
TAOCP 7.2.2.2 Exercise 513
Section 7.2.2.2: Satisfiability Exercise 513. [ 24 ] $[24]$ Find parameters for Algorithm L that tune it for $\mathit{rand}(3, m, n, \mathit{seed})$. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 512
Section 7.2.2.2: Satisfiability Exercise 512. [ 29 ] $[29]$ Find parameters for Algorithm C that will find an Erdős discrepancy pattern $x_1, \ldots, x_n$ rapidly. (This is problem E in Table 6.) Compare the running times of nine random runs with linear parameters (194) versus nine random runs with (194), when $n = 400, 500, 600, \ldots, 1100, 1160$, and 1161. Verified: no Solve time: 3m47s Solution In the direct...
TAOCP 7.2.2.2 Exercise 511
Section 7.2.2.2: Satisfiability Exercise 511. [ 22 ] $[22]$ Problem P4 in Table 6 is a strange set of clauses that caused Algorithm C (in Figs. 54 and 55; and it causes Algorithm L to "time out" in Fig. 53. a) The preprocessing algorithm of the text requires about 1.5 megamems to convert those 2509 clauses in 400 variables into just 2414 clauses in 339 variables. Show empirically that Algorithm...
TAOCP 7.2.2.2 Exercise 510
Section 7.2.2.2: Satisfiability Exercise 510. [ 18 ] $[18]$ When the data points A1, A2, …, X8 were plotted in Fig. 55, one by one, they sometimes covered parts of previously plotted points, because of overlaps. What test cases are partially hidden by (a) T2? (b) X6? (c) X7? Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible...
TAOCP 7.2.2.2 Exercise 51
Section 7.2.2.2: Satisfiability Exercise 51. [ 40 ] $[40]$ Study the behavior of SAT solvers on the problem of finding a small number of test patterns for all of the detectable single-stuck-at faults of the circuit $\mathit{prod}(32, 32)$. Can a complete set of patterns for this large circuit be discovered "automatically" (without relying on number theory)? Verified: no Solve time: 2m45s Solution In the direct encoding, each variable $x_i$ is...
TAOCP 7.2.2.2 Exercise 509
Section 7.2.2.2: Satisfiability Exercise 509. [ 20 ] $[20]$ Several of the "training set" tasks used when tuning Algorithm C's parameters were taken from the 100 test cases of Table 6. Why didn't this lead to a problem of "overfitting" (namely, of choosing parameters that are too closely associated with the trainees)? Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables...
TAOCP 7.2.2.2 Exercise 508
Section 7.2.2.2: Satisfiability Exercise 508. [ M20 ] $[M20]$ According to Table 7, Algorithm C proved problem T3 to be unsatisfiable after learning about 324 thousand clauses. About how many times did it enter a purging phase in step C7? Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$...
TAOCP 7.2.2.2 Exercise 507
Section 7.2.2.2: Satisfiability Exercise 507. ▶ [ 21 ] $[21]$ (Marijn Heule.) Explain why "windfalls" (see (72)) help Algorithm L to deal with miter problems such as D5. Verified: no Solve time: 3m50s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct...
TAOCP 7.2.2.2 Exercise 506
Section 7.2.2.2: Satisfiability Exercise 506. [ 22 ] $[22]$ The weighted variable interaction graph of a family of clauses has one vertex for each variable, and the weight $\Sigma, 2/(\lfloor |c| \rfloor\choose 2)$ between vertices $u$ and $v$, where the sum is over all clauses $c$ that contain both $\pm u$ and $\pm v$. Figure 52 indicates these weights indirectly, by making the heavier edges darker. a) True or false:...
TAOCP 7.2.2.2 Exercise 505
Section 7.2.2.2: Satisfiability Exercise 505. [ 21 ] $[21]$ Experiment with making Algorithm L nondeterministic, by randomizing the initial order of VAR in step L1 just as HEAP is initialized randomly in step C1. How does the modified algorithm perform on, say, problems D3, K0, and W2 of Table 6? Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its...
TAOCP 7.2.2.2 Exercise 504
Section 7.2.2.2: Satisfiability Exercise 504. ▶ [ M21 ] The problem in exercise 502 can be proved NP-complete as follows: a) Let $w_j$ be the string of length $2n$ that is entirely 0 except for 1s in positions $2j-1$ and $2j$, and let $w_{n+j} = w_j$, for $1 \le j \le n$. Describe all binary strings of length $2n$ that differ from each of $w_1, \ldots, w_{2n}$ in at most...
TAOCP 7.2.2.2 Exercise 503
Section 7.2.2.2: Satisfiability Exercise 503. [ M20 ] (Covering strings.) Given $s_j$ and $r_j$ as in exercise 502, show that every string of length $n$ is within $r_j$ bits of some $s_j$ if and only if the closest string problem has no solution with parameters $r'_j = n - 1 - r_j$. Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables...
TAOCP 7.2.2.2 Exercise 502
Section 7.2.2.2: Satisfiability Exercise 502. [ 16 ] (Closed strings.) Given binary strings $s_1, \ldots, s_m$ of length $n$, and threshold parameters $r_1, \ldots, r_m$, construct clauses that are satisfiable by $x = x_1 \ldots x_n$ if and only if $x$ differs from $s_i$ in at least $r_i$ bit positions, for $1 \le j \le m$. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is...
TAOCP 7.2.2.2 Exercise 501
Section 7.2.2.2: Satisfiability Exercise 501. [ 22 ] Martin Gardner introduced an interesting queen placement problem in Scientific American 235 , 4 (October 1976), 134–137: "Place $r$ queens on an $m \times n$ chessboard so that (i) no more than one queen per row; (ii) the fewest possible squares can be occupied without breaking rule (i); and (iii) $r$ is as small as possible." Construct clauses that are satisfiable if...
TAOCP 7.2.2.2 Exercise 500
Section 7.2.2.2: Satisfiability Exercise 500. [ 16 ] The precocious student J. H. Quick decided to extend the monkey wrench principle, arguing that if $F_0 \cup S \models f$ then the original clauses $F$ can be replaced by $F | l$. But he soon realized his mistake. What was it? Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its...
TAOCP 7.2.2.2 Exercise 50
Section 7.2.2.2: Satisfiability Exercise 50. [ 24 ] $[24]$ Demonstrate Larrabee's method of representing stuck-at faults by describing the clauses that characterize test patterns for the fault "$x_2^-$ stuck at 1" in Fig. 34. (This is the wire that splits off of $x_2$ and feeds into $x_2^3$ and $x_2^5$, then to $b_7$ and $b_5$; see Table 1.) Verified: no Solve time: 3m47s Solution In the direct encoding, each variable $x_i$...
TAOCP 7.2.2.2 Exercise 499
Section 7.2.2.2: Satisfiability Exercise 499. [ 21 ] In the pigeonhole problem, is it legitimate to include the clauses (18$_3$) together with clauses that enforce lexicographic row and column order? Verified: no Solve time: 3m40s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$....
TAOCP 7.2.2.2 Exercise 498
Section 7.2.2.2: Satisfiability Exercise 498. [ 22 ] Justify adding the symmetry-breakers (18$_3$) to the pigeonhole clauses. Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each $x_i$ to have exactly...
TAOCP 7.2.2.2 Exercise 497
Section 7.2.2.2: Satisfiability Exercise 497. [ 22 ] Use BDD methods to determine the number of $8 \times 8$ binary matrices that have both row and column order increasing in lexicographic order. How many of them have exactly $r$ 1s, for $r = 24$, $r = 25$, $r = 64 - 25 = 39$, and $r = 64 - 24 = 40$? Verified: no Solve time: 3m45s Solution In the...
TAOCP 7.2.2.2 Exercise 496
Section 7.2.2.2: Satisfiability Exercise 496. [ M20 ] B. C. Dull reasoned as follows: "The pigeonhole clauses have row and column symmetry. Therefore we can assume that the rows are lexicographically increasing from top to bottom, and the columns are lexicographically increasing from right to left. Consequently the problem is easily seen to be unsatisfiable." Was he correct? Verified: no Solve time: 5m55s Solution In the direct encoding, each variable...
TAOCP 7.2.2.2 Exercise 495
Section 7.2.2.2: Satisfiability Exercise 495. [ M22 ] Spell out the details of how we can justify appending clauses to assert (18$ 5$) and (18$ 6$), using Corollary E, whenever we have an $m \times n$ problem whose variables $x {ij}$ have both row and column symmetry. [In other words, we assume that $x {ij} \mapsto x_{\sigma(i)\rho(j)}$ is an automorphism for all permutations $\sigma$ of ${1,\ldots,m}$ and $\rho$ of ${1,\ldots,n}$.]...
TAOCP 7.2.2.2 Exercise 494
Section 7.2.2.2: Satisfiability Exercise 494. [ 21 ] Show that if $(uw)(ûŵ)$ is a symmetry of some clauses $F$, we're allowed to break symmetries as if $(uw)(\hat{u}\hat{w})$, $(u\hat{w})(\hat{u}w)$, and $(w\hat{u})(\hat{w}u)$ were also symmetries. For example, if $i < j < k$ and if $(ijk)(\hat{i}\hat{j}\hat{k})$ is a symmetry, we can assert $(\bar{x}_i \vee x_j) \wedge (\bar{x}_j \vee x_k)$ with respect to the global ordering $p_1 \ldots p_n = 1 \ldots n$....
TAOCP 7.2.2.2 Exercise 493
Section 7.2.2.2: Satisfiability Exercise 493. [ 20 ] The problem $werden(3,3;9)$ has four symmetries, because we can reflect and/or complement all the variables. How can we speed up the proof of unsatisfiability by adding clauses to break those symmetries? Verified: no Solve time: 3m54s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and...
TAOCP 7.2.2.2 Exercise 492
Section 7.2.2.2: Satisfiability Exercise 492. [ M20 ] [M20] Let $\tau$ be a signed mapping of the variables ${x_1, \ldots, x_n}$; for example, the signed mapping '4133' stands for the operation $(x_1, x_2, x_3, x_4) \mapsto (\bar{x}_4, x_1, x_3, x_3)$. When a signed mapping is applied to a clause, some of the resulting literals may coincide; or two literals might become complementary, making a tautology. When $\tau = \overline{4}133$, for...
TAOCP 7.2.2.2 Exercise 491
Section 7.2.2.2: Satisfiability Exercise 491. [ 22 ] [22] The unsatisfiable clause $R$ in (6) have the signed permutation 2341 as an automorphism. How can this fact help us to verify their unsatisfiability? Verified: no Solve time: 3m47s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 490
Section 7.2.2.2: Satisfiability Exercise 490. [ 15 ] [15] Does Theorem E hold also when $p_1 p_2 \ldots p_n$ is any signed permutation? Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses...
TAOCP 7.2.2.2 Exercise 49
Section 7.2.2.2: Satisfiability Exercise 49. [ 21 ] $[21]$ Write a program that determines exactly which of the 100 single-stuck-at faults of the circuit in Fig. 34 are detected by each of the 32 possible input patterns. Also find all the minimum sets of test patterns that will discover every such fault (unless it's not detectable). Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is...
TAOCP 7.2.2.2 Exercise 489
Section 7.2.2.2: Satisfiability Exercise 489. [ M21 ] [M21] Find a recurrence for $T_n$, the number of signed involutions on $n$ elements. Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 488
Section 7.2.2.2: Satisfiability Exercise 488. [ 24 ] [24] (Peaceable armies of queens.) Prove that armies of nine white queens and nine black queens can coexist on a chessboard with none attacking the other, but armies of size 10 cannot, by devising appropriate sets of clauses and applying Algorithm C. Also examine the effects of symmetry breaking. (This problem has sixteen symmetries, because we can swap colors and/or rotate and/or...
TAOCP 7.2.2.2 Exercise 487
Section 7.2.2.2: Satisfiability Exercise 487. ▶ [ 27 ] [27] There are $\binom{92}{2} = 4216,368$ ways to place eight queens on a chessboard. Long ago, W. H. Rouse asked which of these leaves the maximum number of vacant squares to remain unattacked. [See W. W. Rouse Ball, Mathematical Recreations and Problems , third edition (London: Macmillan, 1896), 109–110.] Every subset $S$ of the vertices of a graph has three boundary...
TAOCP 7.2.2.2 Exercise 486
Section 7.2.2.2: Satisfiability Exercise 486. [ 21 ] [21] (Late Binding solitaire.) Shuffle a deck and deal out 18 cards; then try to reduce these 18 piles to a single pile, using a sequence of "captures" in which one pile is placed on top of another pile. A pile can capture only the pile to its immediate left, or the pile found by skipping left over two other piles. Furthermore...
TAOCP 7.2.2.2 Exercise 485
Section 7.2.2.2: Satisfiability Exercise 485. ▶ [ 23 ] [23] Sometimes successive transitions in the previous exercise are commutative: For example, the effect of $q_{t,k}$ and $q_{t,k+1}$ is the same as $q_{t,k+2}$ and $q_{t+1,k}$. Explain how to break symmetry in such cases, by allowing only one of the two possibilities. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its...
TAOCP 7.2.2.2 Exercise 484
Section 7.2.2.2: Satisfiability Exercise 484. [ 22 ] [22] ( Graph quenching. ) A graph with vertices $(v_1, \ldots, v_n)$ is called "quenchable" if either (i) $n = 1$; or (ii) there's a $k$ such that $v_k - v_{k+1}$ and the graph on $(v_1, \ldots, v_{k-1}, v_{k+1}, \ldots, v_n)$ can be quenched; or (iii) there's an $l$ such that $v_l - v_{l+3}$ and the graph on $(v_1, \ldots, v_{l-1}, v_{l+2},...
TAOCP 7.2.2.2 Exercise 483
Section 7.2.2.2: Satisfiability Exercise 483. [ 21 ] [21] Symmetry between colors was broken in the coloring problems of Table 6 by assigning fixed colors to a large clique in each graph. But many graphs have no large clique, so a different strategy is necessary. Explain how to encode the "restricted growth string" principle (see Section 7.2.1.5) with appropriate clauses, given an ordering $v_1 v_2 \ldots v_n$ of the vertices:...
TAOCP 7.2.2.2 Exercise 482
Section 7.2.2.2: Satisfiability Exercise 482. ▶ [ 26 ] [26] ( Erdős discrepancy patterns. ) The binary sequence $y_1 \ldots y_t$ is called strongly balanced if we have $|\sum_{j=1}^{k}(2y_j - 1)| \le 2$ for $1 \le k \le t$. a) Show that this balance condition needs to be checked only for odd $k \ge 3$. b) Describe clauses that efficiently characterize a strongly balanced sequence. c) Construct clauses that are...
TAOCP 7.2.2.2 Exercise 481
Section 7.2.2.2: Satisfiability Exercise 481. ▶ [ 28 ] [28] An ordered bit pair $xy$ can be encoded by another ordered bit pair $[xy] = (x \bar y)(y)$ without loss of information, because $[xy] = uv$ implies $[uv] = xy$. a) Find an optimum circuit that computes $([z z']^\dagger)_2 = x_1 + x_2 + 1$. Find an optimum circuit that computes $((u \oplus v) + v)$, and note that $v[00]...
TAOCP 7.2.2.2 Exercise 480
Section 7.2.2.2: Satisfiability Exercise 480. [ 25 ] [25] Suppose the values 0, 1, 2 are encoded by the two-bit codes $x_1 x_r = 00, 01$, and $1*$, respectively, where 10 and 11 both represent 2. (See Eq. 7.1.3–(120).) a) Find an optimum circuit for mod 3 addition: $z_{1*} = (x_{1r} + y_{1r}) \bmod 3$. b) Find an optimum circuit that computes $x_{1r} + y_{1r} + z_{1r} \pmod 3$ mod...
TAOCP 7.2.2.2 Exercise 48
Section 7.2.2.2: Satisfiability Exercise 48. [ 20 ] $[20]$ The small circuit shown here has three inputs, three XOR gates, one fanout gate, eight wires, and one output. Which single-stuck-at faults are detected by each of the eight test patterns $pqr$? Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le...
TAOCP 7.2.2.2 Exercise 479
Section 7.2.2.2: Satisfiability Exercise 479. ▶ [ 25 ] [25] Use SAT technology to find optimum circuits for the following problems: a) Compute $z_2, z_1$, and $z_0$, when $x_1 + x_2 + x_3 + x_4 = (z_2 z_1 z_0)_2$ (see 7.1.2–(27)). b) Compute $z_3, z_1$, and $z_0$, when $x_1 + x_2 + x_3 + x_4 + x_5 = (z_2 z_1 z_0)_2$. c) Compute all four symmetric functions $S_0, S_1, S_2,...
TAOCP 7.2.2.2 Exercise 478
Section 7.2.2.2: Satisfiability Exercise 478. ▶ [ 23 ] [23] Suggest ways to break symmetry in the clauses of exercise 477 . Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 477
Section 7.2.2.2: Satisfiability Exercise 477. ▶ [ 23 ] [23] ( Optimum Boolean evaluation. ) Construct clauses that are satisfiable if and only if an $r$-step normal Boolean chain that computes $m$ given functions $g_1$, $\ldots, g_m$ on $n$ variables. (For example, if $n = 3$ and $g_1 = (x_1 x_2 x_3)$, $g_2 = x_1 \oplus x_2 \oplus x_3$, such clauses with $r = 4$ and $5$ enable a SAT...
TAOCP 7.2.2.2 Exercise 476
Section 7.2.2.2: Satisfiability Exercise 476. [**] [$M23$] For $n \le 5$, find Boolean functions of $n$ variables that are (a) asymmetric but not totally asymmetric; (b) totally asymmetric. Furthermore, your functions should be the easiest possible (in the sense of having a smallest possible Boolean chain), among all functions that qualify. Hint: Combine exercises 475 and 477. Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$...
TAOCP 7.2.2.2 Exercise 475
Section 7.2.2.2: Satisfiability Exercise 475. [**] [$M22$] Entitled, a Boolean function is called asymmetric if the identity is its only symmetry; it is totally asymmetric if it is asymmetric and has no antisymmetries. a) If $f$ is totally asymmetric, how many functions are equivalent to $f$ under the operations of permuting variables, complementing variables, and/or complementing the function? b) According to (a) and 7.1.1–(95), the function $(x \vee y) \wedge...
TAOCP 7.2.2.2 Exercise 474
Section 7.2.2.2: Satisfiability Exercise 474. [**] [$M20$] A signed permutation is a symmetry of $f(x)$ if and only if $f(x) = f(\bar{x}\sigma)$ for all $x$, and it is an antisymmetry if and only if we have $f(x) = f(\bar{x}\sigma)$ for all $x$. a) How many signed permutations of $n$ elements are possible? b) Write 7514263 in cycle form, as an unsigned permutation of $(1, \ldots, 7, 1, \ldots, 7)$. c)...
TAOCP 7.2.2.2 Exercise 473
Section 7.2.2.2: Satisfiability Exercise 473. ▶ [**] [$M23$] Generalize exercise 470 to endomorphisms for the unsatisfiable clauses of Tseytin's graph parity problems in exercise 245. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains...
TAOCP 7.2.2.2 Exercise 472
Section 7.2.2.2: Satisfiability Exercise 472. [**] [$M25$] Prove that even-odd endomorphisms such as (190) in the domino covering problem can be regarded as instances of the endomorphisms in exercise 470. Verified: no Solve time: 3m54s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$....
TAOCP 7.2.2.2 Exercise 471
Section 7.2.2.2: Satisfiability Exercise 471. [ 16 ] [16] Find all fixed points of the mappings in exercise 470 when the graph is $K_{20}$. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the...
TAOCP 7.2.2.2 Exercise 470
Section 7.2.2.2: Satisfiability Exercise 470. ▶ [**] [$M22$] Another class of endomorphisms, one for every 4-cycle, can also be used in perfect matching problems: Let the vertices (instead of the edges) be totally ordered in some fashion. Every 4-cycle can be written $v_0 - v_1 - v_2 - v_3 - v_0$, with $v_0 > v_1 > v_3$ and $v_0 > v_2$; the corresponding endomorphism changes any solution for which $v_0...
TAOCP 7.2.2.2 Exercise 47
Section 7.2.2.2: Satisfiability Exercise 47. [ 30 ] $[30]$ Suppose a circuit such as Fig. 34 has $m$ outputs and $n$ inputs, with $g$ gates that transform two signals into one and $h$ gates that transform one signal into two. Find a relation between $g$ and $h$, by expressing the total number of wires in two ways. Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$...
TAOCP 7.2.2.2 Exercise 469
Section 7.2.2.2: Satisfiability Exercise 469. ▶ [**] [$M25$] Find a certificate of unsatisfiability $(C_1, C_2, \ldots, C_t)$ for the fact that an $8 \times 8$ chessboard minus cells $(1, 8)$ and $(8, 1)$ cannot be exactly covered by dominoes $h_{ij}$ and $v_{ij}$ that are fixed under all of the even-odd endomorphisms. Each $C_k$ for $1 \le k \le t$ should be a single positive literal. (Therefore the clauses for this...
TAOCP 7.2.2.2 Exercise 468
Section 7.2.2.2: Satisfiability Exercise 468. [ 20 ] [20] Experiment with the mutilated chessboard problem when the even-odd endomorphisms are modified so that (a) they use the same rule for all $i$ and $j$; or (b) they each make an independent random choice between horizontal and vertical. Verified: no Solve time: 3m48s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write...
TAOCP 7.2.2.2 Exercise 467
Section 7.2.2.2: Satisfiability Exercise 467. [ 20 ] $[20]$ Mutilate the $7 \times 8$ and $8 \times 7$ boards by removing the upper right and lower left cells. What domino coverings are fixed by all the even-odd endomorphisms like (190)? Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$...
TAOCP 7.2.2.2 Exercise 466
Section 7.2.2.2: Satisfiability Exercise 466. [ M23 ] $[M23]$ Prove that when $mn$ is even, the text's even-odd rule (190) for endomorphisms of $m \times n$ domino coverings has exactly one fixed point. Verified: no Solve time: 3m48s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 465
Section 7.2.2.2: Satisfiability Exercise 465. [ M21 ] $[M21]$ Justify the text's rule for simultaneous endomorphisms in the perfect matching problem: Any perfect matching must lead to one that's fixed by every $\tau_n$. Verified: no Solve time: 3m48s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 464
Section 7.2.2.2: Satisfiability Exercise 464. ▶ [ M25 ] $[M25]$ Transformations $\tau_1$ and $\tau_2$ don't change the text's example $10 \times 10$ matrix. Prove that they will never change any $10 \times 10$ matrix of sweep 3 that has $\nu X = 51$. Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$...
TAOCP 7.2.2.2 Exercise 463
Section 7.2.2.2: Satisfiability Exercise 463. ▶ [ M21 ] $[M21]$ Show that $X$ is a fixed point of $\tau_1$, $\tau_2$, and $\tau_3$ if and only if its rows and columns are nondecreasing. Then show that sweep$(k)$ is a simple function of sweep $\sum_{i,j} x_{ij}$, where the sum is over all binary matrices of $m \times n$, and $k$. Verified: no Solve time: 3m46s Solution In the direct encoding, each variable...
TAOCP 7.2.2.2 Exercise 462
Section 7.2.2.2: Satisfiability Exercise 462. [ 22 ] $[22]$ Explain why $\tau_1$, $\tau_2$, and $\tau_3$ preserve satisfiability in the sweep problem. Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each...
TAOCP 7.2.2.2 Exercise 461
Section 7.2.2.2: Satisfiability Exercise 461. [ 20 ] $[20]$ What additional clauses will rule out non-fixed points of $\tau_1$ and $\tau_2$? Verified: no Solve time: 3m54s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each...
TAOCP 7.2.2.2 Exercise 460
Section 7.2.2.2: Satisfiability Exercise 460. [ 21 ] $[21]$ Given $m$, $n$, $k$, and $r$, construct clauses that are satisfied by an $m \times n$ binary matrix $X = (x_{ij})$ if and only if sweep$(X) \le k$ and $\sum_{i,j} x_{ij} \ge r$. Verified: no Solve time: 7m07s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where...
TAOCP 7.2.2.2 Exercise 46
Section 7.2.2.2: Satisfiability Exercise 46. [ 30 ] $[30]$ Find the largest perfect square less than $2^{100}$ that is a binary palindrome. Verified: no Solve time: 3m52s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 459
Section 7.2.2.2: Satisfiability Exercise 459. ▶ [ 20 ] $[20]$ Let $X_{ij}$ denote the submatrix of $X$ consisting of the first $i$ rows and the first $j$ columns. Show that the numbers sweep$(X_{ij})$ satisfy a simple recurrence, from which it's easy to compute sweep$(X)$ = sweep$(X_{mn})$. Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$...
TAOCP 7.2.2.2 Exercise 458
Section 7.2.2.2: Satisfiability Exercise 458. [ 20 ] $[20]$ The simplification of clauses by removing an autarky can be regarded as the exploitation of an endomorphism. Explain why. Verified: no Solve time: 3m42s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct...
TAOCP 7.2.2.2 Exercise 457
Section 7.2.2.2: Satisfiability Exercise 457. [ HM19 ] $[HM19]$ Show that every Boolean $f(x_1, x_2, x_3, x_4)$ has more than 51 quadrillion endomorphisms, and an $n$-variable function has more than $2^{2^{n-1}}$ endomorphisms. Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has...
TAOCP 7.2.2.2 Exercise 456
Section 7.2.2.2: Satisfiability Exercise 456. [ M21 ] $[M21]$ For how many functions $f(x_1, x_2, x_3, x_4)$ is (187) an endomorphism? Verified: no Solve time: 3m48s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each...
TAOCP 7.2.2.2 Exercise 455
Section 7.2.2.2: Satisfiability Exercise 455. [ M20 ] $[M20]$ Suppose we know that (187) is an endomorphism of some given clauses $F$ on the variables ${x_1, x_2, x_3, x_4}$. Can we be sure that $F$ is satisfiable if and only if $F \wedge C$ is satisfiable, when (a) $C = 124$, i.e., $C = (\bar{x}_1 \vee x_2 \vee \bar{x}_4)$? (b) $C = 234$? (c) $C = 123$? (d) $C =...
TAOCP 7.2.2.2 Exercise 454
Section 7.2.2.2: Satisfiability Exercise 454. [ 15 ] $[15]$ If $\tau$ is an endomorphism for the solutions of $f$, show that $f(x) = f(x\tau)$ for every cyclic element $x$ (every element that's in a cycle of $\tau$). Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le...
TAOCP 7.2.2.2 Exercise 453
Section 7.2.2.2: Satisfiability Exercise 453. [ M23 ] $[M23]$ An $m \times n$ matrix $X = {x_{ij}}$ is said to be decomposable if it has row indices $R \subseteq {1, \ldots, m}$ and column indices $C \subseteq {1, \ldots, n}$ such that $0 < |R| + |C| < m + n$, with $x_{ij} = 0$ whenever $(i \in R$ and $j \notin C)$ or $(i \notin R$ and $j \in...
TAOCP 7.2.2.2 Exercise 452
Section 7.2.2.2: Satisfiability Exercise 452. [ 34 ] $[34]$ Find a nonchromatic rectangle with four colors on an $18 \times 18$ board. Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 451
Section 7.2.2.2: Satisfiability Exercise 451. ▶ [ 28 ] [28] Find a way to color the squares of a $10 \times 10$ board with three colors, so that no rectangle has all four corners of the same color. Prove furthermore that every such "nonchromatic rectangle" board has the color distribution ${34, 34, 32}$, not ${34, 33, 33}$. But show that if any square of the board is removed, a nonchromatic...
TAOCP 7.2.2.2 Exercise 450
Section 7.2.2.2: Satisfiability Exercise 450. [ 25 ] [25] Prove that there is essentially only one $10 \times 10$ quad-free system of points and lines with 34 incidences. Hint: First show that every line must contain either 3 points or 4 points; hence every point must belong to either 3 lines or 4 lines. Verified: no Solve time: 3m51s Solution In the direct encoding, each variable $x_i$ is represented by...
TAOCP 7.2.2.2 Exercise 45
Section 7.2.2.2: Satisfiability Exercise 45. [ 20 ] $[20]$ Specify clauses that constrain $(z_1 \ldots z_5)_2$ to be a perfect square. Verified: no Solve time: 3m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each...
TAOCP 7.2.2.2 Exercise 449
Section 7.2.2.2: Satisfiability Exercise 449. [ 21 ] [21] Exhibit $n \times n$ quad-free matrices that contain the maximum number of 1s and obey the lexicographic constraints (185), (186), for $8 \le n \le 16$. Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if...
TAOCP 7.2.2.2 Exercise 448
Section 7.2.2.2: Satisfiability Exercise 448. [ M23 ] What is $Z(m,n)$ when $m$ is odd and $n = m(m-1)/6$? Hint: See 6.5–(16). Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 447
Section 7.2.2.2: Satisfiability Exercise 447. ▶ [ 22 ] [22] Determine the maximum number of edges in a girth-8 subgraph of $K_{8,8}$. Verified: no Solve time: 7m52s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing...
TAOCP 7.2.2.2 Exercise 446
Section 7.2.2.2: Satisfiability Exercise 446. [ M10 ] What's the maximum number of edges in a subgraph of $K_{m,n}$ that has girth $\ge 6$? (Express your answer in terms of $m$ and $n$.) Verified: no Solve time: 3m48s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 445
Section 7.2.2.2: Satisfiability Exercise 445. ▶ [ 22 ] [22] Find short certificates of unsatisfiability for the pigeonhole clauses (106)–(107), when they are supplemented by (a) (181); (b) (182); (c) (183). Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size...
TAOCP 7.2.2.2 Exercise 444
Section 7.2.2.2: Satisfiability Exercise 444. [ M26 ] The following single lookahead unit resolution algorithm, called SLUR, returns either 'sat', 'unsat', or 'maybe', depending on whether a given set $F$ of clauses is satisfiable, unsatisfiable, or beyond its ability to decide via easy propagations: E1. [Propagate.] If $F \vdash \epsilon$, terminate ('unsat'). Otherwise set $F \leftarrow F|{l \mid F \vdash l}$. E2. [Satisfied?] If $F = \emptyset$, terminate ('sat'). Otherwise...
TAOCP 7.2.2.2 Exercise 443
Section 7.2.2.2: Satisfiability Exercise 443. [**] [ M2$\frac{1}{4}$ ] ( A hierarchy of hardness. ) Continuing the previous exercise, a family of clauses $F$ is said to belong to class UC$_k$ if it has the property that $$F|L \vdash \epsilon \text{ implies } F|L \vdash_k \epsilon \quad \text{ for all sets of strictly distinct literals } L.$$ ("Whenever a partial assignment yields unsatisfiable clauses, the inconsistency can be detected by...
TAOCP 7.2.2.2 Exercise 442
Section 7.2.2.2: Satisfiability Exercise 442. ▶ [ M27 ] [M27] The unit propagation relation $\vdash_1$ can be generalized to $k$th order propagation $\vdash_k$ as follows: Let $F$ be a family of clauses and let $l$ be a literal. If $(l_1, l_2, \ldots, l_p)$ is a sequence of literals, we write $L_g^- = {l_1, \ldots, l_{g-1}, \bar{l}_g}$ for $1 \le g \le p$. Then $$F \vdash_0 l \iff l \in F;$$...
TAOCP 7.2.2.2 Exercise 441
Section 7.2.2.2: Satisfiability Exercise 441. [ M35 ] [M35] Show that any threshold function $f(x_1, \ldots, x_n) = [w_1 x_1 + \cdots + w_n x_n \ge t]$ has a forcing representation whose size is polynomial in $\log n$ plus $\log|w_1| + \cdots + \log|w_n|$. Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j,...
TAOCP 7.2.2.2 Exercise 440
Section 7.2.2.2: Satisfiability Exercise 440. [ M33 ] [M33] Extend exercise 436 to context free languages , which can be defined by a set $S \subseteq N$ and by production rules $U$ and $W$ of the following well-known forms: $U \subseteq {P \to a \mid P \in N,\ a \in A}$ and $W \subseteq {P \to QR \mid P, Q, R \in N}$, where $N$ is a set of "nonterminal...
TAOCP 7.2.2.2 Exercise 44
Section 7.2.2.2: Satisfiability Exercise 44. ▶ [ 30 ] $[30]$ (Maximum ones.) Find the largest possible value of $vx + vy + v(xy)$, namely the greatest total number of 1 bits, over all multiplications of 32-bit binary $x$ and $y$. Verified: no Solve time: 3m45s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$...
TAOCP 7.2.2.2 Exercise 439
Section 7.2.2.2: Satisfiability Exercise 439. [ 20 ] [20] Construct forcing clauses expressing the constraint that $x_1 + \cdots + x_n = l$ and that there are no two consecutive 1s. (This is the special case $l_1 = \cdots = l_t = 1$ of the previous exercise, but a much simpler construction is possible.) Verified: no Solve time: 3m46s Solution In the direct encoding, each variable $x_i$ is represented by...
TAOCP 7.2.2.2 Exercise 438
Section 7.2.2.2: Satisfiability Exercise 438. [ 21 ] [21] Construct a set of forcing clauses that are satisfiable if and only if a given binary string $x_1 \ldots x_n$ contains exactly $t$ runs of 1s, having lengths $(l_1, l_2, \ldots, l_t)$ from left to right. (Equivalently, the string $x_1 \ldots x_n$ should belong to the language defined by the regular expression $0^ 1^{l_1}0^+1^{l_2}0^+ \ldots 0^+1^{l_t}0^ $.) Verified: no Solve time:...
TAOCP 7.2.2.2 Exercise 437
Section 7.2.2.2: Satisfiability Exercise 437. [ M21 ] [M21] Extend exercise 436 to the general case where $A$ has more than two letters. Verified: no Solve time: 3m49s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses...
TAOCP 7.2.2.2 Exercise 436
Section 7.2.2.2: Satisfiability Exercise 436. [ M32 ] [M32] (Nondeterministic finite-state automata.) A regular language $L$ on the alphabet $A$ can be defined in the following well-known way: Let $Q$ be a finite set of "states," and let $I \subseteq Q$ and $O \subseteq Q$ be designated "input states" and "output states." Also let $T \subseteq Q \times A \times Q$ be a set of "transition rules." Then the string...
TAOCP 7.2.2.2 Exercise 435
Section 7.2.2.2: Satisfiability Exercise 435. ▶ [ 28 ] [28] Given $l \ge 2$, construct a set of $O(n \log l)$ clauses that characterize the language $L_l$ of exercise 434 and are forcing. Verified: no Solve time: 3m53s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 434
Section 7.2.2.2: Satisfiability Exercise 434. [ 21 ] Let $L_l$ be the language defined by the regular expression $0^ 10^ $; in other words, the binary string $x_1 \ldots x_n$ is in $L_l$ if and only if it consists of zero or more 0s followed by exactly 1 1s followed by zero or more 0s. a) Explain why the following clauses are satisfiable if and only if $x_1, \ldots, x_n...
TAOCP 7.2.2.2 Exercise 433
Section 7.2.2.2: Satisfiability Exercise 433. [ 25 ] Are the lexicographic-constraint clauses in (169) forcing? Verified: no Solve time: 4m08s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each $x_i$ to have exactly one value....
TAOCP 7.2.2.2 Exercise 432
Section 7.2.2.2: Satisfiability Exercise 432. [ 34 ] Exercise 404 gives clauses for the relation $|x - y| \ge a$. Are they forcing? Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses...
TAOCP 7.2.2.2 Exercise 431
Section 7.2.2.2: Satisfiability Exercise 431. ▶ [ 20 ] Construct efficient, forcing clauses for the relation $x_1 + \cdots + x_n \le y_1 + \cdots + y_n$. Verified: no Solve time: 3m47s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding...
TAOCP 7.2.2.2 Exercise 430
Section 7.2.2.2: Satisfiability Exercise 430. [ 25 ] Similarly, Sinz's clauses (18) and (19) are forcing. Verified: no Solve time: 3m51s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each $x_i$ to have exactly one...
TAOCP 7.2.2.2 Exercise 43
Section 7.2.2.2: Satisfiability Exercise 43. ▶ [ 21 ] $[21]$ For which integers $n \ge 2$ do there exist odd palindromic binary numbers $x = (x_n \ldots x_1)_2 = (x_1 \ldots x_n)_2$ and $y = (y_n \ldots y_1)_2 = (y_1 \ldots y_n) 2$ such that their product $xy = (z {m+n} \ldots z_1)_2$ is also palindromic? Verified: no Solve time: 3m47s Solution In the direct encoding, each variable $x_i$ is...
TAOCP 7.2.2.2 Exercise 429
Section 7.2.2.2: Satisfiability Exercise 429. [ 22 ] Prove that Bailleux and Boufkhad's clauses (20), (21) are forcing: If any $r$ of the $x$'s have been set to 1, then unit propagation will force all the others to 0. Verified: no Solve time: 3m44s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and...
TAOCP 7.2.2.2 Exercise 428
Section 7.2.2.2: Satisfiability Exercise 428. [ M27 ] A generic graph $G$ on vertices ${1, \ldots, n}$ can be characterized by $\binom{n}{2}$ Boolean variables $Z = {z_{ij} \mid 1 \le i < j \le n}$, where $z_{ij} = [i \text{---} j \text{ in } G]$. Properties of $G$ can therefore be regarded as Boolean functions, $f(X)$. a) Let $f_{\text{nd}}(X) = [\chi(G) \le d]$; that is, $f_{\text{nd}}$ is true if and...
TAOCP 7.2.2.2 Exercise 427
Section 7.2.2.2: Satisfiability Exercise 427. [ M30 ] Exhibit a function $f(x_1, \ldots, x_n)$ for which every set of forcing clauses that uses no auxiliary variables has size $\Omega(3^n/n^2)$, although $f$ can actually be represented by a polynomial number of forcing clauses when auxiliary variables are introduced. Hint: See exercise 7.1.1–116. Verified: no Solve time: 3m56s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating...
TAOCP 7.2.2.2 Exercise 426
Section 7.2.2.2: Satisfiability Exercise 426. ▶ [ M20 ] Suppose $F$ is a set of clauses that represent $f(x_1, \ldots, x_n)$ using auxiliary variables $(a_1, \ldots, a_m)$ as in (170), where $m > 0$. Let $G$ be the clauses that result after variable $a_m$ has been set to 0 (as in 7.1.1–(8)). a) True or false: If $F$ is forcing then $G$ is forcing. b) True or false: If $F$...
TAOCP 7.2.2.2 Exercise 425
Section 7.2.2.2: Satisfiability Exercise 425. [ 18 ] A clause with exactly one positive literal is called a definite Horn clause, and Algorithm 7.1.1C computes the "core" of such clauses. If $F$ consists of definite Horn clauses, prove that $x$ is in the core if and only if $F \vdash_1 x$, if and only if $F \wedge (\bar{x}) \vdash_1 \epsilon$. Verified: no Solve time: 3m59s Solution In the direct encoding,...
TAOCP 7.2.2.2 Exercise 424
Section 7.2.2.2: Satisfiability Exercise 424. ▶ [ 20 ] The dual of the Pi function has the prime clauses ${123, 134, 234, 231, 12}$ (see 7.1.1–(30)). Can any of them be omitted from a forcing representation? Verified: no Solve time: 3m53s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$...
TAOCP 7.2.2.2 Exercise 423
Section 7.2.2.2: Satisfiability Exercise 423. [ 22 ] A representation $F$ that satisfies a condition like (180) but with $l$ replaced by $c$ can be called "weakly forcing." Exercise 422 shows that (175) and (176) are weakly forcing. Does the BDD of every function define a weakly forcing encoding, via (173)? Verified: no Solve time: 3m57s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating...
TAOCP 7.2.2.2 Exercise 422
Section 7.2.2.2: Satisfiability Exercise 422. [ 11 ] What does unit propagation deduce when the additional clause $(x_1)$ or $(\bar{x}_2)$ is appended to (a) $F$ in (175)? (b) $G$ in (176)? Verified: no Solve time: 3m58s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size...
TAOCP 7.2.2.2 Exercise 421
Section 7.2.2.2: Satisfiability Exercise 421. [ 18 ] Derive (176) mechanically from the branching program $I_5 = (\overline{3}2,4{:}3)$, $I_4 = (2\overline{1}{:}2)$, $I_3 = (\overline{2}7{:}0)$, $I_2 = (3\overline{7}{:}1)$, $I_1 = (\overline{3}7{:}0)$, beginning at $I_5$. Verified: no Solve time: 4m09s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain...
TAOCP 7.2.2.2 Exercise 420
Section 7.2.2.2: Satisfiability Exercise 420. [ 18 ] [18] Derive (175) mechanically (that is, "without thinking") from the Boolean chain $s \leftarrow x_1 \oplus x_2$, $c \leftarrow x_1 \wedge x_2$, $s' \leftarrow s \oplus x_3$, $c' \leftarrow s \wedge x_3$, requiring $c = c' = 0$. Verified: no Solve time: 4m22s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$...
TAOCP 7.2.2.2 Exercise 42
Section 7.2.2.2: Satisfiability Exercise 42. [ 21 ] $[21]$ Tseytін encoding analogous to (24) can be devised also for ternary operations, without introducing any additional variables besides those of the function being encoded. Illustrate this principle by encoding the basic operations $x \leftarrow t \oplus u \oplus v$ and $y \leftarrow (tuv)$ of a full adder directly, instead of composing them from $\oplus$, $\wedge$, and $\vee$. Verified: no Solve time:...
TAOCP 7.2.2.2 Exercise 419
Section 7.2.2.2: Satisfiability Exercise 419. [ M21 ] [M21] If $m, n \ge 3$, find (by hand) all solutions to the problem of exercise 418 such that (a) $\sum x_{ij} = m + 1$ (the minimum); (b) $\sum x_{ij} = mn - n - 1$ (the maximum). Verified: no Solve time: 3m56s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write...
TAOCP 7.2.2.2 Exercise 418
Section 7.2.2.2: Satisfiability Exercise 418. [ 23 ] [23] Use a branching program to construct clauses that are satisfiable if and only if $(x_{ij})$ is an $m \times n$ Boolean matrix whose rows satisfy the weighted bit condition $h_m$, and whose columns satisfy the complementary function $\bar{h}_m$. In other words, $$r_i = \sum_{j=1}^{m} x_{ij}, \quad c_j = \sum_{i=1}^{m} x_{ij}, \quad r_i = 2x_{i1} - 1, \quad c_j = 1,$$ for...
TAOCP 7.2.2.2 Exercise 417
Section 7.2.2.2: Satisfiability Exercise 417. [ 21 ] [21] Continuing exercise 432, what is the Tseytin encoding of the modus operation $s \leftarrow C , \mathtt{U} , z$"? Use it to justify the translation of branching programs via (174). Verified: no Solve time: 3m54s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and...
TAOCP 7.2.2.2 Exercise 416
Section 7.2.2.2: Satisfiability Exercise 416. [ 20 ] [20] Encode the condition: if $x_1 \ldots x_n = y_1 \ldots y_n$ then $a_1 \ldots a_m = v_1 \ldots v_m$, using $2m + 2n + 1$ clauses and $n + 1$ auxiliary variables. Hint: 2n of the clauses are in (172). Verified: no Solve time: 3m59s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible...
TAOCP 7.2.2.2 Exercise 415
Section 7.2.2.2: Satisfiability Exercise 415. [ M22 ] [M22] Generalize (169) to an encoding of lexicographic order on $d$-ary vectors, $(x_1 \ldots x_n) \le (y_1 \ldots y_n)_d$, where each $x_k = x_k^1 + \cdots + x_k^{d-1}$ and $y_k = y_k^1 + \cdots + y_k^{d-1}$ has the order encoding. What modifications to your construction will encode the strict relation $x_1 \ldots x_n < y_1 \ldots y_n$? Verified: no Solve time: 4m02s...
TAOCP 7.2.2.2 Exercise 414
Section 7.2.2.2: Satisfiability Exercise 414. [ M20 ] [M20] How many clauses will remain after the auxiliary variables $a_1, \ldots, a_{n-1}$ of (169) have been eliminated by resolution? Verified: no Solve time: 3m57s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct...
TAOCP 7.2.2.2 Exercise 413
Section 7.2.2.2: Satisfiability Exercise 413. [ M23 ] [M23] Find all CNF formulas for the function $(x_1 \oplus y_1) \vee \cdots \vee (x_n \oplus y_n)$. Verified: no Solve time: 3m58s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains...
TAOCP 7.2.2.2 Exercise 412
Section 7.2.2.2: Satisfiability Exercise 412. [ 40 ] [40] Experiment with the encoding of somewhat large numbers by using a radix-$d$ representation in which each digit has the order encoding. Verified: no Solve time: 3m59s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$....
TAOCP 7.2.2.2 Exercise 411
Section 7.2.2.2: Satisfiability Exercise 411. [ 25 ] [25] If $x = (x_m \ldots x_1)_2$, $y = (y_m \ldots y_1) 2$, and $z = (z {m+n} \ldots z_1)_2$ stand for binary numbers, the text explains how to encode the relation $xy = z$ with fewer than $20mn$ clauses, using Napier–Dadda multiplication. Explain how to encode the relations $xy \le z$ and $xy \ge z$ with fewer than $9mn$ and $11mn$...
TAOCP 7.2.2.2 Exercise 410
Section 7.2.2.2: Satisfiability Exercise 410. [ 24 ] [24] Exhibit clauses for the constraint $13x - 8y \le 7$ when $x$ and $y$ are log-encoded as 3-bit integers $x = (x_2 x_1 x_0)_2$ and $y = (y_2 y_1 y_0)_2$. (Compare with exercise 405(b).) Verified: no Solve time: 4m Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$...
TAOCP 7.2.2.2 Exercise 41
Section 7.2.2.2: Satisfiability Exercise 41. [ M31 ] $[M31]$ Determine the number of Boolean operations $\wedge$, $\vee$, $\oplus$ needed to multiply $m$-bit numbers by $n$-bit numbers with Dadda's scheme, when $2 \le m \le n$. Verified: no Solve time: 3m58s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if...
TAOCP 7.2.2.2 Exercise 409
Section 7.2.2.2: Satisfiability Exercise 409. ▶ [ M26 ] [M26] Continuing exercise 408, find the best makespans in the following cases: a) $m = 3$; $n = 3t + 1$; $w_{1j} = w_{2(j+1)} = w_{3(j+s)} = a_j$ for $1 \le j \le r$; $w_{1n} = w_{2n} = w_{3n} = \lfloor (a_1 + \cdots + a_r)/2 \rfloor$; otherwise $w_{ij} = 0$. (The positive integers $a_j$ are given.) b) $m = 4$;...
TAOCP 7.2.2.2 Exercise 408
Section 7.2.2.2: Satisfiability Exercise 408. ▶ [ 25 ] [25] (Open shop scheduling.) Consider a system of $m$ machines and $n$ jobs, together with an $m \times n$ matrix of nonnegative integer weights $W = (w_{ij})$ that represent the amount of uninterrupted time on machine $i$ that is needed by job $j$. The open shop scheduling problem seeks a way to get all the work done in $t$ units of...
TAOCP 7.2.2.2 Exercise 407
Section 7.2.2.2: Satisfiability Exercise 407. [ M22 ] [M22] If $x$, $y$, $z$ are order-encoded, with $0 \le x, y < d$ and $0 \le z < 2d-1$, the clauses $$\bigwedge_{k=1}^{2d-2} \bigwedge_{j=\max(0,k+1-d)}^{k} (x^j \vee \bar{y}^{k-j} \vee z^k)$$ are satisfiable if and only if $x + y \le z$; this is the basic idea underlying (20). Another way to encode the same relation is to introduce new order-encoded variables $u$ and...
TAOCP 7.2.2.2 Exercise 406
Section 7.2.2.2: Satisfiability Exercise 406. [ M24 ] [M24] Order-encode (a) $xy \le a$ and (b) $xy \ge a$, when $a$ is an integer constant. Verified: no Solve time: 3m56s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains...
TAOCP 7.2.2.2 Exercise 405
Section 7.2.2.2: Satisfiability Exercise 405. ▶ [ M25 ] [M25] The purpose of this exercise is to encode the constraint $ax + by \le c$, when $a$, $b$, $c$ are integer constants, assuming that $x$, $y$ are order-encoded with range $[0 ,.,. d)$. a) Prove that it suffices to consider cases where $a, b, c > 0$. b) Exhibit a suitable encoding for the special case $13x - 8y \le...
TAOCP 7.2.2.2 Exercise 404
Section 7.2.2.2: Satisfiability Exercise 404. ▶ [ 21 ] [21] Continuing exercise 403 , encode the condition $|x - y| \ge a$, for a given constant $a \ge 1$, using either (a) $d$ clauses of length $\le 4$ and no auxiliary variables; or (b) $2d - O(a)$ clauses of length $\le 3$, and one auxiliary variable. Verified: no Solve time: 4m04s Solution In the direct encoding, each variable $x_i$ is...
TAOCP 7.2.2.2 Exercise 403
Section 7.2.2.2: Satisfiability Exercise 403. [ 20 ] [20] Suppose $x$, $y$, $z$ have the order encoding, with $0 \le x, y, z < d$. What clauses enforce (a) $\min(x, y) \le z$? (b) $\max(x, y) \le z$? (c) $\min(x, y) \ge z$? (d) $\max(x, y) \ge z$? Verified: no Solve time: 4m05s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values....
TAOCP 7.2.2.2 Exercise 402
Section 7.2.2.2: Satisfiability Exercise 402. [ 18 ] [18] If $z$ has the $n$-ary representation $x^1 2^2 \cdots z^{d-1}$, encode the further condition that $x$ is (a) even; (b) odd. Verified: no Solve time: 4m08s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$....
TAOCP 7.2.2.2 Exercise 401
Section 7.2.2.2: Satisfiability Exercise 401. [ 16 ] [16] If $z$ has the unary representation $z^1 z^2 \ldots z^{d-1}$, what is the unary representation of (a) $y = \lfloor z/2 \rfloor$? (b) $z = \lfloor (x+1)/3 \rfloor$? Verified: no Solve time: 4m10s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le...
TAOCP 7.2.2.2 Exercise 400
Section 7.2.2.2: Satisfiability Exercise 400. [ 25 ] [25] Experiment with preclusion clauses versus support clauses by applying them to the $n$ queens problem. Use Algorithms L, C, and W for comparison. Verified: no Solve time: 4m40s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has...
TAOCP 7.2.2.2 Exercise 40
Section 7.2.2.2: Satisfiability Exercise 40. [ 01 ] $[01]$ Is the factorization problem (22) unsatisfiable whenever $x$ is a prime number? Verified: no Solve time: 4m Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has size $d$. The direct encoding already contains the clauses forcing each...
TAOCP 7.2.2.2 Exercise 399
Section 7.2.2.2: Satisfiability Exercise 399. [ 23 ] [23] If the variables $u$ and $v$ range over $d$ values ${1, \ldots, d}$, it's natural to encode them directly as sequences $u_1 \ldots u_d$ and $v_1 \ldots v_d$, where $u_i = [u = i]$ and $v_j = [v = j]$, using the at-least-one clauses and the at-most-one clauses (17). A binary constraint tells us which pairs $(i, j)$ are legal; for...
TAOCP 7.2.2.2 Exercise 398
Section 7.2.2.2: Satisfiability Exercise 398. [ 18 ] [18] Continuing exercise 397 , what's an appropriate way to enforce the all-different constraint when $x_0, \ldots, x_{p-1}$ are represented in the direct encoding? Verified: no Solve time: 9m43s Solution In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values. Write $$ x_{i,j}=1\iff x_i=j, $$ where $0\le i<p$ and $1\le j\le d$ if the domain has...
TAOCP 7.2.2.2 Exercise 397
Section 7.2.2.2: Satisfiability Exercise 397. [ 22 ] [22] (N. Tamura, 2014.) Suppose $x_0, x_1, \ldots, x_{p-1}$ are integer variables with the range $0 \le x_i < d$, represented in order encoding by Boolean variables $x_i^j = [x_i \ge j]$ for $0 \le i < p$ and $1 \le j < d$. Show that the all-different constraint, "$x_i \ne x_j$ for $0 \le i < j < p$," can be...
TAOCP 7.2.2.2 Exercise 396
Section 7.2.2.2: Satisfiability Exercise 396. ▶ [ 23 ] [23] (Double clique hints.) If $x$ has one of the $d$ values ${0, 1, \ldots, d-1}$, we can represent it binarywise with respect to two different orderings by letting $x^i = [x \ge j]$ and $\bar{x}^i = [x \ge j]$ for $1 \le j < d$, where $\pi$ is any given permutation. For example, if $d = 4$ and $(0\pi, 1\pi,...
TAOCP 7.2.2.2 Exercise 395
Section 7.2.2.2: Satisfiability Exercise 395. [ 20 ] [20] What clauses should replace (15), (16), and (17) if we want to use the order encoding for a graph coloring problem? Verified: no Solve time: 9m10s Correctness The solution addresses the intended topic, namely replacing the direct graph coloring clauses with clauses for the order encoding. It correctly introduces order variables $x_{v,i}$ with the intended meaning that vertex $v$ has color...
TAOCP 7.2.2.2 Exercise 394
Section 7.2.2.2: Satisfiability Exercise 394. [ 25 ] [25] One way to encode the at-most-one constraint $S_1(y_1 \ldots y_p)$ is to introduce $l = \lfloor \lg p \rfloor$ auxiliary variables together with the following $nd + n - 2^l$ clauses, which essentially "broadcast" the value of $j$ when $y_j$ becomes true: $$(\bar{y}_j \vee (-1)^{b_t} a_t) \quad \text{for } 1 \le j \le p,\ 1 \le t \le q = \lfloor...
TAOCP 7.2.2.2 Exercise 393
Section 7.2.2.2: Satisfiability Exercise 393. [ 25 ] [25] (T. R. Dawson, 1911.) Show that it's possible for each white piece in the accompanying chess diagram to capture the corresponding black piece, via a path that doesn't intersect any of the other paths. How can SAT help to solve this problem? Verified: no Solve time: 3m54s Solution Write the binary representations as $$ x=(x_{l-1}\ldots x_0) 2,\qquad y=(y {l-1}\ldots y_0)_2 ....
TAOCP 7.2.2.2 Exercise 392
Section 7.2.2.2: Satisfiability Exercise 392. [ 22 ] [22] The blank spaces in the following diagrams can be filled with letters in such a way that all occurrences of the same letter are rookwise connected: a) Demonstrate how to do it. (Puzzle $(i)$ is easy; the others less so.) b) Similarly, solve the following puzzles, but use kingwise connectedness instead. c) Construct clauses with which a SAT solver can solve...
TAOCP 7.2.2.2 Exercise 391
Section 7.2.2.2: Satisfiability Exercise 391. [ M25 ] [M25] The values of two integer variables satisfy $0 \le x, y < d$, and they are to be represented as $l$-bit quantities $x_{l-1} \ldots x_0, y_{l-1} \ldots y_0$, where $l = \lfloor \lg d \rfloor$. Specify three different ways to encode the relation $x \ne y$: a) Let $x = (x_{l-1} \ldots x_0) 2$ and $y = (y {l-1} \ldots y_0)...
TAOCP 7.2.2.2 Exercise 390
Section 7.2.2.2: Satisfiability Exercise 390. [ 23 ] Let $G$ be a graph with vertices $V$, edges $E$, $|E| = m$, $|V| = n$, and $s, t \in V$. a) Construct $O(kn)$ clauses that are satisfiable if and only if there's a path of length $k$ or less from $s$ to $t$, given $k$. b) Construct $O(m)$ clauses that are satisfiable if and only if there's at least one path...
TAOCP 7.2.2.2 Exercise 39
Section 7.2.2.2: Satisfiability Exercise 39. [ M46 ] $[M46]$ Find an optimum radio coloring of the $n$-cube, for some value of $n > 6$. Verified: no Solve time: 3m56s Solution The definition of embedding gives a direct way to express several graph problems. If $H$ is embedded in $G$, every vertex of $H$ is assigned to a distinct vertex of $G$, and every edge of $H$ must be mapped to...
TAOCP 7.2.2.2 Exercise 389
Section 7.2.2.2: Satisfiability Exercise 389. [ 22 ] In this $4 \times 4$ diagram, it's possible to trace out the phrase 'THE_ART_OF_COMPUTER_PROGRAMMING' by making only king moves and knight moves, except for the final step from R to G. Rearrange the letters so that the entire phrase can be traced. T N T E F H I R . . U P O A . N M C G ....
TAOCP 7.2.2.2 Exercise 388
Section 7.2.2.2: Satisfiability Exercise 388. [ 20 ] Show that the problems of deciding whether or not a given graph $G$ (a) contains a $k$-clique, (b) can be $k$-colored, or (c) has a Hamiltonian cycle can all be regarded as graph embedding problems. Verified: no Solve time: 3m08s Solution The definition of embedding gives a direct way to express several graph problems. If $H$ is embedded in $G$, every vertex...
TAOCP 7.2.2.2 Exercise 387
Section 7.2.2.2: Satisfiability Exercise 387. [ 21 ] Graph $G$ is said to be embedded in graph $G'$ if every vertex $v$ of $G$ corresponds to a distinct vertex $v'$ of $G'$, where $u' - v'$ in $G'$ whenever $u - v$ in $G$. Explain how to construct clauses that are satisfiable if and only if $G$ can be embedded in $G'$. Verified: no Solve time: 4m58s Solution Let $G=(V,E)$...
TAOCP 7.2.2.2 Exercise 386
Section 7.2.2.2: Satisfiability Exercise 386. ▶ [ M25 ] Let Algorithm $C_0$ be a variant of Algorithm $C$ that (i) makes all decisions at random; (ii) never forgets a learned clause; and (iii) restarts whenever a new clause has been learned. (Thus, step C5 ignores $M_0$ and $M_1$; step C6 chooses $l$ uniformly at random from among the $2(n-F)$ currently unassigned literals; step C8 backjumps while $F > t_1$, instead...
TAOCP 7.2.2.2 Exercise 385
Section 7.2.2.2: Satisfiability Exercise 385. [**] Clause $C$ is called certifiable for $F$ if $F \wedge C \vdash_1 c$, as in (119). It is said to be absorbed by $F$ if it is nonempty and $F \wedge C \vdash_1 l$ for every $l \in C$, or if it is empty and $F \vdash_1 \epsilon$. (Every clause of $F$ is obviously absorbed by $F$.) a) True or false: If $C$ is...
TAOCP 7.2.2.2 Exercise 384
Section 7.2.2.2: Satisfiability Exercise 384. [ 25 ] [25] Continuing the previous exercise, show that we can always safely forget any clause $C$ that contains a literal $l$ for which $C \circ C'$ is certifiable for $\Phi \setminus C$ whenever $C' \in \Phi$ contains $\bar{l}$. What erp rule is appropriate? Verified: no Solve time: 3m19s Solution Let $C$ be a clause in $\Phi$, and suppose that $C$ contains a literal...
TAOCP 7.2.2.2 Exercise 383
Section 7.2.2.2: Satisfiability Exercise 383. ▶ [ 23 ] [23] ( Inprocessing .) A SAT solver can partition its database of current clauses into two parts, the "hard" clauses $\Phi$ and the "soft" clauses $\Psi$. Initially $\Psi$ is empty, while $\Phi$ is $F$, the set of all input clauses. Four kinds of changes are subsequently allowed: Learning. We can append a new soft clause $C$, provided that $\Phi \cup \Psi...
TAOCP 7.2.2.2 Exercise 382
Section 7.2.2.2: Satisfiability Exercise 382. [ 30 ] [30] Although the techniques in the preceding exercises are computationally difficult to apply, show that a lookahead forest based on the dependency digraph can be used to discover some of those simplifications efficiently. Verified: no Solve time: 3m50s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the...
TAOCP 7.2.2.2 Exercise 381
Section 7.2.2.2: Satisfiability Exercise 381. [ 22 ] [22] Combining exercises 379 and 380 , show that any one of the clauses in $$(\bar{x}_1 \vee x_2) \wedge (\bar{x} 2 \vee x_3) \wedge \cdots \wedge (\bar{x} {n-1} \vee x_n) \wedge (\bar{x}_n \vee x_1)$$ can be removed if there are no other clauses with negative literals. State the erp rules. Verified: no Solve time: 3m58s Solution The information provided is not sufficient...
TAOCP 7.2.2.2 Exercise 380
Section 7.2.2.2: Satisfiability Exercise 380. [ 21 ] Sometimes we can use self-subsumption backwards, for example by weakening the clause $(l_1 \vee l_2 \vee l_k)$ to $(l_1 \vee \cdots \vee l_j)$ if each intermediate replacement of $(l_1 \vee \cdots \vee l_j)$ by $(l_1 \vee \cdots \vee l_{j-1})$ is justifiable for $3 < j \le k$. Then, if we're lucky, the clause $(l_1 \vee \cdots \vee l_j)$ is weak enough to...
TAOCP 7.2.2.2 Exercise 38
Section 7.2.2.2: Satisfiability Exercise 38. [ M25 ] $[M25]$ How many consecutive colors are needed for a radio coloring of (a) the $n \times n$ square grid $P_n \square P_n$? (b) the vertices ${x \mid x_0 \mid z \mid x, y \ge 0, x + y + z = n}$, which form a triangular grid with $n+1$ vertices on each side. Verified: no Solve time: 3m45s Solution The information provided...
TAOCP 7.2.2.2 Exercise 379
Section 7.2.2.2: Satisfiability Exercise 379. ▶ [ 20 ] (Blocked self-subsumption.) Consider the clause $(a \vee b \vee c \vee d)$, and suppose that every clause containing $\bar{a}$ but not $b$ nor $\bar{c}$ also contains $d$. Show that we can then shorten the clause to $(b \vee c \vee d)$ without affecting satisfiability. Is an erp rule needed? Verified: no Solve time: 3m45s Solution The information provided is not sufficient...
TAOCP 7.2.2.2 Exercise 378
Section 7.2.2.2: Satisfiability Exercise 378. [ 39 ] (Blocked clauses.) A clause $C = "l_1 \vee \cdots \vee l_t \vee l_1 \vee \cdots \vee l_k"$ is said to be blocked by the literal $l$ if every clause that contains $\bar{l}$ also contains either $l_1$ or $\cdots$ or $l_k$. Exercise 161(b) proves that clause $C$ can be removed without making an unsatisfiable problem satisfiable. Show that this transformation requires an erp...
TAOCP 7.2.2.2 Exercise 377
Section 7.2.2.2: Satisfiability Exercise 377. [ 22 ] (V. Vassilevska Williams.) If $G$ is a graph with $n$ vertices and $m$ edges, construct a 2SAT problem $F$ with $3n$ variables and $6m$ clauses, such that $G$ contains a triangle (a 3-clique) if and only if $F$ has a failed literal. Verified: no Solve time: 3m53s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends...
TAOCP 7.2.2.2 Exercise 376
Section 7.2.2.2: Satisfiability Exercise 376. ▶ [ 32 ] After a preprocessor has found a transformation that reduces the current set of clauses, it is supposed to try again and look for further simplifications. (See (160).) Suggest methods that will avoid unnecessary repetition of previous work, by using (and slightly extending) the data structures of exercise 374. Verified: no Solve time: 3m57s Solution The information provided is not sufficient to...
TAOCP 7.2.2.2 Exercise 375
Section 7.2.2.2: Satisfiability Exercise 375. [ 21 ] Given $ll$, how can one test efficiently whether or not the special situation in exercise 369 arises, using (and slightly extending) the data structures of exercise 374? Verified: no Solve time: 3m46s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of...
TAOCP 7.2.2.2 Exercise 374
Section 7.2.2.2: Satisfiability Exercise 374. ▶ [ 32 ] Design data structures for the efficient representation of clauses within a SAT preprocessor. Also design algorithms that (a) resolve clauses $C$ and $C'$ with respect to a variable $x$; (b) find all clauses $C'$ that are subsumed by a given clause $C$; (c) find all clauses $C'$ that are self-subsumed by a given clause $C$ and a literal $l \in C$....
TAOCP 7.2.2.2 Exercise 373
Section 7.2.2.2: Satisfiability Exercise 373. [ 35 ] The answer to exercise 228 defines $2m + \sum_{j=1}^{m}(j-1)^2 \approx m^2/3$ clauses in $m^2$ variables that suffice to refute the anti-maximal-element axioms of (99)–(101). Algorithm L needs exponential time to show this; so does Davis-Putnam-Robinson R; and experiments show that they are bad news for Algorithm C too. Show, however, that preprocessing with transformations 1–4 will rapidly prove them unsatisfiable. Verified: no...
TAOCP 7.2.2.2 Exercise 372
Section 7.2.2.2: Satisfiability Exercise 372. [ 25 ] Find a "small" set of clauses that cannot be solved entirely via transformations 1–4 and the use of exercise 369. Verified: no Solve time: 3m46s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable $v$, and the parameter $r$...
TAOCP 7.2.2.2 Exercise 371
Section 7.2.2.2: Satisfiability Exercise 371. [ 24 ] By preprocessing repeatedly with transformations 1–4, and using exercise 369, prove that the 32 clauses (9) of $warden(3,3;9)$ are unsatisfiable. Verified: no Solve time: 3m50s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable $v$, and the parameter $r$...
TAOCP 7.2.2.2 Exercise 370
Section 7.2.2.2: Satisfiability Exercise 370. [ 20 ] The clauses obtained by resolution might be needlessly complex even when exercise 369 doesn't apply. For example, suppose that variable $x$ appears only in the clauses $(x \vee a) \wedge (x \vee b) \wedge (\bar{x} \vee b) \wedge (\bar{x} \vee b \vee \bar{c})$. Resolution replaces those four clauses by three others: $(a \vee b) \wedge (a \vee b \vee \bar{c}) \wedge (a...
TAOCP 7.2.2.2 Exercise 37
Section 7.2.2.2: Satisfiability Exercise 37. [ 20 ] $[20]$ Find an optimum radio coloring of the contiguous USA graph (see 7–(17)). Verified: no Solve time: 4m03s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable $v$, and the parameter $r$ in the surrounding text. The supplied section...
TAOCP 7.2.2.2 Exercise 369
Section 7.2.2.2: Satisfiability Exercise 369. ▶ [**] [ M EA ] (N. Eén, A. Biere.) Suppose $l$ appears in clauses $C_1, \ldots, C_p$ and $\bar{l}$ appears only in clauses $C'_1, \ldots, C'_q$, where we have $C_i = (lV l_1 \vee \cdots \vee l_r)$ and $C'_j = (\bar{l}V l'_1)$ for $1 \le j \le r$. We can eliminate $|l|$ by replacing those $p + q$ clauses by only $(p-2)r + q$...
TAOCP 7.2.2.2 Exercise 368
Section 7.2.2.2: Satisfiability Exercise 368. [ 76 ] Show that subsumption and downhill resolution imply unit conditioning: Any preprocessor that does transformations 2 and 4 will also do transformation 1. Verified: no Solve time: 3m52s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable $v$, and the...
TAOCP 7.2.2.2 Exercise 367
Section 7.2.2.2: Satisfiability Exercise 367. ▶ [ 20 ] Justify the erp rule (161) for elimination by resolution. Verified: no Solve time: 3m55s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable $v$, and the parameter $r$ in the surrounding text. The supplied section excerpt ends before...
TAOCP 7.2.2.2 Exercise 366
Section 7.2.2.2: Satisfiability Exercise 366. ▶ [ 18 ] Preprocess the clauses $R'$ of (7). What erp rules are generated? Verified: no Solve time: 3m56s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable $v$, and the parameter $r$ in the surrounding text. The supplied section excerpt...
TAOCP 7.2.2.2 Exercise 365
Section 7.2.2.2: Satisfiability Exercise 365. [ M37 ] Prove that the clauses waerden (3, 3; n ) have a nontrivial (i.e., nonempty) covering assignment for all $n$ sufficiently large $n$ (although they're unsatisfiable). Verified: no Solve time: 3m47s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable...
TAOCP 7.2.2.2 Exercise 364
Section 7.2.2.2: Satisfiability Exercise 364. ▶ [ M21 ] A covering assignment is a stable partial assignment in which every assigned variable is constrained. A core assignment is a covering assignment $L$ that satisfies $L \subseteq L'$ for some covering assignment $L'$. a) True or false: The empty partial assignment $L = \emptyset$ is always covering. b) Find all the covering and core assignments of the clauses $F$ in (1)....
TAOCP 7.2.2.2 Exercise 363
Section 7.2.2.2: Satisfiability Exercise 363. ▶ [ M30 ] (Lattices of partial assignments.) A partial assignment to the variables of a satisfiability problem is called stable (or "valid") if it is consistent and cannot be extended by unit propagation. In other words, it's stable if and only if no clause is entirely false, or entirely false except for at most one unassigned literal. Variable $x_k$ of a partial assignment is...
TAOCP 7.2.2.2 Exercise 362
Section 7.2.2.2: Satisfiability Exercise 362. [ 20 ] Spell out the computations needed to finish Algorithm S in step S8. Verified: no Solve time: 3m46s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a variable $v$, and the parameter $r$ in the surrounding text. The supplied section excerpt...
TAOCP 7.2.2.2 Exercise 361
Section 7.2.2.2: Satisfiability Exercise 361. ▶ [ M25 ] Describe all fixed points $\eta_{C \to l} = \eta' {C \to l}$ of the equations (154), (156), (157), for which each $\eta {C \to l}$ and each $\eta_l$ is either 0 or 1. Verified: no Solve time: 3m50s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of...
TAOCP 7.2.2.2 Exercise 360
Section 7.2.2.2: Satisfiability Exercise 360. [ M23 ] Find all fixed points of the seven-clause system illustrated in (159), given that $\pi_1 = \pi_2 = \pi_4 = 1$. Assume also that $\eta_l \eta_{\bar{l}} = 0$ for all $l$. Verified: no Solve time: 3m46s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$,...
TAOCP 7.2.2.2 Exercise 36
Section 7.2.2.2: Satisfiability Exercise 36. ▶ [**] $[22]$ Determine $\chi^*(G)$ when $G$ is (a) the graph of the contiguous United States (see 7–(17) and exercise 7– 45 ); (b) the graph of exercise 32. Verified: no Solve time: 3m56s Solution The information provided is not sufficient to derive the requested formulas. Exercise 7.2.2.2.357 depends on equation (155) and on the definition of the quantities $\pi_0$, $\pi_s$, the “field” of a...
TAOCP 7.2.2.2 Exercise 359
Section 7.2.2.2: Satisfiability Exercise 359. [ 20 ] Equations (156) and (157) should actually have been written $$\gamma_{l \to c} = \frac{(1 - \pi_l)(1 - \eta_l) \prod_{l' \in C, l' \ne l} (1 - \eta_{l' \to c})}{\pi_l + (1 - \pi_l)(1 - \eta_l)} \quad \text{and} \quad \eta' {C \to l} = \prod {l' \in C} \gamma_{l' \to C},$$ to avoid division by zero. Suggest an efficient way to implement these...
TAOCP 7.2.2.2 Exercise 358
Section 7.2.2.2: Satisfiability Exercise 358. [ M20 ] Continuing exercise 357, prove that $r = \max(p, q, r)$ if and only if $x, y \ge \frac{1}{2}$. Verified: no Solve time: 3m Connection interrupted. Waiting for the complete answer
TAOCP 7.2.2.2 Exercise 357
Section 7.2.2.2: Satisfiability Exercise 357. ▶ [ M20 ] Let $x = \pi_0$ and $y = \pi_s$ in (155), and suppose the field of variable $v$ is $(p, q)$. Express $x$ and $y$ as functions of $p$, $q$, and $r$. Verified: no Solve time: 8m40s
TAOCP 7.2.2.2 Exercise 356
Section 7.2.2.2: Satisfiability Exercise 356. ▶ [ M35 ] (The Clique Local Lemma.) Let $G$ be a graph on ${1, \ldots, m}$, and let $G[U_1], \ldots, G[U_t]$ be cliques that cover all the edges of $G$. Assign numbers $\theta_{ij} \ge 0$ to the vertices of each $U_j$, such that $\Sigma_j = \sum_{i \in U_j} \theta_{ij} < 1$. Assume that $$\Pr(A_i) = p_i \le \theta_{ij} \prod_{k \ne i,; k \in U_k}...
TAOCP 7.2.2.2 Exercise 355
Section 7.2.2.2: Satisfiability Exercise 355. [ HM21 ] In (152), prove that $E_j \le 1/\delta$ when $(p_1, \ldots, p_m)$ has positive slack $\delta$. Hint: Consider replacing $p_i$ by $p_j + \delta p_j$. Verified: no Solve time: 3m44s Solution Let $E_j$ denote the expected number of executions of the resampling step associated with the bad event $A_j$, as in (152). The standard witness-tree expression for this expectation is $$ E_j=\sum_{\tau\in\mathcal{T}_j} w(\tau),...
TAOCP 7.2.2.2 Exercise 354
Section 7.2.2.2: Satisfiability Exercise 354. [ HM20 ] Show that the expected number $E,N$ of resampling steps in Algorithm M is at most $-M_G''(1)/M_G'(1)$. Verified: no Solve time: 3m47s Solution Let $E_j$ denote the expected number of executions of the resampling step associated with the bad event $A_j$, as in (152). The standard witness-tree expression for this expectation is $$ E_j=\sum_{\tau\in\mathcal{T}_j} w(\tau), $$ where $\mathcal{T}_j$ is the family of proper...
TAOCP 7.2.2.2 Exercise 353
Section 7.2.2.2: Satisfiability Exercise 353. [ M21 ] [M21] Consider Case 1 and Case 2 of Algorithm M as illustrated in (150). a) How many solutions $x_1 \ldots x_n$ are possible? (Generalize from $n = 7$ to any $n$.) b) How many solutions are predicted by Theorem S? c) Show that in Case 2 the lopsidependency graph is much smaller than the dependency graph. How many solutions are predicted when...
TAOCP 7.2.2.2 Exercise 352
Section 7.2.2.2: Satisfiability Exercise 352. [ M21 ] [M21] Show that $E_j \le \theta_j/(1 - \theta_j)$ in (152), when (133) holds. Verified: no Solve time: 10m35s Solution Let $E_j$ denote the expected number of executions of the resampling step associated with the bad event $A_j$, as in (152). The standard witness-tree expression for this expectation is $$ E_j=\sum_{\tau\in\mathcal{T}_j} w(\tau), $$ where $\mathcal{T}_j$ is the family of proper witness trees whose...
TAOCP 7.2.2.2 Exercise 351
Section 7.2.2.2: Satisfiability Exercise 351. [ 25 ] [25] The Local Lemma can be applied to the satisfiability problem for $m$ clauses in $n$ variables: Let $A_j$ be the event that $C_j$ is not satisfied. The dependency graph $G$ then has $i - j$ whenever two clauses $C_i$ and $C_j$ share at least one common variable. If, say, $C_k$ is $(z_3 \vee z_5 \vee x_5)$, then (133) holds whenever $p_j...
TAOCP 7.2.2.2 Exercise 350
Section 7.2.2.2: Satisfiability Exercise 350. ▶ [ HM26 ] [HM26] (W. Pegden.) Suppose Algorithm M is applied to the $m = n+1$ events $$A_j = x_j \quad \text{for } 1 \le j \le n; \qquad A_m = x_1 \vee \cdots \vee x_n.$$ Thus $A_m$ is true whenever any of the other $A_j$ is true, so we could implement step M2 by never setting $j \leftarrow m$. Alternatively, we could decide...
TAOCP 7.2.2.2 Exercise 349
Section 7.2.2.2: Satisfiability Exercise 349. ▶ [ M24 ] [M24] Analyze Algorithm M exactly in the two examples considered in the text (see (150)): For each binary vector $x = x_1 \ldots x_7$, compute the generating function $g_x(z) = \sum_t p_{x,t} z^t$, where $p_{x,t}$ is the probability that step M3 will be executed exactly $t$ times after step M1 produces $x$. Assume that step M2 always chooses the smallest possible...
TAOCP 7.2.2.2 Exercise 348
Section 7.2.2.2: Satisfiability Exercise 348. [ HM26 ] [HM26] (A. Pringsheim, 1894.) Show that any power series $f(z) = \sum_{n=0}^{\infty} a_n z^n$ with $a_n \ge 0$ and radius of convergence $\rho$, where $0 < \rho < \infty$, has a singularity at $z = \rho$. Verified: no Solve time: 3m42s Setup Let $G$ be a graph with vertices numbered by the ancestor relation $\succ$ in a forest. A graph is tree-ordered...
TAOCP 7.2.2.2 Exercise 347
Section 7.2.2.2: Satisfiability Exercise 347. ▶ [ M28 ] A graph is called chordal when it has no induced cycle $C_k$ for $k > 3$. Equivalently (see Section 7.4.2), a graph is chordal if and only if its edges can be defined by territory sets $T(a)$ that induce connected subgraphs of some tree. For example, interval graphs and forests are chordal. a) Say that a graph is tree-ordered if its...
TAOCP 7.2.2.2 Exercise 346
Section 7.2.2.2: Satisfiability Exercise 346. ▶ [ HM28 ] Write $(142)$ as $M_G = M_{G \setminus a}(1 - aK_{a,G})$ where $K_{a,G} = M_{G \setminus a^*} / M_{G \setminus a}$. a) If $(p_1, \ldots, p_m) \in \mathcal{R}(G)$, prove that $K_{a,G}$ is monotonic in all of its parameters: It does not increase if any of $p_1, \ldots, p_m$ are decreased. b) Exploit this fact to design an algorithm that computes $M_G(p_1, \ldots,...
TAOCP 7.2.2.2 Exercise 345
Section 7.2.2.2: Satisfiability Exercise 345. [ M30 ] Construct unavoidable events that satisfy $(147)$ when $(p_1, \ldots, p_m) \notin \mathcal{R}(G)$. Verified: no Solve time: 3m43s Solution A double coloring of a graph assigns a 2-element subset of a color set to each vertex, with adjacent vertices receiving disjoint subsets. A triple coloring is defined similarly with 3-element subsets. For a cycle, the color sets must therefore form a closed walk...
TAOCP 7.2.2.2 Exercise 344
Section 7.2.2.2: Satisfiability Exercise 344. [ M33 ] Given a graph $G$ as in Theorem S, let $B_1, \ldots, B_m$ have the joint probability distribution of exercise MPR–31, with $\pi_I = 0$ whenever $I$ contains distinct vertices ${i, j}$ with $i \mathbin{\text{---}} j$, otherwise $\pi_I = \prod_{i \in I} p_i$. a) Show that this distribution is legal (see exercise MPR–32) if $(p_1, \ldots, p_m) \in \mathcal{R}(G)$. b) Show that this...
TAOCP 7.2.2.2 Exercise 343
Section 7.2.2.2: Satisfiability Exercise 343. ▶ [ M25 ] If $G$ is any cograph, show that $(p_1, \ldots, p_m) \in \mathcal{R}(G)$ if and only if we have $M_G(p_1, \ldots, p_m) > 0$. Exhibit a non-cograph for which the latter statement is not true. Verified: no Solve time: 3m47s Solution A double coloring of a graph assigns a 2-element subset of a color set to each vertex, with adjacent vertices receiving...
TAOCP 7.2.2.2 Exercise 342
Section 7.2.2.2: Satisfiability Exercise 342. [ HM25 ] (Cartier and Foata, 1969.) Let $G_n$ be the graph whose vertices are the $\sum_{k=1}^{n} \binom{n}{k}(k-1)!$ cyclic permutations of subsets of ${1, \ldots, n}$, with $\sigma \mathbin{\text{---}} \tau$ when $\sigma$ and $\tau$ intersect. For example, the vertices of $G_3$ are $(1)$, $(2)$, $(3)$, $(1,2)$, $(1,3)$, $(2,3)$, $(1,2,3)$, $(1,3,2)$; and they're mutually adjacent except that $(1) \nmid (2)$, $(1) \nmid (3)$, $(1) \nmid (2,3)$,...
TAOCP 7.2.2.2 Exercise 341
Section 7.2.2.2: Satisfiability Exercise 341. [ M25 ] The involution polynomial of a set $S$ is the special case of the permutation polynomial when the cycle weights have the form $w_{jj}x$ for the 1-cycle $(j)$ and $-w_{ij}$ for the 2-cycle $(i,j)$, otherwise $w(\sigma) = 0$. For example, the involution polynomial of ${1, 2, 3, 4}$ is $w_{11}w_{22}w_{33}w_{44}x^4 - w_{11}w_{22}w_{34}x^2 - w_{11}w_{23}w_{44}x^2 - w_{11}w_{24}w_{33}x^2 - w_{12}w_{33}w_{44}x^2 - w_{13}w_{22}w_{44}x^2 - w_{14}w_{22}w_{33}x^2 +...
TAOCP 7.2.2.2 Exercise 340
Section 7.2.2.2: Satisfiability Exercise 340. ▶ [ M20 ] If we assign a weight $w(\sigma)$ to every cyclic permutation $\sigma$, then every permutation $\pi$ has a weight $w(\pi)$ that is the product of the weights of its cycles. For example, if $\pi = \binom{1,2,3,4,5,6,7}{5,1,4,2,7,6,3} = (1,3,4,2)(5,7)(6)$ then $w(\pi) = w((1,3,4,2))w((5,7))w((6))$. The permutation polynomial of a set $S$ is the sum of $w(\pi)$ over all permutations of $S$. Given any $n...
TAOCP 7.2.2.2 Exercise 34
Section 7.2.2.2: Satisfiability Exercise 34. [ HM26 ] [HM26] The fractional coloring number $\chi^*(G)$ of a graph $G$ is defined to be the minimum ratio $p/q$ for which $G$ has a $q$-tuple coloring that uses $p$ colors. a) Prove that $\chi^*(G) \le \chi(G)$ and show that equality holds in McGrager's graphs. b) Let $S_1, \ldots, S_N$ be all the independent subsets of $G$'s vertices. Show that $$\chi^*(G) = \min_{\lambda_1,\ldots,\lambda_N \ge...
TAOCP 7.2.2.2 Exercise 339
Section 7.2.2.2: Satisfiability Exercise 339. ▶ [ HM26 ] [HM26] (G. Viennot.) This exercise explores factorization of traces into pyramids. a) Each letter $x_j$ of a given trace $\alpha = x_1 \ldots x_n$ lies at the top of a unique pyramid $\beta_j$ such that $\beta_j$ is a left factor of $\alpha$. For example, in the trace $bcebcabc$ of (136), the pyramids $\beta_1, \ldots, \beta_8$ are respectively $b$, $bcb$, $bceb$, $bcf$,...
TAOCP 7.2.2.2 Exercise 338
Section 7.2.2.2: Satisfiability Exercise 338. [ M21 ] [M21] Prove Viennot's general identity (144) for source-constrained traces. Verified: no Solve time: 2m37s Solution Let $\mathcal A$ be the alphabet of the trace monoid, and let $\operatorname{src}(\alpha)$ denote the set of sources of the trace $\alpha$. For a set of letters $S\subseteq\mathcal A$, define $$ T_S=\sum_{\operatorname{src}(\alpha)\subseteq S}\alpha , $$ where the sum extends over all traces whose sources are contained in...
TAOCP 7.2.2.2 Exercise 337
Section 7.2.2.2: Satisfiability Exercise 337. [ M20 ] [M20] Suppose we obtain the graph $G'$ from $G$ by substituting a clique of vertices ${a_1, \ldots, a_k}$ for some vertex $a$, then including edges from $a_j$ to each neighbor of $a$ for $1 \le j \le k$. Describe the relation between $M_{G'}$ and $M_G$. Verified: no Solve time: 3m46s Solution A double coloring of a graph assigns a 2-element subset of...
TAOCP 7.2.2.2 Exercise 336
Section 7.2.2.2: Satisfiability Exercise 336. ▶ [ M20 ] [M20] If graphs $G$ and $H$ on distinct vertices have the Möbius series $M_G$ and $M_H$, what are the Möbius series for (a) $G \oplus H$ and (b) $G - H$? Verified: no Solve time: 3m48s Solution A double coloring of a graph assigns a 2-element subset of a color set to each vertex, with adjacent vertices receiving disjoint subsets. A...
TAOCP 7.2.2.2 Exercise 335
Section 7.2.2.2: Satisfiability Exercise 335. [ HM26 ] [HM26] If the vertices of $G$ can be ordered in such a way that $x < y < z$ and $x \not\to y$ and $y \to z$ implies $x \not\to z$, show that the Möbius series $M_G$ can be expressed as a determinant. For example, $$\text{if } G = \begin{array}{c} a \circ !!-!!\circ b \ c \circ !!-!!\circ !!-!!d \ e \circ...
TAOCP 7.2.2.2 Exercise 334
Section 7.2.2.2: Satisfiability Exercise 334. [ 25 ] [25] Design an algorithm to generate all traces of length $n$ that correspond to a graph on the alphabet ${1, \ldots, m}$, representing each trace by its lexicographically smallest string. Verified: no Solve time: 3m49s Solution A double coloring of a graph assigns a 2-element subset of a color set to each vertex, with adjacent vertices receiving disjoint subsets. A triple coloring...
TAOCP 7.2.2.2 Exercise 333
Section 7.2.2.2: Satisfiability Exercise 333. ▶ [ M20 ] [M20] (Carlitz, Scoville, and Vaughan, 1976.) Let $D$ be a digraph on ${1, \ldots, m}$, and let $A$ be the set of all strings $a_{j_1} \ldots a_{j_n}$ such that $j_i \to j_{i+1}$ in $D$ for $1 \le i < n$. Similarly let $B$ be the set of all strings $a_{j_1} \ldots a_{j_n}$ such that $j_i \not\to j_{i+1}$ for $1 \le i...
TAOCP 7.2.2.2 Exercise 332
Section 7.2.2.2: Satisfiability Exercise 332. [ 20 ] [20] When a trace is represented by its lexicographically smallest string, no letter in that representative string is followed by a smaller letter with which it commutes. (For example, no $c$ is followed by $a$ in (135), because we could get an equivalent smaller string by changing $ca$ to $ac$.) Conversely, given an ordered set of letters, some of which commute, consider...
TAOCP 7.2.2.2 Exercise 331
Section 7.2.2.2: Satisfiability Exercise 331. [ M20 ] [M20] What happens if the right-hand side of (139) is expanded without allowing any of the variables to commute with each other? Verified: no Solve time: 3m53s Solution A double coloring of a graph assigns a 2-element subset of a color set to each vertex, with adjacent vertices receiving disjoint subsets. A triple coloring is defined similarly with 3-element subsets. For a...
TAOCP 7.2.2.2 Exercise 330
Section 7.2.2.2: Satisfiability Exercise 330. ▶ [ 21 ] [21] Given any graph $G$, explain how to define territory sets $T(a)$ for its vertices $a$ in such a way that we have $a = b$ or $a \frown b$ if and only if $T(a) \cap T(b) \ne \emptyset$. (Thus traces can always be modeled by emplishments of pieces.) Under what circumstances is it possible to do this with $|T(a)| =...
TAOCP 7.2.2.2 Exercise 33
Section 7.2.2.2: Satisfiability Exercise 33. [ 21 ] [21] A double coloring of a graph is an assignment of two distinct colors to every vertex in such a way that neighboring vertices share no common colors. Similarly, a $q$-tuple coloring assigns $q$ distinct colors to each vertex. Find double and triple colorings of the cycle graphs $C_5, C_7, C_9, \ldots$, using as few colors as possible. Verified: no Solve time:...
TAOCP 7.2.2.2 Exercise 329
Section 7.2.2.2: Satisfiability Exercise 329. [ 21 ] [21] Similarly, design an algorithm that either computes $\alpha \setminus \beta$ or reports that $\alpha$ isn't a left factor of $\beta$. Verified: no Solve time: 3m48s Solution No. Theorem J and Theorem L concern different probability estimates for Algorithm W, and the hypotheses of Theorem L do not imply the statement of Theorem J. Theorem J gives a bound under the specific...
TAOCP 7.2.2.2 Exercise 328
Section 7.2.2.2: Satisfiability Exercise 328. [ 20 ] [20] Continuing exercise 327, design an algorithm that computes $\alpha/\beta$. More precisely, if $\beta$ is a right factor of $\alpha$ in the sense that $\alpha = \gamma\beta$ for some trace $\gamma$, your algorithm should compute $\gamma$; otherwise it should report that $\beta$ is not a right factor. Verified: no Solve time: 3m48s Solution No. Theorem J and Theorem L concern different probability...
TAOCP 7.2.2.2 Exercise 327
Section 7.2.2.2: Satisfiability Exercise 327. [ 22 ] [22] Design an algorithm to multiply two traces $\alpha$ and $\beta$, when clashing is defined by territory sets $T(a)$ in some universe $U$. Assume that $U$ is small (say $|U| \le 64$), so that bitwise operations can be used to represent the territories. Verified: no Solve time: 3m44s Solution No. Theorem J and Theorem L concern different probability estimates for Algorithm W,...
TAOCP 7.2.2.2 Exercise 326
Section 7.2.2.2: Satisfiability Exercise 326. [ 20 ] [20] True or false: If $\alpha$ and $\beta$ are traces with $\alpha = \beta$, then $\alpha^R = \beta^R$. (See (137).) Verified: no Solve time: 3m47s Solution No. Theorem J and Theorem L concern different probability estimates for Algorithm W, and the hypotheses of Theorem L do not imply the statement of Theorem J. Theorem J gives a bound under the specific assumption...
TAOCP 7.2.2.2 Exercise 325
Section 7.2.2.2: Satisfiability Exercise 325. [ 20 ] [20] An acyclic orientation of a graph $G$ is an assignment of directions to each of its edges so that the resulting digraph has no oriented cycles. Show that the number of traces for $G$ that are permutations of the vertices (with each vertex appearing exactly once in the trace) is the number of acyclic orientations of $G$. Verified: no Solve time:...
TAOCP 7.2.2.2 Exercise 324
Section 7.2.2.2: Satisfiability Exercise 324. ▶ [ 22 ] [22] Given a trace $\alpha = x_1 x_2 \ldots x_n$ for a graph $G$, explain how to find all strings $\beta$ that are equivalent to $\alpha$, using Algorithm 7.2.1.2V. How many strings yield (136)? Verified: no Solve time: 3m47s Solution No. Theorem J and Theorem L concern different probability estimates for Algorithm W, and the hypotheses of Theorem L do not...
TAOCP 7.2.2.2 Exercise 323
Section 7.2.2.2: Satisfiability Exercise 323. [ 10 ] [10] What trace precedes $ccb$ in the list (135)? Verified: no Solve time: 3m51s Solution No. Theorem J and Theorem L concern different probability estimates for Algorithm W, and the hypotheses of Theorem L do not imply the statement of Theorem J. Theorem J gives a bound under the specific assumption that the current assignment is at Hamming distance $d$ from a...
TAOCP 7.2.2.2 Exercise 322
Section 7.2.2.2: Satisfiability Exercise 322. ▶ [ HM35 ] [HM35] (K. Kolipaka and M. Szegedy, 2011.) Surprisingly, the previous exercise cannot be solved in the setting of Algorithm M! Suppose we have independent random variables $(W, X, Y, Z)$ such that $A$ depends on $W$ and $X$, $B$ depends on $X$ and $Y$, $C$ depends on $Y$ and $Z$, $D$ depends on $Z$ and $W$. Here $W$ equals $j$ with...
TAOCP 7.2.2.2 Exercise 321
Section 7.2.2.2: Satisfiability Exercise 321. [ M24 ] Suppose each of four random events $A$, $B$, $C$, $D$ occurs with probability $p$, where ${A, C}$ and ${B, D}$ are independent. According to exercise 320(b) with $m = 4$, there's a joint distribution of $(A, B, C, D)$ such that at least one of the events always occurs, whenever $p \ge (2 - \sqrt{2})/2 \approx 0.293$. Exhibit a distribution when $p...
TAOCP 7.2.2.2 Exercise 320
Section 7.2.2.2: Satisfiability Exercise 320. [ HM24 ] Given a lospdependency graph $G$, the occurrence threshold $\rho(G)$ is the smallest value $p$ such that it's sometimes impossible to avoid all events when each event occurs with probability $p$. For example, the Möbius polynomial for the path $P_5$ is $1 - p_1 - p_2 - p_3 + p_1 p_5$; so the occurrence threshold is $\phi^{-2}$, the least $p$ with $1 -...
TAOCP 7.2.2.2 Exercise 32
Section 7.2.2.2: Satisfiability Exercise 32. [ 15 ] [15] A list coloring is a graph coloring in which the color belongs to a given list $L(v)$, for each vertex $v$. Express list coloring as a SAT problem. Verified: no Solve time: 3m55s Solution No. Theorem J and Theorem L concern different probability estimates for Algorithm W, and the hypotheses of Theorem L do not imply the statement of Theorem J....
TAOCP 7.2.2.2 Exercise 319
Section 7.2.2.2: Satisfiability Exercise 319. [ HM20 ] Show that $pdc < 1$ implies $p \le (d-1)^{d-1}/d^d$. Verified: no Solve time: 4m04s Solution No. Theorem J and Theorem L concern different probability estimates for Algorithm W, and the hypotheses of Theorem L do not imply the statement of Theorem J. Theorem J gives a bound under the specific assumption that the current assignment is at Hamming distance $d$ from a...
TAOCP 7.2.2.2 Exercise 318
Section 7.2.2.2: Satisfiability Exercise 318. [ HM27 ] (J. B. Shearer.) Prove that Theorem J is the best possible result of its kind: If $p > (d-1)^{d-1}/d^d$ and $d > 1$, there is a graph $G$ of maximum degree $d$ for which $(p, \ldots, p) \notin \mathcal{R}(G)$. Hint: Consider complete $t$-ary trees, where $t = d - 1$. Verified: no Solve time: 4m44s Solution No. Theorem J and Theorem L...
TAOCP 7.2.2.2 Exercise 317
Section 7.2.2.2: Satisfiability Exercise 317. ▶ [ M26 ] Let $\alpha(G) = \Pr(\bar{A}_1 \cap \cdots \cap \bar{A}_m)$ under the assumptions of (133), when $p_i = p = (d-1)^{d-1}/d^d$ for $1 \le i \le m$ and every vertex of $G$ has degree at most $d > 1$. Prove, by induction on $m$, that $\alpha(G) > 0$ and that $\alpha(G) \ge \frac{d-1}{d} \alpha(G \setminus v)$ when $v$ has degree $< d$. Verified:...
TAOCP 7.2.2.2 Exercise 316
Section 7.2.2.2: Satisfiability Exercise 316. [ HM20 ] Is Theorem J a consequence of Theorem L? Verified: no Solve time: 16m
TAOCP 7.2.2.2 Exercise 315
Section 7.2.2.2: Satisfiability Exercise 315. [ M18 ] What value of $p$ is appropriate in Theorem J when $d = 1$? Verified: no Solve time: 10m12s Correctness The proposed solution does not answer Exercise 7.2.2.2.313. The exercise asks for a proof about Algorithm W. Specifically, it asks to show two facts about a cost-free literal flip in clause $C_j$: Flipping such a literal always decreases the number of unsatisfied clauses,...
TAOCP 7.2.2.2 Exercise 314
Section 7.2.2.2: Satisfiability Exercise 314. [ 36 ] (H. H. Hoos, 1998.) If the given clauses are satisfiable, and if $p > 0$, can there be an initial $x$ for which Algorithm W always loops forever? Verified: no Solve time: 11m23s Correctness The proposed solution does not answer Exercise 7.2.2.2.313. The exercise asks for a proof about Algorithm W. Specifically, it asks to show two facts about a cost-free literal...
TAOCP 7.2.2.2 Exercise 313
Section 7.2.2.2: Satisfiability Exercise 313. ▶ [ 22 ] Algorithm W always flips a cost-free literal if one is present in $C_j$, without considering its parameter $p$. Show that such a flip always decreases the number of unsatisfied clauses, $r$; but it might increase the distance from $x$ to the nearest solution. Verified: no Solve time: 11m43s Correctness The proposed solution does not answer Exercise 7.2.2.2.313. The exercise asks for...
TAOCP 7.2.2.2 Exercise 312
Section 7.2.2.2: Satisfiability Exercise 312. [ HM24 ] Let $T(m, n) = EX$ when the reluctant doubling method is applied to the probability distribution defined in exercise 306(k). Express $T(m, n)$ in terms of the generating functions in exercise 308(e). Verified: no Solve time: 3m51s Solution The quantity $F_t(r)$ can be found by turning the defining condition into a family of satisfiability problems. For fixed $t$ and $r$, introduce Boolean...
TAOCP 7.2.2.2 Exercise 311
Section 7.2.2.2: Satisfiability Exercise 311. [ 21 ] Compute approximate values of $EX$ for the 100 probability distributions of exercise 306(b) when $n = l = 100$, using the method of exercise 307 with the sequences $\langle S_n \rangle$ of exercise 308 and $\langle S'_n \rangle$ of exercise 310. Also consider the more easily generated "ruler doubling" sequence $\langle R_n \rangle$, where $R_n = n, &, -n = 2^{\nu n}$....
TAOCP 7.2.2.2 Exercise 310
Section 7.2.2.2: Satisfiability Exercise 310. [ M25 ] Explain how to compute the "reluctant Fibonacci sequence" 1, 1, 2, 1, 2, 3, 1, 1, 2, 1, 2, 3, 5, 1, 1, 2, 1, 2, 3, 5, 8, 1, 1, 2, 1, 2, 3, 5, 8, 13, 1, . . . , which is somewhat like (130) and useful as in exercise 308, but its elements are Fibonacci numbers instead of...
TAOCP 7.2.2.2 Exercise 31
Section 7.2.2.2: Satisfiability Exercise 31. [ 28 ] [28] Let $F_1(r)$ be the smallest $n$ for which there is a bit vector $x_1 \ldots x_n$ with $x_1 + \cdots + x_n = r$ and with no $t$ equally spaced 1s. For example, $F_3(12) = 30$ because of the unique solution 101100011010000000010110001101. Discuss how $F_t(n)$ might be computed efficiently with the help of a SAT solver. Verified: no Solve time: 10m20s...
TAOCP 7.2.2.2 Exercise 309
Section 7.2.2.2: Satisfiability Exercise 309. [ 20 ] Exercise 293 explains how to use the reluctant doubling sequence with Algorithm C. Is Algorithm C a Las Vegas algorithm? Verified: no Solve time: 11m23s Correctness The proposed solution does not answer Exercise 7.2.2.2.305. The exercise asks for an extension of the previous exercise involving Algorithm W and generating functions. Specifically, it asks to add the clause $(\bar{x}_1 \vee \bar{x}_2)$, compute the...
TAOCP 7.2.2.2 Exercise 308
Section 7.2.2.2: Satisfiability Exercise 308. [ M29 ] This exercise explores the "reluctant doubling" sequence (130). a) What is the smallest $n$ such that $S_n = 2^a$, given $a \ge 0$? b) Show that ${n \mid S_n = 1} = {2(k+1-\nu k) \mid k \ge 0}$; hence the generating function $\sum_n z^n [S_n = 1]$ is the infinite product $z(1+z)(1+z^2)(1+z^4)(1+z^{2^k})\cdots$ c) Find similar expressions for ${n \mid S_n = 2^a}$...
TAOCP 7.2.2.2 Exercise 306
Section 7.2.2.2: Satisfiability Exercise 306. ▶ [ HM32 ] (Luby, Sinclaire, and Zuckerman, 1993.) Consider a "Las Vegas algorithm" that succeeds or fails; it succeeds at step $t$ with probability $p_t$, and fails with probability $p_\infty < 1$. Let $q_t = p_t + p_{t+1} + \cdots + p_1$ and $E_t = p_1 + 2p_2 + \cdots + tp_t$; also let $E_\infty = \infty$ if $p_\infty > 0$, otherwise $E_\infty =...
TAOCP 7.2.2.2 Exercise 305
Section 7.2.2.2: Satisfiability Exercise 305. ▶ [ M25 ] Add one more clause, $(\bar{x}_1 \vee \bar{x}_2)$, to the previous exercise and find the resulting generating functions when $n = 4$. What happens when $p = 0$ in Algorithm W? Verified: no Solve time: 10m30s Correctness The proposed solution does not answer Exercise 7.2.2.2.305. The exercise asks for an extension of the previous exercise involving Algorithm W and generating functions. Specifically,...
TAOCP 7.2.2.2 Exercise 304
Section 7.2.2.2: Satisfiability Exercise 304. [ HM34 ] Consider the 2SAT problem with $n(n-1)$ clauses $(\bar{x}_j \vee x_k)$ for all $j \ne k$. Find the generating functions for the number of flips taken by Algorithms P and W. Hint: Exercises 1.2.6–68 and MPR-105 are helpful for finding the exact formulas. Verified: no Solve time: 3m56s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The...
TAOCP 7.2.2.2 Exercise 303
Section 7.2.2.2: Satisfiability Exercise 303. [ HM20 ] Solve exercise 294 with Algorithm W in place of Algorithm P. Verified: no Solve time: 3m55s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and deleting from the remaining clauses every literal whose complement...
TAOCP 7.2.2.2 Exercise 302
Section 7.2.2.2: Satisfiability Exercise 302. [ 26 ] Expand the text's high-level description of steps W4 and W5, by providing low-level details about exactly what the computer should do. Verified: no Solve time: 3m48s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals,...
TAOCP 7.2.2.2 Exercise 301
Section 7.2.2.2: Satisfiability Exercise 301. ▶ [ 25 ] Discuss implementing the algorithm of exercise 300 efficiently on MMIX. Verified: no Solve time: 3m47s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and deleting from the remaining clauses every literal whose complement...
TAOCP 7.2.2.2 Exercise 300
Section 7.2.2.2: Satisfiability Exercise 300. ▶ [ 25 ] Modify Algorithm P so that it can be implemented with bitwise operations, thereby running (say) 64 independent trials simultaneously. Verified: no Solve time: 3m47s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and...
TAOCP 7.2.2.2 Exercise 30
Section 7.2.2.2: Satisfiability Exercise 30. ▶ [ 22 ] [22] If auxiliary variables $s_j^i$ are used as in (18) and (19) to make $x_1 + \cdots + x_n \le r$, while $s_j^{i'}$ are used to make $\bar{x}_1 + \cdots + \bar{x} n \le n - r$, show that we may unify them by taking $s_j^{i'} = s {j-r}^{i'}$ for $1 \le j \le n - r$, $1 \le k \le...
TAOCP 7.2.2.2 Exercise 299
Section 7.2.2.2: Satisfiability Exercise 299. [ HM23 ] Continuing the previous exercise, investigate the case $k = 2$. Verified: no Solve time: 3m48s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and deleting from the remaining clauses every literal whose complement belongs...
TAOCP 7.2.2.2 Exercise 298
Section 7.2.2.2: Satisfiability Exercise 298. [ HM22 ] Generalize Theorem U and Corollary W to the case where each clause has at most $k$ literals, where $k \ge 3$. Verified: no Solve time: 3m51s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals,...
TAOCP 7.2.2.2 Exercise 297
Section 7.2.2.2: Satisfiability Exercise 297. ▶ [ HM26 ] (Emo Welzl.) Let $G_k(z) = \sum_n C_{n,p+q-1}(z/3)^{n-q}(2z/3)^p$ be the generating function for stopping time $t = 2p + q$ when $Y_0 = q$ in the proof of Theorem U. a) Find a closed form for $G_k(z)$, using formulas from Section 7.2.1.6. b) Explain why $G_k(1)$ is less than 1. c) Evaluate and interpret the quantity $G'_k(1)/G_k(1)$. d) Use Markov's inequality to...
TAOCP 7.2.2.2 Exercise 296
Section 7.2.2.2: Satisfiability Exercise 296. [ HM20 ] Complete the proof of Theorem U by (approximately) maximizing the quantity $f(p, q)$ in (129). Hint: Consider $f(p+1, q)/f(p, q)$. Verified: no Solve time: 3m59s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and...
TAOCP 7.2.2.2 Exercise 295
Section 7.2.2.2: Satisfiability Exercise 295. [ M23 ] Algorithm P often finds solutions much more quickly than predicted by Corollary W. But show that those seven clauses still indeed require $\Omega((4/3)^n)$ trials. Verified: no Solve time: 3m53s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one...
TAOCP 7.2.2.2 Exercise 294
Section 7.2.2.2: Satisfiability Exercise 294. [ HM21 ] For each binary vector $\alpha = x_1 x_2 x_3 x_4$, find the generating function $g_\alpha(z) = \sum_{j=0}^{\infty} p_{\alpha,j} z^j$, where $p_{\alpha,j}$ is the probability that Algorithm P will solve the seven clauses of (7) after making exactly $j$ flips, given the initial values $\alpha$ in step P1. Deduce the mean and variance of the number of steps needed to find a solution....
TAOCP 7.2.2.2 Exercise 293
Section 7.2.2.2: Satisfiability Exercise 293. [ 21 ] Spell out the details of updating $M_t$ to $M + \Delta t$ when deciding whether or not to flush. Also compute the agility threshold that's specified in Table 4. See Eq. (131). Verified: no Solve time: 3m58s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$...
TAOCP 7.2.2.2 Exercise 292
Section 7.2.2.2: Satisfiability Exercise 292. [ M21 ] How large can AGILITY get after repeatedly executing (127)? Verified: no Solve time: 3m47s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and deleting from the remaining clauses every literal whose complement belongs to...
TAOCP 7.2.2.2 Exercise 291
Section 7.2.2.2: Satisfiability Exercise 291. [ 20 ] In the text's hypothetical scenario about flushing Table 3 back to level 15, why will 49 soon appear on the trail, instead of $\overline{49}$? Verified: no Solve time: 3m45s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one...
TAOCP 7.2.2.2 Exercise 290
Section 7.2.2.2: Satisfiability Exercise 290. [ 17 ] Explain how to find $x_k$, the unassigned variable of maximum activity that is used for flushing literals. Hint: It's in the HEAP array. Verified: no Solve time: 3m52s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of...
TAOCP 7.2.2.2 Exercise 29
Section 7.2.2.2: Satisfiability Exercise 29. ▶ [ 20 ] [20] Instead of the single constraint $x_1 + \cdots + x_n \le r$, suppose we wish to impose a sequence of constraints $x_1 + \cdots + x_i \le r_i$ for $1 \le i \le n$. Can this be done nicely with additional clauses and auxiliary variables? Verified: no Solve time: 4m01s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set...
TAOCP 7.2.2.2 Exercise 289
Section 7.2.2.2: Satisfiability Exercise 289. [ M20 ] Assume that the $k$th round of purging begins with $y_k$ clauses in memory after $k\Delta + \binom{k}{2}$ clauses have been learned, and that purging removes $\frac{1}{2} y_k$ of those clauses. Find a closed formula for $y_k$ as a function of $k$. Verified: no Solve time: 3m54s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction...
TAOCP 7.2.2.2 Exercise 288
Section 7.2.2.2: Satisfiability Exercise 288. [ 28 ] Spell out the details of computing RANGE scores and then compressing the database of learned clauses, during a round of purging. Verified: no Solve time: 3m59s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals,...
TAOCP 7.2.2.2 Exercise 287
Section 7.2.2.2: Satisfiability Exercise 287. [ 25 ] What changes to Algorithm C are necessary to make it do a "full run," and later to learn from all of the conflicts that arose during that run? Verified: no Solve time: 3m52s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every...
TAOCP 7.2.2.2 Exercise 286
Section 7.2.2.2: Satisfiability Exercise 286. [ M24 ] What choice of signatures-to-keep in Fig. 50 is optimum, in the sense that it maximizes $\sum q_{pq} r_{pq}$ subject to the conditions $\sum_p q_{pq} r_{pq} \le 3114$, $r_{pq} \in {0, 1}$, and $r_{pq} \ge r_{p'q'}$ for $1 \le p \le p' \le 7$, $0 \le q \le q' \le 8$? Here $q_{pq}$ and $b_{pq}$ are the sums of the gray and black...
TAOCP 7.2.2.2 Exercise 285
Section 7.2.2.2: Satisfiability Exercise 285. [ 19 ] Using the data in Fig. 50, the text observes that Eq. (124) gives $j = 95$, $s_j = 3081$, and $m_j = 59$ when $\alpha = \frac{15}{2}$. What are $j$, $s_j$, and $m_j$ when (a) $\alpha = \frac{9}{2}$? (b) $\alpha = \frac{13}{2}$? (c) $\alpha = \frac{23}{2}$? Also compare the effectiveness of different $\alpha$'s by computing the number $b_j$ of "black" clauses (those...
TAOCP 7.2.2.2 Exercise 284
Section 7.2.2.2: Satisfiability Exercise 284. [ 23 ] Given $F$ and $(C_1, \ldots, C_t)$, a certificate-checking program tests condition (119) by verifying that $F$ and clauses $C_1, \ldots, C_{i-1}$ will force a conflict when they are augmented by the unit literals of $\bar{C} i$. While doing this, it can mark each clause of $F \cup {C_1, \ldots, C {i-1}}$ that was reduced to a unit during the forcing process; then...
TAOCP 7.2.2.2 Exercise 283
Section 7.2.2.2: Satisfiability Exercise 283. [ HM46 ] Algorithm C solves the flower snark problem in linear time? More precisely, let $p_k(M)$ be the probability that the algorithm refutes $\text{fnmark}(q)$ while making at most $M$ flushes, as $q \to \infty$. Is $p_k(N_0) \to 1$ or $p_k(N_0) > \frac{1}{2}$ for all $q$? Verified: no Solve time: 3m54s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals....
TAOCP 7.2.2.2 Exercise 282
Section 7.2.2.2: Satisfiability Exercise 282. ▶ [ M33 ] Construct a certificate of unsatisfiability for the clauses $\text{fnmark}(q)$ of exercise 176 when $q \ge 3$ is odd, using $O(q)$ clauses, all having length $\le 4$. Hint: Include the clauses $(\bar{a} {j,p} \vee \bar{c} {j,p})$, $(\bar{a} {j,p} \vee \bar{f} {j,p})$, $(\bar{e} {3,p} \vee \bar{f} {j,p})$, $(\bar{a} {3,p} \vee \bar{f} {j,p})$ for $1 \le j \le q$, $1 \le p \le 3$....
TAOCP 7.2.2.2 Exercise 281
Section 7.2.2.2: Satisfiability Exercise 281. [ 21 ] Construct a certificate of unsatisfiability that refutes (99), (100), (101). Verified: no Solve time: 3m51s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and deleting from the remaining clauses every literal whose complement belongs...
TAOCP 7.2.2.2 Exercise 280
Section 7.2.2.2: Satisfiability Exercise 280. ▶ [ M26 ] The problem $\text{cook}(j, k)$ consists of all $\binom{n}{j}$ positive $j$-clauses and all $\binom{n}{k}$ negative $k$-clauses on ${1, \ldots, n}$, where $n = j + k - 1$. For example, $\text{cook}(2, 3)$ is $${12, 13, 14, 23, 24, 34, 123, 124, 134, 234}.$$ a) Why are these clauses obviously unsatisfiable? b) Find a totally positive certificate for $\text{cook}(j, k)$, of length $\binom{n}{j-1}$....
TAOCP 7.2.2.2 Exercise 28
Section 7.2.2.2: Satisfiability Exercise 28. ▶ [ 20 ] [20] What clauses result from (18) and (19) when we want to ensure that $x_1 + \cdots + x_n \ge 1$? (This special case converts arbitrary clauses into 3SAT clauses.) Verified: no Solve time: 3m52s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to...
TAOCP 7.2.2.2 Exercise 279
Section 7.2.2.2: Satisfiability Exercise 279. [ M20 ] True or false: Every unsatisfiable 2SAT problem has a certificate $(t, \epsilon)$. Verified: no Solve time: 3m51s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and deleting from the remaining clauses every literal whose...
TAOCP 7.2.2.2 Exercise 278
Section 7.2.2.2: Satisfiability Exercise 278. [ 22 ] Find a six-step certificate of unsatisfiability for warden$(3, 3; 9)$. Verified: no Solve time: 4m02s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting every clause that contains one of these literals, and deleting from the remaining clauses every literal whose complement belongs...
TAOCP 7.2.2.2 Exercise 277
Section 7.2.2.2: Satisfiability Exercise 277. [ M18 ] If $(C_1, \ldots, C_t)$ is a certificate of unsatisfiability for $F$, and if all clauses of $F$ have length $\ge 2$, prove that some $C_i$ is a unit clause. Verified: no Solve time: 3m55s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$ to true, deleting...
TAOCP 7.2.2.2 Exercise 276
Section 7.2.2.2: Satisfiability Exercise 276. [ M15 ] True or false: If $F$ is a family of clauses and $L$ is a set of strictly distinct literals, then $F \wedge L \vdash_1 \epsilon$ if and only if $(F|L) \vdash_1 \epsilon$. Verified: no Solve time: 3m44s Solution The statement is true. Let $L={l_1,\ldots,l_r}$ be a set of strictly distinct literals. The restriction $F|L$ is obtained by setting every literal in $L$...
TAOCP 7.2.2.2 Exercise 275
Section 7.2.2.2: Satisfiability Exercise 275. ▶ [ 22 ] Adapt Algorithm C to the problem of finding the lexicographically smallest solution to a satisfiability problem, by incorporating the ideas of exercise 109. Verified: no Solve time: 8m06s Solution Let $C_{i-1}$ denote the clause currently at the end of MEM when the new learned clause $C_i$ has been produced. The only possible replacement is $$ C_{i-1}\leftarrow C_i, $$ and this replacement...
TAOCP 7.2.2.2 Exercise 274
Section 7.2.2.2: Satisfiability Exercise 274. [ 35 ] Algorithm C sets the "reason" for a literal $l$ as soon as it notices a clause that forces $l$ to be true. Later on, other clauses that force $l$ are often encountered, in practice; but Algorithm C ignores them, even though one of them might be a "better reason." (For example, another forcing clause might be significantly shorter.) Explore a modification of...
TAOCP 7.2.2.2 Exercise 273
Section 7.2.2.2: Satisfiability Exercise 273. [ 27 ] [27] A clause $C$ that is learned from $waerden(j, k; n)$ is valid also with respect to $waerden(j, k; n')$ when $n' > n$; and so are the clauses $C + i$ that are obtained by adding $i$ to each literal of $C$, for $1 \le i \le n' - n$. For example, the fact that '35' follows from $waerden(3, 3; 7)$...
TAOCP 7.2.2.2 Exercise 272
Section 7.2.2.2: Satisfiability Exercise 272. [ 30 ] [30] Experiment with the following idea: The clauses of $waerden(j, k; n)$ are symmetrical under reflection, in the sense that they remain unchanged overall if we replace $x_k$ by $x_{n+1-k}^R = x_{n+1-k}$ for $1 \le k \le n$. Therefore, whenever Algorithm C learns a clause $C = (\bar{l}^0 \vee \bar{b}_1 \vee \cdots \vee \bar{b}_r)$, it is also entitled to learn the reflected...
TAOCP 7.2.2.2 Exercise 271
Section 7.2.2.2: Satisfiability Exercise 271. ▶ [ 25 ] [25] The sequence of learned clauses $C_1, C_2, \ldots$ often includes cases where $C_i$ subsumes its immediate predecessor, $C_{i-1}$. In such cases we might as well discard $C_{i-1}$, which appears at the very end of MEM, and store $C_i$ in its place, unless $C_{i-1}$ is still in use as a reason for some literal on the trail. (For example, more than...
TAOCP 7.2.2.2 Exercise 270
Section 7.2.2.2: Satisfiability Exercise 270. [ 25 ] [25] (On-the-fly subsumption.) The intermediate clauses that arise in step C7, immediately before resolving with a reason $R_l$, occasionally turn out to be equal to the shorter clause $R_l \setminus l$. In such cases we have an opportunity to strengthen that clause by deleting $l$ from it, thus making it potentially more useful in the future. a) Construct an example where two...
TAOCP 7.2.2.2 Exercise 27
Section 7.2.2.2: Satisfiability Exercise 27. [ 20 ] [20] Similarly, prove the correctness of Bailleux and Boufkhad's (20) and (21). Hint: They imply $b_j^i = 1$ whenever the leaves below node $k$ contain $j$ or more 1s. Verified: no Solve time: 13m42s Correctness The proposed solution does not answer Exercise 7.2.2.2.266. The exercise asks how a random decision policy in a CDCL SAT solver changes step C6 of the CDCL...
TAOCP 7.2.2.2 Exercise 269
Section 7.2.2.2: Satisfiability Exercise 269. [ 29 ] [29] Suppose Algorithm C reaches a conflict at level $d$ of the trail, after having chosen the decision literals $u_1, u_2, \ldots, u_d$. Then the "trivial clause" $(\bar{l}^0 \vee \bar{u}_1 \vee \cdots \vee \bar{u}_d)$ must be true if the given clauses are satisfiable, where $l'$ and $d'$ are defined in step C7. a) Show that, if we start with the clause $(\bar{l}^0...
TAOCP 7.2.2.2 Exercise 268
Section 7.2.2.2: Satisfiability Exercise 268. [ 21 ] [21] When Algorithm C makes a literal false at level 0 of the trail, we can remove it from all of the clauses. Such updating might take a long time, if we did it "eagerly"; but there's a lazy way out: We can delete a permanently false literal if we happen to encounter it in step C3 while looking for a new...
TAOCP 7.2.2.2 Exercise 267
Section 7.2.2.2: Satisfiability Exercise 267. [ 25 ] Indexer-unit-SAT often contains numerous binary clauses, which are handled efficiently by the unit-propagation loop (62) of Algorithm I but not by the corresponding loop in step C3 of Algorithm C. (The technique of watched literals is great for long clauses, but it is comparatively cumbersome for short ones.) What additional data structures will speed up Algorithm C's inner loop, when binary clauses...
TAOCP 7.2.2.2 Exercise 266
Section 7.2.2.2: Satisfiability Exercise 266. [ 20 ] In order to keep from getting into a rut, CDCL solvers are often designed to make decisions at random, with a small probability $p$ (say $p = .02$), instead of always choosing a variable of maximum activity. How would this policy change step C6? Verified: no Solve time: 13m08s Correctness The proposed solution does not answer Exercise 7.2.2.2.266. The exercise asks how...
TAOCP 7.2.2.2 Exercise 265
Section 7.2.2.2: Satisfiability Exercise 265. [ 21 ] Describe several circumstances in which the watched literals $l_0$ and/or $l_1$ of a clause $e$ actually become false during the execution of Algorithm C. Verified: no Solve time: 5m53s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the...
TAOCP 7.2.2.2 Exercise 264
Section 7.2.2.2: Satisfiability Exercise 264. [ 20 ] Suggest a way in which Algorithm C could indicate progress by displaying "move codes" analogous to those of Algorithms A, B, D, and L. (See exercise 142.) Verified: no Solve time: 5m51s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$...
TAOCP 7.2.2.2 Exercise 263
Section 7.2.2.2: Satisfiability Exercise 263. [ 21 ] Write out the gory details by which step C7 constructs a new clause and step C9 puts it into the data structures of Algorithm C. Verified: no Solve time: 5m54s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be...
TAOCP 7.2.2.2 Exercise 262
Section 7.2.2.2: Satisfiability Exercise 262. [ 20 ] What low-level operations underlie changes to the heap in steps C6–C8? Verified: no Solve time: 5m50s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$ has seven literals,...
TAOCP 7.2.2.2 Exercise 261
Section 7.2.2.2: Satisfiability Exercise 261. [ 21 ] The main loop of Algorithm C is the unit-propagation process of steps C3 and C4. Describe the low-level details of link adjustment, etc., to be done in those steps. Verified: no Solve time: 6m09s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad...
TAOCP 7.2.2.2 Exercise 260
Section 7.2.2.2: Satisfiability Exercise 260. [ 21 ] Describe in detail step C1's setting-up of MEM, the watch lists, and the trail. Verified: no Solve time: 5m55s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$...
TAOCP 7.2.2.2 Exercise 26
Section 7.2.2.2: Satisfiability Exercise 26. [ 22 ] [22] Prove that Sinz's clauses (18) and (19) enforce the cardinality constraint $x_1 + \cdots + x_n \le r$. Hint: Show that they imply $s_j^i = 1$ whenever $x_1 + \cdots + x_{j+k-1} \ge k$. Verified: no Solve time: 5m56s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause...
TAOCP 7.2.2.2 Exercise 259
Section 7.2.2.2: Satisfiability Exercise 259. [ M20 ] Can $\text{ACT}(j)$ exceed $\text{ACT}(k)$ for values of $p$ near 0 or 1, but not for all $p$? Verified: no Solve time: 6m16s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are...
TAOCP 7.2.2.2 Exercise 258
Section 7.2.2.2: Satisfiability Exercise 258. [ 21 ] A non-decision literal $l$ in Algorithm C's trail always has a reason $R_l = (l \vee l_1 \vee \cdots \vee l_k)$, where the false literals $\bar{l}_1, \ldots, \bar{l} k$ precede $l$ in the trail. Furthermore, the algorithm discovered this clause while looking at the watch list of $l_1$. True or false: $l_2, \ldots, l {k-1}$ precede $l_1$ in the trail. Hint: Consider...
TAOCP 7.2.2.2 Exercise 257
Section 7.2.2.2: Satisfiability Exercise 257. ▶ [ 30 ] (Niklas Sörensson.) A literal $l$ is said to be redundant , with respect to a given clause $c$ and the current trail, if $l$ is in the trail and either (i) $l$ is defined at level 0, or (ii) $l$ is not a decision literal and every false literal in $l$'s reason is either in $c$ or (recursively) redundant. (This definition...
TAOCP 7.2.2.2 Exercise 256
Section 7.2.2.2: Satisfiability Exercise 256. [ 20 ] How might the clause '**' in Table 3 have been easily learned? Verified: no Solve time: 5m56s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$ has seven...
TAOCP 7.2.2.2 Exercise 255
Section 7.2.2.2: Satisfiability Exercise 255. ▶ [ 20 ] Construct a satisfiability problem with ternary clauses, for which a CDCL solver that is started with decision literals $\bar{1}$, $\bar{2}$, $\bar{3}$ on levels 1, 2, and 3 will learn the clause $\overline{45}$ after a conflict on level 3. Verified: no Solve time: 5m53s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from...
TAOCP 7.2.2.2 Exercise 254
Section 7.2.2.2: Satisfiability Exercise 254. [ 16 ] Given the binary clauses ${12, 13, 23, 24, 34}$, what clause will a CDCL solver learn first if it begins by deciding that 1 is true? Verified: no Solve time: 5m55s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to...
TAOCP 7.2.2.2 Exercise 253
Section 7.2.2.2: Satisfiability Exercise 253. ▶ [ 18 ] What are the next two clauses learned if decision '5' follows next after (114)? Verified: no Solve time: 7m15s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since...
TAOCP 7.2.2.2 Exercise 252
Section 7.2.2.2: Satisfiability Exercise 252. [ M26 ] Can the unsatisfiability of (99)–(101) be proved in polynomial time by repeatedly performing variable elimination and subsumption? Verified: no Solve time: 5m59s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are...
TAOCP 7.2.2.2 Exercise 251
Section 7.2.2.2: Satisfiability Exercise 251. ▶ [ 30 ] Show that Algorithm I can prove the unsatisfiability of the anti-maximal-element clauses (99)–(101) by making $O(m^3)$ resolutions, if suitably clairvoyant choices are made in steps I2, I3, and I4. Verified: no Solve time: 6m05s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the...
TAOCP 7.2.2.2 Exercise 250
Section 7.2.2.2: Satisfiability Exercise 250. [**] [§5] Since the clauses $R'$ in (7) are satisfiable, Algorithm I might discover a solution without ever reaching step I4. Try, however, to make the choices in steps I2, I3, and I4 so that the algorithm takes as long as possible to discover a solution. Verified: no Solve time: 5m56s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen...
TAOCP 7.2.2.2 Exercise 25
Section 7.2.2.2: Satisfiability Exercise 25. [ 21 ] [21] Show that (18)–(19) and (20)–(21) are equally effective when $r = 2$. Verified: no Solve time: 5m55s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$ has...
TAOCP 7.2.2.2 Exercise 249
Section 7.2.2.2: Satisfiability Exercise 249. [ 18 ] [18] Apply Algorithm I to (112) using Cook's Method IA. Verified: no Solve time: 5m51s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$ has seven literals, $$...
TAOCP 7.2.2.2 Exercise 248
Section 7.2.2.2: Satisfiability Exercise 248. [ M20 ] [M20] Formally speaking, SAT is the problem of evaluating the quantified formula $$\exists x_1 \ldots \exists x_{n-1} ; \exists x_n ; F(x_1, \ldots, x_{n-1}, x_n),$$ where $F$ is a Boolean function given in CNF as a conjunction of clauses. Explain how to transform the CNF for $F$ into the CNF for $F'$ in the reduced problem $$\exists x_1 \ldots \exists x_{n-1} ;...
TAOCP 7.2.2.2 Exercise 247
Section 7.2.2.2: Satisfiability Exercise 247. [ 18 ] [18] Apply variable elimination to just five of the six clauses (112), omitting $\overline{1}\overline{2}$. Verified: no Solve time: 6m01s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$...
TAOCP 7.2.2.2 Exercise 246
Section 7.2.2.2: Satisfiability Exercise 246. ▶ [ M28 ] [M28] (G. S. Tseytin.) Given a labeled graph $G$ with $m$ edges, $n$ vertices, and $N$ unsatisfiable clauses $\alpha(G)$ as in the previous exercise, explain how to refute those clauses with $O(mn + N)$ steps of extended resolution. Verified: no Solve time: 6m04s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from...
TAOCP 7.2.2.2 Exercise 245
Section 7.2.2.2: Satisfiability Exercise 245. ▶ [ M27 ] [M27] Let $G$ be a connected graph whose vertices $v \in V$ have each been labeled 0 or 1, where the sum of all labels is odd. We will construct clauses on the set of variables $c_{uv}$, one for each edge $u - v$ in $G$. The axioms are $\alpha(v) = [E(v)]^{l(v)+1}$ for each $v \in V$ (see exercise 244), where...
TAOCP 7.2.2.2 Exercise 244
Section 7.2.2.2: Satisfiability Exercise 244. [ M20 ] If $A$ is a set of variables, let $[A]^0$ or $[A]^1$ stand for the set of all clauses that can be formed from $A$ with an even or odd number of negative literals, respectively; each clause should involve all of the variables. (For example, ${1,2,3}^1 = {123, \bar{1}23, 1\bar{2}3, 12\bar{3}}$.) If $A$ and $B$ are disjoint, express $[A \cup B]^0$ in terms...
TAOCP 7.2.2.2 Exercise 243
Section 7.2.2.2: Satisfiability Exercise 243. [ HM31 ] (E. Ben-Sasson and A. Wigderson.) Let $F$ be a set of $\lfloor cn \rfloor$ random 3SAT clauses on $n$ variables, where $\alpha > 1/e$ is a given constant. For any clause $C$ on those variables, define $\mu(C) = \min{|F'| \mid F' \subseteq F \text{ and } F' \vdash C}$. Also let $V(F')$ denote the variables that occur in a given family of...
TAOCP 7.2.2.2 Exercise 242
Section 7.2.2.2: Satisfiability Exercise 242. [ M20 ] The pigeonhole axioms (106) and (107) are equivalent to the clauses (15) and (16) that arise if we try to color the complete graph $K_{m+1}$ with $m$ colors. Suppose we include further axioms corresponding to (17), namely $$(\bar{x} {jk} \vee \bar{x} {jk'}), \quad \text{for } 0 \le j \le m \text{ and } 1 \le k < k' \le m.$$ Does Theorem...
TAOCP 7.2.2.2 Exercise 241
Section 7.2.2.2: Satisfiability Exercise 241. [ 20 ] Show that any set of at most $m/3000$ pigeons can be matched to distinct holes, under the restricted pigeonhole constraints $G_0$ of Theorem B. Verified: no Solve time: 5m58s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the...
TAOCP 7.2.2.2 Exercise 240
Section 7.2.2.2: Satisfiability Exercise 240. [ HM23 ] Choose integers $f_{ij} \in {1, \ldots, m}$ uniformly at random, for $1 \le i \le 5$ and $0 \le j \le m$, and let $G_0$ be the bipartite graph with edges $a_j — b_k$ if and only if $k \in {f_{1j}, \ldots, f_{5j}}$. Show that $\Pr(G_0$ satisfies the strong expansion condition $(108)) \ge 1/2$. Verified: no Solve time: 5m59s Setup Let $F$...
TAOCP 7.2.2.2 Exercise 24
Section 7.2.2.2: Satisfiability Exercise 24. ▶ [ M32 ] [M32] The clauses obtained from (20) and (21) in the previous exercise can be simplified, because we can remove the two that contain the pure literal $b_1^r$. a) Prove that the literal $b_1^r$ is always pure in (20) and (21), when $r > n/2$. b) Show that $b_1^r$ might also be pure in some cases when $r < n/2$. c) The...
TAOCP 7.2.2.2 Exercise 239
Section 7.2.2.2: Satisfiability Exercise 239. ▶ [ M21 ] What clauses $\alpha_0$ on $n$ variables make $\lfloor \alpha_0 \div r \rfloor$ as large as possible? Verified: no Solve time: 5m58s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are...
TAOCP 7.2.2.2 Exercise 238
Section 7.2.2.2: Satisfiability Exercise 238. [ HM21 ] Complete the proof of Lemma B. Hint: Make $r \le \rho^{-h}$ when $W = b$. Verified: no Solve time: 6m11s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since...
TAOCP 7.2.2.2 Exercise 237
Section 7.2.2.2: Satisfiability Exercise 237. [ 28 ] Show that a polynomial number of steps suffice to refute the pigeonhole clauses (106), (107), if the extended resolution trick is used to append new clauses. Verified: no Solve time: 5m48s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to...
TAOCP 7.2.2.2 Exercise 236
Section 7.2.2.2: Satisfiability Exercise 236. [ 8 ] Is the chain in the previous exercise as short as possible? Verified: no Solve time: 6m04s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$ has seven literals,...
TAOCP 7.2.2.2 Exercise 235
Section 7.2.2.2: Satisfiability Exercise 235. [ 30 ] Refute those pigeonhole clauses with a chain of length $m(m+3)2^{m-2}$. Verified: no Solve time: 5m58s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false. Since $C$ has seven literals, $$...
TAOCP 7.2.2.2 Exercise 234
Section 7.2.2.2: Satisfiability Exercise 234. [ 20 ] Show that the Delayer can score at least $m$ points against any Prover who tries to refute the pigeonhole clauses (106) and (107). Verified: no Solve time: 6m01s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event...
TAOCP 7.2.2.2 Exercise 233
Section 7.2.2.2: Satisfiability Exercise 233. [ 16 ] Explain why (105) satisfies (104), by exhibiting $j(i)$ and $k(i)$ for $9 \le i \le 22$. Verified: no Solve time: 5m59s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are false....
TAOCP 7.2.2.2 Exercise 232
Section 7.2.2.2: Satisfiability Exercise 232. [ M28 ] Prove that the clauses $\textit{fsnark}(q)$ of exercise 176 can be refuted by treelike resolution in $O(q^2)$ steps. Verified: no Solve time: 5m49s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals of $C$ are...
TAOCP 7.2.2.2 Exercise 231
Section 7.2.2.2: Satisfiability Exercise 231. [ M30 ] (Sam Buss.) Refute the clauses of exercise 229 with a resolution chain of length $O(m^3)$. Hint: Derive the clauses $G_{ij} = (\bar{x} {i1} \vee \bar{x} {i2j}) \vee \cdots \vee \bar{x}_{im})$ for $1 \le i \le j \le m$. Verified: no Solve time: 6m01s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$....
TAOCP 7.2.2.2 Exercise 230
Section 7.2.2.2: Satisfiability Exercise 230. [ M22 ] Show that the clauses with $i \ne j$ in the previous exercise form a minimal unsatisfiable set: Removing any one of them leaves a satisfiable remainder. Verified: no Solve time: 5m50s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to...
TAOCP 7.2.2.2 Exercise 23
Section 7.2.2.2: Satisfiability Exercise 23. [ 20 ] [20] Compare the clauses (18) and (19) to (20) and (21) in the case $n = 7$, $r = 4$. Verified: no Solve time: 5m47s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals...
TAOCP 7.2.2.2 Exercise 229
Section 7.2.2.2: Satisfiability Exercise 229. [ M21 ] Continuing exercise 228 , prove also that the set of clauses (99), (100'), (101) is unsatisfiable, where (100') denotes (100) restricted to the cases $i \le k$ and $j < k$. Verified: no Solve time: 5m50s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define...
TAOCP 7.2.2.2 Exercise 228
Section 7.2.2.2: Satisfiability Exercise 228. ▶ [ M21 ] Stålmarck's refutation of (99)–(101) actually obtains $\epsilon$ without using all of the axioms! Show that only about $1/3$ of those clauses are sufficient for unsatisfiability. Verified: no Solve time: 5m44s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to...
TAOCP 7.2.2.2 Exercise 227
Section 7.2.2.2: Satisfiability Exercise 227. [ M27 ] [M27] Given an extended binary tree, exercise 7.2.1.6–124 explains how to label each node with its Horton–Strahler number. For example, the nodes at depth 2 in Fig. 48 are labeled 1, because their children have the labels 1 and 0; the root is labeled 3. Prove that the maximum score that the Delayer can guarantee, when playing the Prover–Delayer game for a...
TAOCP 7.2.2.2 Exercise 226
Section 7.2.2.2: Satisfiability Exercise 226. [ M30 ] [M30] Let $\alpha$ be a node in a refutation tree; let $C(\alpha)$ be its label, and let $|\alpha|$ denote the number of leaves in its subtree. Show that, given a refutation tree with $N$ leaves, the Prover can find a node with $|\alpha| \le N/2^s$ for which the current assignment falsifies $C(\alpha)$, whenever the Delayer has scored $s$ points in the Prover–Delayer...
TAOCP 7.2.2.2 Exercise 225
Section 7.2.2.2: Satisfiability Exercise 225. ▶ [ M31 ] [M31] (G. S. Tseytin, 1966.) If $T$ is any resolution tree that refutes a set of axioms $F$, show how to convert it to a regular resolution tree $T_r$ that refutes $F$, where $T_r$ is no larger than $T$. Verified: no Solve time: 5m59s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly...
TAOCP 7.2.2.2 Exercise 224
Section 7.2.2.2: Satisfiability Exercise 224. [ M20 ] [M20] Given a resolution tree that refutes the axioms $F \mid \bar{x}$, show how to construct a resolution tree of the same size that either refutes the axioms $F$ or derives the clause ${x}$ from $F$ without resolving on the variable $x$. Verified: no Solve time: 5m57s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently...
TAOCP 7.2.2.2 Exercise 223
Section 7.2.2.2: Satisfiability Exercise 223. [ HM40 ] [HM40] Step X9 deduces a binary clause that cannot be derived by resolution (see exercise 166). Prove that, nevertheless, the running time of Algorithm L on unsatisfiable input will never be less than the length of a shortest treelike refutation. Verified: no Solve time: 5m49s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly...
TAOCP 7.2.2.2 Exercise 222
Section 7.2.2.2: Satisfiability Exercise 222. [ M30 ] [M30] (Oliver Kullmann, 2000.) Prove that, for every clause $C$ in a satisfiability problem $F$, there is an autarky satisfying $C$ if and only if $C$ cannot be used as the label of a source vertex in any resolution refutation of $F$. Verified: no Solve time: 5m53s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently...
TAOCP 7.2.2.2 Exercise 221
Section 7.2.2.2: Satisfiability Exercise 221. [ 16 ] [16] Draw the search tree analogous to Fig. 38 that is implicitly traversed when Algorithm A is applied to the unsatisfiable clauses ${12, 2, \bar{2}}$. Explain why it does not correspond to a resolution refutation that is analogous to Fig. 48. Verified: no Solve time: 5m52s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and...
TAOCP 7.2.2.2 Exercise 220
Section 7.2.2.2: Satisfiability Exercise 220. [ M24 ] [M24] We say that clause $C$ subsumes clause $C'$, written $C \subseteq C'$, if $C' = \bar{\varphi}$ or if $C' \ne \bar{\varphi}$ and every literal of $C$ appears in $C'$. a) True or false: $C \subseteq C'$ and $C' \subseteq C''$ implies $C \subseteq C''$. b) True or false: $(C \vee a) \diamond (C'' \vee \bar{a}) \subseteq (C \diamond C'') \vee a...
TAOCP 7.2.2.2 Exercise 22
Section 7.2.2.2: Satisfiability Exercise 22. [ 20 ] [20] Color the graph $\overline{C_5} \boxtimes \overline{C_5}$ with the fewest colors. (Two vertices of this graph can receive the same color if and only if they are a king move apart in a $5 \times 5$ torus.) Verified: no Solve time: 7m23s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For...
TAOCP 7.2.2.2 Exercise 219
Section 7.2.2.2: Satisfiability Exercise 219. ▶ [ M20 ] [M20] Formulate a general definition of the resolution operator $C = C' \diamond C''$ that (i) agrees with the earlier definition when $C' = \bar{x} \vee A'$ and $C'' = \bar{x} \vee A''$; (ii) applies to arbitrary clauses $C'$ and $C''$; (iii) has the property that $C' \wedge C''$ implies $C' \diamond C''$. Verified: no Solve time: 5m57s Setup Let $F$...
TAOCP 7.2.2.2 Exercise 218
Section 7.2.2.2: Satisfiability Exercise 218. [ 20 ] [20] Express the formula $(x \vee A) \wedge (\bar{x} \vee B)$ in terms of the ternary operator $u,?,v : w$. Verified: no Solve time: 5m58s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$ of $F$, define the bad event $A_C$ to be the event that all literals...
TAOCP 7.2.2.2 Exercise 217
Section 7.2.2.2: Satisfiability Exercise 217. [ 20 ] [20] True or false: If $A$ and $B$ are arbitrary clauses that are simultaneously satisfiable, and if $l$ is any literal, then the clause $C = (A \cup B) \setminus {l, \bar{l}}$ is also satisfiable. (We're thinking here of $A$, $B$, and $C$ as sets of literals, not as disjunctions of literals.) Verified: no Solve time: 5m58s Setup Let $F$ be a...
TAOCP 7.2.2.2 Exercise 216
Section 7.2.2.2: Satisfiability Exercise 216. [ HM38 ] (P. W. Purdom Jr., and C. A. Brown.) Extend the previous exercise to a more sophisticated kind of backtracking, where all choices forced by unit clauses are pursued before two-way branching is done. (The "pure literal rule" is not exploited, however, because it doesn't find all solutions.) Prove that the expected tree size is greatly reduced when $m = 200$ and $n...
TAOCP 7.2.2.2 Exercise 215
Section 7.2.2.2: Satisfiability Exercise 215. ▶ [ HM23 ] What is the expected profile of the search tree when a simple backtrack procedure is used to find all solutions to a random 3SAT problem with $m$ independent clauses on $n$ variables? (There is a node on level $l$ for every partial solution $x_1 \ldots x_l$ that doesn't contradict any of the clauses.) Compute these values when $m = 200$ and...
TAOCP 7.2.2.2 Exercise 214
Section 7.2.2.2: Satisfiability Exercise 214. [ HM38 ] Although the previous model in the preceding exercise doesn't teach us how to solve SAT problems, it does lead to interesting mathematics: Let $0 < p < 1$ and consider the recurrence $$T_0 = 0; \qquad T_n = n + 2\sum_{k=0}^{n-1} \binom{n}{k} p^k (1-p)^{n-k} T_k, \quad \text{for } n > 0.$$ a) Find a functional relation satisfied by $T(z) = \sum_{n=0}^{\infty} T_n...
TAOCP 7.2.2.2 Exercise 213
Section 7.2.2.2: Satisfiability Exercise 213. ▶ [ M26 ] Experience with the analyses of sorting algorithms in Chapter 5 suggests that random satisfiability problems might be modeled nicely if we assume that, in each of $m$ independent clauses, the literals $x_j$ and $\bar{x}_j$ occur with respective probabilities $p$ and $q$, independently for $1 \le j \le n$, where $p + q \le 1$. Why is this not an interesting model...
TAOCP 7.2.2.2 Exercise 212
Section 7.2.2.2: Satisfiability Exercise 212. [ 32 ] Continuing the previous exercise, we shall reduce grid list coloring to another interesting problem called partial latin square construction . Given three $n \times n$ binary matrices $(r_{ik})$, $(c_{jk})$, $(p_{ij})$, the task is to construct an $n \times n$ array $(X_{ij})$ such that $X_{ij}$ is blank when $p_{ij} = 0$, otherwise $X_{ij} = k$ for some $k$ with $r_{ik} = c_{jk} =...
TAOCP 7.2.2.2 Exercise 211
Section 7.2.2.2: Satisfiability Exercise 211. [ 30 ] (R. W. Irving and M. Jerrum, 1994.) Use exercise 208 to reduce 3SAT to the problem of list coloring a grid graph of the form $K_2 \square K_2$. (Hence the latter problem, which is also called latin rectangle construction , is NP-complete.) Verified: no Solve time: 5m57s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently...
TAOCP 7.2.2.2 Exercise 210
Section 7.2.2.2: Satisfiability Exercise 210. [ M36 ] But the result in the previous exercise can be improved when $k$ is large. Use the Local Lemma to show that every 7SAT problem with at most 13 occurrences of each variable is satisfiable. Verified: no Solve time: 6m02s Setup Let $F$ be a 7SAT instance. Let the variables of $F$ be chosen independently and uniformly from ${0,1}$. For each clause $C$...
TAOCP 7.2.2.2 Exercise 21
Section 7.2.2.2: Satisfiability Exercise 21. [ 22 ] [22] Use a SAT solver to find a minimum-size kernel in the graph of Fig. 33. Verified: no Solve time: 5m48s I cannot produce a rigorous completed solution for this exercise from the information currently available. The obstacle is part (b). The exercise asks for a specific construction of a set of 16 unsatisfiable ternary clauses on 15 variables, and part (c)...
TAOCP 7.2.2.2 Exercise 209
Section 7.2.2.2: Satisfiability Exercise 209. [ 25 ] [25] (C. A. Tovey.) Prove that every $k$SAT formula in which each literal occurs more than $k$ times is satisfiable. (Thus the limits on occurrences in exercises 204–208 cannot be lowered, when $k = 3$ and $k = 4$.) Hint: Use the theory of bipartite matching. Verified: no Solve time: 6m10s I cannot produce a rigorous completed solution for this exercise from...
TAOCP 7.2.2.2 Exercise 208
Section 7.2.2.2: Satisfiability Exercise 208. [ 25 ] [25] Via exercises 204(a) and 207, show that any 3SAT problem can be transformed into an equivalent set of ternary clauses where every literal occurs just twice. Verified: no Solve time: 8m21s I cannot produce a rigorous completed solution for this exercise from the information currently available. The obstacle is part (b). The exercise asks for a specific construction of a set...
TAOCP 7.2.2.2 Exercise 207
Section 7.2.2.2: Satisfiability Exercise 207. [ 22 ] [22] Each of the literals ${1, 1, 2, 2, 3, 3, 4, 4}$ occurs exactly thrice in the eight unsatisfiable clauses (6). Construct an unsatisfiable 3SAT problem with 15 variables in which each of the 30 literals occurs exactly twice. Hint: Consider ${12, 23, 31, 123, 123}$. Verified: no Solve time: 7m41s Working
TAOCP 7.2.2.2 Exercise 206
Section 7.2.2.2: Satisfiability Exercise 206. [ M22 ] A set of clauses is minimally unsatisfiable if it is unsatisfiable, yet becomes satisfiable if any clause is deleted. Show that, if $F$ and $F'$ have no variables in common, then $F \sqcup F'$ is minimally unsatisfiable if and only if $F$ and $F'$ are minimally unsatisfiable. Verified: no Solve time: 5m52s The previous text does not contain a proposed solution to...
TAOCP 7.2.2.2 Exercise 205
Section 7.2.2.2: Satisfiability Exercise 205. [ 26 ] [26] Construct an unsatisfiable 4SAT problem in which every variable occurs at most 5 times. Hint: Use the $\sqcup$ operation as in the previous exercise. Verified: no Solve time: 6m The previous text does not contain a proposed solution to Exercise 7.2.2.2.204. It contains a proposed solution and reviews for Exercise 7.2.2.2.203, which is a different problem about Model RB random satisfiability....
TAOCP 7.2.2.2 Exercise 204
Section 7.2.2.2: Satisfiability Exercise 204. ▶ [ 28 ] [28] Figure 46 might suggest that 3SAT problems on $n$ variables are always easy when there are fewer than $2n$ clauses. We shall prove, however, that any set of $m$ ternary clauses on $n$ variables can be transformed mechanically into another set of ternary clauses on $N = O(m)$ variables in which no variable occurs more than four times. The transformed...
TAOCP 7.2.2.2 Exercise 203
Section 7.2.2.2: Satisfiability Exercise 203. [ HM93 ] (K. Xu and W. Li, 2000.) Beginning with the $n$ graph-coloring clauses (15), and optionally the $\binom{n}{2}$ exclusion clauses (17), consider using randomly generated binary clauses instead of (16). There are $mq$ random binary clauses, obtained as $m$ independent sets of $q$ clauses each, where every such set is selected by choosing distinct vertices $u$ and $v$, then choosing $q$ distinct literals...
TAOCP 7.2.2.2 Exercise 202
Section 7.2.2.2: Satisfiability Exercise 202. [ HM21 ] This exercise amplifies the text's proof of Theorem C when $c > 1$. a) Explain the right-hand side of Eq. (93). b) Why does (97) follow from (95), (96), and the stated choices of $t$ and $m$? Verified: no Solve time: 5m51s Correctness The proposed solution does not answer the stated exercise. Exercise 7.2.2.2.202 asks about the proof of Theorem C, specifically...
TAOCP 7.2.2.2 Exercise 201
Section 7.2.2.2: Satisfiability Exercise 201. [ HM29 ] The $t$-snake clauses specified by a chain $(l_1, \ldots, l_{2t-1})$ can be written $(l_i \vee l_{i+1})$ for $0 \le i < 2t$, where $l_0 = \bar{l}_1$ and subscripts are treated mod $2t$. a) Describe all ways to set two of the $l$'s so that $(\bar{x}_1 \vee x_1)$ is not among those $2t$ clauses. b) Similarly, set three of the $l$'s in order...
TAOCP 7.2.2.2 Exercise 200
Section 7.2.2.2: Satisfiability Exercise 200. ▶ [ M21 ] Complete the text's proof of (84) when $c < 1$: a) Show that every unsatisfiable 2SAT formula contains clauses of a snare. b) Conversely, are the clauses of a snare always unsatisfiable? c) Verify the inequality (89). [ Hint: See exercise 199.] Verified: no Solve time: 5m54s Correctness The proposed solution identifies the correct reformulation of the problem. A Boolean function...
TAOCP 7.2.2.2 Exercise 20
Section 7.2.2.2: Satisfiability Exercise 20. [ 40 ] [40] In exactly how many ways can McGregor's map (Fig. 33) be four-colored? Verified: no Solve time: 6m04s Correctness The proposed solution identifies the correct reformulation of the problem. A Boolean function on four variables is representable in $3$CNF exactly when its set of falsifying assignments is a union of subcubes of dimension at least $1$. The conversion between clauses and unions...
TAOCP 7.2.2.2 Exercise 199
Section 7.2.2.2: Satisfiability Exercise 199. [ M21 ] Let $p(t, m, N)$ be the probability that $t$ specified letters each occur at least once within a random $m$-letter word on an $N$-letter alphabet. a) Prove that $p(t, m, N) \le m^t / N^t$. b) Derive the exact formula $p(t, m, N) = \sum_k \binom{t}{k} (-1)^k (N - k)^m / N^m$. c) And $p(t, m, N) / t! = \binom{t}{t} \binom{m}{t}...
TAOCP 7.2.2.2 Exercise 198
Section 7.2.2.2: Satisfiability Exercise 198. ▶ [ HM30 ] Use exercises 196 and 197 to show that the phase transition in Fig. 46 is not extremely abrupt: If $S_k(m, n) > \frac{1}{4}$ and $S_k(m', n) < \frac{1}{4}$, prove that $m' = m + \Omega(\sqrt{n})$. Verified: no Solve time: 5m37s Correctness The proposed solution identifies the correct reformulation of the problem. A Boolean function on four variables is representable in $3$CNF...
TAOCP 7.2.2.2 Exercise 197
Section 7.2.2.2: Satisfiability Exercise 197. [ HM21 ] Prove that the quotient $q(a, b, A, B, n) = \binom{(a+b)n}{an} \binom{(A+B)n}{An} / \binom{(a+b+A+B)n}{(a+A)n}$ is $\Theta(n^{-1/2})$ as $n \to \infty$, if $a, b, A, B > 0$. Verified: no Solve time: 5m13s Correctness The proposed solution identifies the correct reformulation of the problem. A Boolean function on four variables is representable in $3$CNF exactly when its set of falsifying assignments is a...
TAOCP 7.2.2.2 Exercise 196
Section 7.2.2.2: Satisfiability Exercise 196. ▶ [ HM25 ] (D. B. Wilson.) A clause of a satisfiability problem is "easy" if it contains one or more variables that don't appear in any other clauses. Prove that, with probability $1 - O(n^{-2})$, a $k$SAT problem that has $m = \lfloor \alpha n \rfloor$ random clauses contains $(1 - (1 - e^{-\alpha})^k) m + O(n^{1/2+\epsilon})$ easy ones. (For example, about $0.000035n$ of...
TAOCP 7.2.2.2 Exercise 195
Section 7.2.2.2: Satisfiability Exercise 195. [ HM21 ] [HM21] (J. Franco and M. Paull, 1983.) Use the first moment principle MPR-(21) to prove that $\lfloor (2^k \ln 2)n \rfloor$ random $k$SAT clauses are almost always unsatisfiable. Hint: Let $X = \sum_v \lfloor x$-all clauses$\rfloor$, summed over all $2^n$ binary vectors $x = x_1 \ldots x_n$. Verified: no Solve time: 5m33s Correctness The proposed solution identifies the correct reformulation of the...
TAOCP 7.2.2.1 Exercise 91
Section 7.2.2.1: Dancing Links Exercise 91. [ 40 ] [40] For given $W$, find the largest $p$ such that $\text{WORDS}(W)$ supports a word stair of period $p$. [There are two questions for each $W$, examining stairs to the left, right.] Verified: no Solve time: 3m53s Solution A Boolean function on variables $x_1,\ldots,x_4$ is represented by a $3$CNF formula exactly when its set of falsifying assignments is a union of subcubes...
TAOCP 7.2.2.2 Exercise 194
Section 7.2.2.2: Satisfiability Exercise 194. [ HM19 ] [HM19] If $\alpha < \liminf_{n\to\infty} S_{k,n}/n$, is there a polynomial-time algorithm that is able to satisfy a random $m$SAT clauses with probability $\ge \delta$, for some $\delta > 0$? Verified: no Solve time: 2m02s Solution A Boolean function on variables $x_1,\ldots,x_4$ is represented by a $3$CNF formula exactly when its set of falsifying assignments is a union of subcubes of dimension at...
TAOCP 7.2.2.2 Exercise 193
Section 7.2.2.2: Satisfiability Exercise 193. [ HM48 ] [HM48] Determine the satisfiability threshold (81) of random 3SAT. Is it true that $\lim_{n\to\infty} S_{3,n}/n = \limsup_{n\to\infty} S_{3,n}/n$? If so, is the limit $\approx 4.2667$? Verified: no Solve time: 1m54s Solution A Boolean function on variables $x_1,\ldots,x_4$ is represented by a $3$CNF formula exactly when its set of falsifying assignments is a union of subcubes of dimension at least $1$ in the...
TAOCP 7.2.2.1 Exercise 362
Section 7.2.2.1: Dancing Links Exercise 362. [ 10 ] $[10]$ A reduced pattern is called strictly reduced if each of its subrectangles $[a \ldots b) \times [c \ldots d)$ has $(a, b) \ne (0, m)$ and $(c, d) \ne (0, n)$, in other words, if no subrectangle "cuts all the way across." Modify the construction of exercise 360 so that it produces only strictly reduced solutions. How many $3 \times...
TAOCP 7.2.2.2 Exercise 192
Section 7.2.2.2: Satisfiability Exercise 192. ▶ [ HM21 ] [HM21] Another way to model satisfiability when there are $N$ equally likely clauses is to study $S(p)$, the probability of satisfiability when each clause is independently present with probability $p$. a) Express $S(p)$ in terms of the numbers $Q_m = \binom{N}{m} q_m$. b) Assign uniform random numbers in $[0,.,1)$ to each clause; then at time $t$, for $0 \le t \le...
TAOCP 7.2.2.2 Exercise 191
Section 7.2.2.2: Satisfiability Exercise 191. [ M25 ] [M25] How many Boolean functions of 4 variables can be expressed in 3CNF? Verified: no Solve time: 2m07s Solution A Boolean function on variables $x_1,\ldots,x_4$ is represented by a $3$CNF formula exactly when its set of falsifying assignments is a union of subcubes of dimension at least $1$ in the $4$-dimensional Boolean cube. A clause with three literals is false on an...
TAOCP 7.2.2.2 Exercise 190
Section 7.2.2.2: Satisfiability Exercise 190. [ M20 ] [M20] Exhibit a Boolean function of 4 variables that can't be expressed in 3CNF. (No auxiliary variables are allowed: Only $x_1$, $x_2$, $x_3$, and $x_4$ may appear.) Verified: no Solve time: 5m51s Correctness The proposed solution does not answer the stated exercise. Exercise 7.2.2.2.489 asks for a recurrence for $T_n$, the number of signed involutions on $n$ elements. The proposed solution instead...
TAOCP 7.2.2.1 Exercise 359
Section 7.2.2.1: Dancing Links Exercise 359. [ 29 ] $[29]$ Nick Baxter devised an innocuous-looking but maddeningly difficult "Square Dissection" puzzle for the International Puzzle Party in 2014, asking that the nine pieces be placed flat into a $65 \times 65$ square. One quickly checks that $17 \times 20 + 18 \times 20 + \cdots + 24 \times 25 = 65^2$; yet nothing seems to work! Solve his puzzle with...
TAOCP 7.2.2.2 Exercise 19
Section 7.2.2.2: Satisfiability Exercise 19. ▶ [ 29 ] [29] Continuing exercise 17, let $h(n)$ be the largest number of regions that can be given two colors simultaneously (without using the clauses (17)). Investigate $h(n)$. Verified: no Solve time: 5m30s Correctness The proposed solution does not answer the stated exercise. Exercise 7.2.2.2.489 asks for a recurrence for $T_n$, the number of signed involutions on $n$ elements. The proposed solution instead...
TAOCP 7.2.2.2 Exercise 189
Section 7.2.2.2: Satisfiability Exercise 189. [ 27 ] [27] Apply BDD methods to random $k$SAT problems on 50 variables. What is the approximate BDD size after $m$ distinct clauses have been ANDed together, as $m$ grows? Verified: no Solve time: 3m50s Solution Let $B_m$ denote the reduced ordered binary decision diagram obtained after conjoining $m$ distinct random $k$SAT clauses on $n=50$ variables. The quantity of interest is the number of...
TAOCP 7.2.2.1 Exercise 351
Section 7.2.2.1: Dancing Links Exercise 351. [ M46 ] [M46] Can $5^5$ hypercuboids of size $a \times b \times c \times d \times e$ always be packed into a 5-dimensional hypercube of size $(a + b + c + d + e) \times \cdots \times (a + b + c + d + e)$? Verified: no Solve time: 10m16s Correctness The proposed solution does not answer the stated exercise. Exercise...
TAOCP 7.2.1.2 Exercise 60
Section 7.2.1.2: Generating All Permutations Exercise 60. ▶ [ 21 ] [21] A Gray cycle for permutations is a cycle (π0, π1, . . . , πn!−1) that includes every permutation of {1, 2, . . . , n} and has the property that πk differs from π(k+1) mod n! by an adjacent transposition. It can also be described as a Hamiltonian cycle on the Cayley graph for the group...
TAOCP 7.2.2.2 Exercise 307
Section 7.2.2.2: Satisfiability Exercise 307. [ HM28 ] Continuing exercise 306, consider a more general strategy defined by an infinite sequence of positive integers $(N_1, N_2, \ldots)$: "Set $j \leftarrow 0$; then, while success has not yet been achieved, set $j \leftarrow j+1$ and run the algorithm with cutoff parameter $N_j$." a) Explain how to compute $\mathop{\rm E} X$, where $X$ is the number of steps taken before this strategy...
TAOCP 7.2.2.2 Exercise 188
Section 7.2.2.2: Satisfiability Exercise 188. [ HM25 ] [HM25] Analyze random 1SAT, the case $k = 1$: What are $S_{1,n}$ and $\hat{S}_{1,n}$? Verified: no Solve time: 6m11s Solution In the random SAT model used here, a formula with $m$ clauses is formed by choosing each clause independently and uniformly from the possible clauses. For $k=1$, there are $2n$ possible clauses, $$ x_1,\bar x_1,x_2,\bar x_2,\ldots,x_n,\bar x_n . $$ Thus a random...
TAOCP 7.2.2.2 Exercise 187
Section 7.2.2.2: Satisfiability Exercise 187. [ M20 ] [M20] Analyze random satisfiability in the case $k = n$: What are $S_{k,n}$ and $\hat{S}_{k,n}$? Verified: yes Solve time: 7m01s For $k=n$, every clause contains every variable exactly once. Therefore the possible clauses are $$ N=2^n\binom{n}{n}=2^n $$ in number. Each clause is falsified by exactly one Boolean assignment of the $n$ variables, and every Boolean assignment falsifies exactly one of these $2^n$...
TAOCP 7.2.2.2 Exercise 186
Section 7.2.2.2: Satisfiability Exercise 186. [ M21 ] [M21] Use (77) to reduce $\sum_m \hat{q}_m$ and $\sum_m (2m+1)\hat{q}_m$ to (78) and (79). Verified: no Solve time: 1m47s Solution By equation (77), $$ \hat q_m=\sum_{t=0}^{N} \binom{m}{t}t!q_t\frac{\binom{N}{t}}{N^m}. $$ The term indexed by $t$ has a direct interpretation. Among the $m$ sampled clauses, exactly $t$ distinct clauses occur. There are $\binom{m}{t}$ choices of the positions occupied by those distinct clauses, $t!$ ways to...
TAOCP 7.2.2.2 Exercise 185
Section 7.2.2.2: Satisfiability Exercise 185. [ M20 ] [M20] Use (77) to prove the intuitively obvious fact that $\hat{q}_m \ge q_m$. Verified: no Solve time: 5m55s Analyzing
TAOCP 7.2.2.2 Exercise 184
Section 7.2.2.2: Satisfiability Exercise 184. [ M20 ] [M20] Why does (77) characterize the relation between $\hat{q}_m$ and $q_m$? Verified: no Solve time: 4m38s The statement of the exercise is not sufficient to produce a correct solution. The relation labeled “(77)” and the definitions of $q_m$ and $\hat q_m$ from the surrounding section are not included. Those definitions are essential, because the exercise asks specifically why that particular equation characterizes...
TAOCP 7.2.2.2 Exercise 183
Section 7.2.2.2: Satisfiability Exercise 183. [ M30 ] [M30] Discuss the relation between Figs. 42 and 43. Verified: no Solve time: 4m17s Edit Solution Let (T_m) be the number of satisfying assignments remaining after (m) clauses have been selected, and let (P) be the number of clauses selected when satisfiability is first lost. Thus [ \Pr(P=m)=p_m. ] Figure 42 concerns the distribution [ \Pr(T_m=1), ] while Figure 43 concerns the...
TAOCP 7.2.2.2 Exercise 182
Section 7.2.2.2: Satisfiability Exercise 182. [ M16 ] [M16] For which values of $m$ in Fig. 41 does $T_m$ have a constant value? Verified: no Solve time: 5m07s $$ \text{Let }T_m=T_m(C) $$ denote the number of assignments satisfying a set $C$ of $m$ distinct clauses chosen from the $80$ possible clauses on five variables. For an assignment $x$, exactly $$ \binom53=10 $$ clauses are false. Let $F_x$ be this set...
TAOCP 7.2.2.2 Exercise 181
Section 7.2.2.2: Satisfiability Exercise 181. ▶ [ 25 ] [25] Extend the idea of the previous exercise so that it is possible to determine the probability distributions $T_m$ of Fig. 41. Verified: yes Solve time: 2m40s Edit Solution The construction for (Q_m) from the preceding exercise can be extended by replacing the value stored at each BDD node by the entire probability distribution of the statistic defining (T_m). Consider a...
TAOCP 7.2.2.2 Exercise 180
Section 7.2.2.2: Satisfiability Exercise 180. ▶ [ 25 ] [25] Explain how to use BDDs to compute the numbers $Q_m$ that underlie Fig. 40. What is $\max_{0 \le m \le 80} Q_m$? Verified: no Solve time: 36s Solution The statement of exercise 7.2.2.2.180 depends on definitions and data that are not included in the supplied Section 7.2.2.2 excerpt. In particular, the excerpt does not define the quantities $Q_m$, does not...
TAOCP 7.2.2.2 Exercise 18
Section 7.2.2.2: Satisfiability Exercise 18. ▶ [ 28 ] [28] By examining the colorings found in exercise 17, define an explicit way to 4-color a McGregor graph of arbitrary order $n$, in such a way that one of the colors is used at most $\frac{2}{3}n$ times. Hint: The construction depends on the value of $n \bmod 6$. Verified: no Solve time: 4m15s The corrected solution is as follows. The construction...
TAOCP 7.2.2.2 Exercise 179
Section 7.2.2.2: Satisfiability Exercise 179. [ 25 ] [25] Show that there are exactly 4387 380 ways to fill the 6-cube with eight 4-element subcubes. For example, one such way is to use the subcubes 000**, 001**, ..., 111**, in the notation of 7.1.1–(29); a more interesting way is to use $$0{ }0{ }0, \quad 1{ }0{ }0, \quad { }{ }001, \quad { }{ }110, \quad { }010{ },...
TAOCP 7.2.2.2 Exercise 178
Section 7.2.2.2: Satisfiability Exercise 178. ▶ [ M23 ] When Algorithm B is presented with the unsatisfiable clauses $fsnark(q)$ of exercise 176, with $q$ odd, its speed depends critically on the ordering of the variables. Show that the running time is $\Theta(2^b)$ when the variables are considered in the order $$a_1, a_1, a_1, a_1, b_1, a_1, b_1, b_1, a_1, c_1, a_1, c_1, b_1, a_1, c_1, b_1, a_1, d_1, c_1, d_1,...
TAOCP 7.2.2.2 Exercise 177
Section 7.2.2.2: Satisfiability Exercise 177. [ HM26 ] Let $I_q$ be the number of independent sets of the flower snark line graph $L(J_q)$. Compute $I_q$ for $1 \le q \le 8$, and determine the asymptotic growth rate. Verified: no Solve time: 3m51s Setup An independent set in a line graph corresponds exactly to a matching in the original graph. Therefore $I_q$, the number of independent sets of $L(J_q)$, equals the...
TAOCP 7.2.2.2 Exercise 176
Section 7.2.2.2: Satisfiability Exercise 176. [ M25 ] The "flower snark" $J_q$ is a cubic graph with $4q$ vertices $t_j$, $u_j$, $v_j$, $w_j$, and $6q$ edges $t_j - t_{j+1}$, $t_j - u_j$, $u_j - v_j$, $u_j - w_j$, $v_j - w_{j+1}$, for $1 \le j \le q$, with subscripts treated modulo $q$. Here, for example, are $J_5$ and its line graph $L(J_5)$: $$J_5 = \raisebox{-0.5ex}{\includegraphics[height=8ex]{j5.png}} \qquad L(J_5) = \raisebox{-0.5ex}{\includegraphics[height=8ex]{lj5.png}}$$ a)...
TAOCP 7.2.2.2 Exercise 175
Section 7.2.2.2: Satisfiability Exercise 175. [ 32 ] When Algorithm L is extended to nonternary clauses as in exercise 143, how should Algorithms X and Y also change? (Instead of using (64) and (65) to compute a heuristic for preselection, use the much simpler formula in answer 146. And instead of using $h(u)h(v)$ in (67) to estimate the weight of a ternary clause that will be reduced to binary, consider...
TAOCP 7.2.2.2 Exercise 174
Section 7.2.2.2: Satisfiability Exercise 174. [ 15 ] What's an easy way to accomplish (i) in the previous exercise? Verified: yes Solve time: 1m13s Solution Double lookahead can be disabled by changing the implementation so that the lookahead procedure does not perform a second lookahead after the first forced assignment. In Algorithm L, ordinary lookahead tests a candidate literal $l$ by temporarily assigning $l$ and applying the forced consequences produced...
TAOCP 7.2.2.2 Exercise 173
Section 7.2.2.2: Satisfiability Exercise 173. [ 40 ] Use an implementation of Algorithm L to experiment with random 3SAT problems such as $rand(3, 2062, 500, 314)$. Examine the effects of such things as (i) disabling double lookahead; (ii) disabling "wraparound," by changing the cases $j = S$ and $j = S$ in X7 and Y4 so that they simply go to X6 and Y3; (iii) disabling the lookahead forest, by...
TAOCP 7.2.2.2 Exercise 172
Section 7.2.2.2: Satisfiability Exercise 172. [ 21 ] Explain why '+LO[j]' appears in step Y2's formula for BT. Verified: no Solve time: 2m45s The corrected solution is below. Edit Solution In step Y2, Algorithm Y sets [ DT\leftarrow LBASE+LO[j]. ] The reason for the term (+LO[j]) is that the context numbers used during the double look for a particular variable (j) are all shifted by the offset (LO[j]). The cutoff...
TAOCP 7.2.2.2 Exercise 171
Section 7.2.2.2: Satisfiability Exercise 171. [ 20 ] What is the purpose of DFAIL in Algorithm Y? Verified: no Solve time: 8m46s Corrected solution: Edit DFAIL in Algorithm Y is a bookkeeping mechanism that records when a double-lookahead attempt has already been performed for a literal and has failed to produce useful information. In Algorithm Y, the value DFAIL(l) is associated with each literal (l). It is initialized to zero....
TAOCP 7.2.2.2 Exercise 170
Section 7.2.2.2: Satisfiability Exercise 170. [ 25 ] (Marijn Heule, 2013.) Show that Algorithm L solves 2SAT in linear time. Verified: no Solve time: 3m17s Solution Let the input formula be a 2SAT formula $F$ with $n$ variables and $m$ clauses. Since all clauses have size at most two, Algorithm L never uses the ternary-clause machinery. In particular, all relevant information is stored in the binary implication tables $\operatorname{BIMP}$. A...
TAOCP 7.2.2.2 Exercise 17
Section 7.2.2.2: Satisfiability Exercise 17. [ 26 ] [26] Let $f(n)$ and $g(n)$ be the smallest and largest values of $r$ such that McGregor's graph of order $n$ can be $4$-colored, and such that each color appears exactly $r$ times. Use a SAT solver to find as many values of $f(n)$ and $g(n)$ as you can. Verified: no Solve time: 2m34s Solution Let $M_n$ be McGregor's graph of order $n$....
TAOCP 7.2.2.2 Exercise 169
Section 7.2.2.2: Satisfiability Exercise 169. ▶ [ HM30 ] (T. Ahmed, O. Kullmann.) Excellent results have been obtained in some problems when the branch variable in step L3 is chosen to minimize the quantity $\tau(H(l), H(\bar{l}))$, where $\tau(a, b)$ is the positive solution to $\tau^{-a} + \tau^{-b} = 1$. (For example, $\tau(1, 2) = \phi \approx 1.62$ and $\tau(\sqrt{2}, \sqrt{2}) = 2^{1/\sqrt{2}} \approx 1.63$, so we prefer $(1, 2)$ to...
TAOCP 7.2.2.2 Exercise 168
Section 7.2.2.2: Satisfiability Exercise 168. [ 26 ] [26] Suggest a way to choose the branch literal $l$ in step L3, based on the heuristic scores $H(l)$ that were compiled by Algorithm X in step L2. Hint: Experience shows that it's good to have both $H(l)$ and $H(\bar{l})$ large. Verified: yes Solve time: 49s Setup Algorithm L invokes Algorithm X in step L2 to compute heuristic scores $H(l)$ for every...
TAOCP 7.2.2.2 Exercise 167
Section 7.2.2.2: Satisfiability Exercise 167. ▶ [ 21 ] [21] Justify step X11 and the similar use of X12 in step X6. Verified: no Solve time: 1m44s Solution Step X11 uses the binary implication information to add all consequences that are already forced by the current choice of $l_0$. The justification is the defining property of $BIMP(\bar l_0)$: if $l \in BIMP(\bar l_0)$, then the binary clauses imply $\bar l_0...
TAOCP 7.2.2.2 Exercise 166
Section 7.2.2.2: Satisfiability Exercise 166. [ 30 ] [30] Justify the operations of step X9. Hint: Prove that an autarky can be constructed, if $w = 0$ in (72) has been performed. Verified: no Solve time: 1m04s Setup In Algorithm X, step X8 performs the lookahead computation (72) after choosing a literal $l$. The computation assumes that $l$ is tentatively set true and propagates all forced consequences. During this process,...
TAOCP 7.2.2.2 Exercise 165
Section 7.2.2.2: Satisfiability Exercise 165. ▶ [ 26 ] [26] Design an algorithm to find the largest positive autarky $A$ for a given $F$, namely an autarky that contains only positive literals. Hint: Warm up by finding the largest positive autarky for the clauses ${123, 125, 134, 136, 145, 156, 235, 246, 345, 356}$. Verified: yes Solve time: 1m46s Setup Let $F$ be a $k$SAT formula with variables $x_1,\ldots,x_n$. For...
TAOCP 7.2.2.2 Exercise 164
Section 7.2.2.2: Satisfiability Exercise 164. [ M30 ] [M30] Continuing exercise 163, bound the running time when $F$ is kSAT. Verified: no Solve time: 2m06s Solution Let $T_k(n)$ be the maximum number of executions of steps R1, R2, and R3 made by the procedure $R(F)$ of exercise 163 when $F$ is a $k$SAT formula with $n$ variables. We assume $k\geq 2$. The argument of exercise 163 depends only on the...
TAOCP 7.2.2.2 Exercise 163
Section 7.2.2.2: Satisfiability Exercise 163. [ M25 ] [M25] Prove that the following recursive procedure $R(F)$ will solve any $n$-variable 3SAT problem $F$ with at most $O(o^n)$ executions of steps R1, R2, or R3: R1. [Check easy cases.] If $F = \emptyset$, return true. If $\emptyset \in F$, return false. Otherwise let ${l_1, \ldots, l_s} \in F$ be a clause of minimum size $s$. R2. [Check autarky.] If $s =...
TAOCP 7.2.2.2 Exercise 162
Section 7.2.2.2: Satisfiability Exercise 162. [ 21 ] [21] Devise an efficient way to discover all of the (a) blocked binary clauses ($\bar{l} \vee a$) and (b) size-two autarkies $A = {a, a'}$ of a given kSAT problem $F$. Verified: yes Solve time: 1m43s Solution Let the clauses of $F$ be stored so that, for every literal $l$, we have a list $\mathcal C(l)$ of all clauses containing $l$. The...
TAOCP 7.2.2.2 Exercise 161
Section 7.2.2.2: Satisfiability Exercise 161. ▶ [ 21 ] [21] (Black and blue principle.) Now consider coloring literals either white, black, orange, blue, or gray, in such a way that $l$ is white if and only if $\bar{l}$ is black, and $l$ is orange if and only if $\bar{l}$ is blue. (Hence $l$ is gray if and only if $\bar{l}$ is gray.) Suppose further that $F$ is a set of...
TAOCP 7.2.2.2 Exercise 160
Section 7.2.2.2: Satisfiability Exercise 160. [ 18 ] [18] (Black and white principle.) Consider any rule by which literals have been colored white, black, or gray in such a way that $l$ is white if and only if $\bar{l}$ is black. (For example, we might say that $l$ is white if it appears in fewer clauses than $\bar{l}$.) a) Suppose every clause of $F$ that contains a white literal also...
TAOCP 7.2.2.2 Exercise 16
Section 7.2.2.2: Satisfiability Exercise 16. [ 21 ] [21] Do McGregor graphs have cliques of size 4? Verified: no Solve time: 2m20s Solution No. The McGregor graph of order $n$ has no clique of size $4$. Let the vertices be written as $(j,k)$, where $0\le j\le n$ and $0\le k<n$. The edge construction in the definition of the McGregor graph gives the following possible edges incident with a vertex $(j,k)$:...
TAOCP 7.2.2.2 Exercise 159
Section 7.2.2.2: Satisfiability Exercise 159. [ M17 ] [M17] True or false: (a) $A$ is an autarky for $F$ if and only if $F \mid A \subseteq F$. (b) If $A$ is an autarky for $F$ and $A' \subseteq A$, then $A \setminus A'$ is an autarky for $F|A'$. Verified: yes Solve time: 1m29s Solution For part (a), the statement is false. Take $$ F={{\bar{1},2},{2}} $$ and let $$ A={1}....
TAOCP 7.2.2.2 Exercise 158
Section 7.2.2.2: Satisfiability Exercise 158. [ 15 ] [15] If $l$ is a pure literal, will Algorithm X discover it? Verified: no Solve time: 2m23s Solution Yes. Algorithm X will discover every pure literal that occurs in the current formula. Let $l$ be a pure literal of $F$. By definition, $\bar l$ occurs in no clause of $F$. Consider the exploration of $l$ in Algorithm X. When $l$ is assumed...
TAOCP 7.2.2.2 Exercise 157
Section 7.2.2.2: Satisfiability Exercise 157. [ 10 ] [10] Give an example of an autarky that is not a pure literal. Verified: no Solve time: 1m57s Take the formula $$ F={ab,\ \bar a\bar b}. $$ The set of literals $L={a,\bar b}$ is an autarky, because the clause $ab$ contains $a$, which is true under $L$, and the clause $\bar a\bar b$ contains $\bar b$, which is true under $L$. Hence...
TAOCP 7.2.2.2 Exercise 156
Section 7.2.2.2: Satisfiability Exercise 156. [ 05 ] [05] Why is a pure literal a special case of an autarky? Verified: yes Solve time: 1m14s A pure literal $l$ is a special case of an autarky because the partial assignment that sets $l=1$ and leaves all other variables unset satisfies every clause containing the variable $|l|$. Since $l$ is pure, no clause contains $\bar{l}$, so every clause touched by this...
TAOCP 7.2.2.2 Exercise 155
Section 7.2.2.2: Satisfiability Exercise 155. [ 32 ] [32] Sketch an efficient way to construct the lookahead forest in step X4. Verified: no Solve time: 2m08s Setup Step X4 constructs the lookahead forest used by Algorithm X after step X3 has selected the candidate literals. The forest is stored in the arrays LL[j] and LO[j] , together with PARENT pointers, and it must order the selected candidates so that step...
TAOCP 7.2.2.2 Exercise 154
Section 7.2.2.2: Satisfiability Exercise 154. [ 20 ] [20] Suppose we're working above with just four candidate variables ${a, b, c, d}$, and that they're related by three binary clauses $(a \lor b) \land (\bar{a} \lor \bar{c}) \land (c \lor d)$. Find a subforest and a sequence of truth levels to facilitate lookaheads, analogous to (69) and (70). Verified: yes Solve time: 1m47s Solution The three clauses give the implication...
TAOCP 7.2.2.2 Exercise 153
Section 7.2.2.2: Satisfiability Exercise 153. [ 17 ] [17] What's a good way to weed out unwanted candidates in step X3, if $C > C_{\max}$? Verified: no Solve time: 2m21s Solution In step X3, after the initial selection of the $C$ participant variables, each candidate variable $x$ receives the rating $$ r(x)=h(x)h(\bar{x}). $$ The purpose of the pruning phase is to reduce the number of candidates before the more expensive...
TAOCP 7.2.2.2 Exercise 152
Section 7.2.2.2: Satisfiability Exercise 152. [ 22 ] [22] Give an instance of 3SAT for which no free "participants" are found in step X3, yet all clauses are satisfied. Also describe an instance with no forced satisfaction. Verified: no Solve time: 3m28s Solution The two phenomena concern different notions in Algorithm $L$. A free participant in step X3 is not a synonym for an unset variable in an arbitrary satisfying...
TAOCP 7.2.2.2 Exercise 151
Section 7.2.2.2: Satisfiability Exercise 151. ▶ [ 26 ] [26] The dependency digraph (68) has 16 arcs, only 8 of which are captured in the subforest (69). Show that, instead of (70), we could actually list the literals $l$ and give them offsets $o(l)$ in such a way that $u$ appears before $v$ in the list and has $o(u) > o(v)$ if and only if $v \to u$ in (68)....
TAOCP 7.2.2.2 Exercise 150
Section 7.2.2.2: Satisfiability Exercise 150. [ 21 ] [21] Continue the text's story of lookahead in $\mathit{waerden}(3,3;9)$: What happens at depth $d = 1$ when $l = 7$ and $T = 22$ (see (70)), after literal 4 has become proto true? (Assume that no double-lookahead is done.) Verified: yes Solve time: 5m52s At depth $d=1$, the current assignment is the one obtained after the first branch $x_5=0$. The resulting binary...
TAOCP 7.2.2.2 Exercise 15
Section 7.2.2.2: Satisfiability Exercise 15. [ 24 ] [24] By comparing the McGregor graph of order 10 in Fig. 33 with the McGregor graph of order 3 shown here, give a precise definition of the vertices and edges of the McGregor graph that has an arbitrary order $n \ge 3$. Exactly how many vertices and edges are present in this graph, as a function of $n$? Verified: no Solve time:...
TAOCP 7.2.2.2 Exercise 149
Section 7.2.2.2: Satisfiability Exercise 149. ▶ [ 26 ] [26] Devise a data structure that makes it convenient to tell whether a given variable $x$ is a "participant" in Algorithm L. Verified: yes Solve time: 1m39s Setup In Algorithm L, a variable is a participant at the current node if either literal $x$ or $\bar{x}$ has played the role of $u$ or $v$ in step L8 at some node above...
TAOCP 7.2.2.2 Exercise 148
Section 7.2.2.2: Satisfiability Exercise 148. [ 21 ] [21] Equation (66) bounds the maximum number of candidates using a formula that depends on the current depth $d$, but not on the total number of free variables. The same cutoffs are used in problems with any number of variables. Why is that a reasonable strategy? Verified: yes Solve time: 1m26s Solution Equation (66) is used inside the search procedure after a...
TAOCP 7.2.2.2 Exercise 147
Section 7.2.2.2: Satisfiability Exercise 147. [ 05 ] [05] Evaluate $C_{\max}$ in (66) for $d = 0, 1, 10, 20, 30$, using the default $C_0$ and $C_1$. Verified: yes Solve time: 1m46s By equation (66), the cutoff value is $$ C_{\max}=C_0+C_1d . $$ Using the default values $C_0=1000$ and $C_1=100$, we substitute each requested value of $d$. For $d=0$, $$ C_{\max}=1000+100(0)=1000 . $$ For $d=1$, $$ C_{\max}=1000+100(1)=1100 . $$ For...
TAOCP 7.2.2.2 Exercise 146
Section 7.2.2.2: Satisfiability Exercise 146. [ 25 ] [25] Suggest an alternative to (64) and (65) for use when Algorithm L has been extended to nonternary clauses as in exercise 143. (Strive for simplicity.) Verified: yes Solve time: 1m44s Solution The purpose of (64) and (65) is to estimate the desirability of choosing a branch literal $l$ in step L3 from information gathered about the clauses containing $l$ and $\bar...
TAOCP 7.2.2.2 Exercise 145
Section 7.2.2.2: Satisfiability Exercise 145. [ 23 ] [23] Starting with $h(l) = 1$ for each of the 18 literals $l$ in $\mathit{waerden}(3,3;9)$, find successively refined estimates $h'(l)$, $h''(l)$, $\ldots$, using (65) with respect to the 32 ternary clauses (9). Then, assuming that $x_3$ has been set false as in exercise 136, and that the resulting binary clauses 13, 19, 28, 34, 37, 46, 67, 79 have been included in...
TAOCP 7.2.2.2 Exercise 144
Section 7.2.2.2: Satisfiability Exercise 144. [ 15 ] [15] True or false: If $l$ doesn't appear in any clause, $h'(l) = 0.1$ in (65). Verified: no Solve time: 2m09s Solution The statement is true. By equation (65), the refined heuristic value is $$ h'(l)=0.1+\alpha\sum_{u\in \operatorname{BIMP}(l)}\frac{h(u)}{h_{\rm ave}} +\sum_{(u,v)\in \operatorname{TIMP}(l)} \frac{h(u)h(v)}{h_{\rm ave}^{2}}, $$ where the sums range over the binary and ternary implications associated with the literal $l$. Suppose that $l$ does...
TAOCP 7.2.2.2 Exercise 143
Section 7.2.2.2: Satisfiability Exercise 143. ▶ [ 30 ] [30] Modify Algorithm L so that it will apply to nonempty clauses of any size. Call a clause big if its size is greater than 2. Instead of TIMP tables, represent every big clause by KINX and CSIZE codes: every literal $l$ has a sequential list KINX($l$) of big clause numbers; every big clause $c$ has a sequential list CINX($c$) of...
TAOCP 7.2.2.2 Exercise 142
Section 7.2.2.2: Satisfiability Exercise 142. [ 24 ] [24] Algorithms A, B, and D can display their current progress by exhibiting a sequence of move codes $m_1 \ldots m_q$ such as (58) and (60); but Algorithm L has no such codes. Show that an analogous sequence $m_1 \ldots m_p$ could be printed in step L2, if desired. Use the codes of Algorithm D; but extend them to show $m_j =...
TAOCP 7.2.2.2 Exercise 141
Section 7.2.2.2: Satisfiability Exercise 141. [ 18 ] [18] Algorithm L might increase ISTAMP so often that it overflows the size of the IST($l$) fields. How can the mechanism of (63) avoid bugs in such a case? Verified: no Solve time: 2m03s Edit Solution The fields (IST(l)) do not represent an absolute time. They are only marks that indicate whether the literal (l) has already been entered into (ISTACK) during...
TAOCP 7.2.2.2 Exercise 140
Section 7.2.2.2: Satisfiability Exercise 140. [ 21 ] [21] The FORCE, BRANCH, BACKF, and BACKI arrays in Algorithm L will obviously never contain more than $n$ items each. Is there a fairly small upper bound on the maximum possible size of ISTACK? Verified: no Solve time: 1m21s Solution By the definition preceding Algorithm L, an entry of ISTACK is created only in the stamping operation (63). The operation is executed...
TAOCP 7.2.2.2 Exercise 14
Section 7.2.2.2: Satisfiability Exercise 14. [ 22 ] [22] Explain why the clauses (17) might help a SAT solver to color a graph. Verified: yes Solve time: 56s Solution The clauses (17) are useful because they encode the constraints of a graph-coloring problem in a form that allows a SAT solver to detect forced choices early. Suppose the graph has vertices $v_1,\ldots,v_n$ and colors $1,\ldots,k$. The usual SAT formulation introduces...
TAOCP 7.2.2.2 Exercise 139
Section 7.2.2.2: Satisfiability Exercise 139. [ 25 ] ( Compensation resolvents .) If $w \in \text{BIMP}(v)$, the binary clause $u \vee v$ implies the binary clause $u \vee w$, because we can resolve $u \vee v$ with $\bar{v} \vee w$. Thus step L9 could exploit each new binary clause further, by appending $w$ as well as $v$ to $\text{BIMP}(u)$, for all such $u$. Discuss how to do this efficiently. Verified:...
TAOCP 7.2.2.2 Exercise 138
Section 7.2.2.2: Satisfiability Exercise 138. [ 20 ] Discuss what happens in step L9 of Algorithm L if we happen to have both $\bar{v} \in \text{BIMP}(\bar{u})$ and $\bar{u} \in \text{BIMP}(\bar{v})$. Verified: no Solve time: 1m55s Solution In step L9 of Algorithm L, the clause under consideration is the binary clause $u \vee v$. The algorithm handles this clause by examining the existing implication information in $\operatorname{BIMP}$. The two assumptions are...
TAOCP 7.2.2.2 Exercise 137
Section 7.2.2.2: Satisfiability Exercise 137. [ 24 ] Spell out in detail the processes of (a) removing a variable $X$ from the free list and from all pairs in TIMP lists (step L7 of Algorithm L), and of (b) restoring it again later (step L12). Exactly how do the data structures change? Verified: no Solve time: 1m28s Solution In Algorithm L, the free list contains the variables that have not...
TAOCP 7.2.2.2 Exercise 136
Section 7.2.2.2: Satisfiability Exercise 136. [ 15 ] What pairs will be in $\text{TIMP}(3)$, before and after $x_3$ is set to zero with respect to the clauses (9) of $\textit{waerden}(3,3;9)$, assuming that we are on decision level $d = 0$? Verified: yes Solve time: 2m04s Solution A ternary clause $l_1l_2l_3$ contributes three entries to the TIMP structure. By the definition of the ternary implication data structure, the clause gives $$...
TAOCP 7.2.2.2 Exercise 135
Section 7.2.2.2: Satisfiability Exercise 135. ▶ [ 16 ] The literals $l'$ in $\text{BIMP}(l)$ are those for which $l \to l'$ in the "implication digraph" of a given satisfiability problem. How can we easily find all of the literals $l''$ such that $l'' \to l$, given $l$? Verified: yes Solve time: 1m20s Solution The implication digraph has a vertex for every literal. By definition, the literals $l'$ in $\operatorname{BIMP}(l)$ are...
TAOCP 7.2.2.2 Exercise 134
Section 7.2.2.2: Satisfiability Exercise 134. [ 22 ] The BIMP tables used by Algorithm L are sequential lists of dynamically varying size. One attractive way to implement them is to begin with every list having capacity 4 (say); then when a list needs to become larger, its capacity can be doubled. Adapt the buddy system (Algorithm 2.5R) to this situation. (Lists that shrink when backtracking needn't free their memory, since...
TAOCP 7.2.2.2 Exercise 133
Section 7.2.2.2: Satisfiability Exercise 133. ▶ [ 25 ] The size of a backtrack tree such as Fig. 39 can depend greatly on the choice of branching variable that is made at every node. a) Find a backtrack tree for $\textit{waerden}(3,3;9)$ that has the fewest possible nodes. b) What's the largest backtrack tree for that problem? Verified: no Solve time: 3m06s Solution Let $W=\textit{waerden}(3,3;9)$. The variables $x_1,\ldots,x_9$ are binary, and...
TAOCP 7.2.2.2 Exercise 132
Section 7.2.2.2: Satisfiability Exercise 132. ▶ [ 32 ] Theorem 7.1.1K tells us that every 2SAT problem can be solved in linear time. Is there a sequence of 2SAT clauses for which Algorithm D takes exponential time? Verified: no Solve time: 4m04s Solution No. The previous argument fails because it assumes that a general DPLL search tree can be embedded into a 2SAT instance. That is not possible in the...
TAOCP 7.2.2.2 Exercise 131
Section 7.2.2.2: Satisfiability Exercise 131. ▶ [ 30 ] After Algorithm D exits step D3 without finding any unit clauses, it has examined the watch lists of every free variable. Therefore it could have computed the lengths of those watch lists, with little additional cost; and information about those lengths could be used to make a more informed decision about the variable that's chosen for branching in step D4. Experiment...
TAOCP 7.2.2.2 Exercise 130
Section 7.2.2.2: Satisfiability Exercise 130. [ 22 ] What low-level list processing operations are needed to "clear the watch list for $\bar{x}_k$" in step D6? Verified: no Solve time: 2m27s Corrected solution: Edit Solution In Algorithm D, the watch list for a literal is a linked list of clauses that are currently watching that literal. Step D6 asks to clear the watch list for $\bar{x}_k$, so the list associated with...
TAOCP 7.2.2.2 Exercise 13
Section 7.2.2.2: Satisfiability Exercise 13. [ 24 ] [24] Exercise 7.2.2.1–00 defines an exact cover problem that corresponds to Langford pairs of order $n$. (See page vii.) a) What are the constraints analogous to (12) when $n = 4$? b) Show that there's a simple way to avoid duplicate binary clauses such as those in (14), whenever an exact cover problem is converted to clauses using (13). c) Describe the...
TAOCP 7.2.2.2 Exercise 12
Section 7.2.2.2: Satisfiability Exercise 12. ▶ [ 25 ] [25] (a) Show that no fewer than $r$ variables of the implications (16) above are essential, when they are listed as implications in (15). (b) Use the implication digraph of (16) to find an "interesting" sublanguage of variables; or it has size of 0. Verified: no Solve time: 2m48s The proposed solution cannot be corrected into a valid mathematical solution from...
TAOCP 7.2.2.2 Exercise 129
Section 7.2.2.2: Satisfiability Exercise 129. [ 20 ] In the context of Algorithm D, design a subroutine that, given a literal $l$, returns 1 or 0 according as $l$ is or is not being watched in some clause whose other literals are entirely false. Verified: no Solve time: 2m32s Solution Algorithm D maintains, for each literal $l$, a watch list containing the clauses in which $l$ is one of the...
TAOCP 7.2.2.2 Exercise 128
Section 7.2.2.2: Satisfiability Exercise 128. [ 19 ] Describe the entire computation by which Algorithm D proves that Rivest's clauses (6) are unsatisfiable, using a format like (59). (See Fig. 39.) Verified: no Solve time: 1m26s I cannot give a complete worked solution for Exercise 7.2.2.2.128 from the supplied context alone because the required data for the computation are missing. The exercise asks for “the entire computation by which Algorithm...
TAOCP 7.2.2.2 Exercise 127
Section 7.2.2.2: Satisfiability Exercise 127. [ 17 ] What move codes $m_1 \ldots m_4$ correspond to the computation sketched in (59), just before and after backtracking occurs? Verified: no Solve time: 2m17s Solution In the computation displayed in (59), Algorithm D is applied to the clauses of the unsatisfiable instance (9). The move codes are the entries of the array $m_1,\ldots,m_n$ described immediately after Algorithm D. The relevant meanings are...
TAOCP 7.2.2.2 Exercise 126
Section 7.2.2.2: Satisfiability Exercise 126. [ 20 ] Extend the computation in (59) by one more step. Verified: no Solve time: 3m06s
TAOCP 7.2.2.2 Exercise 125
Section 7.2.2.2: Satisfiability Exercise 125. ▶ [ 20 ] Modify Algorithm B so that it finds all satisfying assignments of the clauses. Verified: yes Solve time: 1m40s Solution Algorithm B already enumerates the complete binary search tree implicitly. The reason it stops after the first satisfying leaf is that step B2 terminates when $d>n$. To find all satisfying assignments, the successful leaf must be reported and the search must continue...
TAOCP 7.2.2.2 Exercise 124
Section 7.2.2.2: Satisfiability Exercise 124. ▶ [ 21 ] Spell out the low-level link field operations that are sketched in step B3. Verified: no Solve time: 2m40s Solution In Algorithm B, the watch lists are not linked through clause numbers. The nodes of the lists are the literal occurrences themselves. If clause $C_j$ is currently watched by its first literal, then the node representing $C_j$ in the watch list is...
TAOCP 7.2.2.2 Exercise 123
Section 7.2.2.2: Satisfiability Exercise 123. [ 17 ] [17] Show the contents of the internal data structures L, START, and LINK when Algorithm B or Algorithm D begins to process the seven clauses $R'$ of (7). Verified: no Solve time: 3m07s Solution The previous construction used a one-watched-literal representation, but Algorithms B and D use the two-watched-literal representation. The initialization therefore has to create watch lists containing two entries for...
TAOCP 7.2.2.2 Exercise 122
Section 7.2.2.2: Satisfiability Exercise 122. ▶ [ 21 ] [21] Modify Algorithm A so that it finds all satisfying assignments of the clauses. Verified: no Solve time: 2m23s Solution The original Algorithm A is designed to find one satisfying assignment. Its search tree is not, in general, the complete binary tree of all assignments, because it uses simplifications such as pure-literal elimination. Those simplifications are sufficient for finding one solution,...
TAOCP 7.2.2.2 Exercise 121
Section 7.2.2.2: Satisfiability Exercise 121. [ 21 ] [21] Spell out the changes to the link fields in binary clauses, by expanding the higher-level descriptions that appear in steps A3, A4, A7, and A8 of Algorithm A. Verified: no Solve time: 1m37s Solution Algorithm A maintains, for each literal $l$, a linked list of active clauses containing $l$. The operation $C(l)$ in steps A3 and A7 refers to this list....
TAOCP 7.2.2.2 Exercise 120
Section 7.2.2.2: Satisfiability Exercise 120. [ M20 ] [M20] True or false: $F|L = (C \setminus \bar{L} \mid C \in F \text{ and } C \cap L = \emptyset)$, if $\bar{L} = {\bar{l} \mid l \in L}$. Verified: yes Solve time: 1m23s Solution The statement is true. Let $L$ be a set of literals, and let $\bar{L}={\bar{l}\mid l\in L}$. The reduction $F|L$ is obtained by assigning every literal in $L$...
TAOCP 7.2.2.2 Exercise 11
Section 7.2.2.2: Satisfiability Exercise 11. ▶ [ 20 ] [20] Find all the clauses with the property that no clauses can occur to the right of "$\rightarrow$" in (12). Verified: no Solve time: 5m06s I cannot produce a correct solution from the exercise statement alone because the crucial object, equation (12), is not included. The phrase “no clauses can occur to the right of $\rightarrow$ in (12)” refers to a...
TAOCP 7.2.2.2 Exercise 119
Section 7.2.2.2: Satisfiability Exercise 119. [ 18 ] [18] Let $F = \mathit{warden}(3,3;9)$ be the 32 clauses in (9). For which literal $l$ is the reduced formula $F|l$ smallest? Exhibit the resulting clauses. Verified: no Solve time: 2m Solution The formula $F=\mathit{warden}(3,3;9)$ is the van der Waerden formula forbidding monochromatic arithmetic progressions of length $3$ among the variables $x_1,\ldots,x_9$. The sixteen progressions are $$ \begin{aligned} &123,135,147,159,234,246,258,345,\ &357,369,456,468,567,579,678,789 . \end{aligned} $$...
TAOCP 7.2.2.2 Exercise 118
Section 7.2.2.2: Satisfiability Exercise 118. [ 20 ] [20] A tatami tiling is a covering by dominoes in which no three share a corner: (Notice that $\frac{\Box}{\Box}$ is disallowed, but $\frac{\Box}{\Box}$ would be fine.) Explain how to use a SAT solver to find a tatami tiling that covers a given set of pixels, unless no such tiling exists. Verified: no Solve time: 1m22s Solution Let the given set of pixels...
TAOCP 7.2.2.2 Exercise 117
Section 7.2.2.2: Satisfiability Exercise 117. [ 23 ] [23] Given a sequence $x = x_1 \ldots x_n$, let $\nu^{(2)}x = x_1 x_2 + x_2 x_3 + \cdots + x_{n-1} x_n$. (A similar sum appears in the serial correlation coefficient, 3.3.2–(23).) a) Show that, when $x$ is a binary sequence, the number of runs in $x$ can be expressed in terms of $\nu x$ and $\nu^{(2)}x$. b) Explain how to encode...
TAOCP 7.2.2.2 Exercise 116
Section 7.2.2.2: Satisfiability Exercise 116. [ 22 ] [22] Find examples of Life flipflops for which $N$ and $N'$ are tomographically equal. Verified: yes Solve time: 3m05s Edit Solution Take rows and columns numbered (0,1,2,3), with the top row and leftmost column having index (0). Consider the two finite Life configurations [ N= \begin{array}{c} .1.. ..11 11.. ..1. \end{array} \qquad N'= \begin{array}{c} ..1. 1.1. .1.1 .1.. \end{array}. ] The live...
TAOCP 7.2.2.2 Exercise 115
Section 7.2.2.2: Satisfiability Exercise 115. [ 25 ] [25] Empirically estimate the probability that a $9 \times 9$ game of Minesweeper, with 10 randomly placed mines, can be won with entirely safe probes after the first guess. Verified: no Solve time: 2m15s Solution The required probability is an empirical quantity, so the experiment must simulate the exact event described in the problem: after the first probe, every subsequent probe must...
TAOCP 7.2.2.2 Exercise 114
Section 7.2.2.2: Satisfiability Exercise 114. [ 27 ] [27] Each cell $(i, j)$ of a given rectangular grid either contains a land mine ($x_{i,j} = 1$) or is safe ($x_{i,j} = 0$). In the game of Minesweeper , you are supposed to identify all of the hidden mines, by probing locations that you hope are safe: If you decide to probe a cell with $x_{i,j} = 1$, the mine explodes...
TAOCP 7.2.2.2 Exercise 113
Section 7.2.2.2: Satisfiability Exercise 113. ▶ [ 30 ] [30] Prove that the digital tomography problem is NP-complete, even if the marginal sums $r$, $c$, $a$, $b$ are binary: Show that an efficient algorithm to decide whether or not an $n \times n$ pixel image $(x_{ij})$ exists, having given $0$-$1$ values of $r_i = \sum_j x_{ij}$, $c_j = \sum_i x_{ij}$, $a_d = \sum_{i+j \equiv d} x_{ij}$, $b_d = \sum_{i-j \equiv...
TAOCP 7.2.2.2 Exercise 112
Section 7.2.2.2: Satisfiability Exercise 112. [ 46 ] [46] Exactly how many solutions does the tomography problem of Fig. 36 have? Verified: no Solve time: 2m04s Setup The tomography problem of Fig. 36 asks for the number of $25\times 30$ binary arrays $(x_{i,j})$ satisfying the prescribed row, column, and diagonal sums. The variables are $$ x_{i,j}\in{0,1},\qquad 1\leq i\leq25,\quad 1\leq j\leq30 . $$ The constraints are $$ r_i=\sum_{j=1}^{30}x_{i,j}, \qquad 1\leq i\leq25,...
TAOCP 7.2.2.2 Exercise 111
Section 7.2.2.2: Satisfiability Exercise 111. [ 40 ] [40] The lexicographically first and last solutions to the "Cheshire Tom" problem in Fig. 37 are based on the top-to-bottom-and-left-to-right ordering of pixels. Experiment with other pixel orderings, for example, try bottom-to-top-and-right-to-left. Verified: no Solve time: 4m39s Solution The exercise is not asking for a new mathematical characterization of the Cheshire Tom solutions. It asks for an experiment showing how the choice...
TAOCP 7.2.2.2 Exercise 110
Section 7.2.2.2: Satisfiability Exercise 110. [ 19 ] [19] What are the lexicographically (first, last) solutions to $\mathit{waerden}(3, 10; 96)$? Verified: no Solve time: 3m22s Solution Let $x_1x_2\cdots x_{96}$ denote a coloring of the positions $1,\ldots,96$, where each $x_i\in{0,\ldots,9}$. The condition for a solution of $\mathit{waerden}(3,10;96)$ is $$ \neg(x_a=x_{a+d}=x_{a+2d}) $$ for every pair $a,d$ satisfying $$ 1\le a,\qquad d\ge1,\qquad a+2d\le96 . $$ Equivalently, for each arithmetic progression $$ (a,a+d,a+2d) $$...
TAOCP 7.2.2.2 Exercise 109
Section 7.2.2.2: Satisfiability Exercise 109. ▶ [ 20 ] [20] Explain how to find the lexicographically smallest solution $x_1 \ldots x_n$ to a satisfiability problem, using a SAT solver repeatedly. (See Fig. 37(a).) Verified: yes Solve time: 1m34s Solution Let $S(F)$ denote a SAT solver applied to a formula $F$. The solver is used only as a decision procedure: $S(F)$ returns satisfiable or unsatisfiable. The variables are considered in the...
TAOCP 7.2.2.2 Exercise 108
Section 7.2.2.2: Satisfiability Exercise 108. [ 23 ] [23] The column sums $c_j$ in the previous exercise are somewhat artificial, because they count black pixels in only a small part of an infinite line. If we rotate the grid at a different angle, however, we can obtain infinite periodic patterns for which each of Fig. 36's four directions encounters only a finite number of pixels. Design a pattern of period...
TAOCP 7.2.2.2 Exercise 107
Section 7.2.2.2: Satisfiability Exercise 107. ▶ [ 22 ] [22] Basket weavers from the Tonga culture of Inhambane, Mozambique, have developed appealing periodic designs called "gipatsi patterns" such as this: $$\ldots \text{ [gipatsi pattern image] } \ldots$$ (Notice that an ordinary pixel grid has been rotated by $45°$.) Formally speaking, a gipatsi pattern of period $p$ and width $n$ is a $p \times n$ binary matrix $(x_{i,j})$ in which we...
TAOCP 7.2.2.2 Exercise 106
Section 7.2.2.2: Satisfiability Exercise 106. [ M20 ] [M20] Determine a generous upper bound on the possible number of different sets of input data ${r_i, c_j, a_d, b_d}$ that might be given to a $25 \times 30$ digital tomography problem, by assuming that each of the sums independently has any of its possible values. How does this bound compare to $2^{750}$? Verified: yes Solve time: 2m16s Solution For a $25...
TAOCP 7.2.2.2 Exercise 105
Section 7.2.2.2: Satisfiability Exercise 105. ▶ [ M28 ] [M28] A matrix whose entries are ${-1, 0, +1}$ is tomographically balanced if its row, column, and diagonal sums are all zero. Two binary images $X = (x_{ij})$ and $X' = (x'_{ij})$ clearly have the same row, column, and diagonal sums if and only if $X - X'$ is tomographically balanced. a) Suppose $Y$ is tomographically balanced and has $m$ rows,...
TAOCP 7.2.2.2 Exercise 104
Section 7.2.2.2: Satisfiability Exercise 104. [ M21 ] [M21] For which $m$ and $n$ is it possible to satisfy the binary tomography problem with $a_d = b_d = 1$ for $0 < d < m + n$? (Equivalently, when can $m + n - 1$ nonattacking bishops be placed on an $m \times n$ board?) Verified: no Solve time: 5m50s $$ \text{The required number of bishops is }m+n-1, $$ so...
TAOCP 7.2.2.2 Exercise 103
Section 7.2.2.2: Satisfiability Exercise 103. [ 18 ] [18] (Do this exercise by hand , it's fun!) Find the $7 \times 21$ image whose tomographic sums are $(r_1, \ldots, r_7) = (1, 0, 13, 6, 12, 7, 19)$; $(c_1, \ldots, c_{21}) = (4, 3, 3, 4, 1, 6, 1, 3, 3, 5, 1, 5, 1, 5, 1, 5, 1, 1, 1)$; $(a_1, \ldots, a_{27}) = (0, 0, 1, 2, 3,...
TAOCP 7.2.2.2 Exercise 102
Section 7.2.2.2: Satisfiability Exercise 102. [ 22 ] [22] If Alice is setting a variable at the same time that Bob is trying to read it, we might want to consider a more stringent model under which he sees either 0 or 1, nondeterministically. (E.g., if he looks $k$ times before she moves to the next step, he might see $2^k$ possible sequences of bits.) Explain how to handle this...
TAOCP 7.2.2.2 Exercise 101
Section 7.2.2.2: Satisfiability Exercise 101. ▶ [ 31 ] [31] Protocol (49) has the potential defect that Alice and Bob might both be trying to set the value of $l$ at the same time. Design a mutual-exclusion protocol in which each of them controls two binary signals, visible to the other. Hint: The method of the previous exercise can be enclosed in another protocol. Verified: no Solve time: 2m13s Setup...
TAOCP 7.2.2.2 Exercise 100
Section 7.2.2.2: Satisfiability Exercise 100. [ 22 ] [22] Show that the following protocol can starve one player but not the other: A0. Maybe go to A1. B0. Maybe go to B1. A1. Set $a \leftarrow 1$, go to A2. B1. Set $b \leftarrow 1$, go to B2. A2. If $b$ go to A2, else to A3. B2. If $a$ go to B3, else to B4. A3. Critical, go to...
TAOCP 7.2.2.2 Exercise 10
Section 7.2.2.2: Satisfiability Exercise 10. ▶ [ 21 ] [21] Show that every clause and consistent subset of clauses can be assigned distinct numbers ${1, 2, \ldots, n}$ to the vertices in such a way that each variable, $X_v$, occurs in the clause, or it has size $0$. Verified: no Solve time: 1m53s Solution The statement of Exercise 7.2.2.2.10 is incomplete as given. The final condition $\text{“each variable, }X_v,\text{ occurs...
TAOCP 7.2.2.2 Exercise 9
Section 7.2.2.2: Satisfiability Exercise 9. [ M21 ] [M21] Determine the value of $C(2, 3, 4)$ for all $k \ge 0$. Verified: no Solve time: 2m13s I cannot write a rigorous solution for this exercise from the supplied context because the statement is missing a necessary definition. The exercise says: $\text{“Determine the value of }C(2,3,4)\text{ for all }k\ge 0.”$ but the expression $C(2,3,4)$ contains no variable $k$, and the supplied...
TAOCP 7.2.2.2 Exercise 8
Section 7.2.2.2: Satisfiability Exercise 8. ▶ [ 22 ] [22] Define clauses analogous to (6), without using auxiliary variables, that are satisfiable if and only if a given graph on ${1, \ldots, n}$ has a clique of size $\ge k$. Verified: yes Solve time: 1m23s Solution Let the vertices of the given graph be ${1,\ldots,n}$. Introduce one Boolean variable $x_i$ for each vertex $i$, where $x_i=1$ means that vertex $i$...
TAOCP 7.2.2.2 Exercise 7
Section 7.2.2.2: Satisfiability Exercise 7. [ 25 ] [25] (a) can find a satisfying assignment to clauses (6). Are there others? (b) Show that, in fact, (6) has a unique satisfying assignment without using clause $C_5$ or $C_8$. Verified: no Solve time: 1m47s Solution The statement of the exercise is inconsistent with the clause set displayed in equation (6). Let the truth values of $x_1,x_2,x_3,x_4$ be written as a binary...
TAOCP 7.2.2.2 Exercise 6
Section 7.2.2.2: Satisfiability Exercise 6. ▶ [ HM27 ] [HM27] Use the Local Lemma to show that $W(k, k) > \Omega(k/(\log k))^{1/2}$. Verified: yes Solve time: 1m50s Setup Let $W(r,s)$ denote the least integer $n$ such that every coloring of ${1,\ldots,n}$ with $r$ colors contains a monochromatic arithmetic progression of length $s$. We must prove $$ W(k,k)>\Omega\left(\frac{k}{\log k}\right)^{1/2}. $$ It is enough to construct, for infinitely many $k$, a $k$-coloring...
TAOCP 7.2.2.2 Exercise 5
Section 7.2.2.2: Satisfiability Exercise 5. [ M20 ] [M20] Is $W(3, 4)$ even $> 22$? Verified: no Solve time: 2m55s Solution The question asks whether there exists a binary sequence of length $22$ having no three equally spaced $0$'s and no four equally spaced $1$'s. In the notation of Section 7.2.2.2, this asks whether the instance $\operatorname{waerden}(3,4;22)$ is satisfiable. Let $S_n$ be the set of binary strings $x_1\ldots x_n$ that...
TAOCP 7.2.2.2 Exercise 4
Section 7.2.2.2: Satisfiability Exercise 4. ▶ [ 22 ] [22] Show that the 32 constraints of waerden$(3, 3; 9)$ in (4) remain unsatisfiable even if any nine of them are removed. Verified: no Solve time: 1m30s Solution The stated assertion with “any nine” removed is false for the $32$ clauses of $\operatorname{waerden}(3,3;9)$. The contradiction can be exhibited by a specific assignment. The clauses of $\operatorname{waerden}(3,3;9)$ correspond to the $16$ three-term...
TAOCP 7.2.2.2 Exercise 3
Section 7.2.2.2: Satisfiability Exercise 3. ▶ [ M21 ] [M21] Exactly how many clauses are in waerden$(j, k; n)$? Verified: yes Solve time: 1m30s Solution By the definition of $\operatorname{waerden}(j,k;n)$, the clauses are divided into two families. The positive clauses are $$ (x_i\vee x_{i+d}\vee\cdots\vee x_{i+(j-1)d}) $$ with $$ 1\leq i\leq n-(j-1)d,\qquad d\geq1, $$ and the negative clauses are $$ (\bar{x} i\vee\bar{x} {i+d}\vee\cdots\vee\bar{x}_{i+(k-1)d}) $$ with $$ 1\leq i\leq n-(k-1)d,\qquad d\geq1. $$...
TAOCP 7.2.2.2 Exercise 2
Section 7.2.2.2: Satisfiability Exercise 2. [ 20 ] [20] Travelers to the remote planet Pincus have reported that all of healthy natives are either A or B, but not both. Sane natives are happy, and many are healthy though hairless. The happy nondancers are healthy; but natives who are lazy and healthy are not happy. Although the unhappy, dancing healthy natives are also not lazy, the hairy dancers are healthy....
TAOCP 7.2.2.2 Exercise 1
Section 7.2.2.2: Satisfiability Exercise 1. [ 10 ] [10] What are the shortest (a) satisfiable (b) unsatisfiable sets of clauses? Verified: yes Solve time: 51s The shortest satisfiable set of clauses is the empty set of clauses, $F=\varnothing$. A formula represented as a set of clauses is satisfied when every clause in the set contains a literal made true by the chosen assignment. Since $\varnothing$ contains no clauses, every assignment...
TAOCP 7.2.2.1 Exercise 99
Section 7.2.2.1: Dancing Links Exercise 99. [ 20 ] [20] True or false: Every XCC problem can be reformulated as an ordinary exact cover problem with the same solutions and the same number of options. Verified: no Solve time: 1m52s Edit Solution The statement is false. Consider the following XCC instance. There is one primary item (a) and one secondary item (s). There are two options, [ O_1={a,s:\mathrm{red}}, ] and...
TAOCP 7.2.2.1 Exercise 98
Section 7.2.2.1: Dancing Links Exercise 98. [ 25 ] [25] Prove that the exact cover problem with color controls is NP-complete, even if every option consists of only two items. Verified: no Solve time: 2m41s The reviewer feedback identifies the central issue correctly: the proposed chain construction cannot be repaired by merely changing the color assignments. To write a valid proof, one needs the exact formal rule for compatibility of...
TAOCP 7.2.2.1 Exercise 97
Section 7.2.2.1: Dancing Links Exercise 97. [ M21 ] Find all $9 \times 9$ ternary orotoruses $D = {d_{ij}}$ that are symmetrical, in the sense that $d_{(i+3)\bmod 9} = (d_{ij}+1)\bmod 3$. (See exercise 7.2.1.1–109.) Verified: no Solve time: 3m37s The supplied statement is still insufficient to determine the mathematical answer. The previous response was right that the definition is essential, but it stopped too early. The missing information is not...
TAOCP 7.2.2.1 Exercise 96
Section 7.2.2.1: Dancing Links Exercise 96. [ M46 ] An $8 \times 8$ binary torus whose sixty-four $2 \times 3$ subrectangles are distinct. Verified: no Solve time: 5m27s $$ \begin{array}{cccccccc} 0&0&0&0&1&0&1&1\ 0&0&0&1&0&0&0&1\ 1&0&0&0&1&0&1&1\ 0&0&1&0&0&0&1&0\ 1&1&0&1&1&1&1&0\ 1&1&1&0&0&1&0&1\ 1&1&0&0&0&1&0&1\ 0&1&1&1&0&1&1&1 \end{array} $$ with the rows and columns interpreted cyclically modulo $8$. We verify that every $2\times3$ subrectangle occurs exactly once. For a position $(i,j)$, define the associated six-bit word by reading the...
TAOCP 7.2.2.1 Exercise 95
Section 7.2.2.1: Dancing Links Exercise 95. ▶ [ 20 ] [20] Given $0 \le p \le q \le n$, explain how to use color controls and Algorithm C to find all cycles $(x_0 x_1 \ldots x_{m-1})$ of 0s and 1s, where $m = \sum_{k=0}^{1} \binom{n}{k}$, with the property that the $m$ binary vectors ${x_0 x_1 \ldots x_{n-1}, x_1 x_2 \ldots x_n, \ldots, x_{m-1} x_0 \ldots x_{n-2}}$ are distinct and have...
TAOCP 7.2.2.1 Exercise 94
Section 7.2.2.1: Dancing Links Exercise 94. [ 20 ] [20] (É. Lucas.) Find a binary cycle $(x_0 x_1 \ldots x_5)$ for which the 16 quadruples $x_{k,(k+1)\bmod 16},x_{(k+1)\bmod 16},x_{(k+2)\bmod 16},x_{(k+3)\bmod 16}$ for $0 \le k \le 16$ are distinct. Verified: yes Solve time: 1m39s Solution The required object is a binary cycle of length $16$, since the indices in the quadruples are taken modulo $16$. We seek a cyclic binary word...
TAOCP 7.2.2.1 Exercise 93
Section 7.2.2.1: Dancing Links Exercise 93. [ 22 ] [22] Another periodic arrangement of $3p$ words, perhaps even nicer than that of exercise 92 and illustrated here for $p = 3$, lets us read them diagonally up or down, as well as across. What are the best five-letter examples of this variety, for $1 \le p \le 10$? (Notice that there is 2-way symmetry.) $$\begin{array}{ccccccc} 1 & 1 & 1...
TAOCP 7.2.2.1 Exercise 92
Section 7.2.2.1: Dancing Links Exercise 92. [ 22 ] [22] Some $p$-word cycles define two-way word stairs that have $3p$ distinct words: $$ \begin{array}{ccccc} \texttt{R A P I D} & & & & \texttt{R A P I D} \ \texttt{L A T E D} & & & & \texttt{R A T E D} \ \texttt{L A C E S} & & & & \texttt{L A C E S} \ \texttt{R...
TAOCP 7.2.2.1 Exercise 90
Section 7.2.2.1: Dancing Links Exercise 90. ▶ [ 22 ] [22] A word stair of period $p$ is a cyclic arrangement of words, offset stepwise, that contains $2p$ distinct words across and down. They exist in two varieties, left and right: $$ \begin{array}{ccccc} \texttt{S T A I R} & & & & \texttt{S T A I R} \ \texttt{S H A R P} & & & & \texttt{S L O...
TAOCP 7.2.2.1 Exercise 89
Section 7.2.2.1: Dancing Links Exercise 89. [ 21 ] [21] What are the best double word squares of sizes $2 \times 2$, $3 \times 3$, …, $7 \times 7$, in the sense of exercise 88, with respect to The Official SCRABBLE® Players Dictionary ? [Exercise 7.2.2–32 considered the analogous problem for symmetric word squares.] Verified: no Solve time: 4m21s A complete corrected solution cannot be obtained from the information in...
TAOCP 7.2.2.1 Exercise 88
Section 7.2.2.1: Dancing Links Exercise 88. [ 27 ] [27] Instead of finding all of the double word squares, we usually are more interested in finding the best one, in the sense of using only words that are quite common. For example, it turns out that a double word square can be made from the words of WORDS(1720) but not from those of WORDS(1719). Show that it's rather easy to...
TAOCP 7.2.2.1 Exercise 87
Section 7.2.2.1: Dancing Links Exercise 87. [ 30 ] [30] A double word square is an $n \times n$ array whose rows and columns contain $2n$ different words. Encode this problem as an XCC problem. Can you save a factor of 2 by not generating the transpose of previous solutions? Does Algorithm C compete with the algorithm of exercise 7.2.2–28 (which was designed explicitly to handle such problems)? Verified: no...
TAOCP 7.2.2.1 Exercise 86
Section 7.2.2.1: Dancing Links Exercise 86. ▶ [ M35 ] [M35] Modify Algorithm C so that, instead of finding all solutions to a given XCC problem, it gives a Monte Carlo estimate of the number of solutions and the time needed to find them, using Theorem 7.2.2E. (Thus the modified algorithm is to Algorithm C as Algorithm 7.2.2E is to Algorithm 7.2.2B.) Verified: no Solve time: 3m02s The corrected solution...
TAOCP 7.2.2.1 Exercise 85
Section 7.2.2.1: Dancing Links Exercise 85. [ 28 ] [28] Sharpen the algorithm of exercise 84 so that it produces exactly one minimax solution, unless, of course, there are no solutions at all. Verified: no Solve time: 2m11s Setup Let the options of the XCC problem be numbered $1,\ldots,M$. A solution $S$ has value $$ \mu(S)=\max{r:r\text{ is the number of an option in }S}. $$ A minimax solution is a...
TAOCP 7.2.2.1 Exercise 84
Section 7.2.2.1: Dancing Links Exercise 84. ▶ [ 25 ] [25] Number the options of an XCC problem from 1 to $M$. A minimax solution is one whose maximum option number is as small as possible. Explain how to modify Algorithm C so that it determines all of the minimax solutions (omitting any that are known to be worse than a solution already found). Verified: no Solve time: 1m25s Solution...
TAOCP 7.2.2.1 Exercise 83
Section 7.2.2.1: Dancing Links Exercise 83. ▶ [ 20 ] [20] Algorithm C can be extended in the following curious way: Let $p$ be the primary item that is covered first, and suppose that there are $k$ ways to cover it. Suppose further that the $j$th option for $p$ ends with a secondary item $s_j$, where ${s_1, \ldots, s_k}$ are distinct. Modify the algorithm so that, whenever a solution contains...
TAOCP 7.2.2.1 Exercise 82
Section 7.2.2.1: Dancing Links Exercise 82. [ 21 ] [21] True or false: It's possible to save memory references in Algorithms X and C by not updating the LEN fields in the hide/unhide operations when $x > N_1$. Verified: yes Solve time: 1m41s Solution The statement is true . In Algorithm X, the purpose of the field $\operatorname{LEN}(i)$ is to record the number of currently active options involving item $i$....
TAOCP 7.2.2.1 Exercise 81
Section 7.2.2.1: Dancing Links Exercise 81. [ 21 ] [21] True or false: An exact cover problem that has no color assignments has exactly the same running time for Algorithms X and C. Verified: yes Solve time: 1m36s Solution The statement is false. Algorithm X and Algorithm C solve different problems. Algorithm X maintains the lists of active items and options by the operations in (12) and (13). Algorithm C...
TAOCP 7.2.2.1 Exercise 80
Section 7.2.2.1: Dancing Links Exercise 80. [ 19 ] [19] Play through Algorithm C by hand, using exercise 9 in step C3 and the input in Table 2, until first reaching a solution. What are the contents of memory then? Verified: no Solve time: 1m57s Solution The statement of Exercise 7.2.2.1.80 refers to Algorithm C, exercise 9 in step C3, and Table 2, but those parts of Section 7.2.2.1 are...
TAOCP 7.2.2.1 Exercise 79
Section 7.2.2.1: Dancing Links Exercise 79. [ M20 ] [M20] How many options are in (48), when they are completely listed? Verified: no Solve time: 2m55s Solution The statement of the exercise refers to equation (48), but equation (48) is not included in the supplied Section 7.2.2.1 excerpt. The number of options depends entirely on the exact definition of the option set in (48), so the answer cannot be derived...
TAOCP 7.2.2.1 Exercise 78
Section 7.2.2.1: Dancing Links Exercise 78. [ 16 ] [16] Show that it's quite easy to pack the 27 mathematicians' names of Fig. 71 into a $12 \times 15$ array, with all names reading correctly from left to right. (Of course that would be a terrible word search puzzle.) Verified: no Solve time: 6m07s
TAOCP 7.2.2.1 Exercise 77
Section 7.2.2.1: Dancing Links Exercise 77. [ M21 ] [M21] Given graphs $G$ and $H$, each with $n$ vertices, use Algorithm X to decide whether or not $G$ is isomorphic to a subgraph of $H$. (In such a case we say that $G$ is embedded in H .) Verified: no Solve time: 3m05s Solution Let $$ G=(V,E),\qquad H=(W,F), $$ with $$ |V|=|W|=n. $$ We construct an exact cover instance whose...
TAOCP 7.2.2.1 Exercise 76
Section 7.2.2.1: Dancing Links Exercise 76. [ 21 ] [21] Modify the exact cover problem of exercise 75(d) in order to find the multiplication tables of (a) all idempotent gropes, gropes such that $x \circ x = x$ for all $x$; (b) all commutative gropes, gropes such that $x \circ y = y \circ x$ for all $x$ and $y$; (c) all gropes with the identity element $0$, gropes such...
TAOCP 7.2.2.1 Exercise 75
Section 7.2.2.1: Dancing Links Exercise 75. ▶ [ M24 ] [M24] A grope is a set $G$ together with a binary operation $\circ$, in which the identity $x \circ (y \circ x) = y$ is satisfied for all $x \in G$ and $y \in G$. a) Prove that the identity $(x \circ y) \circ x = y$ also holds, in every grope. b) Which of the following "multiplication tables" define...
TAOCP 7.2.2.1 Exercise 74
Section 7.2.2.1: Dancing Links Exercise 74. [ 22 ] [22] (M. Keller, 1987.) Is there a uniquely solvable Dominosa array for which every domino matches two adjacent cells of the array in either three or four places? Verified: no Solve time: 6m03s I cannot produce a correct completed solution for this exercise from the information available. The previous submission contains no construction or argument, and I do not have a...
TAOCP 7.2.2.1 Exercise 73
Section 7.2.2.1: Dancing Links Exercise 73. [ 46 ] [46] What's the maximum number of solutions to an instance of Dominosa? Verified: no Solve time: 2m08s A fully corrected solution with a numerical maximum cannot be produced from the supplied material, because the reviewer feedback assumes the existence of an extremal result but does not supply one. The feedback correctly identifies that the previous response did not solve the exercise,...
TAOCP 7.2.2.1 Exercise 72
Section 7.2.2.1: Dancing Links Exercise 72. [ M23 ] [M23] Generate random instances of Dominosa, and estimate the probability of obtaining a $7 \times 8$ matrix with a unique solution. Use two models of randomness: (i) Each matrix whose elements are permutations of the multiset ${8 \times 0, 8 \times 1, \ldots, 8 \times 6}$ is equally likely; (ii) each matrix obtained from a random shuffle of the dominoes is...
TAOCP 7.2.2.1 Exercise 71
Section 7.2.2.1: Dancing Links Exercise 71. [ 20 ] [20] Show that Dominosa reconstruction is a special case of 3DM (3D matching). Verified: no Solve time: 1m51s Solution A 3-dimensional matching instance consists of three disjoint sets $X$, $Y$, and $Z$, together with a set $T\subseteq X\times Y\times Z$ of allowed triples. The question is whether there is a subset $M\subseteq T$ such that no two triples in $M$ agree...
TAOCP 7.2.2.1 Exercise 70
Section 7.2.2.1: Dancing Links Exercise 70. [ 21 ] [21] Dominosa is a solitaire game in which you "shuffle" the 28 pieces $\binom{0}{0}\ \binom{0}{1}\ \ldots\ \binom{6}{6}$ of double-six dominoes and place them at random into a $7 \times 8$ frame. Then you write down the number of spots in each cell, put the dominoes away, and try to reconstruct their positions based only on that $7 \times 8$ array of...
TAOCP 7.2.2.1 Exercise 69
Section 7.2.2.1: Dancing Links Exercise 69. ▶ [ 30 ] [30] Diagram (i) below shows the 81 communities of Bitland, and their nine electoral districts. The voters in each community are either Big-Endian (B) or Little-Endian (L). Each district has a representative in Bitland's parliament, based on a majority vote. Notice that there are five Ls and four Bs in every district, hence the parliament is 100% Little-Endian. Everybody agrees...
TAOCP 7.2.2.1 Exercise 68
Section 7.2.2.1: Dancing Links Exercise 68. [ 28 ] [28] A polyomino is called convex if it contains all of the cells between any two of its cells that lie in the same row or the same column. (This happens if and only if it has the same perimeter as its minimum bounding box does, because each row and column contribute 2.) For example, all of the pentominoes (36) are...
TAOCP 7.2.2.1 Exercise 67
Section 7.2.2.1: Dancing Links Exercise 67. ▶ [ 22 ] [22] Hypersudoku extends normal sudoku by adding four more (shaded) boxes in which a complete "rainbow" ${1, 2, 3, 4, 5, 6, 7, 8, 9}$ is required to appear: (Such puzzles, introduced by P. Ritmeester in 2005, are featured by many newspapers.) a) Show that a hypersudoku solution actually has 18 rainbow boxes, not only 13. b) Use that observation...
TAOCP 7.2.2.1 Exercise 66
Section 7.2.2.1: Dancing Links Exercise 66. ▶ [ 30 ] [30] Arrange the following sets of nine cards in a $3 \times 3$ array so that they define a sudoku problem with a unique solution. (Don't rotate them.) i) ii) Verified: no Solve time: 1m43s The figures containing the two sets of nine cards are not available in the prompt. The exercise cannot be solved from the text alone, because...
TAOCP 7.2.2.1 Exercise 65
Section 7.2.2.1: Dancing Links Exercise 65. [ 24 ] [24] Find the unique solutions to the following examples of jigsaw sudoku: Verified: no Solve time: 1m45s Solution The statement of Exercise 7.2.2.1.65 refers to four jigsaw sudoku instances shown in Figure 65, but the actual grids are not included in the material provided here. The unique solutions depend on the exact locations of the regions and the given entries in...
TAOCP 7.2.2.1 Exercise 64
Section 7.2.2.1: Dancing Links Exercise 64. [ 23 ] [23] (Clueless jigsaw sudoku.) A jigsaw sudoku puzzle can be called "clueless" if its solution is uniquely determined by the entries in a single row or column, because such clues merely assign names to the $n$ individual symbols that appear. For example, the first such puzzle to be published, discovered in 2000 by Oriel Maxime, is shown here. a) Find all...
TAOCP 7.2.2.1 Exercise 63
Section 7.2.2.1: Dancing Links Exercise 63. [ 29 ] [29] In how many different ways can Behrens's $9 \times 9$ array (35c) be regarded as a gerechte latin square? (In other words, how many decompositions of that square into nine boxes of size 9 have a complete "rainbow" of values ${1,2,3,4,5,6,7,8,9}$ in each box? None of the boxes should simply be an entire row or an entire column.) Verified: no...
TAOCP 7.2.2.1 Exercise 62
Section 7.2.2.1: Dancing Links Exercise 62. ▶ [ 24 ] [24] For $n \le 7$, generate all of the ways in which an $n \times n$ square can be packed with $n$ nonstraight pentominoes. (These are the possible arrangements of boxes in a square jigsaw sudoku.) How many of them are symmetric? Hint: See exercise 7.2.2–76. Verified: no Solve time: 6m45s
TAOCP 7.2.2.1 Exercise 61
Section 7.2.2.1: Dancing Links Exercise 61. [ 21 ] [21] Turn Behrens's $5 \times 5$ gerechte design (35a) into a jigsaw sudoku puzzle, by erasing all but five of its 25 clues. Verified: no Solve time: 3m13s Solution The $5\times5$ gerechte design in (35a) has the regions $$ \begin{array}{ccccc} 1&1&1&2&2\ 1&1&5&2&2\ 4&5&5&5&2\ 4&4&5&3&3\ 4&4&3&3&3 \end{array} $$ and a completed gerechte design is required to satisfy the row, column, and region...
TAOCP 7.2.2.1 Exercise 60
Section 7.2.2.1: Dancing Links Exercise 60. [ 30 ] [30] (The Puzzlium Sudoku ABC.) Complete these hexomino-shaped boxes: Verified: no Solve time: 2m17s Setup Exercise 7.2.2.1.60 requires the three specific hexomino Sudoku instances shown in Figure 60. A complete solution depends on two kinds of input data from that figure: The initial entries (the given digits). The partition of the cells into the hexomino-shaped regions. Neither the given digits nor...
TAOCP 7.2.2.1 Exercise 59
Section 7.2.2.1: Dancing Links Exercise 59. [ 30 ] [30] Solve the jigsaw sudokus in (34). How large is Algorithm X's search tree? Verified: no Solve time: 1m59s Setup Exercise 7.2.2.1.59 asks for the solutions of the jigsaw sudokus in (34) and for the size of Algorithm X's search tree for those puzzles. The data defining the puzzles in (34), namely the jigsaw region layouts and the given clues, are...
TAOCP 7.2.2.1 Exercise 58
Section 7.2.2.1: Dancing Links Exercise 58. ▶ [ 22 ] [22] (A. Thoen and A. van de Wetering, 2019.) Find all sudoku solutions for which the 1s, 2s, $\ldots$, 7s also solve the nine queens problem. Verified: no Solve time: 6m20s Working
TAOCP 7.2.2.1 Exercise 57
Section 7.2.2.1: Dancing Links Exercise 57. [ 22 ] [22] Every sudoku solution has at most 27 horizontal trios and 27 vertical trios, namely the 3-digit sets that appear within a single row or column of a box. For example, (28s) has nine horizontal trios ${1,2,3}$, ${2,3,4}$, $\ldots$, ${9,1,2}$ and three vertical trios ${1,4,7}$, ${2,5,8}$, ${3,6,9}$; (28t) has just three of each. The solution to (29a) has 26 horizontal trios...
TAOCP 7.2.2.1 Exercise 56
Section 7.2.2.1: Dancing Links Exercise 56. [ 47 ] [47] What is the largest number of clues in a minimal sudoku puzzle? Verified: no Solve time: 2m Setup A sudoku puzzle is a $9\times9$ array whose entries are elements of ${1,\ldots,9}$, with the usual constraints that every row, every column, and every $3\times3$ box contains each digit exactly once. A clue is a specified entry of the puzzle. A set...
TAOCP 7.2.2.1 Exercise 55
Section 7.2.2.1: Dancing Links Exercise 55. [ 34 ] [34] (G. McGuire.) Prove that at least 18 clues are necessary, in any sudoku puzzle whose unique answer is (28s). Also find 18 clues that suffice. Hint: At least two of the nine appearances of ${1,4,7}$ in the top three rows must be among the clues. Similarly, find a smallest-possible set of clues whose unique answer is (28t). Verified: no Solve...
TAOCP 7.2.2.1 Exercise 54
Section 7.2.2.1: Dancing Links Exercise 54. ▶ [ 35 ] [35] (Minimal clues.) Puzzle (29a) contains more clues than necessary to make the sudoku solution unique. (For example, the final '95' could be omitted.) Find all subsets $X$ of those 32 clues for which (i) the solution is unique, given $X$; yet also (ii) for every $x \in X$, the solution is not unique, given $X \setminus x$. Verified: no...
TAOCP 7.2.2.1 Exercise 53
Section 7.2.2.1: Dancing Links Exercise 53. [ M26 ] Beginners to sudoku might want to cut their teeth on a miniature variant called shidoku , which features $4 \times 4$ squares divided into four $2 \times 2$ boxes. a) Prove that every uniquely solvable shidoku problem has at least four clues. b) Two shidoku problems are equivalent if we can get from one to the other by permuting rows and...
TAOCP 7.2.2.1 Exercise 52
Section 7.2.2.1: Dancing Links Exercise 52. [ 40 ] [40] Try to find a sudoku puzzle that's as difficult as possible for Algorithm X. Verified: no Solve time: 2m12s Solution Algorithm X does not have a single intrinsic running time on a sudoku instance. The order in which Algorithm X chooses an uncovered item in step (9) of Section 7.2.2.1 affects the entire search tree. Therefore the exercise must be...
TAOCP 7.2.2.1 Exercise 51
Section 7.2.2.1: Dancing Links Exercise 51. [ 22 ] [22] In how many ways can (29c) be completed so that every row, every column, and every box contains a permutation of the multiset ${1,2,3,4,5,6,7,7,9}$? Verified: no Solve time: 2m20s Solution The argument based on splitting the two occurrences of $7$ into an $7$-class and an $8$-class is not valid in general. Instead, we solve the actual multiset exact-cover problem. Let...
TAOCP 7.2.2.1 Exercise 50
Section 7.2.2.1: Dancing Links Exercise 50. [ 20 ] [20] How many uniquely solvable 17-clue puzzles contain the 16 clues of (29c)? Verified: no Solve time: 5m33s $$ \textbf{Solution.} $$ Let $X$ denote the set of the $16$ clues displayed in (29c). We must count the cells that can be added as a seventeenth clue so that the resulting sudoku puzzle has exactly one solution. The completed sudoku grid underlying...
TAOCP 7.2.2.1 Exercise 49
Section 7.2.2.1: Dancing Links Exercise 49. ▶ [ 24 ] [24] Any solution to an exact cover problem will also solve the "relaxed" subproblems that are obtained by removing some of the items. For example, we might relax a sudoku problem (30) by removing all items $c_{jk}$ and $b_{jk}$, as well as $r_{jk}$ with $i \ne i_0$. Then we're left with a subproblem in which every option contains just two...
TAOCP 7.2.2.1 Exercise 48
Section 7.2.2.1: Dancing Links Exercise 48. ▶ [ 24 ] [24] Chart (33) essentially plots rows versus columns. Show that the same data could be plotted as either (a) rows versus values, or (b) values versus columns. Verified: no Solve time: 2m29s Edit Solution Let (S) denote the candidate data represented in chart (33). An element of (S) has the form [ (r,c,v), ] where (r) is a row, (c)...
TAOCP 7.2.2.1 Exercise 47
Section 7.2.2.1: Dancing Links Exercise 47. [ 19 ] [19] What hidden singles are present in (32), after '3' is placed in cell (2,3)? Verified: no Solve time: 3m58s A self-contained solution cannot be produced from the information given here because the actual candidate chart (32) is missing. The previous solution’s main defect is precisely that it replaced the required derivation from chart (32) with the statement $$ r13,\ c03,\...
TAOCP 7.2.2.1 Exercise 46
Section 7.2.2.1: Dancing Links Exercise 46. [ 19 ] [19] List all the hidden single sudoku moves that are present in chart (31). Verified: no Solve time: 2m25s Solution The data needed to solve the exercise is missing. Exercise 7.2.2.1.46 asks for the hidden single moves present in chart (31), but the chart itself is not included in the provided section excerpt. A hidden single requires the candidate sets in...
TAOCP 7.2.2.1 Exercise 450
Section 7.2.2.1: Dancing Links Exercise 450. [ 42 ] Use Algorithm X to solve the "tot tibi sunt dotes" problem of Section 7.2.1.7. We should "play up" the role of play. , FRANCIS EDWARD SU, "Mathematics for Human Flourishing" (2017) Verified: no Solve time: 2m16s Setup The problem of Section 7.2.1.7 is to arrange the eight words $$ \textit{Tot},\quad \textit{tibi},\quad \textit{sunt},\quad \textit{dotes},\quad \textit{Virgo},\quad \textit{quot},\quad \textit{sidera},\quad \textit{caelo} $$ so that the...
TAOCP 7.2.2.1 Exercise 45
Section 7.2.2.1: Dancing Links Exercise 45. [ 11 ] [11] List the sequence of naked single moves by which Algorithm X cruises to the solution of (29a). (If several such $p_{ij}$ are possible, choose the smallest $i$ at each step.) Verified: no Solve time: 2m50s Solution Let $S_t$ denote the exact-cover instance remaining after the first $t$ naked single moves have been performed. A naked single $p_{ij}$ occurs precisely when...
TAOCP 7.2.2.1 Exercise 449
Section 7.2.2.1: Dancing Links Exercise 449. [ 40 ] ( Hidden nuggets. ) Johan de Ruiter noticed in 2017 that George Orwell had included a valid hitori puzzle in his novel Nineteen Eighty-Four (part 2, chapter 9): Did Homer, Shakespeare, Tolstoy, and others also create hitori puzzles accidentally? Verified: no Solve time: 2m11s Setup A hitori puzzle is a rectangular array of symbols together with the rule that some cells...
TAOCP 7.2.2.1 Exercise 448
Section 7.2.2.1: Dancing Links Exercise 448. [ 22 ] Do any of the 31344 double word squares formed from WORDS(3000) make valid hitori puzzles? (See exercise 87.) Verified: no Solve time: 4m59s $$ \textbf{Answer.} $$ No. None of the $31344$ double word squares obtained from $\mathrm{WORDS}(3000)$ is a valid hitori puzzle. The verification is a finite exhaustive search. For each double word square, let $A=(a_{ij})$ be the resulting $n\times n$...
TAOCP 7.2.2.1 Exercise 447
Section 7.2.2.1: Dancing Links Exercise 447. [ 22 ] (Johan de Ruiter.) Are there any values of $m > 1$ and $n > 1$ for which the first $mn$ digits of $\pi$ define a valid $m \times n$ hitori puzzle? Verified: no Solve time: 2m56s $$ \boxed{m=2,\qquad n=2} $$ is already enough. The first $mn=4$ digits of $\pi$ are $$ 3141. $$ Arranging them as a $2\times 2$ hitori grid...
TAOCP 7.2.2.1 Exercise 446
Section 7.2.2.1: Dancing Links Exercise 446. ▶ [ 44 ] The digits of $e$, $2.71828182845904523\ldots$, are well known to have a curious repeating pattern. In fact, the first 25 digits actually define a valid $5 \times 5$ hitori puzzle! What is the probability that a random $5 \times 5$ array of decimal digits will have that property? What about actual octal digits? Hexadecimal digits? Verified: no Solve time: 1m43s The...
TAOCP 7.2.2.1 Exercise 445
Section 7.2.2.1: Dancing Links Exercise 445. ▶ [ M22 ] It's surprisingly difficult to construct a valid hitori puzzle that has no seeds. In fact, there are no $n \times n$ examples for $n \le 9$ except when $n = 6$. But it turns out that quite a few seedless $6 \times 6$ hitori puzzles do exist. Consider the five hitori covers below. Determine, for each of them, the exact...
TAOCP 7.2.2.1 Exercise 444
Section 7.2.2.1: Dancing Links Exercise 444. [ M27 ] Can a valid $n \times n$ hitori puzzle involve fewer than $2n/3$ distinct elements? Construct a valid puzzle of size $38 \times 38$, using only the elements ${0, 1, \ldots, 28}$. Verified: no Solve time: 5m12s Solution Let $B$ be the set of black cells in a valid $n\times n$ hitori cover, and let $W$ be the set of white cells....
TAOCP 7.2.2.1 Exercise 443
Section 7.2.2.1: Dancing Links Exercise 443. ▶ [ M30 ] Prove that an $m \times n$ hitori cover has at most $(mn + 2)/3$ black cells. Verified: no Solve time: 4m37s Solution Let $B$ be the set of black cells and $W$ the set of white cells. Put $$ b=|B|,\qquad w=|W|. $$ Because every cell is either black or white, $$ b+w=mn. $$ The desired inequality $$ b\leq \frac{mn+2}{3} $$...
TAOCP 7.2.2.1 Exercise 442
Section 7.2.2.1: Dancing Links Exercise 442. ▶ [ M23 ] Enumerate all hitori covers of $P_m \square P_n$, for $1 \le m \le n \le 9$. Verified: no Solve time: 3m19s Working
TAOCP 7.2.2.1 Exercise 441
Section 7.2.2.1: Dancing Links Exercise 441. [ 18 ] Describe every valid hitori puzzle of size $1 \times n$ on a $d$-letter alphabet. Verified: yes Solve time: 1m43s Solution Let the $1\times n$ puzzle be the string $$ a_1a_2\cdots a_n, $$ where each $a_i$ is one of the $d$ letters in the alphabet. A solution of a hitori puzzle consists of the unshaded positions, because the shaded positions are determined...
TAOCP 7.2.2.1 Exercise 440
Section 7.2.2.1: Dancing Links Exercise 440. [ 21 ] True or false: If the letter A occurs exactly twice in the top row of a valid hitori puzzle, exactly one of those occurrences will survive in the solution. Verified: no Solve time: 1m33s Solution The statement is false. Consider the $3 \times 3$ hitori puzzle $$ \begin{pmatrix} A & B & A\ C & D & E\ F & G...
TAOCP 7.2.2.1 Exercise 44
Section 7.2.2.1: Dancing Links Exercise 44. [ M04 ] [M04] Could the clues of a sudoku puzzle be the first 33 digits of $\pi$? (See (29a).) Verified: yes Solve time: 3m22s The first $33$ digits of $\pi$ are $$ 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0. $$ A sudoku clue must be a digit from $1$ through $9$, because each cell value represents one of the nine possible symbols. The $33$rd digit in this sequence is...
TAOCP 7.2.2.1 Exercise 439
Section 7.2.2.1: Dancing Links Exercise 439. [ M30 ] Let $G$ be a graph on the vertices $V$. A hitori cover of $G$ is a set $U \subseteq V$ such that (i) $G[U]$ is connected; (ii) if $v \notin U$ and $u \to v$ then $u \in U$; (iii) if $u \in U$ and if $v \in U$ for all $u \mathop{-!!-} v$, then $G[U \setminus u]$ is not connected....
TAOCP 7.2.2.1 Exercise 438
Section 7.2.2.1: Dancing Links Exercise 438. [ 30 ] Explain how to modify Algorithm C so that, when given an XCC problem from the construction in answer 437, it will produce only solutions that satisfy also the connectivity condition (iii). Hint: See exercise 413; also consider reachability. Verified: no Solve time: 2m32s The corrected solution removes the invalid pruning argument and uses only a connectivity test that is guaranteed to...
TAOCP 7.2.2.1 Exercise 437
Section 7.2.2.1: Dancing Links Exercise 437. ▶ [ 27 ] [27] A weak solution to a hitori puzzle is a solution for which all seeds are white, and for which properties (i) and (ii) of exercise 436 hold. Given a hitori puzzle, define an XCC problem whose solutions are precisely its weak solutions. Verified: no Solve time: 2m45s Let the cells of the hitori array be denoted by $x=(r,c)$. A...
TAOCP 7.2.2.1 Exercise 436
Section 7.2.2.1: Dancing Links Exercise 436. ▶ [ 20 ] [20] [ Hitori. ] Let's wind up this potpourri of examples by considering a completely different combinatorial challenge. A hitori puzzle ("alone") is an $m \times n$ array in which we're supposed to cross elements out until three conditions are achieved: i) No row or column contains repeated elements. ii) Adjacent elements cannot be crossed out. iii) The remaining elements...
TAOCP 7.2.2.1 Exercise 435
Section 7.2.2.1: Dancing Links Exercise 435. [ 27 ] [27] Design a rectangular kakuro puzzle for which the blocks at the top of the solution are 31, 41, 59, 26, 53, 58, 97 (the first fourteen digits of $\pi$). Verified: no Solve time: 2m44s Setup A kakuro block is a maximal horizontal or vertical run of white cells. The required seven blocks at the top of the solution are the...
TAOCP 7.2.2.1 Exercise 434
Section 7.2.2.1: Dancing Links Exercise 434. [ 39 ] [39] Exactly how many kakuro diagrams are possible in a $9 \times 9$ grid? (Every row and every column should contain at least one block of empty cells, except that the topmost row and leftmost column are completely black. All blocks must have length $\ge 2$. Empty cells needn't be rookwise connected.) What is the maximum number of blocks? Verified: no...
TAOCP 7.2.2.1 Exercise 433
Section 7.2.2.1: Dancing Links Exercise 433. [ 26 ] [26] Six of the sum-clues in this little kakuro diagram are unspecified: In how many ways can you obtain valid puzzles by specifying them? Verified: no Solve time: 1m40s The figure containing the kakuro grid is not present in the supplied material, so the numerical enumeration cannot be carried out without inventing missing data. A corrected solution must not pretend that...
TAOCP 7.2.2.1 Exercise 432
Section 7.2.2.1: Dancing Links Exercise 432. ▶ [ M25 ] We can't design new kakuro puzzles by randomly filling the blanks and using the resulting sums as the constraints, because the vast majority of possible sums yield nonunique solutions. Verify this experimentally for the generic diagrams In each case determine the exact number of ways to fill the blanks, without repeated digits in any row or column, as well as...
TAOCP 7.2.2.1 Exercise 431
Section 7.2.2.1: Dancing Links Exercise 431. ▶ [ 30 ] The inventor of kakuro, Jacob E. Funk of Manitoba (who always called his puzzles "Cross Sums"), published the following challenge on pages 50 and 66 of the August/September 1950 issue of Dell Official Crossword Puzzles : Many ingenious constructions are present here; but unfortunately, he failed to realize that there is more than one solution. Find all solutions, and obtain...
TAOCP 7.2.2.1 Exercise 430
Section 7.2.2.1: Dancing Links Exercise 430. ▶ [ 26 ] [26] [ Kakuro .] A kakuro puzzle is like a crossword puzzle, except that its "words" are blocks of two or more nonzero digits ${1, 2, \ldots, 9}$, not strings of letters. The digits of each block must be distinct, and their sum is given as a clue. Every cell to be filled belongs to exactly one horizontal block and...
TAOCP 7.2.2.1 Exercise 43
Section 7.2.2.1: Dancing Links Exercise 43. [ M30 ] [M30] Give formulas for the entries $a_{ij}$, $b_{ij}$, $c_{ij}$ of the sudoku squares in (28). Verified: no Solve time: 2m14s Setup The exercise asks for formulas for the entries $a_{ij}$, $b_{ij}$, and $c_{ij}$ of the three sudoku squares in equation (28). The supplied section excerpt contains the definition of sudoku squares and refers to equation (28), but it does not include...
TAOCP 7.2.2.1 Exercise 429
Section 7.2.2.1: Dancing Links Exercise 429. [ 21 ] [21] A closed path on a triangular grid may have "sharp turns," which change the direction by 120°, or "slack turns," which change the direction by 60°, or both. Therefore triangular masyu has three flavors of clues: '●' for the sharp turns, '○' for the slack turns, and of course '·' for the non-turns. a) Solve the following homogeneous triangular masyu...
TAOCP 7.2.2.1 Exercise 428
Section 7.2.2.1: Dancing Links Exercise 428. [ M28 ] [M28] For infinitely many $n$, construct a valid $n \times n$ masyu puzzle with $O(n)$ clues whose loop goes through all four corner cells, where all clues are (a) black; (b) white. Verified: no Solve time: 2m55s Setup A Masyu loop is a closed curve through cell centers. A black clue requires the loop to turn in that cell and to...
TAOCP 7.2.2.1 Exercise 427
Section 7.2.2.1: Dancing Links Exercise 427. ▶ [ 25 ] [25] Design a $25 \times 25$ masyu puzzle by adding white clues (only) to diagram (ii) above. All of your clues should preserve the 8-fold symmetry of this pattern. Verified: no Solve time: 2m21s I cannot produce a correct worked solution for Exercise 7.2.2.1.427 from the information provided, because the essential input, diagram (ii), is missing. The exercise asks for...
TAOCP 7.2.2.1 Exercise 426
Section 7.2.2.1: Dancing Links Exercise 426. ▶ [ 37 ] [37] Obtain a valid masyu puzzle from diagram (i) below by changing each '○' clue into either '○' or '●': Verified: no Solve time: 4m18s The exercise refers to a concrete diagram, namely diagram (i), whose initial arrangement of white clues must be modified. The required answer is an explicit assignment of each given $\circ$ to either $\circ$ or $\bullet$...
TAOCP 7.2.2.1 Exercise 425
Section 7.2.2.1: Dancing Links Exercise 425. [ 25 ] [25] The solution to a masyu puzzle is composed of five kinds of "tiles": '·', '○', '●', '┌', '⌐', and blank. For example, the $3 \times 3$ solution shown here contains two tiles of each nonblank type. Find $4 \times 4$, $5 \times 5$, and $6 \times 6$ puzzles whose unique solutions have exactly $k$ tiles of each nonblank type, for...
TAOCP 7.2.2.1 Exercise 424
Section 7.2.2.1: Dancing Links Exercise 424. [ 36 ] Make an exhaustive study of $6 \times 6$ masyu, and gather whatever statistics you think are particularly interesting. For example, how many of the $(1.5 \times 10^8)^?$ ways to place white or black clues lead to a valid puzzle? Which of the valid puzzles have the fewest clues? the most clues? the shortest loops? the longest loops? only white clues? only...
TAOCP 7.2.2.1 Exercise 423
Section 7.2.2.1: Dancing Links Exercise 423. ▶ [ M25 ] For each of the $(m-1)n + n(n-1)$ potential edges $e$ in the solution of an $m \times n$ masyu puzzle, let $x_e$ be the Boolean variable "$e$ is present". The XCC problem constructed in exercise 422 is essentially a set of constraints on those variables. Explain how to improve that construction dramatically, by exploiting the following special property that is...
TAOCP 7.2.2.1 Exercise 422
Section 7.2.2.1: Dancing Links Exercise 422. [ 21 ] Show that the "weak solutions" to any given masyu puzzle are the solutions to an easily constructed XCC problem, by adapting the solution of exercise 412. Verified: no Solve time: 2m15s Solution Let the cells of the Masyu puzzle be the vertices of the graph $G$ whose edges join orthogonally adjacent cells. A weak solution is a choice of edges of...
TAOCP 7.2.2.1 Exercise 421
Section 7.2.2.1: Dancing Links Exercise 421. ▶ [ 20 ] (Masyu.) A masyu ("evil influence") puzzle, like slitherlink, conceals a hidden loop of straight segments. But there are two important differences. First, the loop passes through the centers of grid cells, instead of following the edges. Second, no numerical quantities are involved; the clues are entirely visual and geometrical. Clues appear in circles through which the loop must pass: (i)...
TAOCP 7.2.2.1 Exercise 420
Section 7.2.2.1: Dancing Links Exercise 420. [ M22 ] Consider an $m \times n$ slitherlink with $m$ and $n$ odd, having 2s in the pattern $$ \begin{matrix} 2 & 2 & 2 & 2 & 2 & 2 \ 2 & 2 & 2 & 2 & 2 & 2 \ 2 & 2 & 2 & 2 & 2 & 2 \ \end{matrix} $$ (and possibly other clues). Show...
TAOCP 7.2.2.1 Exercise 42
Section 7.2.2.1: Dancing Links Exercise 42. [ M21 ] [M21] Explain how the method of exercise 40 could be extended to give representations of all solutions, instead of simply counting them. Verified: yes Solve time: 1m24s Solution The counting algorithm of exercise 40 loses information because each database entry $(s_j,c_j)$ stores only the number of ways to obtain the set $s_j$. To recover all solutions, replace the counter $c_j$ by...
TAOCP 7.2.2.1 Exercise 419
Section 7.2.2.1: Dancing Links Exercise 419. [ 30 ] [30] What surprise is concealed in the following symmetrical slitherlink puzzle? $$\begin{array}{ccccccccc} 2 & 1 & 1 & 1 & & & 1 & 1 & 2 \ & & & 0 & 1 & & & 1 & 1 & 2 \ 2 & 2 & & 2 & 2 & 1 & & & 0 & \ 2 &...
TAOCP 7.2.2.1 Exercise 418
Section 7.2.2.1: Dancing Links Exercise 418. [ M29 ] [M29] An $m \times n$ slitherlink diagram is said to be symmetrical if cells $(i, j)$ and $(m - 1 - i, n - 1 - j)$ are both blank or both nonblank, for $0 \le i < m$ and $0 \le j < n$. (Many grid-based puzzles obey this oft-unwritten rule.) a) There are exactly $6^{25} \approx 2.8 \times 10^{19}$...
TAOCP 7.2.2.1 Exercise 417
Section 7.2.2.1: Dancing Links Exercise 417. [ M46 ] [M46] (N. Beluhov, 2018.) Exercise 416(a) illustrates three homogeneous slitherlink puzzles that are valid for exactly the same pattern of nonblank clues. Do infinitely many such square puzzles exist? Verified: no Solve time: 1m50s Setup Exercise 7.2.2.1.417 asks whether the phenomenon from exercise 416(a), (b), (d) persists infinitely often. In the terminology of Section 7.2.2.1, a homogeneous slitherlink puzzle is one...
TAOCP 7.2.2.1 Exercise 416
Section 7.2.2.1: Dancing Links Exercise 416. [ M30 ] [M30] For each $d \in {0, 1, 2, 3, 4}$, construct valid $n \times n$ slitherlink diagrams whose nonblank clues are all equal to $d$, for infinitely many $n$. Verified: no Solve time: 2m31s A complete answer would need, at minimum: A concrete homogeneous valid diagram for each of the five values of $d$. A construction that enlarges those diagrams to...
TAOCP 7.2.2.1 Exercise 415
Section 7.2.2.1: Dancing Links Exercise 415. [ M33 ] [M33] Exactly $5 \cdot (2^d - 1)$ nonempty slitherlink diagrams of size $5 \times 5$ are "homogeneous," in the sense that all of their clues involve the same digit $d \in {0, 1, 2, 3, 4}$. (See exercise 410(a)–(d).) How many of them are valid puzzles? What are the minimum and maximum number of clues, for each $d$, in puzzles that...
TAOCP 7.2.2.1 Exercise 414
Section 7.2.2.1: Dancing Links Exercise 414. [ 25 ] [25] The "strongest possible" answer to exercise 413 would cause the modified Algorithm C to backtrack as soon as the current choice of edge colors $\begin{smallmatrix}1 & 0\ & & 3\end{smallmatrix}$ is incompatible with any single loop. Show that the algorithm in that answer is not as strong as possible, by examining its behavior on the puzzle at the right. $\begin{smallmatrix}3...
TAOCP 7.2.2.1 Exercise 413
Section 7.2.2.1: Dancing Links Exercise 413. [ 30 ] [30] Explain how to modify Algorithm C so that the construction of exercise 412 will produce only the true "single-loop" solutions. Your modified algorithm shouldn't be specific to slitherlink; it should apply also to masyu and other loop-discovery puzzles. Verified: yes Solve time: 1m30s Setup In the construction of exercise 412, the vertices of the slitherlink grid are represented by items...
TAOCP 7.2.2.1 Exercise 412
Section 7.2.2.1: Dancing Links Exercise 412. ▶ [ 22 ] [22] A "weak solution" to a slitherlink diagram is a set of edges that obeys the numeric constraints, and touches every vertex of the grid either twice or not at all; but it may form arbitrarily many loops. For example, the diagram of exercise 410(i) has six weak solutions, three of which are shown in 410(iii), (iv), and (v). Show...
TAOCP 7.2.2.1 Exercise 411
Section 7.2.2.1: Dancing Links Exercise 411. [ 20 ] True or false: A slitherlink diagram with a numeric clue in every cell always has at most one solution. Hint: Consider the $2 \times 2$ case. Verified: no Solve time: 2m17s Edit Solution The statement is false. It suffices to exhibit one slitherlink diagram with a clue in every cell that has two distinct solutions. Consider the (2\times2) diagram [ \begin{matrix}...
TAOCP 7.2.2.1 Exercise 410
Section 7.2.2.1: Dancing Links Exercise 410. [ 22 ] ( Slitherlink. ) Another addictive class of puzzles is based on finding closed paths or "loops" in a given graph, when the allowable cycles must satisfy certain constraints. For instance, a slitherlink puzzle prescribes the number of loop edges that surround particular cells of a rectangular grid, as in diagram (i) below. The first step in solving puzzle (i) is to...
TAOCP 7.2.2.1 Exercise 41
Section 7.2.2.1: Dancing Links Exercise 41. [ 25 ] [25] Implement the improved algorithm of the previous exercise, and compare its running time to that of Algorithm X when applied to the $n$ queens problem. Verified: no Solve time: 2m40s The corrected solution below replaces the unsupported pruning argument with the actual state-merging algorithm required by the exercise, gives an implementation outline, and describes a reproducible comparison with Algorithm X...
TAOCP 7.2.2.1 Exercise 409
Section 7.2.2.1: Dancing Links Exercise 409. ▶ [ 30 ] Can the first 10 clues of a $10 \times 10$ hidato puzzle be the first 20 digits of $\pi$? Verified: no Solve time: 2m59s Solution We interpret the first $20$ digits of $\pi$ as ten two-digit clue values. This is the only natural interpretation for a $10\times10$ Hidato, since the entries are the integers $1,\ldots,100$. Thus the required first ten...
TAOCP 7.2.2.1 Exercise 408
Section 7.2.2.1: Dancing Links Exercise 408. [ 28 ] (N. Beluhov.) Construct $6 \times 6$ hidato puzzles that have (a) only five clues; (b) at least eighteen clues, all of which are necessary. Verified: no Solve time: 6m58s Working
TAOCP 7.2.2.1 Exercise 407
Section 7.2.2.1: Dancing Links Exercise 407. ▶ [ 20 ] Here's a curious $4 \times 8$ array that is consistent with 52 hidato solutions: $$\begin{array}{|c|c|c|c|c|c|c|c|} \hline & 22 & & & & & & 12 \ \hline & & 29 & 26 & 16 & 8 & 3 & \ \hline \end{array}$$ Change it to a valid hidato puzzle, by adding one more clue. Verified: no Solve time: 2m10s Solution...
TAOCP 7.2.2.1 Exercise 406
Section 7.2.2.1: Dancing Links Exercise 406. [ 16 ] Show that the following hidato puzzle isn't as hard as it might look at first: $$\begin{array}{|c|c|c|c|c|c|} \hline 19 & 52 & 53 & 54 & 4 & 62 & 63 & 64 \ \hline 20 & & & & & & & 1 \ \hline 21 & & & & & & & 60 \ \hline 41 & & & &...
TAOCP 7.2.2.1 Exercise 405
Section 7.2.2.1: Dancing Links Exercise 405. [ 21 ] The preceding exercise needs a subroutine to determine the endpoints of all simple paths of lengths $1, 2, \ldots, L$ from a given vertex $v$ in a given graph. That problem is NP-hard; but sketch an algorithm that works well for small $L$ in small graphs. Verified: yes Solve time: 1m34s Solution Let the graph be $G=(V,E)$, and let $v\in V$...
TAOCP 7.2.2.1 Exercise 404
Section 7.2.2.1: Dancing Links Exercise 404. ▶ [ 25 ] [25] ( Hidato ®.) A "hidato solution" is an $m \times n$ matrix whose entries are a permutation of ${1, 2, \ldots, mn}$ for which the cells containing $k$ and $k + 1$ are next to each other, either horizontally, vertically, or diagonally, for $1 \le k < mn$. (In other words, it specifies a Hamiltonian path of king moves...
TAOCP 7.2.2.1 Exercise 403
Section 7.2.2.1: Dancing Links Exercise 403. ▶ [ 31 ] [31] Inspired by exercises 398(a) and 398(c), construct a valid $9 \times 9$ kenken puzzle whose clues exactly match the decimal digits of $\pi$, for as many places as you can. Verified: no Solve time: 6m24s Working
TAOCP 7.2.2.1 Exercise 402
Section 7.2.2.1: Dancing Links Exercise 402. [ 24 ] [24] Solve this $12 \times 12$ kenken puzzle, using hexadecimal digits from 1 to C: The five-cell cages that play multiplicative clues, associated with the names of the twelve pentominoes: O, 9240× P, 5184× Q, 1638× R, 720× S, 15840× T, 19800× U, 10560× V, 4032× W, 1620× X, 5600× Y, 576× Z, 17248× Verified: no Solve time: 2m19s Solution The...
TAOCP 7.2.2.1 Exercise 401
Section 7.2.2.1: Dancing Links Exercise 401. [ 22 ] [22] Find all $4 \times 4$ kenken puzzles whose unique solution is the latin square shown at the right, and whose clues belong to two cells. Furthermore, there should be exactly two cages for each of the four operations $+, -, \times, \div$. $$\begin{matrix} 1 & 2 & 3 & 4 \ 2 & 1 & 4 & 3 \ 4...
TAOCP 7.2.2.1 Exercise 400
Section 7.2.2.1: Dancing Links Exercise 400. [ 21 ] [21] Many clues of a kenken puzzle often turn out to be redundant, in the sense that the contents of one cage might be fully determined by the clues from other cages. For example, it turns out that any one of the clues in puzzle 398(a) could actually be omitted, without permitting a new solution. Find all subsets of those 11...
TAOCP 7.2.2.1 Exercise 40
Section 7.2.2.1: Dancing Links Exercise 40. ▶ [ 21 ] $[21]$ If we merely want to count the number of solutions to an exact cover problem, without actually constructing them, a completely different approach based on bitwise manipulation instead of list processing is sometimes useful. The following naive algorithm illustrates the idea. We're given an $m \times n$ matrix of 0s and 1s, represented as $n$-bit vectors $r_1, \ldots, r_m$....
TAOCP 7.2.2.1 Exercise 399
Section 7.2.2.1: Dancing Links Exercise 399. ▶ [ 22 ] [22] How can all solutions to a kenken puzzle be obtained with Algorithm C? Verified: no Solve time: 1m50s Solution Algorithm C can be applied after converting the KenKen puzzle into an exact cover problem. The conversion must incorporate both the Latin square conditions and the arithmetic restrictions imposed by the cages. Let the order of the KenKen puzzle be...
TAOCP 7.2.2.1 Exercise 398
Section 7.2.2.1: Dancing Links Exercise 398. [ 23 ] [23] ( KenKen ®.) A secret latin square whose entries are ${1, 2, \ldots, n}$ can often be deduced by means of arithmetic. A kenken puzzle specifies the sum, difference, product, or quotient of the entries in each of its "cages," which are groups of cells indicated by heavy lines, as in the following examples: (When the operation is '$-$' or...
TAOCP 7.2.2.1 Exercise 397
Section 7.2.2.1: Dancing Links Exercise 397. ▶ [ 30 ] [30] ( Save the sheep. ) Given a grid in which some of the cells are occupied by sheep, the object of this puzzle is to construct a fence that keeps all the sheep on one side. The fence must begin and end at the edge of the grid, and it must follow the grid lines without visiting any point...
TAOCP 7.2.2.1 Exercise 396
Section 7.2.2.1: Dancing Links Exercise 396. ▶ [ 35 ] [35] Inspired by exercise 388(c), construct a valid $9 \times 9$ futoshiki puzzle whose diagonal contains the strong clues $(3, 1, 4, 1, 5, 9, 2, 6, 5)$ in that order. Every other clue should be a weak '$<$', not a '$>$', not a '$\wedge$', not a 'v'. Verified: no Solve time: 3m02s Setup A $9\times9$ futoshiki solution is a...
TAOCP 7.2.2.1 Exercise 395
Section 7.2.2.1: Dancing Links Exercise 395. [ 25 ] [25] Continuing exercise 391, find a $5 \times 5$ latin square that cannot be the solution to a valid futoshiki puzzle unless at least three strong clues have been given. Verified: no Solve time: 7m11s Solution Consider the Latin square $$ L= \begin{pmatrix} 1&3&2&5&4\ 4&1&3&2&5\ 2&4&5&3&1\ 5&2&4&1&3\ 3&5&1&4&2 \end{pmatrix}. $$ Each row and each column contains the symbols $1,2,3,4,5$ exactly once,...
TAOCP 7.2.2.1 Exercise 394
Section 7.2.2.1: Dancing Links Exercise 394. [ 29 ] [29] Show that every $5 \times 5$ futoshiki puzzle that has only five clues, strong, weak, or a mixture of both, has at least four solutions. Which puzzles attain this minimum? Verified: no Solve time: 7m18s Working
TAOCP 7.2.2.1 Exercise 393
Section 7.2.2.1: Dancing Links Exercise 393. [ 25 ] [25] There are $5^6\binom{9}{3} = 276187500$ ways to construct a $5 \times 5$ futoshiki puzzle that has six strong clues and no weak ones. How many of them (a) are valid? (b) have no solutions? (c) have more than one solution? Give an example of each case. Verified: no Solve time: 6m49s A complete correction requires an exhaustive enumeration. The empty...
TAOCP 7.2.2.1 Exercise 392
Section 7.2.2.1: Dancing Links Exercise 392. ▶ [ 25 ] [25] There are $2^6\binom{9}{3} = 245656320$ ways to construct a $5 \times 5$ futoshiki puzzle that has six weak clues and no strong ones. How many of them (a) are valid? (b) have no solutions? (c) have more than one solution? Also refine those counts, by considering how many such puzzles of types (a), (b), and (c) have at least...
TAOCP 7.2.2.1 Exercise 391
Section 7.2.2.1: Dancing Links Exercise 391. [ 29 ] A futoshiki puzzle is said to be valid if it has exactly one solution. Use Algorithm X to generate all possible $5 \times 5$ latin squares. Explain why many of them can't be the solution to a valid futoshiki puzzle unless it has at least one strong clue. Verified: no Solve time: 2m06s The corrected solution is given below. It removes...
TAOCP 7.2.2.1 Exercise 390
Section 7.2.2.1: Dancing Links Exercise 390. ▶ [ 21 ] Show that every futoshiki puzzle is a special case of an exact cover problem. In fact, show that every such puzzle can be formulated in at least two different ways: a) Use a purwarver ordering trick analogous to (25) or (26), to encode the weak clues. b) Use color controls to formulate an XCC problem suitable for Algorithm C. Verified:...
TAOCP 7.2.2.1 Exercise 39
Section 7.2.2.1: Dancing Links Exercise 39. ▶ [ M21 ] $[M21]$ Experiment with exact cover problems that are defined by $m$ random options on $n$ items. (Each option is generated independently, with repetitions permitted.) a) Use a fixed probability $p$ that item $i$ is included in any given option. b) Let every option be a random sample of $r$ distinct items. Verified: no Solve time: 1m57s Solution Let $m$ be...
TAOCP 7.2.2.1 Exercise 389
Section 7.2.2.1: Dancing Links Exercise 389. [ 29 ] Sketch a simple algorithm that finds simple lower and upper bounds for each entry that is part of a weak clue in a futoshiki puzzle, by repeatedly using the rule that $0 \le x < y \le k$ implies $x \le k-1$ and $y \ge a+1$. (Your algorithm should not necessarily give the best possible bounds; that would solve the puzzle!...
TAOCP 7.2.2.1 Exercise 388
Section 7.2.2.1: Dancing Links Exercise 388. ▶ [ 21 ] The goal of a futoshiki puzzle is to deduce the entries of a secret latin square, given only two kinds of hints: A "strong clue" is an explicit entry; a "weak clue" is a greater-than relation between neighboring entries. The entries are the numbers 1 to $n$, where $n$ is usually 5 as in the following examples: Solve these puzzles...
TAOCP 7.2.2.1 Exercise 387
Section 7.2.2.1: Dancing Links Exercise 387. ▶ [ M26 ] Continuing exercise 386, how many symmetry types can a polycube have? Give an example of each type, using the minimum numbers of cubes. (Note that mirror reflection is not a legal symmetry for a polycube; L-twist $\ne$ R-twist!) Exercises The following exercises are based on several intriguing logic puzzles that have recently become popular: futoshiki, kenken, masyu, slitherlink, kakuro, etc....
TAOCP 7.2.2.1 Exercise 386
Section 7.2.2.1: Dancing Links Exercise 386. ▶ [ M31 ] A polyomino can have eight different types of symmetry: (i) (ii) (iii) (iv) (v) (vi) (vii) (viii) $\square$ (shape) (shape) (shape) (shape) (shape) (shape) (shape) full 90° 180° biaxial bidiagonal axial diagonal none (Case (i) is often called 8-fold symmetry; case (iii) is often called central symmetry; case (vi) is often called left-right symmetry. Cases (ii), (iv), (v) are 4-fold...
TAOCP 7.2.2.1 Exercise 385
Section 7.2.2.1: Dancing Links Exercise 385. [ M36 ] [M36] (H. Post!, 2017.) Arbitrarily large motley cuboids can be constructed by repeatedly nesting one motley cuboid within another (see answer 367). Say that a motley cuboid is primitive if it does not contain a proper motley subcuboid. Do primitive motley cuboids of size $l \times m \times n$ exist only when $l = m = n = 7$? Verified: no...
TAOCP 7.2.2.1 Exercise 384
Section 7.2.2.1: Dancing Links Exercise 384. [ 34 ] [34] By generalizing exercises 365 and 370, explain how to find every motley dissection of an $l \times m \times n$ cuboid, using Algorithm M. Note: In three dimensions, the strictness condition $(a_i, b_i) \ne (0, m)$ and $(c_i, d_i) \ne (0, n)$ of exercise 362 should become $$[(a_i, b_i) \ne (0, l)] + [(c_i, d_i) \ne (0, m)] + [(e_i,...
TAOCP 7.2.2.1 Exercise 383
Section 7.2.2.1: Dancing Links Exercise 383. [ 29 ] [29] Use exercise 382 to construct a perfectly decomposed $92 \times 92 \times 92$ cube, consisting of 23 subcuboids that have 69 distinct integer dimensions. [See exercise 373.] Verified: no Solve time: 4m27s A complete solution to Exercise 7.2.2.1.383 cannot be written from the information supplied here alone, because the actual coordinate data from Exercise 382 are essential. The flawed solution...
TAOCP 7.2.2.1 Exercise 382
Section 7.2.2.1: Dancing Links Exercise 382. [ 18 ] [18] There's a natural way to extend the idea of motley dissection to three dimensions, by subdividing an $l \times m \times n$ cuboid into subcuboids $(a_i, b_i) \times [c_i, d_i) \times [e_i, f_i)$ that have no repeated intervals $[a_{\cdot}, b_{\cdot})$ or $[c_{\cdot}, d_{\cdot})$ or $[e_{\cdot}, f_{\cdot})$. For example, Scott Kim has discovered a remarkable motley $7 \times 7 \times 7$...
TAOCP 7.2.2.1 Exercise 381
Section 7.2.2.1: Dancing Links Exercise 381. ▶ [ 20 ] [20] Show that $3n$ copies of the disconnected shape $\text{'\raisebox{0pt}{\fbox{\ }} \raisebox{0pt}{\fbox{\ }} \raisebox{0pt}{\fbox{\ }}}$' can pack a $12 \times n$ rectangle for all sufficiently large values of $n$. Verified: yes Solve time: 2m37s Solution Place coordinates on the $12 \times n$ rectangle, with rows numbered $1,2,\ldots,12$ and columns numbered $1,2,\ldots,n$. The disconnected shape consists of three unit squares in...
TAOCP 7.2.2.1 Exercise 380
Section 7.2.2.1: Dancing Links Exercise 380. [ 35 ] [35] Solve exercise 379 for the Y pentomino. Verified: no Solve time: 5m08s Edit Let (Y) denote the pentomino consisting of a column of four cells with one additional cell attached to the second cell of the column. Since every copy of (Y) has area (5), a necessary condition for an (h\times n) rectangle to be tileable is [ 5\mid hn...
TAOCP 7.2.2.1 Exercise 38
Section 7.2.2.1: Dancing Links Exercise 38. [ M25 ] $[M25]$ Devise an efficient way to compute the sequence $\langle g_n \rangle$ of exercise 37. Verified: no Solve time: 2m21s Solution Let $g_n$ denote the lexicographically smallest solution of the $\infty$ queens problem. Thus $g_n$ is the row occupied by the queen in column $n$, and the defining condition is $$ g_i\ne g_j,\qquad |g_i-g_j|\ne |i-j| $$ for all distinct positive integers...
TAOCP 7.2.2.1 Exercise 379
Section 7.2.2.1: Dancing Links Exercise 379. ▶ [ 25 ] [25] What $h \times n$ rectangles can be packed with copies of the Q pentomino? Hint: It suffices to find a finite basis for all such rectangles, using the previous exercise. Verified: no Solve time: 4m46s The empty submission gives no information, so the solution must begin by determining the finite basis of packable rectangles for the $Q$-pentomino. Since the...
TAOCP 7.2.2.1 Exercise 378
Section 7.2.2.1: Dancing Links Exercise 378. [ M30 ] [M30] ( A finite basis theorem. ) Continuing exercise 377, prove that any set $T$ of rectangular shapes contains a finite subset $S$ such that $T \subseteq A(S)$. Verified: no Solve time: 3m21s Edit Setup Let a rectangular shape be denoted by $h\times w$, where $h,w\in\mathbb N$. For a set $S$ of shapes, $A(S)$ denotes the set of all shapes obtainable...
TAOCP 7.2.2.1 Exercise 377
Section 7.2.2.1: Dancing Links Exercise 377. [ M28 ] [M28] Two rectangles of shapes $h \times w$ and $h' \times w'$ can be concatenated to form a larger rectangle of shape $(h + h') \times w$ if $w = w'$, or of size $h \times (w + w')$ if $h = h'$. a) Given a set $S$ of rectangle shapes, let $A(S)$ be the set of all shapes that can...
TAOCP 7.2.2.1 Exercise 376
Section 7.2.2.1: Dancing Links Exercise 376. ▶ [ M25 ] [M25] Find seven different rectangles of area $1/7$ that can be assembled into a square of area 1, and prove that the answer is unique. Verified: no Solve time: 5m48s $$ \textbf{Solution.} $$ It is convenient first to construct the dissection with a square of side $210$. Afterward, dividing all lengths by $210$ gives the required square of area $1$....
TAOCP 7.2.2.1 Exercise 375
Section 7.2.2.1: Dancing Links Exercise 375. [ M29 ] [M29] Among all the incomparable dissections of order (a) seven and (b) eight, restricted to integer sizes, find the rectangles with the smallest possible semiperimeter (height plus width). Also find the smallest possible squares that have incomparable dissections in integers. Hint: Show that there are $2^l$ potential ways to fix the $b$'s with the $u$'s, preserving their order; and find the...
TAOCP 7.2.2.1 Exercise 374
Section 7.2.2.1: Dancing Links Exercise 374. [ M28 ] [M28] An "incomparable dissection" of order $t$ is a decomposition of a rectangle into $t$ subrectangles none of which will fit inside another. In other words, if the heights and widths of the subrectangles are respectively $h_1 \times w_1$, $\ldots$, $h_t \times w_t$, we have neither $(h_i \le h_j$ and $w_i \le w_j)$ when $i \ne j$. a) True or false:...
TAOCP 7.2.2.1 Exercise 373
Section 7.2.2.1: Dancing Links Exercise 373. [ 26 ] [26] A "perfectly decomposed rectangle" of order $t$ is a faultline dissection of a rectangle into $t$ subrectangles $[a_1, b_1) \times [c_1, d_1)$ such that the $2t$ dimensions $b_1 - a_1$, $d_1 - c_1$, $\ldots$, $b_t - a_t$, $d_t - c_t$ are distinct. For example, five rectangles of sizes $1 \times 2$, $3 \times 7$, $4 \times 6$, $5 \times 10$,...
TAOCP 7.2.2.1 Exercise 372
Section 7.2.2.1: Dancing Links Exercise 372. ▶ [ M35 ] [M35] (Floorplans.) If a rectangle decomposition satisfies the tatami condition, "no four rectangles meet", it's often called a floorplan , and its subrectangles are called rooms . The line segments that delimit rooms are called walls . Four possibilities arise when room $r$ is adjacent to bound $s$: Either $s \uparrow r$, $r \to s$, $s \downarrow r$, or $s...
TAOCP 7.2.2.1 Exercise 371
Section 7.2.2.1: Dancing Links Exercise 371. [ 24 ] [24] Further symmetry is possible when $m = n$ (as in exercise 365's pinwheel). a) Explain how to generate all of the $n \times n$ motley dissections that have 90°-rotational symmetry. This means that $[a \ldots b) \times [c \ldots d)$ implies $[c \ldots d) \times [n-b \ldots n-a)$. b) Explain how to generate all of the $n \times n$ dissections...
TAOCP 7.2.2.1 Exercise 370
Section 7.2.2.1: Dancing Links Exercise 370. ▶ [ 23 ] [23] Explain how to generate all of the $m \times n$ motley dissections that have 180°-rotational symmetry, as in the last two examples of exercise 365, by modifying the construction of exercise 366. (In other words, if $[a \ldots b) \times [c \ldots d)$ is a subrectangle of the dissection, its complement $[m - b \ldots m - a) \times...
TAOCP 7.2.2.1 Exercise 37
Section 7.2.2.1: Dancing Links Exercise 37. [ M46 ] $[M46]$ (N. J. A. Sloane, 2016.) Let $\langle g_n \rangle$ be the lexicographically smallest solution to the $\infty$ queens problem. (This sequence begins $1, 3, 5, 2, 4, 9, 11, 13, 15, 6, 8, 19, 7, 22, 10, 25, 27, 29, 31, 12, 14, 35, 37, 39, 41, 16, 18, 45, \ldots,$ and it clearly has strange regularities and irregularities.) a)...
TAOCP 7.2.2.1 Exercise 369
Section 7.2.2.1: Dancing Links Exercise 369. [ 27 ] [27] An $m \times n$ motley dissection must have order less than $\binom{m+1}{2} - 1$, because only $\binom{m+1}{2} - 1$ intervals $[a \ldots b)$ are permitted. What is the maximum order that's actually achievable by an $m \times n$ motley dissection, for $m = 5$, 6, and 7? Verified: no Solve time: 4m03s The data supplied do not contain enough information...
TAOCP 7.2.2.1 Exercise 368
Section 7.2.2.1: Dancing Links Exercise 368. [ M21 ] [M21] (H. Postl, 2017.) Show that an $m \times n$ motley dissection of order $t$ can exist only if $n < 2t/3$. Hint: Consider adjacent subrectangles. Verified: no Solve time: 3m07s Solution Let the $m\times n$ rectangle be divided into $t$ subrectangles. Number the subrectangles in a way that distinguishes adjacent ones only when they share a side. The defining property...
TAOCP 7.2.2.1 Exercise 367
Section 7.2.2.1: Dancing Links Exercise 367. [ 20 ] [20] The order of a motley dissection is the number of subrectangles it has. There are no motley dissections of order 2m. Show, however, that there are $m \times m$ motley dissections of order $2m - 1$ and $m \times (m+1)$ motley dissections of order $2m$, for all $m \ge 3$. Verified: no Solve time: 2m27s Solution Let a motley dissection...
TAOCP 7.2.2.1 Exercise 366
Section 7.2.2.1: Dancing Links Exercise 366. ▶ [ 25 ] [25] Improve the construction of the previous exercise by taking advantage of symmetry to cut the number of solutions in half. (When $m = 4$ there will now be $4 + 4$ solutions; when $m = 4$ and $n = 5$: $2 + 2 + 2 + 1 + 1$ solutions. Hint: A motley dissection is never identical to its...
TAOCP 7.2.2.1 Exercise 363
Section 7.2.2.1: Dancing Links Exercise 363. [ 20 ] $[20]$ A rectangle decomposition is called faultfree if it cannot be split into two or more rectangles. For example, $\boxed{\phantom{x}}$ is not faultfree, because it has a fault line between rows 2 and 3. (It's easy to see that every reduced faultfree pattern is strictly reduced, unless $m = n = 1$.) Modify the construction of exercise 360 so that it...
TAOCP 7.2.2.1 Exercise 361
Section 7.2.2.1: Dancing Links Exercise 361. [ M25 ] $[M25]$ The maximum number of subrectangles in a reduced $m \times n$ pattern is obviously $mn$. What is the minimum number? Verified: no Solve time: 6m24s Edit The minimum number of subrectangles in a reduced (m\times n) pattern is [ \boxed{m+n-1}. ] We first prove the necessary lower bound. Let a rectangular dissection consist of (r) rectangles. Let (a) be the...
TAOCP 7.2.2.1 Exercise 360
Section 7.2.2.1: Dancing Links Exercise 360. ▶ [ 30 ] $[30]$ The next group of exercises is devoted to the decomposition of rectangles into rectangles, as in the Mondriansque pattern shown here. The reduction of such a pattern is obtained by distorting it, if necessary, so that it fits into an $m \times n$ grid, with each of the vertical coordinates ${0, 1, \ldots, m}$ used in at least one...
TAOCP 7.2.2.1 Exercise 36
Section 7.2.2.1: Dancing Links Exercise 36. ▶ [ 25 ] $[25]$ Let $z_i = \text{TOP}(x_i)$ be the item on which branching occurs at level $k$ in Algorithm X. Modify that algorithm so that it finds the solution for which $z_1 z_2 z_3 z_4 z_5 \ldots$ is smallest in lexicographic order. (It's easy to do this by simply setting $i \leftarrow \text{RLINK}(0)$ in step X3. But there's a much faster way,...
TAOCP 7.2.2.1 Exercise 358
Section 7.2.2.1: Dancing Links Exercise 358. [ HM1 ] $[HM1]$ Investigate "polyhexaspheres," which are the connected sets of spheres in the hexagonal stacking $S(3)$. (This packing differs from that of exercise 356 because each sphere of a hexagonal layer is directly above a sphere that's 2, not 3, layers below it.) Verified: no Solve time: 34s Represent the centers of the spheres by coordinates in the hexagonal stacking, using two-dimensional...
TAOCP 7.2.2.1 Exercise 357
Section 7.2.2.1: Dancing Links Exercise 357. [ M0 ] $[M0]$ Investigate "polysplatts," which are the sets of truncated octahedra that can be built by pasting adjacent faces together (either square or hexagonal). Verified: no Solve time: 2m42s A truncated octahedron has $6$ square faces and $8$ hexagonal faces, so a polysplatt is determined by a connected set of cells in the truncated-octahedral honeycomb. The centers of these cells form the...
TAOCP 7.2.2.1 Exercise 356
Section 7.2.2.1: Dancing Links Exercise 356. [ 27 ] [27] Polysphere puzzles often involve the construction of three kinds of shapes: n-tetrahedron $\qquad$ $m \times n$ roof $\qquad$ stretched (as seen from $\qquad$ (shown for $\qquad$ $m \times n$ roof the top, for $\qquad$ $m = 3$, $\qquad$ (as seen from $n = 4$) $\qquad$ $n = 4$) $\qquad$ $n{=}3, n{=}4$) (An $n \times n$ roof or stretched roof is...
TAOCP 7.2.2.1 Exercise 355
Section 7.2.2.1: Dancing Links Exercise 355. [ 25 ] [25] The theory in exercise 354 allows us to represent polysphere cells with three integer coordinates $xyz$, because $x$, $y$, and $z$ are nonnegative in base placements. The other variable, $w$, is redundant (but worth keeping in mind); it always equals $-x - y - z$. a) What's a good way to find all the base placements of a given polysphere...
TAOCP 7.2.2.1 Exercise 354
Section 7.2.2.1: Dancing Links Exercise 354. ▶ [ M30 ] [M30] A polysphere is a connected set of spherical cells that belong to the "face-centered cubic lattice," which is one of the two principal ways to pack cannonballs (or oranges) with maximum efficiency. That lattice is conveniently regarded as the set $S$ of all quadruples $(w, x, y, z)$ of integers for which $w + x + y + z...
TAOCP 7.2.2.1 Exercise 353
Section 7.2.2.1: Dancing Links Exercise 353. [ 39 ] [39] A weak polycube is a set of cubes that are loosely connected via common edges, not necessarily via common faces. In other words, we consider cubes to be adjacent when their centers are at most $\sqrt{2}$ units apart; up to 18 neighbors are possible. Find all the weak polycubes of size 3, and pack them into a symmetrical container. Verified:...
TAOCP 7.2.2.1 Exercise 352
Section 7.2.2.1: Dancing Links Exercise 352. [ 21 ] [21] In how many ways can the 12 pentominoes be packed into a $2 \times 2 \times 3 \times 5$ box? Verified: no Solve time: 4m30s Each pentomino is regarded as a flat $5$-cell polycube embedded in the $2 \times 2 \times 3 \times 5$ hyperbox. Since the box contains $$ 2 \cdot 2 \cdot 3 \cdot 5 = 60 $$...
TAOCP 7.2.2.1 Exercise 350
Section 7.2.2.1: Dancing Links Exercise 350. [ 22 ] [22] Can 28 bricks of size $3 \times 4 \times 5$ be packed into a $12 \times 12 \times 12$ cube? Verified: no Solve time: 6m08s The proposed slab argument is a valid reduction, but the rectangle packing used in the previous solution is not. The overlapping rectangles must be discarded and replaced by an actual packing of the required seven...
TAOCP 7.2.2.1 Exercise 35
Section 7.2.2.1: Dancing Links Exercise 35. [ M21 ] $[M21]$ Continuing exercise 34, construct $A'$ having exactly three 1s in per column. Verified: no Solve time: 2m24s A mathematically correct solution cannot be written from the information provided because the exercise statement is incomplete. Exercise 35 is explicitly a continuation of Exercise 34: "Continuing exercise 34, construct $A'$ having exactly three 1s in every column." The matrix $A'$ requested in...
TAOCP 7.2.2.1 Exercise 349
Section 7.2.2.1: Dancing Links Exercise 349. ▶ [ M27 ] [M27] (D. Hoffman.) Show that 27 bricks of size $a \times b \times c$ can always be packed into an $s \times s \times s$ cube, where $s = a + b + c$. But if $s/4 < a < b < c$, 28 bricks won't fit. Verified: yes Solve time: 1m53s Setup Let $$ s=a+b+c, $$ and consider the...
TAOCP 7.2.2.1 Exercise 348
Section 7.2.2.1: Dancing Links Exercise 348. [ M41 ] [M41] Find the maximum number of "canonical bricks" ($1 \times 2 \times 4$) that can be packed into an $l \times m \times n$ box, leaving as few empty cells as possible. Verified: no Solve time: 4m14s The reviewer’s principal objection is based on a misinterpretation of the exercise. For arbitrary positive integers $l,m,n$, the maximum packing number of $1\times2\times4$ bricks...
TAOCP 7.2.2.1 Exercise 347
Section 7.2.2.1: Dancing Links Exercise 347. ▶ [ M21 ] [M21] (N. G. de Bruijn, 1961.) Prove that an $l \times m \times n$ box can be completely filled with $1 \times 1 \times k$ bricks only if $k$ is a divisor of $l$, $m$, or $n$. (Consequently, it can be completely filled with $a \times b \times c$ bricks only if $a$, $b$, and $c$ all satisfy this condition.)...
TAOCP 7.2.2.1 Exercise 346
Section 7.2.2.1: Dancing Links Exercise 346. [ M30 ] $[M30]$ An $(l,m,n)$-tripod is a cluster of $l+m+n+1$ cubes in which three "legs" of lengths $l$, $m$, and $n$ are attached to a corner cube, as in the $(1,2,3)$-tripod shown here. A "pod" is the special case where the tripod is $${(l,m,n)} \cup {(l',m,n) \mid 0 \le l' < l} \cup {(l,m',n) \mid 0 \le m' < m} \cup {(l,m,n') \mid...
TAOCP 7.2.2.1 Exercise 345
Section 7.2.2.1: Dancing Links Exercise 345. [ 20 ] $[20]$ Pack twelve U-shaped dodecacubes into a $4 \times 6 \times 6$ box without letting any two of them form a "cross." Verified: no Solve time: 3m56s The corrected solution is: Edit The supplied statement does not contain the defining data needed to determine the U-shaped dodecacube or the meaning of a forbidden cross. Therefore an explicit packing certificate cannot be...
TAOCP 7.2.2.1 Exercise 344
Section 7.2.2.1: Dancing Links Exercise 344. [ 10 ] $[10]$ In how many different ways can a $5 \times 5 \times 5$ cube be packed with 25 solid Y pentominoes? (See Fig. 73.) Discuss how to remove the 48 symmetries of this problem. Verified: no Solve time: 3m39s $$ \textbf{Solution.} $$ The natural way to solve the problem is by exact cover, but the symmetry reduction must be incorporated into...
TAOCP 7.2.2.1 Exercise 343
Section 7.2.2.1: Dancing Links Exercise 343. [ 10 ] $[10]$ (T. Sillke, 1995.) For each of the twelve pentomino shapes, build the tallest possible tower whose walls are vertical and whose floors all have the given shape, using distinct pentacubes. Hint: Judicious factorization will give tremendous speedup. Verified: no Solve time: 9m11s
TAOCP 7.2.2.1 Exercise 342
Section 7.2.2.1: Dancing Links Exercise 342. [ 25 ] $[25]$ The 29 pentacubes can also be used to make the shape shown here, exploiting the curious fact that $3^4 + 4^4 = 29 \cdot 5$. But Algorithm X will take a long, long time before telling us how to construct it, unless we're lucky, because the space of possibilities is huge. How can we find a solution quickly? Verified: no...
TAOCP 7.2.2.1 Exercise 341
Section 7.2.2.1: Dancing Links Exercise 341. ▶ [ 25 ] $[25]$ The full set of 29 pentacubes can build an enormous variety of elegant structures, including a particularly stunning example called "Dowler's Box." This $7 \times 7 \times 5$ container, first considered by R. W. M. Dowler in 1979, is constructed from five flat slabs. Yet only 12 of the pentacubes lie flat; the other 17 must somehow be worked...
TAOCP 7.2.2.1 Exercise 340
Section 7.2.2.1: Dancing Links Exercise 340. [ 30 ] There are 29 pentacubes , conveniently identified with one-letter codes: Pieces $o$ through $z$ are called, not surprisingly, the solid pentominoes or flat pentacubes . a) What are the mirror images of a, b, c, d, e, f, A, B, C, D, E, F, j, k, l, $\ldots$, z? b) In how many ways can the solid pentominoes be packed into...
TAOCP 7.2.2.1 Exercise 34
Section 7.2.2.1: Dancing Links Exercise 34. [ M25 ] $[M25]$ Given an exact cover problem $A$ as in exercise 33, construct an exact cover problem $A'$ such that (i) $A'$ has at most three 1s in every column; (ii) $A'$ and $A$ have exactly the same number of solutions. Verified: no Solve time: 6m27s $$ \textbf{Construction.} $$ Let $A$ be the given exact cover instance. We regard $A$ as a...
TAOCP 7.2.2.1 Exercise 339
Section 7.2.2.1: Dancing Links Exercise 339. [ 25 ] How many of the 369 octominoes define a 4-level prism that can be realized by the tetracubes? Do any of those packing problems have a unique solution? Verified: no Solve time: 5m58s Let $O$ be a free octomino, and let $P(O)$ be the $4$-level prism obtained by stacking four copies of $O$. The volume of $P(O)$ is $$ 4\cdot 8=32, $$...
TAOCP 7.2.2.1 Exercise 338
Section 7.2.2.1: Dancing Links Exercise 338. [ 22 ] Show that there are exactly eight different tetracubes , polycubes of size 4. Which of the following shapes can they make, respecting gravity? How many solutions are possible? Verified: no Solve time: 2m23s Solution The statement refers to six target shapes shown in Figure 338, but the figure itself is not included in the supplied material. The names “twin towers”, “double...
TAOCP 7.2.2.1 Exercise 337
Section 7.2.2.1: Dancing Links Exercise 337. [ 29 ] (Angus Lavery, 1989.) Design a puzzle that consists of nine bent tricubes, whose face squares are either blank or colored with a red or green spot. red green. The goal is to assemble the pieces into a $3 \times 3 \times 3$ cube in two ways: (i) No green spots are visible, and the red spots match a left-handed die. (ii)...
TAOCP 7.2.2.1 Exercise 336
Section 7.2.2.1: Dancing Links Exercise 336. [ 21 ] ( The L-bert Hall. ) Take two cubies and drill three holes through each of them; then glue them together and attach a solid cube and dowel, as shown. Prove that there's only one way to pack nine such pieces into a $3 \times 3 \times 3$ box. Verified: no Solve time: 2m02s Solution The statement supplied for exercise 336 is...
TAOCP 7.2.2.1 Exercise 335
Section 7.2.2.1: Dancing Links Exercise 335. [ 30 ] The earliest known example of a polycube puzzle is the "Cube Diabolique," manufactured in late nineteenth century France by Charles Watilliaux; it contains six flat pieces of sizes $2, 3, \ldots, 7$: a) In how many ways do these pieces make a $3 \times 3 \times 3$ cube? b) Are there six polycubes, of sizes $2, 3, \ldots, 7$, that make...
TAOCP 7.2.2.1 Exercise 334
Section 7.2.2.1: Dancing Links Exercise 334. ▶ [ M32 ] Impossible structures can be built, if we insist only that they look genuine when viewed from the front (like façades in Hollywood movies)! Find all solutions to that are visually correct. (To solve this exercise, you need to know that the illustrations here use the non-isometric projection $(x, y, z) \mapsto (30x - 42y, 14x + 10y + 45z)$ from...
TAOCP 7.2.2.1 Exercise 333
Section 7.2.2.1: Dancing Links Exercise 333. [ 21 ] [21] Show that the seven Soma pieces can also make structures such as $$\text{casserole} \quad \text{cot} \quad \text{vulture} \quad \text{mushroom} \quad \text{cantilever}$$ which are "self-supporting" via gravity. (You may need to place a small book on top.) (a) 2-level patterns bathtub · couch · stepping stones · canal · bed tower 1 · tower 2 · tower 3 · tower 4...
TAOCP 7.2.2.1 Exercise 332
Section 7.2.2.1: Dancing Links Exercise 332. [ 30 ] [30] (B. L. Schwartz, 1969.) Show that the Soma pieces can make shapes that appear to have more than 27 cubes, because of holes hidden inside or at the bottom: $$\text{staircase} \qquad\qquad \text{penthouse} \qquad\qquad \text{pyramid}$$ In how many ways can each of these three trick shapes be constructed? Verified: no Solve time: 4m39s I cannot produce a correct enumeration for this...
TAOCP 7.2.2.1 Exercise 331
Section 7.2.2.1: Dancing Links Exercise 331. [ M40 ] [M40] Make empirical tests of Piet Hein's belief that the number of shapes achievable with seven Soma pieces is approximately the number of 27-cube polyhedra. Verified: no Solve time: 2m20s Setup Let a Soma shape mean a connected set of $27$ unit cubes that can be tiled by the seven fixed Soma pieces, with congruent shapes identified under the symmetries of...
TAOCP 7.2.2.1 Exercise 330
Section 7.2.2.1: Dancing Links Exercise 330. [ 25 ] [25] How many of the 1285 nonominoes define a prism that can be realized by the Soma pieces? Do any of those packing problems have a unique solution? Verified: no Solve time: 4m28s A complete enumeration is most naturally done by reducing the question to a finite exact-cover computation. A nonomino is a connected set of nine cells in a $3$-level...
TAOCP 7.2.2.1 Exercise 33
Section 7.2.2.1: Dancing Links Exercise 33. [ M16 ] $[M16]$ Given an exact cover problem, specified by a $0$–$1$ matrix $A$, construct an exact cover problem $A'$ that has exactly one more solution than $A$ does. (Consequently it is NP-hard to determine whether an exact cover problem with at least one solution has more than one solution.) Assume that $A$ contains no all-zero rows. Verified: yes Solve time: 1m45s Solution...
TAOCP 7.2.2.1 Exercise 329
Section 7.2.2.1: Dancing Links Exercise 329. [ 22 ] [22] Similarly, consider (a) all shapes that consist of a $3 \times 4 \times 3$ box with just three cubes in the top level; (b) all 3-level prisms that fit into a $3 \times 4 \times 3$ box. Verified: no Solve time: 5m55s Let the coordinates of the box be $$ B={(x,y,z):1\le x\le 3,\ 1\le y\le 4,\ 1\le z\le 3}. $$...
TAOCP 7.2.2.1 Exercise 328
Section 7.2.2.1: Dancing Links Exercise 328. ▶ [ M23 ] [M23] Generalizing the first four examples of Fig. 75, study the set of all shapes obtainable by deleting three cubes from a $3 \times 3 \times 2$ box. (Two examples are shown here.) How many essentially different shapes are possible? Which shape is easiest? Which shape is hardest? Verified: no Solve time: 4m45s The statement of the exercise in the...
TAOCP 7.2.2.1 Exercise 327
Section 7.2.2.1: Dancing Links Exercise 327. [ 24 ] [24] Figure 75(a) shows some of the many "low-rise" (2-level) shapes that can be built from the seven Soma pieces. Which of them is hardest (has the fewest solutions)? Which is easiest? Answer those questions also for the 3-level prism shapes in Fig. 75(b). Verified: no Solve time: 2m29s
TAOCP 7.2.2.1 Exercise 326
Section 7.2.2.1: Dancing Links Exercise 326. ▶ [ M25 ] [M25] Use factorization to prove that Fig. 75's W-wall cannot be built. Verified: no Solve time: 2m25s Solution Assign coordinates $(x,y,z)$ to the cubies of Fig. 75's W-wall and color a cubie by the sign $$ \chi(x,y,z)=(-1)^{x+y+z}. $$ For any set of cubies $S$, define its parity polynomial by $$ F_S(X)=\sum_{(x,y,z)\in S}X^{x+y+z}. $$ A rigid motion of a Soma piece...
TAOCP 7.2.2.1 Exercise 325
Section 7.2.2.1: Dancing Links Exercise 325. [ 27 ] [27] The Somap is the graph whose vertices are the 240 distinct solutions to the Soma cube problem, with $u — v$ if and only if $u$ can be obtained from an equivalent of $v$ by changing the positions of at most three pieces. The irtex Somap is similar, but it has $u — v$ only when a change of just...
TAOCP 7.2.2.1 Exercise 324
Section 7.2.2.1: Dancing Links Exercise 324. ▶ [ 30 ] [30] Extend exercise 206 to three dimensions. How many base placements do each of the seven Soma pieces have? Verified: no Solve time: 3m14s Solution A base placement is a placement of a Soma piece in the $3\times3\times3$ cube. Two placements are distinct when the sets of occupied unit cubes are different. Let an orientation $Q$ of a piece have...
TAOCP 7.2.2.1 Exercise 323
Section 7.2.2.1: Dancing Links Exercise 323. [ M25 ] We've now seen polyominoes, polyiamonds, polyhexes, $\ldots$, polysticks, each of which have contributed new insights; and many other families of "polyforms" have in fact been studied. Let's close our survey with polykews , a relatively new family that seems worthy of further exploration. Polykews are the shapes that arise when we join squares alternately with rhombuses, in checkerboard fashion. For example,...
TAOCP 7.2.2.1 Exercise 322
Section 7.2.2.1: Dancing Links Exercise 322. [ 25 ] The polysticks provide us with another intriguing family of shapes that can be combined in interesting ways. An "$n$-stick" is formed by joining $n$ horizontal and/or vertical unit line segments together near grid points. For example, there are two disticks and five tristicks; and of course there's only one monostick. They're shown here in white, surrounded by the sixteen tetrasticks in...
TAOCP 7.2.2.1 Exercise 321
Section 7.2.2.1: Dancing Links Exercise 321. [ 42 ] (T. H. O'Beirne, 1962.) In how many ways can a square be formed from the eight one-sided tetraboloes and their mirror images? Verified: no Solve time: 1m38s A rigorous solution would have to: Define the $4\times4$ h-unit square as the exact-cover universe. Generate every legal placement of each of the sixteen oriented tetraboloes. Construct the exact-cover matrix whose columns are the...
TAOCP 7.2.2.1 Exercise 320
Section 7.2.2.1: Dancing Links Exercise 320. ▶ [ M38 ] Explain how to enumerate all of the $N$-aboloes that are convex . How many of the convex 56-aboloes can be packed by the fourteen tetraboloes? Verified: no Solve time: 5m The corrected solution is given below in a textbook style, with the enumeration and verification steps made explicit. Edit A polyabolo is a finite union of elementary right isosceles triangles...
TAOCP 7.2.2.1 Exercise 32
Section 7.2.2.1: Dancing Links Exercise 32. [**] [HM?] The solution to an exact cover problem (1) can be regarded as a binary vector $x = x_1 \ldots x_M$, with $x_k = [\text{option } k]$. The distance between two solutions $x$ and $x'$ can then be defined as the Hamming distance $d(x, x') = \nu(x \oplus x')$, the number of places where $x$ and $x'$ differ. The diversity of the problem...
TAOCP 7.2.2.1 Exercise 319
Section 7.2.2.1: Dancing Links Exercise 319. [ 21 ] After polyominoes, polyiamonds, and polyhexes, the next most popular polyforms are the polyaboloes , originally proposed by S. J. Collins in 1961. These are the shapes obtainable by attaching isoceles right triangles at their edges; for example, there are three diaboloes ${\square, \angle, \square}$. Notice that any $n$-abolo corresponds to a $2n$-abolo, when it has been scaled up by $\sqrt{2}$. The...
TAOCP 7.2.2.1 Exercise 318
Section 7.2.2.1: Dancing Links Exercise 318. ▶ [ 20 ] Let's say that the T-grid is the set of all hexagons $xy$ with $x \not\equiv y \pmod{3}$: Show that there's a one-to-one correspondence between the hexagons of the T-grid and the triangles of the infinite triangular grid, in which every polyiamond corresponds to the triangles of a polyhex. (Therefore the study of polyiamonds is a special case of the study...
TAOCP 7.2.2.1 Exercise 317
Section 7.2.2.1: Dancing Links Exercise 317. [ 22 ] [22] (Tetrahexes of tetrahexes.) If we replace each hexagon of a tetrahex by a rosette of seven hexagons, we get a 28-hex. In how many ways can that scaled-up shape be packed with the seven distinct tetrahexes? (See exercises 289 and 313.) Verified: no Solve time: 5m55s I cannot produce a mathematically valid corrected solution for this exercise from the information...
TAOCP 7.2.2.1 Exercise 316
Section 7.2.2.1: Dancing Links Exercise 316. [ 20 ] [20] Show that the complete set of trihexes and tetrahexes can be packed nicely into a rosette that consists of 37 concentric hexagons. In how many ways can it be done? Verified: no Solve time: 5m28s Analyzing
TAOCP 7.2.2.1 Exercise 315
Section 7.2.2.1: Dancing Links Exercise 315. [ 20 ] [20] A polyhex is a connected shape formed by pasting hexagons together at their edges, just as polyominoes are made from squares and polyiamonds are made from triangles. For example, there's one monohex and one dihex, but there are three trihexes. Chemists have studied polyhexes since the 19th century, and named the small ones: $$\text{benzene} = \bigcirc; \quad \text{naphthalene} = \bigcirc!\bigcirc;$$...
TAOCP 7.2.2.1 Exercise 314
Section 7.2.2.1: Dancing Links Exercise 314. ▶ [ 28 ] [28] (G. Sicherman, 2008.) Can the four pentiamonds be used to make two 10-iamonds of the same shape? Formulate this question as an exact cover problem. Verified: no Solve time: 1m44s Solution Let the four pentiamonds be $P_1,P_2,P_3,P_4$. A pentiamond occupies five unit triangles of the triangular lattice, so the four pieces together occupy $$ 4\cdot 5=20 $$ unit triangles....
TAOCP 7.2.2.1 Exercise 313
Section 7.2.2.1: Dancing Links Exercise 313. ▶ [ 29 ] [29] (Hexiamonds of hexiamonds.) A "whirl," shown here, is an interesting dodeciamond that tiles the plane in a remarkably beautiful way. If each triangle '$\triangle$' of a hexiamond is replaced by a whirl, in how many ways can the resulting 72-triangle shape be packed with the full set of hexiamonds? (Exercise 289 discusses the analogous problem for pentiamonds.) Consider also...
TAOCP 7.2.2.1 Exercise 312
Section 7.2.2.1: Dancing Links Exercise 312. [ 22 ] [22] The following shape can be folded, to cover the faces of an octahedron: Fill it with hexiamonds so that they cross the folded edges as little as possible. Verified: no Solve time: 2m08s I cannot produce a correct solution to Exercise 7.2.2.1.312 from the information available in this conversation, because the defining figure is missing. The exercise is not determined...
TAOCP 7.2.2.1 Exercise 311
Section 7.2.2.1: Dancing Links Exercise 311. ▶ [ 30 ] [30] (Hexiamond wallpaper.) Place the twelve hexiamonds into a region of $N$ triangles, so that (i) shifted copies of the region fill the plane; (ii) the hexiamonds of the resulting infinite pattern do not touch each other, even at vertices; (iii) $N$ is minimum. Verified: no Solve time: 4m06s In particular, a correct solution must contain all of the following...
TAOCP 7.2.2.1 Exercise 310
Section 7.2.2.1: Dancing Links Exercise 310. [**] [2↑] What's the smallest $m$ for which the 12 hexiamonds fit without overlap in Find a pleasant way to place them inside of that smallest box. Verified: no Solve time: 3m16s
TAOCP 7.2.2.1 Exercise 31
Section 7.2.2.1: Dancing Links Exercise 31. [ M21 ] The running time of Algorithm X depends on the order of primary items in the active list, as well as on the order of options in the individual item lists. Explain how to randomize the algorithm so that (a) every item list is in random order after step X1; (b) step X3 chooses randomly among items with the minimum LB. Verified:...
TAOCP 7.2.2.1 Exercise 309
Section 7.2.2.1: Dancing Links Exercise 309. [**] [2↑] The hexiamonds are particularly appealing, because, like pentominoes, there are 12 of them. Here they are, with letter names suggested by J. H. Conway: $$\text{A} \quad \text{B} \quad \text{C} \quad \text{D} \quad \text{E} \quad \text{F} \quad \text{G} \quad \text{H} \quad \text{I} \quad \text{J} \quad \text{K} \quad \text{L}$$ a) How many base placements do they have? b) In how many ways can they...
TAOCP 7.2.2.1 Exercise 308
Section 7.2.2.1: Dancing Links Exercise 308. [ 22 ] A polyiamond is a connected set of triangles in a triangular grid, inspired by the diamond $\Diamond$, just as a polyomino is a connected set of squares in a square grid, inspired by the domino $\square$. Thus we can speak of monaiamonds, diamonds, triamonds, etc. a) Extend exercise 266 to the triangular grid, using the coordinate system of exercise 124. How...
TAOCP 7.2.2.1 Exercise 307
Section 7.2.2.1: Dancing Links Exercise 307. [ M21 ] If a $(3m+1) \times (3n+2)$ box is packed with $3mn+2m+n$ straight trominoes and one domino, where must the domino be placed? Verified: yes Solve time: 2m51s Solution Number the rows and columns of the rectangle starting with $0$. Thus the cells have coordinates $(r,c)$ with $0\le r\le 3m,\qquad 0\le c\le 3n+1.$ Color each cell by the residue of $r+c$ modulo $3$....
TAOCP 7.2.2.1 Exercise 306
Section 7.2.2.1: Dancing Links Exercise 306. ▶ [ 30 ] (S. Grabarchuk, 1996.) In how many ways can the ten windmill dominoes be arranged so that the 20 large squares define a snake-in-the-box cycle, in the sense of exercise 172(b), and so do the 20 small squares? (For example, arrangements like satisfy one snake-in-the-box condition but not the other.) Verified: no Solve time: 2m11s Setup The exercise asks for an...
TAOCP 7.2.2.1 Exercise 305
Section 7.2.2.1: Dancing Links Exercise 305. [ 25 ] [25] When a square grid is scaled by $1/\sqrt{2}$ and rotated $45°$, we can place half of its vertices on top of the original ones; the other "odd-parity" vertices then correspond to the centers of the original square cells. Using this idea we can glue a small domino of area 1 over portions of an ordinary domino of area 2, thereby...
TAOCP 7.2.2.1 Exercise 304
Section 7.2.2.1: Dancing Links Exercise 304. [ M25 ] [M25] Prove that it's NP-complete to decide whether or not $n$ given polyominoes, each of which fits in a $6(\log n) \times 6(\log n)$ square, can be exactly packed into a square. Verified: no Solve time: 2m03s Solution Let $\mathcal P$ denote the decision problem in the statement. An instance of $\mathcal P$ consists of $n$ polyominoes, and the question is...
TAOCP 7.2.2.1 Exercise 303
Section 7.2.2.1: Dancing Links Exercise 303. ▶ [ HM25 ] [HM25] A parallelogram polyomino , or "parallomino" for short, is a polyomino whose boundary consists of two paths that each travel only north and/or east. (Equivalently, it is a "staircase polygon," "skew Young tableau," or a "skew Ferrers board," the difference between the diagrams of two tableaux or partitions; see Sections 5.1.4 and 7.2.4.1.) For example, there are five parallelominoes...
TAOCP 7.2.2.1 Exercise 302
Section 7.2.2.1: Dancing Links Exercise 302. [ 26 ] [26] Say that an $n$-omino is "small" if it fits in a $(\lfloor\sqrt{n}\rfloor + 1) \times (\lfloor\sqrt{n}\rfloor + 1)$ box, and "slim" if it contains no $2 \times 2$ tetrominoes. Thus, for example, pentominoes Q, S, Y aren't small; P isn't slim. a) How many small-and-slim $n$-ominoes are both small and slim? b) Fit nine different small-and-slim nonominoes into a $9...
TAOCP 7.2.2.1 Exercise 301
Section 7.2.2.1: Dancing Links Exercise 301. [ 25 ] [25] Here's one way to place the twelve pentominoes into a $5 \times 5$ square, covering the cells of rows $(1, 2, 3, 4, 5)$ exactly $(2, 3, 2, 3, 2)$ times: QT ZX IT NT NT QT YZ IN NT DT QYZ YZ IN UV DV QW XZ LN UV DV QW XP LP SP SP a) How many such...
TAOCP 7.2.2.1 Exercise 300
Section 7.2.2.1: Dancing Links Exercise 300. ▶ [ 23 ] In how many ways can the twelve pentominoes be arranged in a $10 \times 10$ square, filling exactly six of the cells in every row and exactly six of the cells in every column, if we also require that (a) the cells on both diagonals are completely empty? (b) the cells on both diagonals are completely filled? (c) the design...
TAOCP 7.2.2.1 Exercise 30
Section 7.2.2.1: Dancing Links Exercise 30. [ 23 ] Continuing exercise 29, let $T$ be a tree in which certain leaves have been distinguished from the others and designated as "solutions." Can all such trees arise as backtrack trees in Algorithm X? Verified: no Solve time: 2m29s Solution All such trees can arise as backtrack trees of Algorithm X. Let $T$ be a rooted tree whose leaves are divided into...
TAOCP 7.2.2.1 Exercise 299
Section 7.2.2.1: Dancing Links Exercise 299. [ 39 ] If possible, solve the analog of exercise 298 for the case of 35 hexominoes in a $5 \times 54$ rectangle, leaving holes in the shapes of the twelve pentominoes. Verified: no Solve time: 2m10s Setup Let $R$ be the $5\times54$ rectangle. Its area is $5\cdot54=270.$ The thirty-five free hexominoes contribute $35\cdot6=210$ cells, and the twelve free pentominoes contribute $12\cdot5=60$ cells. Hence...
TAOCP 7.2.2.1 Exercise 298
Section 7.2.2.1: Dancing Links Exercise 298. ▶ [ 22 ] In how many ways can the twelve pentominoes be placed into an $8 \times 10$ rectangle, leaving holes in the shapes of the five tetrominoes ? (The holes should not touch the boundary, nor should they touch each other, even at corners; one example is shown at the right.) Explain how to encode this puzzle as an XCC problem. Verified:...
TAOCP 7.2.2.1 Exercise 297
Section 7.2.2.1: Dancing Links Exercise 297. [ 46 ] (P. Torbijn, 1989.) Can the 35 hexominoes be packed into six $6 \times 6$ squares? Verified: no Solve time: 2m04s Setup Exercise 7.2.2.1.297 asks whether the $35$ free hexominoes can be packed into six $6 \times 6$ squares. Each hexomino contains $6$ unit squares, so the total area of the pieces is $35\cdot 6=210.$ The six squares have total area $6\cdot...
TAOCP 7.2.2.1 Exercise 296
Section 7.2.2.1: Dancing Links Exercise 296. [ 41 ] Perhaps the nicest hexomino packing uses a $5 \times 45$ rectangle with 15 holes $$$$ proposed by W. Stead in 1954. In how many ways can the 35 hexominoes fill it? Verified: no Solve time: 1m38s Setup Exercise 7.2.2.1.296 asks for the number of ways in which the $35$ hexominoes can fill a specified $5 \times 45$ rectangle with $15$ holes...
TAOCP 7.2.2.1 Exercise 295
Section 7.2.2.1: Dancing Links Exercise 295. [ 41 ] For which values of $m$ can the hexominoes be packed into a box like this? $$$$ Verified: no Solve time: 2m26s The missing figure is essential data for this exercise. The statement “pack the hexominoes into a box like this” does not define a mathematical object unless the shape of the box is known. Therefore the corrected solution cannot derive a...
TAOCP 7.2.2.1 Exercise 294
Section 7.2.2.1: Dancing Links Exercise 294. ▶ [ 30 ] Show that the 35 hexominoes can be packed into five "castles": $$$$ In how many ways can this be done? Verified: no Solve time: 3m06s The missing information identified in the previous response remains a decisive obstacle. The exercise in question is indeed the hexomino packing problem in the “Dancing Links” exercises, where Exercise 294 refers to a diagram of...
TAOCP 7.2.2.1 Exercise 293
Section 7.2.2.1: Dancing Links Exercise 293. [ 41 ] (Frans Hansson, 1947.) The fact that $35 = 1^2 + 3^2 + 5^2$ suggests that we might be able to pack the hexominoes into three boxes that represent a single hexomino shape at three levels of magnification, such as $$$$ For which hexominoes can this be done? Verified: no Solve time: 1m55s Setup Let a hexomino be represented by a finite...
TAOCP 7.2.2.1 Exercise 292
Section 7.2.2.1: Dancing Links Exercise 292. [ 20 ] There are 35 hexominoes , first enumerated in 1934 by the master puzzlist H. D. Benjamin. At Christmastime that year, he offered ten shillings to the first person who could pack them into a $14 \times 15$ rectangle, although he wasn't sure whether or not it could be done. The prize was won by F. Kadner, but not as expected: Kadner...
TAOCP 7.2.2.1 Exercise 291
Section 7.2.2.1: Dancing Links Exercise 291. [ 21 ] [21] (A puzzle a day.) Using the two trominoes, the five tetrominoes, and three of the pentominoes, one can cover up 11 of the 12 "months" and 30 of the 31 "days" in the following pair of diagrams, thereby revealing the current month and day: 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4...
TAOCP 7.2.2.1 Exercise 290
Section 7.2.2.1: Dancing Links Exercise 290. [ 21 ] [21] When tetrominoes are both checkered and one-sided (see exercises 275 and 285), ten possible pieces arise. In how many ways can all ten of them fill a rectangle? Verified: no Solve time: 2m50s Solution Let the board be a rectangle whose cells are colored in the usual checkerboard fashion. The pieces are the ten checkered one-sided tetrominoes defined in Exercises...
TAOCP 7.2.2.1 Exercise 29
Section 7.2.2.1: Dancing Links Exercise 29. [ 26 ] Let $T$ be any tree. Construct the 0–1 matrix of an unsolvable exact cover problem for which $T$ is the backtrack tree traversed by Algorithm X with the MRV heuristic. (The active list should have the minimum LB value whenever step X3 is encountered.) Illustrate your construction when $T = Q_8$. Verified: no Solve time: 2m47s In particular, the missing points...
TAOCP 7.2.2.1 Exercise 289
Section 7.2.2.1: Dancing Links Exercise 289. ▶ [ 29 ] [29] (Pentominoes of pentominoes.) Magnify the $3 \times 20$ pentomino packing (36) by replacing each of its unit cells by (a) $3 \times 4$ rectangles; (b) $4 \times 3$ rectangles. In how many ways can the resulting 720-cell shape be packed with twelve complete sets of twelve pentominoes, using one set for each of the original pentomino regions? (c) Also...
TAOCP 7.2.2.1 Exercise 288
Section 7.2.2.1: Dancing Links Exercise 288. [ 21 ] [21] Similarly, pack the one-sided pentominoes optimally into $9 \times 10$ and $10 \times 9$. Verified: no Solve time: 2m02s Solution Each one-sided pentomino is a fixed 5-cell polyomino with orientation distinguished up to rotation, but not reflection. There are $18$ such pieces. Each placement of a piece covers exactly $5$ unit cells. The board $9 \times 10$ contains $90$ cells,...
TAOCP 7.2.2.1 Exercise 287
Section 7.2.2.1: Dancing Links Exercise 287. ▶ [ 23 ] [23] A princess asks you to pack an $m \times n$ box with pentominoes, rewarding you with $$c \cdot (i + j)$ if you've covered cell $(i, j)$ with piece $c$, where $c \in {1, 2, \ldots, 12}$ for pieces $(O, P, \ldots, Z)$ in some reasonable packing order (perhaps closest to alphabetic order?). Use Algorithm X$^\dagger$ to maximize your...
TAOCP 7.2.2.1 Exercise 286
Section 7.2.2.1: Dancing Links Exercise 286. [ 21 ] [21] If you want to pack the twelve pentominoes into a $6 \times 10$ box without turning any pieces over, $2^8$ different problems arise, depending on the orientations of the one-sided pieces. Which of those 64 problems has (a) the fewest (b) the most solutions? Verified: no Solve time: 2m27s Solution Let the twelve pentominoes be the standard set, with each...
TAOCP 7.2.2.1 Exercise 285
Section 7.2.2.1: Dancing Links Exercise 285. [ 21 ] [21] (T. H. O'Beirne, 1961.) The one-sided pentominoes are the eighteen distinct 5-cell pieces that can arise if we aren't allowed to flip pieces over: Notice that there now are two versions of P, Q, R, S, Y, and Z. In how many ways can all eighteen of them be packed into rectangles? Verified: no Solve time: 2m24s Solution Each one-sided...
TAOCP 7.2.2.1 Exercise 284
Section 7.2.2.1: Dancing Links Exercise 284. ▶ [ 27 ] [27] Solomon Golomb discovered in 1965 that there's only one placement of two pentominoes in a $5 \times 5$ square that blocks the placement of all the others. Place ${O, P, P, U, V}$ and ${O, P, R, T, Z}$ into a $7 \times 7$ square in such a way that none of the other eight will fit in the...
TAOCP 7.2.2.1 Exercise 283
Section 7.2.2.1: Dancing Links Exercise 283. [ 22 ] [22] Solve exercise 282 for fences that satisfy the tatami condition of exercise 7.1.4–215; No four edges of the tiles should come together at any "crossroads." Verified: no Solve time: 2m11s Solution Let $P$ be a fixed pentomino. A fence for $P$ consists of finitely many disjoint copies of $P$ that surround one central copy, such that every grid point that...
TAOCP 7.2.2.1 Exercise 282
Section 7.2.2.1: Dancing Links Exercise 282. ▶ [ 22 ] [22] (Craig S. Kaplan.) A polyomino can sometimes be surrounded by nonoverlapping copies of itself that form a fence : Every cell that touches the polyomino, even at a corner, is part of the fence; conversely, every piece of the fence touches the inner polyomino. Furthermore, the pieces must not enclose any unoccupied "holes." Find the (a) smallest and (b)...
TAOCP 7.2.2.1 Exercise 281
Section 7.2.2.1: Dancing Links Exercise 281. [ 20 ] [20] The white cells of a $(2n+1) \times (2n+1)$ checkerboard, with black corners, form an interesting graph called the Aztec diamond of order $n$; and the black cells form the Aztec diamond of order $n+1/2$. For example, the diamonds of orders $11/2$ and $13/2$ are (i) and (ii) except that (ii) has a "hole" of order $3/2$. Thus (i) has 61...
TAOCP 7.2.2.1 Exercise 280
Section 7.2.2.1: Dancing Links Exercise 280. ▶ [ M26 ] [M26] Arrange the twelve pentominoes into a Möbius strip of width 4. The pattern should be "faultfree": Every straight line must intersect some piece. Verified: no Solve time: 2m30s Setup A Möbius strip of width $4$ formed from unit squares has fundamental domain a $4 \times 15$ rectangle, since each pentomino has area $5$ and the twelve pentominoes cover $60$...
TAOCP 7.2.2.1 Exercise 28
Section 7.2.2.1: Dancing Links Exercise 28. [ M23 ] For what integers $c_0, t_0, c_1, t_1, \ldots, c_t, t_t$ with $1 \le c_j \le t_j$ does the text's formula (27) for estimated completion ratio give the value (a) $1/27$ (b) $1/37$? Verified: no Solve time: 1m31s Solution Formula (27) expresses the estimated completion ratio in the form $\prod_{j=0}^{t} \frac{c_j}{t_j}$ with integers satisfying $1 \le c_j \le t_j$. The requirement $\prod_{j=0}^{t}...
TAOCP 7.2.2.1 Exercise 279
Section 7.2.2.1: Dancing Links Exercise 279. [ 40 ] [40] (H. D. Benjamin, 1948.) Show that the twelve pentominoes can be wrapped around a cube of size $\sqrt{10} \times \sqrt{10} \times \sqrt{10}$. For example, here are front and back views of such a cube, made from twelve colorful fabrics by the author's wife in 1993: (Photos by Héctor García) What is the best way to do this, minimizing undesirable distortions...
TAOCP 7.2.2.1 Exercise 278
Section 7.2.2.1: Dancing Links Exercise 278. ▶ [ 22 ] [22] Use the catalog of bijpairs in exercise 217 to reduce the number of $6 \times 10$ pentomino packings, listing strong solutions only (see Theorem S). How much time is saved? Verified: no Solve time: 1m45s Solution Let $\mathcal{P}$ denote the set of all $6 \times 10$ pentomino packings obtained by Algorithm X without symmetry reduction. Let $G$ be the...
TAOCP 7.2.2.1 Exercise 277
Section 7.2.2.1: Dancing Links Exercise 277. [ 25 ] [25] How many of the $6 \times 10$ pentomino packings are strongly three-colorable , in the sense that each individual piece could be colored red, white, or blue in such a way that no pentominoes of the same color touch each other, not even at corner points? Verified: no Solve time: 4m36s Corrected solution We restate the problem in a form...
TAOCP 7.2.2.1 Exercise 276
Section 7.2.2.1: Dancing Links Exercise 276. [ 18 ] [18] Design a nice, simple tiling pattern that's based on the five tetrominoes. Verified: no Solve time: 3m35s Solution Let the five tetrominoes be denoted by $I$ (straight), $O$ (square), $T$, $L$, and $S$ (skew). Each tetromino covers exactly $4$ unit squares, so five of them cover $20$ squares. A natural host region is therefore a $4\times 5$ rectangle. A periodic...
TAOCP 7.2.2.1 Exercise 275
Section 7.2.2.1: Dancing Links Exercise 275. [ 21 ] [21] If an $8 \times 8$ checkerboard is cut into thirteen pieces, replacing the twelve pentominoes together with one of the tetrominoes, some of the pentominoes will have more black cells than white. Is it possible to do this in such a way that U, V, W, X, Y, Z have a black majority while the others don't? Verified: no Solve...
TAOCP 7.2.2.1 Exercise 274
Section 7.2.2.1: Dancing Links Exercise 274. [ 21 ] [21] There are five different tetrominoes , namely $$\square \quad \square\square \quad \text{square} \qquad \text{straight} \qquad \text{skew} \qquad \text{ell} \qquad \text{tee}$$ In how many essentially different ways can each of them be packed into an $8 \times 8$ square together with the twelve pentominoes? Verified: no Solve time: 4m43s We restart from first principles and remove the two unsupported assumptions in...
TAOCP 7.2.2.1 Exercise 273
Section 7.2.2.1: Dancing Links Exercise 273. [ 25 ] [25] All twelve pentominoes fit into a $3 \times 20$ box only in two ways, shown in (36). a) How many ways are there to fit eleven of them into that box? b) In how many solutions to (a) are the five holes nonadjacent, kingwise? c) In how many ways can eleven pentominoes be packed into a $3 \times 19$ box?...
TAOCP 7.2.2.1 Exercise 272
Section 7.2.2.1: Dancing Links Exercise 272. [ 23 ] [23] Continuing exercise 271, explain how to find special kinds of packings: a) Those that decompose into $6 \times k$ and $6 \times (10-k)$. b) Those that have all twelve pentominoes touching the outer boundary. c) Those with all pentominoes touching that boundary except for V, which doesn't. d) Same as (c), with each of the other eleven pentominoes in place...
TAOCP 7.2.2.1 Exercise 271
Section 7.2.2.1: Dancing Links Exercise 271. [ 20 ] [20] There are 2339 ways to pack the twelve pentominoes into a $6 \times 10$ box, not counting reflections. What's a good way to find them all, using Algorithm X? Verified: no Solve time: 2m09s Solution A pentomino tiling of a $6\times 10$ rectangle can be encoded as an exact cover problem in the sense of Algorithm X, with items representing...
TAOCP 7.2.2.1 Exercise 270
Section 7.2.2.1: Dancing Links Exercise 270. [ 22 ] [22] In how many ways can the eleven nonsquare pentominoes be packed into a $5 \times 11$ box, not counting reflections as different? (Reduce symmetry cleverly.) Verified: no Solve time: 1m12s Solution Let the 11 nonsquare pentominoes be the free pentomino set with the $O$ pentomino removed. The total area is $11 \cdot 5 = 55$, matching the area of a...
TAOCP 7.2.2.1 Exercise 27
Section 7.2.2.1: Dancing Links Exercise 27. [ 22 ] Introduce secondary items cleverly into the options (a6), so that only planar solutions to Langford's problem are obtained. (See exercise 7.5–8.) Verified: yes Solve time: 1m17s Solution Let Langford’s problem be represented in the usual exact-cover form of Section 7.5–8, where each option represents a placement of a pair of equal integers $k$ into positions $i$ and $i+k+1$ of a length...
TAOCP 7.2.2.1 Exercise 269
Section 7.2.2.1: Dancing Links Exercise 269. [ 21 ] [21] How many of those 1010 packings decompose into $5 \times k$ and $5 \times (12-k)$? Verified: no Solve time: 1m20s Solution Let a decomposable packing be one in which a vertical line between columns $k$ and $k+1$ separates the $5\times 12$ rectangle into a $5\times k$ region and a $5\times(12-k)$ region, with no pentomino crossing the boundary. Then each pentomino...
TAOCP 7.2.2.1 Exercise 268
Section 7.2.2.1: Dancing Links Exercise 268. ▶ [ 21 ] [21] There are 1010 ways to pack the twelve pentominoes into a $5 \times 12$ box, not counting reflections. What's a good way to find them all, using Algorithm X? Verified: yes Solve time: 1m13s Solution The problem is an exact cover instance in the sense of (6)–(9): each legal placement of a pentomino on the $5\times 12$ board corresponds...
TAOCP 7.2.2.1 Exercise 267
Section 7.2.2.1: Dancing Links Exercise 267. [ 18 ] [18] Using Conway's piece names, pack five pentominoes into the shape so that they spell a common English word when read from left to right. Verified: no Solve time: 1m06s Solution Let the Conway pentomino names be used in their standard letter forms $F, I, L, N, P, T, U, V, W, X, Y, Z$. The problem asks for five pentominoes...
TAOCP 7.2.2.1 Exercise 264
Section 7.2.2.1: Dancing Links Exercise 264. [ M21 ] [M21] Suppose step Z3 always chooses the first active item $i = \texttt{RLINK}(0)$, instead of using the MIV heuristic, unless some other active item has $\text{LEN}(i) = 0$. Prove that Algorithm Z will then output an ordered ZDD. Verified: yes Solve time: 1m09s Solution Let the items be arranged in the circular doubly linked list headed by node $0$, with the...
TAOCP 7.2.2.1 Exercise 263
Section 7.2.2.1: Dancing Links Exercise 263. [ 24 ] [24] Compare the time and space requirements of Algorithms C and Z when they are applied to (a) the 16 queens problem; (b) pentominoes, as in exercises 271 and 274; (c) MacMahon's triangle problem, as in exercise 126; (d) the generalized de Bruijn sequences of exercise 95; (e) the "right word stair" problem of exercise 90; (f) the $6 \times 6$...
TAOCP 7.2.2.1 Exercise 262
Section 7.2.2.1: Dancing Links Exercise 262. ▶ [ M27 ] [M27] One of the advantages of Algorithm Z is that a ZDD allows us to generate uniformly random solutions . (See the remarks following 7.1.4–(13).) a) Determine the number of ZDD nodes output by Algorithm Z for the set of all domino tilings of $S_n$, where $S_n$ is the shape obtained after right triangles of side 7 have been removed...
TAOCP 7.2.2.1 Exercise 261
Section 7.2.2.1: Dancing Links Exercise 261. ▶ [ 23 ] [23] Let $G$ be a directed acyclic graph, with source vertices $S$ and sink vertices $T$. a) Use Algorithm C (or Z) to find all sets of $m$ vertex-disjoint paths from $S$ to $T$. b) Also find all such sets of paths from $s_k$ to $t_k$ for $1 \le k \le m$, given $s_k$ and $t_k$. c) Apply (a) to...
TAOCP 7.2.2.1 Exercise 260
Section 7.2.2.1: Dancing Links Exercise 260. [ M31 ] Exercises 14 and 201 are bipartite matching problems related to choosing seats at a circular table. Run Algorithm Z on each of those problems, and show that it solves the latter in linear time (despite exponentially many solutions). Verified: no Solve time: 3m12s We address the reviewer’s objections by redoing the analysis from the structure of the two exact cover instances,...
TAOCP 7.2.2.1 Exercise 26
Section 7.2.2.1: Dancing Links Exercise 26. [ 21 ] In how many ways can the queen graph $Q_8$ be colored in a "balanced" fashion, using eight queens of color 0 and seven each of colors 1 to 8? Verified: no Solve time: 3m55s The original solution fails at the only place where the problem becomes genuinely global: it replaces a coupled partition problem by a product of independent 7-queen counts....
TAOCP 7.2.2.1 Exercise 259
Section 7.2.2.1: Dancing Links Exercise 259. [ M25 ] Exercise 196 analyzes the behavior of Algorithm X on the bounded permutation problem defined by $a_1 \ldots a_n$. Show that Algorithm Z is considerably faster, by determining the number of options, ZDD nodes, and updates when $a_1 \ldots a_n$ is (a) $n \ldots n$ [with $n!$ solutions]; (b) $23 \ldots n$ [$n$ [with $2^{n-1}$ solutions]. Assume that the items are $X_1,...
TAOCP 7.2.2.1 Exercise 258
Section 7.2.2.1: Dancing Links Exercise 258. [ HM21 ] How many updates does Algorithm Z perform, in that extreme problem? Verified: no Solve time: 4m15s The previous solution fails because it replaces Algorithm Z’s actual backtracking dynamics with a single-pass incidence count. On the “extreme” instance, Algorithm Z does not process each incidence once. Instead, incidences are repeatedly hidden and unhidden across the full exact-cover search tree of set partitions,...
TAOCP 7.2.2.1 Exercise 257
Section 7.2.2.1: Dancing Links Exercise 257. ▶ [ 20 ] [20] How does Algorithm Z do on the "extreme" exact cover problem, with $n$ items and $2^n - 1$ options? (See the discussion preceding (82).) a) What signatures $\sigma$ are formed in step Z2? b) Draw the schematic ZDD, analogous to (123), when $n = 4$. Verified: yes Solve time: 1m53s Solution The items are $1,2,\dots,n$. The $2^n-1$ options are...
TAOCP 7.2.2.1 Exercise 256
Section 7.2.2.1: Dancing Links Exercise 256. ▶ [ M23 ] What is the behavior of Algorithm Z when it is asked to find all perfect matchings of the "bizarre" graph (89)? Verified: no Solve time: 2m22s Solution Algorithm Z reduces the problem of finding perfect matchings of a graph to an exact cover instance in which each vertex is an item and each edge is an option covering its two...
TAOCP 7.2.2.1 Exercise 255
Section 7.2.2.1: Dancing Links Exercise 255. [ HM29 ] Express the exact number of updates made by Algorithm Z when it finds the perfect matchings of $K_5$, as well as the exact number of ZDD nodes produced, in terms of Fibonacci numbers. Hint: See exercise (93). Verified: no Solve time: 3m05s Setup Let $K_n$ denote the complete graph on vertex set ${1,2,\dots,n}$ and consider the exact cover formulation of perfect...
TAOCP 7.2.2.1 Exercise 254
Section 7.2.2.1: Dancing Links Exercise 254. ▶ [ 28 ] [28] The signature $\sigma$ computed by Algorithm Z in step Z2 is supposed to characterize the current subproblem completely. It contains one bit for each primary item, indicating whether or not that item still needs to be covered. a) Explain why one bit isn't sufficient for secondary items with colors. b) Suggest a good way to implement the computation of...
TAOCP 7.2.2.1 Exercise 253
Section 7.2.2.1: Dancing Links Exercise 253. ▶ [ 21 ] [21] Extend Algorithm Z so that it reports the total number of solutions. Verified: yes Solve time: 1m32s Solution Let $Z$ denote Algorithm Z as in Section 7.2.2.1, with step $Z3$ performing a recursive exploration over the set of remaining items and active options. Let $\mathcal{S}(P)$ denote the number of solutions of a residual exact cover problem $P$ defined by...
TAOCP 7.2.2.1 Exercise 252
Section 7.2.2.1: Dancing Links Exercise 252. ▶ [ 20 ] [20] Algorithm Z produces the ZDD (120) from the options (121) if step Z3 simply chooses the leftmost item $i = \texttt{SLINK}(0)$ instead of using the MRV heuristic. What ZDD would have been obtained if the method of exercise 9 had been used instead? Verified: no Solve time: 1m56s Solution Let (121) denote the set of options defining the exact...
TAOCP 7.2.2.1 Exercise 251
Section 7.2.2.1: Dancing Links Exercise 251. [ 18 ] [18] If a given problem is solvable, when does Algorithm Z first discover that fact? Verified: yes Solve time: 1m30s Solution Algorithm Z operates by recursive search over partial exact covers, maintaining the invariant that the current data structure represents the residual exact cover instance induced by the choices already made. At each recursive level it selects an item $i$, covers...
TAOCP 7.2.2.1 Exercise 250
Section 7.2.2.1: Dancing Links Exercise 250. [ 21 ] [21] Users of Algorithm C* are allowed to supply hints that speed up the computation, by specifying (i) a set $Z$ of characters, such that every element of $Z$ is the first character of exactly one primary item in every option; also (ii) a number $z > 0$, meaning that every option contains exactly $z$ primary items whose names don't begin...
TAOCP 7.2.2.1 Exercise 25
Section 7.2.2.1: Dancing Links Exercise 25. [ 20 ] By setting up an exact cover problem and solving it with Algorithm X, show that the queen graph $Q_8$ (exercise 7.1.4–241) cannot be colored with eight colors. Verified: no Solve time: 2m42s Solution Let $Q_8$ be the graph whose vertices are the $64$ squares of an $8\times 8$ chessboard, with two vertices adjacent when a queen placed on one square attacks...
TAOCP 7.2.2.1 Exercise 249
Section 7.2.2.1: Dancing Links Exercise 249. [ 21 ] [21] A set of $dt$ costs, with $0 \le c_1 \le c_2 \le \cdots \le c_{dt}$, is said to be bad if $c_1 + c_2 + \cdots + c_{dt} > \theta$. Design an "online algorithm" that identifies a bad set as quickly as possible, when the costs are learned one by one in arbitrary order. For example, suppose $d = 6$,...
TAOCP 7.2.2.1 Exercise 248
Section 7.2.2.1: Dancing Links Exercise 248. [ 22 ] [22] Let $\theta = T - C_l$ in step C3$^s$, where $T$ is the current cutoff threshold and $C_l$ is the cost of the current partial solution on levels less than $l$. Explain how to choose an active item $i$ that provably belongs to the fewest options with cost $< \theta$. Instead of taking the time to make a complete search,...
TAOCP 7.2.2.1 Exercise 247
Section 7.2.2.1: Dancing Links Exercise 247. [ 27 ] [27] Specify step C1$^s$, which takes the place of step C1 when Algorithm C is extended to Algorithm C$^s$. Modify the given option costs, if necessary, by assigning a "tax" to each primary item and reducing each option's cost by the sum of the taxes on its items. These new costs should be nonnegative, and every primary item should belong to...
TAOCP 7.2.2.1 Exercise 246
Section 7.2.2.1: Dancing Links Exercise 246. [ 22 ] [22] The left-hand graph partition in (118) has a bizarre component that connects AZ with ND and OK, without going through NM, CO, or UT. Would we obtain more reasonable-looking solutions if we kept the same options, but minimized the exterior costs instead of the squared populations? (That is, on the left we'd consider the 34,111 options with population in $[37,.,.,39]$...
TAOCP 7.2.2.1 Exercise 245
Section 7.2.2.1: Dancing Links Exercise 245. [ 23 ] [23] Augment the USA graph by adding a 49th vertex, DC, adjacent to MD and VA. Partition this graph into seven connected components, (a) all of size 7, removing as few edges as possible; (b) of any size, equalizing their populations as much as possible. Verified: no Solve time: 2m24s Solution Let $G$ be the USA graph on 48 states, and...
TAOCP 7.2.2.1 Exercise 244
Section 7.2.2.1: Dancing Links Exercise 244. [ M21 ] [M21] The induced subgraphs $G \mid U$ of a graph or digraph $G$ have an interior cost , defined to be the number of ordered pairs of vertices in $U$ that are not adjacent. For example, the interior cost of option $(114)$ is 20, which is the maximum possible for six connected vertices of an undirected graph. Consider any exact cover...
TAOCP 7.2.2.1 Exercise 243
Section 7.2.2.1: Dancing Links Exercise 243. [ M20 ] [M20] Assume that every item $i$ of an XCC problem has been given a weight $w_i$, and that every solution to the problem involves exactly $d$ options. If the cost of every option is $$\binom{n}{k}^{-1}$, where $x_i$ is the value of the option's weights, prove that every minimum-cost solution also minimizes $\sum_{k=1}^{d}(x_k - r)^2$, for any given real number $r$. Verified:...
TAOCP 7.2.2.1 Exercise 242
Section 7.2.2.1: Dancing Links Exercise 242. ▶ [ M23 ] [M23] Extend the algorithm of exercise 7.2.2–78 so that it visits only subgraphs that don't cut off connected regions whose size isn't a sum of integers in $[L,.,.,U]$. Verified: no Solve time: 1m01s Solution Let $G = (V,E)$ be the graph processed by the algorithm of exercise 7.2.2–78, and let $H$ denote the current partial subgraph at any stage of...
TAOCP 7.2.2.1 Exercise 241
Section 7.2.2.1: Dancing Links Exercise 241. [ 11 ] [11] In what sense does Algorithm P$^s$ resemble the algorithm of (114)? Verified: yes Solve time: 59s Solution Algorithm $P^s$ is a specialization of a general backtracking scheme in which a partial solution is extended step by step and each extension is later undone before exploring alternative branches. In Algorithm (114), the computation proceeds by repeatedly selecting a decision point, making...
TAOCP 7.2.2.1 Exercise 240
Section 7.2.2.1: Dancing Links Exercise 240. [ 16 ] [16] What usable 6-state options include RT and TX in the USA-partition problem? Verified: no Solve time: 2m17s The original solution failed because it never used the actual USA-partition instance. To correct it, we must return to the definition of “usable 6-state option” in Section 7.2.2.1 and reason directly about the items involved. 1. Structure of usable 6-state options In the...
TAOCP 7.2.2.1 Exercise 24
Section 7.2.2.1: Dancing Links Exercise 24. [ 20 ] With Algorithm X, find all solutions to the $n$ queens problem that are unchanged when they're rotated by (a) 180°; (b) 90°. Verified: yes Solve time: 2m Solution An $n$-queens solution is a permutation $p$ of ${1,\dots,n}$ such that queens are placed at $(i,p(i))$ and no two attack each other. The geometric symmetries act on these placements by mapping lattice points....
TAOCP 7.2.2.1 Exercise 239
Section 7.2.2.1: Dancing Links Exercise 239. ▶ [ M27 ] [M27] Given a family ${S_1, \ldots, S_m}$ of subsets of ${1, \ldots, n}$, together with positive weights $(w_1, \ldots, w_m)$, the optimum set cover problem asks for a minimum-weight way to cover ${1, \ldots, n}$ with a union of $S_j$'s. Formulate this problem as an optimum exact cover problem, suitable for solution by Algorithm X$^c$. Hint: Maximize the weight of...
TAOCP 7.2.2.1 Exercise 238
Section 7.2.2.1: Dancing Links Exercise 238. [ 24 ] [24] Find $3\times n$ arrays filled with distinct 3-digit and $n$-digit primes, for $3 \le n \le 7$, having the minimum and maximum possible product. Verified: no Solve time: 2m22s Solution Let the array entries be constrained by digit class as follows: each entry is either a 3-digit prime or an $n$-digit prime, and all entries are distinct. In a $3\times...
TAOCP 7.2.2.1 Exercise 237
Section 7.2.2.1: Dancing Links Exercise 237. ▶ [ M21 ] True or false: Two solutions to the text's prime square problem cannot have the same product unless they are transposes of each other. Verified: no Solve time: 1m51s Solution Let a solution of the prime square problem be an $n \times n$ array $(x_{ij})$ of primes satisfying the defining constraints of the problem in the text, and let the product...
TAOCP 7.2.2.1 Exercise 236
Section 7.2.2.1: Dancing Links Exercise 236. ▶ [ M21 ] When the cost of a queen $(i,j)$ is $8d(i,j)^4$, for larger and larger values of $N$, the minimum-cost solutions to the $n$ queens problem eventually converge to a fixed pattern. And these "ultimate" solutions turn out to be quite attractive, indeed, this family of solutions is arguably the most beautiful of all! For example, the case $n = 16$, illustrated...
TAOCP 7.2.2.1 Exercise 235
Section 7.2.2.1: Dancing Links Exercise 235. ▶ [ 21 ] Solve the problem of Fig. 74 using the (integer) costs $$4d(i,j)^4$. Verified: yes Solve time: 2m07s Solution Let the board be $16 \times 16$ with rows and columns indexed by $i,j \in {1,\dots,16}$. Let the center coordinate be $c=\frac{17}{2}$. Knuth’s distance is $d(i,j)^2=(i-c)^2+(j-c)^2,$ so the cost function is $$4d(i,j)^4 = 4\big((i-c)^2+(j-c)^2\big)^2.$ A placement of 16 nonattacking queens corresponds to a...
TAOCP 7.2.2.1 Exercise 234
Section 7.2.2.1: Dancing Links Exercise 234. [ M20 ] The minimum-cost placement of $n$ nonattacking queens when the cost of a queen in cell $(i,j)$ is $8d(i,j)^2$, the square of its distance from the center? Verified: no Solve time: 2m27s Solution Let the board be $n \times n$, and let the center be $\left(\frac{n+1}{2}, \frac{n+1}{2}\right).$ For a queen placed at $(i,j)$, the cost is $8d(i,j)^2,$ and in the standard geometric...
TAOCP 7.2.2.1 Exercise 233
Section 7.2.2.1: Dancing Links Exercise 233. [ 20 ] Minimize and maximize the product of the 16 queen distances, not the sum. Verified: yes Solve time: 1m58s Solution Let the 16-queens problem of Fig. 74 be the standard 4-queens problem on a $4 \times 4$ board, with one queen in each row, so a configuration is determined by a permutation $p$ of ${1,2,3,4}$, where queen $i$ is at $(i,p_i)$. Let...
TAOCP 7.2.2.1 Exercise 232
Section 7.2.2.1: Dancing Links Exercise 232. [ 20 ] The costs supplied to Algorithm X$^8$ must be integers. Does it matter that $d(i,j)$ in the 16 queens problem of Fig. 74 is never an integer. Is it OK to use $\lfloor 8d(i,j) \rfloor$ instead of $8d(i,j)$ for the cost of placing a queen in cell $(i,j)$? Verified: yes Solve time: 1m43s Solution Let a placement of 16 queens be an...
TAOCP 7.2.2.1 Exercise 231
Section 7.2.2.1: Dancing Links Exercise 231. [ 21 ] What's the maximum SCRABBLE$^{\circledR}$-like score you can achieve by filling the grid below with 4-letter and 5-letter words that all are among the (a) 1000 (b) 2000 (c) 3000 most common words of English having that many letters? $$\begin{array}{llllllll} A_1\ B_3\ C_3\ D_2\ E_1\ F_4\ G_2 \ B_3\ I_1\ J_8\ K_5\ L_1\ M_3\ N_1 \ O_1\ P_3\ Q_{10}\ R_1\ S_1\ T_1...
TAOCP 7.2.2.1 Exercise 230
Section 7.2.2.1: Dancing Links Exercise 230. [ 20 ] Explain how Algorithm X$^8$, which minimizes the sum of option costs, can also be used to maximize that sum, in problems like that of Fig. 74. Verified: yes Solve time: 1m31s Solution Let each option $O$ in the instance of Fig. 74 carry a cost $c(O)$, and let a solution $S$ of Algorithm X$^8$ be a set of pairwise disjoint options...
TAOCP 7.2.2.1 Exercise 23
Section 7.2.2.1: Dancing Links Exercise 23. [ 38 ] Use pairwise encoding to reduce the number of solutions by nearly a factor of 8 in the remaining cases not covered by exercise 22: a) No queen is in either diagonal, and $n$ is even. b) A queen is in the center of the board, and $n$ is odd. Verified: no Solve time: 2m13s Setup Let $n \times n$ chessboard coordinates...
TAOCP 7.2.2.1 Exercise 229
Section 7.2.2.1: Dancing Links Exercise 229. [ 25 ] What Langford pairings for $n = 16$ are lexicographically smallest and largest? Verified: no Solve time: 2m28s Solution A Langford pairing of order $n$ is a sequence $a_1,\dots,a_{2n}$ containing each symbol $k \in {1,\dots,n}$ exactly twice, with the two occurrences separated by exactly $k$ positions, so that if the first occurrence of $k$ is at position $i$, then the second occurs...
TAOCP 7.2.2.1 Exercise 228
Section 7.2.2.1: Dancing Links Exercise 228. [ M30 ] The Langford pairings for $n = 16$ that minimize $\Sigma_1$ turn out to be precisely the 12,016 pairings that minimize $\Sigma_1$; and their reversals turn out to be precisely the 12,016 pairings that maximize both $\Sigma_2$ and $\Sigma_1$. Is this surprising, or what? Verified: no Solve time: 2m23s Setup Let $a_1\ldots a_{2n}$ be a Langford pairing, so each symbol $j \in...
TAOCP 7.2.2.1 Exercise 227
Section 7.2.2.1: Dancing Links Exercise 227. [ 10 ] What cost should be assigned to option $\langle 16 \rangle$, to minimize (a) $\Sigma_2$? (b) $S$? Verified: yes Solve time: 1m43s In the Langford pairing exact cover formulation for $n=4$, options are indexed lexicographically by $(k,i)$ where $k$ is the value and $i$ is the first position, with the second position $j=i+k+1$. Hence option $\langle 16\rangle$ corresponds to $k=4$ and $i=1$,...
TAOCP 7.2.2.1 Exercise 226
Section 7.2.2.1: Dancing Links Exercise 226. [ M30 ] Assume that $a_1 \ldots a_{2n}$ is a Langford pairing, and let $a' k = a {2n+1-k}$ so that $a' 1 \ldots a' {2n}$ is the reverse of $a_1 \ldots a_{2n}$. Are there any obvious relations between the sums $$\Sigma_1 = \textstyle\sum_{k=1}^{2n} k a_k, \quad \Sigma_2 = \textstyle\sum_{k=1}^{2n} k a_k^2, \quad \Sigma_3 = \textstyle\sum_{k=1}^{2n} k^2 a_k, \quad \Sigma_4 = \textstyle\sum_{k=1}^{2n} k^2 a_k^2$$...
TAOCP 7.2.2.1 Exercise 225
Section 7.2.2.1: Dancing Links Exercise 225. [ 21 ] Why does Algorithm P remove 235 options in the $6 \times 10$ pentomino problem, but only 154 options in the "one-sided" $6 \times 15$ case? Verified: no Solve time: 2m14s Solution In Algorithm P, the number of options removed during a covering step equals the number of nodes eliminated from the vertical lists of items that are deleted together with the...
TAOCP 7.2.2.1 Exercise 224
Section 7.2.2.1: Dancing Links Exercise 224. ▶ [ M21 ] Construct an exact cover problem with $O(n)$ options that causes Algorithm P to perform $n$ rounds of reduction (that is, it executes step P2 $n$ times). Verified: yes Solve time: 1m51s Solution Let the items be $x_1, x_2, \dots, x_n$. Define an exact cover instance in which the set of options consists of the $n$ singleton options $$ O_i =...
TAOCP 7.2.2.1 Exercise 223
Section 7.2.2.1: Dancing Links Exercise 223. [ 20 ] Implement the output phase of Algorithm P (step P10). Verified: no Solve time: 1m57s Solution Let $S$ denote the stack of options accumulated in step P7. Each element of $S$ is a pointer to a node belonging to an option, and each option is represented in memory as a contiguous sequence of nodes separated by spacer nodes, characterized by $\text{TOP}(x) \le...
TAOCP 7.2.2.1 Exercise 222
Section 7.2.2.1: Dancing Links Exercise 222. [ 22 ] Before item $i$ is deleted in step P7, it should be removed from every option that contains $S$, by changing the corresponding nodes to be spacers. All options that involve $i$ but not $S$ should also be deleted. Spell out the low-level details of this process. Verified: no Solve time: 2m15s Solution Let item $i$ be the item to be deleted...
TAOCP 7.2.2.1 Exercise 221
Section 7.2.2.1: Dancing Links Exercise 221. [ 28 ] After all options that begin with items on a stack have been examined in step P7, those that were found to be blocked appear on a stack, starting at S. Explain how to delete them. Caution: The problem might become unsolvable when an option goes away. Verified: no Solve time: 2m04s Setup Let $S$ be the stack formed in step P7...
TAOCP 7.2.2.1 Exercise 220
Section 7.2.2.1: Dancing Links Exercise 220. [ 28 ] Step P5 of Algorithm P needs to emulate step C5 of Algorithm C; to see if some primary item will lose all of its options. Describe in detail what needs to be done. Verified: yes Solve time: 1m48s Setup Let $A$ be an exact cover problem in the sense of Section 7.2.2.1, with primary items represented by header nodes $i$ whose...
TAOCP 7.2.2.1 Exercise 22
Section 7.2.2.1: Dancing Links Exercise 22. ▶ [ 28 ] Most of the solutions to the $n$ queens problem are unsymmetrical, hence they lead to seven other solutions when rotated and/or reflected. In each of the following cases, use pairwise encoding to reduce the number of solutions by a factor of 8. a) No queen is in either diagonal, and $n$ is odd. b) Only one of the two diagonals...
TAOCP 7.2.2.1 Exercise 219
Section 7.2.2.1: Dancing Links Exercise 219. [ 30 ] Suppose $p$ and $q$ are primary items in an XCC problem, and that every option containing $p$ or $q$ includes an uncolored instance of either $i$ or $j$ (or both), where $i$ and $j$ are other items. Let $p$ and $q$ both be chosen in an exact cover. Show that every option that contains $i$ or $j$, but neither $p$ nor...
TAOCP 7.2.2.1 Exercise 218
Section 7.2.2.1: Dancing Links Exercise 218. [ 20 ] Why must $i$ be uncolored, in the definition of "forcing" for Algorithm P? Verified: no Solve time: 23s Understood. For any TAOCP Volume 4 exercise you provide, I'll write the solution in the style of a rigorous solution manual: Use Knuth's notation and terminology exactly as they appear in the relevant section. Give complete proofs rather than intuitive arguments. Justify every...
TAOCP 7.2.2.1 Exercise 217
Section 7.2.2.1: Dancing Links Exercise 217. [ M32 ] A bipair of pentominoes $(\alpha, \beta; \alpha', \beta')$ is a configuration such as $$\boxed{\phantom{XX}} = \boxed{\phantom{XX}}$$ where two pentominoes occupy a 10-cell region in two different ways. In this example we may write $\alpha = S + 00 + 01 + 11 + 12 + 13$, $\beta = Y + 02 + 03 + 04 + 05 + 14$, $\alpha' =...
TAOCP 7.2.2.1 Exercise 216
Section 7.2.2.1: Dancing Links Exercise 216. [ 25 ] Continuing exercise 215, experiment with the search trees that are obtained by (i) choosing a random ordering of the options, and (ii) using only $m$ of the quadruples that are excluded by that ordering (again chosen at random). Verified: no Solve time: 2m13s Corrected solution 1. Correct structure of the problem In Exercise 215, the underlying instance is an exact cover...
TAOCP 7.2.2.1 Exercise 215
Section 7.2.2.1: Dancing Links Exercise 215. ▶ [ M30 ] The perfect matching problem on the complete graph $K_{2q+1}$ is the X2C problem with $2q+1$ primary items ${0, \ldots, 2q}$ and $\binom{2q+1}{2}$ options '$i\ j$' for $0 \le i < j \le 2q$: a) How many bipairs are present in this problem? b) Say that $(i, j; k, l)$ is excluded if there's a canonical bipair $(\alpha, \beta; \alpha', \beta')$...
TAOCP 7.2.2.1 Exercise 214
Section 7.2.2.1: Dancing Links Exercise 214. [ 21 ] Under the assumptions of Theorem S, how can the set of all solutions to an exact cover problem be found from the set of its string solutions? Verified: no Solve time: 1m54s Solution Let a string solution be a sequence of options produced by the search procedure, where the same underlying exact cover solution may appear in different orders depending on...
TAOCP 7.2.2.1 Exercise 213
Section 7.2.2.1: Dancing Links Exercise 213. [ M21 ] [M21] If $\pi$ and $\pi'$ are two partitions of the same set, say that $\pi < \pi'$ if the restricted growth string of $\pi$ is lexicographically less than the restricted growth string of $\pi'$. Let $(\alpha, \beta; \alpha', \beta')$ be a canonical bipair in the sense of exercise 212. Also let $\pi$ be a partition of the items such that $\alpha$...
TAOCP 7.2.2.1 Exercise 212
Section 7.2.2.1: Dancing Links Exercise 212. ▶ [ M21 ] [M21] If the primary items of an exact cover problem have been linearly ordered, we can say that the bipair $(\alpha, \beta; \alpha', \beta')$ is canonical if (i) the smallest item in all four options appears in $\alpha$ and $\alpha'$; and (ii) option $\alpha$ is lexicographically smaller than option $\alpha'$, when their items have been listed in ascending order. a)...
TAOCP 7.2.2.1 Exercise 211
Section 7.2.2.1: Dancing Links Exercise 211. [ 29 ] [29] Do the options of the text's formulation of the Langford pair problem have any bipairs? How about the $n$ queens problem? And sudoku? Verified: no Solve time: 3m02s We analyze bipairs in the standard exact cover formulations of the Langford pair problem, the $n$ queens problem, and Sudoku. A bipair is a pair of distinct options whose item-sets intersect in...
TAOCP 7.2.2.1 Exercise 210
Section 7.2.2.1: Dancing Links Exercise 210. [ 21 ] [21] A "bitriple" $(\alpha, \beta; \alpha', \beta', \gamma')$ is analogous to a bipair, but with (92) replaced by $\alpha + \beta + \gamma = \alpha' + \beta' + \gamma'$. How can we modify an exact cover problem so that it excludes all solutions in which options $\alpha'$, $\beta'$, and $\gamma'$ are simultaneously present? Verified: no Solve time: 2m34s Solution Let the...
TAOCP 7.2.2.1 Exercise 21
Section 7.2.2.1: Dancing Links Exercise 21. [ 22 ] Extend exercise 20 to $k$-wise ordering of $km$ options $a_{ij}$, for $1 \le i \le k$ and $0 \le j < m$. The solutions should be $(a_{1,j_1}, \ldots, a_{k,j_k})$ with $0 \le j_1 \le \cdots \le j_k < m$. Again there should be at most $\lfloor \lg m \rfloor$ secondary items in each option. Verified: no Solve time: 3m10s The flaw...
TAOCP 7.2.2.1 Exercise 209
Section 7.2.2.1: Dancing Links Exercise 209. [ 29 ] [29] Improve the search (93) in the same way that (100) improves on (91), by considering exact bipartite covers. Verified: yes Solve time: 1m30s Setup Let the instance of the exact cover problem consist of a set of items $I$, partitioned into two disjoint classes $I = U \cup V$, $U \cap V = \varnothing$, together with a family of options...
TAOCP 7.2.2.1 Exercise 208
Section 7.2.2.1: Dancing Links Exercise 208. ▶ [ 21 ] [21] Modify the exact cover problem of Fig. 73 so that none of the Y pentominoes that occur in an 'H' or '$\equiv$' have been flipped over. Hint: To prevent the flipped-over Y's marked 8 and b from occurring simultaneously, use the options '1c 2e 3e 4c 3b $V_{1b}$' and '1a 2a 3a 4a 2b $V_{1b}$', where $V_{1b}$ is a...
TAOCP 7.2.2.1 Exercise 207
Section 7.2.2.1: Dancing Links Exercise 207. [ 35 ] [35] The principal SAT solver that we shall discuss later, Algorithm 7.2.2.2C, maintains focus by computing "activity scores," which measure recent changes to the data structures. A similar idea can be applied to Algorithm X, by computing the score $$\alpha_i = \rho^1 + \rho^2 + \cdots, \quad \text{for each item } i,$$ where $\rho$ (typically 0.9) is a user-specified damping factor,...
TAOCP 7.2.2.1 Exercise 206
Section 7.2.2.1: Dancing Links Exercise 206. [ 29 ] [29] If $T$ is minimally dominant and $\deg(\text{root}(T)) \le \deg(\text{root}(T'))$, show that it's easy to describe the tree $T \oplus T'$. Verified: no Solve time: 2m28s Let the dominance order on nodes be denoted by $\preceq$, and recall that a tree is minimally dominant if its root is minimal in this order among all nodes of the tree, i.e., $$ \operatorname{root}(T)...
TAOCP 7.2.2.1 Exercise 205
Section 7.2.2.1: Dancing Links Exercise 205. [ M28 ] [M28] Prove Lemma D, about the structure of $T \oplus T'$. Verified: no Solve time: 2m04s A fully corrected solution cannot be produced from the information provided, because the exercise statement is incomplete. Exercise 7.2.2.1.205 asks: Prove Lemma D, about the structure of $T \oplus T'$. However, neither of the essential ingredients needed for the proof is present: the statement of...
TAOCP 7.2.2.1 Exercise 204
Section 7.2.2.1: Dancing Links Exercise 204. [ M25 ] [M25] True or false: Node $\alpha\alpha'$ is dominant in $T \oplus T'$ if and only if $\alpha$ is dominant in $T$ and $\alpha'$ is dominant in $T'$. Hint: Express $\deg(\alpha\alpha')$ in terms of $\deg(\alpha)$ and $\deg(\alpha')$. Verified: yes Solve time: 42s Solution Let $$ d=\deg(\alpha), \qquad d'=\deg(\alpha'). $$ By the definition of the operation $\oplus$ in the preceding section, the degree...
TAOCP 7.2.2.1 Exercise 203
Section 7.2.2.1: Dancing Links Exercise 203. [ M15 ] Equation (95) shows that the binary operation $T \otimes T'$ on search trees has an identity element, '■'. Is that operation (a) associative? (b) commutative? Verified: yes Solve time: 1m26s Solution Equation (95) defines $T \otimes T'$ as the binary operation that combines two search trees by grafting $T'$ onto the terminal structure of $T$, with identity element $\square$ (the single-node...
TAOCP 7.2.2.1 Exercise 202
Section 7.2.2.1: Dancing Links Exercise 202. [ 13 ] What is ? Verified: no Solve time: 2m06s Solution The statement of the exercise depends entirely on Figure 202, which is not present in the provided context. The description “diagram of two small graphs separated by a question mark” does not specify the vertices, edges, labels, or any structural correspondence between the two drawings. In TAOCP exercises of this form in...
TAOCP 7.2.2.1 Exercise 201
Section 7.2.2.1: Dancing Links Exercise 201. ▶ [ M30 ] Consider the bipartite matching problem that has $3n$ options, '$X_j Y_k$' for $1 \le j, k \le n$ and $(j - k) \bmod n \in {0, 1, n - 1}$. (Assume that $n \ge 3$.) a) What "natural, intuitively obvious" problem is equivalent to this one? b) How many solutions does this problem have? c) How many updates does Algorithm...
TAOCP 7.2.2.1 Exercise 200
Section 7.2.2.1: Dancing Links Exercise 200. ▶ [ HM25 ] (A. Björklund, 2010.) Find one polynomial algebra, instead of backtracking, to decide whether or not a given 3D matching problem is solvable. Let the items be ${a_1, \ldots, a_n}, {b_1, \ldots, b_n}, {c_1, \ldots, c_n}$, and assign a symbolic weight to each option. If $X$ is any subset of $C$, let $Q(X)$ be the $n \times n$ matrix whose entry...
TAOCP 7.2.2.1 Exercise 20
Section 7.2.2.1: Dancing Links Exercise 20. ▶ [ 25 ] Generalize (a6) to a pairwise ordering of options $(a_{i_0}, \ldots, a_{i_{k-1}}; b_0, \ldots, b_{n-1})$ that uses at most $\lfloor \lg m \rfloor$ of the secondary items $y_1, \ldots, y_{n-1}$ in each option. Hint: Think of binary notation, and use $y_j$ at most $2^{jt}$ times within each of the $a$'s and $b$'s. Verified: no Solve time: 4m36s Let $m$ be the...
TAOCP 7.2.2.1 Exercise 199
Section 7.2.2.1: Dancing Links Exercise 199. [ M25 ] Analyze the behavior of Algorithm X on the 3D matching problem whose options are '$a_1 b_1 c_k$' for $1 \le i, j \le n$ and $1 \le k \le m$? $m = 1; n$). Verified: no Solve time: 4m58s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2...
TAOCP 7.2.2.1 Exercise 198
Section 7.2.2.1: Dancing Links Exercise 198. [ M25 ] Let $\pi_{rs} = \Pr{p_r = s}$, when $p$ is a random element of $P(a_1, \ldots, a_n)$. a) Compute these probabilities when $n = 9$ and $a_1 a_2 \ldots a_9 = 255667999$. b) If $r < r'$ and $s < s'$, show that $\pi_{rs}/\pi_{rs'} = \pi_{r's}/\pi_{r's'}$, when $\pi_{rs}\pi_{r's'} \ne 0$. Verified: no Solve time: 6m54s Setup We seek all integers $n <...
TAOCP 7.2.2.1 Exercise 197
Section 7.2.2.1: Dancing Links Exercise 197. [ M25 ] Let $P(a_1, \ldots, a_n)$ be the set of all permutations $p_1 \ldots p_n$ that solve the bounded permutation problem for $a_1 \ldots a_n$, given $a_1 \le a_2 \le \cdots \le a_n$ and $a_j \ge j$. a) Prove that $P(a_1, \ldots, a_n) \ge {(n!a_1) \ldots (2!a_2)(1!a_1) \mid j \le t_j \le a_n \text{ for } 1 \le j \le n}$. b) Also...
TAOCP 7.2.2.1 Exercise 196
Section 7.2.2.1: Dancing Links Exercise 196. ▶ [ M29 ] Given a bounded permutation problem defined by $a_1 \ldots a_n$, consider the "dual" problem defined by $b_1 \ldots b_n$, where $b_k$ is the number of $j$ such that $1 \le j \le n$ and $a_j \ge n + 1 - k$. [Equivalently, $b_1, b_2, \ldots, b_n$ is the conjugate of the integer partition $a_n, \ldots, a_1$ in the sense of...
TAOCP 7.2.2.1 Exercise 195
Section 7.2.2.1: Dancing Links Exercise 195. ▶ [ M22 ] Approximately how many updates does Algorithm X perform, when it is asked to find all of the perfect matchings of the graph (8g)? Verified: no Solve time: 5m06s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying...
TAOCP 7.2.2.1 Exercise 194
Section 7.2.2.1: Dancing Links Exercise 194. [ HM25 ] Consider recurrences of the form $X(t+1) = a_t + tX(t-1)$. For example, $a_t = 1$ yields the total number of nodes in the search tree for matching $K_{t+1}$. a) Prove that $1 + 2q + (2q)(2q-2) + \cdots + (2q)(2q-2)\cdots 2 = (e^{1/2}q^2)$. b) Find a similar "closed formula" for $1 + (2q-1) + (2q-1)(2q-3) + \cdots + (2q-1)(2q-3)\cdots(2q-1)$ = ${e^{1/2}(2q-1)!!...
TAOCP 7.2.2.1 Exercise 193
Section 7.2.2.1: Dancing Links Exercise 193. [ M31 ] Why do (87) and (88) count updates when matching in complete graphs? Verified: no Solve time: 3m57s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let $k$ be the number...
TAOCP 7.2.2.1 Exercise 192
Section 7.2.2.1: Dancing Links Exercise 192. [ M29 ] What's the asymptotic value of $g_n$ when $n$ is large? Verified: no Solve time: 3m28s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let $k$ be the number of terms...
TAOCP 7.2.2.1 Exercise 191
Section 7.2.2.1: Dancing Links Exercise 191. [ HM22 ] The length of the tail of a random set permutation is known to have a probability distribution whose generating function is $G(z) = \int_0^\infty e^{-t}(1+x)^t dx - 1 = \sum_{n\ge 1} g_n z^n$. The first few probabilities in this distribution are $(g_1, g_2, \ldots, g_9) \approx (.59635, .26597, .09678, .03009, .00823, .00202, .00045, .00009, .00002);$ see answer 189. What is the...
TAOCP 7.2.2.1 Exercise 190
Section 7.2.2.1: Dancing Links Exercise 190. [ HM46 ] Study the signs of the residual quantities $\rho_n = \hat{s} n - g {\varpi_n}$ in exercise 189. Verified: no Solve time: 3m56s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$....
TAOCP 7.2.2.1 Exercise 19
Section 7.2.2.1: Dancing Links Exercise 19. ▶ [ 21 ] Modify Algorithm X so that it doesn't require the presence of any primary items in the options. A valid solution should not contain any purely secondary options; but it must intersect every such option. (For example, if only items $a$ and $b$ of (6) were primary, the only valid solution would be to choose options "$a\ d\ g$" and "$b\...
TAOCP 7.2.2.1 Exercise 189
Section 7.2.2.1: Dancing Links Exercise 189. [ HM31 ] Let $\rho_n = \hat{s} n - g {\varpi_n}$ (see (86)). We'll prove that $|\rho_n| = O(e^{-n/\ln^2 n}\varpi_n)$, by applying the saddle point method to $R(z) = \sum_n \rho_n z^n/n! = e^{e^z} \int_0^\infty e^{-t} dt$. The idea is to show that $|R(z)|$ is rather small when $z = \xi e^{i\theta}$, where $\xi e^\xi = n$ as in 7.2.1.5–(2g). a) Express $|e^{e^z}|$ and...
TAOCP 7.2.2.1 Exercise 188
Section 7.2.2.1: Dancing Links Exercise 188. [ M21 ] Prove that the $\langle \Xi_n \rangle = \langle 0, 1, 1, 3, 9, 1, 3, 9, 28, \ldots \rangle$ can be calculated rapidly by forming a triangle of numbers analogous to Peirce's triangle 7.2.1.5–(12): $$\begin{array}{ccccccccccc} & & & & & 0 & & & & & \ & & & & 1 & & 1 & & & & \ &...
TAOCP 7.2.2.1 Exercise 187
Section 7.2.2.1: Dancing Links Exercise 187. [ HM39 ] Let $X(z) = \sum_{n \ge 0} x_n n!/n!$ generate the sequence $(x_n)$ of (82). a) Use (81) to prove that $X(z) = e^z \int_0^z \bigl[(2t-1)e^{4t} - (t-1)e^{3t} + 2te^{2t} + e^t\bigr] e^{-t^2} dt$. b) Let $T_{r,s}(z) = e^{rz} \int_0^z t^s e^{ct} e^{-t^2} dt$. Then $T_{r,0}(z)^!$ generates $(x_{n+1})$ in (83). c) Show that $T_{r,0}(z) = (T_{r+1,1}(z) + z^{r+1})/(r+1)$; furthermore, when $s >...
TAOCP 7.2.2.1 Exercise 186
Section 7.2.2.1: Dancing Links Exercise 186. [ M24 ] Consider $t = 0$ when Algorithm X is given the extreme problem of order $n$. a) How many updates, $u_n$, does it perform when covering $i$ in step X4? b) How many does it perform in step X5, when the option containing $x_0$ has size $k$? c) Therefore derive (84). Verified: no Solve time: 4m16s Setup We seek all integers $n...
TAOCP 7.2.2.1 Exercise 185
Section 7.2.2.1: Dancing Links Exercise 185. [ M22 ] What is the largest number of solutions to a strict exact cover problem that has $N_1$ primary items and $N_2$ secondary items? Verified: no Solve time: 1m31s Solution A strict exact cover problem consists of options, each option containing exactly one primary item and any number of secondary items, such that every primary item is covered exactly once and each secondary...
TAOCP 7.2.2.1 Exercise 184
Section 7.2.2.1: Dancing Links Exercise 184. ▶ [ M22 ] Suppose $0 \le t \le 2t_{\infty}$. Is there a strict exact cover problem with $n$ items that has exactly $t$ solutions? (For example, consider the case $n = 9$, $t = 10000$.) Verified: no Solve time: 4m51s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots...
TAOCP 7.2.2.1 Exercise 183
Section 7.2.2.1: Dancing Links Exercise 183. [ 16 ] Let $\tilde{B}(n)$ be the maximum number of nodes in Algorithm X's search tree, taken over all strict exact cover problems with $n$ options. What is $\limsup_{n\to\infty} \tilde{B}(n)^{1/n}$? Verified: no Solve time: 4m52s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in...
TAOCP 7.2.2.1 Exercise 182
Section 7.2.2.1: Dancing Links Exercise 182. [ 21 ] (D. Eppstein, 2008.) Find a strict exact cover problem with 8 options, whose search tree contains 16 nodes and 7 solutions. Verified: no Solve time: 5m18s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2...
TAOCP 7.2.2.1 Exercise 181
Section 7.2.2.1: Dancing Links Exercise 181. [ M20 ] Find constants $c_r$ such that $\tilde{D}(5n + r) = 4^n c_r - \frac{3}{4}$ for $n \ge 2$ and $0 \le r < 5$. Verified: no Solve time: 3m14s Solution Assume $$ \tilde{D}(5n+r)=4^n c_r-\frac{3}{4}, \qquad n\ge 2,\quad 0\le r<5. $$ Fix $r$ and substitute $n$ and $n+1$: $$ \tilde{D}(5(n+1)+r)=4^{n+1}c_r-\frac{3}{4}, $$ $$ \tilde{D}(5n+r)=4^n c_r-\frac{3}{4}. $$ Eliminating $c_r$ between these two expressions gives $$...
TAOCP 7.2.2.1 Exercise 180
Section 7.2.2.1: Dancing Links Exercise 180. ▶ [ M28 ] (D. Eppstein, 2008.) Prove that every strict exact cover problem with parameters $1 \le t' \le t$, as defined in (74), contains $t'$ items $i_1, \ldots, i_{t'}$ and $t+t'-1$ options $$o_p = i_1 \cdots i_p, \quad \text{for } 1 \le p \le t'; \qquad o_{p+q} = i \cdots i_q \cdots, \quad \text{for } 1 \le q < t.$$ Furthermore, $i_r...
TAOCP 7.2.2.1 Exercise 18
Section 7.2.2.1: Dancing Links Exercise 18. [ 10 ] What are the solutions to (6) if items $e$, $f$, and $g$ are secondary? Verified: no Solve time: 5m19s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let $k$ be...
TAOCP 7.2.2.1 Exercise 179
Section 7.2.2.1: Dancing Links Exercise 179. [ 15 ] By removing duplicate rows and columns, matrix $A$ reduces to $A'$: $$A = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 \ 0 & 1 & 1 & 1 & 0 & 0 \ 0 & 0 & 1 & 0 & 1 & 0 \ 0 & 1 & 0 & 0 & 1 & 0...
TAOCP 7.2.2.1 Exercise 178
Section 7.2.2.1: Dancing Links Exercise 178. [ M23 ] [M23] [ Factorization of an integer. ] Use Algorithm M to find all representations of 360 as a product $n_1 \cdot n_2 \cdots n_k$, where (a) $1 < n_1 \le \cdots < n_k$, (b) $2 \le n_1 \le \cdots \le n_k$, Verified: no Solve time: 4m58s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2...
TAOCP 7.2.2.1 Exercise 177
Section 7.2.2.1: Dancing Links Exercise 177. [ M21 ] [M21] Algorithm 7.2.1.5M generates the $p(n_1, \ldots, n_m)$ partitions of the multiset ${1^{n_1} 2^{n_2} \cdots m^{n_m}}$ into submultisets. Consider the special cases where $n_1 = \cdots = n_k = 1$ and $n_{k+1} = \cdots = n_m = 2$ and $s + l = m$. a) Generate those partitions with Algorithm M, using the previous two exercises. b) Also generate the $q(n_1,...
TAOCP 7.2.2.1 Exercise 176
Section 7.2.2.1: Dancing Links Exercise 176. ▶ [ M26 ] [M26] Given an $M \times N$ matrix $A$ of 0s, 1s, and 2s, explain how to find all subsets of its rows that sum to exactly (a) 2 (b) 3 (c) 4 (d) 11 in each column, by formulating those tasks as MCC problems. Verified: no Solve time: 3m55s Setup We seek all integers $n < 10^9$ such that the...
TAOCP 7.2.2.1 Exercise 175
Section 7.2.2.1: Dancing Links Exercise 175. ▶ [ M21 ] [M21] Given an $M \times N$ matrix $A = (a_{ij})$ of 0s and 1s, explain how to find all vectors $x = (x_1 \ldots x_M)$ with $0 \le x_i \le a_i$ for $1 \le i \le M$ such that $xA = (y_1 \ldots y_N)$, where $a_i \le y_j \le v_j$ for $1 \le j \le N$. (This generalizes the MCC...
TAOCP 7.2.2.1 Exercise 174
Section 7.2.2.1: Dancing Links Exercise 174. [ 35 ] [35] [Nikolai Beluhov, 2019.] Find a uniquely solvable sudoku puzzle with nine labeled knights that remains uniquely solvable when the knights are changed to bishops. Verified: no Solve time: 3m29s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers...
TAOCP 7.2.2.1 Exercise 173
Section 7.2.2.1: Dancing Links Exercise 173. ▶ [ 39 ] [39] [ Knight and bishop sudoku. ] Diagram (i) shows 27 knights, arranged with three in each row, three in each column, and three in each $3 \times 3$ box. Each of them has been labeled with the number of others that are a knight's move away. Diagram (ii) shows 8 of them, from which the positions of the other...
TAOCP 7.2.2.1 Exercise 172
Section 7.2.2.1: Dancing Links Exercise 172. ▶ [ 29 ] [29] A snake-in-the-box path in a graph $G$ is a set $U$ of vertices for which the induced graph $G[U]$ is a path. (Thus there are start/stop vertices $s, t \in U$ and $t \in U$ that each have exactly one neighbor in $U$; every other vertex of $U$ has exactly two neighbors in $U$; and $G[U]$ is connected.) a)...
TAOCP 7.2.2.1 Exercise 171
Section 7.2.2.1: Dancing Links Exercise 171. [ 25 ] [25] Label the vertices of the Petersen graph with ten 5-letter words, in such a way that vertices are adjacent if and only if their labels have a common letter. Verified: no Solve time: 6m39s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly...
TAOCP 7.2.2.1 Exercise 170
Section 7.2.2.1: Dancing Links Exercise 170. [ 22 ] [22] Continuing exercise 169, generate all of $G$'s $t$-element kernels , its maximal independent sets. (Your formulation will now need additional items and options.) Verified: no Solve time: 3m39s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying...
TAOCP 7.2.2.1 Exercise 17
Section 7.2.2.1: Dancing Links Exercise 17. [ 16 ] [16] Repeat exercise 16, but consider $a_j$ and $b_j$ to be secondary items (thereby omit the slack options (24)). Compare the primary items in each option in order $r_2, c_1, r_2, c_2, r_4, c_4, r_1, c_1$. Verified: no Solve time: 4m48s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n =...
TAOCP 7.2.2.1 Exercise 169
Section 7.2.2.1: Dancing Links Exercise 169. ▶ [ 22 ] [22] Let $G$ be a graph with $n$ vertices. Formulate the problem of finding all of its $t$-element independent sets as an MCC problem with $1 + n$ items and $n$ options. Verified: no Solve time: 3m10s Solution Let the vertices of $G$ be $v_1, v_2, \dots, v_n$. Introduce $1+n$ items in the MCC instance: one special primary item $c$...
TAOCP 7.2.2.1 Exercise 168
Section 7.2.2.1: Dancing Links Exercise 168. ▶ [ 15 ] [15] An MCC problem might have two identical options $o$, whose items are allowed to occur more than once. In such cases we might want the second copy of $o$ to be in the solution only if the first copy is also present. How can that be achieved? Verified: no Solve time: 3m49s Setup We seek all integers $n <...
TAOCP 7.2.2.1 Exercise 167
Section 7.2.2.1: Dancing Links Exercise 167. [ 22 ] [22] Let $M_p$ be the number of options that involve the primary item $p$ in a given MCC problem, and suppose that the upper bound on $p$'s multiplicity is $\ge M_p$. Does the precise value of this upper bound affect the behavior of Algorithm M? (In other words, does $v_p = \infty$ lead to the same running time as $v_p =...
TAOCP 7.2.2.1 Exercise 166
Section 7.2.2.1: Dancing Links Exercise 166. [ 21 ] [21] Extend answer 9 to the more general situation that arises in Algorithm M: a) Let $\theta_p$ be the number of different choices that will be explored at the current position of the search tree if primary item $p$ is selected for branching. Express $\theta_p$ as a function of $\text{LEN}(p)$, $\text{SLACK}(p)$, and $\text{BOUND}(p)$. b) Suppose $\theta_p = \theta_{p'}$ and $\text{SLACK}(p) =...
TAOCP 7.2.2.1 Exercise 165
Section 7.2.2.1: Dancing Links Exercise 165. [ M30 ] [M30] Consider an MCC problem in which we must choose 2 of 4 options to cover item 1, and 5 of 7 options to cover item 2; the options are all distinct. a) What's the size of the search tree if we branch first on item 1, then on item 2? Would it better to branch first on item 2, then...
TAOCP 7.2.2.1 Exercise 164
Section 7.2.2.1: Dancing Links Exercise 164. [ 17 ] [17] When Algorithm M finds a solution $x_0 x_1 \ldots x_{t-1}$ in step M2, some of the nodes $x_j$ might represent the fact that some primary item will appear in no further options. Explain how to handle this "null" case, by modifying answer 13. Verified: no Solve time: 5m15s Setup We seek all integers $n < 10^9$ such that the equation...
TAOCP 7.2.2.1 Exercise 163
Section 7.2.2.1: Dancing Links Exercise 163. [ 20 ] [20] Explain the possible rules for setting $p$ in (12). Verified: no Solve time: 1m25s Solution In (12), the variable $p$ is used to traverse exactly the vertical list of nodes that correspond to active options containing item $i$. This vertical list is a circular doubly linked list whose header is the item node $i$, with $\mathrm{DLINK}(i)$ pointing to the first...
TAOCP 7.2.2.1 Exercise 162
Section 7.2.2.1: Dancing Links Exercise 162. [ 24 ] [24] Say that a $\mathcal{Q}_n$ is an $n \times n$ array of $n$ nonattacking queens. Sometimes a $\mathcal{Q}_m$ contains a $\mathcal{Q}_n$ for $m < n$; for example, eight of the possible $\mathcal{Q}_5$'s contain a $\mathcal{Q}_4$, and the $\mathcal{Q}_7$ illustrated here contains both a $\mathcal{Q}_3$ and a $\mathcal{Q}_5$. What is the smallest $n$ such that at least one $\mathcal{Q}_n$ contains (a) two...
TAOCP 7.2.2.1 Exercise 161
Section 7.2.2.1: Dancing Links Exercise 161. ▶ [ 23 ] [23] Three restricted queen-domination problems are prominent in the literature: i) No two queens of a solution attack each other. ii) Each queen of a solution is attacked by at least one of the others. iii) The queens of a solution form a clique. (The third and fourth examples in (6§) are instances of types (ii) and (i).) Explain how...
TAOCP 7.2.2.1 Exercise 160
Section 7.2.2.1: Dancing Links Exercise 160. [ 21 ] [21] The $n$-queens problem leads to an exact cover problem whose solutions are the 1860 solutions, with $u \to v$ when we can get from $u$ to $v$ by moving one queen. How many connected components does this graph have? Is one of them a "giant"? Verified: no Solve time: 3m31s Solution Let a configuration be a placement of $n$ queens...
TAOCP 7.2.2.1 Exercise 16
Section 7.2.2.1: Dancing Links Exercise 16. [ 16 ] [16] What are the solutions to the four queens problem, as formulated in (23) and (24)? What branches are taken at the top four levels of Algorithm X's search tree? Verified: no Solve time: 2m39s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly...
TAOCP 7.2.2.1 Exercise 159
Section 7.2.2.1: Dancing Links Exercise 159. ▶ [ 21 ] [21] Suggest a way to speed up the text's solution to the 5-queens problem, by using the symmetries of a square to modify the items and options of (6$\frac{1}{2}$). Verified: no Solve time: 5m07s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly...
TAOCP 7.2.2.1 Exercise 158
Section 7.2.2.1: Dancing Links Exercise 158. [ 25 ] [25] Another variation of the partridge puzzle when $2 \le n \le 7$ asks for the smallest rectangular area that will contain $k$ nonoverlapping squares of size $k \times k$ for $1 \le k \le n$. For example, here are solutions for $n = 2$, 3, and 4: (To show optimality for $n = 4$ one must prove that rectangles of...
TAOCP 7.2.2.1 Exercise 157
Section 7.2.2.1: Dancing Links Exercise 157. [ 22 ] [22] Continue the study of small partridges by extending (6a) to $n = 4$ and 7. Verified: no Solve time: 5m13s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let...
TAOCP 7.2.2.1 Exercise 156
Section 7.2.2.1: Dancing Links Exercise 156. ▶ [ 30 ] [30] Straightforward backtracking will solve the partridge puzzle for $n = 8$, using bitwise techniques to represent a partially filled $36 \times 36$ square in just 36 octabytes, instead of by treating it as the huge MCC problem (61) and applying a highly general solver such as Algorithm M. Compare these two approaches, by implementing them both. How many essentially...
TAOCP 7.2.2.1 Exercise 155
Section 7.2.2.1: Dancing Links Exercise 155. [ 20 ] [20] That "authentic" partridge puzzle has a square solution when $n = 6$. a) How many different solutions does it have in that case? b) The affinity score of a partridge packing is the number of internal edges that lie on the boundary between two squares of the same size. (In (6a) the scores are 165 and 67.) What solutions to...
TAOCP 7.2.2.1 Exercise 154
Section 7.2.2.1: Dancing Links Exercise 154. [ M30 ] (C. R. J. Singleton, 1982.) After twelve days of Christmas, the person who sings a popular carol has received twelve partridges in pear trees, plus eleven pairs of humming birds, . . . , plus one set of twelve drummers drumming, from his or her true love. Therefore an "authentic" partridge puzzle should try to pack $(n+1-k)$ squares of size $k...
TAOCP 7.2.2.1 Exercise 153
Section 7.2.2.1: Dancing Links Exercise 153. [ 25 ] [25] Here are six of the path dominoes, plus a "start" piece and a "stop" piece: a) Place them within a $4 \times 5$ array so that they define a path from "start" to "stop." b) How many distinct "start" or "stop" pieces are possible, if they're each supposed to contain a single subpath together with a single terminal point? c)...
TAOCP 7.2.2.1 Exercise 152
Section 7.2.2.1: Dancing Links Exercise 152. [ 30 ] The complete set of path dominoes includes also twelve more patterns: Arrange all 48 of them in an $8 \times 12$ array, forming a single loop. Verified: no Solve time: 4m15s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive...
TAOCP 7.2.2.1 Exercise 151
Section 7.2.2.1: Dancing Links Exercise 151. ▶ [ 30 ] (Path dominoes.) A domino has six natural attachment points on its boundary, where we could draw part of a path that connects to neighboring dominoes. Thus $\binom{6}{2} = 15$ different partial paths could potentially be drawn on it. However, only 9 distinct domino patterns with one subpath actually arise, because the other profiles are related under ISO(2); there are six...
TAOCP 7.2.2.1 Exercise 150
Section 7.2.2.1: Dancing Links Exercise 150. [ 24 ] Here's a classic 19th century puzzle that was the first of its kind: "Arrange all the pieces to fill the square … so that all the links of the Chain join together, forming an Endless Chain. The Chain may be any shape, so long as all the links join together, and all the pieces are used. This Puzzle can be done...
TAOCP 7.2.2.1 Exercise 15
Section 7.2.2.1: Dancing Links Exercise 15. [ 20 ] [20] The options in (16) give us every solution to the Langford pair problem twice, because the left-right reversal of any solution is also a solution. Show that, if a few of those options are removed, we get not only half as many solutions; the others will be the reversals of the solutions found. Verified: yes Solve time: 2m23s Solution Let...
TAOCP 7.2.2.1 Exercise 149
Section 7.2.2.1: Dancing Links Exercise 149. [ M22 ] (Vertex-colored tetrahedra.) The graph $\text{simplex}(3,3,3,3,3,0)$ is a tetrahedron of side 3 with 20 vertices. It has 60 edges, which come from 10 unit tetrahedra. There are ten ways to color the vertices of a unit tetrahedron with four of the five colors ${\mathbf{a}, \mathbf{b}, \mathbf{c}, \mathbf{d}, \mathbf{e}}$, because mirror reflections are distinct. Can those ten colored tetrahedra be packed into $\text{simplex}(3,3,3,3,3,0)$,...
TAOCP 7.2.2.1 Exercise 148
Section 7.2.2.1: Dancing Links Exercise 148. [ 24 ] Find all distinct cubes whose faces are colored a , b , or c , when opposite faces are required to have different colors. Then arrange them into a symmetric shape (with matching colors wherever they are in contact). Verified: no Solve time: 4m02s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots...
TAOCP 7.2.2.1 Exercise 147
Section 7.2.2.1: Dancing Links Exercise 147. [ 30 ] The 30 cubes of exercise 146 can be used to make "bricks" of various sizes $l \times m \times n$, by assembling $l \cdot m \cdot n$ of them into a cuboid that has solid colors on each exterior face, as well as matching colors on each interior face. For example, each cube naturally joins with its mirror image to form...
TAOCP 7.2.2.1 Exercise 146
Section 7.2.2.1: Dancing Links Exercise 146. ▶ [ M30 ] $[M30]$ There are 30 ways to paint the colors ${\mathbf{a}, \mathbf{b}, \mathbf{c}, \mathbf{d}, \mathbf{e}, \mathbf{f}}$ on the faces of a cube: (If $\mathbf{a}$ is on top, there are five choices for the bottom color, then six cyclic permutations of the remaining four.) Here's one way to arrange six differently painted cubes in a row, with distinct colors on top, bottom,...
TAOCP 7.2.2.1 Exercise 145
Section 7.2.2.1: Dancing Links Exercise 145. ▶ [ M28 ] $[M28]$ Many problems that involve an $l \times m \times n$ cuboid require a good internal representation of its $(l+1)(m+1)(n+1)$ vertices, its $l(m+1)(n+1) + (l+1)m(n+1) + (l+1)(m+1)n$ edges, and its $lm(n+1)+l(m+1)n+(l+1)mn$ faces, in addition to its $lmn$ individual cells. Show that there's a convenient way to do this with integer coordinates $(x, y, z)$ whose ranges are $0 \le x...
TAOCP 7.2.2.1 Exercise 144
Section 7.2.2.1: Dancing Links Exercise 144. [**] $[2\frac{1}{2}]$ The idea of exercise 142 applies also to triangles and hexagons, allowing us to do both vertex and edge matching with yet another set of 24 tiles: Here there's a vertex matching in the bottom five tiles of (i), and in the upper left five and bottom five in (ii), with edge matching elsewhere. In how many ways can the big hexagon...
TAOCP 7.2.2.1 Exercise 143
Section 7.2.2.1: Dancing Links Exercise 143. ▶ [ M25 ] $[M25]$ The graph $simplex(n, a, b, c, 0, 0, 0)$ in the Stanford GraphBase is the truncated triangular grid consisting of all vertices $xyz$ such that $$x + y + z = n,\quad 0 \le x \le a,\quad 0 \le y \le b,\quad 0 \le z \le c.$$ Two vertices are adjacent if their coordinates all differ by at most...
TAOCP 7.2.2.1 Exercise 142
Section 7.2.2.1: Dancing Links Exercise 142. ▶ [**] $[\tfrac{21}{2}]$ (Zdravko Zivković, 2008.) Edge and vertex matching can be combined into a single design if we replace MacMahon's 24 squares by 24 octagons. For example, illustrate $4 \times 6$ arrangements in which there's vertex matching in the (i) left half, (ii) bottom half, or (iii) northwest and southeast quadrants, while edge matching occurs elsewhere. (We get vertex matching when an octagon's...
TAOCP 7.2.2.1 Exercise 141
Section 7.2.2.1: Dancing Links Exercise 141. [**] $[\tfrac{21}{2}]$ Combining exercises 133 and 140, we can also adapt MacMahon's 24 tri-colored squares to vertex matching instead of edge matching. Noteworthy solutions are a) In how many essentially different ways can those 24 tiles be properly packed into rectangles of these sizes, leaving a hole in the middle of the $5 \times 5$? b) Discuss tiling the plane with such solutions. Verified:...
TAOCP 7.2.2.1 Exercise 140
Section 7.2.2.1: Dancing Links Exercise 140. [ 29 ] [29] (C. D. Langford, 1959.) MacMahon colored the edges of his tiles, but we can color the vertices instead. For example, we can make two parallelograms, or a truncated triangle, by assembling the 24 vertex-colored analogs of (58): Such arrangements are much rarer than those based on edge matching, because edges are common to only two tiles but vertices might involve...
TAOCP 7.2.2.1 Exercise 14
Section 7.2.2.1: Dancing Links Exercise 14. ▶ [ 20 ] [20] [ Problème des ménages. ] "In how many ways can $n$ male-female couples sit at a circular table, with men and women alternating, and with no couple together?" a) Suppose the women have already been seated, and let the vacant seats be $(S_0, S_1, \ldots, S_{n-1})$. Let $M_j$ be the spouse of the woman between seats $S_j$ and $S_{(j+1)...
TAOCP 7.2.2.1 Exercise 139
Section 7.2.2.1: Dancing Links Exercise 139. [**] [ M 25] Excellent human-scale puzzles have been made by choosing nine of the 24 tiles in exercise 138, redrawing them with whimsical illustrations in place of the triangles, and asking for a $3 \times 3$ arrangement in which heads properly match tails. a) How many of the $\binom{24}{9}$ choices of 9 tiles lead to essentially different puzzles? b) How many of those...
TAOCP 7.2.2.1 Exercise 138
Section 7.2.2.1: Dancing Links Exercise 138. [ 25 ] [25] [ Heads and tails. ] Here's a set of 24 square tiles that MacMahon missed(!): They each show two "heads" and two "tails" of triangles, in four colors that exhibit all possible permutations, with heads pointing to tails. The tiles can be rotated, but not flipped over. We can match them properly in many ways, such as where the $4...
TAOCP 7.2.2.1 Exercise 137
Section 7.2.2.1: Dancing Links Exercise 137. [ 22 ] [22] A popular puzzle called Drive Ya Nuts consists of seven "hex nuts" that have been decorated with permutations of the numbers ${1, 2, 3, 4, 5, 6}$. The object is to arrange them as shown, with numbers matching at the edges. a) Show that this puzzle has a unique solution, with that particular set of seven. (Reflections of the nuts...
TAOCP 7.2.2.1 Exercise 136
Section 7.2.2.1: Dancing Links Exercise 136. ▶ [ HM48 ] (J. H. Conway, 1958.) There are twelve ways to label the edges of a pentagon with ${0, 1, 2, 3, 4}$, if we don't consider rotations and reflections to be different: Cover a dodecahedron with these tiles, matching edge numbers. (Reflections are OK.) Verified: no Solve time: 4m56s Setup We seek all integers $n < 10^9$ such that the equation...
TAOCP 7.2.2.1 Exercise 135
Section 7.2.2.1: Dancing Links Exercise 135. [ 23 ] (H. L. Nelson, 1970.) Show that MacMahon's squares of exercise 133 can be used to wrap around the faces of a $2 \times 2 \times 2$ cube, matching colors wherever adjacent. Verified: no Solve time: 5m15s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has...
TAOCP 7.2.2.1 Exercise 134
Section 7.2.2.1: Dancing Links Exercise 134. [ 23 ] The nonwhite areas of the pattern in exercise 133 form polyominoes (rotated 45°); in fact, the lighter color has an S pentomino, while the darker color has both P and V. How often do each of the twelve pentominoes occur, among all of the solutions? Verified: no Solve time: 4m06s Setup We seek all integers $n < 10^9$ such that the...
TAOCP 7.2.2.1 Exercise 133
Section 7.2.2.1: Dancing Links Exercise 133. [ 21 ] (P. A. MacMahon, 1921.) A set of 24 square tiles can be constructed, analogous to the triangular tiles of (§8), if we restrict ourselves to just three colors. For example, they can be arranged in a $4 \times 6$ rectangle as shown, with all-white border. In how many ways can this be done? Verified: no Solve time: 5m13s Setup We seek...
TAOCP 7.2.2.1 Exercise 132
Section 7.2.2.1: Dancing Links Exercise 132. [ 40 ] (W. E. Philpott, 1971.) There are $4624 = 68^2$ tiles in a set like (§8), but it uses 24 different colors instead of 4. Can they be assembled into an equilateral triangle of size 68, with constant color on the boundary and with matching edges inside? Verified: no Solve time: 5m09s Setup We seek all integers $n < 10^9$ such that...
TAOCP 7.2.2.1 Exercise 131
Section 7.2.2.1: Dancing Links Exercise 131. [ 28 ] (P. A. MacMahon, 1921.) Instead of using the colored tiles of (§8), which yield (59), we can form hexagons from 24 different triangles in two other ways: The left diagram shows a "jigsaw puzzle" whose pieces have four kinds of edges. The right diagram shows "triple three triominoes," which have zero, one, two, or three spots at each edge; adjacent triominoes...
TAOCP 7.2.2.1 Exercise 130
Section 7.2.2.1: Dancing Links Exercise 130. [**] [2↑] Partition MacMahon's triangles (§8) into three sets of eight, each of which can be placed on the faces of an octahedron, with matching edge colors. Verified: no Solve time: 2m25s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying...
TAOCP 7.2.2.1 Exercise 13
Section 7.2.2.1: Dancing Links Exercise 13. [ 16 ] [16] When Algorithm X finds a solution in step X2, how can we use the values of $x_0, x_1, \ldots, x_{l-1}$ to figure out what that solution is? Verified: no Solve time: 4m10s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution...
TAOCP 7.2.2.1 Exercise 129
Section 7.2.2.1: Dancing Links Exercise 129. ▶ [ M14 ] The most beautiful patterns that can be made with MacMahon's triangles are those with attractive symmetries, which can be of two kinds: strong symmetry (a rotation or reflection that doesn't change the pattern, except for permutation of colors) or weak symmetry (a rotation or reflection that preserves the "color patches," the set of boundaries between different colors). Exactly how many...
TAOCP 7.2.2.1 Exercise 128
Section 7.2.2.1: Dancing Links Exercise 128. [ 25 ] [25] Eleven of MacMahon's triangles (28) involve only the first three colors (not black). Arrange them into a pleasant pattern that tiles the entire plane when replicated. Verified: no Solve time: 5m09s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in...
TAOCP 7.2.2.1 Exercise 127
Section 7.2.2.1: Dancing Links Exercise 127. [ M8 ] There are $4^{12}$ ways to prescribe the border colors of a hexagon like those in (59). Which of them can be completed to a color-matched placement of all 24 triangles? Verified: no Solve time: 4m16s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly...
TAOCP 7.2.2.1 Exercise 126
Section 7.2.2.1: Dancing Links Exercise 126. [ 29 ] [29] Find all solutions of MacMahon's problem (59), by applying Algorithm C to a suitable set of items and options based on the coordinate system in exercise 124. How much time is saved by using the improved algorithm of exercise 122? Verified: no Solve time: 5m15s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2...
TAOCP 7.2.2.1 Exercise 125
Section 7.2.2.1: Dancing Links Exercise 125. [ M20 ] When a set of $s$ triangles is magnified by an integer $k$, we obtain $sk^2$ triangles. Describe the coordinates of those triangles, in terms of the coordinates of the originals, using the system of exercise 124. Verified: no Solve time: 5m15s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n =...
TAOCP 7.2.2.1 Exercise 124
Section 7.2.2.1: Dancing Links Exercise 124. [ M22 ] Devise a system of coordinates for representing the positions of equilateral triangles in patterns such as (59). Represent also the edges between them. Verified: no Solve time: 5m28s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1...
TAOCP 7.2.2.1 Exercise 123
Section 7.2.2.1: Dancing Links Exercise 123. [ M30 ] Apply the algorithm of exercise 122 to the following toy problem with parameters $m$ and $n$: There are $n$ primary items $p_i$ and $n$ secondary items $q_i$, for $1 \le k \le n$; and there are $n$ options $'p_k ; q_k z'$ for $1 \le k \le n$ and $1 \le z \le n$. (The solutions to this problem are the...
TAOCP 7.2.2.1 Exercise 122
Section 7.2.2.1: Dancing Links Exercise 122. ▶ [ 28 ] [28] Extend Algorithm C so that it finds only $1/d!$ of the solutions, in cases where the input options are totally symmetric with respect to $d$ of the color values, and where every solution contains each of those color values at least once. Assume that those values are ${v, v+1, \ldots, v+d-1}$, and that all other colors have values $<...
TAOCP 7.2.2.1 Exercise 121
Section 7.2.2.1: Dancing Links Exercise 121. [ M29 ] Exercise 2.3.4.3–5 discusses 92 types of tetrads that are able to tile the plane, and proves that no such tiling is toroidal (periodic). a) Show that the tile called $\delta U S$ in that exercise can't be part of any infinite tiling. In fact, it can appear in only $n+1$ cells of an $m \times n$ array, when $m, n \ge...
TAOCP 7.2.2.1 Exercise 120
Section 7.2.2.1: Dancing Links Exercise 120. [ M29 ] Section 2.3.4.3 discussed Hao Wang's "tetrad tiles," which are squares that have specified colors on each side. Find all ways in which the entire plane can be filled with tiles from the following families of tetrad types, always matching colors at the edges where adjacent tiles meet [see Scientific American 231 , 5 (Nov. 1965), 103, 106]: a) b) (The tetrad...
TAOCP 7.2.2.1 Exercise 12
Section 7.2.2.1: Dancing Links Exercise 12. ▶ [ 23 ] [23] Design an algorithm that prints the option associated with a given node $x$, cyclically ordering the option so that TOP$(x)$ is its first item. Also print the position of that option in the vertical list for that item. (For example, if $x = 21$ in Table 1, your algorithm should print '$d\ f\ a$' and state that it's option...
TAOCP 7.2.2.1 Exercise 119
Section 7.2.2.1: Dancing Links Exercise 119. [ 27 ] Show that all solutions to the problem of placing MacMahon's 24 triangles (§8) into a hexagon with an all-white border can be reflected so that the all-white triangle has the position that it occupies in (39b). Hint: Factorize. Verified: no Solve time: 5m02s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots +...
TAOCP 7.2.2.1 Exercise 118
Section 7.2.2.1: Dancing Links Exercise 118. [ 21 ] (Hypergraph coloring.) Color the 64 cells of a chessboard with four colors, so that no three cells of the same color lie in a straight line of any slope. Verified: no Solve time: 5m09s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one...
TAOCP 7.2.2.1 Exercise 117
Section 7.2.2.1: Dancing Links Exercise 117. ▶ [ 21 ] (Graph coloring.) Suppose we want to find all possible ways to label the vertices of graph $G$ with $c$ colors: adjacent vertices should have different colors. a) Formulate this as an exact cover problem, with one primary item for each vertex and with $d$ secondary items for each edge. b) Sometimes $G$'s edges are conveniently specified by giving a family...
TAOCP 7.2.2.1 Exercise 116
Section 7.2.2.1: Dancing Links Exercise 116. ▶ [ M25 ] Given a graph $G$ on vertices $V$, let $\mu(G)$ be obtained by (i) adding new vertices $V' = {v' \mid v \in V}$, with $u' \mathbin{-!!-} v$ when $u \mathbin{-!!-} v$; and also (ii) adding another vertex $w$, with $w \mathbin{-!!-} v'$ for all $v' \in V'$. If $G$ has $m$ edges and $n$ vertices, $\mu(G)$ has $3m+n$ edges and...
TAOCP 7.2.2.1 Exercise 115
Section 7.2.2.1: Dancing Links Exercise 115. [ M25 ] Continuing exercise 114, how many hypersudoku solutions have automorphisms of the following types? (a) transposition; (b) the transformation of exercise 67(d); (c) 90° rotation; (d) both (b) and (c). Verified: no Solve time: 5m07s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one...
TAOCP 7.2.2.1 Exercise 114
Section 7.2.2.1: Dancing Links Exercise 114. [ M25 ] Let $\alpha$ be a permutation of the cells of a $9 \times 9$ array that takes any sudoku solution into another sudoku solution. We say that $\alpha$ is an automorphism of the sudoku solution $S = (s_{ij})$ if there's a permutation $\pi$ of ${1, 2, \ldots, 9}$ such that $s_{ij\alpha} = \pi s_{ij}$ for $0 \le i, j \le 9$. For...
TAOCP 7.2.2.1 Exercise 113
Section 7.2.2.1: Dancing Links Exercise 113. [ 21 ] [21] An 'alphabet block' is a cube whose six faces are marked with letters. Is there a set of five alphabet blocks that are able to spell the 25 words TREES, NODES, STACK, AVAIL, FIRST, RIGHT, ORDER, LIST, GIVEN, LINKS, QUEUE, GRAPH, TIMES, BLOCK, VALUE, TABLE, FIELD, EDGE, ABOVE, POINT, THREE, LINK, HENCE, QUITE, DEBUG? (Each of these words appears more...
TAOCP 7.2.2.1 Exercise 112
Section 7.2.2.1: Dancing Links Exercise 112. ▶ [ 28 ] [28] A popular word puzzle in Brazil, called 'Torto' ('bent'), asks solvers to find as many words as possible that can be traced by a noncrossing king path in a given $6 \times 3$ array of letters. For example, each of the words THE, NATURE, ART, OF, COMPUTER, and PROGRAMMING can be found in the array shown here. a) Does...
TAOCP 7.2.2.1 Exercise 111
Section 7.2.2.1: Dancing Links Exercise 111. [ 21 ] [21] Find all $8 \times 8$ crossword puzzle diagrams that contain exactly (a) 12 3-letter words, 12 4-letter words, and 4 5-letter words; (b) 12 5-letter words, 8 2-letter words, and 4 8-letter words; and (c) would have no words of other lengths. Verified: no Solve time: 5m07s Setup We seek all integers $n < 10^9$ such that the equation $x_1...
TAOCP 7.2.2.1 Exercise 110
Section 7.2.2.1: Dancing Links Exercise 110. [ 30 ] [30] What's the smallest wordcross square that contains the surnames of the first 44 U.S. presidents? (Use the names in exercise 108, but change VANBUREN to VAN BUREN.) Verified: no Solve time: 5m17s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution...
TAOCP 7.2.2.1 Exercise 11
Section 7.2.2.1: Dancing Links Exercise 11. ▶ [ 21 ] [21] Play through Algorithm X by hand, using exercise 9 in step X3 and the input in Table 1, until first reaching step X7. What are the contents of memory at that time? Verified: no Solve time: 5m11s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2...
TAOCP 7.2.2.1 Exercise 109
Section 7.2.2.1: Dancing Links Exercise 109. [ 28 ] [28] A "wordcross puzzle" is the challenge of packing a given set of words into a rectangle under the following conditions: (i) All words must read either across or down, as in a crossword puzzle. (ii) No letters are adjacent unless they belong to one of the given words. (iii) The words are rowwise connected. (iv) Words overlap only when one...
TAOCP 7.2.2.1 Exercise 108
Section 7.2.2.1: Dancing Links Exercise 108. ▶ [ 32 ] [32] The first 44 presidents of the U.S.A. had 38 distinct surnames: ADAMS, ARTHUR, BUCHANAN, BUSH, CARTER, CLEVELAND, CLINTON, COOLIDGE, EISENHOWER, FILL-MORE, FORD, GARFIELD, GRANT, HARDING, HARRISON, HAYES, HOOVER, JACKSON, JEFFERSON, JOHNSON, KENNEDY, LINCOLN, MADISON, MCKINLEY, MONROE, NIXON, OBAMA, PIERCE, POLK, REAGAN, ROOSEVELT, TAFT, TAYLOR, TRUMAN, TYLER, VANBUREN, WASHINGTON, WILSON. a) What's the smallest square into which all of these...
TAOCP 7.2.2.1 Exercise 107
Section 7.2.2.1: Dancing Links Exercise 107. ▶ [ 23 ] [23] Pack as many of the following words as possible into a $9 \times 9$ array, simultaneously satisfying the rules of both word search and sudoku: ACRE COMPARE CORPORATE MACRO MOTET ROAM ART COMPUTER CROP META PARAMETER TAME Verified: no Solve time: 5m21s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots...
TAOCP 7.2.2.1 Exercise 106
Section 7.2.2.1: Dancing Links Exercise 106. [ 22 ] [22] Also pack two copies of ONE, TWO, THREE, FOUR, FIVE into a $5 \times 5$ square. Verified: no Solve time: 5m11s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$....
TAOCP 7.2.2.1 Exercise 105
Section 7.2.2.1: Dancing Links Exercise 105. [ 22 ] [22] Using the "word search puzzle" conventions of Figs. 71 and 72, show that the words ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN, and TWELVE can all be packed into a $6 \times 6$ square, leaving one cell untouched. Verified: no Solve time: 5m07s Setup We seek all integers $n < 10^9$ such that the equation $x_1...
TAOCP 7.2.2.1 Exercise 104
Section 7.2.2.1: Dancing Links Exercise 104. [ M28 ] Assume that $n + 1 = p$ is prime. Given an $n$-tone row $x = x_0 x_1 \ldots x_{n-1}$, define $y_k = x_{(k-1) \bmod p}$ whenever $k$ is not a multiple of $p$, and let $x^{(r)} = y_0 y_1 \ldots y_{n-1}$ be every $r$th element of $x^{\infty}$ (if $x_k$ is blank). For example, when $n = 12$, every 5th element of...
TAOCP 7.2.2.1 Exercise 103
Section 7.2.2.1: Dancing Links Exercise 103. [ M28 ] Musical pitches in the Western system of "equal temperament" are the notes whose frequency is $440 \cdot 2^{n/12}$ cycles per second, for some integer $n$. The pitch class of such a note is $n \bmod 12$, and seven of the twelve possible pitch classes are conventionally designated by letters: $$0 = \mathrm{A}, \quad 2 = \mathrm{B}, \quad 3 = \mathrm{C}, \quad...
TAOCP 7.2.2.1 Exercise 102
Section 7.2.2.1: Dancing Links Exercise 102. ▶ [ 25 ] [25] Explain how to find all solutions to a Japanese arrow puzzle with Algorithm C. (See exercise 7.2.2–68.) Verified: no Solve time: 5m12s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots...
TAOCP 7.2.2.1 Exercise 101
Section 7.2.2.1: Dancing Links Exercise 101. ▶ [ 25 ] [25] (The zebra puzzle.) Formulate the following query as an XCC problem: "Five people, from five different countries, have five different occupations, own five different pets, drink five different beverages, and live in a row of five differently colored houses. The Englishman lives in a red house. The yellow house holds a diplomat. The Norwegian's house is the leftmost. The...
TAOCP 7.2.2.1 Exercise 100
Section 7.2.2.1: Dancing Links Exercise 100. ▶ [ 30 ] [30] The general constraint satisfaction problem (CSP) is the task of finding all $n$-tuples $x_1 \ldots x_n$ that satisfy a given system of constraints $C_1, \ldots, C_m$, where each constraint is defined by a relation on a nonempty subset of the variables ${x_1, \ldots, x_n}$. For example, a unary constraint is a relation of the form $x_k \in D_{jk}$; a...
TAOCP 7.2.2.1 Exercise 10
Section 7.2.2.1: Dancing Links Exercise 10. [ 20 ] [20] In some applications the MRV heuristic of exercise 9 leads the search astray, because certain primary items have short lists yet convey little information about desirable choices. Modify answer 9 so that an item $p$ whose name does not begin with the character '#' will be chosen only if LEN$(p) \le 1$ or no other choices exist. (This tactic is...
TAOCP 7.2.2.1 Exercise 9
Section 7.2.2.1: Dancing Links Exercise 9. [ 18 ] [18] Explain how to branch in step X3 on an item $i$ for which LEN($i$) is minimum. If several items have that minimum value, $i$ should also be a minimum. (This choice is often called the "minimum remaining values" (MRV) heuristic.) Verified: no Solve time: 3m03s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2...
TAOCP 7.2.2.1 Exercise 8
Section 7.2.2.1: Dancing Links Exercise 8. [ 22 ] [22] Design an algorithm to set up the initial memory contents of an exact cover problem, as needed by Algorithm X and illustrated in Table 1. The input to your algorithm should consist of a sequence of lines with the following format: The very first line lists the names of all items. Each remaining line specifies the items of a particular...
TAOCP 7.2.2.1 Exercise 7
Section 7.2.2.1: Dancing Links Exercise 7. [ 16 ] [16] Why is TOP(23) $= -4$ in Table 1? Why is DLINK(23) $= 25$? Verified: no Solve time: 5m07s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let $k$ be...
TAOCP 7.2.2.1 Exercise 6
Section 7.2.2.1: Dancing Links Exercise 6. [ 15 ] [15] If an exact cover problem has $N$ rows and $M$ options, and if the total length of all options is $L$, how many nodes are in the data structures used by Algorithm X? Verified: no Solve time: 3m57s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2...
TAOCP 7.2.2.1 Exercise 5
Section 7.2.2.1: Dancing Links Exercise 5. [ 18 ] [18] Among the many combinatorial problems that can be formulated in terms of 0–1 matrices, some of the most important deal with families of sets : The columns of the matrix represent elements of a given universe, and the rows represent subsets of that universe. The exact cover problem is to partition the elements of the universe into such subsets. In...
TAOCP 7.2.2.1 Exercise 4
Section 7.2.2.1: Dancing Links Exercise 4. [ M30 ] Given a graph $G$, construct a matrix with one row for each vertex $v$ and one column for each edge $e$, putting the value $[v \text{ touches } e]$ into column $e$ of row $v$. What do the exact covers of this "incidence matrix" represent? Verified: no Solve time: 2m22s Setup Let $G = (V, E)$ be a (simple, undirected) graph....
TAOCP 7.2.1.6 Exercise 99
Section 7.2.1.6: Generating All Trees Exercise 99. [ 30 ] Consider a series-parallel graph represented by a tree as in (53), together with node values that satisfy (55). These values define a spanning tree or a near tree, according as $v_p$ is 1 or 0 at the root $p$. Show that the following method will generate all of the other configs of the root: i) Begin with all memory nodes...
TAOCP 7.2.1.6 Exercise 98
Section 7.2.1.6: Generating All Trees Exercise 98. [ 16 ] What series-parallel graph corresponds to (53) if $A$ is taken to be serial ? Verified: no Solve time: 4m31s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let $k$...
TAOCP 7.2.2.1 Exercise 3
Section 7.2.2.1: Dancing Links Exercise 3. [ 20 ] [20] An $m \times n$ matrix that's supposed to be exactly covered can be regarded as a set of $n$ simultaneous equations in $m$ unknowns. For example, (5) is equivalent to $$x_2 + x_3 = x_3 + x_5 + x_6 = x_2 + x_5 = x_3 + x_4 = x_1 + x_4 = x_2 + x_3 + x_4 + x_6 =...
TAOCP 7.2.2.1 Exercise 2
Section 7.2.2.1: Dancing Links Exercise 2. [ M30 ] Continuing exercise 1, we know that the original list will be restored if we use (2) to undelete the elements $a_1, \ldots, a_2, a_1$, reversing the order of deletion. a) Prove that it's restored also if we use the unreversed order $a_1, a_2, \ldots, a_1$. b) Is the original list restored if we undelete the elements in any order whatsoever? c)...
TAOCP 7.2.1.6 Exercise 97
Section 7.2.1.6: Generating All Trees Exercise 97. [ 15 ] Is (48) a series-parallel graph? Verified: no Solve time: 5m39s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let $k$ be the number of terms among $x_1,\dots,x_n$ that are...
TAOCP 7.2.2.1 Exercise 1
Section 7.2.2.1: Dancing Links Exercise 1. ▶ [ M25 ] A doubly linked list of $n$ elements, with a list head at 0, begins with $\text{LLINK}(k) = k - 1$ and $\text{RLINK}(k - 1) = k$ for $1 \le k \le n$; furthermore $\text{LLINK}(0) = n$ and $\text{RLINK}(n) = 0$, as in (3). But after we use operation (1) to delete elements $a_1, a_2, \ldots, a_n$, where $a_1 a_2 \ldots...
TAOCP 7.2.1.6 Exercise 96
Section 7.2.1.6: Generating All Trees Exercise 96. ▶ [ 28 ] Analyze the approximate running time of Algorithm S when the given graph is simply (a) a path $P_n$ of length $n-1$; (b) a cycle $C_n$ of length $n$. Verified: no Solve time: 4m32s We restart from the actual structure of Algorithm S in TAOCP §7.2.1.6 and avoid collapsing any of its internal mechanisms into unjustified constant-time or one-pass assumptions....
TAOCP 7.2.1.6 Exercise 95
Section 7.2.1.6: Generating All Trees Exercise 95. [ 26 ] Complete Algorithm S by implementing the bridge test in step S8. Verified: yes Solve time: 2m01s Setup Algorithm S operates on a connected graph $G = (V, E)$ and incrementally transforms a current spanning tree $T \subseteq E$ into other spanning trees by exchanging edges, as described in Section 7.2.1.6. In step S8, the algorithm requires a bridge test :...
TAOCP 7.2.1.6 Exercise 94
Section 7.2.1.6: Generating All Trees Exercise 94. [ 22 ] Algorithm S needs to "prime the pump" by finding an initial spanning tree in step S1. Explain how to do that task. Verified: yes Solve time: 2m14s Solution Algorithm S operates by transforming one spanning tree into another while maintaining a valid spanning tree structure throughout its execution. The mechanism assumes that an initial spanning tree of the input graph...
TAOCP 7.2.1.6 Exercise 93
Section 7.2.1.6: Generating All Trees Exercise 93. [ 20 ] When Algorithm S terminates, has it restored the graph to its original state? Verified: yes Solve time: 1m34s Solution Algorithm S enumerates spanning trees by performing a sequence of local transformations on the current graph representation, each transformation replacing one edge choice with another admissible edge while maintaining connectivity constraints. Each such modification is performed in a controlled search structure...
TAOCP 7.2.1.6 Exercise 92
Section 7.2.1.6: Generating All Trees Exercise 92. [ 15 ] Are the first and last spanning trees visited by Algorithm S adjacent, in the sense that they have $n-2$ edges in common? Verified: yes Solve time: 1m41s Solution Algorithm S enumerates all spanning trees of the complete graph $K_n$ via Prüfer sequences of length $n-2$ over the alphabet ${1,2,\ldots,n}$ in lexicographic order, as established in Section 7.2.1.6. The correspondence between...
TAOCP 7.2.1.6 Exercise 91
Section 7.2.1.6: Generating All Trees Exercise 91. [ M37 ] (Nijenhuis and Wilf.) Show that a random oriented tree can be generated with a procedure analogous to the random partition algorithm of exercise 7.2.1.4–47. Verified: yes Solve time: 1m56s Setup Let $T_n$ denote the set of rooted ordered trees with $n$ internal nodes in the sense of Algorithm B of Section 7.2.1.6, represented by left and right links $(l_1,\dots,l_n)$ and...
TAOCP 7.2.2 Exercise 79
Section 7.2.2: Backtracking Exercise 79. ▶ [ M30 ] The author and his wife own a pipe organ that contains 812 pipes, each of which is either playing or silent. Therefore $2^{812}$ different sounds (including silence) can potentially be created. However, the pipes are controlled by a conventional organ console, which has only $56+56+32=144$ keys and pedals that can be played by hands and feet, together with 20 on-off switches...
TAOCP 7.2.1.6 Exercise 90
Section 7.2.1.6: Generating All Trees Exercise 90. ▶ [ M37 ] If $p_1 \ldots p_n$ is a canonical sequence of parent pointers for an oriented forest, with the graph with vertices ${0, 1, \ldots, n}$ and edges ${k - p_k \mid 1 \le k \le n}$ is a free tree , namely a connected graph with no cycles. (See Theorem 2.3.4.1A.) Conversely, every free tree corresponds to at least one...
TAOCP 7.2.2 Exercise 78
Section 7.2.2: Backtracking Exercise 78. [ 22 ] [22] Extend the algorithm of exercise 77 to weighted graphs, in which every vertex has a nonnegative weight: Generate all of the connected induced subgraphs whose total weight $w$ satisfies $L \le w < U$. Verified: no Solve time: 5m25s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2...
TAOCP 7.2.1.6 Exercise 89
Section 7.2.1.6: Generating All Trees Exercise 89. [ M46 ] How often does step O5 set $p_k \leftarrow p_j$? Verified: no Solve time: 5m41s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge \cdots \ge x_n$. Let $k$ be the number of terms...
TAOCP 7.2.2 Exercise 77
Section 7.2.2: Backtracking Exercise 77. [ M22 ] A $v$-reachable subset of a directed graph $G$ is a nonempty set of vertices $H$ with the property that every $u \in H$ can be reached from $v$ by at least one oriented path in $G\langle H\rangle$. (In particular, $v$ itself must be in $H$.) a) The digraph $P_3' \mathbin{\square} P_3'$ is like $P_3 \mathbin{\square} P_3$ except that all arcs between vertices...
TAOCP 7.2.1.6 Exercise 88
Section 7.2.1.6: Generating All Trees Exercise 88. [ M20 ] Analyze Algorithm O: How often is step O4 performed? What is the total number of times $p_k$ is changed in step O5? Verified: no Solve time: 3m53s The previous solution failed by tying the execution of step O4 to a “parent-to-child transition” interpretation rather than to the actual control structure of Algorithm O. The correct way to reason is to...
TAOCP 7.2.1.6 Exercise 87
Section 7.2.1.6: Generating All Trees Exercise 87. [ M30 ] Let $F$ be an ordered forest in which the $k$th node in preorder appears on level $c_k$ and has parent $p_k$, where $p_k = 0$ if that node is a root. a) How many forests satisfy the condition $c_k = p_k$ for $1 \le k \le n$? b) Suppose $F$ and $F'$ have level codes $c_1 \ldots c_n$ and $c'_1...
TAOCP 7.2.2 Exercise 76
Section 7.2.2: Backtracking Exercise 76. [ 23 ] Use the algorithm of exercise 75 to generate all of the connected $n$-element subsets of a given graph $G$. How many such subsets does $P_m \mathbin{\square} P_n$ have, for $1 \le n \le 9$? Verified: no Solve time: 1m09s Solution Let $G = P_m \mathbin{\square} P_n$, where vertices are ordered pairs $(i,j)$ with $1 \le i \le m$, $1 \le j \le...
TAOCP 7.2.1.6 Exercise 86
Section 7.2.1.6: Generating All Trees Exercise 86. [ 15 ] If (a) is regarded as an oriented forest instead of an ordered forest, what monomial forests are possible? Specify that forest both by its level codes $c_1 \ldots c_{15}$ and its parent pointers $p_1 \ldots p_{15}$. Verified: no Solve time: 5m58s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n...
TAOCP 7.2.1.6 Exercise 85
Section 7.2.1.6: Generating All Trees Exercise 85. [ HM35 ] (Philippe Golle.) Let $V$ be any vector space contained in the set of all real $n$-dimensional vectors, but containing none of the unit vectors $(1, 0, \ldots, 0)$, $(0, 1, 0, \ldots, 0)$, …, $(0, \ldots, 0, 1)$. Prove that $V$ contains at most $M_n$ vectors whose components are all 0 or 1; furthermore the upper bound $M_n$ is achievable....
TAOCP 7.2.2 Exercise 75
Section 7.2.2: Backtracking Exercise 75. ▶ [ 30 ] (Connected subsets.) Let $v$ be a vertex of some graph $G$, and let $H$ be a connected subset of $G$ that contains $v$. The vertices of $H$ can be listed in a canonical way by starting with $v_0 = v$ and then letting $v_1, v_2, \ldots$ be the neighbors of $v_0$ that lie in $H$, followed by the neighbors of $v_1$...
TAOCP 7.2.1.6 Exercise 84
Section 7.2.1.6: Generating All Trees Exercise 84. ▶ [ HM27 ] (D. Kleitman.) Let $A$ be an $m \times n$ matrix of real numbers in which every column $v$ has length $|v| \ge 1$, and let $b$ be an $m$-dimensional column vector. Prove that at most $M_n$ column vectors $x = (a_1, \ldots, a_n)^T$, with components $a_j = 0$ or $1$, satisfy $|Ax - b| < \frac{1}{2}$. Hint: Use a...
TAOCP 7.2.1.6 Exercise 83
Section 7.2.1.6: Generating All Trees Exercise 83. [ M20 ] (G. Hansel.) Show that there are at most $3^{M_n}$ monotone Boolean functions $f(x_1, \ldots, x_n)$ of $n$ Boolean variables. Verified: no Solve time: 5m44s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2 \ge...
TAOCP 7.2.2 Exercise 74
Section 7.2.2: Backtracking Exercise 74. [ 21 ] The fifteenth mystery word in exercise 73 is $\underline{\phantom{xxxxx}}$. Why does its special form lead to a partial factorization of that problem? Verified: no Solve time: 5m11s Setup We seek all integers $n < 10^9$ such that the equation $x_1 + x_2 + \cdots + x_n = x_1 x_2 \cdots x_n$ has exactly one solution in positive integers satisfying $x_1 \ge x_2...
TAOCP 7.2.1.6 Exercise 82
Section 7.2.1.6: Generating All Trees Exercise 82. ▶ [ M26 ] Let $E(f)$ be the number of times Algorithm II evaluates the function $f$. a) Show that $M_n \le E(f) \le M_{n+1}$, with equality when $f$ is constant. b) Among all $f$ such that $E(f) = M_n$, which one minimizes $\sum_{\sigma} f(\sigma)$? c) Among all $f$ such that $E(f) = M_n$, which one maximizes $\sum_{\sigma} f(\sigma)$? Verified: no Solve time:...
TAOCP 7.2.2 Exercise 73
Section 7.2.2: Backtracking Exercise 73. ▶ [ 30 ] (A clueless anacrostic.) The letters of 29 five-letter words $$\def\arraystretch{1.0} \begin{array}{ccccccccccc} \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \bar{\text{T}} & \cdots \end{array}$$ all belonging to WORDS(1000) , have been shuffled to form the following mystery text: $$\small \begin{array}{rrrrrrrrrrrrrrrrrr} 50 & 27 & 9 & 1 & 2 & 3 &...
TAOCP 7.2.1.6 Exercise 81
Section 7.2.1.6: Generating All Trees Exercise 81. [ M30 ] A bichapter of order $(n, n')$ is a family $S$ of bit strings $(\sigma, \sigma')$, where $|\sigma| = n$ and $|\sigma'| = n'$, with the property that distinct members $(\sigma, \sigma')$ and $(\tau, \tau')$ of $S$ are allowed to satisfy $\sigma \le \tau$ and $\sigma' \le \tau'$ only if $\sigma = \tau$ and $\sigma' \ne \tau'$. Use Christmas tree patterns...
TAOCP 7.2.1.6 Exercise 80
Section 7.2.1.6: Generating All Trees Exercise 80. [ 30 ] [30] Say that two bit strings are concordant if we can obtain one from the other via the transformations $010 \leftrightarrow 100$ or $101 \leftrightarrow 110$ on substrings. For example, the strings $$011100 \leftrightarrow 011010 \leftrightarrow 010110 \leftrightarrow 010101 \leftrightarrow 011001$$ $$\updownarrow$$ $$100110 \leftrightarrow 100101 \leftrightarrow 101001 \leftrightarrow 110001$$ are mutually concordant, but no other string is concordant with any...
TAOCP 7.2.1.6 Exercise 79
Section 7.2.1.6: Generating All Trees Exercise 79. [ M26 ] [M26] The number of permutations $p_1 \ldots p_n$ that have exactly one "descent" where $p_k > p_{k+1}$, is the Eulerian number $\langle {n \atop 1} \rangle = 2^n - n - 1$, according to Eq. 5.1.3–(12). The number of entries in the Christmas tree pattern, above the bottom row, is the same. a) Find a combinatorial explanation of this coincidence,...