1、*010a 011r 111r 010a111r*100a 100a*101a 000a 101a*110a 001a 110aExercise 2.2.2The statement to be proved is -hat(q,xy) = -hat(-hat(q,x),y), and we proceed by induction on the length of y. 证明:通过对|y|进行归纳,来证明(q , xy)=(q , x) , y) ,具体过程如下:Basis: If y = , then the statement is -hat(q,x) = -hat(-hat(q,x),
2、). This statement follows from the basis in the definition of -hat. Note that in applying this definition, we must treat -hat(q,x) as if it were just a state, say p. Then, the statement to be proved is p = -hat(p,), which is easy to recognize as the basis in the definition of -hat. 基础:=0,则y=。那么需证(q,
3、x)=(q ,x),),记p=(q,x),命题变为 p=(p ,), 由的定义知这显然成立。Induction: Assume the statement for strings shorter than y, and break y = za, where a is the last symbol of y. The steps converting -hat(-hat(q,x),y) to -hat(q,xy) are summarized in the following table:归纳: 假设命题对于比 y短的串成立, 且y = za, 其中 a 是y的结尾符号。(q,x),y) 到
4、(q,xy) 的变换总结在下表中:Expression 表达式Reason 原因(q,x),y) Start 开始(q,x),za) y=za by assumption 由假设y=za(q,x),z),a) Definition of -hat, treating -hat(q,x) as a state 的定义, 把(q,x) 看作是一个状态(q,xz),a) Inductive hypothesis 归纳假设(q,xza) Definition of -hat 的定义(q,xy) y=zaExercise 2.2.4(a)The intuitive meanings of states
5、A, B, and C are that the string seen so far ends in 0, 1, or at least 2 zeros. 状态 A, B,C分别表示以,和00结尾的串的状态。0 1B AC *C Exercise 2.2.6(a)The trick is to realize that reading another bit either multiplies the number seen so far by 2 (if it is a 0), or multiplies by 2 and then adds 1 (if it is a 1). We do
6、nt need to remember the entire number seen - just its remainder when divided by 5. That is, if we have any number of the form 5a+b, where b is the remainder, between 0 and 4, then 2(5a+b) = 10a+2b. Since 10a is surely divisible by 5, the remainder of 10a+2b is the same as the remainder of 2b when di
7、vided by 5. Since b, is 0, 1, 2, 3, or 4, we can tabulate the answers easily. The same idea holds if we want to consider what happens to 5a+b if we multiply by 2 and add 1. 对于一个二进制整数,如果读入一个比特,其值等于原数乘以;否则等于原数乘以再加以1。而任意一个数均可写成形如5a+b,其中a任意,0= b k-1) = qf. Using Exercise 2.2.2, -hat(q0,xk) = -hat(-hat(q
8、0,xk-1),x) = -hat(qf,x) by the inductive hypothesis = qf by (a). b) x是属于L(A)的非空串,也即串x被接收,因此(q0,x) = qf ,则由 a)知(qf,x) =(q0,x)= qf 。现在通过对k 的归纳来证明(q0,xk) = qf 。 k=1 时,需证(q0,x) = qf ,由已知可得。归纳:假设对于k-1命题成立,也就是说,(q0,xk-1) = qf 。由练习 2.2.2, (q0,xk) =(q0,xk-1),x) = (qf,x) 由归纳假设 = qf 由(a)。Exercise 2.2.10The au
9、tomaton tells whether the number of 1s seen is even (state A) or odd (state B), accepting in the latter case. It is an easy induction on |w| to show that dh(A,w) = A if and only if w has an even number of 1s. |w| = 0. Then w, the empty string surely has an even number of 1s, namely zero 1s, and (A,w
10、) = A. Assume the statement for strings shorter than w. Then w = za, where a is either 0 or 1. Case 1: a = 0. If w has an even number of 1s, so does z. By the inductive hypothesis, (A,z) = A. The transitions of the DFA tell us (A,w) = A. If w has an odd number of 1s, then so does z. By the inductive
11、 hypothesis, -hat(A,z) = B, and the transitions of the DFA tell us -hat(A,w) = B. Thus, in this case, -hat(A,w) = A if and only if w has an even number of 1Case 2: a = 1. If w has an even number of 1s, then z has an odd number of 1s. By the inductive hypothesis, -hat(A,z) = B. The transitions of the
12、 DFA tell us -hat(A,w) = A. If w has an odd number of 1s, then z has an even number of 1s. By the inductive hypothesis, -hat(A,z) = A, and the transitions of the DFA tell us -hat(A,w) = B. Thus, in this case as well, -hat(A,w) = A if and only if w has an even number of 1这个自动机表示,状态A表示偶数个1,状态B表示奇数个1,不
13、管串有偶数个还是奇数个1,都会被接受。当且仅当串w中有偶数个1时, (A,w) = A.。用归纳法证明如下 |w| = 0。空串当然有偶数个 1 ,即0个 1,且 (A,w) = A. 假设对于比w 短的串命题成立。令 w = za, 其中 a 为 0 或1。情形1: a = 0. 如果w有偶数个 1, 则z有偶数个1。由归纳假设, (A,z) = A。由转移表的DFA知(A,w) = A.如果w有奇数个1, 则z有奇数个1. 由归纳假设, (A,z) = B, 由转移表的 DFA 知 (A,w) = B. 因此这种情况下(A,w) = A 当且仅当 w 有偶数个 1。情形2: a = 1.
14、如果w有偶数个 1, 则z有奇数个1。 (A,z) = B. 由转移表的DFA知 (A,w) = A. 如果w有奇数个 1, 则z有偶数个1。由归纳假设, (A,z) = A, 由转移表的DFA知(A,w) = A 当且仅当 w 有偶数个 1. 综合上述情形,命题得证。Exercise 2.3.1Here are the sets of NFA states represented by each of the DFA states A through H: A = p; B = p,q; C = p,r; D = p,q,r; E = p,q,s; F = p,q,r,s; G = p,r,
15、s; H = p,s. 下表就是利用子集构造法将NFA转化成的DFA。其中构造的子集有:A = p;D CE F *E G*F *G H*H Exercise 2.3.4(a)The idea is to use a state qi, for i = 0,1,.,9 to represent the idea that we have seen an input i and guessed that this is the repeated digit at the end. We also have state qs, the initial state, and qf, the fina
16、l state. We stay in state qs all the time; it represents no guess having been made. The transition table:记状态qi为已经看到i并猜测i就是结尾将要重复的数字,i = 0,1,.,9 。初始状态为qs,终止状态为qf。我们可以一直停留在状态qs,表示尚未猜测。转移表如下:1 . 9qs qs,q0 qs,q1 qs,q9qf q0 q0q1 q1.q9 q9 qf*qf Exercise 2.4.1(a)Well use q0 as the start state. q1, q2, and
17、q3 will recognize abc; q4, q5, and q6 will recognize abd, and q7 through q10 will recognize aacd. The transition table is:记q0为初始状态。q1, q2和q3识别 abc; q4, q5和q6 识别abd, q7 到q10 识别aacd. 转移表如下:a b c q0,q1,q4,q7 q2 q3 *q3 q5 q5 q6*q6 q7 q8 q8 q10*q10 Exercise 2.4.2(a)The subset construction gives us the fo
18、llowing states, each representing the subset of the NFA states indicated: A = q0; B = q0,q1,q4,q7; C = q0,q1,q4,q7,q8; D = q0,q2,q5; E = q0,q9; F = q0,q3; G = q0,q6; H = q0,q10. Note that F, G and H can be combined into one accepting state, or we can use these three state to signal the recognition of abc, abd, and aacd, respectively. 由子集构造法可得以下DFA的状态,其中每一个状态都是NFA状态的子集: H = q0,q10.注意到 F, G 和H 可以整合到一个接受状态中,或者我们可以用这三个状态来分别标记已识别abc, abd 和aacd。