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

Similar documents
Theory Bridge Exam Example Questions Version of June 6, 2008

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

Theory of Computation, Homework 3 Sample Solution

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

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 Exam Solutions

UNIT I PART A PART B

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

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

Multiple Choice Questions

Decision Properties for Context-free Languages

Turing Machine Languages

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

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Chapter 14: Pushdown Automata

CS402 - Theory of Automata Glossary By


CT32 COMPUTER NETWORKS DEC 2015

Computer Sciences Department

Introduction to Computers & Programming

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

A Characterization of the Chomsky Hierarchy by String Turing Machines

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

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

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

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

Final Course Review. Reading: Chapters 1-9

(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

ECS 120 Lesson 16 Turing Machines, Pt. 2

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

CpSc 421 Final Solutions

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

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

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

Recursively Enumerable Languages, Turing Machines, and Decidability

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

Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson

Theory of Computations Spring 2016 Practice Final

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

Outline. Language Hierarchy

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

A Note on the Succinctness of Descriptions of Deterministic Languages

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

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

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

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

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

CS 44 Exam #2 February 14, 2001

Theory of Programming Languages COMP360

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

AUTOMATA THEORY AND COMPUTABILITY

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,

CS402 - Theory of Automata FAQs By

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

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

AUBER (Models of Computation, Languages and Automata) EXERCISES

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

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

Problems, Languages, Machines, Computability, Complexity

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

(Refer Slide Time: 0:19)

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

Formal Languages and Automata

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

THEORY OF COMPUTATION

CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY

Languages and Compilers

Reflection in the Chomsky Hierarchy

Context Free Languages and Pushdown Automata

LECTURE NOTES THEORY OF COMPUTATION

Specifying Syntax COMP360

Computability Summary

LECTURE NOTES THEORY OF COMPUTATION

Learn Smart and Grow with world

1.3 Functions and Equivalence Relations 1.4 Languages

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Equivalence of NTMs and TMs

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

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

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

Turing Machines, continued

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

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

CS21 Decidability and Tractability

1 Parsing (25 pts, 5 each)

Eliminating the Storage Tape in Reachability Constructions

QUESTION BANK. Unit 1. Introduction to Finite Automata

Recursive and Recursively Enumerable Languages

pp Variants of Turing Machines (Sec. 3.2)

The Big Picture. Chapter 3

Ambiguous Grammars and Compactification

Elementary Recursive Function Theory

JNTUWORLD. Code No: R

CSE 105 THEORY OF COMPUTATION

KHALID PERVEZ (MBA+MCS) CHICHAWATNI

Lecture 3: Tilings and undecidability

Transcription:

CSCI 2400 Models of Computation, Section 3 Solutions to Practice Final Exam Here are solutions to the practice final exam. For some problems some details are missing for brevity. You should write complete solutions at the final exam. 1. Prove that the following language is not context-free. L = fa i b j c k :0» i» j» kg Answer. Let m be the parameter of the pumping Lemma. We choose to pump the string a m b m c m. The string vxy has length at most m. Notice that v cannot be simultaneously in a m and b m, since if we repeat v (we take v 2 xy 2 ) then a's are mixed with b's and the resulting string is not in the language L. Similarly, v cannot be simultaneously in b m and c m. A similar observation holds for y. Now let's consider the case where vxy is completely within a m. If we pump up the string vxy and we take v 2 xy 2, then the resulting string has the form a m+k b m c m, for some k>0 (since jvyj 1), which is not in the language L. For similar reasons vxy cannot be completely within b m and c m. Now we consider the case where vxy is such that v is completely within a m, and y is completely within b m. If pump up the string vxy once and we obtain the string v 2 xy 2, then the resulting string has the form a m+k1 b m+k2 c m, with k 1 + k 2 1 (since jvyj 1), which is not in the language L. We treat similarly the case where vxy is such that v is completely within b m, and y is completely within c m. Therefore, in all cases the resulting string is not in the language L, and therefore the language L is not context-free. 2. Prove that the following language is context-free. L = fww R : w 6= abba; and w 2fa; bg Λ g Answer. We know that the language L 1 = fww R : w 2fa; bg Λ g is context-free, since it is generated by the context-free grammar: S! asajbsbj The language L 2 = fabbaabbag is regular, since it is described by the regular expression abbaabba. Therefore, the language L 2 is regular too (the complement of a regular language is regular). We have: L = L 1 L 2 1

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 L is context-free. 3. Design a Turing Machine that accepts the following language. L = fab(a + b) Λ g a! a; R b! b; R Figure 1: Turing machine for language L = fab(a + b) Λ g Answer. The Turing machine for language L is shown in Figure 1. Notice that the machine doesn't have to read all the input string in order to accept the string. This is because we know the input string alphabet which isfa; bg, and after string ab any string made from the input alphabet can follow. 4. Describe the algorithm of a three-tape Turing machine that computes the following function. f(x) =x 2 Answer. The algorithm is the following: Compute-Square Input: The input is number x in unary notation which appears on the first tape. i. Copy x to the second and third tape. ii. Append the contents of the second tape to the end of the contents of the first tape. iii. Remove one 1 from the string of the third tape. iv. If more than one 1's are still on the third tape goto step ii. 2

5. Show that the class of Pushdown Automata with two stacks are equivalent with the Turing machines. Answer. We want to show that Turing machines can simulate Pushdown Automata with two stacks and vice versa. ffl Turing machines simulate pushdown automata with two stacks. Pushdown automata are non deterministic. For this reason we choose nondeterministic Turing machines (which are equivalent to standard Turing machines) to simulate the pushdown automata. We split the tape of the Turing machine into two halfs. We place a marker symbol somewhere on the tape to denote the border between the two halfs. The part of the tape left from the marker simulates one stack and the part of the tape right from the marker simulates the second stack. The bottom of the two stacks is the marker. You can imagine the rest of the details. ffl Pushdown automata with two stacks simulate Turing machines. The only difficultly is to simulate the Turing machine tape with two stacks. We can think of the two stacks as being concatenated at their tops. When we want to get to a symbol which is in the first stack then we pop all the contents of the first stack above that symbol and we push these contents to the second stack. This way we can access any symbol stored in a stack without loosing any contents. Essentially this simulates the tape ofaturing machine where the head corresponds to the heads of the two stacks (which point at the top of the stacks). You can imagine the rest of the details. 6. Describe a procedure that enumerates the following strings in proper order. S = f1 2n : n 0g Answer. The proper order is: 1; 11; 1111; 11111111;::: Notice that each string is twice as big as the previous string. The enumeration procedure is the following. Enumeration Procedure i. Write 1 on the tape. This is an enumerated string. 3

ii. Copy the contents of the previously enumerated string next to that string. This is an enumerated string. iii. Goto step ii. 7. Prove that the family of recursively enumerable languages is closed under union. Answer. Let L 1 and L 2 be two recursively enumerable languages. We want to prove that the language L = L 1 [ L 2 is recursively enumerable. We can prove this by giving an enumeration procedure for L (see the discussion on page 287). Since L 1 and L 2 are recursively enumerable then there are respective enumeration procedures M 1 and M 2 for each language. We can construct an enumeration procedure M for L as follows. Enumeration procedure M interleaves the computation of M 1 and M 2. In particular, M allows M 1 to write its first string, then allows M 2 to write its first string, then allows M 1 to write its second string, then allows M 2 to write its second string, and so on. The above procedure enumerates all the strings of L. As an alternative proof you could construct a Turing machine that accepts the union. 8. Prove that the family of recursive languages are closed under intersection. Answer. Let L 1 and L 2 be two recursive languages. We want toprove that the language L = L 1 L 2 is recursive. Since L 1 and L 2 are recursive, there are respective Turing machines M 1 and M 2 which accept each language and halt for each input string. From M 1 and M 2 we can construct a Turing machine that accepts L and halts for each input string as follows. For input string w machine M first allows machine M 1 to run with input string w. If M 1 rejects then M rejects. If M 1 accepts then M allows M 2 to run with input string w. If M 2 accepts then M accepts. If M 2 rejects then M rejects. 9. Prove that the problem of determining whether w 2 L(G), where G is a context-free grammar, is decidable. Answer. This problem is decidable because there are many algorithms that answer this problem. See for example the exhaustive search parsing method, described in page 141, and the CYK algorithm, described in Section 6.3, page 178. 4

10. Prove that the problem of determining whether twoturing machines accept the same language is undecidable. Answer. This problem is equivalent with the following problem. Determine for two recursively enumerable languages L 1 and L 2 whether L 1 = L 2. We will call this the language-equality problem". We know that the following problem is undecidable. Given any recursively enumerable language L 1 determine whether L 1 = ; (see Theorem 12.3, page 322). We will call this the empty-language problem". We will reduce the empty-language problem to the language-equality problem. In particular, set L 2 = ; (trivially, L 2 is a recursively enumerable language since we can easily construct a Turing machine that accepts no string). Obviously, ifwe can solve the language-equality problem L 1 = ;, then we can solve the empty-language problem L 1 = ;. 5