CPSC 313 Introduction to Computability

Size: px
Start display at page:

Download "CPSC 313 Introduction to Computability"

Transcription

1 CPSC 313 Introduction to Computability Grammars in Chomsky Normal Form (Cont d) (Sipser, pages (3 rd ed) and (2 nd ed)) Renate Scheidler Fall 2018

2 Chomsky Normal Form A context-free grammar G = (V, Σ, R, S) is in Chomsky Normal Form if each rule has the form A BC (A, B, C V; B S; C S), or A a (A V and a Σ) We also allow the rule S ε 2

3 Transformation Steps 1. Create new start symbol S 1 and add new rule S 1 S 2. Eliminate all ε-productions (A ε) 3. Eliminate all unit productions (A B) 4. Convert all rules to proper format by introducing new variables 3

4 Step 3 Removing Unit Rules A unit rule has the form A B where A and B are variables Replace by A B B x 1 x 2... x n A x 1 x 2... x n B x 1 x 2... x n (x i (V Σ)*) 4

5 Algorithm for Step 3 Input: G 2 = (V 1, Σ, R 2, S 1 ) Output: G 3 = (V 1, Σ, R 3, S 1 ) (no unit rules) R 3 R 2 while R 3 contains unit rules do choose any unit rule A B in R 3 remove A B from R 3 For each rule B x add A x to R 3 except if A x is a unit rule we previously removed or is already contained in R 3 or x = A end for end while 5

6 Correctness of Step 3 Claim 1: L(G 3 ) = L(G 2 ) Claim 2: S 1 does not appear on the right-hand side of any rule in G 3 Claim 3: G 3 contains no ε-rules except possibly S 1 ε (in the case where ε L(G)) Claim 4: G 3 does not contain any unit rules 6

7 Example G = (V, Σ, R, S) where V = {S, A, B, C} Σ = {a, b, c} R contains the rules S aab ABCA AC A aab ε B BB b C cc ε 7

8 Example After Step 2 S 1 S ε S aab ab ABCA BCA ABA ABC BA BC AB B AC C A A aab ab B B BB b C cc c 8

9 Example Step 3: Unit Rules S 1 S ε S aab ab ABCA BCA ABA ABC BA BC AB B AC C A A aab ab B B BB b C cc c 9

10 Eliminating Unit Rule A B A aab ab B B BB b A aab ab BB b B BB b 10

11 Eliminating Unit Rule S C S aab ab ABCA BCA ABA ABC BA BC AB B AC C A C cc c S aab ab ABCA BCA ABA ABC BA BC AB B AC cc c A C cc c 11

12 Eliminating Unit Rule S B S aab ab ABCA BCA ABA ABC BA BC AB B AC cc c A B BB b S aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c A B BB b 12

13 Eliminating Unit Rule S A S aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c A A aab ab B Do not substitute A aab or A ab since S aab and S ab are already present Do not substitute A B, since we previously removed that unit rule 13

14 Eliminating Unit Rule S A (Cont d) S aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c A aab ab B (we simply dropped A from right-hand side) 14

15 Eliminating Unit Rule S 1 S S 1 S ε S aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c 15 S 1 aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c ε S (as before)

16 Removing Unreachable Rules Note that S does not appear in the right-hand side of any rule So any rule of the form S x is never applied Drop all rules with S in the left-hand side from G 3 In general, remove all unreachable rules 16

17 Example After Step 3 S 1 aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c ε A aab ab BB b B BB b C cc c 17

18 Step 4 Format Rules First remove all rules A A 1 A 2... A n (n > 2, A i V Σ) by A A 1 X 1, X 1 A 2 X 2, X 2 A 3 X 3,..., X i-1 A i X i,..., X n-2 A n-1 X n-1, X n-1 A n-1 A n with new variables X 1, X 2,..., X n-1 Then remove all rules B xc (x Σ, C V Σ) by B XC, X x with a new variable X Finally, replace all rules B Cx (x Σ, C V) by B CX, X x 18

19 Algorithm for Step 4 Input: G 3 = (V 1, Σ, R 3, S 1 ) Output: G 4 = (V 4, Σ, R 4, S 1 ) (all rules in proper format) R 4 R 3, V 4 V 1 while R 4 contains rules whose right-hand side has length > 2 do choose any such rule A A 1 A 2...A n (with A i V 4 Σ) remove the rule A A 1 A 2...A n from R 4 add a new variable X to V 4 add A A 1 X and X A 2 A 3...A n to R 4 end while 19

20 Algorithm for Step 4 (Cont d) for each a Σ add a new variable X a to V 4 add X a a to R 4 end for for each rule A ab (a Σ and B Σ V) replace A ab with A X a B in R 4 end for for each rule A Ba (a Σ and B V) replace A Ba with A BX a in R 4 end for 20

21 Correctness of Step 4 Claim 1: L(G 4 ) = L(G 3 ) Claim 2: All the rules in G 4 have the form A BC with A V and B, C V \ {S 1 } A a with A V and a Σ S 1 ε (in the case where ε L(G)) Claims 1 & 2 imply that G 4 is a grammar in CNF that generates the same language as our original grammar G. 21

22 Example G = (V, Σ, R, S) where V = {S, A, B, C} Σ = {a, b, c} R contains the rules S aab ABCA AC A aab B ε B BB b C cc ε 22

23 Example After Step 3 S 1 aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c ε A aab ab BB b B BB b C cc c 23

24 Example Step 4: Formatting S 1 aab ab ABCA BCA ABA ABC BA BC AB BB b AC cc c ε A aab ab BB b B BB b C cc c 24

25 Example Step 4: Long Rules Long rules for S 1 : S 1 aab ABCA BCA ABA ABC New rules: S 1 ax 1, X 1 Ab S 1 AY 1, Y 1 BY 2, Y 2 CA S 1 BZ 1, Z 1 CA S 1 AW 1, W 1 BA S 1 AV 1, V 1 BC 25

26 Example Step 4: Long Rules Long rules for A: A aab Re-use corresponding rule introduced for S 1 : we replaced S 1 aab by S 1 ax 1, X 1 Ab so replace A aab by A ax 1, X 1 Ab 26

27 Example Step 4: Remaining Rules Remaining rules to be fixed: S 1 ax 1 ab cc X 1 Ab A ax 1 ab C cc New rules: U a, V b, W c S 1 UX 1 UV WC X 1 AV A UX 1 UV C WC 27

28 Example After Step 4 G 4 = (V 4, Σ, R 4, S 1 ) where V 4 = { S 1, A, B, C, X 1, Y 1, Y 2, Z 1, W 1, V 1, U, V, W } Σ = { a, b, c } R 4 contains the following rules: 28

29 Example After Step 4 S 1 UX 1 UV AY 1 BZ 1 AW 1 BA BC AB BB AC WC b c ε A UX 1 UV BB b B BB b C WC c X 1 AV Y 1 BY 2, Y 2 CA Z 1 CA W 1 BC U a, V b, W c 29

Lecture 12 Simplification of Context-Free Grammars and Normal Forms

Lecture 12 Simplification of Context-Free Grammars and Normal Forms Lecture 12 Simplification of Context-Free Grammars and Normal Forms COT 4420 Theory of Computation Chapter 6 Normal Forms for CFGs 1. Chomsky Normal Form CNF Productions of form A BC A, B, C V A a a T

More information

CS 373: Theory of Computation. Fall 2010

CS 373: Theory of Computation. Fall 2010 CS 373: Theory of Computation Gul Agha Mahesh Viswanathan Fall 2010 1 1 Normal Forms for CFG Normal Forms for Grammars It is typically easier to work with a context free language if given a CFG in a normal

More information

Homework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0,

Homework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0, Introduction to Formal Language, Fall 2016 Due: 21-Apr-2016 (Thursday) Instructor: Prof. Wen-Guey Tzeng Homework 4 Solutions Scribe: Yi-Ruei Chen 1. Find context-free grammars for the language L = {a n

More information

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y.

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. CSE2001, Fall 2006 1 Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. S 00S1 A - xay, where x = 2 y.

More information

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form

More information

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner. Tel Aviv University. November 28, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Parsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26

Parsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26 Parsing Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Winter 2017/18 1 / 26 Table of contents 1 Context-Free Grammars 2 Simplifying CFGs Removing useless symbols Eliminating

More information

MTH401A Theory of Computation. Lecture 17

MTH401A Theory of Computation. Lecture 17 MTH401A Theory of Computation Lecture 17 Chomsky Normal Form for CFG s Chomsky Normal Form for CFG s For every context free language, L, the language L {ε} has a grammar in which every production looks

More information

Concordia University Department of Computer Science & Software Engineering

Concordia University Department of Computer Science & Software Engineering Concordia University Department of Computer Science & Software Engineering COMP 335/4 Theoretical Computer Science Winter 2015 Assignment 3 1. In each case, what language is generated by CFG s below. Justify

More information

Context-Free Grammar

Context-Free Grammar Context-Free Grammar CFGs are more powerful than regular expressions. They are more powerful in the sense that whatever can be expressed using regular expressions can be expressed using context-free grammars,

More information

Theory of Computation - Module 3

Theory of Computation - Module 3 Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of

More information

Theory of Computer Science

Theory of Computer Science Theory of Computer Science C1. Formal Languages and Grammars Malte Helmert University of Basel March 14, 2016 Introduction Example: Propositional Formulas from the logic part: Definition (Syntax of Propositional

More information

Solution. S ABc Ab c Bc Ac b A ABa Ba Aa a B Bbc bc.

Solution. S ABc Ab c Bc Ac b A ABa Ba Aa a B Bbc bc. Section 12.4 Context-Free Language Topics Algorithm. Remove Λ-productions from grammars for langauges without Λ. 1. Find nonterminals that derive Λ. 2. For each production A w construct all productions

More information

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where Recitation 11 Notes Context Free Grammars Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x A V, and x (V T)*. Examples Problem 1. Given the

More information

Context-Free Grammars: Normal Forms

Context-Free Grammars: Normal Forms Context-Free Grammars: Normal Forms Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters

More information

C1.1 Introduction. Theory of Computer Science. Theory of Computer Science. C1.1 Introduction. C1.2 Alphabets and Formal Languages. C1.

C1.1 Introduction. Theory of Computer Science. Theory of Computer Science. C1.1 Introduction. C1.2 Alphabets and Formal Languages. C1. Theory of Computer Science March 20, 2017 C1. Formal Languages and Grammars Theory of Computer Science C1. Formal Languages and Grammars Malte Helmert University of Basel March 20, 2017 C1.1 Introduction

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

Linear conjunctive languages are closed under complement

Linear conjunctive languages are closed under complement Linear conjunctive languages are closed under complement Alexander Okhotin okhotin@cs.queensu.ca Technical report 2002-455 Department of Computing and Information Science, Queen s University, Kingston,

More information

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor 60-354, Theory of Computation Fall 2013 Asish Mukhopadhyay School of Computer Science University of Windsor Pushdown Automata (PDA) PDA = ε-nfa + stack Acceptance ε-nfa enters a final state or Stack is

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form:

More information

CS A Term 2009: Foundations of Computer Science. Homework 2. By Li Feng, Shweta Srivastava, and Carolina Ruiz.

CS A Term 2009: Foundations of Computer Science. Homework 2. By Li Feng, Shweta Srivastava, and Carolina Ruiz. CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 2 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 4 Problem 1: (10 Points) Exercise 4.3 Solution 1: S is

More information

Mathematics I. Exercises with solutions. 1 Linear Algebra. Vectors and Matrices Let , C = , B = A = Determine the following matrices:

Mathematics I. Exercises with solutions. 1 Linear Algebra. Vectors and Matrices Let , C = , B = A = Determine the following matrices: Mathematics I Exercises with solutions Linear Algebra Vectors and Matrices.. Let A = 5, B = Determine the following matrices: 4 5, C = a) A + B; b) A B; c) AB; d) BA; e) (AB)C; f) A(BC) Solution: 4 5 a)

More information

CpSc 421 Homework 1 Solutions

CpSc 421 Homework 1 Solutions CpSc 421 Homework 1 Solutions 1. (15 points) Let Σ = {a, b, c}. Figure 7 depicts two finite state machines that read Let L a and L b denote the languages recognized by DFA (a) and DFA (b) respectively.

More information

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions? Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)

More information

Context-Free Grammars. 2IT70 Finite Automata and Process Theory

Context-Free Grammars. 2IT70 Finite Automata and Process Theory Context-Free Grammars 2IT70 Finite Automata and Process Theory Technische Universiteit Eindhoven May 18, 2016 Generating strings language L 1 = {a n b n n > 0} ab L 1 if w L 1 then awb L 1 production rules

More information

The Pumping Lemma for Context Free Grammars

The Pumping Lemma for Context Free Grammars The Pumping Lemma for Context Free Grammars Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar is in the form A BC A a Where a is any terminal

More information

CS481F01 Prelim 2 Solutions

CS481F01 Prelim 2 Solutions CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of

More information

Plan for 2 nd half. Just when you thought it was safe. Just when you thought it was safe. Theory Hall of Fame. Chomsky Normal Form

Plan for 2 nd half. Just when you thought it was safe. Just when you thought it was safe. Theory Hall of Fame. Chomsky Normal Form Plan for 2 nd half Pumping Lemma for CFLs The Return of the Pumping Lemma Just when you thought it was safe Return of the Pumping Lemma Recall: With Regular Languages The Pumping Lemma showed that if a

More information

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4 Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A BC A a S ε B and C aren t start variables a is

More information

The uvw method - Tejs. The uvw method. by Mathias Bæk Tejs Knudsen

The uvw method - Tejs. The uvw method. by Mathias Bæk Tejs Knudsen The uvw method - Tejs The uvw method by Mathias Bæk Tejs Knudsen The uvw method - Tejs BASIC CONCEPTS Basic Concepts The basic concept of the method is this: With an inequality in the numbers a, b, c R,

More information

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3}, Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014 Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary

More information

This lecture covers Chapter 7 of HMU: Properties of CFLs

This lecture covers Chapter 7 of HMU: Properties of CFLs This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal

More information

How to write proofs - II

How to write proofs - II How to write proofs - II Problem (Ullman and Hopcroft, Page 104, Exercise 4.8). Let G be the grammar Prove that S ab ba A a as baa B b bs abb L(G) = { x {a, b} x contains equal number of a s and b s }.

More information

CFG Simplification. (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions

CFG Simplification. (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions CFG Simplification (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions 1 Eliminating useless symbols 1. A symbol X is generating if there exists: X * w, for

More information

CSCI Compiler Construction

CSCI Compiler Construction CSCI 742 - Compiler Construction Lecture 12 Cocke-Younger-Kasami (CYK) Algorithm Instructor: Hossein Hojjat February 20, 2017 Recap: Chomsky Normal Form (CNF) A CFG is in Chomsky Normal Form if each rule

More information

Section 1 (closed-book) Total points 30

Section 1 (closed-book) Total points 30 CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes

More information

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF) CS5371 Theory of Computation Lecture 7: Automata Theory V (CFG, CFL, CNF) Announcement Homework 2 will be given soon (before Tue) Due date: Oct 31 (Tue), before class Midterm: Nov 3, (Fri), first hour

More information

5/10/16. Grammar. Automata and Languages. Today s Topics. Grammars Definition A grammar G is defined as G = (V, T, P, S) where:

5/10/16. Grammar. Automata and Languages. Today s Topics. Grammars Definition A grammar G is defined as G = (V, T, P, S) where: Grammar Automata and Languages Grammar Prof. Mohamed Hamada oftware Engineering Lab. The University of Aizu Japan Regular Grammar Context-free Grammar Context-sensitive Grammar Left-linear Grammar right-linear

More information

SFWR ENG 2FA3. Solution to the Assignment #4

SFWR ENG 2FA3. Solution to the Assignment #4 SFWR ENG 2FA3. Solution to the Assignment #4 Total = 131, 100%= 115 The solutions below are often very detailed on purpose. Such level of details is not required from students solutions. Some questions

More information

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Salil Vadhan October 11, 2012 Reading: Sipser, Section 2.3 and Section 2.1 (material on Chomsky Normal Form). Pumping Lemma for

More information

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). 1a) G = ({R, S, T}, {0,1}, P, S) where P is: S R0R R R0R1R R1R0R T T 0T ε (S generates the first 0. R generates

More information

A MOST BASIC TRIAD OF PARABOLAS ASSOCIATED WITH A TRIANGLE

A MOST BASIC TRIAD OF PARABOLAS ASSOCIATED WITH A TRIANGLE Global Journal of Advanced Research on Classical and Modern Geometries ISSN: 2284-5569, Vol.6, (207), Issue, pp.45-57 A MOST BASIC TRIAD OF PARABOLAS ASSOCIATED WITH A TRIANGLE PAUL YIU AND XIAO-DONG ZHANG

More information

6.8 The Post Correspondence Problem

6.8 The Post Correspondence Problem 6.8. THE POST CORRESPONDENCE PROBLEM 423 6.8 The Post Correspondence Problem The Post correspondence problem (due to Emil Post) is another undecidable problem that turns out to be a very helpful tool for

More information

A Universal Turing Machine

A Universal Turing Machine A Universal Turing Machine A limitation of Turing Machines: Turing Machines are hardwired they execute only one program Real Computers are re-programmable Solution: Universal Turing Machine Attributes:

More information

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata. Code No: R09220504 R09 Set No. 2 II B.Tech II Semester Examinations,December-January, 2011-2012 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 75 Answer

More information

EXAMPLE CFG. L = {a 2n : n 1 } L = {a 2n : n 0 } S asa aa. L = {a n b : n 0 } L = {a n b : n 1 } S asb ab S 1S00 S 1S00 100

EXAMPLE CFG. L = {a 2n : n 1 } L = {a 2n : n 0 } S asa aa. L = {a n b : n 0 } L = {a n b : n 1 } S asb ab S 1S00 S 1S00 100 EXAMPLE CFG L = {a 2n : n 1 } L = {a 2n : n 0 } S asa aa S asa L = {a n b : n 0 } L = {a n b : n 1 } S as b S as ab L { a b : n 0} L { a b : n 1} S asb S asb ab n 2n n 2n L {1 0 : n 0} L {1 0 : n 1} S

More information

5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp )

5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp ) 5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp. 91-108) Example 3.1 Consider S ε asb. What is L(S)? Solution S asb aasbb a n Sb n a n b n. L(S) = {a n b n n 0} Example 3.2 Consider

More information

Einführung in die Computerlinguistik

Einführung in die Computerlinguistik Einführung in die Computerlinguistik Context-Free Grammars formal properties Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2018 1 / 20 Normal forms (1) Hopcroft and Ullman (1979) A normal

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Push-Down Automata CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard Janicki Computability

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of

More information

Properties of Context-free Languages. Reading: Chapter 7

Properties of Context-free Languages. Reading: Chapter 7 Properties of Context-free Languages Reading: Chapter 7 1 Topics 1) Simplifying CFGs, Normal forms 2) Pumping lemma for CFLs 3) Closure and decision properties of CFLs 2 How to simplify CFGs? 3 Three ways

More information

MODEL ANSWERS TO THE THIRD HOMEWORK

MODEL ANSWERS TO THE THIRD HOMEWORK MODEL ANSWERS TO THE THIRD HOMEWORK 1 (i) We apply Gaussian elimination to A First note that the second row is a multiple of the first row So we need to swap the second and third rows 1 3 2 1 2 6 5 7 3

More information

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX

More information

Fundamentele Informatica II

Fundamentele Informatica II Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,

More information

Solutions to Problem Set 3

Solutions to Problem Set 3 V22.0453-001 Theory of Computation October 8, 2003 TA: Nelly Fazio Solutions to Problem Set 3 Problem 1 We have seen that a grammar where all productions are of the form: A ab, A c (where A, B non-terminals,

More information

Theory of Computation Turing Machine and Pushdown Automata

Theory of Computation Turing Machine and Pushdown Automata Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Solutions to Chapter Review Questions, Chapter 0

Solutions to Chapter Review Questions, Chapter 0 Instructor s Solutions Manual, Chapter 0 Review Question 1 Solutions to Chapter Review Questions, Chapter 0 1. Explain how the points on the real line correspond to the set of real numbers. solution Start

More information

Automata Theory CS F-13 Unrestricted Grammars

Automata Theory CS F-13 Unrestricted Grammars Automata Theory CS411-2015F-13 Unrestricted Grammars David Galles Department of Computer Science University of San Francisco 13-0: Language Hierarchy Regular Languaes Regular Expressions Finite Automata

More information

Chomsky Normal Form for Context-Free Gramars

Chomsky Normal Form for Context-Free Gramars Chomsky Normal Form for Context-Free Gramars Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 17 September 2014 Outline 1 CNF 2 Converting to CNF 3 Correctness

More information

Finite Automata and Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols

Finite Automata and Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols Finite Automata and Formal Languages TMV026/DIT321 LP4 2012 Lecture 13 Ana Bove May 7th 2012 Overview of today s lecture: Normal Forms for Context-Free Languages Pumping Lemma for Context-Free Languages

More information

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove Tuesday 28 of May 2013 Total: 60 points TMV027/DIT321 registration VT13 TMV026/DIT321 registration before VT13 Exam

More information

Properties of Context-Free Languages. Closure Properties Decision Properties

Properties of Context-Free Languages. Closure Properties Decision Properties Properties of Context-Free Languages Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms

More information

Automata Theory CS F-08 Context-Free Grammars

Automata Theory CS F-08 Context-Free Grammars Automata Theory CS411-2015F-08 Context-Free Grammars David Galles Department of Computer Science University of San Francisco 08-0: Context-Free Grammars Set of Terminals (Σ) Set of Non-Terminals Set of

More information

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 4 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 7 Problem: Chap 7.1 part a This PDA accepts the language

More information

TAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar

TAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar TAFL 1 (ECS-403) Unit- III 3.1 Definition of CFG (Context Free Grammar) and problems 3.2 Derivation 3.3 Ambiguity in Grammar 3.3.1 Inherent Ambiguity 3.3.2 Ambiguous to Unambiguous CFG 3.4 Simplification

More information

Math 4377/6308 Advanced Linear Algebra

Math 4377/6308 Advanced Linear Algebra 2.3 Composition Math 4377/6308 Advanced Linear Algebra 2.3 Composition of Linear Transformations Jiwen He Department of Mathematics, University of Houston jiwenhe@math.uh.edu math.uh.edu/ jiwenhe/math4377

More information

Linear Algebra and Matrix Inversion

Linear Algebra and Matrix Inversion Jim Lambers MAT 46/56 Spring Semester 29- Lecture 2 Notes These notes correspond to Section 63 in the text Linear Algebra and Matrix Inversion Vector Spaces and Linear Transformations Matrices are much

More information

Grammars and Context Free Languages

Grammars and Context Free Languages Grammars and Context Free Languages H. Geuvers and A. Kissinger Institute for Computing and Information Sciences Version: fall 2015 H. Geuvers & A. Kissinger Version: fall 2015 Talen en Automaten 1 / 23

More information

CSE 355 Test 2, Fall 2016

CSE 355 Test 2, Fall 2016 CSE 355 Test 2, Fall 2016 28 October 2016, 8:35-9:25 a.m., LSA 191 Last Name SAMPLE ASU ID 1357924680 First Name(s) Ima Regrading of Midterms If you believe that your grade has not been added up correctly,

More information

Chapter 6. Properties of Regular Languages

Chapter 6. Properties of Regular Languages Chapter 6 Properties of Regular Languages Regular Sets and Languages Claim(1). The family of languages accepted by FSAs consists of precisely the regular sets over a given alphabet. Every regular set is

More information

JEE/BITSAT LEVEL TEST

JEE/BITSAT LEVEL TEST JEE/BITSAT LEVEL TEST Booklet Code A/B/C/D Test Code : 00 Matrices & Determinants Answer Key/Hints Q. i 0 A =, then A A is equal to 0 i (a.) I (b.) -ia (c.) -I (d.) ia i 0 i 0 0 Sol. We have AA I 0 i 0

More information

Einführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften

Einführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften Normal forms (1) Einführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften Laura Heinrich-Heine-Universität Düsseldorf Sommersemester 2013 normal form of a grammar formalism

More information

Grammars and Context-free Languages; Chomsky Hierarchy

Grammars and Context-free Languages; Chomsky Hierarchy Regular and Context-free Languages; Chomsky Hierarchy H. Geuvers Institute for Computing and Information Sciences Version: fall 2015 H. Geuvers Version: fall 2015 Huygens College 1 / 23 Outline Regular

More information

UNRESTRICTED GRAMMARS

UNRESTRICTED GRAMMARS 136 UNRESTRICTED GRAMMARS Context-free grammar allows to substitute only variables with strings In an unrestricted grammar (or a rewriting system) one may substitute any non-empty string (containing variables

More information

HASSE-MINKOWSKI THEOREM

HASSE-MINKOWSKI THEOREM HASSE-MINKOWSKI THEOREM KIM, SUNGJIN 1. Introduction In rough terms, a local-global principle is a statement that asserts that a certain property is true globally if and only if it is true everywhere locally.

More information

Grammars (part I) Prof. Dan A. Simovici UMB

Grammars (part I) Prof. Dan A. Simovici UMB rammars (part I) Prof. Dan A. Simovici UMB 1 / 36 Outline 1 rammars and Chomsky s Hierachy 2 Productions and Derivations in rammars 3 Chomsky s Hierachy 4 Equivalent rammars 2 / 36 Outline Language classes

More information

CPS 220 Theory of Computation

CPS 220 Theory of Computation CPS 22 Theory of Computation Review - Regular Languages RL - a simple class of languages that can be represented in two ways: 1 Machine description: Finite Automata are machines with a finite number of

More information

REGULATED GALIUKSCHOV SEMICONTEXTUAL GRAMMARS

REGULATED GALIUKSCHOV SEMICONTEXTUAL GRAMMARS KYBERNETIKA- VOLUME 26 (1990), NUMBER 4 REGULATED GALIUKSCHOV SEMICONTEXTUAL GRAMMARS MONICA MARCUS, GHEORGHE PĂUN We consider matrix, programmed, random context and regular control semicontextual grammars

More information

Context Free Grammars

Context Free Grammars Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 14 SMALL REVIEW FOR FINAL SOME Y/N QUESTIONS Q1 Given Σ =, there is L over Σ Yes: = {e} and L = {e} Σ Q2 There are uncountably

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Rewriting Systems and Chomsky Grammars CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard

More information

Grammars and Context Free Languages

Grammars and Context Free Languages Grammars and Context Free Languages H. Geuvers and J. Rot Institute for Computing and Information Sciences Version: fall 2016 H. Geuvers & J. Rot Version: fall 2016 Talen en Automaten 1 / 24 Outline Grammars

More information

CS 133 : Automata Theory and Computability

CS 133 : Automata Theory and Computability CS 133 : Automata Theory and Computability Lecture Slides 1 Regular Languages and Finite Automata Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University

More information

Languages. Languages. An Example Grammar. Grammars. Suppose we have an alphabet V. Then we can write:

Languages. Languages. An Example Grammar. Grammars. Suppose we have an alphabet V. Then we can write: Languages A language is a set (usually infinite) of strings, also known as sentences Each string consists of a sequence of symbols taken from some alphabet An alphabet, V, is a finite set of symbols, e.g.

More information

Problem 2.6(d) [4 pts] Problem 2.12 [3pts] Original CFG:

Problem 2.6(d) [4 pts] Problem 2.12 [3pts] Original CFG: Problem 2.6(d) [4 pts] S X T#X X#T T#X#T X axa bxb #T# # T at bt #T ε Problem 2.12 [3pts] Original CFG: R XRX S S atb bta T XTX X ε X a b q start ε, ε $ ε, R X ε, ε R ε, ε X ε, R S ε, T X ε, T ε ε, X a

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: Captured by Regular Operations a b

More information

Context Free Language Properties

Context Free Language Properties Context Free Language Properties Knowing that the context free languages are exactly those sets accepted by nondeterministic pushdown automata provides us a bit of information about them. We know that

More information

Absolute Value Equations and Inequalities. Use the distance definition of absolute value.

Absolute Value Equations and Inequalities. Use the distance definition of absolute value. Chapter 2 Section 7 2.7 Absolute Value Equations and Inequalities Objectives 1 2 3 4 5 6 Use the distance definition of absolute value. Solve equations of the form ax + b = k, for k > 0. Solve inequalities

More information

Homework 5 - Solution

Homework 5 - Solution DCP3122 Introduction to Formal Languages, Spring 2015 Instructor: Prof. Wen-Guey Tzeng Homework 5 - Solution 5-May-2015 Due: 18-May-2015 1. Given Σ = {a, b, c}, find an NPDA that accepts L = {a n b n+m

More information

Recursive descent for grammars with contexts

Recursive descent for grammars with contexts 39th International Conference on Current Trends in Theory and Practice of Computer Science Špindleruv Mlýn, Czech Republic Recursive descent parsing for grammars with contexts Ph.D. student, Department

More information

Grammars (part II) Prof. Dan A. Simovici UMB

Grammars (part II) Prof. Dan A. Simovici UMB rammars (part II) Prof. Dan A. Simovici UMB 1 / 1 Outline 2 / 1 Length-Increasing vs. Context-Sensitive rammars Theorem The class L 1 equals the class of length-increasing languages. 3 / 1 Length-Increasing

More information

CA320 - Computability & Complexity

CA320 - Computability & Complexity CA320 - Computability & Complexity David Sinclair Context-Sensitive Grammars An unrestricted grammar is a 4-tuple G = (V,Σ,S,P), where V and Σ are disjoint sets of variables and terminals respectively.

More information

Sheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed

Sheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed Sheet -8 Dr. Mostafa Aref Format By : Mostafa Sayed 09 Introduction Assignment. For = {a, } a) Write 0 strings of the following languages i) All strings with no more than one a,,, a, a, a, a, a, a, a ii)

More information

Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8

Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8 Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8 John Martin: Introduction to Languages and the Theory of Computation Jetty Kleijn Najaar 2008 7.1 (q 0,bbcbb,Z

More information

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

FABER Formal Languages, Automata. Lecture 2. Mälardalen University CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010 1 Content Languages, g Alphabets and Strings Strings & String Operations Languages & Language Operations

More information

Talen en Compilers. Johan Jeuring , period 2. October 29, Department of Information and Computing Sciences Utrecht University

Talen en Compilers. Johan Jeuring , period 2. October 29, Department of Information and Computing Sciences Utrecht University Talen en Compilers 2015-2016, period 2 Johan Jeuring Department of Information and Computing Sciences Utrecht University October 29, 2015 12. LL parsing 12-1 This lecture LL parsing Motivation Stack-based

More information