Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017

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

CS375: Logic and Theory of Computing

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

The Pumping Lemma for Context Free Grammars

CSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.

V Honors Theory of Computation

CS375 Midterm Exam Solution Set (Fall 2017)

Section 1 (closed-book) Total points 30

SFWR ENG 2FA3. Solution to the Assignment #4

A Universal Turing Machine

Equivalent Variations of Turing Machines

Section 14.1 Computability then else

CS311 Computational Structures More about PDAs & Context-Free Languages. Lecture 9. Andrew P. Black Andrew Tolmach

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Chapter 6. Properties of Regular Languages

6.8 The Post Correspondence Problem

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

CS 410/610, MTH 410/610 Theoretical Foundations of Computing

The Power of One-State Turing Machines

Properties of Context-Free Languages

The Chomsky Hierarchy(review)

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Context Free Language Properties

HW 3 Solutions. Tommy November 27, 2012

This lecture covers Chapter 7 of HMU: Properties of CFLs

Properties of context-free Languages

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

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

CS154 Final Examination

Theory of Computation

Notes on Pumping Lemma

Introduction to Turing Machines. Reading: Chapters 8 & 9

The View Over The Horizon

Ogden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.

CS20a: summary (Oct 24, 2002)

Exam 1 CSU 390 Theory of Computation Fall 2007

ECS 120 Lesson 20 The Post Correspondence Problem

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Theory of Computation Turing Machine and Pushdown Automata

Notes for Comp 497 (Comp 454) Week 10 4/5/05

Computational Models - Lecture 5 1

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Question Bank UNIT I

CS154 Final Examination

Homework 5 - Solution

Notes for Comp 497 (454) Week 10

Chapter 8. Turing Machine (TMs)

Automata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles

Computability and Complexity

Theory of Computation

Theory of Computation

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Properties of Context-free Languages. Reading: Chapter 7

Turing Machine Recap

Formal Languages, Automata and Models of Computation

CS21 Decidability and Tractability

CS 341 Homework 16 Languages that Are and Are Not Context-Free

Sample Project: Simulation of Turing Machines by Machines with only Two Tape Symbols

Non-context-Free Languages. CS215, Lecture 5 c

The Post Correspondence Problem; Applications to Undecidability Results

Computability and Complexity

Chapter 5. Finite Automata

HW6 Solutions. Micha l Dereziński. March 20, 2015

Automata Theory CS S-12 Turing Machine Modifications

CpSc 421 Homework 9 Solution

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Automata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008

Theory of Computation (Classroom Practice Booklet Solutions)

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

Chap. 7 Properties of Context-free Languages

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

From Fundamentele Informatica 1: inleverdatum 1 april 2014, 13:45 uur. A Set A of the Same Size as B or Larger Than B. A itself is not.

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Lecture 12: Mapping Reductions

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Part I: Definitions and Properties

CpSc 421 Final Exam December 15, 2006

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

Introduction to Theory of Computing

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Lecture 12 Simplification of Context-Free Grammars and Normal Forms

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

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

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSCI3390-Assignment 2 Solutions

SD & Turing Enumerable. Lecture 33: Reductions and Undecidability. Lexicographically Enumerable. SD & Turing Enumerable

CSE 468, Fall 2006 Homework solutions 1

(a) Definition of TMs. First Problem of URMs

There are two main techniques for showing that problems are undecidable: diagonalization and reduction

Theory of Computation - Module 4

Please give details of your answer. A direct answer without explanation is not counted.

More Properties of Regular Languages

TAKE-HOME: OUT 02/21 NOON, DUE 02/25 NOON

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 17 april Classrum Edition

Transcription:

Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017 1. Find a Greibach normal form for the following given grammar. (10 points) S bab A BAa a B bb Ʌ Solution: (1) Since S does not occur on the right hand side of any productions, we don t need to create S S in this case. (2) There is a Λ-production in the given grammar B Λ, so we need to remove this Λ-production. Since B is the only non-terminal that derives Λ, after removing B Λ, the grammar is: S bab ba A BAa Aa a B bb b (3) There are no unit productions in the grammar, this step is not needed. (4) There is a direct left recursion in the grammar A Aa a, but no indirect left recursion. After transforming A Aa a to A ac C ac Ʌ we have S bab ba A BAa ac C ac Ʌ B bb b Since the language does not contain Ʌ, we have to eliminate Ʌ-production again. After eliminating Ʌ-production, we have S bab ba A BAa ac a C ac a B bb b (5) Replace B in A BAa ac a with bb b to obtain A bbaa baa ac a. Replace B in S bab ba with bb b to obtain S babb bab ba. We have S babb bab ba A bbaa baa ac a C ac a B bb b

Finally add the new productions D a and E b and make appropriate replacements to obtain the proper form: S baeb bae ba A bbad bad ac a C ac a B bb b D a E b 2. Use the Pumping Lemma to show that the following language is not contextfree. (10 points) L = {a i b j c k 0 < i < j < k} Proof: Given the language L = { a i b j c k 0 < i < j < k }, assume, BWOC, that L is context-free. L is infinite, so Pumping Lemma applies. Choose z= a m b m+1 c m+2 where m is the positive integer from the lemma. Then z= a m b m+1 c m+2 = uvwxy where 1 vx vwx m and uv k wx k y L for all k N. First, note that neither v nor x can contain distinct letters. For example, if v = a b, then we have v 2 = a b a b, which cannot appear as a substring of any string in L. So v and x must be strings of repeated occurrences of a single letter. Second, note that since vwx m, vwx cannot extends from a m into c m+2. For, otherwise, as the following figure shows, the length of vwx would be bigger than or equal to m+3, a contradiction. So we only have 5 cases to consider: (1) v and x both occur in a m (2) v and x occur in a m and b m+1, respectively.

(3) v and x both occur in b m+1 (4) v and x occur in b m+1 and c m+2, respectively. (5) v and x both occur in c m+2 However, each of these would lead to a contradiction. So the given language is not context-free language. In the following, we will only consider the first two cases. The other three cases can be proved similarly. Case (1) is shown in the following figure. Each of u, v, w and x is a substring of a m. Let u = a p p 0 v = a i i > 0 w = a q q 0 x = a j j > 0 y = a m p i q j b m+1 c m+2 But then for k=2, we have uv 2 wx 2 y = a p a 2i a q a 2j a m p i q j b m+1 c m+2 = a m+i+j b m+1 c m+2 L a contradiction! Case (2) is shown in the following figure. Here v is a substring of a m and x is s substring of b m+1. Let v = a i i > 0 x = b j j > 0

y = b q c m+2 q 0 w = a p b m+1 j q p 0 u = a m i p Then for k = 2, we have uv 2 wx 2 y = a m i p a 2i a p b m+1 j q b 2j b q c m+2 = a m+i b m+1+j c m+2 L a contradiction! (Note: if you are careful enough, you would notice that the precise requirement is actually i+j > 0. But even with that requirement, the above proof is still true. Why?) 3. Tell if it is possible to construct a Turing machine to move an input string over {a, b} to the right two cells position. Assume that the tape head is at the left end of the input string if the string is not empty. The rest of the tape cells are blank. The machine is supposed to move the entire string to the right two cells position, leaving all remaining tape cells blank. If your answer is YES, show the instructions for such a machine. Otherwise, explain why it is not possible. (10 points) Solution: The answer is YES. Option 1: First, note that it is possible to build a TM to move an input string over {a, b} to the right one cell position. The instruction set of such a TM is as follows, with 0 being the start state:

So, to move an input string over {a, b} to the right two cells position, we can use the above process twice. Option 2: It is also possible to move a string directly to the right two cells position. The instruction set is as follows.

The following shows the execution of the above TM to move the string ababb to the right two cells position:

4. Construct a Turing machine to add 2 to a natural number represented as a binary string. (2.5 points) Solution: The instruction set of the TM is shown below. The start state is 0.

The state transition diagram of the TM is as follows. In the following, we use examples to show the function of each instruction by showing the instruction on the left (framed in blue), an example before and after the execution of the instruction on the right, and the corresponding state transition diagram at the lower left corner.