计算理论答案ch2
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Undergraduate Course ELEMENTS OF COMPUTATION THEORY College of Computer Science Chapter2ZHEJIANG UNIVERSITY
Fall-Winter,2006
P60
2.1.1Let M be a deterministicfinite automaton.Under exactly what cir-cumstances is e∈L(M)?Prove your answer.
Solution:
e∈L(M)if and only if s∈F.
Suppose e∈L(M).Then,by definition of L(M),(s,e) ∗
M
(q,e),where q∈F.
Because it is not the case that(s,e) M(q,w)for any configuration(q,w)(w=e).
(s,e) ∗
M
(q,e)must be in the reflexive transitive closure of M by virtue of reflexivity −that is,(s,e)=(q,e).
Therefore,s=q and thus s∈F.
Suppose s∈F.Because ∗
M is reflexive,(s,e) ∗
M
(s,e).Because s∈F,we have
e∈L(M)by definition of L(M).
2.1.2Describe informally the languages accepted by the following DF A.
Solution:
(c)All strings with the same number of a s and b s and in which no prefix has more than
two b s than a s,or a s than b s.
(d)All strings with the same number of a s and b s and in which no prefix has more than
one more a than b,or vice-versa.
2.1.3Construct DF A accepting each of the following languages.
(c){w∈{a,b}∗:w has neither aa nor bb as a substring}.
(e){w∈{a,b}∗:w has both ab and ba as a substring}.
Solution:(c)M=(K,Σ,δ,sF),where
K={q0,q1,q2,q3},Σ={a,b},s=q0,F={q0,q1,q2}
q aδ(q,a)
q0a q1
q0b q2
q1a q3
q1b q2
q2a q1
q2b q3
q3a q3
q3b q3
(e)M=(K,Σ,δ,sF),where
K={q0,q1,q2,q3,q4,q5},Σ={a,b},s=q0,F={q5}
q aδ(q,a)
q0a q1
q0b q2
q1a q1
q1b q3
q2a q4
q2b q2
q3a q5
q3b q3
q4a q4
q4b q5
q5a q5
q5b q5
P74
2.2.2Which regular expression for the languages accepted by the NF A of Problem2.2.1.
Solution:
a)a∗
b)a(ba∪baa)∗(b∪ba)
2.2.6(a)Find a simple NF A accepting(ab∪aab∪aba)∗.
(b)Convert the NF A of part(a)to a DF A by the method in section2.2.
Solution:
(a)M=(K,Σ,∆,sF),where K={q0,q1,q2,q3},Σ={a,b},s=q0,F={q0}
(qσq i)
(q0a q1)
(q1a q2)
(q1b q0)
(q1b q3)
(q2a q0)
(q3b q0)
(b)Determinizing the above machine results in the following DFA:
K={{q0},{q1},{q3},{q0,q1},{q0,q2},{q1,q3},∅},Σ={a,b},s={q0},
F={{q0},{q0,q1},{q0,q2}}
{q}σ{δ(q,σ)}
{q0}a{q1}
{q0}b∅
{q1}a{q3}
{q1}b{q0,q2}
{q0,q2}a{q0,q1}
{q0,q2}b∅
{q0,q1}a{q1,q3}
{q0,q1}b{q0,q2}
{q3}a∅
{q3}b{q0}
{q1,q3}a{q3}
{q1,q3}b{q0,q2}
∅a∅
∅b∅
2.2.10Describe exactly what happens when the construction of this section