CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY

Similar documents
Final Course Review. Reading: Chapters 1-9

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3)

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Ambiguous Grammars and Compactification

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Decision Properties for Context-free Languages

Lecture 12: Cleaning up CFGs and Chomsky Normal

Theory of Computations Spring 2016 Practice Final Exam Solutions

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

CS 44 Exam #2 February 14, 2001

Final Exam 2, CS154. April 25, 2010

Enumerations and Turing Machines

Derivations of a CFG. MACM 300 Formal Languages and Automata. Context-free Grammars. Derivations and parse trees

CSC-461 Exam #2 April 16, 2014

Formal Languages and Automata

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

(Refer Slide Time: 0:19)

Compiler Construction

JNTUWORLD. Code No: R

Homework 2. Sample Solution. Due Date: Thursday, May 31, 11:59 pm

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.

Lab 7 1 Due Thu., 6 Apr. 2017

Multiple Choice Questions

1. [5 points each] True or False. If the question is currently open, write O or Open.

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

Post's Correspondence Problem. An undecidable, but RE, problem that. appears not to have anything to do with. TM's.


QUESTION BANK. Unit 1. Introduction to Finite Automata

Computer Science 236 Fall Nov. 11, 2010

Pushdown Automata. A PDA is an FA together with a stack.

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Math 302 Introduction to Proofs via Number Theory. Robert Jewett (with small modifications by B. Ćurgus)

Limits of Computation p.1/?? Limits of Computation p.2/??

CS154 Midterm Examination. May 4, 2010, 2:15-3:30PM

COMP 330 Autumn 2018 McGill University

Normal Forms and Parsing. CS154 Chris Pollett Mar 14, 2007.

Chapter 14: Pushdown Automata

(Refer Slide Time 3:31)

Recursively Enumerable Languages, Turing Machines, and Decidability

CS103 Handout 14 Winter February 8, 2013 Problem Set 5

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

CT32 COMPUTER NETWORKS DEC 2015

LING/C SC/PSYC 438/538. Lecture 20 Sandiway Fong

CSE 105 THEORY OF COMPUTATION

Problems, Languages, Machines, Computability, Complexity

Theory of Programming Languages COMP360

Quiz 1: Solutions J/18.400J: Automata, Computability and Complexity. Nati Srebro, Susan Hohenberger

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

Final Exam 1, CS154. April 21, 2010

EDAA40 At home exercises 1

Slides for Faculty Oxford University Press All rights reserved.

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

Introduction to Sets and Logic (MATH 1190)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

CS525 Winter 2012 \ Class Assignment #2 Preparation

Homework Set #2 Math 440 Topology Topology by J. Munkres

HKN CS 374 Midterm 1 Review. Tim Klem Noah Mathes Mahir Morshed

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

Theory of Computation Prof. Raghunath Tewari Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

To illustrate what is intended the following are three write ups by students. Diagonalization

Context-Free Grammars

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Unit 7 Number System and Bases. 7.1 Number System. 7.2 Binary Numbers. 7.3 Adding and Subtracting Binary Numbers. 7.4 Multiplying Binary Numbers

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFR08008 INFORMATICS 2A: PROCESSING FORMAL AND NATURAL LANGUAGES

Theory of Computation, Homework 3 Sample Solution

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

Announcements. CS243: Discrete Structures. Strong Induction and Recursively Defined Structures. Review. Example (review) Example (review), cont.

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

Homework. Context Free Languages. Before We Start. Announcements. Plan for today. Languages. Any questions? Recall. 1st half. 2nd half.

Lecture 22 Tuesday, April 10

Reflection in the Chomsky Hierarchy

Math 485, Graph Theory: Homework #3

CS402 - Theory of Automata Glossary By

Chapter 18: Decidability

Yet More CFLs; Turing Machines. CS154 Chris Pollett Mar 8, 2006.

Solutions to Homework 10

Succinctness counts. You may receive as little as 0 points for an answer that, even

Context Free Languages and Pushdown Automata

Chapter 3: Theory of Modular Arithmetic 1. Chapter 3: Theory of Modular Arithmetic

Basic Triangle Congruence Lesson Plan

Lecture 6: Sequential Sorting

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

Actually talking about Turing machines this time

The CYK Algorithm. We present now an algorithm to decide if w L(G), assuming G to be in Chomsky Normal Form.

Problem 3.1 (Building up geometry). For an axiomatically built-up geometry, six groups of axioms needed:

ECS 120 Lesson 16 Turing Machines, Pt. 2

Starting Boolean Algebra

Automata Theory CS S-FR Final Review

CS103 Handout 16 Winter February 15, 2013 Problem Set 6

CS210 THEORY OF COMPUTATION QUESTION BANK PART -A UNIT- I

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

Normal Forms for CFG s. Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form

CS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010

Chapter 3. Set Theory. 3.1 What is a Set?

Transcription:

CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY Homework # 8 Max. Points: 100 Due Date: Thursday, February 15, 2007, 11:45 AM Student s Name: Student ID: Important Instructions You are required to get print-out of this homework, and solve it using the space provided against each question. You are not allowed to solve on other papers. Clearly state your assumptions, if you are assuming some thing in addition to the given information in each question. Please write legibly. Write your roll number on every page that you submit. Avoid copying work of another person. If found, then such case would be forwarded for disciplinary action without any warning / justification. If you are acquiring help from any resource, then include references completely. There are total 5 questions in this homework Qs 1a)Suppose that you have a class of PDAs, let us say PDA new where you are allowed to have more than one symbol on the left side of a transition. E.g, ABC D is allowed under the rules of PDA new. Show that this class of PDAs has equivalent power to the PDAs that you have studied in class (let us call this latter class PDA normal.) in which you were allowed to pop only one symbol at a time. To do so, use the following method. Take a PDA new that accepts an arbitrary language L, and construct a PDA normal that accepts the same language. Similarly, take a PDA normal that accepts an arbitrary language L, and construct a PDA new that accepts the same language. Note: Over here, both PDA new and PDA normal accept by final state. (15 marks) Ans 1) Showing that a PDA new simulates a PDA normal is trivial. Since you may have one or more symbols on the left side of a transition of PDA new, you can take a PDA normal and simulate all its transitions. The reverse direction is a little more tricky(simulating a PDA new by a PDA normal ) is a bit more tricky, but it can be done like this. Suppose you have a transition as below: x, ABC-> DE Q1

Now, what you need to do is introduce new states for popping each symbol in turn. It goes like this: Q1 x, A-> λ λ, B-> λ λ, C-> DE P1 P2 In general, for any transition with z number of symbols on L.H.S (where z>1), add z-1 new states, where you pop out each symbol in turn. If you find all the symbols in the transition, then from the last state push the entire R.H.S of original transition. This will yield an equivalent NPDA.

Qs 1b) Now, let us consider another class of PDAs, which has no start symbol and does not necessarily halt upon empty stack. So, for example, it will halt if the only transition available between two states q i and q j while stack is empty is of form ( 0,A anything ) but it will not halt if there is a transition of form ( 0, λ B) or (0, λ λ) while the stack is empty. Show that this class of PDAs (let us call these PDA no_start ) are equivalent in power to PDA normal, by the same method as used in part a) Note: Over here, both PDA no_start and PDA normal accept by final state. (10 marks) Ans) Showing that PDA normal simulates PDA no_start is fairly trivial. Take PDA no_start, and add a new start state and start variable. If PDA no_start hangs any where, so does the PDA normal we have constructed. Simlarly, if PDA no_start accepts, so does PDA normal. The original PDA no_start, with no start symbol. Qf We simulate the same thing in PDA normal, but over here when we start in P0, the stack contains a start symbol $. This PDA will accept same language as above. P0 λ, λ-> λ Qf Now, we need to show that PDA no_start simulates PDA normal.. Its fairly simple.

1) Take a given PDA normal P1 with its states and transitions. It starts out with a start symbol $. 2) Take all the states and transitions to a new machine P2 which is a PDA no_start. Introduce a new start state, and push the start symbol $ onto PDA no_start. This new PDA now simulates all the transitions of PDA normal. 3) Now, what we need to do is find a way to have this PDA halt if the start symbol is popped. So what we do is replace all transitions of form (a, λ -> x) according to every letter of the alphabet. So, if stack alphabet is {A,B,C, $} then (a, λ -> x) is replaced by (a, A -> x) and (a, B -> x), (a, C -> x) and (a, $ -> x). This modification now prevents us operating on an empty stack, just as we had in original P1. 4) We also need to ensure that the state machine halts after doing something f the form $->$. So, wherever a $->$ transition occurs, we remove it and replace it with the same transition going to a state having no outgoing transitions (we take it to an accepting state if the $->$ transition occurred on a accepting state in the original P1; a non-accepting state if it initially occurred on a non-accepting state in P1). 5) This P2 now accepts an equivalent language to P1. The original PDAnormal, with a start symbol $ present by default. Qf Below, we have to place the start symbol in PDAno_start ourselves. We also take precautions by modifying lambada transitions in between and Qf to halt the PDA when stack is empty. P0 λ, λ-> $ Qf

Qs 2 a). Use the CYK algorithm on the strings 010010 and 000000 for the grammar below to determine whether they belong to the language or not. You must exhibit the table correctly to receive credit. (Note: You may, or may not, have to simplify the grammar first before proceeding) 20 marks S --> AB BC A --> BA 0 B --> CC 1 C --> AB 0 {B} {S,C} {S,C,A} {A,S} - {A,S,C} {B} - {B} {B} {S,C} {S,A} {B} {S,C} {S,A} {A,C} {B} {A,C} {A,C} {B} {A,C} 0 1 0 0 1 0 Since the last entry does not contain S, we say the string w cannot be produced by the grammar. {B} {S,A,C} {S,A,C} {B} {B} {B} {S,A,C} {S,A,C} {S,A,C} {S,A,C} {B} {B} {B} {B} {B} {A,C} {A,C} {A,C} {A,C} {A,C} {A,C} 0 0 0 0 0 0

Since the last entry does not contain S, we say the string w cannot be produced by the grammar. b) You have studied the time-complexity of CYK algorithm in class (or at least in the slides). Give the big-oh, and explain why the algorithm has this complexity.. (5 marks) Since we have O(n square) entries, and each takes O(n) time, it takes O(n cube) time to implement this algorithm. Qs 3) Consider the language L of the form a n b n c i (0 <= n <= i <= 2n). Show that this language is non-context free using pumping lemma for CFL. This topic will be covered in Saturday s lecture. (20 marks) First of all, we assume the language L to be an infinite CFL for contradiction. We select the string w= a m b m c 2m, where m is pumping lemma constant. Now, we subdivide w = uvwxy, where w >m., vwx <=m and vx >=1. Case 1: vwx lies entirely in a s. Simply pump i = 2 to get a string where no of a s exceeds no of b s and hence does not belong to L. Case 2: vwx lies entirely in b s. Similar treatment to case 1. Case 3: vwx lies entirely in c s. Pump i =2 to get a string where no of c s exceeds double numbers of b s (and hence does not belong to L)

Case 4: v contains a s and b s, while x contains b s.simply pump i=2, the string you get will no longer be of form a s followed by b s followed by c s, and hence will not belong to L Case 5: v contains a s, while x contains a s and b s. Similar to case 4. Case 6: v contains b s and c s while x contains c s. Similar to case 4. Case 7: v contains b s while x contains b s and c s. Similar to case 4. Case 8: v contains a s, while x contains b s. Pump down (i = 0) to get a string where no of c s exceeds double numbers of b s, or double numbers of a s(and hence does not belong to L) Case 9: V contains b s and x contains c s. Pump up (i=2), to get a string where either no of c s exceeds double number of b s, or number of b s and a s are not equal (or both conditions) and hence does not belong to language L. Since we have a contradiction for each case when we pump the repeated portion of string, hence we have that our original assumption that L is CFL is mistaken. Hence by pumping lemma it is shown to be non-cfl. Qs 4 )Use the construction given in your book (pg 272-273, Exercise 7.1.11) to convert the following grammar to Greibach normal form. (10 marks) S AA 0 A SS 1 To be emailed later this evening Qs 5) This is essentially a reading/research check. Find out what the operations of homomorphism and inverse homomorphisms on a language are, and what are the closure properties of CFLs under these operations. Don t worry, these are just complicated names for a very simple concept that is explained in the book. You will need to know this(as well as the other closure properties studied in class) to solve the following questions.

a)assume that L1 ={ a n b n, n >= 0} is a CFL.. Now, use closure properties of CFL (you may use the ones studied in class, as well as homomorphisms and inverse homomorphisms) to prove that L2 = { a m b n c n, m>=0, n>=0} is also a CFL. (7 marks) Ans) First do a homomorphism on L1, replacing a with b and b with c to get L3 ={ b n c n, n >= 0} is a CFL. Now, take the language L4 =a* (which we know to be a CFL), and using closure of CFL under concatenation, take L4. L3 = { a m b n c n, m>=0, n>=0} as the required language which we needed to show to be CFL. b)you may assume that L1 ={ a n b n c n, n >= 0} is NOT a CFL. Using this fact, and closure properties of CFL(you may use the ones studied in class, as well as homomorphisms and inverse homomorphisms), show that L2 ={ a n b n c 2n, n >= 0} is also not a CFL. (13 marks) Ans) Assume for contradiction that L1 ={ a n b n c 2n, n >= 0} is indeed a CFL. Then we may perform a inverse homomorphism on L2, replacing cc with c (as CFL closed under inverse homomorphism). This gives us a new language, that is L1 ={ a n b n c n, n >= 0} which must also be CFL. But we are already given that L2 is non-cfl, so this conclusion is impossible. Hence our initial assumption that L1 is a CFL must have been wrong. Hence proved by contradiction, that L1 is noncfl (since assuming it to be CFL leads to impossible conclusion).

Note: To get credit in part a) and b), you may ONLY use closure properties and the assumptions given to you