CIT 596 Theory of Computation Spring 2005, 212 Moore, TR PM. Homework Assignment 2

Similar documents
September 11, Second Part of Regular Expressions Equivalence with Finite Aut

Johns Hopkins Math Tournament Proof Round: Automata

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs)

CS 154 Formal Languages and Computability Assignment #2 Solutions

CpSc 421 Homework 9 Solution

Formal Definition of a Finite Automaton. August 26, 2013

Deterministic Finite Automata (DFAs)

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

CpSc 421 Homework 1 Solutions

a 2 = ab a 2 b 2 = ab b 2 (a + b)(a b) = b(a b) a + b = b

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

201-1A5-MT - Mathematics Summer 2015 HOMEWORK 2 Deadline : Sunday, August 30, 2015 at 12 :30.

Name: Student ID: Instructions:

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture 2: Regular Expression

CS 321 Solutions to Homework 4 Due October 22, 5pm

Sri vidya college of engineering and technology

Closure under the Regular Operations

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

CSE 105 THEORY OF COMPUTATION

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

CS 581: Introduction to the Theory of Computation! Lecture 1!

CS154 Final Examination

Closure under the Regular Operations

Johns Hopkins Math Tournament 2018 Proof Round: Sequences

Fooling Sets and. Lecture 5

CSCI 2670 Introduction to Theory of Computing

Your Name: UVa Id:

11-711: Algorithms for NLP Homework Assignment #1: Formal Language Theory Solutions

(pp ) PDAs and CFGs (Sec. 2.2)

Nondeterministic Finite Automata

CS154 Final Examination

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

Extended transition function of a DFA

Deterministic Finite Automata (DFAs)

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Computational Models - Lecture 1 1

1. Induction on Strings

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

CSE 105 THEORY OF COMPUTATION

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Equivalence of Regular Expressions and FSMs

This lecture covers Chapter 6 of HMU: Pushdown Automata

CS 154 Introduction to Automata and Complexity Theory

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

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

Lecture 4 Nondeterministic Finite Accepters

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove

CSE 105 THEORY OF COMPUTATION

Math.3336: Discrete Mathematics. Mathematical Induction

Homework 1 Due September 20 M1 M2

CS243, Logic and Computation Nondeterministic finite automata

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Homework #1. Denote the sum we are interested in as To find we subtract the sum to find that

Midterm II : Formal Languages, Automata, and Computability

Solutions. CS 2800 Fall 2017 Final exam Friday, December 8. NetID: 1. Modular arithmetic [9 pts]

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

CpSc 421 Final Exam December 6, 2008

Computational Models - Lecture 3 1

HOMEWORK #2 - MATH 3260

Theory of Computation

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

CSE 105 THEORY OF COMPUTATION

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

CSE 105 Homework 3 Due: Monday October 23, Instructions. should be on each page of the submission.

Formal Definition of Computation. August 28, 2013

1 Showing Recognizability

Takeaway Notes: Finite State Automata

Finite Automata. Theorems - Unit I SUSAN ELIAS. Professor Department of Computer Science & Engineering Sri Venkateswara College of Engineering

CS 322 D: Formal languages and automata theory

Ogden s Lemma for CFLs

September 7, Formal Definition of a Nondeterministic Finite Automaton

(pp ) PDAs and CFGs (Sec. 2.2)

Preparing for the CS 173 (A) Fall 2018 Midterm 1

Introduction to Formal Languages, Automata and Computability p.1/51

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Do not open this exam until you are told to begin. You will have 75 minutes for the exam.

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

Your quiz in recitation on Tuesday will cover 3.1: Arguments and inference. Your also have an online quiz, covering 3.1, due by 11:59 p.m., Tuesday.

CS103 Handout 12 Winter February 4, 2013 Practice Midterm Exam

1 Functions, relations, and infinite cardinality

Math 3000 Section 003 Intro to Abstract Math Homework 6

Chapter 5. Finite Automata

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Context-free grammars and languages

Introduction to Formal Languages, Automata and Computability p.1/42

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

COMPUTER SCIENCE TRIPOS

front pad rear pad door

Chapter 2: Finite Automata

Lecture 13: Turing Machine

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Homework 1 Submission

Automata Theory, Computability and Complexity

CSE 355 Homework One Sample Solutions

CS 154, Lecture 3: DFA NFA, Regular Expressions

Formal Languages. We ll use the English language as a running example.

Transcription:

CIT 596 Theory of Computation Spring 2005, 212 Moore, TR 12-1.30PM Homework Assignment 2 Due: Tuesday, February 1, 2005, by 12 PM (IN CLASS) Name: Student ID (8 digits): Email: Signature: PLEASE, READ THE FOLLOWING INSTRUCTIONS: Fill out this form with your name, student ID, email, and signature and return it as the cover page of your homework. Turn in your homework at the beginning of your class on the due date described at the top of this page. Late assignments will be penalized 25% and will not be accepted after 1:30PM of the day following the due date. Late assignments must be turned in to Janean Williams in room 308, 3rd floor, Levine Building. All writings must be neat, well-organized, and include sufficient explanations in the delineation of the solutions. Full credit will be given only in the case where the correct answer has been properly justified with complete explanations. Good luck! Question 1 2 3 4 5 6 Max 10 20 20 10 20 20 Score TOTAL:

Problem 1 [10 points] The reversal of a string w, denoted w R, is the string spelled backwards. For example, reverse R = esrever. Formally, we can define the reversal of a string by induction on the length of the string as follows: i. If w is a string of length 0 then w R = w = ɛ. ii. If w is a string of length n + 1 > 0 over Σ then w = ua for some a Σ, and w R = au R. By using the above formal definition of reversal of a string, we can compute the reversal of the string reverse as follows: reverse R = e(revers) R, revers R = s(rever) R, rever R = r(reve) R, reve R = e(rev) R, rev R = v(re) R, re R = e(r) R, r R = r(ɛ) R, and ɛ R = ɛ. So, reverse R = esreverɛ = esrever, as expected. (a) Use the inductive definition of reversal of a string to compute the reversal of the string 010010 over Σ = {0, 1}. (b) Note that item (ii) of the above definition of reversal of a string can also be defined as: If w is a string of length n + 1 > 0 over Σ then w = au for some a Σ, and w R = u R a. Using this definition for item (ii), compute the reversal of the string 010010 over Σ = {0, 1}. (a) 010010 R = 0(01001) R, 01001 R = 1(0100) R, 0100 R = 0(010) R, 010 R = 0(01) R, 01 R = 1(0) R, 0 R = 0(ɛ) R, ɛ R = ɛ. So, 010010 R = 010010. (b) 010010 R = (10010) R 0, 10010 R = (0010) R 1, 0010 R = (010) R 0, 010 R = (10) R 0, 10 R = (0) R 1, 0 R = (ɛ) R 0, ɛ R = ɛ. So, 010010 R = 010010. 2

Problem 2 [20 points] Let Σ be any alphabet. Use the inductive definition of reversal of a string given in the previous problem to prove that (w R ) R = w for any w Σ. Note that an obvious choice for your method of proof is induction on the length of the string. We prove the claim using induction on the length w of w. For the base case, we have w = 0, which means that w = ɛ. From the definition of the reversal of a string, we have that ɛ R = ɛ. So, (w R ) R = (ɛ R ) R = (ɛ) R = ɛ = w, and therefore our claim holds for w = 0. For the induction hypothesis, assume that (w R ) R = w for every string w such that w = k, where k is an integer with k 0. Now, we must prove that (w R ) R = w for every string w such that w = k + 1. Since k + 1 1, we can write w = ua, where a Σ and u Σ. From the definition of reversal of a string, we know that w R = (ua) R = au R. From item (b) in Problem (1), we also know that (w R ) R = (au R ) R = (u R ) R a. Since the length of u is k, we can use the induction hypothesis to conclude that (u R ) R = u. So, (w R ) R = (au R ) R = (u R ) R a = ua = w, and our claim also holds for w Σ such that w = k+1. From the first principle of induction, our claim holds for every w Σ. 3

Problem 3 [20 points] Let M = (Q, Σ, δ, q 0, F ) be a DFA. Under exactly what circumstances is ɛ L(M)? Specify a condition that would guarantee that L(M) = Σ? Justify your answers. Note that ɛ L(M) if and only if δ(q 0, ɛ) F. But, by definition of δ, δ(q 0, ɛ) = δ(q 0, ɛ) = q 0. So, ɛ L(M) if and only if q 0 F. Similarly, L(M) = Σ if and only if δ(q 0, w) F for all w Σ. Since δ(q 0, w) can in principle be any state of M, a condition that would guarantee that δ(q 0, w) F is F = Q. 4

Problem 4 [10 points] Draw and specify the five parts of a DFA that accepts the language of all strings w over Σ = {a, b} such that w contains at least two consecutive b s and w does not contain two consecutive a s. Let M = (Q, Σ, δ, q 0, F ) such that Q = {s 1, s 2, s 3, s 4, s 5, s 6 }, Σ = {a, b}, q 0 = s 1, F = {s 5, s 6 }, and δ is given by the following table: a b s 1 s 2 s 3 s 2 s 4 s 3 s 3 s 2 s 5 s 4 s 4 s 4 s 5 s 6 s 5 s 6 s 4 s 5 Your solution should contain the finite state diagram corresponding to the above DFA. 5

Problem 5 [20 points] Draw and specify the five parts of a DFA that accepts the language of all strings w over Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} such that the sum of the digits of w is divisible by 7. For example, w = ɛ, w = 95, w = 007 are in the aforementioned language, as 0, 9 + 5 = 14, 0 + 0 + 7 = 7 are all divisible by 7. A DFA for the language of all strings w over Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} such that the sum of the digits of w is divisible by 7 can be easily built using our knowledge on Number Theory. The idea is to build a DFA in which each state corresponds to a remainder of the division of a number x by 7. If the DFA is in the state s n, for 0 n < 7, and the current input symbol is a Σ, the DFA goes to state s (n+a) mod 7. Formally, we have M = (Q, Σ, δ, q 0, F ) such that Q = {s 0, s 1, s 2, s 3, s 4, s 5, s 6 }, Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, q 0 = s 0, F = {s 0 }, and δ is given by δ(s i, a) = s (i+a) mod 7 for all i with 0 i < 7 and for all a Σ. Your solution should contain the finite state diagram corresponding to the above DFA. 6

Problem 6 [20 points] Let M = (Q, Σ, δ, q 0, F ) be an (arbitrary) DFA that accepts the language L(M). Write down a general procedure for modifying this machine so that it will accept L(M) {ɛ}. Specify the five parts of the new machine and justify your statements. Let M = (Q, Σ, δ, s, F ) be the new DFA. If ɛ L(M), we just have to let M = M. Otherwise, we know that q 0 F, and we define M as follows: The set Q of states of M contains all states of Q and a new state s, which is the initial state of M. The transition function δ is defined such that δ (q, a) = δ(q, a) for all q Q and a Σ and δ (s, a) = δ(q 0, a) for all a Σ. That is, M is the DFA M with one more state, s, which is now the initial state of M. The state s mimics the initial state of M in the sense that δ (s, a) = δ(q 0, a) for all a Σ. Note that there is no transition from a state q Q with q s to state s, i.e., there is no state q Q such that δ (q, a) = s, for any a Σ. We now claim that L(M ) = L(M) {ɛ}. Since s F, we have that ɛ L(M ). Now, note that, for all w Σ +, we can write w = au such that a Σ and u Σ. From the definition of extended transition function, we have that δ (s, w) = δ (δ (s, a), u). From the definition of δ, we have that δ (s, a) = δ(q 0, a). So, δ (s, w) = δ (δ (s, a), u) = δ (δ(q 0, a), u). Since there is no transition from a state q Q to s in M, we have that δ (δ (s, a), u) = q if and only if δ(δ(q 0, a), u) = q, for all w Σ +, with q Q. So, w = au L(M) if and only if w = au L(M ), and therefore L(M ) is precisely L(M) {ɛ}. 7