The Art of Computer Programming 4A (7-7.1.1)
仅供看一乐。
7 Combinatorial Searching
\(L_n\) is the number of permutations of \(\{1,1,\ldots,n,n\}\) such that there are exact \(i\) numbers between two \(i\)s. Reverse regard as the same one.
Graph Algebra
If \(G=(V,E)\) is any graph, its complement \(\overline{G}=(V,\overline E)\) is obtained by letting
Given two graphs \(G=(U,E)\) and \(H=(V,F)\), their union is the graph \((U\cup V,E\cup F)\). In the special case where \(U\) and \(V\) are disjoint, this case is called direct sum, donate it by \(G \oplus H\).
Another way to combine disjoint graph is join \(G - H\), which consist of \(G\oplus H\) together with all edges \(u-v\) for \(u\in U\) and \(v\in V\).
Cartesian product operation forms a graph \(G\Box H\) of order \(mn\) from a graph \(G=(U,E)\) of order \(m\) and a graph \(H=(V,F)\) of order \(n\). The vertices of \(G\square H\) are ordered pairs \((u,v)\), where \(u\in U\) and \(v\in V\); the edges are \((u,v)-(u',v)\) when \(u-u'\) in \(G\), together with \((u,v)-(u,v')\) when \(v-v'\) in \(H\).
The direct product \(G\otimes H\), also called "conjunction" or "categorical product", has \((u,v)-(u',v')\) when \(u-u'\) in \(G\) and \(v-v'\) in \(H\).
The strong product \(G\boxtimes H\) combines the edges of \(G\Box H\) and \(G\otimes H\).
The odd product \(G\triangle H\) has \((u,v)-(u',v')\) when either \(u-u'\) in \(G\) or \(v-v'\) in \(H\), but not both.
The lexicographic product \(G\circ H\), also called "composition", has \((u,v)-(u',v')\) when \(u-u'\) in \(G\), and has \((u,v)-(u,v')\) when \(v-v'\) in \(H\).
Exercise 7
-
\([\mathcal{M28}]\) Let \(f(x_1,\ldots,x_{2n})=\prod_{k=1}^n(x_kx_{n+k} \sum_{j=1}^{2n-k-1} x_jx_{j+k+1})\).
(a) Prove that \(\sum_{x_1,\ldots,x_{2n}\in \{-1,+1\}} f(x_1,\ldots,x_{2n})=2^{2n+1} L_n\).
展开 \(f\) 的多项式,其为 \(2n\) 次齐次多项式,注意到所有 \(x_1^2\cdots x_n^2\) 项对应了一个满足条件的排列,其他项至少有一个 \(i\) 满足 \(x_i\) 指数为奇数。所有 \(x_i\) 以及左右翻转给出了系数 \(2^{2n+1}\)。
(b) Explain how to evaluate this sum in \(O(4^nn)\) steps. How many bits of precision are needed for the arithmetic?
按 Gray-Code 顺序枚举所有 \(x_i\)。可以模大质数计算。
(c) Gain a factor of eight by exploiting the identities
\[f(x_1,\ldots,x_{2n})=f(-x_1,\ldots,-x_{2n})=f(x_{2n},\ldots,x_{1})=f(x_1,-x_2,\ldots,x_{2n-1},-x_{2n}) \]利用第 1,3 个等号,即得
\[2^{2n-1}L_n=\sum_{x_2,\ldots,x_{2n-1}\in \{-1,+1\}} f(1,x_2,\ldots,x_{2n-1},1) \]考虑 \(x_2\) 和 \(x_{2n-1}\) 是否相同,若不同,记 \(s_2=\sum_{x_3,\ldots,x_{2n-1}\in \{-1,+1\}} f(1,1,x_3,\ldots,x_{2n-1},1)\)。若相同,记 \(d=\sum_{x_2,\ldots,x_{2n-2}\in \{-1,+1\}} f(1,x_2,\ldots,x_{2n-2},x_2,1)\)。利用第 2 个等号,得到
\[2^{2n-1}L_n=2s_2+d \]重复如上操作,记 \(s_i=\sum_{x_2,\ldots,x_{i-1},x_{i+1},\ldots,x_{2n-i+1}\in \{-1,+1\}} f(1,x_2,\dots,x_{i-1},1,x_{i+1},\ldots,x_{2n-i+1},1,x_{i-1},\ldots,x_{n-1},1)\)。得到
\[2^{2n-2}L_n=s_n/2+\sum_{i=2}^{n-1} s_i \] -
\([\mathcal{M22}]\) Prove that every Langford pairing of \(\{1,1,\ldots,16,16\}\) must have seven uncompleted pairs at some point, when read from left to right.
令 \(n=16\)。对于一个合法的序列 \(a_1,\ldots,a_{2n}\),设长为 \(2n\) 的序列 \(b\) 满足,每个 \(i\),记 \(a_x=a_y=i,x<y\),则 \(b_x=1,b_y=-1\)。定义序列 \(s\) 满足 \(s_0=0,s_i=s_{i-1}+b_i\)。考虑 \(\sum_{i=0}^{2n} s_i\),由 Langford pairing 性质给出其等于 \(\sum_{i=1}^n (i+1)=152\)。若 \(\forall i, s_i\le 6\),满足 \(|s_i-s_{i-1}|=1\) 最大可能的 \(\sum_{i=0}^{2n} s_i\) 在 \(\{s_i\}\) 为 \(0,1,2,3,4,5,6,5,6,\ldots,5,6,5,4,3,2,1,0\) 时得到,其值为 \(146\),矛盾。
-
\([\mathcal{M21}]\) Let \(L_{ij}=(i+j) \bmod n\) for \(0 \le i, j < n\) be the addition table for integers mod \(n\). Prove that a latin square orthogonal to \(L\) exists if and only if \(n\) is odd.
如果 \(n\) 为偶数,若存在解 \(M\),取 \(\{p_i\}\) 使得 \(M_{i,p_i}=0\),则 \(\{t_i=L_{i,p_i}\}\) 应为排列。然而 $\sum_{i=0}^n (i+p_i) \bmod n \not\equiv \sum_{k=0}^n k \pmod n $,矛盾。
如果 \(n\) 为奇数,取 \(M_{ij}=(i-j)\bmod n\) 即可。
-
\([\mathcal{M25}]\) The string \(x_1x_2 \ldots x_N\) is called "\(n\)-ary" if each element \(x_j\) belongs to the set \(\{0, 1, \ldots , n−1\}\) of \(n\)-ary digits. Two strings \(x_1x_2 \ldots x_N\) and \(y_1y_2 \ldots y_N\) are said to be orthogonal if the \(N\) pairs \((x_j , y_j)\) are distinct for \(1 \le j \le N\). An \(n\)-ary matrix with \(m\) rows and \(n^2\) columns whose rows are orthogonal to each other is called an orthogonal array of order \(n\) and depth \(m\).
Prove that an orthogonal array of order \(n > 1\) and depth \(m\) is possible only if \(m \le n + 1\). Show that this upper limit is achievable when \(n\) is a prime number \(p\). Write out an example when \(p = 5\).
不妨设第一行为 \(0^n1^n\cdots(n-1)^n\),剩下 \(m-1\) 行前 \(n\) 个均为 \(0,1,\ldots,n-1\),这意味着 \(m-1\) 行中其他所有位置之中两两不同,于是给出了 \(m\) 的上界 \(n-1\)。
当 \(p=5\) 时,一个解为
\[\left(\begin{matrix} 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 \\ 0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3 \\ 0 1 2 3 4 2 3 4 0 1 4 0 1 2 3 1 2 3 4 0 3 4 0 1 2 \\ 0 1 2 3 4 3 4 0 1 2 1 2 3 4 0 4 0 1 2 3 2 3 4 0 1 \\ 0 1 2 3 4 4 0 1 2 3 3 4 0 1 2 2 3 4 0 1 1 2 3 4 0 \\ \end{matrix}\right) \] -
\([\mathcal{M21}]\) A geometric net is a system of points and lines that obeys three axioms:
i) Each line is a set of points.
ii) Distinct lines have at most one point in common.
iii) If \(p\) is a point and \(L\) is a line with \(p \not \in L\), then there is exactly one line \(M\) such that \(p \in M\) and \(L \cap M = \varnothing\).
If \(L \cap M = \varnothing\) we say that \(L\) is parallel to \(M\), and write \(L\ ||\ M\).
(a) Prove that the lines of a geometric net can be partitioned into equivalence classes, with two lines in the same class if and only if they are equal or parallel.
传递性利用反证法和 (iii) 即得,自反性显然成立。
(b) Show that if there are at least two classes of parallel lines, every line contains the same number of points as the other lines in its class.
利用 (ii) 两次即得双射。
(c) Furthermore, if there are at least three classes, there are numbers \(m\) and \(n\) such that all points belong to exactly \(m\) lines and all lines contain exactly \(n\) points.
利用 (ii) 可得每条线上点的双射,即得每条线都包含 \(n\) 个点。而 \(m\) 即为等价类个数。
-
\([\mathcal{M22}]\) Show that every orthogonal array can be regarded as a geometric net. Is the converse also true?
对于一个 orthogonal array with order \(n\) and depth \(m\),可以构造一个 geometric net with \(m\) classes and \(n^2\) point,设 point 编号为 \(1,\ldots,n^2\),orthogonal array 的每行对应一个 class,对于一行 \(\{a_i\}\),其对应的 class 包含 \(n\) 条直线 \(\{\{j\ |\ a_j=k\}\ |\ 0\le k<n\}\)。容易验证其满足三条公理。
若 \(m\ge 3\),利用 21(c) 可证点数为 \(n^2\),其确实可以对应到一个 orthogonal array with order \(n\) and depth \(m\)。当 \(m=1,2\) 时显然不能。
-
\([\mathcal{M22}]\) Given a geometric net as described in exercise 21, construct the bipartite graph whose vertices are the points \(p\) and the lines \(L\) of the net, with \(p-L\) if and only if \(p \in L\). What is the girth(the length of the shortest circle) of this graph?
四元环存在将与公理 (ii) 矛盾,所以答案 \(\ge 6\)。
记 geometric net with \(m\) classes and \(n\) point,若 \(m=1\),则无环。若 \(m=2\),若 \(n\ge n'\ge 2\),答案为 \(8\),否则无环。若 \(n\ge 3\),答案为 \(6\)。
-
\([\mathcal{M22}]\) Let \(u\) be a vertex of greatest out-degree in a tournament, and let \(v\) be any other vertex. Prove that \(d(u,v) \le 2\).
对于所有 \(v\) 满足 \(u \rightarrow v\) 直接得到。对于其他所有 \(v\) 满足 \(u \leftarrow v\) 若不存在 \(w\) 使得 \(u \rightarrow w \rightarrow v\),则有 \(v\) 的出度大于 \(u\),与题设矛盾。
-
\([\mathcal{M23}]\) Let \(G\) be a graph of girth \(g\) in which every vertex has at least \(d\) neighbors. Prove that \(G\) has at least \(N\) vertices, where
\[N= \begin{cases} 1+\sum_{0\le k<t} d(d-1)^k, & \text{if } g=2t+1 \\ 1+(d-1)^t+\sum_{0\le k<t} d(d-1)^k, & \text{if } g=2t+2 \end{cases} \]若 \(g=2t+1\),设 \(u\) 为 \(G\) 中任意一点,则满足 \(d(u,v)=k(1\le k \le t)\) 的 \(v\) 至少有 \(d(d-1)^{k-1}\) 个。据此即得 \(N=1+\sum_{0\le k <t} d(d-1)^k\)。
若 \(g=2t+2\),设 \(u\) 为 \(G\) 中任意一点,则满足 \(d(u,v)=k(1\le k \le t)\) 的 \(v\) 至少有 \(d(d-1)^{k-1}\) 个。再取一点 \(u'\) 满足 \(d(u,u')=1\),则满足 \(d(u,v)=t+1\) 且 \(d(u',v)=t\) 的 \(v\) 至少有 \((d-1)^t\) 个。据此即得 \(N=1+(d-1)^t+\sum_{0\le k<t} d(d-1)^k\)。
-
\([\mathcal{M21}]\) Continuing exercise 63, show that there’s a unique graph of girth \(4\), minimum degree \(d\), and order \(2d\), for each \(d \ge 2\).
\(N=2d\) 即为 63 中的下界,为此,每个点的度必须恰好为 \(d\)。即得唯一解为 \(K_{d,d}\)。
-
\([\mathcal{HM31}]\) Suppose graph \(G\) has girth \(5\), minimum degree \(d\), and \(N = d^2+ 1\) vertices.
(a) Prove that the adjacency matrix \(A\) of \(G\) satisfies the equation \(A^2+A = (d−1)I+J\).
利用 63 中的下界,\(G\) 中每个点度数均为 \(d\),对于任意 \(u\ne v\),恰有一条路径长度 \(\le 2\)。所以 \(A^2+A = (d−1)I+J\) 成立。
(b) Since \(A\) is a symmetric matrix, it has \(N\) orthogonal eigenvectors \(x_j\) , with corresponding eigenvalues \(\lambda_j\) , such that \(Ax_j = \lambda_jx_j\) for \(1 \le j \le N\). Prove that each \(\lambda_j\) is either \(d\) or \((-1 \pm \sqrt{4d-3})/2\).
特征值 \(\lambda_1=d\) 对应特征向量 \(x_1=(1,\ldots,1)^T\)。利用 (a) 中结论 \(A^2+A = (d−1)I+J\),得到对于 \(2\le j \le N\),\((\lambda_j^2+\lambda_j-d+1)x_j=Jx_j\),注意到这意味着 \(Jx_j=(0,\ldots,0)^T\),所以 \(\lambda_j^2+\lambda_j-d+1=0\),明所欲证。
(c) Show that if \(\sqrt{4d − 3}\) is irrational, then \(d = 2\).
注意到 \(\sum_{i=1}^N \lambda_i=\operatorname{trace} A=0\),设特征值 \(\lambda=(-1 - \sqrt{4d-3})/2\) 为 \(m\) 重,则有 \(\lambda=(-1 + \sqrt{4d-3})/2\) 为 \(N-m-1\) 重。利用 \(\sqrt{4d − 3}\) 为无理数的性质,得到 \(m=N-m-1\),即 \(m=d^2/2\)。所以 \(d-d^2/2=0\),据此 \(d=2\) 成立。
(d) And if \(\sqrt{4d − 3}\) is rational, \(d \in \{3, 7, 57\}\).
做 (c) 中相同假设,得到 \(\sum_{i=1}^N \lambda_i\) 为
\[\frac{15}{32} + \frac{s}{32} (9 - 32m + s (2 + s (6 + s(-1 + s)))) \]这给出 \(s\) 为 \(15\) 的约数,明所欲证。
-
\([\mathcal{M25}]\) Find all connected graphs \(G\) and \(H\) such that \(G\Box H \cong G \otimes H\).
分析度数最大和最小的点,得到 \(d_u+d_v=d_ud_v\),所以要么 \(G=H=K_1\),要么 \(G=C_n,H=C_m\)。
显然 \(G\Box H\) 是联通的,所以 \(G,H\) 不全为二分图。所以 \(G\Box H\) 不为二分图,所以 \(G,H\) 均不为二分图。这意味着 \(n,m\) 均为奇数。
分析最小奇环长,\(C_n\Box C_m\) 的最小奇环长为 \(\min(n,m)\),\(C_n\otimes C_m\) 的最小奇环长至少为 \(\max(n,m)\),这意味着 \(n=m\)。
同时 \(C_n\Box C_n \cong C_n \otimes C_n\) 确实成立,仅需映 \(C_n\Box C_n\) 中的 \((x,y)(0\le x,y<n)\) 至 \(C_n\otimes C_n\) 中的 \(((x+y)\bmod n,(x-y)\bmod n)\) 即可。
-
\([\mathcal{M25}]\) Let \(A\) be any matrix with \(m > 1\) distinct rows, and \(n \ge m\) columns. Prove that at least one column of \(A\) can be deleted, without making any two rows equal.
考虑反证法,若不存在这样的列,则得到存在至少两个完全相同的行,矛盾。
7.1 Zeros and Ones
7.1.1 Boolean Basics
Functions of \(n\) variables. We can always write
when \(n>0\), for appropriate functions \(g\) and \(h\), by letting
Repeatedly iterating Boole’s procedure \((20)\), using the distributive law, and eliminating constants, leaves us with a formula that is a disjunction of zero or more minterms.
Ingeneral, a disjunction of minterms is called a full disjunctive normal form. And we speak in general of a disjunctive normal form or "DNF" as any disjunction of conjunctions,
where each \(u_{jk}\) is a literal, namely a variable \(x_i\) or its complement. Similarly, any conjunction of disjunctions of literals,
is called a conjunctive normal form, or "CNF".
Theorem Q The shortest DNF of a monotone Boolean function is its disjunctive prime form.
Proof is trivial.
Corollary Q A disjunctive normal form is the disjunctive prime form of a monotone Boolean function if and only if it has no complemented literals and none of its implicants is contained in another.
Medians \(\left< xyz \right>=(x\land y) \lor (y\land z) \lor (z\land x)\). It's also "majority".
A Boolean function \(f(x_1,\ldots,x_n)\) is called self-dual when it satisfies
We’ve noted that a Boolean function is monotone if and only if it can be expressed in terms of \(\land\) and \(\lor\). By the fact that \(\overline{x\land y}=\overline x \lor \overline y\) and \(\overline{x\lor y}=\overline x \land \overline y\), a monotone formula is self-dual if and only if the symbols \(\land\) and \(\lor\) can be interchanged without changing the formula’s value. Thus the median operation is both monotone and self-dual.
Theorem P. Every monotone, self-dual Boolean function \(f(x_1, \ldots , x_n)\) can be expressed entirely in terms of the median operation \(\left<xyz\right>\) (without using constants).
Median algebras and median graphs. A median algebra is any set \(M\) on which a ternary operation \(\left<xyz\right>\) is defined that takes elements of \(M\) into elements of \(M\) and obeys the following three axioms:
- majortity law: \(\left<xxy\right>=x\);
- commutative law: \(\left<xyz\right>=\left<xzy\right>=\left<yxz\right>=\left<yzx\right>=\left<zxy\right>=\left<zyx\right>\);
- associative law: \(\left<xw\left<ywz\right>\right>=\left<\left<xwy\right>wz\right>\).
If \(u\) and \(v\) are any elements of \(M\), the interval \([u\ .. v]\) is defined as follows:
Now let’s define a graph on the vertex set \(M\), with the following edges:
Theorem G. If \(M\) is any finite median algebra, the graph defined by (61) is connected. Moreover, vertex \(x\) belongs to the interval \([u\ . . v]\) if and only if \(x\) lies on a shortest path from \(u\) to \(v\).
Threshold functions. A particularly appealing and important class of Boolean functions \(f(x_1, x_2, \ldots , x_n)\) arises when \(f\) can be defined by the formula
Furthermore, any positive threshold function (75) can be expressed as a special case of the median/majority-of-odd function, because we have
where \(a=\max(0,2t-1-w),b=\max(0,w+1-2t)\) and \(w=\sum w_i\).
Given any Boolean function \(f(x_1, x_2, \ldots , x_n)\), let \(N(f)\) be the number of vectors \(x = (x_1,\ldots, x_n)\) for which \(f(x) = 1\), and let \(\Sigma(f)\) be the sum of all those vectors. For example, if \(f(x_1, x_2) = x_1 \lor x_2\), we have \(N(f) = 3\) and \(\Sigma(f) = (0, 1) + (1, 0) + (1, 1) = (2, 2)\).
Theorem T. Let \(f(x_1, x_2, \ldots , x_n)\) and \(g(x_1, x_2, \ldots , x_n)\) be Boolean functions with \(N(f) = N(g)\) and \(\Sigma(f) = \Sigma(g)\), where \(f\) is a threshold function. Then \(f = g\).
Exercise 7.1
-
(18) \([\mathcal{20}]\) Let \(u_1 \land \cdots \land u_s\) be an implicant in a disjunctive normal form for a Boolean function \(f\), and let \(v_1 \lor \cdots \lor v_t\) be a clause in a conjunctive normal form for the same function. Prove that \(u_i = v_j\) for some \(i\) and \(j\).
反证法,若不存在,则令 \(u_i=1(1\le i\le s),v_j=0(1\le j\le t)\),则有 \(f(x)\) 同时是 \(0\) 和 \(1\)。
-
(26) \([\mathcal{M23}]\) Let \(\mathcal F\) and \(\mathcal G\) be the families of index sets for the prime clauses and the prime implicants of a monotone CNF and a monotone DNF:
\[f(x)=\bigwedge_{I\in \mathcal F} \bigvee_{i\in I} x_i;\ g(x)=\bigvee_{J\in \mathcal G} \bigwedge_{j\in J} x_j \]Efficiently exhibit an \(x\) such that \(f(x) \ne g(x)\) if any of the following conditions hold:
(a) There is an \(I\in \mathcal F\) and a \(J\in \mathcal G\) with \(I\cap J =\varnothing\).
只需取 \(x_k=[k\in J]\),即得 \(f(x)=0,g(x)=1\)。
(b) \(\bigcup_{I\in \mathcal F}I \ne \bigcup_{J\in \mathcal G} J\).
不妨设 \(i\in I \in \mathcal F\) 满足 \(i \not\in \bigcup_{J\in \mathcal J} J\),取 \(x_k=[k \in I \land i\ne k]\),假设 (a) 不成立,则有 \(f(x)=0,g(x)=1\)。
(c) There is an \(I\in \mathcal F\) with \(|I|>|\mathcal G|\), or a \(J\in \mathcal G\) with \(|J|>|\mathcal F|\).
不妨设 \(I\in \mathcal I\) 满足 \(|I|>|\mathcal G|\)。设 \(\mathcal G=\{J_1,\ldots,J_s\}\),令 \(a_k\in I\cap J_k(1\le k\le s)\),由条件,存在 \(i\in I\) 使得 \(\forall k,i\ne a_k\),取 \(x_t=[t\in\bigcup_{k=1}^s\{a_k\}]\),则有 \(f(x)=0,g(x)=1\)。
(d) \(\sum_{I\in \mathcal F}2^{n-|I|} + \sum_{J\in \mathcal G} 2^{n-|J|} < 2^n\), where \(n=|\bigcup_{I\in \mathcal F} I|\).
假设 (b) 不成立,即 \(\bigcup_{I\in \mathcal F}I = \bigcup_{J\in \mathcal G} J\)。\(2^n\) 即为所有有意义的参数种数,\(2^{n-|I|}\) 对应 \(\{x_k\}\) 满足 \(x_i=0 \iff i\in I\),这些 \(\{x_k\}\) 满足 \(f(x)=0\),且 \(\sum_{I\in \mathcal F}2^{n-|I|}\) 为 \(f(x)=0\) 的 \(x\) 个数上界。同理 \(\sum_{J\in \mathcal G} 2^{n-|J|}\) 给出 \(g(x)=1\) 的 \(x\) 个数上界。\(\sum_{I\in \mathcal F}2^{n-|I|} + \sum_{J\in \mathcal G} 2^{n-|J|} < 2^n\) 给出存在 \(x\) 使得 \(f(x)\ne g(x)\)。构造方案逐位确定即可。
-
(28) \([\mathcal{M31}]\) Continuing the previous exercise, consider the following algorithm \(X(\mathcal F, \mathcal G)\), which either returns a vector \(x\) with \(f(x) \ne g(x)\), or returns \(\Lambda\) if \(f = g\):
X1. [Check necessary conditions.] Return an appropriate value \(x\) if condition (a), (b), (c), or (d) in exercise 26 applies.
X2. [Done?] If \(|\mathcal F||\mathcal G| \le 1\), return \(\Lambda\).
X3. [Recurse.] Compute the following reduced families, for a "best" index \(k\):
\[\mathcal F_1=\{I | I\in \mathcal F ,k\not \in I \}, \quad \mathcal F_0=\mathcal F_1 \cup\{I| k\not\in I, I\cup \{k\} \in \mathcal F \} \\ \mathcal G_0=\{J | J\in \mathcal G ,k\not \in J \}, \quad \mathcal G_1=\mathcal G_0 \cup\{J| k\not\in J, J\cup \{k\} \in \mathcal G \} \\ \]Delete any member of \(\mathcal F_0\) or \(\mathcal G_1\) that contains another member of the same family. The index \(k\) should be chosen so that the ratio \(\rho = \min(|\mathcal F_1|/|\mathcal F|, |\mathcal G_0|/|\mathcal G|)\) is as small as possible. If \(X(\mathcal F_0, \mathcal G_0)\) returns a vector \(x\), return the same vector extended with \(x_k = 0\). Otherwise if \(X(\mathcal F_1, \mathcal G_1)\) returns a vector \(x\), return the same vector extended with \(x_k = 1\). Otherwise return \(\Lambda\).
If \(N = |\mathcal F| + |\mathcal G|\), prove that step X1 is executed at most \(N^{O(\log N)^2}\) times. Hint: Show that we always have \(\rho \le 1 − 1/\lg N\) in step X3.
记 \(m=\min(\{|I|\; |\; I\in \mathcal F\} \cup \{|J|\; |\; J\in \mathcal G\})\),则有 \(N\cdot 2^{n-m} \ge \sum_{I\in \mathcal F}2^{n-|I|} + \sum_{J\in \mathcal G} 2^{n-|J|} \ge 2^n\),这给出 \(m\le \lg N\)。不妨存在 \(I\in \mathcal F\),使得 \(|I|=m\),由 \(\forall J\in \mathcal G\) 均有 \(I\cap J\ne \varnothing\) 得到存在一个 \(i\in I\),其在 \(\mathcal G\) 中被覆盖了多于 \(1/m\),这给出 Hint 结论,即 X3 中 \(\rho \le 1 − 1/\lg N\)。
考虑递归次数,记 \(A(0)=A(1)=1,A(v)=1+A(v-1)+A(\lfloor \rho v \rfloor)\),则 \(A(|\mathcal F||\mathcal G|)\le A(N^2/4)\) 是递归次数的一个上界。设 \(B(v)=A(v)+1\),则有 \(B(v)=B(v-1)+B(\lfloor \rho v \rfloor),v > 1\),对此迭代,给出当 \(k<v\) 时 \(B(v)\le B(v-k)+kB(\lfloor \rho v \rfloor)\)。取 \(k=v-\lfloor \rho v\rfloor\),得到 \(B(v)\le (v-\lfloor\rho v\rfloor+1) B(\lfloor\rho v\rfloor)\)。至此,明所欲证。
-
(31) \([\mathcal{28}]\) The algorithm in exercise 30 requires a complete list of all points where a Boolean function is true, and that list may be quite long. Therefore we may prefer to work directly with subcubes, never going down to the level of explicit \(n\)-tuples unless necessary. The key to such higher-level methods is the notion of consensus between subcubes \(c\) and \(c'\) , denoted by \(c\sqcup c'\) and defined to be the largest subcube \(c''\) such that
\[c'' \sube c \cup c', \quad c'' \not\sube c, \quad \text{and}\quad c''\not\sube c' \](a) Prove that the consensus, when it exists, can be computed componentwise using the following formulas in each coordinate position:
\[x \sqcup x = x\sqcup * = *\sqcup x = x \quad \text{and} \quad x\sqcup \overline x = * \sqcup * = *, \quad \text{for }x=0 \text{ and } x=1. \]Furthermore, \(c\sqcup c'\) exists if and only if the rule \(x\sqcup \overline x = *\) has been used in exactly one component.
正确性的证明均直接通过定义检验。当 \(c\sqcup c'\) 不存在时也可以通过定义类似检验。
(b) A subcube with \(k\) asterisks is called a \(k\)-cube. Show that, if \(c\) is a \(k\)-cube and \(c'\) is a \(k'\)-cube, and if the consensus \(c'' = c \sqcup c'\) exists, then \(c'\) is a \(k''\)-cube where \(1 \le k'' \le \min(k, k' ) + 1\).
利用 (a) 即得。
(c) If \(C\) and \(C'\) are families of subcubes, let
\[C\sqcup C'=\{c\sqcup c'\;|\; c\in C,c'\in C',c\sqcup c' \text{ exists} \} \]Explain why the following algorithm works.
Algorithm E (Find maximal subcubes). Given a family \(C\) of subcubes of the \(n\)-cube, this algorithm outputs the maximal subcubes of \(V = \bigcup_{c\in C} c\), without actually computing the set \(V\) itself.
E1. [Initialize.] Set \(j \leftarrow 0\). Delete any subcube \(c\) of \(C\) that is contained in another.
E2. [Done?] (At this point, every \(j\)-cube \(\sube V\) is contained in some element of \(C\), and \(C\) contains no \(k\)-cubes with \(k < j\).) If \(C\) is empty, the algorithm terminates.
E3. [Take consensuses.] Set \(C' \leftarrow C \sqcup C\), and remove all subcubes from \(C'\) that are \(k\)-cubes for \(k \le j\). While performing this computation, also output any \(j\)-cube \(c \in C\) for which \(c \sqcup C\) does not produce a \((j + 1)\)-cube of \(C'\).
E4. [Advance.] Set \(C \leftarrow C\cup C'\) , but delete all \(j\)-cubes from this union. Then delete any subcube \(c \in C\) that is contained in another. Set \(j \leftarrow j+1\) and go to E2.
对 \(j\) 应用归纳法,首先说明 E2 括号中内容正确性。显然在 \(j-1\) 时已满足的 \(j\)-cube 在 \(j\) 时仍满足,对于其他 \(j\)-cube \(c\sube V\),必满足 \(c=c'\sqcup c''\),其中 \(c',c''\) 均为 \(j-1\)-cube,\(\sqcup\) 的定义给出了结论成立。
同时,需要证明 E3 中输出的确实是所有极大的 subcubes,前面已说明所有可能的 subcudes 均包含于 \(C\) 中,而一个 \(j\)-cube \(c\) 极大等价于不存在另一个 \(j\)-cube \(c'\) 满足 \(c\sqcup c'\) 是 \((j+1)\)-cube,且不存在一个 \((j+1)\)-cube 包含 \(c\),至此明所欲证。
-
(33) \([\mathcal{M21}]\) Let \(f(x_1, \ldots , x_n)\) be one of the \(\binom {2^n} m\) Boolean functions that are true at exactly \(m\) points. If \(f\) is chosen at random, what is the probability that \(x_1 \land \cdots \land x_k\) is (a) an implicant of \(f\)? (b) a prime implicant of \(f\)? [Give the answer to part (b) as a sum; but evaluate it in closed form when \(k = n\).]
(a) \(\binom{2^n-2^{n-k}}{m-2^{n-k}}/\binom{2^n} m\) (b) 利用容斥原理即得
\[\sum_{i=0}^k \binom k i (-1)^{i} \left.\binom{2^n-(i+1)2^{n-k}}{m-(i+1)2^{n-k}}\right /\binom{2^n}m \]当 \(n=k\) 时,利用范德蒙德卷积及归纳法,得到其等于 \(\binom{2^n-n-1}{m-1}/\binom {2^n} m\)。
-
(34) \([\mathcal{HM37}]\) Continuing exercise 33, let \(c(m, n)\) be the average total number of implicants, and let \(p(m, n)\) be the average total number of prime implicants.
(a) If \(0\le m \le 2^n/n\), show that \(m\le c(m,n) \le \frac 3 2 m+O(m/n)\) and \(p(m,n) \ge me^{-1}+O(m/n)\); hence \(p(m,n)=\Theta(c(m,n))\) in this range.
对于 \(c(m,n)\),枚举项的个数,利用 (33) 结果,得到
\[c(m,n)=\sum_{i=0}^n2^{n-i}\binom n i \binom{2^n-2^i}{m-2^i}\left/\binom{2^n} m \right. \]显然 \(c_0(m,n)=m,c_1(m,n)=\dfrac{nm(m-1)}{2(2^n-1)}<\dfrac m 2\)。对于其他 \(i\) 做类似推导,得到 \(c_i(m,n)<m/(2^i\cdot i!\cdot n^{2^i-i-1})\)。据此得到 \(m\le c(m,n) \le \frac 3 2 m+O(m/n)\)。
对于 \(p(m,n)\),利用 (33) 结果,有 \(p(m,n)=\sum_{k=0}^np_k(m,n)\),其中
\[p_k(m,n)=\sum_{k=0}^n 2^{n-k}\binom n k \sum_{i=0}^{n-k} \binom {n-k} i (-1)^{i} \left.\binom{2^n-(i+1)2^k}{m-(i+1)2^k}\right /\binom{2^n}m \]考虑 \(p_0(m,n)\),有
\[p_0(m,n)=2^n\cdot \binom{2^n-n-1}{m-1}\left/\binom {2^n} m\right. \ge m\left(1-\frac n {2^n-m}\right)^m \ge m\left(1-\frac n {2^n-2^n/n}\right)^{2^n/n} \\ = m\exp\left(\frac{2^n} n \ln\left( 1-\frac {n^2} {2^n(n-1)} \right) \right) \]利用 \(\ln(1+x)\le x\) 得到 \(p_0(m,n) \ge me^{-1}\)。
太困难了,不会做。
-
(66) \([\mathcal{M25}]\) A coterie of \(\{1, \ldots , n\}\) is a family \(\mathcal C\) of subsets called quorums, which have the following properties whenever \(Q \in \mathcal C\) and \(Q' \in \mathcal C\): (i) \(Q \cap Q' \ne \varnothing\); (ii) \(Q \sube Q'\) implies \(Q = Q'\) . Coterie \(\mathcal C\) dominates coterie \(\mathcal C'\) if \(C \ne C'\) and if, for every \(Q ' \in C'\) , there is a \(Q \in \mathcal C\) with \(Q \sube Q'\) . For example, the coterie \(\{\{1, 2\}, \{2, 3\}\}\) is dominated by \(\{\{1, 2\}, \{1, 3\}, \{2, 3\}\}\) and also by \(\{\{2\}\}\).
Prove that \(\mathcal C\) is a nondominated coterie if and only if its quorums are the index sets of variables in the prime implicants of a monotone self-dual Boolean function \(f(x_1, . . . , x_n)\).
monotone 自动满足,property (i) 等价于 \(\overline{f(x_1,\ldots,x_n)} \ge f(\overline x_1,\ldots,\overline x_n)\)。
如果 \(\mathcal C\) 支配 \(\mathcal C'\),令他们分别对应 \(f,f'\),则有 \(f(x)\ge f'(x)\),且存在 \(x\) 使得 \(f(x)>f'(x)\),因为 \(\mathcal C\ne \mathcal C' \implies f\ne f'\),这意味着 \(f'\) 为 non-self-dual 的。这给出仅当方向成立。
如果 \(f\) 为 non-self-dual 的,由于 \(\overline{f(x)}\ge f(\overline x)\),存在一个 self-dual 的 \(f'\) 使得 \(f(x)\le f'(x)\),此时 \(f'\) 对应的 \(\mathcal C'\) 支配 \(f\) 对应的 \(\mathcal C\)。这给出当方向成立。
-
(70) \([\mathcal{M20}]\) Given any monotone self-dual Boolean function \(f(x) = f(x_1, \ldots , x_n)\), choose any prime implicant \(x_{j_1} \land \ldots \land x_{j_s}\) and let
\[g(x)=(f(x) \land [x\ne t]) \lor [x=\overline t] \]where \(t = t_1 \ldots t_n\) is the bit vector that has 1s in positions \(\{j_1, \ldots , j_s\}\). Prove that \(g(x)\) is also monotone and self-dual.
注意 \(f\) 和 \(g\) 只有 \(t\) 和 \(\overline t\) 两处点值不同,所以 self-dual 自动成立。monotone 等价于说明对于所有 \(t'\subsetneq t\),均有 \(g(t')=0\),而这由 \(t\) 为 prime implicant 直接给出。
-
(79) \([\mathcal{M27}]\) An induced subgraph of a hypercube is a graph whose vertices \(v\) can be labeled with bit strings \(l(v)\) in such a way that \(u-v\) if and only if \(l(u)\) and \(l(v)\) differ in exactly one bit position. (Each label has the same length.)
(a) One way to define an \(n\)-vertex subgraph of a hypercube is to let \(l(v)\) be the binary representation of \(v\), for \(0 \le v < n\). Show that this subgraph has exactly \(f(n) = \sum_{k=0}^{n−1} \nu(k)\) edges, where \(\nu(k)\) is the sideways addition function.
将每条边 \(u-v\) 贡献统计在 \(\max(u,v)\) 上,即得每个点的贡献均为 \(\nu(v)\),所以 \(f(n) = \sum_{k=0}^{n−1} \nu(k)\)。
(b) Prove that \(f(n)\le n\lceil \lg n\rceil /2\).
对 (a) 中结论拆位即得。
(c) Prove that no \(n\)-vertex subgraph of a hypercube has more than \(f(n)\) edges.
注意到 \(f(2n)=2f(n)+n\),记 \(f'(n)=\max_{k=1}^{n-1} \big( \min(k,n-k)+f(k)+f(n-k) \big)\),只需证 \(f(x)=f'(x)\)。当 \(n\le m\) 时设 \(g(n,m)=f(n+m)-f(n)-f(m)-n\)。注意到
\[\begin{aligned} & g(2n,2m) &= & 2g(n,m) \\ & g(2n+1,2m) &= &g(n+1,m)+g(n,m) \\ & g(2n,2m+1) &= &g(n,m+1)+g(n,m) \\ & g(2n+1,2m+1) &= & g(n+1,m)+g(m+1,n)+1 \\ \end{aligned} \]而 \(g(1,1)=0\),利用归纳法即得 \(g(n,n)=0\) 且 \(g(n,m) \ge 0\)。这说明 \(f(n)=f'(n)\)。
-
(90) \([\mathcal{21}]\) Construct a CI-net with input bits \(x_1 \ldots x_t\) and output bits \(y_1 \ldots y_t\), where \(y_1 = \cdots = y_{t−1} = 0\) and \(y_t = x_1 \oplus \cdots \oplus x_t\). Try for only \(O(\log t)\) levels of delay.
当 \(t=1\) 时无事可做,当 \(t=2\) 时做 \(\texttt{inv(1),cmp(1,2),inv(2),cmp(1,2)}\) 即可。当 \(t\ge 3\) 时做线段树分治即可。
-
(99) \([\mathcal{20}]\) Prove that:
\[\left< \left< x_1\ldots x_{2s-1} \right> y_1 \ldots y_{2t-2} \right> = \left< x_1\ldots x_{2s-1} y_1^s \ldots y_{2t-2}^s \right> \]展开为 threshold function 形式,LHS 化简为
\[\left[ \left[ \sum_{i=1}^{2s-1} x_i \ge s \right]+\sum_{i=1}^{2t-2}y_i \ge t \right] \]RHS 化简为
\[\left[ \sum_{i=1}^{2s-1}x_i+\sum_{j=1}^{2t-2}s\cdot y_j \ge st\right] \]两者显然等价。
-
(106) \([\mathcal{M25}]\) The median-of-three operation \(\left<x\overline{y}\overline z\right>\) is true if and only if \(x \ge y + z\).
(a) Generalizing, show that we can test the condition \((x_1x_2 \ldots x_n)_2 \ge (y_1y_2 \ldots y_n)_2+z\) by performing a median of \(2^{n+1} − 1\) Boolean variables.
答案是 \(\left< x_1^{2^{n-1}}x_2^{2^{n-2}}\ldots x_n \overline y_1^{2^{n-1}}\overline y_2^{2^{n-2}}\ldots \overline y_n \overline z\right>\),正确性显然成立。
(b) Prove that no median of fewer than \(2^{n+1} −1\) will suffice for this problem.
假设式 \(\left< x_1^{a_1}x_2^{a_2}\ldots x_n^{a_n} \overline y_1^{b_1}\overline y_2^{b_2}\ldots \overline y_n^{b_n} \overline z^{c}\right>\) 满足条件。则 \(\forall 0\le i=(t_1\ldots t_n)_2 <2^n,i\ge i+0\) 对应 \(\sum_{j=0}^n (-1)^{[t_i=1]}a_i+\sum_{j=0}^n (-1)^{[t_i=0]}b_i+c \ge 1\),\(\forall 0\le i-1 =(u_1\ldots u_n)_2 <i=(t_1\ldots t_n)_2 <2^n,i\ge (i-1)+1\) 对应 \(\sum_{j=0}^n (-1)^{[t_i=1]}a_i+\sum_{j=0}^n (-1)^{[u_i=0]}b_i-c \ge 1\),将这些所有式子相加,即得 \(\sum (a_i+b_i)+c\ge 2^{n+1}-1\)。
-
(121) \([\mathcal{M23}]\) The function \(\left<1(x_1\oplus x_2)y_1y_2y_3\right>\) is partially symmetric, since it is symmetric in \(\{x_1, x_2\}\) and in \(\{y_1, y_2, y_3\}\), but not in all five variables \(\{x_1, x_2, y_1, y_2, y_3\}\).
a) Exactly how many Boolean functions \(f(x_1, \ldots , x_m, y_1, \ldots , y_n)\) are symmetric in \(\{x_1, \ldots , x_m\}\) and \(\{y_1, \ldots , y_n\}\)?
答案为 \(2^{(m+1)(n+1)}\)。
b) How many of those functions are monotone?
答案为 \(\binom{m+n+2}{m+1}\)。
c) How many of those functions are self-dual?
若 \((m+1)(n+1)\) 为偶数,答案为 \(2^{(m+1)(n+1)/2}\),否则为 \(0\)。
d) How many of those functions are monotone and self-dual?
若 \((m+1)(n+1)\) 为偶数,答案为 \(\binom{\lceil m/2 \rceil+\lceil n/2 \rceil}{\lceil m/2 \rceil}\),否则为 \(0\)。
-
(128) \([\mathcal{20}]\) Find a noncanalizing \(f(x_1, \ldots , x_n)\) that is true at exactly two points.
取 \(f(x)=(x_1\land \cdots \land x_n) \lor (\overline x_1\land \cdots \land \overline x_n)\) 即可。
-
(132) \([\mathcal{HM30}]\) The Boolean function \(g(x)=g(x_1,\ldots,x_n)\) is called affine if it can be written in the form \(y_0\oplus(x_1\land y_1) \oplus \cdots \oplus (x_n\land y_n)=(y_0+x\cdot y)\bmod 2\) for some Boolean canstants \(y_0,y_1,\ldots,y_n\).
a) Given any Boolean function \(f(x)\), show that some affine function agrees with \(f(x)\) at \(2^{n-1}+2^{n/2-1}\) or more points \(x\).
设 \(s(y)=\sum_x (-1)^{f(x)+x\cdot y}\),设 \(t(z)=\sum_y s(y)s(y\oplus z)\),注意到 \(\sum_y (-1)^{x\cdot y}=[x=0]2^n\),展开 \(g(z)\) 得
\[\begin{aligned} t(z) &= \sum_y \sum_{x_1,x_2} (-1)^{f(x_1)+x_1\cdot y}(-1)^{f(x_2)+x_2 \cdot (y+z)} \\ &= \sum_{x_1,x_2}(-1)^{f(x_1)+f(x_2)+x_2\cdot z} \sum_y (-1)^{(x_1+x_2)\cdot y} \\ &=2^n \sum_x (-1)^{x\cdot z}\\ &= [z=0] 2^{2n} \end{aligned} \]取 \(z=0\),利用抽屉原理,存在 \(y\) 使得 \(|s(y)|\ge 2^{n/2}\),取 \(y_0=[s(y)<0]\) 即得满足条件的 \(y_0,y_1,\ldots,y_n\)。
b) The Boolean function \(f(x)\) is called bent if no affine function agrees with it at more than \(2^{n-1}+2^{n/2-1}\) points. Prove that
\[(x_1\land x_2) \oplus (x_3 \land x_4) \oplus \cdots \oplus (x_{n-1}\land x_n)\oplus h(x_2,x_4,\ldots,x_n) \]is a bent function, when \(n\) is even and \(h(y_1, y_2, \ldots , y_{n/2})\) is arbitrary.
\(f(x)\) 为 bent function 等价于 \(\forall y,s(y)=\pm 2^{n/2}\),展开 \(s(y)\) 得
\[\begin{aligned} s(y)&= \sum_{x_2,x_4,\ldots,x_n} (-1)^{h(x_2,x_4,\ldots,x_n)+x_2y_2+x_4y_4+\cdots+x_ny_n} \sum_{x_1,x_3,\ldots,x_{n-1}} (-1)^{(x_1\land x_2)+(x_3\land x_4)+\cdots+(x_{n-1}\land x_n)} (-1)^{x_1y_1+x_3y_3+\cdots +x_{n-1}y_{n-1}} \end{aligned} \]注意后半个和式不为 \(0\) 当且仅当 \(x_2=y_1,x_4=y_3,\ldots,x_n=y_{n-1}\),且此时后半和式值为 \(2^{n/2}\)。至此,明所欲证。
c) Prove that \(f(x)\) is a bent function if and only if
\[\sum_x (f(x)\oplus f(x\oplus y))=2^{n-1} \quad \text{for all } y\ne 0\ldots 0 \]假设 (a) 中结论给出的 affine function 为 \(g(x)\),则题设等价于 \(s(y)=(-1)^{g(y)}2^{n/2}\)。设 \(t(w)=\sum_x (-1)^{g(x)+x\cdot w}\),则有
\[\begin{aligned} t(w)&=2^{-n/2}\sum_{x,y}(-1)^{f(y)+x\cdot w+x\cdot y} \\ &=2^{-n/2}\sum_y (-1)^{f(y)} \sum_x (-1)^{x\cdot (y+w)} \\ &=2^{n/2}\sum_y (-1)^{f(y)} [y=w] \\ &=2^{n/2}(-1)^{f(w)} \end{aligned} \]这说明若 \(f(x)\) 为 bent function 则 \(g(x)\) 也为 bent function。此时原式等价于 \(\sum_x (-1)^{f(x)+f(x\oplus y)}=0\) 对所有 \(y\ne 0\) 成立,有
\[\begin{aligned} 2^{n}\sum_x (-1)^{f(x)+f(x\oplus y)} &= \sum_x t(x)t(x\oplus z) \\ &=\sum_x \sum_{w_1,w_2} (-1)^{g(w_1)+g(w_2)+x\cdot w_1+w_2\cdot(x+ y) } \\ &= 2^{2n} [y=0] \end{aligned} \]这给出 \(\implies\) 方向成立。至于 \(\impliedby\) 方向,注意到
\[\begin{aligned} s^2(y)&=\sum_x\sum_d (-1)^{f(x)+f(x\oplus d)+y\cdot(x+x\oplus d)} \\ &= \sum_d(-1)^{y\cdot d} \sum_x (-1)^{f(x)+f(x\oplus d)} \\ &= 2^n \end{aligned} \]据此,明所欲证。