Lecture 10UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 10.

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Advertisements

1 Lecture 32 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union,
Closure Properties of CFL's
About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
CS5371 Theory of Computation
Lecture Note of 12/22 jinnjy. Outline Chomsky Normal Form and CYK Algorithm Pumping Lemma for Context-Free Languages Closure Properties of CFL.
Lecture 7 Sept 22, 2011 Goals: closure properties regular expressions.
104 Closure Properties of Regular Languages Regular languages are closed under many set operations. Let L 1 and L 2 be regular languages. (1) L 1  L 2.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
1 Module 31 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union, concatenation.
Normal forms for Context-Free Grammars
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
Lecture 7UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 7.
Lecture 9UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 9.
Lecture 27UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 27.
1 Background Information for the Pumping Lemma for Context-Free Languages Definition: Let G = (V, T, P, S) be a CFL. If every production in P is of the.
Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.
Context-Free Grammars Chapter 3. 2 Context-Free Grammars and Languages n Defn A context-free grammar is a quadruple (V, , P, S), where  V is.
Lecture 4UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 4.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 Properties of Context-free Languages Reading: Chapter 7.
Chapter 4 Context-Free Languages Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
CONVERTING TO CHOMSKY NORMAL FORM
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
Context-Free Grammars – Chomsky Normal Form Lecture 16 Section 2.1 Wed, Sep 26, 2007.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
1 Let L= { w= u v : u  {a, b}*, v  {c, d}* and |u|= |v|} 1.Design a context-free grammar that generates L. 2.Use your grammar and the construction from.
1 Module 31 Closure Properties for CFL’s –Kleene Closure –Union –Concatenation CFL’s versus regular languages –regular languages subset of CFL.
Context Free Grammars CFGs –Add recursion to regular expressions Nested constructions –Notation expression  identifier | number | - expression | ( expression.
Context-Free and Noncontext-Free Languages Chapter 13 1.
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.
Non-CF Languages The language L = { a n b n c n | n  0 } does not appear to be context-free. Informal: A PDA can compare #a’s with #b’s. But by the time.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
Lecture 11UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 11.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Lecture 14UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 14.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Chomsky Normal Form.
Dept. of Computer Science & IT, FUUAST Theory of Computation 2 Regular Expressions Regular Expression.
Lecture 6: Context-Free Languages
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory III Properties of Regular Languages 1.Closure 2.Union 3.Concatenation 4.Complement(Negation)
1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping.
Properties of Context-Free Languages
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Definition: Let G = (V, T, P, S) be a CFL
COSC 3340: Introduction to Theory of Computation
Properties of Context-Free Languages
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

Lecture 10UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 10

UofH - COSC Dr. Verma 2 Chomsky Normal Form (CNF) Rules of CFG G are in one of two forms: (i) A  a (ii) A  BC, B  S and C  S + Only one rule of the form S   is allowed if  in L(G). Easier to reason with in proofs Leads to more efficient algorithms Credited to Prof. Noam Chomsky at MIT Reading Assignment: Converting a CFG to CNF.

Lecture 10UofH - COSC Dr. Verma 3 Exercises Are the following CFG's in CNF? (i) S  aSb |  (ii) S  aS | Sb |  (iii) S  AS | SB |  A  a B  b (iv) S  AS | SB A  a |  B  b

Lecture 10UofH - COSC Dr. Verma 4 Closure properties of CFL's CFL's are closed under: (i) Union (ii) Concatenation (iii) Kleene Star What about intersection and complement?

Lecture 10UofH - COSC Dr. Verma 5 The setting L 1 = L(G 1 ) where G 1 = (V 1, T, P 1, S 1 ) L 2 = L(G 2 ) where G 2 = (V 2, T, P 2, S 2 ) Assume wlog that V 1  V 2 = 

Lecture 10UofH - COSC Dr. Verma 6 Closure under Union -- Example L 1 = { a n b n | n  0 } L 2 = { b n a n | n  0 } G 1 ? – Ans: S 1  aS 1 b |  G 2 ? – Ans: S 2  bS 2 a |  How to make grammar for L 1  L 2 ? – Ans: Idea: Add new start symbol S and rules S  S 1 | S 2

Lecture 10UofH - COSC Dr. Verma 7 Closure under Union General construction Let G = (V, T, P, S) where – V = V 1  V 2  { S }, – S  V 1  V 2 – P = P 1  P 2  { S  S 1 | S 2 }

Lecture 10UofH - COSC Dr. Verma 8 Closure under concatenation Example L 1 = { a n b n | n  0 } L 2 = { b n a n | n  0 } Is L 1 L 2 = { a n b {2n} a n | n >= 0 } ? – Ans: No! It is { a n b {n+m} a m | n, m  0 } How to make grammar for L 1 L 2 ? – Idea: Add new start symbol and rule S  S 1 S 2

Lecture 10UofH - COSC Dr. Verma 9 Closure under concatenation General construction Let G = (V, T, P, S) where – V = V 1  V 2  { S }, – S  V 1  V 2 – P = P 1  P 2  { S  S 1 S 2 }

Lecture 10UofH - COSC Dr. Verma 10 Closure under kleene star Examples L 1 = {a n b n | n  0} What is (L 1 )*? – Ans: { a {n1} b {n1}... a {nk} b {nk} | k  0 and ni  0 for all i } L 2 = { a {n 2 } | n  1 } What is (L 2 )*? – Ans: a*. Why? How to make grammar for (L 1 )*? – Idea: Add new start symbol S and rules S  SS 1 | .

Lecture 10UofH - COSC Dr. Verma 11 Closure under kleene star General construction Let G = (V, T, P, S) where – V = V 1  { S }, – S  V 1 – P = P 1  { S  SS 1 |  }

Lecture 10UofH - COSC Dr. Verma 12 Tips for Designing CFG's Use closure properties -- divide and conquer Analyze strings – Is order important? Number? Do we need recursion? Flat versus hierarchical? Are any possibilities (strings) missing? Is the grammar generating too many strings?