- 1、本文档共19页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 12 Context-Free Languages and Pushdown Automata.ppt
James L. Hein - Discrete Structures, Logic, and Computability Chapter 12: Context-Free Languages and Pushdown Automata Section 12.4 Context-Free Language Topics Remove Λ-productions Algorithm. Remove Λ-productions from grammars for langauges without Λ. 1. Find nonterminals that derive Λ. 2. For each production A → w construct all productions A → w’ where w’ is obtained from w by removing one or more occurrences of the nonterminals from Step 1. 3. Combine the original productions with those of step 2 and eliminate any Λ-productions. Example Remove Λ-productions from the grammar S → ABc A → aA | Λ B → bB | Λ. Solution. Step 1: The nonterminals A and B derive Λ. Step 2: From the production S → ABc we construct S → Bc | Ac | c. From the production A → aA we construct A → a. From the production B → bB we construct B → b. Step 3: S → ABc | Bc | Ac | c A → aA | a B → bB | b. Quiz Remove Λ -productions from S → ABc | Ab | c A → ABa | Λ B → Bbc | Λ. Solution. S → ABc | Ab | c| Bc | Ac | b A → ABa | Ba | Aa | a B → Bbc | bc. Chomsky Normal Form Productions have one of the following forms A → b (b a terminal) A → BC S → Λ (if Λ is in the language). Advantages: Parse trees are binary, which are easy to represent. Any string of length n 0 can be derived in 2n – 1 steps. Transform context-free grammar to Chomsky normal form Algorithm. Transform context-free grammar to Chomsky normal form 1. Remove A → Λ (if A ≠ S) by previous algorithm. (If S → Λ is removed, add it back.) 2. Remove unit productions (i.e., A → B): If A → B or A + B, then construct productions A → w where B → w is not a unit production. Now remove all unit productions. 3. For each production whose right side has two or more symbols, replace all occurrences of each terminal a with a new nonterminal A and also add the new production A → a. 4. Replace each production B → C1…Cn with n 2 with B → C1D where D → C2 …Cn. Repeat this step until all right sides have length two. Example Construct a C
您可能关注的文档
- 24 给予是快乐的.ppt
- 2、平均速度.ppt
- 2、我国财政赤字与发达资本主义国家财政赤字的不同性质.ppt
- 3.1 电磁感应现象.ppt
- 3I与各科的整合.ppt
- 4.2 直接三角分解法.ppt
- 4.6 他励直流电动机的瞬态分析与控制.ppt
- 5 成本理论.ppt
- 5.1 基本迭代方法.ppt
- 5.2 “是否”问题及语言.ppt
- Chapter 12 File System Implementation.PPT
- Chapter 12 Fundamentals of Expert Systems.ppt
- Chapter 12 Human Impact on Resources and Ecosystems.ppt
- Chapter 12 Indexing and Hashing.ppt
- Chapter 12 Infrared Spectroscopy and Mass Spectrometry.ppt
- Chapter 12 Intangible Assets.ppt
- Chapter 12 Inventory Control.ppt
- CHAPTER 12 MANAGERIAL ACCOUNTING.ppt
- Chapter 12 Pest ControlIn this chapter the following topics wil.ppt
- Chapter 12 Signal generators and waveform-shaping circuits.ppt
文档评论(0)