CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Similar documents
FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

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

Theory of Computation Lecture 1. Dr. Nahla Belal

1 Showing Recognizability

Decidability (What, stuff is unsolvable?)

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

Automata and Languages

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

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

ACS2: Decidability Decidability

CSE 105 THEORY OF COMPUTATION

CSCI 2670 Introduction to Theory of Computing

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

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSCE 551: Chin-Tser Huang. University of South Carolina

A non-turing-recognizable language

CSE 105 THEORY OF COMPUTATION

CS 154 Formal Languages and Computability Assignment #2 Solutions

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

TURING MAHINES

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

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

Turing machines COMS Ashley Montanaro 21 March Department of Computer Science, University of Bristol Bristol, UK

CS 154, Lecture 3: DFA NFA, Regular Expressions

Closure under the Regular Operations

Undecidability. We are not so much concerned if you are slow as when you come to a halt. (Chinese Proverb)

Most General computer?

Intro to Theory of Computation

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

Harvard CS 121 and CSCI E-121 Lecture 20: Polynomial Time

Introduction to Automata

CSCC63 Worksheet Turing Machines

Turing Machines. Our most powerful model of a computer is the Turing Machine. This is an FA with an infinite tape for storage.

CSCI3390-Lecture 6: An Undecidable Problem

Question Bank UNIT I

Computer Sciences Department

CSCE 551 Final Exam, Spring 2004 Answer Key

CSE 105 THEORY OF COMPUTATION

Deterministic Finite Automata (DFAs)

SCHEME FOR INTERNAL ASSESSMENT TEST 3

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Part I: Definitions and Properties

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CS21 Decidability and Tractability


Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

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

Closure under the Regular Operations

Deterministic Finite Automata (DFAs)

CSE 311: Foundations of Computing. Lecture 26: More on Limits of FSMs, Cardinality

CS 121, Section 2. Week of September 16, 2013

Finite Automata. Mahesh Viswanathan

Deterministic Finite Automata (DFAs)

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Lecture Notes: The Halting Problem; Reductions

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

Decidable and undecidable languages

Turing Machines. Fall The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Theory of Computation

Finite Automata and Languages

CISC 4090 Theory of Computation

4.2 The Halting Problem

Turing Machines Part III

Introduction to Turing Machines. Reading: Chapters 8 & 9

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

Undecidability. Andreas Klappenecker. [based on slides by Prof. Welch]

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

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

Assignment #2 COMP 3200 Spring 2012 Prof. Stucki

Turing Machines. Chapter 17

Chapter 3: The Church-Turing Thesis

Homework Assignment 6 Answers

Foundations of Computer Science Lecture 23 Languages: What is Computation?

Homework. Turing Machines. Announcements. Plan for today. Now our picture looks like. Languages

Section 14.1 Computability then else

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

V Honors Theory of Computation

Computability and Complexity

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computability Theory

COM364 Automata Theory Lecture Note 2 - Nondeterminism

6.8 The Post Correspondence Problem

Turing Machines. Lecture 8

INF210 Datamaskinteori (Models of Computation)

CSE 311: Foundations of Computing I Autumn 2014 Practice Final: Section X. Closed book, closed notes, no cell phones, no calculators.

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

CS20a: Turing Machines (Oct 29, 2002)

Transcription:

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS 1. [6 POINTS] For language L 1 = {0 n 1 m n, m 1, m n}, which string is in L 1? ANSWER: 0001111 is in L 1 (with n = 3, m = 4). Note that the other strings (0111110, 0000000, 0000111) are not in L 1. 2. [6 POINTS] Let A and B both be countable sets. The Cartesian product A B is the set of 2-tuples (a, b), where a A and b B. What can be said about the claim that A B is countable? ANSWER: The claim is true. Since A and B are both countable sets, taking elements a A and b B to form 2-tuples (a, b) is also countable. If A and B are both finite, then the resulting Cartesian product is certainly countable (since any finite set is countable). If A and/or B are infinite, write out the Cartesian product A B as (a 0, b 0 ), (a 0, b 1 ), (a 0, b 2 ),..., (a 1, b 0 ), (a 1, b 1 ), (a 1, b 2 ),..., and so on. Though infinite, we can list all elements and therefore map them to N. As a more formal approach, we observe that since A and B are countable, there is an injection from A to N and an injection from B to N. It follows that there is an injection from A B to N 2 and that N 2 = N. 3. [6 POINTS] Which of the following sets has the same cardinality as N 0 = {0, 1, 2, 3,...}? ANSWER: First note that N 0 is an infinite set. Given J = {1, 2, 3, 4,..., 100}, G = {the set of all connected graphs with edge set E and with E 100}, and M = {M 1, M 2, M 3,...} (the set of all possible Turing Machines). Since sets J and G are finite sets, they do not have the same cardinality as N 0. The set of all Turing Machines M is an infinite set that can be mapped to N 0. Therefore, the answer is M. 4. [6 POINTS] Which of the following strings, if any, is not in the language L 4 described by the regular expression {1, 010}? ANSWER: 11011010 is not in the language L 4 because we cannot construct this string from zero or more occurrences of 1 and 010. Note that we can construct strings 10101010, ε, and 11111111 from zero or more occurrences of 1 and 010. 1

5. [6 POINTS] Given Z = N and the list-position l z of element z Z defined as: { 2z if z > 0 l z = 2 z + 1 if z 0 What is the list-position l z of element z = 73? ANSWER: List-position l z for element z = 73 is 2 z + 1 = 2 73 + 1 = 147. 6. [6 POINTS] Given the following language: L 6 = {0100, 011000, 001000, 00110000, 00010000, 0001100000, 01110000, 0011100000,...} Which of the following best describes this language? ANSWER: L 6 = {0 n 1 m 0 (m+n) m, n > 0} 7. [6 POINTS] For the DFA below, what is an equivalent regular expression? ANSWER: All of the given answers are correct. More specifically, the following regular expressions accept strings that the given DFA accepts: {0, 1} 11 ; 1; 0 {10 } 1. 8. [6 POINTS] Which computing problem below, if any, cannot be solved by a CFG? Assume alphabet Σ = {0, 1}. ANSWER: There were actually two correct answers to this question. Both L 8 = {w01#10w w = Σ } and L 8 = {1 n 0 2n 1 n n > 0} cannot be solved by a CFG. Further, L 8 = {all strings with an even number of 0 s and an odd number of 1 s} and L 8 = {all strings with at least five 1 s} can be solved using a DFA (and therefore a CFG). 9. [6 POINTS] What is the computing problem L 9 solved by the CFG below? In other words, what is the language generated by the CFG? Assume alphabet Σ = {0, 1}. S ε 0S1 1S1 ANSWER: L 9 = {u v u Σ and v = 1 u } 2

10. [6 POINTS] What is the language L 10 recognized by Turing Machine M 10 below? In other words, for what input(s) does L 10 (M 10 ) halt in accept state A? ANSWER: L 10 (M 10 ) = {1 0, 1 00, 1 0#} 11. [6 POINTS] A random binary string b 1 b 2 b 3 b 7 of length 7 is input into the DFA below, with P[b i is even] = 0.5. What is the probability that the string is accepted? 29 ANSWER: 128 The DFA accepts strings containing zero, one, or two 1 s. For strings of length 7, there is one string containing zero 1 s (i.e., 0000000), ( ( 7 1) = 7 strings containing one 1, and 7 2) = 21 strings containing two 1 s. Of the 2 7 = 128 possible bit strings, 1 + 7 + 21 = 29 strings that the DFA would accept. 3

12. [6 POINTS] The computing problem L 12 = {all strings of length at least 3 with an odd number of 0 s} can be solved by which of the following? (I) DFA (II) CFG (III) Turing Machine ANSWER: A DFA can solve this computing problem. Since this can be solved by a DFA, then it can also be solved by a CFG and a Turing Machine. 13. [6 POINTS] The computing problem L 13 = {0 3i 10 3j 10 3k i, j, k 0, k = i + j} can be solved by which of the following? (I) DFA (II) CFG (III) Turing Machine ANSWER: Given the need for memory, a DFA cannot solve this computing problem. We can use the following CFG to solve this problem: S 000S000 A A 1B B 000B000 1 Therefore, a Turing Machine can also solve this computing problem. 14. [6 POINTS] Which of the following are countable? ANSWER: All three of these sets are countable. Z is countable as shown in Chapter 22. The set of all odd numbers in N are countable, similar to the approach shown in Chapter 22 for all even numbers. The set of all prime numbers is countable since it forms an injection to N. 15. [8 POINTS] For given language L 15 = {0 n 1 m 0 2n n, m 1, m n}, how many strings of length l 8 are in L 15? ANSWER: Exactly 6 strings of length l 8 are in L 15 : n = 1, 2n = 2, m = 1 = 0100 n = 1, 2n = 2, m = 2 = 01100 n = 1, 2n = 2, m = 3 = 011100 n = 1, 2n = 2, m = 4 = 0111100 n = 1, 2n = 2, m = 5 = 01111100 n = 2, 2n = 4, m = 2 = 00110000 4

16. [8 POINTS] Given the CFG defined as: S P S + P P T P T T 8 (S) How many different derivations are there of string 8 + 8 (8 + 8)? ANSWER: There are many derivations (far more than 4) of string 8 + 8 (8 + 8). One derivation is: S S + P S + P T S + T T S + T (S) S + T (S + P ) S + T (S + T ) P + T (S + T ) T + T (S + T ) T + T (P + T ) T + T (T + T ) 8 + T (T + T ) 8 + 8 (T + T ) 8 + 8 (8 + T ) 8 + 8 (8 + 8) Note that only one variable (i.e., S, P, T ) is replaced at each step. replacements to form a different derivation. Change the order of 5