Skip to content

Commit f961a4c

Browse files
committed
docs: add TCS lec13
1 parent aa0df0c commit f961a4c

2 files changed

Lines changed: 104 additions & 0 deletions

File tree

docs/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ nav:
1313
- lec10
1414
- lec11
1515
- lec12
16+
- lec13
1617
- rl:
1718
- fundamentals
1819
- value-based

docs/cs/tcs/lec13.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Lecture 13
3+
---
4+
5+
$\newcommand{\NN}{\mathbb{N}}$
6+
$\newcommand{\rmSIZE}{\mathrm{SIZE}}$
7+
$\newcommand{\rmTIME}{\mathrm{TIME}}$
8+
$\newcommand{\rmRAM}{\mathrm{RAM}}$
9+
$\newcommand{\rmTM}{\mathrm{TM}}$
10+
$\newcommand{\rmHALT}{\mathrm{HALT}}$
11+
$\newcommand{\Ppoly}{\mathcal{P}/\mathrm{poly}}$
12+
$\newcommand{\zeroone}{\{0,1\}}$
13+
$\newcommand{\zeroonestar}{\zeroone^*}$
14+
15+
::fold{title="**定理**:Cook-Levin 定理" success always expand}
16+
**3SAT is NP-complete.**
17+
18+
:::fold{title="证明" expand}
19+
3SAT $\in \mathcal{NP}$ 在上节课已经证明,接下来证明:
20+
21+
**对于任意 $F \in \mathcal{NP}$,$F \leq_P$ 3SAT。**
22+
23+
我们采取以下规约链条:
24+
25+
$$
26+
F \leq_P \text{NANDSAT} \leq_P \text{SAT} \leq_P \text{3SAT}
27+
$$
28+
29+
- **NANDSAT:** Given a NAND-CIRC $Q$ with $n$ inputs and one output, is there an input $t \in \zeroonestar$ such that $Q(t) = 1$?
30+
- **SAT:** 和 3SAT 唯一的区别是每个子句可以有任意数量的文字。
31+
32+
---
33+
34+
**Step 1:** $\text{NANDSAT} \leq_P \text{SAT}$
35+
36+
例子:对于 NAND-CIRC 程序,输入 $t_1, t_2, t_3$,输出 $y$
37+
38+
```
39+
temp_1 = NAND(t_1, t_2)
40+
temp_2 = NAND(t_2, t_3)
41+
y = NAND(temp_1, temp_2)
42+
```
43+
44+
找到一组输入使得输出为 1,其实等价于
45+
46+
$\newcommand{\temp}{\text{temp}}$
47+
$\newcommand{\NAND}{\text{NAND}}$
48+
49+
$$
50+
\begin{aligned}
51+
&(\temp_1==\NAND(t_1, t_2)) \\
52+
\land& (\temp_2==\NAND(t_2, t_3)) \\
53+
\land& (y==\NAND(\temp_1, \temp_2)) \\
54+
\land& (y==1)
55+
\end{aligned}
56+
$$
57+
58+
对于其中每一个子句 $a==\NAND(b, c)$,我们可以将其转化为 SAT 子句:
59+
60+
$$
61+
\newcommand{\ba}{\bar a}
62+
\newcommand{\bb}{\bar b}
63+
\newcommand{\bc}{\bar c}
64+
(\ba \lor \bb \lor \bc) \land (a \lor b) \land (a \lor c)
65+
$$
66+
67+
而对于 $y==1$,可以直接转换成 $y$。
68+
69+
**Step 2:** $\text{SAT} \leq_P \text{3SAT}$
70+
71+
对于子句 $(x_1 \lor x_2)$,转换成 $(x_1 \lor x_2 \lor y) \land (x_1 \lor x_2 \lor \bar y)$。
72+
73+
对于子句 $(x_1 \lor x_2 \lor x_3 \lor x_4)$,转换成 $(x_1 \lor x_2 \lor y) \land (\bar y \lor x_3 \lor x_4)$。
74+
75+
递归地做就行。
76+
77+
**Step 3:** $F \leq_P \text{NANDSAT}$
78+
79+
回顾 $\mathcal{NP}$ 的定义:
80+
81+
> $\exists$ TM $V$ with polynomial running time such that for any $x \in \zeroonestar$, $F(x) = 1 \iff \exists t \in \zeroonestar$ such that $V(x, t) = 1$ and $|t| \leq |x|^a$($a$ 是某个常数)。
82+
83+
由于 $F \in \mathcal{NP}$,所以问 $F(x)$ 是否为 1,等价于问是否 $\exists t \in \zeroonestar$ such that $V(x, t) = 1$ and $|t| \leq |x|^a$,该形式和 NANDSAT 非常类似。
84+
85+
$V$ 是一个图灵机,对于给定的 $x$,其输入长度 $\leq |x|+|t| \leq 2|x|^a$,且运行时间 $\leq (2|x|^a)^b = 2^b |x|^{ab}$($b$ 是某个常数)。
86+
87+
讲图灵机转化为 NAND-CIRC 程序的唯一问题在于**前者可以有变量长度的循环**,据说两周之前的课(lec11)讲过**如果图灵机的输入长度和运行时间都是多项式级别的,那么可以将循环展开,且展开之后也是多项式的。**
88+
89+
因此此处能够将 $V(x, t)$ 转化为 NAND-CIRC 程序 $Q(x, t)$,由于 $x$ 给定,可以将 $x$ 的值直接写死在程序中,得到 NAND-CIRC 程序 $Q_x(t)$。
90+
91+
从而问题转化为:是否 $\exists t \in \zeroone^{|x|^a}$ 使得 $Q_x(t) = 1$,即 NANDSAT 问题,完成规约。
92+
:::
93+
::
94+
95+
**证明 $F$ 是 $\mathcal{NP}$ 完全的:** (1) 证明 $F \in \mathcal{NP}$;(2) 证明 $\text{3SAT} \leq_P F$。
96+
97+
**Subset Sum is NP-complete.**
98+
99+
::fold{title="Independent Set problem" always expand}
100+
给定一个无向图 $G=(V,E)$ 和整数 $k$,问是否存在 $S \subseteq V$,使得 $|S| \geq k$,且对于任意 $u,v \in S$,$(u,v) \notin E$。(即 $S$ 中的任意两个顶点都不相邻)
101+
102+
(课上详细证明了 IS 是 $\mathcal{NP}$ 完全的,通过规约 3SAT $\leq_P$ IS,这里略过。)
103+
::

0 commit comments

Comments
 (0)