Theory of Computation, Homework 3 Sample Solution

Similar documents
Outline. Language Hierarchy

Computer Sciences Department

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Variants of Turing Machines

ECS 120 Lesson 16 Turing Machines, Pt. 2

CSE 105 THEORY OF COMPUTATION

CS21 Decidability and Tractability

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

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

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

pp Variants of Turing Machines (Sec. 3.2)

Turing Machines, continued

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Equivalence of NTMs and TMs

CSC-461 Exam #2 April 16, 2014

Decidable Problems. We examine the problems for which there is an algorithm.

Final Course Review. Reading: Chapters 1-9

Actually talking about Turing machines this time

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

t!1; R 0! 1; R q HALT

Lecture 18: Turing Machines

CS525 Winter 2012 \ Class Assignment #2 Preparation

CISC 4090 Theory of Computation

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

Theory of Programming Languages COMP360

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

Multiple Choice Questions

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

Theory of Languages and Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Turing Machine Languages

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

Theory of Computations Spring 2016 Practice Final Exam Solutions

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

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

Ambiguous Grammars and Compactification

T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

Computability Summary

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

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

Today, we will dispel the notion that Java is a magical language that allows us to solve any problem we want if we re smart enough.

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

Theory of Computations Spring 2016 Practice Final

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

CSCI 340: Computational Models. Turing Machines. Department of Computer Science

CT32 COMPUTER NETWORKS DEC 2015


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

Introduction to Computers & Programming

Theory Bridge Exam Example Questions Version of June 6, 2008

Computation Engineering Applied Automata Theory and Logic. Ganesh Gopalakrishnan University of Utah. ^J Springer

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

Recursive and Recursively Enumerable Languages

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

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

AUBER (Models of Computation, Languages and Automata) EXERCISES

CS402 - Theory of Automata Glossary By

Recursively Enumerable Languages, Turing Machines, and Decidability

CS/B.Tech/CSE/IT/EVEN/SEM-4/CS-402/ ItIauIafIaAblll~AladUnrtel1ity

Languages and Automata

Formal languages and computation models

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

UNIT I PART A PART B

Enumerations and Turing Machines

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C.

CS 44 Exam #2 February 14, 2001

THEORY OF COMPUTATION

Decision Properties for Context-free Languages

JNTUWORLD. Code No: R

Theory of Computation p.1/?? Theory of Computation p.2/?? A Turing machine can do everything that any computing

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

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

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

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

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

Learn Smart and Grow with world

Computability via Recursive Functions

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

(Refer Slide Time: 0:19)

NFAs and Myhill-Nerode. CS154 Chris Pollett Feb. 22, 2006.

A Characterization of the Chomsky Hierarchy by String Turing Machines

1. Provide two valid strings in the languages described by each of the following regular expressions, with alphabet Σ = {0,1,2}.

Final Exam 1, CS154. April 21, 2010

where is the transition function, Pushdown Automata is the set of accept states. is the start state, and is the set of states, is the input alphabet,

CIT3130: Theory of Computation. Regular languages

Chapter 14: Pushdown Automata

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

An Interactive Approach to Formal Languages and Automata with JFLAP

Rice s Theorem and Enumeration

14.1 Encoding for different models of computation

Automata & languages. A primer on the Theory of Computation. The imitation game (2014) Benedict Cumberbatch Alan Turing ( ) Laurent Vanbever

6.045J/18.400J: Automata, Computability and Complexity Final Exam. There are two sheets of scratch paper at the end of this exam.

CSE 105 THEORY OF COMPUTATION

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

CpSc 421 Final Solutions

AUTOMATA THEORY AND COMPUTABILITY

Does this program exist? Limits of computability. Does this program exist? A helper function. For example, if the string program is

Transcription:

Theory of Computation, Homework 3 Sample Solution 3.8 b.) The following machine M will do: M = "On input string : 1. Scan the tape and mark the first 1 which has not been marked. If no unmarked 1 is found, go to step 5. Otherwise, move the head back to the front of the tape. 2. Scan the tape and mark the first 0 which has not been marked. If no unmarked 0 is found, reject. 3. Move on to mark the next unmarked 0. If no such unmarked 0 is found, reject. 4. Move the head back to the front of the tape and go to step 1. 5. Move the head back to the front of the tape. Scan the tape to see if there is any unmarked 0 found. If yes, reject. Otherwise, accept. c.) This machine is identical to 3.8b) if we switch reject with accept. M = "On input string : 1. Scan the tape and mark the first 1 which has not been marked. If no unmarked 1 is found, go to step 5. Otherwise, move the head back to the front of the tape. 2. Scan the tape and mark the first 0 which has not been marked. If no unmarked 0 is found, accept. 3. Move on to mark the next unmarked 0. If no such unmarked 0 is found, accept. 4. Move the head back to the front of the tape and go to step 1. 5. Move the head back to the front of the tape. Scan the tape to see if there is any unmarked 0 found. If yes, accept. Otherwise, reject.

3.12 Let be a Turing machine with left reset and be an ordinary Turing machine. If can simulate all the operations that can perform, recognizes the class of Turingrecognizable language. Obviously, can simulate of without problems. How simulates of is described as follows. 1. overwrite with a marked 2. reset to the left-hand end 3. shift the whole tape one cell to the right but keep the mark in the same position 4. reset to the left-hand end 5. scan right to find the marked symbol; the next move will treat the marked symbol as a normal symbol. We assume the following during the shifting for Step 3: a. We use states to remember the symbol to be shifted right. b. The first symbol of the tape after the shift is a symbol not used by the original M. c. If the current symbol is c and the next symbol is the marked b, after the shifting, c becomes marked but b is not marked. d. The shifting stops when we see a blank symbol.

3.15 b.) Let and be two decidable languages and and be the corresponding TMs. The aim is to construct a TM based on and such that the concatenation is also decidable. Since a given input concatenation of strings and has finite possible partitions, a nondeterministic TM is chosen to simplifies the description. NTM On input 1. Nondeterministically split into and 2. run on and on 3. accept if both accepts and accepts ; reject otherwise Obviously, the NTM accepts an input iff there exists a split of such that accepts and accepts. Besides, eventually halts because and are both deciders. Therefore, is decidable since there exists an NTM which decides. c.) Let be a decidable language and be the corresponding TM. The aim is to construct a TM based on such that is also decidable. Since a given input has finite possible combinations of strings where and, a nondeterministic TM is chosen to simplify the description. NTM On input 1. accept if 2. if, nondeterministically split into, where is not empty. 3. run on for all i. 4. accept if accepts all, ; reject otherwise Obviously, the NTM accepts an input iff or there exists a combination of such that accepts. Besides, eventually halts because is a decider. Therefore, is decidable since there exists an NTM which decides.

d.) Let be a decidable language and be the corresponding TM. The aim is to construct a TM based on such that, the complement of, is also decidable. The resulting TM is described as follows. TM On input 1. run on 2. accept if rejects 3. reject if accepts Obviously, accepts an input iff rejects. Besides, eventually halts because is a decider. Therefore, is decidable since there exists a TM which decides. e.) Let and be two decidable languages and and be the corresponding TMs. The aim is to construct a TM based on and such that the intersection is also decidable. The resulting TM is described as follows. On input 4. run and on 1. accept if both and accepts ; reject otherwise Obviously, the NTM accepts an input iff is accepted by and. Besides, eventually halts because and are both deciders. Therefore, is decidable since there exists a TM which decides.

3.16 b.) Let and be two Turing-recognizable languages and and be the corresponding TMs. The aim is to construct a TM based on and such that the concatenation is also Turing-recognizable. Since a given input concatenation of strings and has finite possible partitions, a nondeterministic TM is chosen to simplify the description. NTM On input 1. Nondeterministically split into and 2. run on input 3. reject if halts and rejects 4. run on input 5. accept if accepts ; reject if halts and rejects Obviously, the NTM recognizes an input iff there exists a partition of such that accepts and accepts. However, may loop forever on some input because and are not deciders. Therefore, which recognizes. is Turing-recognizable since there exists an NTM c.) Let be a Turing-recognizable language and be the corresponding TM. The aim is to construct a TM based on such that is also Turing-recognizable. Since a given input has finite possible combinations of strings where,, a nondeterministic TM is chosen to simplify the description. NTM On input 1. accept if 2. if nondeterministically split into, where is not empty. 3. run on for all i. 4. accept if accepts all, ; 5. reject if halts and rejects for any Obviously, the NTM recognizes an input iff or there exists a combination of such that accepts. However, may loop forever on some input because is not a decider. Therefore, is Turing-recognizable since there exists an NTM which recognizes.

d.) Let and be two Turing-recognizable languages and and be the corresponding TMs. The aim is to construct a TM based on and such that the intersection is also Turing-recognizable. The resulting TM is described as follows. On input 1. run on 2. rejects if halts and rejects 3. run on 4. accept if accepts ; reject if halts and rejects Obviously, the TM recognizes an input iff is accepted by and then. However, may loop forever on some input because and both are not deciders. Therefore, is Turing-recognizable since there exists a TM which recognizes. 4.4 Since is just a special case of, it is possible to adapt TM S for as follows. TM S = "On input, where is a CFG and is an empty string: 1. Convert G to an equivalent grammar in Chomsky normal form. 2. If S -> is a production rule in Chomsky normal form, accept; if not, reject." 4.10 To decide is to determine if there exist strings generated by with lengths at least the pumping length. Let be a CFG for and design a TM that decides The construction of TM is as follows, deciding : TM = On input: < > 1. convert to Chomsky normal form 2. calculate the pumping length p = from, where is the number of variables in (in Chomsky normal form, each rule has 0 or two variables at the right, so the pumping length is that is computable) 3. accept if produces a string of length at least because the string can be pumped to generate infinitely other strings 4. otherwise, reject For step 3, it is decidable since it is possible to construct a DFA such that the regular language recognized by is the set of strings of lengths at least. Let be which is a CFL from Problem 2.18a and be the CFG of Then TM in Theorem 4.8 can decide. If TM accepts, produces no strings of lengths at least. If not, produces a string of length at least p.

4.12 If. Therefore, we can first construct two equivalent DFA and recognizing and and then run TM in theorem 4.5 to decide if the two DFA are equivalent. TM = "On input < >: 1. construct the equivalent NFA and for and 4.24 2. construct the equivalent DFA and for the and 3. construct a DFA, accepting. 4. run TM to decide if and are equivalent 5. accept if TM accepts; reject if TM rejects Let be a CFL containing all the palindromes, be the regular language accepted by and be. The goal is that is decidable iff the emptiness of is also decidable. Since is a CFL from Problem 2.18, its emptiness can be decided by TM in theorem 4.8. Let be the CFG of The decider is constructed as follows. TM = "On input where is a DFA accepting some palindrome: 1. Let be a CFL containing all the palindromes 2. Let be the regular language accepted by 3. derive the CFG for 4. run TM to decide 5. accept if TM accepts; reject if TM rejects.

4.28 Let us prove it by contradiction. Suppose that every decider is in A. Since A is Turingrecognizable, A is also enumerable. Let be the i th decider in A. We may construct the following decider as follows: On input, (1) decide the order number of, i.e, =, the index of be ; (2) accept if rejects; rejects if accepts. Apparently, is a decider as (1)-(2) halts. is different from any in A, which is a contradiction to the assumption that every decider is in A. To show that is different from any in A, let be the list of all the strings in an canonical order of string (length than dictionary order). Then can be derived by applying the diagonalization method as illustrated by the following table. The table below demonstrates an example. reject accept accept... accept accept accept... reject accept reject.................. accept reject accept...... Obviously, is different from any language decided by whose description appears in.