资源描述:
《《形式语言与自动机》(王柏、杨娟编著)北邮出版社_课后习题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、北京邮电大学——形式语言与自动机课后作业答案第二章4.找出右线性文法,能构成长度为1至5个字符且以字母为首的字符串。答:G={N,T,P,S}其中N={S,A,B,C,D}T={x,y}其中x∈{所有字母}y∈{所有的字符}P如下:S→xS→xAA→yA→yBB→yB→yCC→yC→yDD→y6.构造上下文无关文法能够产生L={ω/ω∈{a,b}*且ω中a的个数是b的两倍}答:G={N,T,P,S}其中N={S}T={a,b}P如下:S→aabS→abaS→baaS→aabSS→aaSbS→aSabS→SaabS→abaSS→ab
2、SaS→aSbaS→SabaS→baaSS→baSaS→bSaaS→Sbaa7.找出由下列各组生成式产生的语言(起始符为S)(1)S→SaSS→b(2)S→aSbS→c(3)S→aS→aEE→aS答:(1)b(ab)n/n≥0}或者L={(ba)nb/n≥0}(2)L={ancbn/n≥0}(3)L={a2n+1/n≥0}第三章1.下列集合是否为正则集,若是正则集写出其正则式。(1)含有偶数个a和奇数个b的{a,b}*上的字符串集合(2)含有相同个数a和b的字符串集合(3)不含子串aba的{a,b}*上的字符串集合答:(1)是正则
3、集,自动机如下奇a偶b偶a偶baabbbb奇a奇b偶a奇baa(2)不是正则集,用泵浦引理可以证明,具体见17题(2)。Inrecentyears,thecitywithacity"eightenvironmentalconstruction,andactivelypromotetheenvironmentalremediation,urbanmanagementhasgreatprogress,significantlyimprovedtheappearanceofthecity,significantlyimprovingth
4、equalityofcitizens.However,urbanenvironmentandthecurrentsituationofeconomicandsocialdevelopmentdoesnotadaptto,andthegeneralpublictogoodlivingenvironmentisstilllaggingbehindexpectations,withthecityasanationalhealthcity,touristcity,environmentalprotectionmodelcity,garde
5、ncitytitledoesnotmatch,therearestillmanyseriousproblemremediationandFoot,concentratedexpressionfortheoldurbancommunity,Beijiexiaoxiang,villagesandotherweakareacitydirty,trafficcongestion,shopmanagement,Jeeves,open-airbarbecue,LuandaluanjianLuantingluanfang,scribbling,
6、andsoon.Theexistenceoftheseproblems,seriousdamagetotheurbanimage,affectingtheprojectattract,reducethepublictrust,restrictsthedevelopmentoftheplace.Therefore,tocarryoutthecomprehensiveimprovementoftheoutstandingproblemsitisurgentandimperativemustactimmediately,effortst
7、opromote.(3)是正则集先看L’为包含子串aba的{a,b}*上的字符串集合显然这是正则集,可以写出表达式和画出自动机。(略)则不包含子串aba的{a,b}*上的字符串集合L是L’的非。根据正则集的性质,L也是正则集。4.对下列文法的生成式,找出其正则式(1)G=({S,A,B,C,D},{a,b,c,d},P,S),生成式P如下:S→aAS→BA→abSA→bBB→bB→cCC→DD→bBD→d(2)G=({S,A,B,C,D},{a,b,c,d},P,S),生成式P如下:S→aAS→BA→cCA→bBB→bBB→aC→
8、DC→abBD→d答:(1)由生成式得:S=aA+B①A=abS+bB②B=b+cC③C=D④D=d+bB⑤③④⑤式化简消去CD,得到B=b+c(d+bB)即B=cbB+cd+b=>B=(cb)*(cd+b)⑥将②⑥代入①S=aabS+ab(cb)