自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx

上传人:b****5 文档编号:16277291 上传时间:2022-11-22 格式:DOCX 页数:64 大小:93.63KB
下载 相关 举报
自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx_第1页
第1页 / 共64页
自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx_第2页
第2页 / 共64页
自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx_第3页
第3页 / 共64页
自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx_第4页
第4页 / 共64页
自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx_第5页
第5页 / 共64页
点击查看更多>>
下载资源
资源描述

自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx

《自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx(64页珍藏版)》请在冰豆网上搜索。

自动机理论语言和计算导论课后习题答案中文版Word文档下载推荐.docx

*010a

011r

111r

010a

111r

*100a

100a

*101a

000a

101a

*110a

001a

110a

Exercise2.2.2

Thestatementtobeprovedisδ-hat(q,xy)=δ-hat(δ-hat(q,x),y),andweproceedbyinductiononthelengthofy.

证明:

通过对|y|进行归纳,来证明

(q,xy)=

(q,x),y),具体过程如下:

Basis:

Ify=ε,thenthestatementisδ-hat(q,x)=δ-hat(δ-hat(q,x),ε).Thisstatementfollowsfromthebasisinthedefinitionofδ-hat.Notethatinapplyingthisdefinition,wemusttreatδ-hat(q,x)asifitwerejustastate,sayp.Then,thestatementtobeprovedisp=δ-hat(p,ε),whichiseasytorecognizeasthebasisinthedefinitionofδ-hat.

基础:

=0,则y=ε。

那么需证

(q,x)=

(q,x),ε),记p=

(q,x),命题变为p=

(p,ε),由

的定义知这显然成立。

Induction:

Assumethestatementforstringsshorterthany,andbreaky=za,whereaisthelastsymbolofy.Thestepsconvertingδ-hat(δ-hat(q,x),y)toδ-hat(q,xy)aresummarizedinthefollowingtable:

归纳:

假设命题对于比y 短的串成立,且y=za,其中a是y的结尾符号。

(q,x),y)到

(q,xy)的变换总结在下表中:

Expression表达式

Reason原因

(q,x),y)

Start开始

(q,x),za)

y=zabyassumption由假设y=za

δ(

(q,x),z),a)

Definitionofδ-hat,treatingδ-hat(q,x)asastate

的定义,把

(q,x)看作是一个状态

(q,xz),a)

Inductivehypothesis归纳假设

(q,xza)

Definitionofδ-hat

的定义

(q,xy)

y=za

Exercise2.2.4(a)

TheintuitivemeaningsofstatesA,B,andCarethatthestringseensofarendsin0,1,oratleast2zeros.

状态A,B,C分别表示以1,0和00结尾的串的状态。

0

1

B

A

C

*C

Exercise2.2.6(a)

Thetrickistorealizethatreadinganotherbiteithermultipliesthenumberseensofarby2(ifitisa0),ormultipliesby2andthenadds1(ifitisa1).Wedon'

tneedtoremembertheentirenumberseen---justitsremainderwhendividedby5.Thatis,ifwehaveanynumberoftheform5a+b,wherebistheremainder,between0and4,then2(5a+b)=10a+2b.Since10aissurelydivisibleby5,theremainderof10a+2bisthesameastheremainderof2bwhendividedby5.Sinceb,is0,1,2,3,or4,wecantabulatetheanswerseasily.Thesameideaholdsifwewanttoconsiderwhathappensto5a+bifwemultiplyby2andadd1.

对于一个二进制整数,如果读入一个比特0,其值等于原数乘以2;

否则等于原数乘以2再加以1。

而任意一个数均可写成形如5a+b,其中a任意,0<

=b<

=4,那么输入0,原数变为2(5a+b)=10a+2b,由于10a是5的倍数,,因此10a+2b除以5的余数与2b相同。

输入1,则得2(5a+b)+1类似。

因此对于所有的数只要记住它被5除的余数就可以。

由于b是0,1,2,3或者4,我们可以容易得到该DPA的转移表,具体如下:

Thetablebelowshowsthisautomaton.Stateqimeansthattheinputseensofarhasremainderiwhendividedby5.

其中状态qi代表输入串被5除的余数i的状态。

*q0

q0

q1

q1

q2

q3

q4

q0

q3

q2

q4

Thereisasmallmatter,however,thatthisautomatonacceptsstringswithleading0'

s.Sincetheproblemcallsforacceptingonlythosestringsthatbeginwith1,weneedanadditionalstates,thestartstate,andanadditional``deadstate'

'

d.If,instates,weseea1first,weactlikeq0;

.,wegotostateq1.However,ifthefirstinputis0,weshouldneveraccept,sowegotostated,whichweneverleave.Thecompleteautomatonis:

但是上述自动机仍接受以0开头的字符串。

因为题目要求只接受以1开头的串,可增加一个初始状态s和“死亡状态”d。

在状态初始状态s,若看到1,则转到状态q1;

若看到0,则直接转到状态d,识别终止。

所求自动机如下:

s

d

d

Exercise2.2.9

Part(a)isaneasyinductiononthelengthofw,startingatlength1.

|w|=1.Thenδ-hat(q0,w)=δ-hat(qf,w),becausewisasinglesymbol,andδ-hatagreeswithδonsinglesymbols.

Letw=za,sotheinductivehypothesisappliestoz.Thenδ-hat(q0,w)=δ-hat(q0,za)=δ(δ-hat(q0,z),a)=δ(δ-hat(qf,z),a)[bytheinductivehypothesis]=δ-hat(qf,za)=δ-hat(qf,w).

a)通过对w长度的归纳证明。

若|w|=1,则w是一个符号,此时需证

(q0,w)=

(qf,w),而对于单个符号扩展转移函数

与转移函数δ的作用是一样的,得证。

令w=za,假设对于z命题

(q0,z)=

(qf,z)成立。

那么

(q0,za)=δ(

(q0,z),a)=δ(

(qf,z),a)[由归纳假设]=

(qf,za)=

(qf,w).

Forpart(b),weknowthatδ-hat(q0,x)=qf.Sincexε,weknowbypart(a)thatδ-hat(qf,x)=qf.Itisthenasimpleinductiononktoshowthatδ-hat(q0,xk)=qf.

Fork=1thestatementisgiven.

Assumethestatementfork-1;

.,δ-hat(q0,xSUP>

k-1)=qf.UsingExercise2.2.2,δ-hat(q0,xk)=δ-hat(δ-hat(q0,xk-1),x)=δ-hat(qf,x)[bytheinductivehypothesis]=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)]。

Exercise2.2.10

Theautomatontellswhetherthenumberof1'

sseeniseven(stateA)orodd(stateB),acceptinginthelattercase.Itisaneasyinductionon|w|toshowthatdh(A,w)=Aifandonlyifwhasanevennumberof1'

s.

|w|=0.Thenw,theemptystringsurelyhasanevennumberof1'

s,namelyzero1'

s,and

(A,w)=A.

Assumethestatementforstringsshorterthanw.Thenw=za,whereaiseither0or1.

Case1:

a=0.Ifwhasanevennumberof1'

s,sodoesz.Bytheinductivehypothesis,

(A,z)=A.ThetransitionsoftheDFAtellus

(A,w)=A.Ifwhasanoddnumberof1'

s,thensodoesz.Bytheinductivehypothesis,δ-hat(A,z)=B,andthetransitionsoftheDFAtellusδ-hat(A,w)=B.Thus,inthiscase,δ-hat(A,w)=Aifandonlyifwhasanevennumberof1'

Case2:

a=1.Ifwhasanevennumberof1'

s,thenzhasanoddnumberof1'

s.Bytheinductivehypothesis,δ-hat(A,z)=B.ThetransitionsoftheDFAtellusδ-hat(A,w)=A.Ifwhasanoddnumberof1'

s,thenzhasanevennumberof1'

s.Bytheinductivehypothesis,δ-hat(A,z)=A,andthetransitionsoftheDFAtellusδ-hat(A,w)=B.Thus,inthiscaseaswell,δ-hat(A,w)=Aifandonlyifwhasanevennumberof1'

这个自动机表示,状态A表示偶数个1,状态B表示奇数个1,不管串有偶数个还是奇数个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.如果w有偶数个1,则z有奇数个1。

(A,z)=B.由转移表的DFA知

(A,w)=A.如果w有奇数个1,则z有偶数个1。

由归纳假设,

(A,z)=A,由转移表的DFA知

(A,w)=A当且仅当w有偶数个1.

综合上述情形,命题得证。

Exercise2.3.1

HerearethesetsofNFAstatesrepresentedbyeachoftheDFAstatesAthroughH:

A={p};

B={p,q};

C={p,r};

D={p,q,r};

E={p,q,s};

F={p,q,r,s};

G={p,r,s};

H={p,s}.

下表就是利用子集构造法将NFA转化成的DFA。

其中构造的子集有:

A={p};

D

C

E

F

*E

G

*F

*G

H

*H

Exercise2.3.4(a)

Theideaistouseastateqi,fori=0,1,...,9torepresenttheideathatwehaveseenaninputiandguessedthatthisistherepeateddigitattheend.Wealsohavestateqs,theinitialstate,andqf,thefinalstate.Westayinstateqsallthetime;

itrepresentsnoguesshavingbeenmade.Thetransitiontable:

记状态qi为已经看到i并猜测i就是结尾将要重复的数字,i=0,1,...,9。

初始状态为qs,终止状态为qf。

我们可以一直停留在状态qs,表示尚未猜测。

转移表如下:

1

...

9

qs

{qs,q0}

{qs,q1}

{qs,q9}

{qf}

{q0}

{q0}

{q1}

{q1}

...

q9

{q9}

{qf}

*qf

{}

{}

Exercise2.4.1(a)

We'

lluseq0asthestartstate.q1,q2,andq3willrecognizeabc;

q4,q5,andq6willrecognizeabd,andq7throughq10willrecognizeaacd.Thetransitiontableis:

记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

Exercise2.4.2(a)

Thesubsetconstructiongivesusthefollowingstates,eachrepresentingthesubsetoftheNFAstatesindicated:

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}.NotethatF,GandHcanbecombinedintooneacceptingstate,orwecanusethesethreestatetosignaltherecognitionofabc,abd,andaacd,respectively.

由子集构造法可得以下DFA的状态,其中每一个状态都是NFA状态的子集:

H={q0,q10}.注意到F,G和H可以整合到一个接受状态中,或者我们可以用这三个状态来分别标记已识别abc,abd和aacd。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 学科竞赛

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1