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

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

CSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.

CS 133 : Automata Theory and Computability

Closure under the Regular Operations

CSE 105 THEORY OF COMPUTATION

Sri vidya college of engineering and technology

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Nondeterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CS 154. Finite Automata, Nondeterminism, Regular Expressions

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS Automata, Computability and Formal Languages

CS 154, Lecture 3: DFA NFA, Regular Expressions

Theory of Computation

CSE 105 THEORY OF COMPUTATION

CMSC 330: Organization of Programming Languages. Regular Expressions and Finite Automata

Theory of Computation (I) Yijia Chen Fudan University

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

CMSC 330: Organization of Programming Languages

How do regular expressions work? CMSC 330: Organization of Programming Languages

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

CMSC 330: Organization of Programming Languages

UNIT-I. Strings, Alphabets, Language and Operations

CSE 105 THEORY OF COMPUTATION

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Equivalence of DFAs and NFAs

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

CPS 220 Theory of Computation REGULAR LANGUAGES

CSE 105 THEORY OF COMPUTATION

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 105 THEORY OF COMPUTATION

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

CSC173 Workshop: 13 Sept. Notes

Closure under the Regular Operations

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Theory of Computation

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

Finite Automata and Regular Languages

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

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

Languages, regular languages, finite automata

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

Computational Models - Lecture 1 1

CSE 105 THEORY OF COMPUTATION

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

Automata: a short introduction

CSE 105 Theory of Computation Professor Jeanne Ferrante

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Theory

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

CISC 4090 Theory of Computation

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

Mathematical Preliminaries. Sipser pages 1-28

False. They are the same language.

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

CSE 105 THEORY OF COMPUTATION

Finite Automata Part Two

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Introduction to Turing Machines. Reading: Chapters 8 & 9

Lecture 3: Nondeterministic Finite Automata

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

CSE 105 THEORY OF COMPUTATION

MATH CSE20 Homework 5 Due Monday November 4

Name: Student ID: Instructions:

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

1 Showing Recognizability

Nondeterministic Finite Automata and Regular Expressions

Computational Models: Class 1

CPSC 421: Tutorial #1

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

Computer Sciences Department

Author: Vivek Kulkarni ( )

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

CS 154 Introduction to Automata and Complexity Theory

UNIT-III REGULAR LANGUAGES

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

Automata Theory and Formal Grammars: Lecture 1

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

Computational Models #1

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

Two-Way Automata and Descriptional Complexity

CSE 105 THEORY OF COMPUTATION

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

INSTITUTE OF AERONAUTICAL ENGINEERING

Homework 1 Due September 20 M1 M2

Theory of Computation Lecture 1. Dr. Nahla Belal

What we have done so far

Transcription:

CSE 5 Homework Due: Monday October 9, 7 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments in this class will be evaluated not only on the correctness of your answers, but on your ability to present your ideas clearly and logically. You should always explain how you arrived at your conclusions, using mathematically sound reasoning. Whether you use formal proof techniques or write a more informal argument for why something is true, your answers should always be well-supported. Your goal should be to convince the reader that your results and methods are sound. Reading Sipser Chapter and Section. Key Concepts Sets, integers, sequences, functions, relations, predicates, graphs, trees, strings, languages, lexicographic ordering, boolean logic, proof by construction, proof by contradiction, proof by induction, finite automata (DFA), computation trace, accept / reject, language of an automaton, regular language, union of languages, concatenation of languages, star of a language.

. ( points) In this problem, we ll use the following definitions (from page 44) of operations on languages (sets of strings) A, B: Union A B = {x x A or x B} Concatenation A B = {xy x A and y B} Star A = {x x... x k k Z and k and each x i A} For each of the following sets of strings over the alphabet {a, b}, answer the following questions () Is ε (the empty string) in the set? () What s an example of a string over {a, b} of length at least that is in the set (or why isn t there such an example)? (3) What s an example of a string over this alphabet of length at least that is not in the set (or why isn t there such an example)? (a) {w {a, b} y(w = yy)} (b) {a, b} {aa, bb} (c) {a, b} {aa, bb} (a) () Yes, if y = ε then w = ε and is part of that set. () A string in the set is abab. If y = ab then w = abab and is part of that set. (3) A string not in the set is aba. Since the requirement is that w = yy, w cannot have an odd length since then y would have non-integer length. (b) {a, b} {aa, bb} = {aaa, abb, baa, bbb} () No, because an empty string cannot be the result of concatenation of non-empty strings. () A string in the set is aaa. It is the result of a concatenated with aa. (3) A string not in the set is aab. The entire set has been enumerated and aab is not one of the elements. (c) {a, b} {aa, bb} = {a, b, aa, bb} () No, because an empty string is not an element of either set that are unioned together. () A string in the set is bb. It is in the second set, and thus is also in the union. (3) A string not in the set is aaa. It is not in either of the sets that are unioned together, so it will not be in their union.

. ( points) Consider the DFA, M, whose state diagram is given by: q q q q 3 q 4 q 5 (a) What is the language recognized by M? Give an informal description in English and briefly justify your answer. (b) Are there strings x L(M), such that if the bits of x are flipped (changing to and to ), the resulting string will also be in L(M)? Why or why not? Is this true for every string x L(M)? (c) Write the formal definition of M = (Q, Σ, δ, q, F ). Use a table to define δ. (a) The language recognized by M is the set of all strings with an odd number of s and a number of s that s a multiple of three. This is because horizontally, the states represent the number of s mod 3 and vertically, the states represent the number of s mod (so even or odd). The bottom left state thus represents both an odd number of s and a number of s that s a multiple of three (i.e. number of s mod 3 = ). (b) Yes, there does exist such a string. For example, choose string. Since it has an odd number of s and exactly three s it is in the language L(M). If the bits are flipped, it still has an odd number of s and exactly three s, so it is still in the language. This is not true for every string, because is in L(M) but when the bits are flipped, we get which is not, since it does not have an odd number of s. (c) M = (Q, Σ, δ, q, F ) Q = {q, q, q, q 3, q 4, q 5 } Σ = {, } q = q F = {q 3 } δ(q, c) = q c δ(q, c) q q q q 3 q q q q 4 q q q q 5 q c δ(q, c) q 3 q 4 q 3 q q 4 q 5 q 4 q q 5 q 3 q 5 q

3. ( points) CSE 5 is a fairly proof heavy class, so the goal of this problem is to help refresh you on different proof techniques. In particular, proof by induction and closure proofs will be important in this class. (a) Prove by induction that + + 3 +... + n = n(n+). (b) Prove that the set of odd integers is closed under multiplication, but not under addition. (a) WTS: + + 3 +... + n = n(n+) Base case: n = When n =, the base case holds because = Inductive Step: When n >, assume by inductive hypthesis that the equation is true for some n = k. Thus we assume that + + 3 +... + k = k(k+) Now we want to show this to be true for k +. When n = k +, the left side of the equation becomes + + 3 +... + (k + ), which is equivalent to ( + + 3 +... + k) + (k + ). By inductive hypothesis, that is equal to k(k+) + (k + ). This can be simplified to k(k+)+(k+) which is equal to (k+)(k+), the equation on the right hand side when n = k +. Thus, we have proven both the base base and the inductive step, so the equation is true for all n. (b) Suppose we have two odd integers. By definition, they have forms k + and m +, for some integers m and k. The product of k + and m + is (k + )(m + ) = 4km + k + m +. We can distribute out a from the first three terms and get (km+k+m)+. Since integers are closed under addition, (km+k+m) is also an integer, which we can call n. Thus, (km+k+m)+ = n+, which is the definition of an odd integer. Since we just showed that the product of any two odd integers is an odd integer, we just showed that the set of integers is closed under multiplication. The set of odd integers is not closed under addition. As counter example, let us choose integers and 3. + 3 = 4, which is not an odd integer. Thus, the sum of two odd integers is not necessarily another odd integer, so the set of odd integers is not closed under addition.

4. ( points) Consider the DFA, M, with the following state diagram., q q q q 3 (a) Write the formal definition of M = (Q, Σ, δ, q, F ). Use a table to define δ. (b) Give an example of a string x such that both x and x R (x R is the reverse of x) are in L(M). (c) Give an example of a string y such that neither y nor y R are in L(M). (d) Can you find an example of a string w such that w is in L(M) but w R is not in L(M)? If so, write the exmaple. If not, explain why. (e) What is the language recognized by M? (a) M = (Q, Σ, δ, q, F ). Q = {q, q, q, q 3 } Σ = {, } q = q F = {q } δ(q, c) = q c δ(q, c) q q q q q q q q q q 3 q q q 3 q 3 q 3 q 3 (b) If x =, then both x and x R () are accepted by M and thus are in L(M). (c) If y =, then it is not accepted by M and thus is not in L(M). Since in this case, y = y R, y R is also not in L(M). (d) This is not possible, because whether the machine accepts or rejects the string depends only on the number of s in that string. Reversing a string does not change the number of s, so it will not change whether it gets accepted or rejected. (e) The language recognized is the set of all strings with exactly two s. This is because we transition horizontally upon reading a, and stay in the same state upon reading a. The state after reading two s is the accept state, so the DFA accepts all strings with exactly two s. In other words, M accepts all strings in the form.

5. ( points) You have an incoming bitstream (sequence of s and s) that might be truncated at any time. Create a DFA (State diagram) to determine if the number represented (in binary) is a multiple of four. (If you need to you can use http://madebyevan.com/fsm/ to draw your diagram.) Left to right q q q Right to left, q q q q 4,