CSC312 Automata Theory Grammatical Format Chapter # 13 by Cohen

Slides:



Advertisements
Similar presentations
Closure Properties of CFL's
Advertisements

About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
Context Free Grammars.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory VII.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Western Michigan University CS6800 Advanced Theory of Computation Spring 2014 By Abduljaleel Alhasnawi & Rihab Almalki.
Theory Of Automata By Dr. MM Alam
CS 3240 – Chapter 6.  6.1: Simplifying Grammars  Substitution  Removing useless variables  Removing λ  Removing unit productions  6.2: Normal Forms.
Chapter 4 Normal Forms for CFGs Chomsky Normal Form n Defn A CFG G = (V, , P, S) is in chomsky normal form if each rule in G has one of.
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
1 Module 32 Chomsky Normal Form (CNF) –4 step process.
Cs466(Prasad)L8Norm1 Normal Forms Chomsky Normal Form Griebach Normal Form.
CS 3813 Introduction to Formal Languages and Automata Chapter 6 Simplification of Context-free Grammars and Normal Forms These class notes are based on.
Context-Free Grammars Normal Forms Chapter 11. Normal Forms A normal form F for a set C of data objects is a form, i.e., a set of syntactically valid.
Normal Forms for Context-Free Grammars Definition: A symbol X in V  T is useless in a CFG G=(V, T, P, S) if there does not exist a derivation of the form.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
Lecture # 19. Example Consider the following CFG ∑ = {a, b} Consider the following CFG ∑ = {a, b} 1. S  aSa | bSb | a | b | Λ The above CFG generates.
Context Free Grammar. Introduction Why do we want to learn about Context Free Grammars?  Used in many parsers in compilers  Yet another compiler-compiler,
Regular Grammars Chapter 7. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
Regular Grammars Chapter 7 1. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
Lecture 11 Theory of AUTOMATA
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
1 Simplification of Context-Free Grammars Some useful substitution rules. Removing useless productions. Removing -productions. Removing unit-productions.
Closure Properties Lemma: Let A 1 and A 2 be two CF languages, then the union A 1  A 2 is context free as well. Proof: Assume that the two grammars are.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1 Chapter 6 Simplification of CFGs and Normal Forms.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Context Free Grammars and Regular Grammars Needs for CFG Grammars and Production Rules Context Free Grammars (CFG) Regular Grammars (RG)
Lecture # 31 Theory Of Automata By Dr. MM Alam 1.
Chomsky Normal Form.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Theory Of Automata By Dr. MM Alam
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture 17: Theory of Automata:2014 Context Free Grammars.
Recap lecture 5 Different notations of transition diagrams, languages of strings of even length, Odd length, starting with b, ending in a (with different.
Context Free Grammars Chapter 12.
Recap lecture 35 Regular grammar, null productions and examples, nullable productions and examples, unit productions and example, Chomsky Normal Form (Definition)
Normal Forms for CFG’s Eliminating Useless Variables Removing Epsilon
Context-Free Grammars: an overview
Chomsky Normal Form CYK Algorithm
Recap lecture 33 Example of trees, Polish Notation, examples, Ambiguous CFG, example,
Complexity and Computability Theory I
7. Properties of Context-Free Languages
Theorem 29 Given any PDA, there is another PDA that accepts exactly the same language with the additional property that whenever a path leads to ACCEPT,
Recap Lecture 34 Example of Ambiguous Grammar, Example of Unambiguous Grammer (PALINDROME), Total Language tree with examples (Finite and infinite trees),
Even-Even Devise a grammar that generates strings with even number of a’s and even number of b’s.
Simplifications of Context-Free Grammars
Theory Of Automata By Dr. MM Alam
Recap lecture 38 Example of PDA with table for running a string, Equivalent PDA, PDA for EVEN EVEN Language. Non-Derterministic PDA, Example of Non-Derterministic.
Lecture 9 Theory of AUTOMATA
Chapter 7 Regular Grammars
7. Properties of Context-Free Languages
Chapter 6 Simplification of Context-free Grammars and Normal Forms
CHAPTER 2 Context-Free Languages
Midterm #2 — Review problems
ReCap Chomsky Normal Form, Theorem regarding CNF, examples of converting CFG to be in CNF, Example of an FA corresponding to Regular CFG, Left most and.
CSC312 Automata Theory Transition Graphs Lecture # 9
PDA corresponding to CFG
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
Kleene’s Theorem (Part-3)
Context Free Grammars-II
Mealy and Moore Machines
CSC312 Automata Theory Lecture # 24 Chapter # 11 by Cohen Decidability.
Normal Forms for Context-free Grammars
Context-Free Languages
Presentation transcript:

CSC312 Automata Theory Grammatical Format Chapter # 13 by Cohen Lecture # 28 Chapter # 13 by Cohen Grammatical Format

Semiword: A semiword is a string of terminal (maybenone) concaenated with exactly one nonterminal (on the right). i.e. of the shape (terminal) (terminal) … (terminal)(Nonterminal) Theorem 22: If all the productions in a given CFG fit one of the two forms: Nonterminal  semiword or Nonterminal  word ( where the word may be ), then the language generated by this CFG is regular.

Regular Grammar: A CFG is called a regular grammar if each of its productions is of one of the two forms Nonterminal  semiword or Nonterminal  word Example: Consider the CFG S  aaS | bbS |  Consider the regular CFG S  aaS | bbS | abX | baX |  S  aaS | bbS | abS | baS

NULL-Productions: -Productions The production of the form Non-terminal   is said to be NULL production. Note: If a CFG has a Null production, then it is possible to construct another CFG without Null production accepting the same language with the exception of the word . Removing Null-Production: Delete all the Null productions and add new productions by substituting the  in the old productions.

Example: Consider the CFG S  aSbSa |  Now remove the  and add new productions as Old production New productions S  aSbSa S  aSba S  abSa S  aba So the new CFG without  is S  aSbSa |aSba | abSa | aba

Nullable-Productions: A production is called nullable if is of the form N   or there is derivation that starts at N and leads to  i.e. N1  N2  N3  … Nn   where N1,N2,…,Nn are non-terminals Example: S  AA | bB A  aa | B B  aS |  .

Removing Nullable-Production: Example: S  AA | bB A  aa | B B  aS |  Here S  AA and A  B are nullable productions while B   is null production Removing Nullable-Production: Remove all -productions by substituting the  in the old productions and also substitute  for the nullable productions.

Z  AB, W  Z are nullable productions Example: S  XY X  Zb Y  bW Z  AB W  Z A  aA | bA |  B  Ba | Bb |  Here A   and B   are null productions, whereas Z  AB, W  Z are nullable productions Now removing all the null productions we get the following new productions

Old productions New Productions S  XY A  a | b X  Zb B  a | b Y  bW X  b Z  AB Y  b W  Z Z  A (by substituting  for B) A  aA | bA Z  B B  Ba | Bb So the final CFG is S  XY A  aA | bA | a | b X  Zb | b B  Ba | Bb | a | b Y  bW | b Z  AB | A | B W  Z

The production of the form Removing Unit Production: Examples: nonterminal  one terminal, is called unit production. Removing Unit Production: Examples: Consider the following CFG S  A | bb A  B | b B  S | a Separate the unit production from non-unit productions. Now delete unit productions and add the new productions that can be generated by using the deleted unit productions.

Chomsky Normal Form (CNF): A CFG is said to be in CNF if it has all its productions of the form nonterminal  string of two nonterminals nonterminal  on terminal Note: Any CFG can be converted into CNF, if the null productions and the unit productions are remobed. Also if a CFG contains nullable productions as well then the corresponding new productions are also to be added.

Examples: S  aSa | bSb | a | b | aa | bb Consider the following CFG Convert it into equivalent CNF. Steps for converting any CFG into CNF Remove all the null and nullable productions Kill all the unit productions Convert all the productions of multiple letters into the form nonterminal  string of two nonterminal by converting all terminal in strings of multiple letters into nonterminals and then introduce new productions in the form of pairs of nonterminals.