0 Up votes0 Down votes

12 views3 pagesCNF Tutorial

Feb 20, 2013

© Attribution Non-Commercial (BY-NC)

PDF, TXT or read online from Scribd

CNF Tutorial

Attribution Non-Commercial (BY-NC)

12 views

CNF Tutorial

Attribution Non-Commercial (BY-NC)

- The Woman Who Smashed Codes: A True Story of Love, Spies, and the Unlikely Heroine who Outwitted America's Enemies
- Steve Jobs
- NIV, Holy Bible, eBook
- NIV, Holy Bible, eBook, Red Letter Edition
- Hidden Figures Young Readers' Edition
- Cryptonomicon
- Console Wars: Sega, Nintendo, and the Battle that Defined a Generation
- Make Your Mind Up: My Guide to Finding Your Own Style, Life, and Motavation!
- The Golden Notebook: A Novel
- Alibaba: The House That Jack Ma Built
- Hit Refresh: The Quest to Rediscover Microsoft's Soul and Imagine a Better Future for Everyone
- Hit Refresh: The Quest to Rediscover Microsoft's Soul and Imagine a Better Future for Everyone
- Autonomous: A Novel
- The 10X Rule: The Only Difference Between Success and Failure
- Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are
- Life After Google: The Fall of Big Data and the Rise of the Blockchain Economy

You are on page 1of 3

A CNF grammar is a CFG with rules restricted as follows. The right hand side of a rule consists of: i. Either a single terminal, e.g. A a. ii. Or two variables, e.g. A BC, iii. Or the rule S , if is in the language.

iv. The start symbol S may appear only on the left hand side of rules. Given a CFG G, we show how to convert it to a CNF grammar G generating the same language. We use a grammar G with the following rules as a running example. S ASA | aB; A B | S; B b | We proceed in a series of steps which gradually enforce the above CNF criteria; each step leaves the generated language unchanged. Step 1 For each terminal a, we introduce a new variable, Ua say, add a rule Ua a, and for each occurrence of a in a string of length 2 or more on the right hand side of a rule, replace a by Ua . Clearly, the generated language is unchanged. Example: If we have the rule A Ba, this is replaced by Ua a, A BUa . This ensures that terminals on the right hand sides of rules obey criteria (i) above. This step changes our example grammar G to have the rules: S ASA | Ua B; A B | S; B b | ; Ua a

2 Step 2 For each rule with 3 or more variables on the righthand side, we replace it with a new collection of rules obeying criteria (ii) above. Suppose there is a rule U W1 W2 Wk , for some k 3. Then we create new variables X2 , X3 , , Xk1 , and replace the prior rule with the rules: U W1 X2 ; X2 W2 X3 ; ; Xk2 Wk2 Xk1 ; Xk1 Wk1 Wk . Clearly, the use of the new rules one after another, which is the only way they can be used, has the same eect as using the old rule U W1 W2 Wk . Thus the generated language is unchanged. This ensures, for criteria (ii) above, that no right hand side has more than 2 variables. We have yet to eliminate right hand sides of one variable or of the form . This step changes our example grammar G to have the rules: S AX | Ua B; X SA; A B | S; B b | ; Ua a Step 3 We replace each occurrence of the start symbol S with the variable S and add the rule S S . This ensures criteria (iv) above. This step changes our example grammar G to have the rules: S S ; S AX | Ua B; X S A; A B | S ; B b | ; Ua a Step 4 This step removes rules of the form A , as follows. First, we determine all variables that can generate in one or more moves. We explain how to do this two paragraphs down. Then for each such variable A, for each occurrence of A in a 2-variable right hand side, we create a new rule with the A omitted; i.e. if there is a rule C AB we create the new rule C B, and if there is a rule C DA we create the new rule C D (if there is a rule C AA, we create the new rule C A). Then we remove all rules of the form A , apart from S , if present (i.e. we keep rule S , if present). The new rules serve to shortcut a previously generatable instances of , i.e. if previously we had used a rule A BC, and then in a series of steps had generated from B, which has the net eect of generating C from A, we could instead do this directly by applying the new rule A C. Consequently, the generated language is unchanged. To nd the variables that can generate , we use an iterative rule reduction procedure. First, we make a copy of all the rules. We then modify the rules by removing from the right hand sides all instances of variables A for which there is a rule A . We keep iterating this procedure so long as it creates new reduced rules with on the right hand side. (An ecient implementation keeps track of the lengths of each right hand side, and a list of the locations of each variable; the new rules with on the right hand side are those which have newly obtained length 0. It is not hard to have this procedure run in time linear in the sum of the lengths of the rules.) This step changes our example grammar G to have the rules:

S S ; S AX | X | Ua B; X S A | S ; A B | S ; B b; Ua a Step 5 This step removes rules of the form A B, which we call unit rules. We form the directed graph dened by these rules, i.e. for each rule A B, we create a directed edge (A, B). For each strong component in this graph, we replace the variables it contains with a single one of these variables in all the rules in which these variables occur. So if U1 , U2 , , Uk form a strong component (and so any one of these variables can be replaced, in a sequence of applications of unit rules, by any other of these variables) then we replace every occurrence of Ui , 2 i k with U1 in every rule in which they occur. In the example grammar, the one non-trivial strong component contains the variables {S , X}. We replace S with X yielding the rules: S X; X AX | X | Ua B; X XA | X; A B | X; B b; Ua a We can remove the unnecessary rule X X also. Next, we traverse the resulting acyclic graph, in reverse topological order (i.e. starting at nodes with no outedges and working back from these nodes); for each traversed edge (E, F ), which corresponds to a rule E F , for each rule F CD, we add the rule E CD, and then remove the rule E F . Any derivation which had used the rules E F and F CD in turn can now use the rule E CD instead. So the same strings are derived with the new set of rules. (This can be implemented via a depth rst search on the acyclic graph.) This step changes our example grammar G to have the rules: S AX | Ua B | XA; X AX | Ua B | XA; A b | AX | Ua B | XA; B b; Ua a Steps 4 and 5 complete the observance of criteria (ii), and thereby creates a CNF grammar generating the same language as the original grammar.

- Chapter 1Uploaded bySue_Aziz
- DSPA Solution Manual Chap 5 - kk parhiUploaded byNESEGA
- MMW-Project-1.docxUploaded byAlyssa Ortega
- RECTAUploaded byjose_dino10005190
- 2011-2012-waterloo-local-contest-2-october-2011-en-converted.pdfUploaded byAnonymous dGVRcI3
- math 4Uploaded byKC PISONET-1
- Bipolar Neutrosophic Planar GraphsUploaded byMia Amalia
- ug.psUploaded bySara Silva
- June Final Exam Session Academic Year 2015 2016Uploaded byClaudiu Sipoș
- (Werra, 1985)Uploaded byGürkan Özbil
- matrixUploaded byapi-278852361
- CMSC 27100Uploaded byKaushik Vasudevan
- Game Design DevelopmentUploaded byReginald Dickson Dequilla
- L04Uploaded byRonak Chaudhary
- Bipolar Complex Neutrosophic Graphs of Type 1Uploaded byAnonymous 0U9j6BLllB
- 10.1.1.15.3523Uploaded bygeneralguy
- assAsUploaded byMukesh Bisht
- Project PresentationUploaded bysaitapasvy
- Matgraph - A Matlab Toolbox for Graph TheoryUploaded byTan Duy
- Konigburg ProblemUploaded byRonakPawar
- multi.pdfUploaded byHarman Singh
- Departmental Schedule2-1st Semester 2017-2018Uploaded byvisayasstateu
- advocacyUploaded byAmalia Mihaela
- The Ring programming language version 1.5.1 book - Part 102 of 180Uploaded byMahmoud Samir Fayed
- The Ring programming language version 1.5.2 book - Part 88 of 181Uploaded byMahmoud Samir Fayed
- The Ring programming language version 1.5.2 book - Part 103 of 181Uploaded byMahmoud Samir Fayed
- yes docUploaded byJudel Lozada
- Q4CS-FinalProject.pdfUploaded byJudel Lozada
- Graph LabelingUploaded byYuri Sagala
- 0801CS39Uploaded byamulya_manchester

- Termenilogies ( Ict)Uploaded byKatlyn Ilustrisimo
- Solairs-hbaUploaded byping2pratap
- WindowsTroubleUploaded byapi-19799369
- CICSRefUploaded byGunjan Narulkar
- Edu 649 Week 5 Journal KEITH C QUARLES GRADE A ASHFORD GOOGLE BINGUploaded bykeith_quarles
- The Works of George Berkeley 1Uploaded byDavid Richard Jones
- Dark Web Terrorism Research _ Research _ Artificial Intelligence Laboratory _ Eller College of Management _ the University of ArizonaUploaded byHutch Rev Oliver
- FIEUT003AR_04 Bad Debt Provision and Write OffUploaded byMajut Alenk
- Getting Started With a Pmo WpUploaded byfehema
- Excel 2007 Advanced Training ManualUploaded byHofmang
- Audit Checklist for POSUploaded byErin Smith
- 36037374 Slides SIMOTION Traversing Drive V4 0 0Uploaded byAbez Five
- Solutions to ANSI CUploaded byprayag527
- 2017 03 29 Tutorial ShipresistanceUploaded byKayhan
- Software Testing Fundamentals (1)Uploaded bybibin89raj
- Curtis,BarrereUploaded byUtkarsh Rathore
- Mobilink SWOT AnalysisUploaded byIdealeyes
- Approximation of Large-scale Dynamical SystemsUploaded byصلاح الماربي
- Freenove Arduino Processing PDFUploaded byAnoshanJayahanthan
- Downloads-Dev19_getting Started With Office Add-InsUploaded byFauzy M. Rachman
- Hog iPC ManualUploaded byAdrian Gardner
- C# in Depth Second EditionUploaded byDreamtech Press
- 33601016018_marksheet (1).pdfUploaded byAvijit Paul
- Corporate Deck With CWCE v 2 Speaker NotesUploaded by01202
- Chalenge-5Uploaded byBHASKAR SANKAR
- RegularizationUploaded bySai Sumanth P
- Devicenet Communication for Panelview TerminalsUploaded byMidhun Varghese
- 21474220 Hack the WorldUploaded byjuli_naz
- DBS3900 Upgrade Guide for SP88Uploaded byCésarAntonioPérezCoronel
- Resume__M MUploaded byMONCY MATHEWS

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.