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

Similar documents
Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Name: Student ID: Instructions:

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

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

V Honors Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Theory Bridge Exam Example Questions

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

CpSc 421 Final Exam December 15, 2006

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

CISC4090: Theory of Computation

10. The GNFA method is used to show that

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

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

CSE 105 THEORY OF COMPUTATION

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Section 1 (closed-book) Total points 30

Theory of Computation (II) Yijia Chen Fudan University

Sample Midterm. Understanding the questions is part of the exam; you are not allowed to ask questions during the exam.

CPSC 421: Tutorial #1

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Homework Assignment 6 Answers

CS 154 Introduction to Automata and Complexity Theory

DM17. Beregnelighed. Jacob Aae Mikkelsen

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Decidability (What, stuff is unsolvable?)

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

Theory of Computation

Computer Sciences Department

CSE 105 THEORY OF COMPUTATION

Computational Models - Lecture 4

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

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

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Theory of Computation (IX) Yijia Chen Fudan University

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Reducability. Sipser, pages

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

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

CSE 355 Test 2, Fall 2016

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

CSE 105 THEORY OF COMPUTATION

CS 311 Sample Final Examination

Solutions to Old Final Exams (For Fall 2007)

Undecidable Problems and Reducibility

Computability Theory

CSE 105 THEORY OF COMPUTATION

Closure under the Regular Operations

Context-Free Languages

False. They are the same language.

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Final Exam Comments. UVa - cs302: Theory of Computation Spring < Total

Lecture 17: Language Recognition

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

SE 3310b Theoretical Foundations of Software Engineering. Turing Machines. Aleksander Essex

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Properties of Context-Free Languages. Closure Properties Decision Properties

Introduction to Turing Machines. Reading: Chapters 8 & 9

Closure under the Regular Operations

Automata and Computability. Solutions to Exercises

CS481F01 Prelim 2 Solutions

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

3130CIT Theory of Computation

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CSE 105 THEORY OF COMPUTATION

Theory of Computation Turing Machine and Pushdown Automata

ACS2: Decidability Decidability

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

CPS 220 Theory of Computation

COM364 Automata Theory Lecture Note 2 - Nondeterminism

CS154 Final Examination

CS154 Final Examination

Finite Automata. Mahesh Viswanathan

Announcements. Using a 72-hour extension, due Monday at 11:30AM.

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Automata: a short introduction

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

Final exam study sheet for CS3719 Turing machines and decidability.

Intro to Theory of Computation

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Automata and Computability. Solutions to Exercises

Automata Theory, Computability and Complexity

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

Computational Models - Lecture 3

Before we show how languages can be proven not regular, first, how would we show a language is regular?

UNIT-VIII COMPUTABILITY THEORY

Decidability (intro.)

MA/CSSE 474 Theory of Computation

CS375 Midterm Exam Solution Set (Fall 2017)

Rumination on the Formal Definition of DPDA

Transcription:

Midterm Exam CS 341-451: Foundations of Computer Science II Fall 2016, elearning section Prof. Marvin K. Nakayama Print family (or last) name: Print given (or first) name: I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity. Signature and Date This exam has 9 pages in total, numbered 1 to 9. Make sure your exam has all the pages. Note the number written on the upper right-hand corner of the first page. On the sign-up sheet being passed around, print your name next to this number. Unless other prior arrangements have been made with the professor, the exam is to last 2.5 hours and is to be given on Saturday, October 22, 2016. This is a closed-book, closed-note exam. Electronic devices (e.g., calculators, cellphones, smart watches) are not allowed. For all problems, follow these instructions: 1. Give only your answers in the spaces provided. I will only grade what you put in the answer space, and I will take off points for any scratch work in the answer space. Use the scratch-work area or the backs of the exam sheets to work out your answers before filling in the answer space. 2. DFA stands for deterministic finite automaton; NFA stands for nondeterministic finite automaton; CFG stands for context-free grammar; PDA stands for pushdown automaton. TM stands for Turing machine. 3. For any proofs, be sure to provide a step-by-step argument, with justifications for every step. If you are asked to prove a result X, you may use in your proof of X any other result Y without proving Y. However, make it clear what the other result Y is that you are using; e.g., write something like, By the result that A = A, we know that... Problem 1 2 3 4 5 6 7 Total Points 1

1. [20 points] For each of the following, circle TRUE if the statement is correct. Otherwise, circle FALSE (a) TRUE FALSE Every non-context-free language is also non-regular. (b) TRUE FALSE If A is a regular language, then A is finite. (c) TRUE FALSE If M = (Q,Σ,Γ,δ,q 0,q accept,q reject ) is a Turing machine and w Σ is a string, then M either accepts or rejects w. (d) TRUE FALSE Every nonregular language is context-free. (e) TRUE (f) TRUE FALSE The class of context-free languages is closed under intersection. FALSE If A and B are regular languages, then so is A B. (g) TRUE (h) TRUE FALSE If language A has a regular expression, then A has a PDA. FALSE If A B and A is a regular language, then B is a regular language. (i) TRUE (j) TRUE FALSE There is a language recognized by an NFA but has no DFA. FALSE If A is a context-free language that is also non-regular, then A has a CFG in Chomsky normal form. 2

2. [20 points] Give short answers to each of the following parts. Each answer should be at most a few sentences. Be sure to define any notation that you use. (a) Let Σ = {a,b}, and let A be the set of strings over Σ that have an odd number of a s. Give a regular expression for A. (b) Consider the following CFG G = (V,Σ,R,S), with V = {S,X,Y}, Σ = {a,b}, start variable S, and rules R as follows: S YY a ε X Ya b Y YX XS ε YYXY Note that G is not in Chomsky normal form. List all of the rules in G that violate Chomsky normal form. Explain your answer. 3

(c) Let M 1 = (Q 1,Σ,δ 1,q 1,F 1 ) be a DFA with language A 1, and M 2 = (Q 2,Σ,δ 2,q 2,F 2 ) be a DFA with language A 2. Consider the language A = A 1 A 2. Give a DFA M 3 for A in terms of M 1 and M 2. Your DFA M 3 must be completely general. Do not prove the correctness of your DFA M 3, but do not just give an example. (d) Suppose that A is a language defined by a CFG G 1 = (V 1,Σ,R 1,S 1 ). Give a CFG G 2 for A in terms of G 1. You do not have to prove the correctness of your CFG G 2, but do not give just an example. 4

3. [10 points] Consider the below Turing machine M = (Q,Σ,Γ,δ,q 1,q accept,q reject ) with Q = {q 1,...,q 8,q accept,q reject }, Σ = {0,1,#}, Γ = {0,1,#,x, }, and transitions below. q 1 # #,R q 8 x x,r 0 0,R 1 1,R 0 x,r 1 x,r q 2 x x,r q 3 0 0,R 1 1,R,R # #,R q 7 # #,R 0 0,L q 4 1 1,L # #,L q 5 x x,r x x,r 0 x,l 1 x,l q accept q 6 0 0,L 1 1,L x x,l To simplify the figure, we don t show the reject state q reject or the transitions going to the reject state. Those transitions occur implicitly whenever a state lacks an outgoing transition for a particular symbol. For example, because in state q 5 no outgoing arrow with a # is present, if a # occurs under the head when the machine is in state q 5, it goes to state q reject. For completeness, we say that in each of these transitions to the reject state, the head writes the same symbol as is read and moves right. Give the sequence of configurations that M enters when started on the input string 01#0. 5

4. [10 points] Let N be the following NFA with Σ = {a,b}, and let C = L(N). ε 1 2 a b a b 3 a 4 Give a DFA for C. b 6

5. [20 points] LetΣ = {a,b,c},andconsiderthelanguagea = {a i b j c k i,j,k 0, and i+j = k }. (a) Give a CFG G for A. Be sure to specify G as a 4-tuple G = (V,Σ,R,S). (b) Give a PDA for A. You only need to give the drawing. Scratch-work area 7

Each of the following problems may require you to prove a result. Unless stated otherwise, in your proofs, you can apply any theorems or results that we went over in class (lectures, homeworks) without proving them, except for the result you are asked to prove in the problem. When citing a theorem or result, make sure that you give enough details so that it is clear what theorem or result you are using (e.g., say something like, By the result that says A = A, we can show that... ) 6. [10 points] (a) Showbygivinganexamplethat,ifM isannfathatrecognizeslanguagec,swappingthe accept and non-accept states in M doesn t necessarily yield a new NFA that recognizes C. Explain your answer. (b) Is the class of languages recognized by NFAs closed under complementation? Explain your answer. 8

7. [10 points] Recall the pumping lemma for regular languages: Theorem: If L is a regular language, then there is a number p (pumping length) where, if s L with s p, then s can be split into 3 pieces, s = xyz, satisfying conditions (i) xy i z L for each i 0, (ii) y > 0, and (iii) xy p. Let Σ = {a,b,c}, and consider the language A = {a i b j c k i,j,k 0, and i+j = k }. Is A a regular or nonregular language? If A is regular, give a regular expression for A. If A is not regular, prove that it is a nonregular language. Circle one: Regular Language Nonregular Language 9