COSC 3340: Introduction to Theory of Computation

Slides:



Advertisements
Similar presentations
6.2 Closure Properties of CFL's
Advertisements

Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
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
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
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.
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
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.
1 Properties of Context-free Languages Reading: Chapter 7.
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.
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.
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.
Lecture 10UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 10.
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.
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,
Lecture 14UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 14.
Exercises on Chomsky Normal Form and CYK parsing
Chomsky Normal Form.
Dept. of Computer Science & IT, FUUAST Theory of Computation 2 Regular Expressions Regular Expression.
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)
Language Recognition MSU CSE 260.
Closed book, closed notes
Properties of Context-Free Languages
COSC 3340: Introduction to Theory of Computation
Properties of Regular Languages
Complexity and Computability Theory I
Lecture 22 Pumping Lemma for Context Free Languages
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Course 2 Introduction to Formal Languages and Automata Theory (part 2)
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
CSE322 PROPERTIES OF REGULAR LANGUAGES
COSC 3340: Introduction to Theory of Computation
Definition: Let G = (V, T, P, S) be a CFL
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
Properties of Context-Free Languages
Subject Name: Finite Automata & Formal Languages Subject Code 10CS56.
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Convert to a DFA: Start state: Final States: P Symbol Q E(Q) a b.
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
MA/CSSE 474 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
CSE 105 theory of computation
Presentation transcript:

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

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 10 UofH - COSC 3340 - Dr. Verma

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 |  Lecture 10 UofH - COSC 3340 - Dr. Verma

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

The setting L1 = L(G1) where G1 = (V1, T, P1, S1) L2 = L(G2) where Assume wlog that V1  V2 =  Lecture 10 UofH - COSC 3340 - Dr. Verma

Closure under Union -- Example L1 = { anbn | n  0 } L2 = { bnan | n  0 } G1 ? Ans: S1  aS1b |  G2 ? Ans: S2  bS2a |  How to make grammar for L1  L2 ? Ans: Idea: Add new start symbol S and rules S  S1 | S2 Lecture 10 UofH - COSC 3340 - Dr. Verma

Closure under Union General construction Let G = (V, T, P, S) where V = V1  V2  { S }, S  V1  V2 P = P1  P2  { S  S1 | S2 } Lecture 10 UofH - COSC 3340 - Dr. Verma

Closure under concatenation Example L1 = { anbn | n  0 } L2 = { bnan | n  0 } Is L1L2 = { anb{2n}an | n >= 0 } ? Ans: No! It is { anb{n+m}am | n, m  0 } How to make grammar for L1L2 ? Idea: Add new start symbol and rule S  S1S2 Lecture 10 UofH - COSC 3340 - Dr. Verma

Closure under concatenation General construction Let G = (V, T, P, S) where V = V1  V2  { S }, S  V1  V2 P = P1  P2  { S  S1S2 } Lecture 10 UofH - COSC 3340 - Dr. Verma

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

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

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? Lecture 10 UofH - COSC 3340 - Dr. Verma