- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
计算理论基础课件III
The Theory of Computation Part III CONTENTS Introduction Sets, Relations, and Functions Finite Automata Context-free Languages Turing Machines 5. Undecidablity Authors of Elements of the theory of computation Harry R. Lewis Christos H. Papadimitriou Typos of Elements of the theory of computation PART III Context-free Languages Part III. Context-Free Languages 3.1 Context-free grammars 3.2 Parse trees 3.3 Pushdown automata 3.4 Pushdown automata and context-free grammars 3.5 Languages that are and are not context-free 3.6 Algorithms for Context-Free Grammar 3.7 Determinism and parsing 3.8 Chomsky normal form 3.1 Context-Free Grammars Language recognizer and generator Language recognizer: finite automata Language generator: regular expression A new language generator context-free grammar 3.1 Context-Free Grammars Production (Rules) ? S ? aMb ? M ? A ? M ? B ? A ? aA ? A ? e ? B ? bB ? B ? e Generation: ? S ? aMb ? aAb ? aaAb ? aaaAb ? aaab (aaaeb) 3.1 Context-Free Grammars Start symbols S, A, B, M, … These symbols appear to the left of “?” . Terminals a, b, e, … Context-Free A start symbol can be replaced by a string no matter what the surrounding strings are. 3.1 Context-Free Grammars Definition 3.1.1 A context-free grammar G is a quadruple (V, ?, R, S), where: V is an alphabet; ? (the set of terminals) is a subset of V ; R (the set of rules) is a finite subset of (V??)?V* ; S (the start symbols) is an element of V??. 3.1 Context-Free Grammars Relation ?G and its closure ?*G If u,v?V*, x,y?V*, A?V??, A?w ? R, the v=xwy is generated by u=xAy , rewritten: u?Gv or u?v. If there is a sequence: u1, u2, … uk, which makes a derivation: u?G u1?G u2?G… ?G uk ?Gv, k?0 rewritten : u?*G v or u?*v. Context-free Language L If G is a context-free grammar, G generates each string in L(G) , so L=L(G)={w??* : S ?* w} 3.1 Context-Free Grammars Example 3.1.1 A CFG: G=(V, ?, R, S), where V={S,a,b}, ? ={a,b}, R={S?aSb , S?e }, so a possibl
文档评论(0)