上半学期
Lec1
Q \mathbb{Q} Q : 有理数
基本代数定理 FTA:任何大于1的整数都能被分解为质数乘积 n = p 1 e 1 ⋯ p r e r n=p_1^{e_1}\cdots p_r^{e_r} n = p 1 e 1 ⋯ p r e r (数学归纳法证明)
良序公理:非空非负子集有最小元
带余除法:a = b q + r a=bq+r a = b q + r
理想:加法/数乘封闭,d Z = { 0 , ± d , ± 2 d , ⋯ } d\mathbb{Z}=\{0,\pm d,\pm 2d,\cdots\} d Z = { 0 , ± d , ± 2 d , ⋯ } ,a Z + b Z = gcd ( a , b ) Z a\mathbb{Z}+b\mathbb{Z}=\gcd(a,b)\mathbb{Z} a Z + b Z = g cd( a , b ) Z
gcd ( a , b ) = p 1 m i n ( { α 1 , β 1 } ) ⋯ p r m i n ( { α r , β r } ) \gcd(a,b)=p_1^{min(\{\alpha_1,\beta_1\})}\cdots p_r^{min(\{\alpha_r,\beta_r\})} g cd( a , b ) = p 1 m i n ( { α 1 , β 1 } ) ⋯ p r m i n ( { α r , β r } )
裴蜀定理 Bézout’s Theorem:∃ s , t ∈ Z , gcd ( a , b ) = a s + b t \exists s,t\in\mathbb{Z},\gcd(a,b)=as+bt ∃ s , t ∈ Z , g cd( a , b ) = a s + b t
Lec2
二元关系:是 A × B A\times B A × B 的子集 R R R ,a R b aRb a R b 意味着 ( a , b ) ∈ R (a,b)\in R ( a , b ) ∈ R
等价关系:R R R 在 A A A 上,满足 ∀ a ∈ A , a R a \forall a\in A,aRa ∀ a ∈ A , a R a (自反性),对称性,传递性的集合
等价类:[ a ] R = { b ∈ A : a R b } , a ∈ A [a]_R=\{b\in A:aRb\},a\in A [ a ] R = { b ∈ A : a R b } , a ∈ A
剩余类:[ a ] n = a + n Z = { a + n x : x ∈ Z } [a]_n=a+n\mathbb{Z}=\{a+nx:x\in Z\} [ a ] n = a + n Z = { a + n x : x ∈ Z } (a m o d n a\bmod n a m o d n 下的)
Z n = { [ 0 ] n , [ 1 ] n , ⋯ , [ n − 1 ] n } = { 0 , 1 , ⋯ , n − 1 } \mathbb{Z}_n=\{[0]_n,[1]_n,\cdots,[n-1]_n\}=\{0,1,\cdots,n-1\} Z n = { [ 0 ] n , [ 1 ] n , ⋯ , [ n − 1 ] n } = { 0 , 1 , ⋯ , n − 1 }
Lec3
[ b ] n [ s ] n = [ 1 ] n [b]_n[s]_n=[1]_n [ b ] n [ s ] n = [ 1 ] n ,则 [ s ] n [s]_n [ s ] n 为 [ b ] n [b]_n [ b ] n 逆元(EEA求解)
Z n ∗ = { [ b ] n ∈ Z n : gcd ( b , n ) = 1 } \mathbb{Z}_n^*=\{[b]_n\in\mathbb{Z}_n:\gcd(b,n)=1\} Z n ∗ = { [ b ] n ∈ Z n : g cd( b , n ) = 1 } (与 n n n 互质;是循环群,所有元素都是生成元)
欧拉 ϕ \phi ϕ 函数:ϕ ( n ) = ∣ Z n ∗ ∣ = n ( 1 − p 1 − 1 ) ⋯ ( 1 − p r − 1 ) \phi(n)=|\mathbb{Z}_n^*|=n(1-p_1^{-1})\cdots(1-p_r^{-1}) ϕ ( n ) = ∣ Z n ∗ ∣ = n ( 1 − p 1 − 1 ) ⋯ ( 1 − p r − 1 )
欧拉定理:n ≤ 1 , α ∈ Z n ∗ n \le 1, \alpha \in \mathbb{Z}_n^* n ≤ 1 , α ∈ Z n ∗ ,则 α ϕ ( n ) = 1 \alpha^{\phi(n)}=1 α ϕ ( n ) = 1
费马小定理:在欧拉定理基础上取 n n n 为质数,即 α p − 1 = 1 \alpha^{p-1}=1 α p − 1 = 1
Lec4
RSA:取质数 p , q , N = p q , r = ϕ ( N ) p,q,N=pq,r=\phi(N) p , q , N = p q , r = ϕ ( N ) ,选择整数 e , e < r , gcd ( e , r ) = 1 e,e<r,\gcd(e,r)=1 e , e < r , g cd( e , r ) = 1 ,求其逆元 d = e − 1 m o d r d=e^{-1}\bmod r d = e − 1 m o d r
公钥 ( N , e ) (N,e) ( N , e ) 私钥 ( N , d ) (N,d) ( N , d ) ,m → c : = m e m o d N → m = c e m o d N m\rightarrow c:=m^e\bmod N\rightarrow m=c^e\bmod N m → c : = m e m o d N → m = c e m o d N
Lec5
二进制加减法:O ( k ) O(k) O ( k ) ,乘法:O ( k 2 ) O(k^2) O ( k 2 ) ,除法:O ( ( k − l + 1 ) ⋅ l ) O((k-l+1)\cdot l) O ( ( k − l + 1 ) ⋅ l ) ,快速幂:O ( k ) O(k) O ( k )
乘法:和快速幂同一种算法;除法:先令余数 r : = a r:=a r : = a ,再模拟竖式计算
Lec6
扩展欧几里得算法(EEA):求解 a s + b t = gcd ( a , b ) as+bt=\gcd(a,b) a s + b t = g cd( a , b ) ,r 0 = a , r 1 = b r_0=a,r_1=b r 0 = a , r 1 = b ,复杂度 O ( l ( a ) l ( b ) ) O(l(a)l(b)) O ( l ( a ) l ( b ) )
i r i q i s i t i 0 12345 1 0 1 123 100 0 1 2 45 2 1 − 100 3 33 1 − 2 201 4 12 2 3 − 301 5 9 1 − 8 803 6 3 3 11 − 1104 7 0 \begin{array}{|c|c|c|c|c|}
\hline
i & r_i & q_i & s_i & t_i \\
\hline
0 & 12345 & & 1 & 0 \\
1 & 123 & 100 & 0 & 1 \\
2 & 45 & 2 & 1 & -100 \\
3 & 33 & 1 & -2 & 201 \\
4 & 12 & 2 & 3 & -301 \\
5 & 9 & 1 & -8 & 803 \\
6 & 3 & 3 & 11 & -1104 \\
7 & 0 & & & \\
\hline
\end{array}
i 0 1 2 3 4 5 6 7 r i 1 2 3 4 5 1 2 3 4 5 3 3 1 2 9 3 0 q i 1 0 0 2 1 2 1 3 s i 1 0 1 − 2 3 − 8 1 1 t i 0 1 − 1 0 0 2 0 1 − 3 0 1 8 0 3 − 1 1 0 4
(疑似不重要)素数理论:π ( x ) \pi(x) π ( x ) 为小于等于 x x x 素数个数,有 lim x → ∞ π ( x ) x ln x = 1 \lim_{x\to\infty}\frac{\pi(x)}{\frac{x}{\ln x}}=1 lim x → ∞ l n x x π ( x ) = 1 ;P n \mathbb{P}_n P n 为 2 n − 1 2^{n-1} 2 n − 1 到 2 n 2^n 2 n 素数个数,则 ∣ P n ∣ ≥ 2 n n ln 2 ( 1 2 + O ( 1 n ) ) |\mathbb{P}_n|\ge \frac{2^n}{n\ln2}(\frac{1}{2}+O(\frac{1}{n})) ∣ P n ∣ ≥ n l n 2 2 n ( 2 1 + O ( n 1 ) ) ;说明生成素数的高效性
Lec7
线性同余方程:d : = gcd ( a , n ) , a x ≡ b ( m o d n ) d:=\gcd(a,n),ax\equiv b\pmod n d : = g cd( a , n ) , a x ≡ b ( m o d n ) 有解 ⇔ d ∣ b \Leftrightarrow d\mid b ⇔ d ∣ b (裴蜀定理,即 b = k gcd ( a , n ) b=k\gcd(a,n) b = k g cd( a , n ) )
d : = gcd ( a , n ) , t : = ( a d ) − 1 m o d n d , d ∣ b d:=\gcd(a,n),t:=(\frac{a}{d})^{-1} \bmod \frac{n}{d},d \mid b d : = g cd( a , n ) , t : = ( d a ) − 1 m o d d n , d ∣ b 则 a x ≡ b ( m o d n ) ⇔ x ≡ b d t ( m o d n d ) ax\equiv b\pmod n \Leftrightarrow x \equiv \frac{b}{d}t \pmod {\frac{n}{d}} a x ≡ b ( m o d n ) ⇔ x ≡ d b t ( m o d d n ) (约分)
中国剩余定理:{ x ≡ b i ( m o d n i ) \{x \equiv b_i \pmod{n_i} { x ≡ b i ( m o d n i ) 任意 n i n_i n i 互质,则有解
先求 n = ∏ n i n=\prod n_i n = ∏ n i ,记 N i = n n i N_i=\frac{n}{n_i} N i = n i n ,由 s i N i + t i n i = 1 s_iN_i+t_in_i=1 s i N i + t i n i = 1 用 EEA 求出 s i s_i s i ,令 b = ∑ b i ( N i s i ) b=\sum b_i(N_is_i) b = ∑ b i ( N i s i ) ,得解 [ b ] n [b]_n [ b ] n
CRT 映射:k k k 个两两互质正整数,n = ∏ n i n=\prod n_i n = ∏ n i ,则映射 θ ( [ x ] n ) = ( [ x ] n 1 , ⋯ , [ x ] n k ) \theta([x]_n)=([x]_{n_1},\cdots,[x]_{n_k}) θ ( [ x ] n ) = ( [ x ] n 1 , ⋯ , [ x ] n k ) 为 Z n \mathbb{Z}_n Z n 到 Z n 1 × ⋯ × Z n k \mathbb{Z}_{n_1}\times\cdots\times\mathbb{Z}_{n_k} Z n 1 × ⋯ × Z n k 以及 Z n ∗ \mathbb{Z}_n^* Z n ∗ 到 Z n 1 ∗ × ⋯ × Z n k ∗ \mathbb{Z}_{n_1}^*\times\cdots\times\mathbb{Z}_{n_k}^* Z n 1 ∗ × ⋯ × Z n k ∗ 的双射
良定义:[ x ] n = [ y ] n ⇒ θ ( [ x ] n ) = θ ( [ y ] n ) [x]_n=[y]_n\Rightarrow\theta([x]_n)=\theta([y]_n) [ x ] n = [ y ] n ⇒ θ ( [ x ] n ) = θ ( [ y ] n ) ;单射:θ ( [ x ] n ) = θ ( [ y ] n ) ⇒ [ x ] n = [ y ] n \theta([x]_n)=\theta([y]_n)\Rightarrow[x]_n=[y]_n θ ( [ x ] n ) = θ ( [ y ] n ) ⇒ [ x ] n = [ y ] n
欧拉 ϕ \phi ϕ 函数:若 n = n 1 ⋯ n k n=n_1\cdots n_k n = n 1 ⋯ n k ,且 n i n_i n i 两两互质,则 ϕ ( n ) = ϕ ( n 1 ) ⋯ ϕ ( n k ) \phi(n)=\phi(n_1)\cdots\phi(n_k) ϕ ( n ) = ϕ ( n 1 ) ⋯ ϕ ( n k ) ;若 n i n_i n i 均为质数,则 ϕ ( n ) = ( p 1 e 1 − p 1 e 1 − 1 ) ⋯ ( p k e k − p k e k − 1 ) = n ( 1 − p 1 − 1 ) ⋯ ( 1 − p k − 1 ) \phi(n)=(p_1^{e_1}-p_1^{e_1-1})\cdots(p_k^{e_k}-p_k^{e_k-1})=n(1-p_1^{-1})\cdots(1-p_k^{-1}) ϕ ( n ) = ( p 1 e 1 − p 1 e 1 − 1 ) ⋯ ( p k e k − p k e k − 1 ) = n ( 1 − p 1 − 1 ) ⋯ ( 1 − p k − 1 )
Lec8
群:封闭性 Closure、结合律 Associative、单位元 Identity (a ∗ e = e ∗ a = a a*e=e*a=a a ∗ e = e ∗ a = a )、逆元 Inverse (a ∗ b = b ∗ a = e a*b=b*a=e a ∗ b = b ∗ a = e );阿贝尔群:交换律
( Z n , + ) (\mathbb{Z}_n,+) ( Z n , + ) :阿贝尔群,单位元为 [ 0 ] n [0]_n [ 0 ] n ;( Z n ∗ , ⋅ ) (Z_n^*,\cdot) ( Z n ∗ , ⋅ ) :当 n > 1 n>1 n > 1 时为阿贝尔群
阶 Order:群的阶是群的元素个数;群内元素 a a a 的阶是使得 a l = 1 a^l=1 a l = 1 的最小 l l l (加法群为 l a = 0 la=0 l a = 0 )
若乘法阿贝尔群阶数为 m m m ,则对于任意 a ∈ G a\in G a ∈ G ,都有 a m = 1 a^m=1 a m = 1
子群:( G , ⋅ ) (G,\cdot) ( G , ⋅ ) 是阿贝尔群,令 g ∈ G , ⟨ g ⟩ = { g k : k ∈ Z } g\in G,\langle g \rangle = \{g^k:k\in\mathbb{Z}\} g ∈ G , ⟨ g ⟩ = { g k : k ∈ Z } 为 G G G 的子群,且 ⟨ g ⟩ ≤ G \langle g \rangle \le G ⟨ g ⟩ ≤ G
循环群 Cyclic Group:⟨ g ⟩ = G \langle g \rangle = G ⟨ g ⟩ = G ,则 g g g 为 G G G 的生成元;对于质数 p p p ,Z p ∗ \mathbb{Z}_p^* Z p ∗ 为循环群
Lec9
DLOG:循环群内若 h = g x h=g^x h = g x ,则 x = log g h x=\log_g h x = log g h ,称 x x x 为 h h h 的离散对数
若安全素数 p = 2 q + 1 p=2q+1 p = 2 q + 1 ,q q q 也为素数,则难以计算 DLOG:exp ( O ( ln q ln ln q ) ) \exp(O(\sqrt{\ln q\ln\ln q})) exp ( O ( ln q ln ln q ) )
Diffie-Hellman Key Exchange:A, B 规定大素数 p p p 以及生成元 g g g ,使得 G = ⟨ g ⟩ G=\langle g \rangle G = ⟨ g ⟩ 的阶为 p p p ;A 选择 a ← Z p , A = g a a\leftarrow \mathbb{Z}_p,A=g^a a ← Z p , A = g a 发送给 B;B 选择 b ← Z p , B = g b b\leftarrow\mathbb{Z}_p,B=g^b b ← Z p , B = g b 发送给 A;则密钥 k = B a = A b = g a b k=B^a=A^b=g^{ab} k = B a = A b = g a b
Lec10
集合的基数 Cardinality:若是有限集,则为元素个数
两个任意集合 A , B A,B A , B 有相同基数(∣ A ∣ = ∣ B ∣ |A|=|B| ∣ A ∣ = ∣ B ∣ )当存在双射 f : A → B f:A\rightarrow B f : A → B
当存在单射 f : A → B f:A\rightarrow B f : A → B ,则 ∣ A ∣ ≤ ∣ B ∣ |A|\le|B| ∣ A ∣ ≤ ∣ B ∣ ;同时满足 ∣ A ∣ ≠ ∣ B ∣ |A|\ne|B| ∣ A ∣ = ∣ B ∣ 时则 ∣ A ∣ < ∣ B ∣ |A|<|B| ∣ A ∣ < ∣ B ∣
∣ Z + ∣ = ∣ N ∣ = ∣ Q + ∣ = ∣ Q ∣ , ∣ R + ∣ = ∣ R ∣ = ∣ ( 0 , 1 ) ∣ = ∣ [ 0 , 1 ] ∣ |\mathbb{Z}^+|=|\mathbb{N}|=|\mathbb{Q}^+|=|\mathbb{Q}|,|\mathbb{R}^+|=|\mathbb{R}|=|(0,1)|=|[0,1]| ∣ Z + ∣ = ∣ N ∣ = ∣ Q + ∣ = ∣ Q ∣ , ∣ R + ∣ = ∣ R ∣ = ∣ ( 0 , 1 ) ∣ = ∣ [ 0 , 1 ] ∣
证明 ∣ ( 0 , 1 ) ∣ = ∣ [ 0 , 1 ] ∣ |(0,1)|=|[0,1]| ∣ ( 0 , 1 ) ∣ = ∣ [ 0 , 1 ] ∣ :取 f ( 0 ) = 2 − 2 , f ( 1 ) = 2 − 1 , f ( 2 − n ) = 2 − n − 2 f(0)=2^{-2},f(1)=2^{-1},f(2^{-n})=2^{-n-2} f ( 0 ) = 2 − 2 , f ( 1 ) = 2 − 1 , f ( 2 − n ) = 2 − n − 2 ,其余 f ( x ) = x f(x)=x f ( x ) = x
Cantor’s Diagonal Argument:反证法(例:证明 ∣ ( 0 , 1 ) ∣ ≠ ∣ Z + ∣ |(0,1)|\ne|\mathbb{Z}^+| ∣ ( 0 , 1 ) ∣ = ∣ Z + ∣ )
构造序列 f ( i ) = 0. b i 1 b i 2 b i 3 ⋯ f(i)=0.b_{i1}b_{i2}b_{i3}\cdots f ( i ) = 0 . b i 1 b i 2 b i 3 ⋯ ,则存在 b n i ≠ b i i , f ( n ) ≠ f ( i ) b_{ni}\ne b_{ii},f(n)\ne f(i) b n i = b i i , f ( n ) = f ( i ) 对于任意 i i i ,得证
P ( A ) \mathcal{P}(A) P ( A ) 为集合 A A A 的所有子集的集合;∣ A ∣ < ∣ P ( A ) ∣ |A|<|\mathcal{P}(A)| ∣ A ∣ < ∣ P ( A ) ∣ (设其双射,构造 X = { a : a ∈ A and a ∉ g ( a ) } ∈ P ( A ) X=\{a:a\in A\text{ and } a\notin g(a)\}\in\mathcal{P}(A) X = { a : a ∈ A and a ∈ / g ( a ) } ∈ P ( A ) ,应存在 X = g ( x ) X=g(x) X = g ( x ) ,说明 x x x 不存在以反证)
停机问题:不存在图灵机可解决之(假设图灵机 P P P ,以及函数 H a l t ( P , P ) Halt(P,P) H a l t ( P , P ) )
集合可数:即 ∣ A ∣ < ∞ |A|<\infty ∣ A ∣ < ∞ 或 ∣ A ∣ = ∣ Z + ∣ |A|=|\mathbb{Z}^+| ∣ A ∣ = ∣ Z + ∣ ,否则不可数
集合可数无穷 ⇔ \Leftrightarrow ⇔ 可以排成序列 ⇔ \Leftrightarrow ⇔ 存在双射 f : Z + → A f:\mathbb{Z}^+\rightarrow A f : Z + → A
集合可数无穷,则任意无穷子集可数,A ∪ B , A × B A\cup B, A\times B A ∪ B , A × B 也可数无穷
集合不可数,则其任意父集不可数
Schröder-Bernstein Theorem:∣ A ∣ ≤ ∣ B ∣ , ∣ B ∣ ≤ ∣ A ∣ ⇒ ∣ A ∣ = ∣ B ∣ |A|\le|B|,|B|\le|A|\Rightarrow|A|=|B| ∣ A ∣ ≤ ∣ B ∣ , ∣ B ∣ ≤ ∣ A ∣ ⇒ ∣ A ∣ = ∣ B ∣
ℵ 0 = ∣ Z + ∣ < 2 ℵ 0 = ∣ P ( Z + ) ∣ = ∣ [ 0 , 1 ) ∣ = ∣ ( 0 , 1 ) ∣ = ∣ R ∣ = c \aleph_0=|\mathbb{Z}^+|<2^{\aleph_0}=|\mathcal{P}(\mathbb{Z}^+)|=|[0,1)|=|(0,1)|=|\mathbb{R}|=c ℵ 0 = ∣ Z + ∣ < 2 ℵ 0 = ∣ P ( Z + ) ∣ = ∣ [ 0 , 1 ) ∣ = ∣ ( 0 , 1 ) ∣ = ∣ R ∣ = c
The continuum hypothesis 连续统假设:不存在集合 A A A 使得 ℵ 0 < ∣ A ∣ < c \aleph_0<|A|<c ℵ 0 < ∣ A ∣ < c
Lec11
r r r -permutation 排列:A A A 中 r r r 个不同元素组成的序列
一个 n n n 元素的集合有 P ( n , r ) = A n r = n ! ( n − r ) ! P(n,r)=A_n^r=\frac{n!}{(n-r)!} P ( n , r ) = A n r = ( n − r ) ! n ! 种不同的 r r r -permutation
若为可重复 r r r -permutation 则有 n r n^r n r 种
multiset 多重集:某个元素 x x x 出现了 m m m 次则有重数 m m m ,多重集 A A A 有 n n n 个元素为 n n n -multiset,r r r -subset 每个元素重数不超过父集
多重集的排列:先排列后去重 ( n 1 + n 2 + ⋯ + n k ) ! n 1 ! n 2 ! ⋯ n k ! \frac{(n_1+n_2+\cdots+n_k)!}{n_1!n_2!\cdots n_k!} n 1 ! n 2 ! ⋯ n k ! ( n 1 + n 2 + ⋯ + n k ) !
普通集合 r r r -permutation 不带重复相当于 { 1 ⋅ a 1 , ⋯ , 1 ⋅ a n } \{1\cdot a_1,\cdots,1\cdot a_n\} { 1 ⋅ a 1 , ⋯ , 1 ⋅ a n } 的排列,带重复相当于 { ∞ ⋅ a 1 , ⋯ , ∞ ⋅ a n } \{\infty\cdot a_1,\cdots,\infty\cdot a_n\} { ∞ ⋅ a 1 , ⋯ , ∞ ⋅ a n } 的排列
最短路径:p p p 行 q q q 列格子,只能向右向上走,有 ( p + q ) ! p ! q ! \frac{(p+q)!}{p!q!} p ! q ! ( p + q ) ! 种路径
T-Route:斜着往右从 ( a , α ) (a,\alpha) ( a , α ) 走到 ( b , β ) (b,\beta) ( b , β ) ,需要满足 b > a b>a b > a ; b − a ≥ ∣ β − α ∣ b-a\ge|\beta-\alpha| b − a ≥ ∣ β − α ∣ ; 2 ∣ ( b + β − a − α ) 2\mid(b+\beta-a-\alpha) 2 ∣ ( b + β − a − α )
T-Route 数量:
( b − a ) ! ( b − a 2 + β − α 2 ) ! ( b − a 2 − β − α 2 ) ! \frac{(b-a)!}{(\frac{b-a}{2}+\frac{\beta-\alpha}{2})!(\frac{b-a}{2}-\frac{\beta-\alpha}{2})!}
( 2 b − a + 2 β − α ) ! ( 2 b − a − 2 β − α ) ! ( b − a ) !
与 x x x 轴相交的 T-Route 数量:即 ( a , − α ) (a,-\alpha) ( a , − α ) 到 ( b , β ) (b,\beta) ( b , β ) 的 T-Route 数量
( b − a ) ! ( b − a 2 + β + α 2 ) ! ( b − a 2 − β + α 2 ) ! \frac{(b-a)!}{(\frac{b-a}{2}+\frac{\beta+\alpha}{2})!(\frac{b-a}{2}-\frac{\beta+\alpha}{2})!}
( 2 b − a + 2 β + α ) ! ( 2 b − a − 2 β + α ) ! ( b − a ) !
不与 x x x 轴相交的 T-Route 数量:即上面两者相减
Bertrand’s Ballot Problem 投票问题:候选人 A, B 均获得 n n n 张选票,在整个点票过程中 A 的票数都严格大于 B B B 的概率是 C n / ( 2 n n ) C_n/\binom{2n}{n} C n / ( n 2 n ) ,其中 C n C_n C n 为卡特兰数
Catalan Number 卡特兰数:下面方程组的解的个数,即从 ( 1 , 2 ) (1,2) ( 1 , 2 ) 到 ( 2 n , 1 ) (2n,1) ( 2 n , 1 ) 的 T-Route 个数
{ x 1 + x 2 + ⋯ + x 2 n = n x 1 + x 2 + ⋯ + x i ≤ i / 2 , i = 1 , 2 , … , 2 n − 1 x i ∈ { 0 , 1 } , i = 1 , 2 , … , 2 n \begin{cases}
x_1 + x_2 + \cdots + x_{2n} = n \\
x_1 + x_2 + \cdots + x_i \leq i/2, \quad i = 1,2,\dots,2n-1 \\
x_i \in \{0,1\}, \quad i = 1,2,\dots,2n
\end{cases}
⎩ ⎪ ⎪ ⎨ ⎪ ⎪ ⎧ x 1 + x 2 + ⋯ + x 2 n = n x 1 + x 2 + ⋯ + x i ≤ i / 2 , i = 1 , 2 , … , 2 n − 1 x i ∈ { 0 , 1 } , i = 1 , 2 , … , 2 n
C n = ( 2 n − 1 ) ! ( n − 1 ) ! n ! − ( 2 n − 1 ) ! ( n + 1 ) ! ( n − 2 ) ! = ( 2 n ) ! n ! ( n + 1 ) ! C_n=\frac{(2n-1)!}{(n-1)!n!}-\frac{(2n-1)!}{(n+1)!(n-2)!}=\frac{(2n)!}{n!(n+1)!}
C n = ( n − 1 ) ! n ! ( 2 n − 1 ) ! − ( n + 1 ) ! ( n − 2 ) ! ( 2 n − 1 ) ! = n ! ( n + 1 ) ! ( 2 n ) !
Lec12
r r r -combination 组合:一个集合的 r r r -subset (r r r -子集)
一个 n n n 元素的集合有 ( n r ) = C n r = n ! r ! ( n − r ) ! \binom{n}{r}=C_n^r=\frac{n!}{r!(n-r)!} ( r n ) = C n r = r ! ( n − r ) ! n ! 种不同的 r r r -combination
若为可重复 r r r -combination 则有 ( n + r − 1 r ) \binom{n+r-1}{r} ( r n + r − 1 ) 种(相当于第 i i i 个元素取 x i x_i x i 个,∑ x i = r \sum x_i=r ∑ x i = r )
将整数 r r r 分为 n n n 份(有顺序)有 ( n + r − 1 r ) \binom{n+r-1}{r} ( r n + r − 1 ) 种分法(隔板法)
U \mathcal{U} U 为 A = [ n ] A=[n] A = [ n ] 的所有带重复 r r r -组合 的集合,V \mathcal{V} V 为 [ n + r − 1 ] [n+r-1] [ n + r − 1 ] 的所有不带重复 r r r -组合 的集合
令 U = u 1 , ⋯ , u r ∈ U U={u_1,\cdots,u_r}\in\mathcal{U} U = u 1 , ⋯ , u r ∈ U ,且 1 ≤ u 1 ≤ u 2 ≤ ⋯ ≤ u r ≤ n 1\le u_1\le u_2\le\cdots\le u_r\le n 1 ≤ u 1 ≤ u 2 ≤ ⋯ ≤ u r ≤ n ,则 1 ≤ u 1 < u 2 + 1 < u 3 + 2 < ⋯ < u r + r − 1 ≤ n + r − 1 1\le u_1<u_2+1<u_3+2<\cdots<u_r+r-1\le n+r-1 1 ≤ u 1 < u 2 + 1 < u 3 + 2 < ⋯ < u r + r − 1 ≤ n + r − 1 ,而 u 1 , u 2 + 1 , ⋯ , u r + r − 1 ∈ V {u_1,u_2+1,\cdots,u_r+r-1}\in\mathcal{V} u 1 , u 2 + 1 , ⋯ , u r + r − 1 ∈ V ;故 f : U → V f:\mathcal{U\rightarrow V} f : U → V 构成双射,因此 ∣ U ∣ = ∣ V ∣ = ( n + r − 1 r ) \mathcal{|U|=|V|}=\binom{n+r-1}{r} ∣ U ∣ = ∣ V ∣ = ( r n + r − 1 )
例:∑ i 1 = 1 n ∑ i 2 = 1 i 1 ⋯ ∑ i r = 1 i r − 1 1 = ( n + r − 1 r ) \sum_{i_1=1}^n\sum_{i_2=1}^{i_1}\cdots\sum_{i_r=1}^{i_{r-1}} 1=\binom{n+r-1}{r} ∑ i 1 = 1 n ∑ i 2 = 1 i 1 ⋯ ∑ i r = 1 i r − 1 1 = ( r n + r − 1 ) ,即生成最大值为 n n n 的 r r r 个元素的递增序列的个数
普通集合 r r r -combination 不带重复且 0 ≤ r ≤ n 0\le r\le n 0 ≤ r ≤ n 相当于 { 1 ⋅ a 1 , ⋯ , 1 ⋅ a n } \{1\cdot a_1,\cdots,1\cdot a_n\} { 1 ⋅ a 1 , ⋯ , 1 ⋅ a n } 的组合,带重复且 r ≥ 0 r\ge 0 r ≥ 0 相当于 { ∞ ⋅ a 1 , ⋯ , ∞ ⋅ a n } \{\infty\cdot a_1,\cdots,\infty\cdot a_n\} { ∞ ⋅ a 1 , ⋯ , ∞ ⋅ a n } 的组合,即 ( n + r − 1 r ) \binom{n+r-1}{r} ( r n + r − 1 )
组合证明:L = R L=R L = R ,同一对象用两种计数方式或构成双射
例 ( n i ) = ( n n − i ) \binom{n}{i}=\binom{n}{n-i} ( i n ) = ( n − i n ) :X = { s ∈ { 0 , 1 } n : X=\{s\in\{0,1\}^n: X = { s ∈ { 0 , 1 } n : 包含 i i i 个 0 0 0 } = { s ∈ { 0 , 1 } n : \}=\{s\in\{0,1\}^n: } = { s ∈ { 0 , 1 } n : 包含 n − i n-i n − i 个 1 1 1 } \} }
{ a n } n ≥ s \{a_n\}_{n\ge s} { a n } n ≥ s 的二项式变换是 { b n } n ≥ s \{b_n\}_{n\ge s} { b n } n ≥ s 并且 b n = ∑ k = s n ( n k ) a k b_n=\sum_{k=s}^n\binom{n}{k}a_k b n = ∑ k = s n ( k n ) a k
Inverse Binomial Transform 二项式反演:a n = ∑ k = s n ( − 1 ) n − k ( n k ) b k a_n=\sum_{k=s}^n(-1)^{n-k}\binom{n}{k}b_k a n = ∑ k = s n ( − 1 ) n − k ( k n ) b k
引理:( n k ) ( k i ) = ( n i ) ( n − i k − i ) \binom{n}{k}\binom{k}{i}=\binom{n}{i}\binom{n-i}{k-i} ( k n ) ( i k ) = ( i n ) ( k − i n − i ) ,∑ k = i n ( − 1 ) n − k ( n k ) ( k i ) = { 1 n = i 0 n > i \sum_{k=i}^n(-1)^{n-k}\binom{n}{k}\binom{k}{i}=\begin{cases}1\quad n=i\\0\quad n>i\end{cases} ∑ k = i n ( − 1 ) n − k ( k n ) ( i k ) = { 1 n = i 0 n > i
引理:令 n , s ∈ N , s ≤ n n,s\in\mathbb{N},s\le n n , s ∈ N , s ≤ n ,则 ∑ k = s n ∑ i = s k a k , i = ∑ k = s n α k = ∑ i = s n ∑ k = i n a k , i = ∑ i = s n β i \sum_{k=s}^n\sum_{i=s}^ka_{k,i}=\sum_{k=s}^n\alpha_k=\sum_{i=s}^n\sum_{k=i}^na_{k,i}=\sum_{i=s}^n\beta_i ∑ k = s n ∑ i = s k a k , i = ∑ k = s n α k = ∑ i = s n ∑ k = i n a k , i = ∑ i = s n β i
k \ i s s + 1 s + 2 ⋯ n row sum s a s , s ⋯ α s s + 1 a s + 1 , s a s + 1 , s + 1 ⋯ α s + 1 s + 2 a s + 2 , s a s + 2 , s + 1 a s + 2 , s + 2 ⋯ α s + 2 ⋮ ⋮ ⋮ ⋮ ⋱ ⋮ ⋮ n a n , s a n , s + 1 a n , s + 2 ⋯ a n , n α n col sum β s β s + 1 β s + 2 ⋯ β n ∑ ∑ \begin{array}{c|cccccc|c}
k \backslash i & s & s+1 & s+2 & \cdots & n & \text{row sum} \\
\hline
s & a_{s,s} & & & \cdots & & \alpha_s \\
s+1 & a_{s+1,s} & a_{s+1,s+1} & & \cdots & & \alpha_{s+1} \\
s+2 & a_{s+2,s} & a_{s+2,s+1} & a_{s+2,s+2} & \cdots & & \alpha_{s+2} \\
\vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
n & a_{n,s} & a_{n,s+1} & a_{n,s+2} & \cdots & a_{n,n} & \alpha_n \\
\hline
\text{col sum} & \beta_s & \beta_{s+1} & \beta_{s+2} & \cdots & \beta_n & \sum\sum
\end{array}
k \ i s s + 1 s + 2 ⋮ n col sum s a s , s a s + 1 , s a s + 2 , s ⋮ a n , s β s s + 1 a s + 1 , s + 1 a s + 2 , s + 1 ⋮ a n , s + 1 β s + 1 s + 2 a s + 2 , s + 2 ⋮ a n , s + 2 β s + 2 ⋯ ⋯ ⋯ ⋯ ⋱ ⋯ ⋯ n ⋮ a n , n β n row sum α s α s + 1 α s + 2 ⋮ α n ∑ ∑
Lec13
object box formula type labeled labeled n ! n 1 ! n 2 ! … n k ! { n 1 ⋅ 1 , … , n k ⋅ k } permutation unlabeled labeled ( n + k − 1 n ) { ∞ ⋅ 1 , … , ∞ ⋅ k } n -combination labeled unlabeled ∑ j = 1 k S 2 ( n , j ) 分类(相加),注意可空 unlabeled unlabeled ∑ j = 1 k p j ( n ) 整数分割 \begin{array}{|c|c|c|c|}
\hline
\text{object} & \text{box} & \text{formula} & \text{type} \\
\hline
\text{labeled} & \text{labeled} & \frac{n!}{n_1! n_2! \dots n_k!} & \{n_1 \cdot 1, \dots, n_k \cdot k\} \text{ permutation} \\
\hline
\text{unlabeled} & \text{labeled} & \binom{n+k-1}{n} & \{\infty \cdot 1, \dots, \infty \cdot k\} \text{ } n\text{-combination} \\
\hline
\text{labeled} & \text{unlabeled} & \sum_{j=1}^{k} S_2(n,j) & \text{分类(相加),注意可空} \\
\hline
\text{unlabeled} & \text{unlabeled} & \sum_{j=1}^{k} p_j(n) & \text{整数分割} \\
\hline
\end{array}
object labeled unlabeled labeled unlabeled box labeled labeled unlabeled unlabeled formula n 1 ! n 2 ! … n k ! n ! ( n n + k − 1 ) ∑ j = 1 k S 2 ( n , j ) ∑ j = 1 k p j ( n ) type { n 1 ⋅ 1 , … , n k ⋅ k } permutation { ∞ ⋅ 1 , … , ∞ ⋅ k } n -combination 分类(相加),注意可空 整数分割
第二类斯特林数(n n n 个元素分成 j j j 个非空集合):S 2 ( n , j ) = 1 j ! ∑ i = 0 j − 1 ( − 1 ) i ( j i ) ( j − i ) n , n ≥ j ≥ 1 S_2(n,j)=\frac{1}{j!}\sum_{i=0}^{j-1}(-1)^i\binom{j}{i}(j-i)^n,n\ge j\ge 1 S 2 ( n , j ) = j ! 1 ∑ i = 0 j − 1 ( − 1 ) i ( i j ) ( j − i ) n , n ≥ j ≥ 1
证明:T ( n , j ) T(n,j) T ( n , j ) 为将 n n n 个区分的物品放入 j j j 个区分的盒子(没有盒子空着)的方案数,T ( n , j ) = j ! ⋅ S 2 ( n , j ) T(n,j)=j!\cdot S_2(n,j) T ( n , j ) = j ! ⋅ S 2 ( n , j ) ;∣ X ∣ = j n |X|=j^n ∣ X ∣ = j n 为有盒子空者的方案数;X i ⊂ X X_i\subset X X i ⊂ X 有 i i i 个盒子被使用的方案集合,X 1 , ⋯ , X j {X_1,\cdots,X_j} X 1 , ⋯ , X j 构成 partition,且 ∣ X i ∣ = ( j i ) T ( n , i ) |X_i|=\binom{j}{i}T(n,i) ∣ X i ∣ = ( i j ) T ( n , i ) ,则 j n = ∣ X ∣ = ∑ i = 1 j ( j i ) T ( n , i ) j^n=|X|=\sum_{i=1}^j\binom{j}{i}T(n,i) j n = ∣ X ∣ = ∑ i = 1 j ( i j ) T ( n , i ) ,二项式反演得出斯特林数公式
整数分割:把 n n n 分成 j j j 份方案数记为 p j ( n ) p_j(n) p j ( n ) ;定理:p j ( n + j ) = ∑ i = 1 j p i ( n ) p_j(n+j)=\sum_{i=1}^jp_i(n) p j ( n + j ) = ∑ i = 1 j p i ( n ) ;p 1 ( n ) = p n ( n ) = 1 p_1(n)=p_n(n)=1 p 1 ( n ) = p n ( n ) = 1 ;若 j > n j>n j > n 则 p j ( n ) = 0 p_j(n)=0 p j ( n ) = 0
Recurrence Relation 递推关系:Hanoi 塔问题 H 1 = 1 , H 2 = 3 , H n = 2 H n − 1 + 1 H_1=1,H_2=3,H_n=2H_{n-1}+1 H 1 = 1 , H 2 = 3 , H n = 2 H n − 1 + 1
线性齐次递推关系(LHRR):a n = c 1 a n − 1 + c 2 a n − 2 + ⋯ + c k a n − k a_n=c_1a_{n-1}+c_2a_{n-2}+\cdots+c_ka_{n-k} a n = c 1 a n − 1 + c 2 a n − 2 + ⋯ + c k a n − k ,有通项公式
特征根:LHRR 变换为 r k − c 1 r k − 1 − c 2 r k − 2 − ⋯ − c k = 0 r^k-c_1r^{k-1}-c_2r^{k-2}-\cdots-c_k=0 r k − c 1 r k − 1 − c 2 r k − 2 − ⋯ − c k = 0 ,可解得 k k k 个特征根,再带回前 k k k 个初始值 a n = c 1 r 1 n + c 2 r 2 n + ⋯ + c k r k n a_n=c_1r_1^n+c_2r_2^n+\cdots+c_kr_k^n a n = c 1 r 1 n + c 2 r 2 n + ⋯ + c k r k n ,解出 c 1 , ⋯ , c k c_1,\cdots,c_k c 1 , ⋯ , c k ;若特征根有重数 m 1 , m 2 , ⋯ , m t m_{1},m_{2},\cdots,m_{t} m 1 , m 2 , ⋯ , m t ,则可构造通解:x n = ∑ j = 1 k ( ∑ l = 0 m j − 1 a j , l n l ) r j n x_{n}=\sum_{j=1}^k\left( \sum_{l=0}^{m_{j}-1} a_{j,l} n^l \right) r_{j}^n x n = ∑ j = 1 k ( ∑ l = 0 m j − 1 a j , l n l ) r j n
线性非齐次递推关系(LNRR):a n = c 1 a n − 1 + c 2 a n − 2 + ⋯ + c k a n − k + F ( n ) a_n=c_1a_{n-1}+c_2a_{n-2}+\cdots+c_ka_{n-k}+F(n) a n = c 1 a n − 1 + c 2 a n − 2 + ⋯ + c k a n − k + F ( n ) ;则 a n = a_n= a n = 齐次通解 + + + 特解
LNRR 特解:若 F ( n ) = P ( n ) s n F(n)=P(n)s^n F ( n ) = P ( n ) s n ,其中 P ( n ) P(n) P ( n ) 为 n n n 的 l l l 阶多项式,s s s 为特征根之一,其重数为 m m m ,则特解 x n = ( p l n l + ⋯ + p 1 n + p 0 ) s n n m x_n=(p_ln^l+\cdots+p_1n+p_0)s^nn^m x n = ( p l n l + ⋯ + p 1 n + p 0 ) s n n m ;齐次通解:两个不同特征根,则 y n = A r 1 n + B r 2 n y_n = Ar_{1}^n+Br_{2}^n y n = A r 1 n + B r 2 n ;重根:y n = ( A + B n ) r n y_{n} = (A+Bn)r^n y n = ( A + B n ) r n (参考上面)
Lec14
{ a r } r = 0 ∞ \{a_{r}\}_{r=0}^\infty { a r } r = 0 ∞ 的生成函数 (Generating function) 为 G ( x ) = ∑ r = 0 ∞ a r x r G(x)=\sum_{r=0}^\infty a_{r}x^r G ( x ) = ∑ r = 0 ∞ a r x r ;两个生成函数相等即每项相等
定义加减、数乘、乘法:A ( x ) ⋅ B ( x ) = ∑ r = 0 ∞ ( ∑ j = 0 r a j b r − j ) A(x)\cdot B(x)=\sum_{r=0}^\infty\left( \sum_{j=0}^r a_{j}b_{r-j} \right) A ( x ) ⋅ B ( x ) = ∑ r = 0 ∞ ( ∑ j = 0 r a j b r − j )
A ( x ) A(x) A ( x ) 有逆元当且仅当 a 0 ≠ 0 a_0\ne0 a 0 = 0 (如 A ( x ) = ∑ r = 0 ∞ x r A(x)=\sum_{r=0}^\infty x^r A ( x ) = ∑ r = 0 ∞ x r 逆元为 A − 1 ( x ) = 1 − x A^{-1}(x)=1-x A − 1 ( x ) = 1 − x )
Extended binomial coefficient: u ∈ R , n ∈ N u\in\mathbb{R},n\in\mathbb{N} u ∈ R , n ∈ N 可定义
( u n ) = { u ( u − 1 ) ⋯ ( u − n + 1 ) n ! n > 0 1 n = 0 \binom{u}{n} =
\begin{cases}
\displaystyle \frac{u(u-1)\cdots(u - n + 1)}{n!} & n > 0 \\
1 & n = 0
\end{cases}
( n u ) = ⎩ ⎪ ⎨ ⎪ ⎧ n ! u ( u − 1 ) ⋯ ( u − n + 1 ) 1 n > 0 n = 0
x , u ∈ R , ∣ x ∣ < 1 x,u\in\mathbb{R},|x|<1 x , u ∈ R , ∣ x ∣ < 1 则 ( 1 + x ) u = ∑ n = 0 ∞ ( u n ) x n (1+x)^u=\sum_{n=0}^\infty\binom{u}{n}x^n ( 1 + x ) u = ∑ n = 0 ∞ ( n u ) x n ;例如 ( 1 − α x ) − 1 = ∑ n = 0 ∞ α n x n (1-\alpha x)^{-1}=\sum_{n=0}^\infty \alpha^n x^n ( 1 − α x ) − 1 = ∑ n = 0 ∞ α n x n 以及 ( 1 − α x ) − u = ∑ n = 0 ∞ ( n + u − 1 n ) a n x n (1-\alpha x)^{-u}=\sum_{n=0}^\infty\binom{n+u-1}{n}a^nx^n ( 1 − α x ) − u = ∑ n = 0 ∞ ( n n + u − 1 ) a n x n
两个多项式 deg ( Q ) > deg ( P ) , Q ( x ) = ( 1 − r 1 x ) m 1 ⋯ ( 1 − r t x ) m t \deg(Q)>\deg(P),Q(x)=(1-r_{1}x)^{m_{1}}\cdots(1-r_{t}x)^{m_{t}} deg ( Q ) > deg ( P ) , Q ( x ) = ( 1 − r 1 x ) m 1 ⋯ ( 1 − r t x ) m t 则存在 P ( x ) Q ( x ) = ∑ j = 1 t ∑ u = 1 m j a j , u ( 1 − r j x ) u \frac{P(x)}{Q(x)} = \sum_{j=1}^t \sum_{u=1}^{m_{j}} \frac{a_{j,u}}{(1-r_{j}x)^u} Q ( x ) P ( x ) = ∑ j = 1 t ∑ u = 1 m j ( 1 − r j x ) u a j , u (可裂项)
使用生成函数解决 RR:例如 a n = 8 a n − 1 + 1 0 n − 1 a_n=8a_{n-1}+10^{n-1} a n = 8 a n − 1 + 1 0 n − 1
A ( x ) = ∑ n = 0 ∞ a n x n = 1 + ∑ n = 1 ∞ ( 8 a n − 1 + 1 0 n − 1 ) x n = 1 + 8 x A ( x ) + x 1 − 10 x A ( x ) = 1 − 9 x ( 1 − 8 x ) ( 1 − 10 x ) = 1 2 ( 1 1 − 8 x + 1 1 − 10 x ) = ∑ n = 0 ∞ 1 2 ( 8 n + 1 0 n ) x n \begin{aligned}
A(x) &= \sum_{n=0}^\infty a_{n} x^n = 1 + \sum_{n=1}^\infty(8a_{n-1}+10^{n-1})x^n \\
&= 1 + 8xA(x) + \frac{x}{1-10x} \\
A(x) &= \frac{1-9x}{(1-8x)(1-10x)} = \frac{1}{2} \left( \frac{1}{1-8x} + \frac{1}{1-10x} \right) \\
&= \sum_{n=0}^\infty \frac{1}{2}(8^n+10^n)x^n
\end{aligned}
A ( x ) A ( x ) = n = 0 ∑ ∞ a n x n = 1 + n = 1 ∑ ∞ ( 8 a n − 1 + 1 0 n − 1 ) x n = 1 + 8 x A ( x ) + 1 − 1 0 x x = ( 1 − 8 x ) ( 1 − 1 0 x ) 1 − 9 x = 2 1 ( 1 − 8 x 1 + 1 − 1 0 x 1 ) = n = 0 ∑ ∞ 2 1 ( 8 n + 1 0 n ) x n
卡特兰数 C n = C 0 C n − 1 + C 1 C n − 2 + ⋯ + C n − 1 C 0 C_n=C_{0}C_{n-1}+C_{1}C_{n-2}+\cdots+C_{n-1}C_{0} C n = C 0 C n − 1 + C 1 C n − 2 + ⋯ + C n − 1 C 0 生成函数 x C ( x ) 2 = C ( x ) − 1 xC(x)^2=C(x)-1 x C ( x ) 2 = C ( x ) − 1
用生成函数计算组合数:a n a_n a n 为 [ k ] [k] [ k ] 的带重复n n n -组合个数 (Type 2),即 N i N_i N i 为 i i i 可能的出现次数的集合,a n = ∣ { ( n 1 , ⋯ , n k ) : n 1 ∈ N 1 , ⋯ , n k ∈ N k , n 1 + ⋯ + n k = n } ∣ a_{n}=|\{(n_{1},\cdots,n_{k}):n_{1}\in N_{1},\cdots,n_k\in N_{k},n_{1}+\cdots+n_{k}=n\}| a n = ∣ { ( n 1 , ⋯ , n k ) : n 1 ∈ N 1 , ⋯ , n k ∈ N k , n 1 + ⋯ + n k = n } ∣
∑ n = 0 ∞ a n x n = ∑ n = 0 ∞ ( ∑ n i ∈ N i , n 1 + ⋯ + n k = n 1 ) x n = ∏ i = 1 k ∑ n i ∈ N i x n i \sum_{n=0}^\infty a_{n}x^n=\sum_{n=0}^\infty\left( \sum_{n_{i}\in N_{i},n_{1}+\cdots+n_{k}=n}1 \right)x^n=\prod_{i=1}^k\sum_{n_{i}\in N_{i}}x^{n_{i}} ∑ n = 0 ∞ a n x n = ∑ n = 0 ∞ ( ∑ n i ∈ N i , n 1 + ⋯ + n k = n 1 ) x n = ∏ i = 1 k ∑ n i ∈ N i x n i
例:a n a_n a n 为分配 n n n 本相同的书给 5 5 5 个人,其中四人分别 ≥ 3 , ≥ 2 , ≥ 4 , ≥ 6 \ge3,\ge2,\ge4,\ge6 ≥ 3 , ≥ 2 , ≥ 4 , ≥ 6 ;则 a n = ∣ { ( n 1 , ⋯ , n 5 ) : n 1 ≥ 3 , ⋯ , n 5 ≥ 0 , n 1 + ⋯ + n 5 = n } ∣ a_n=|\{(n_{1},\cdots,n_{5}):n_{1}\ge 3,\cdots,n_{5}\ge 0,n_{1}+\cdots+n_{5}=n\}| a n = ∣ { ( n 1 , ⋯ , n 5 ) : n 1 ≥ 3 , ⋯ , n 5 ≥ 0 , n 1 + ⋯ + n 5 = n } ∣ ,则
∑ n = 0 ∞ a n x n = ( x 3 + ⋯ ) ⋯ ( 1 + x + ⋯ ) = x 3 1 − x x 2 1 − x ⋯ 1 1 − x = x 15 ∑ m = 0 ∞ ( − 5 m ) ( − 1 ) m x m \begin{aligned}
\sum_{n=0}^\infty a_{n}x^n&=(x^3+\cdots)\cdots(1+x+\cdots) \\
&=\frac{x^3}{1-x} \frac{x^2}{1-x} \cdots \frac{1}{1-x}=x^{15} \sum_{m=0}^\infty \binom{-5}{m}(-1)^m x^m
\end{aligned}
n = 0 ∑ ∞ a n x n = ( x 3 + ⋯ ) ⋯ ( 1 + x + ⋯ ) = 1 − x x 3 1 − x x 2 ⋯ 1 − x 1 = x 1 5 m = 0 ∑ ∞ ( m − 5 ) ( − 1 ) m x m
计算 [ k ] [k] [ k ] 的n n n -排列:a n = ∑ n ! n 1 ! n 2 ! ⋯ n k ! a_n=\sum \frac{n!}{n_{1}!n_{2}!\cdots n_{k}!} a n = ∑ n 1 ! n 2 ! ⋯ n k ! n ! ;∑ n = 0 ∞ a n n ! x n = ∏ i = 1 k ∑ n i ∈ N i x n i n i ! \sum_{n=0}^\infty \frac{a_{n}}{n!} x^n = \prod_{i=1}^k \sum_{n_{i}\in N_{i}} \frac{x^{n_{i}}}{n_{i}!} ∑ n = 0 ∞ n ! a n x n = ∏ i = 1 k ∑ n i ∈ N i n i ! x n i
例:a n = { s ∈ { 1 , 2 , 3 , 4 } n : s has an even number of 1s } a_{n} = \{ s \in \{1,2,3,4\}^n:s \text{ has an even number of 1s} \} a n = { s ∈ { 1 , 2 , 3 , 4 } n : s has an even number of 1s }
∑ n = 0 ∞ a n n ! x n = ( 1 + x 2 2 ! + x 4 4 ! ⋯ ) ( 1 + x 1 ! + x 2 2 ! + ⋯ ) 3 = e x + e − x 2 ⋅ e 3 x = 1 2 ∑ n = 0 ∞ ( 4 n n ! + 2 n n ! ) x n \begin{aligned}
\sum_{n=0}^\infty \frac{a^n}{n!} x^n &= \left( 1 + \frac{x^2}{2!} + \frac{x^4}{4!}\cdots \right)\left( 1 + \frac{x}{1!} + \frac{x^2}{2!} + \cdots \right)^3 \\
&= \frac{e^x+e^{-x}}{2} \cdot e^{3x} = \frac{1}{2} \sum_{n=0}^\infty \left( \frac{4^n}{n!} + \frac{2^n}{n!} \right)x^n
\end{aligned}
n = 0 ∑ ∞ n ! a n x n = ( 1 + 2 ! x 2 + 4 ! x 4 ⋯ ) ( 1 + 1 ! x + 2 ! x 2 + ⋯ ) 3 = 2 e x + e − x ⋅ e 3 x = 2 1 n = 0 ∑ ∞ ( n ! 4 n + n ! 2 n ) x n
附录
e x = ∑ n = 0 ∞ x n n ! , ln ( 1 + x ) = ∑ n = 1 ∞ ( − 1 ) n − 1 x n n sin x = ∑ n = 0 ∞ ( − 1 ) n x 2 n + 1 ( 2 n + 1 ) ! , cos x = ∑ n = 0 ∞ ( − 1 ) n x 2 n ( 2 n ) ! ( 1 + x ) α = ∑ n = 0 ∞ α ( α − 1 ) ⋯ ( a − n + 1 ) n ! x n \begin{array}{ll}
e^x=\sum^\infty_{n=0}\frac{x^n}{n!},&
\ln(1+x)=\sum^\infty_{n=1}\frac{(-1)^{n-1}x^n}{n}\\
\sin x=\sum^\infty_{n=0}(-1)^{n}\frac{x^{2n+1}}{(2n+1)!},&
\cos x=\sum^\infty_{n=0}(-1)^{n}\frac{x^{2n}}{(2n)!}\\
(1+x)^\alpha=\sum^\infty_{n=0}\frac{\alpha(\alpha-1)\cdots(a-n+1)}{n!}x^n
\end{array}
e x = ∑ n = 0 ∞ n ! x n , sin x = ∑ n = 0 ∞ ( − 1 ) n ( 2 n + 1 ) ! x 2 n + 1 , ( 1 + x ) α = ∑ n = 0 ∞ n ! α ( α − 1 ) ⋯ ( a − n + 1 ) x n ln ( 1 + x ) = ∑ n = 1 ∞ n ( − 1 ) n − 1 x n cos x = ∑ n = 0 ∞ ( − 1 ) n ( 2 n ) ! x 2 n
( n m ) = ( n n − m ) ( n k ) = n k ( n − 1 k − 1 ) ( n m ) = ( n − 1 m ) + ( n − 1 m − 1 ) ∑ i = 0 n ( n i ) = 2 n , [ 1 ] ∑ i = 0 n ( − 1 ) i ( n i ) = ( n = 0 ? ) , [ 2 ] ( n r ) ( r k ) = ( n k ) ( n − k r − k ) ∑ i = 0 m ( n i ) ( m m − i ) = ( m + n m ) , n ≥ m ∑ i = 0 n ( n i ) 2 = ( 2 n n ) ∑ i = 0 n i ( n i ) = n 2 n − 1 ∑ i = 0 n i 2 ( n i ) = n ( n + 1 ) 2 n − 2 ∑ l = 0 n ( l k ) = ( n + 1 k + 1 ) , [ 3 ] ∑ i = 0 n ( n − i i ) = F n + 1 , [ 4 ] \begin{array}{lll}
\binom{n}{m}=\binom{n}{n-m} & \binom{n}{k}=\frac{n}{k}\binom{n-1}{k-1} & \binom{n}{m}=\binom{n-1}{m}+\binom{n-1}{m-1} \\
\sum_{i=0}^n\binom{n}{i}=2^n,[1] & \sum_{i=0}^n(-1)^i\binom{n}{i}=(n=0?),[2] & \binom{n}{r}\binom{r}{k}=\binom{n}{k}\binom{n-k}{r-k} \\
\sum_{i=0}^m\binom{n}{i}\binom{m}{m-i}=\binom{m+n}{m},n\ge m & \sum_{i=0}^n\binom{n}{i}^2=\binom{2n}{n} & \sum_{i=0}^n i\binom{n}{i}=n2^{n-1} \\
\sum_{i=0}^n i^2\binom{n}{i}=n(n+1)2^{n-2} & \sum_{l=0}^n\binom{l}{k}=\binom{n+1}{k+1},[3] & \sum_{i=0}^n\binom{n-i}{i}=F_{n+1},[4]
\end{array}
( m n ) = ( n − m n ) ∑ i = 0 n ( i n ) = 2 n , [ 1 ] ∑ i = 0 m ( i n ) ( m − i m ) = ( m m + n ) , n ≥ m ∑ i = 0 n i 2 ( i n ) = n ( n + 1 ) 2 n − 2 ( k n ) = k n ( k − 1 n − 1 ) ∑ i = 0 n ( − 1 ) i ( i n ) = ( n = 0 ? ) , [ 2 ] ∑ i = 0 n ( i n ) 2 = ( n 2 n ) ∑ l = 0 n ( k l ) = ( k + 1 n + 1 ) , [ 3 ] ( m n ) = ( m n − 1 ) + ( m − 1 n − 1 ) ( r n ) ( k r ) = ( k n ) ( r − k n − k ) ∑ i = 0 n i ( i n ) = n 2 n − 1 ∑ i = 0 n ( i n − i ) = F n + 1 , [ 4 ]
1: 二项式定理的特殊情况 a = b = 1 a=b=1 a = b = 1 ;2: 特殊情况 a = 1 , b = − 1 a=1,b=-1 a = 1 , b = − 1 ,且 n = 0 n=0 n = 0 答案为 1 1 1 ;3: 组合证明,取 S = a 1 , ⋯ , a n + 1 S={a_1,\cdots,a_{n+1}} S = a 1 , ⋯ , a n + 1 的 k + 1 k+1 k + 1 子集数;4: F F F 为斐波那契数列
下半学期
Lec15
命题:proposition;Simple Proposition, Compound(复合) Proposition, Propositional Constant, Propositional Variable, Propositional Logic
Negation 否定 ¬ \neg ¬ ,Conjunction 合取(and) ∧ \land ∧ ,Disjunction 析取(or) ∨ \lor ∨ ,Implication 蕴含 → \rightarrow → ,Bi-Implication 等值 ↔ \leftrightarrow ↔
蕴含的真值表:p p p 为 T 时,p → q = q p\rightarrow q=q p → q = q ,p p p 为 F 时均为 T;等值:两者的真值相同为真
Well-Formed Formulas(合式公式):合法的公式,用树状结构检查
运算优先级:先括号,再依次为 ¬ , ∧ , ∨ , → , ↔ \neg, \land, \lor, \rightarrow, \leftrightarrow ¬ , ∧ , ∨ , → , ↔ ,从左至右
转换例子:A comes to the party if and only if B doesn’t come, but, if B comes,
then C doesn’t come and D comes. 答案:( a ↔ ¬ b ) ∧ ( b → ( ¬ c ∧ d ) ) (a\leftrightarrow\neg b)\land (b\rightarrow(\neg c\land d)) ( a ↔ ¬ b ) ∧ ( b → ( ¬ c ∧ d ) )
A sufficient condition for A coming to the party is that, if B does
not come, then at least one of C and D must come. 答案:( ¬ b → ( c ∨ d ) ) → a (\neg b\rightarrow(c\lor d))\rightarrow a ( ¬ b → ( c ∨ d ) ) → a
Lec16
真值表:如 F = ( p → q ) ∧ ( q → r ) ↔ ( p → r ) F=(p\rightarrow q)\land(q\rightarrow r)\leftrightarrow (p\rightarrow r) F = ( p → q ) ∧ ( q → r ) ↔ ( p → r ) ,括号内分别为 A , B , C A,B,C A , B , C ,则真值表头为 p , q , r , A , B , C , A ∧ B , F p,q,r,A,B,C,A\land B,F p , q , r , A , B , C , A ∧ B , F
Tautology 重言式:任意truth assignment恒真;Contradiction 矛盾式:恒假;Contingency 可能式:非前面两者;Satisfiable:至少有一种真值指派使得它为真
Logically Equivalent 逻辑等值:任意真值指派都有相同的真值;A ≡ B A\equiv B A ≡ B 当且仅当 A ↔ B A\leftrightarrow B A ↔ B 为 tautology
表格省略:交换律、结合律(括号内外同号)、分配律(异号)
Double Negation Law 双重否定律 ¬ ( ¬ P ) ≡ P Identity Laws 同一律 P ∧ T ≡ P , P ∨ F ≡ P Idempotent Laws 等幂律 P ∨ P ≡ P , P ∧ P ≡ P Domination Laws 零律 P ∨ T ≡ T , P ∧ F ≡ F Negation Laws 补余律 P ∨ ¬ P ≡ T , P ∧ ¬ P ≡ F De Morgan’s Laws 摩根律 ¬ ( P ∧ Q ) ≡ ¬ P ∨ ¬ Q , ¬ ( P ∨ Q ) ≡ ¬ P ∧ ¬ Q Absorption Laws 吸收律 P ∨ ( P ∧ Q ) ≡ P , P ∧ ( P ∨ Q ) ≡ P P → Q ≡ ¬ P ∨ Q P ↔ Q ≡ ( ¬ P ∨ Q ) ∧ ( P ∨ ¬ Q ) P → Q ≡ ¬ Q → ¬ P P ↔ Q ≡ ( P ∧ Q ) ∨ ( ¬ P ∧ ¬ Q ) ( P → R ) ∧ ( Q → R ) ≡ ( P ∨ Q ) → R P ↔ Q ≡ ( P → Q ) ∧ ( Q → Q ) P → ( Q → R ) ≡ ( P ∧ Q ) → R P ↔ Q ≡ ¬ P ↔ ¬ Q P → ( Q → R ) ≡ Q → ( P → R ) 左侧为 → ,右侧为 ↔ \begin{array}{|c|c|}
\hline
\text{Double Negation Law 双重否定律}
& \neg(\neg P) \equiv P \\
\hline
\text{Identity Laws 同一律}
& P \land \mathbf{T} \equiv P, P \lor \mathbf{F} \equiv P \\
\hline
\text{Idempotent Laws 等幂律}
& P \lor P \equiv P, P \land P \equiv P \\
\hline
\text{Domination Laws 零律}
& P \lor \mathbf{T} \equiv \mathbf{T}, P \land \mathbf{F} \equiv \mathbf{F} \\
\hline
\text{Negation Laws 补余律}
& P \lor \neg P \equiv \mathbf{T}, P \land \neg P \equiv \mathbf{F} \\
\hline
\text{De Morgan's Laws 摩根律}
& \neg(P \land Q) \equiv \neg P \lor \neg Q, \neg(P \lor Q) \equiv \neg P \land \neg Q \\
\hline
\text{Absorption Laws 吸收律}
& P \lor (P \land Q) \equiv P, P \land (P \lor Q) \equiv P \\
\hline
P \to Q \equiv \neg P \lor Q & P \leftrightarrow Q \equiv (\neg P \lor Q) \land (P \lor \neg Q) \\
\hline
P \to Q \equiv \neg Q \to \neg P & P \leftrightarrow Q \equiv (P \land Q) \lor (\neg P \land \neg Q) \\
\hline
(P \to R) \land (Q \to R) \equiv (P \lor Q) \to R & P \leftrightarrow Q \equiv (P\rightarrow Q) \land (Q\rightarrow Q) \\
\hline
P \to (Q \to R) \equiv (P \land Q) \to R & P \leftrightarrow Q \equiv \neg P \leftrightarrow \neg Q \\
\hline
P \to (Q \to R) \equiv Q \to (P \to R) & \text{左侧为}\rightarrow\text{,右侧为}\leftrightarrow \\
\hline
\end{array}
Double Negation Law 双重否定律 Identity Laws 同一律 Idempotent Laws 等幂律 Domination Laws 零律 Negation Laws 补余律 De Morgan’s Laws 摩根律 Absorption Laws 吸收律 P → Q ≡ ¬ P ∨ Q P → Q ≡ ¬ Q → ¬ P ( P → R ) ∧ ( Q → R ) ≡ ( P ∨ Q ) → R P → ( Q → R ) ≡ ( P ∧ Q ) → R P → ( Q → R ) ≡ Q → ( P → R ) ¬ ( ¬ P ) ≡ P P ∧ T ≡ P , P ∨ F ≡ P P ∨ P ≡ P , P ∧ P ≡ P P ∨ T ≡ T , P ∧ F ≡ F P ∨ ¬ P ≡ T , P ∧ ¬ P ≡ F ¬ ( P ∧ Q ) ≡ ¬ P ∨ ¬ Q , ¬ ( P ∨ Q ) ≡ ¬ P ∧ ¬ Q P ∨ ( P ∧ Q ) ≡ P , P ∧ ( P ∨ Q ) ≡ P P ↔ Q ≡ ( ¬ P ∨ Q ) ∧ ( P ∨ ¬ Q ) P ↔ Q ≡ ( P ∧ Q ) ∨ ( ¬ P ∧ ¬ Q ) P ↔ Q ≡ ( P → Q ) ∧ ( Q → Q ) P ↔ Q ≡ ¬ P ↔ ¬ Q 左侧为 → , 右侧为 ↔
Lec17
若 A − 1 ( T ) A^{-1}(\mathbf{T}) A − 1 ( T ) 为令 A A A 为 true 的真值指派,则 A ≡ B ↔ A − 1 ( T ) = B − 1 ( T ) A\equiv B \leftrightarrow A^{-1}(\mathbf{T})=B^{-1}(\mathbf{T}) A ≡ B ↔ A − 1 ( T ) = B − 1 ( T ) ,T \mathbf{T} T 可换成 F \mathbf{F} F (即令命题为真或假的真值指派完全相同)
Tautological Implication 重言蕴含 ⇒ \Rightarrow ⇒ :A A A 重言蕴涵 B B B 当任意真值指派使得 A A A 为真时也会使得 B B B 为真,即 A − 1 ( T ) ⊆ B − 1 ( T ) , B − 1 ( F ) ⊆ A − 1 ( F ) A^{-1}(\mathbf{T})\subseteq B^{-1}(\mathbf{T}),B^{-1}(\mathbf{F})\subseteq A^{-1}(\mathbf{F}) A − 1 ( T ) ⊆ B − 1 ( T ) , B − 1 ( F ) ⊆ A − 1 ( F )
A ⇒ B A\Rightarrow B A ⇒ B 当且仅当 A → B A\rightarrow B A → B 是 tautology(即 A A A 能推出 B B B ),当且仅当 A ∧ ¬ B A\land\neg B A ∧ ¬ B 是 contradiction
Simplification 化简 P ∧ Q ⇒ P 或 Q Addition 附加 P ⇒ P ∨ Q Modus ponens 假言推理 P ∧ ( P → Q ) ⇒ Q Modus tollens 拒取 ¬ Q ∧ ( P → Q ) ⇒ ¬ P Disjunctive syllogism 析取三段论 ¬ P ∧ ( P ∨ Q ) ⇒ Q Hypothetical syllogism 假言三段论 ( P → Q ) ∧ ( Q → R ) ⇒ ( P → R ) Resolution 归结 ( P ∨ Q ) ∧ ( ¬ P ∨ R ) ⇒ ( Q ∨ R ) \begin{array}{|c|c|}
\hline
\text{Simplification 化简} & P \land Q \Rightarrow P \text{或} Q \\
\hline
\text{Addition 附加} & P \Rightarrow P \lor Q \\
\hline
\text{Modus ponens 假言推理} & P \land (P \rightarrow Q) \Rightarrow Q \\
\hline
\text{Modus tollens 拒取} & \lnot Q \land (P \rightarrow Q) \Rightarrow \lnot P \\
\hline
\text{Disjunctive syllogism 析取三段论} & \lnot P \land (P \lor Q) \Rightarrow Q \\
\hline
\text{Hypothetical syllogism 假言三段论} & (P \rightarrow Q) \land (Q \rightarrow R) \Rightarrow (P \rightarrow R) \\
\hline
\text{Resolution 归结} & (P \lor Q) \land (\lnot P \lor R) \Rightarrow (Q \lor R) \\
\hline
\end{array}
Simplification 化简 Addition 附加 Modus ponens 假言推理 Modus tollens 拒取 Disjunctive syllogism 析取三段论 Hypothetical syllogism 假言三段论 Resolution 归结 P ∧ Q ⇒ P 或 Q P ⇒ P ∨ Q P ∧ ( P → Q ) ⇒ Q ¬ Q ∧ ( P → Q ) ⇒ ¬ P ¬ P ∧ ( P ∨ Q ) ⇒ Q ( P → Q ) ∧ ( Q → R ) ⇒ ( P → R ) ( P ∨ Q ) ∧ ( ¬ P ∨ R ) ⇒ ( Q ∨ R )
Argument 论证:一个命题序列,含有:Conclusion 结论,Premises 假设,Valid 有效(前提为真,则结论必为真),Proof 证明
Argument Form 论证形式:一个 formula 公式序列,把 argument 中的命题换为命题 variables
Rules of inference 推理规则:例题证明 ( P ∨ Q ) ∧ ( P → R ) ∧ ( Q → S ) ⇒ S ∨ R (P\lor Q)\land(P\rightarrow R)\land(Q\rightarrow S)\Rightarrow S\lor R ( P ∨ Q ) ∧ ( P → R ) ∧ ( Q → S ) ⇒ S ∨ R
( 1 ) P ∨ Q Premise ( 2 ) ¬ P → Q Rule of replacement applied to (1) ( 3 ) Q → S Premise ( 4 ) ¬ P → S Hypothetical syllogism applied to (2) and (3) ( 5 ) ¬ S → P Rule of replacement applied to (4) ( 6 ) P → R Premise ( 7 ) ¬ S → R Hypothetical syllogism applied to (5) and (6) ( 8 ) S ∨ R Rule of replacement applied to (7) \begin{array}{ll}
(1)\quad P \lor Q & \text{Premise} \\
(2)\quad \lnot P \rightarrow Q & \text{Rule of replacement applied to (1)} \\
(3)\quad Q \rightarrow S & \text{Premise} \\
(4)\quad \lnot P \rightarrow S & \text{Hypothetical syllogism applied to (2) and (3)} \\
(5)\quad \lnot S \rightarrow P & \text{Rule of replacement applied to (4)} \\
(6)\quad P \rightarrow R & \text{Premise} \\
(7)\quad \lnot S \rightarrow R & \text{Hypothetical syllogism applied to (5) and (6)} \\
(8)\quad S \lor R & \text{Rule of replacement applied to (7)} \\
\end{array}
( 1 ) P ∨ Q ( 2 ) ¬ P → Q ( 3 ) Q → S ( 4 ) ¬ P → S ( 5 ) ¬ S → P ( 6 ) P → R ( 7 ) ¬ S → R ( 8 ) S ∨ R Premise Rule of replacement applied to (1) Premise Hypothetical syllogism applied to (2) and (3) Rule of replacement applied to (4) Premise Hypothetical syllogism applied to (5) and (6) Rule of replacement applied to (7)
Lec18
Predicate 谓词:一元(Unary)谓词,如 5 5 5 是整数;二元(Binary)谓词,如 a a a 比 b b b 大;Predicate constant,Predicate variable;Individual 个体词:你在考虑的东西;Individual constant:如 5 5 5 ,Individual variable:如 a a a ;Domain 个体域:所有被考虑的个体的集合
Propositional function 命题函数:P ( x 1 , … , x n ) P(x_1,\dots,x_n) P ( x 1 , … , x n ) ,P P P 是 n n n 元谓词;如 p p p 为 Alice’s father is a doctor,f ( x ) = x f(x)=x f ( x ) = x ’s father,谓词 D D D 为 is a doctor,则 p = D ( f ( A l i c e ) ) p=D(f(Alice)) p = D ( f ( A l i c e ) )
Universal Quantifier 全称量词 ∀ \forall ∀ ,如 ∀ x P ( x ) \forall xP(x) ∀ x P ( x ) ;Existential Quantifier 存在量词 ∃ \exists ∃
如果 ∀ , ∃ \forall,\exists ∀ , ∃ 被用于个体 variable x x x ,则其为 bound 约束的,否则是 free 自由的
Well-Formed Formulas 合式公式:正确且包含上述内容及表达式;WFF 类型:logically valid 普遍有效,恒真;unsatisfiable 不可满足,恒假;satisfiable 可满足,存在真的情况
转换例子:There is a symbol that can not be understood by any person’s brain. S ( x ) S(x) S ( x ) : x x x is a symbol. P ( x ) P(x) P ( x ) : x x x is a person. U ( x , y ) U(x,y) U ( x , y ) : x can understand y. b ( x ) b(x) b ( x ) the brain of x x x . 答案:∃ x ( S ( x ) ∧ ∀ y ( P ( y ) → ¬ U ( b ( y ) , x ) ) ) \exists x(S(x)\land \forall y(P(y)\rightarrow \neg U(b(y),x))) ∃ x ( S ( x ) ∧ ∀ y ( P ( y ) → ¬ U ( b ( y ) , x ) ) )
Interpretation 解释:把所有变量换成实际的东西;Logical Equivalence 逻辑等值:任意解释都有相同的真值(类比任意真值指派)
Lec19
De Morgan’s Laws 摩根律 ¬ ∀ x P ( x ) ≡ ∃ x ¬ P ( x ) , ¬ ∃ x P ( x ) ≡ ∀ x ¬ P ( x ) Distributive Laws 分配律 ∀ x ( P ( x ) ∧ Q ( x ) ) ≡ ∀ x P ( x ) ∧ ∀ x Q ( x ) ∃ x ( P ( x ) ∨ Q ( x ) ) ≡ ∃ x P ( x ) ∨ ∃ x Q ( x ) Conclusion Premise 附加前提 P ⇒ A → B ≡ P ∧ A ⇒ B ∀ x P ( x ) ∨ ∀ x Q ( x ) ⇒ ∀ x ( P ( x ) ∨ Q ( x ) ) ∃ x ( P ( x ) ∧ Q ( x ) ) ⇒ ∃ x P ( x ) ∧ ∃ x Q ( x ) ∀ x ( P ( x ) → Q ( x ) ) ⇒ ∀ x P ( x ) → ∀ x Q ( x ) ∀ x ( P ( x ) → Q ( x ) ) ⇒ ∃ x P ( x ) → ∃ x Q ( x ) ∀ x ( P ( x ) ↔ Q ( x ) ) ⇒ ∀ x P ( x ) ↔ ∀ x Q ( x ) ∀ x ( P ( x ) ↔ Q ( x ) ) ⇒ ∃ x P ( x ) ↔ ∃ x Q ( x ) ∀ x ( P ( x ) → Q ( x ) ) ∧ P ( a ) ⇒ Q ( a ) ∀ x ( P ( x ) → Q ( x ) ) ∧ ∀ x ( Q ( x ) → R ( x ) ) ⇒ ∀ x ( P ( x ) → R ( x ) ) Universal Instantiation 全称量词消去 ∀ x P ( x ) ⇒ P ( a ) a is any individual in the domain of x Universal Generalization 全称量词引入 P ( a ) ⇒ ∀ x P ( x ) a takes any individual in the domain of x Existential Instantiation 存在量词消去 ∃ x P ( x ) ⇒ P ( a ) a is a specific individual in the domain of x Existential Generalization 存在量词引入 P ( a ) ⇒ ∃ x P ( x ) a is a specific individual in the domain of x \begin{array}{|c|c|}
\hline
\text{De Morgan's Laws 摩根律}
& \neg \forall xP(x) \equiv \exists x \neg P(x), \neg \exists xP(x) \equiv \forall x \neg P(x)\\
\hline
\text{Distributive Laws 分配律}
& \forall x(P(x)\land Q(x))\equiv \forall x P(x)\land \forall x Q(x) \\
& \exists x(P(x)\lor Q(x))\equiv \exists x P(x)\lor \exists x Q(x) \\
\hline
\text{Conclusion Premise 附加前提}
& P\Rightarrow A\rightarrow B \equiv P\land A \Rightarrow B \\
\hline
\forall x P(x)\lor \forall x Q(x) \Rightarrow \forall x(P(x)\lor Q(x))
& \exists x(P(x)\land Q(x))\Rightarrow \exists x P(x)\land \exists x Q(x) \\
\hline
\forall x (P(x) \rightarrow Q(x)) \Rightarrow \forall x P(x) \rightarrow \forall x Q(x)
& \forall x (P(x) \rightarrow Q(x)) \Rightarrow \exists x P(x) \rightarrow \exists x Q(x)\\
\hline
\forall x (P(x) \leftrightarrow Q(x)) \Rightarrow \forall x P(x) \leftrightarrow \forall x Q(x)
& \forall x (P(x) \leftrightarrow Q(x)) \Rightarrow \exists x P(x) \leftrightarrow \exists x Q(x)\\
\hline
\forall x (P(x) \rightarrow Q(x)) \land P(a) \Rightarrow Q(a)
& \forall x (P(x) \rightarrow Q(x)) \land \forall x (Q(x) \rightarrow R(x)) \\ & \Rightarrow \forall x (P(x) \rightarrow R(x))\\
\hline
\text{Universal Instantiation 全称量词消去} & \forall x P(x) \Rightarrow P(a) \\
& a \text{ is any individual in the domain of } x \\
\hline
\text{Universal Generalization 全称量词引入} & P(a) \Rightarrow \forall x P(x) \\
& a \text{ takes any individual in the domain of } x \\
\hline
\text{Existential Instantiation 存在量词消去} & \exists x P(x) \Rightarrow P(a) \\
& a \text{ is a specific individual in the domain of } x \\
\hline
\text{Existential Generalization 存在量词引入} & P(a) \Rightarrow \exists x P(x) \\
& a \text{ is a specific individual in the domain of } x \\
\hline
\end{array}
De Morgan’s Laws 摩根律 Distributive Laws 分配律 Conclusion Premise 附加前提 ∀ x P ( x ) ∨ ∀ x Q ( x ) ⇒ ∀ x ( P ( x ) ∨ Q ( x ) ) ∀ x ( P ( x ) → Q ( x ) ) ⇒ ∀ x P ( x ) → ∀ x Q ( x ) ∀ x ( P ( x ) ↔ Q ( x ) ) ⇒ ∀ x P ( x ) ↔ ∀ x Q ( x ) ∀ x ( P ( x ) → Q ( x ) ) ∧ P ( a ) ⇒ Q ( a ) Universal Instantiation 全称量词消去 Universal Generalization 全称量词引入 Existential Instantiation 存在量词消去 Existential Generalization 存在量词引入 ¬ ∀ x P ( x ) ≡ ∃ x ¬ P ( x ) , ¬ ∃ x P ( x ) ≡ ∀ x ¬ P ( x ) ∀ x ( P ( x ) ∧ Q ( x ) ) ≡ ∀ x P ( x ) ∧ ∀ x Q ( x ) ∃ x ( P ( x ) ∨ Q ( x ) ) ≡ ∃ x P ( x ) ∨ ∃ x Q ( x ) P ⇒ A → B ≡ P ∧ A ⇒ B ∃ x ( P ( x ) ∧ Q ( x ) ) ⇒ ∃ x P ( x ) ∧ ∃ x Q ( x ) ∀ x ( P ( x ) → Q ( x ) ) ⇒ ∃ x P ( x ) → ∃ x Q ( x ) ∀ x ( P ( x ) ↔ Q ( x ) ) ⇒ ∃ x P ( x ) ↔ ∃ x Q ( x ) ∀ x ( P ( x ) → Q ( x ) ) ∧ ∀ x ( Q ( x ) → R ( x ) ) ⇒ ∀ x ( P ( x ) → R ( x ) ) ∀ x P ( x ) ⇒ P ( a ) a is any individual in the domain of x P ( a ) ⇒ ∀ x P ( x ) a takes any individual in the domain of x ∃ x P ( x ) ⇒ P ( a ) a is a specific individual in the domain of x P ( a ) ⇒ ∃ x P ( x ) a is a specific individual in the domain of x
例题:∃ x ( C ( x ) ∧ ¬ B ( x ) ) ∧ ∀ x ( C ( x ) → P ( x ) ) ⇒ ∃ x ( P ( x ) ∧ ¬ B ( x ) ) \exists x (C(x) \land \neg B(x)) \land \forall x (C(x) \rightarrow P(x)) \Rightarrow \exists x (P(x) \land \neg B(x)) ∃ x ( C ( x ) ∧ ¬ B ( x ) ) ∧ ∀ x ( C ( x ) → P ( x ) ) ⇒ ∃ x ( P ( x ) ∧ ¬ B ( x ) )
( 1 ) ∃ x ( C ( x ) ∧ ¬ B ( x ) ) Premise ( 2 ) C ( a ) ∧ ¬ B ( a ) Existential instantiation from (1) ( 3 ) C ( a ) Simplification from (2) ( 4 ) ∀ x ( C ( x ) → P ( x ) ) Premise ( 5 ) C ( a ) → P ( a ) Universal instantiation from (4) ( 6 ) P ( a ) Modus ponens from (3) and (5) ( 7 ) ¬ B ( a ) Simplification from (2) ( 8 ) P ( a ) ∧ ¬ B ( a ) Conjunction from (6) and (7) ( 9 ) ∃ x ( P ( x ) ∧ ¬ B ( x ) ) Existential generalization from (8) \begin{array}{ll}
(1)\quad \exists x (C(x) \land \neg B(x)) & \text{Premise} \\
(2)\quad C(a) \land \neg B(a) & \text{Existential instantiation from (1)} \\
(3)\quad C(a) & \text{Simplification from (2)} \\
(4)\quad \forall x (C(x) \rightarrow P(x)) & \text{Premise} \\
(5)\quad C(a) \rightarrow P(a) & \text{Universal instantiation from (4)} \\
(6)\quad P(a) & \text{Modus ponens from (3) and (5)} \\
(7)\quad \neg B(a) & \text{Simplification from (2)} \\
(8)\quad P(a) \land \neg B(a) & \text{Conjunction from (6) and (7)} \\
(9)\quad \exists x (P(x) \land \neg B(x)) & \text{Existential generalization from (8)} \\
\end{array}
( 1 ) ∃ x ( C ( x ) ∧ ¬ B ( x ) ) ( 2 ) C ( a ) ∧ ¬ B ( a ) ( 3 ) C ( a ) ( 4 ) ∀ x ( C ( x ) → P ( x ) ) ( 5 ) C ( a ) → P ( a ) ( 6 ) P ( a ) ( 7 ) ¬ B ( a ) ( 8 ) P ( a ) ∧ ¬ B ( a ) ( 9 ) ∃ x ( P ( x ) ∧ ¬ B ( x ) ) Premise Existential instantiation from (1) Simplification from (2) Premise Universal instantiation from (4) Modus ponens from (3) and (5) Simplification from (2) Conjunction from (6) and (7) Existential generalization from (8)
Lec20
图 G = ( V , E ) G=(V,E) G = ( V , E ) 即 edges 和 vertices,∣ V ∣ |V| ∣ V ∣ 为 G G G 的 order 阶数
Type Edges Multiple Edges Allowed? Loops Allowed? Simple graph undirected No No Multigraph undirected Yes No Pseudograph undirected Yes Yes Simple directed graph directed No No Directed multigraph directed Yes Yes Mixed graph undirected + directed Yes Yes \begin{array}{|c|c|c|c|}
\hline
\text{Type} & \text{Edges} & \text{Multiple Edges Allowed?} & \text{Loops Allowed?} \\
\hline
\text{Simple graph} & \text{undirected} & \text{No} & \text{No} \\
\hline
\text{Multigraph} & \text{undirected} & \text{Yes} & \text{No} \\
\hline
\text{Pseudograph} & \text{undirected} & \text{Yes} & \text{Yes} \\
\hline
\text{Simple directed graph} & \text{directed} & \text{No} & \text{No} \\
\hline
\text{Directed multigraph} & \text{directed} & \text{Yes} & \text{Yes} \\
\hline
\text{Mixed graph} & \text{undirected + directed} & \text{Yes} & \text{Yes} \\
\hline
\end{array}
Type Simple graph Multigraph Pseudograph Simple directed graph Directed multigraph Mixed graph Edges undirected undirected undirected directed directed undirected + directed Multiple Edges Allowed? No Yes Yes No Yes Yes Loops Allowed? No No Yes No Yes Yes
Adjacency List 邻接表;Adjacency Matrix 邻接矩阵(开 n n n 方则为从节点 i i i 到节点 j j j 的长度为 n n n 的路径条数);Incidence Matrix 关联矩阵(行是点,列是边);isolated deg ( v ) = 0 \deg(v)=0 deg ( v ) = 0 ;pendant 悬挂的 deg ( v ) = 1 \deg(v)=1 deg ( v ) = 1
Handshaking Theorem:无向图,2 ∣ E ∣ = ∑ v ∈ V deg ( v ) 2|E|=\sum_{v\in V}\deg(v) 2 ∣ E ∣ = ∑ v ∈ V deg ( v ) ,并且 ∣ { v ∈ V : deg ( v ) 为奇数 } ∣ |\{v\in V:\deg(v)\text{为奇数}\}| ∣ { v ∈ V : deg ( v ) 为奇数 } ∣ 为偶数;有向图,∑ v ∈ V deg − ( v ) = ∑ v ∈ V deg + ( v ) = ∣ E ∣ \sum_{v\in V}\deg^-(v)=\sum_{v\in V}\deg^+(v)=|E| ∑ v ∈ V deg − ( v ) = ∑ v ∈ V deg + ( v ) = ∣ E ∣
proper subgraph 真子图;subgraph induced 导出子图(W ⊆ V , W = { 1 , 2 , 3 , 4 } , G ′ = G [ W ] W\subseteq V,W=\{1,2,3,4\},G'=G[W] W ⊆ V , W = { 1 , 2 , 3 , 4 } , G ′ = G [ W ] 或 F ⊆ E , F = { { 1 , 2 } , { 2 , 3 } } , G ′ ′ = G [ F ] F\subseteq E,F=\{\{1,2\},\{2,3\}\},G''=G[F] F ⊆ E , F = { { 1 , 2 } , { 2 , 3 } } , G ′ ′ = G [ F ] );Edge Contraction 即合并两个点;complement graph 补图,补成完全图(K n K_n K n );Isomorphism 同构,即连接方式一样(顶点编号无关)
Lec21
一个简单图是二分图 K n , n K_{n,n} K n , n 当且仅当存在一种可能的着色方案,使得任意两个相邻顶点不同色;Matching 匹配(仅二分图,是边的集合);
Hall’s Theorem:二分图 G = ( X ∪ Y , E ) G=(X\cup Y,E) G = ( X ∪ Y , E ) 有完全匹配当且仅当 ∀ A ⊆ X , ∣ N ( A ) ∣ ≥ ∣ A ∣ \forall A\subseteq X,|N(A)|\ge|A| ∀ A ⊆ X , ∣ N ( A ) ∣ ≥ ∣ A ∣ (N ( A ) N(A) N ( A ) 是邻接集,和 A A A 相连点的集合)
Path:简单 simple 路径不经过一个边超过两次;passes through 点,traverses 边
connected 连通的:即任意两个不同点之间都有 path
Connected Component 连通分支/分量:即极大连通子图(类似森林的不同树)
Lec22
Cut vertex割点,Cut edge(bridge) 割边,即去除后就有了更多的连通分量
Vertex Connectivity 点连通度 κ ( G ) \kappa(G) κ ( G ) :nonseparable 不可分的,即没有割点;对于一个连通简单图,vertex cut 点割集即去掉这些点后变成不连通;点连通度,即点割集点数量的最小值(非连通图为 0 0 0 ,完全图为 n − 1 n-1 n − 1 );一个图是 k k k -连通的当 κ ( G ) ≥ k \kappa(G)\ge k κ ( G ) ≥ k
Edge Connectivity 边连通度 λ ( G ) \lambda(G) λ ( G ) :非连通图 λ ( G ) = 0 \lambda(G)=0 λ ( G ) = 0 ,连通图 ∣ V ∣ = 1 |V|=1 ∣ V ∣ = 1 时 λ ( G ) = 0 \lambda(G)=0 λ ( G ) = 0 ,否则为边割集(edge cut)边数量的最小值
δ ( G ) = min v ∈ V deg ( v ) \delta(G)=\min_{v\in V}\deg(v) δ ( G ) = min v ∈ V deg ( v ) ,则 κ ( G ) ≤ λ ( G ) ≤ δ ( G ) \kappa(G)\le \lambda(G)\le \delta(G) κ ( G ) ≤ λ ( G ) ≤ δ ( G )
Strongly/Weakly Connected:有向图,分别为考虑方向/不考虑方向的连通
长度大于3的简单回路是同构不变量
Euler Path/Circuit 欧拉路径/回路:simple path/circuit 遍历每个边
欧拉回路:G G G 为连通的点数大于 2 的 multigraph,存在欧拉回路当且仅当对任意点 v v v 都有 2 ∣ deg ( v ) 2|\deg(v) 2 ∣ deg ( v )
Hierholzer 算法:先选择一个环,将图不断去掉这个环和孤立的点,再选取图中的一个与当前环有某个点重合的环,再把两个环拼接,循环,最后得到欧拉回路
欧拉路径:G G G 为连通的点数大于 2 的 multigraph,存在欧拉路径当且仅当 G G G 恰好有两个点有奇数的度;算法:连接这两个奇数度的点,用 Hierholzer,再去除该边
Lec23
欧拉是遍历边,哈密顿 Hamilton 是遍历点
哈密顿回路存在充分条件: Ore’s Theorem: 点数大于 3 的简单图,如果 ∀ { u , v } ∉ E , deg ( u ) + deg ( v ) ≥ n \forall\{u,v\}\notin E,\deg(u)+\deg(v)\ge n ∀ { u , v } ∈ / E , deg ( u ) + deg ( v ) ≥ n ;Dirac’s Theorem:点数大于 3 的简单图,如果对任意点都有 deg ( u ) ≥ n 2 \deg(u)\ge \frac{n}{2} deg ( u ) ≥ 2 n
Djikstra’s Algorithm:
Lec24
Planar Graph 平面图:可以被画在平面上且没有边相交
Jordan Curve Theorem:简单闭合平面曲线把平面分为内外区域,连接这两个区域的曲线一定和该曲线相交;图 K 3 , 3 K_{3,3} K 3 , 3 判断方法:先选择一个环,再依次画边,如果有哪条边跨区域了就非平面
Regions 面:平面图划分出来的多个区域,有 exterior 外部面,boundary,degree(一个面的边界上边的数量)
Euler’s Formula:对于连通简单平面图,面的数量 r = e − v + 2 r=e-v+2 r = e − v + 2 ;有 p p p 个连通分量:r = e − v + p + 1 r=e-v+p+1 r = e − v + p + 1
一个平面连通简单图,如果每个面的度都大于 l l l ,则 ∣ E ( G ) ∣ ≤ l l − 2 ( ∣ V ( G ) ∣ − 2 ) |E(G)|\le \frac{l}{l-2}(|V(G)|-2) ∣ E ( G ) ∣ ≤ l − 2 l ( ∣ V ( G ) ∣ − 2 )
Homeomorphic 同胚的:同一个图经过不同的 elementary subdivision 初等细分(拆分一条边为两条)后获得的图
Kuratowski’s Theorem:一个图是非平面的当且仅当其有一个子图和 K 3 , 3 K_{3,3} K 3 , 3 或 K 5 K_5 K 5 同胚
Dual Graph 对偶图:一个平面图,面变成点,点变成面后得到 G ∗ G^* G ∗ ;有 2 v − 2 2v-2 2 v − 2 条边,G ∗ ∗ = G , v ∗ = f , e ∗ = e , f ∗ = v G^{**}=G,v^*=f,e^*=e,f^*=v G ∗ ∗ = G , v ∗ = f , e ∗ = e , f ∗ = v (f f f 为面);self-dual 即某个图的对偶图和它本身同构
Lec25
chromatic number χ ( G ) \chi(G) χ ( G ) 色数:k k k -着色的最小 k k k 值;1 ≤ χ ( G ) ≤ ∣ V ∣ 1\le \chi(G)\le |V| 1 ≤ χ ( G ) ≤ ∣ V ∣ (平面图不超过4色)
χ ( G ) = 1 \chi(G) = 1 χ ( G ) = 1 iff E = ∅ E = \emptyset E = ∅ ;χ ( G ) = 2 \chi(G) = 2 χ ( G ) = 2 iff G G G is bipartite and ∣ E ∣ ≥ 1 |E| \ge 1 ∣ E ∣ ≥ 1
χ ( K n ) = n \chi(K_n) = n χ ( K n ) = n for every integer n ≥ 1 n \ge 1 n ≥ 1 ;χ ( G ) ≥ n \chi(G) \ge n χ ( G ) ≥ n if G G G has a subgraph isomorphic to K n K_n K n
χ ( C n ) = 2 \chi(C_n) = 2 χ ( C n ) = 2 if 2 ∣ n 2|n 2 ∣ n ; χ ( C n ) = 3 \chi(C_n) = 3 χ ( C n ) = 3 if 2 ∣ ( n − 1 ) 2|(n-1) 2 ∣ ( n − 1 ) ; (n ≥ 3 n \ge 3 n ≥ 3 )
χ ( G ) ≤ Δ ( G ) + 1 \chi(G) \le \Delta(G) + 1 χ ( G ) ≤ Δ ( G ) + 1 , where Δ ( G ) = max { deg ( v ) : v ∈ V } \Delta(G) = \max\{\deg(v): v \in V\} Δ ( G ) = max { deg ( v ) : v ∈ V }
树的定义:无向无环图里两个点之间有唯一路径;n n n 顶点的树有 n − 1 n-1 n − 1 边;Rooted Tree(有向树);full m m m -ary tree:叶子是满的,n = m i + 1 n=mi+1 n = m i + 1
Lec26
Preorder/Inorder/Postorder traversal; Prefix/Infix/Postfix notation
Spanning tree 生成树:一个简单图含有生成树当且仅当其连通
Prim’s Algorithm:选取一个点开始,选取与当前树连接的最小权边
Kruskal’s Algorithm:初始每个点自成一个 component,循环地选取最小权边并 merge 两个 components(除非成环)
Lec27
Language: 可被自动机 M 1 M_1 M 1 识别的字符串的集合记为 A = L ( M 1 ) A=L(M_1) A = L ( M 1 ) ,如果一个语言能被某个有限自动机识别,则语言 regular 正则
有限自动机 M M M 为五元组 ( Q , Σ , δ , q 0 , F ) (Q,\Sigma,\delta,q_0,F) ( Q , Σ , δ , q 0 , F ) :Q Q Q 为有限状态集合,Σ \Sigma Σ 为有限字母表集合,δ \delta δ 为转换方程 δ : Q × Σ → Q \delta:Q\times\Sigma\rightarrow Q δ : Q × Σ → Q 如 δ ( q , a ) = r \delta(q,a)=r δ ( q , a ) = r 意味着从 q q q 匹配字符 a a a 到状态 r r r ,q 0 q_0 q 0 为初始状态,F F F 为可接受的状态集合
Union ∪ \cup ∪ ,Concatenation A ∘ B = A B A\circ B=AB A ∘ B = A B ,Star A ∗ = { ϵ , a , b , a a , a b , b a , a a b , … } A^*=\{\epsilon,a,b,aa,ab,ba,aab,\dots\} A ∗ = { ϵ , a , b , a a , a b , b a , a a b , … }
Regular Expression:从字符集、空集和 ϵ \epsilon ϵ 通过上述三个符号构建成
正则语言的封闭性质:两个正则语言 A 1 ∪ A 2 A_1\cup A_2 A 1 ∪ A 2 :Q = Q 1 × Q 2 , q 0 = ( q 1 , q 2 ) , δ ( ( q , r ) , a ) = ( δ 1 ( q , a ) , δ 2 ( r , a ) ) Q=Q_1\times Q_2, q_0=(q_1,q_2),\delta((q,r),a)=(\delta_1(q,a),\delta_2(r,a)) Q = Q 1 × Q 2 , q 0 = ( q 1 , q 2 ) , δ ( ( q , r ) , a ) = ( δ 1 ( q , a ) , δ 2 ( r , a ) ) , F = ( F 1 × Q 2 ) ∪ ( Q 1 × F 2 ) F=(F_1\times Q_2)\cup(Q_1\times F_2) F = ( F 1 × Q 2 ) ∪ ( Q 1 × F 2 ) ;或者用 NFA 在最前面加入初始状态,用 ϵ \epsilon ϵ 连接两个自动机的初始状态
两个正则语言 A 1 ∘ A 2 A_1\circ A_2 A 1 ∘ A 2 :把第一个的可接受状态用 ϵ \epsilon ϵ 连到第二个的初始状态
Nondeterministic Finite Automata:允许接受 ϵ \epsilon ϵ ,不消耗字符,δ \delta δ 右侧变为状态集合
NFA M M M 转为 DFA M ′ M' M ′ :Q ′ = P ( Q ) , q 0 ′ = { q 0 } , F ′ = { R ∈ Q ′ ∣ R intersects F } Q'=\mathbf{P}(Q),q'_0=\{q_0\},F'=\{R\in Q'|R \text{ intersects } F\} Q ′ = P ( Q ) , q 0 ′ = { q 0 } , F ′ = { R ∈ Q ′ ∣ R intersects F }
A 1 ∪ A 2 , A 1 A 2 , A ∗ A_1\cup A_2,A_1A_2,A^* A 1 ∪ A 2 , A 1 A 2 , A ∗ 的自动机:
Lec28
Generalized NFA:状态之间转换从字符变成正则表达式;每个 GNFA 都有等价的正则表达式(对状态数 k k k 从 2 2 2 开始归纳法,每个 k k k states GNFA 都能转换成 k − 1 k-1 k − 1 的 GNFA)
Context Free Grammars:四元组 ( V , Σ , R , S ) (V,\Sigma,R,S) ( V , Σ , R , S ) ,V V V 是变量有限集合,Σ \Sigma Σ 是 terminal symbols 终止符集合,R R R 是规则集合(形式 V → ( V ∪ Σ ) ∗ V\rightarrow (V\cup\Sigma)^* V → ( V ∪ Σ ) ∗ ),S S S 是初始变量
u , v ∈ ( V ∪ Σ ) ∗ u,v\in (V\cup \Sigma)^* u , v ∈ ( V ∪ Σ ) ∗ ,如果 u u u 仅用一次 subtitution 走到 v v v 记为 u ⇒ v u\Rightarrow v u ⇒ v ;如果多次记为 u ⇒ ∗ v u \overset{*}{\Rightarrow}v u ⇒ ∗ v (derivation);Context Free Language 如果 A = L ( G ) A=L(G) A = L ( G )
例子:G 2 G_2 G 2 ,E → E + T ∣ T , T → T × F ∣ F , F → ( E ) ∣ a E\rightarrow E+T|T,T\rightarrow T\times F|F,F\rightarrow(E)|a E → E + T ∣ T , T → T × F ∣ F , F → ( E ) ∣ a ;G 3 G_3 G 3 ,E → E + E ∣ E × E ∣ ( E ) ∣ a E\rightarrow E+E|E\times E|(E)|a E → E + E ∣ E × E ∣ ( E ) ∣ a
虽然 L ( G 2 ) = L ( G 3 ) L(G_2)=L(G_3) L ( G 2 ) = L ( G 3 ) 但是 G 2 G_2 G 2 不模糊(表达了符号顺序),G 3 G_3 G 3 模糊
Pushdown Automata:外接一个栈,如识别 D = { 0 k 1 k ∣ k ≥ 0 } , B = { w w R ∣ w ∈ { 0 , 1 } ∗ } D=\{0^k1^k|k\ge0\},B=\{ww^R|w\in\{0,1\}^*\} D = { 0 k 1 k ∣ k ≥ 0 } , B = { w w R ∣ w ∈ { 0 , 1 } ∗ } (1. 读入并压栈,重复或去2;2. 读入并 pop,比较如果当前的不等于上一个,则拒绝;3. 栈为空进入接受状态),为六元组 ( Q , Σ , Γ , δ , q 0 , F ) (Q,\Sigma,\Gamma,\delta,q_0,F) ( Q , Σ , Γ , δ , q 0 , F ) ,Σ , Γ \Sigma,\Gamma Σ , Γ 分别为输入/栈的字母,δ : Q × Σ ϵ × Γ ϵ → P ( Q × Γ ϵ ) \delta:Q\times\Sigma_\epsilon\times\Gamma_\epsilon\rightarrow\mathcal{P}(Q\times\Gamma_\epsilon) δ : Q × Σ ϵ × Γ ϵ → P ( Q × Γ ϵ ) ,δ ( q , a , c ) = { ( r 1 , d ) , ( r 2 , e ) } \delta(q,a,c)=\{(r_1,d),(r_2,e)\} δ ( q , a , c ) = { ( r 1 , d ) , ( r 2 , e ) }
CFG 转为 PDA:Push the start symbol on the stack, If the top of stack is Variable: replace with right hand side of rule (nondet choice). Terminal: pop it and match with next input symbol. If the stack is empty, accept.