5 context-free languages (1)

5 context-free languages (1)

ID:40254260

大小:1.14 MB

页数:34页

时间:2019-07-29

5 context-free languages (1)_第1页
5 context-free languages (1)_第2页
5 context-free languages (1)_第3页
5 context-free languages (1)_第4页
5 context-free languages (1)_第5页
资源描述:

《5 context-free languages (1)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、5Context-freeLanguages5.1IntroductionYouhavetriedtoconstructaregulargrammarforthelanguage{akbk:k∈N},butfailed.However,thestringsoftheformakbkcanbegeneratedbytwoproductionssuchasS→ε,S→aSb.Forexample,withsuchproductions,wecanhaveaderivationfora3b3asS⇒aSb

2、⇒aaSbb⇒aaaSbbb⇒aaabbb.TheproductionS→aSbviolatestheregularityconditionthatanonterminalontherighthandsideofaproductioncanappearasonlytherightmostsymbol.Toaccom-modatethesegeneraltypeofproductions,wewilldefinecontext-freegrammars.5.2Context-freeGrammarsAco

3、ntext-freegrammar(CFG)isaquadrupleG=(N,Σ,R,S),whereNisanalphabet,calledthesetofnonterminalsymbols,Σisanotheralphabet,calledthesetofterminalsymbols,N∩Σ=∅,S∈Nisthestartsymbol,andRisafinitesubsetofN×(N∪Σ)∗.ThefiniterelationRfromNto(N∪Σ)∗isthesetofproductions,

4、whereeachelement(A,u)isrewrittenintheformA→uasearlier.Anapplicationofaproductionruleisformalizedbytherelationofderivationinonestep,de-11notedby⇒.WewritexAy⇒xuy(readasxAygivesinonestepxuy)iffx,y∈(N∪Σ)∗,A∈N,u∈(N∪Σ∗),andA→uisaproductioninR.We∗1denoteby⇒,t

5、hetransitiveandreflexiveclosureoftheone-stepyield⇒.1∗Wesimplywrite⇒forboth⇒and⇒ifnoconfusionarises.Thatis,weoverusethissymbolforderivation:u⇒v(readasugivesv)iffthereisasequenceofA.Singh,ElementsofComputationTheory,TextsinComputerScience,125cSpringer-Verl

6、agLondonLimited20091265Context-freeLanguages11111derivationsu⇒u1⇒u2⇒···⇒un⇒vorwhenu=v.Suchasequenceisalsocalledaderivation.Thelengthofthisderivationiseithern+1or0,accordingly.Ifmanycontext-freegrammarsareinvolvedinaparticularcontext,thenwewillwrite⇒tosay

7、thatthederivationisdoneinthegrammarG.Astringw∈Σ∗isGgeneratedbythegrammarGiffS⇒winG.ThelanguagegeneratedbyGisL(G)={w∈Σ∗:S⇒winG}.Alanguageiscalledacontext-freelanguage(CFL)ifitisgeneratedbyacontext-freegrammar.Theword“context-free”comesfromthemodeofapplica

8、tionofaproduction.TheproductionA→uisappliedonthestringxAy,wherethecontextx(ontheleft)alongwithy(ontheright)remainsunchanged.Thatis,itcanbeappliedwithoutbotheringwhatxandyare.Whenthismodeofapplicationisviolated,agrammarisc

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。