Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Similar documents
Homework 3 Solutions

Lecture 08: Feb. 08, 2019

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages

Harvard University Computer Science 121 Midterm October 23, 2012

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Finite Automata-cont d

Name Ima Sample ASU ID

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CHAPTER 1 Regular Languages. Contents

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

First Midterm Examination

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

First Midterm Examination

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

Homework Solution - Set 5 Due: Friday 10/03/08

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CS375: Logic and Theory of Computing

More on automata. Michael George. March 24 April 7, 2014

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A.

1 From NFA to regular expression

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

State Minimization for DFAs

NFAs continued, Closure Properties of Regular Languages

Finite-State Automata: Recap

Closure Properties of Regular Languages

Solutions Problem Set 2. Problem (a) Let M denote the DFA constructed by swapping the accept and non-accepting state in M.

Fundamentals of Computer Science

input tape head moves current state

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Non-deterministic Finite Automata

Non-deterministic Finite Automata

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Some Theory of Computation Exercises Week 1

Automata and Languages

3 Regular expressions

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Let's start with an example:

Today s Topics Automata and Languages

Automata and Languages

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

1.3 Regular Expressions

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

Revision Sheet. (a) Give a regular expression for each of the following languages:

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Chapter 2 Finite Automata

Minimal DFA. minimal DFA for L starting from any other

CS 330 Formal Methods and Models

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

1.4 Nonregular Languages

Designing finite automata II

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

CS 275 Automata and Formal Language Theory

Myhill-Nerode Theorem

1 Nondeterministic Finite Automata

Formal languages, automata, and theory of computation

CISC 4090 Theory of Computation

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

Bases for Vector Spaces

Deterministic Finite Automata

Formal Languages and Automata

Nondeterminism and Nodeterministic Automata

ɛ-closure, Kleene s Theorem,

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

1 Structural induction, finite automata, regular expressions

CS375: Logic and Theory of Computing

GNFA GNFA GNFA GNFA GNFA

Worked out examples Finite Automata

Lecture 09: Myhill-Nerode Theorem

set is not closed under matrix [ multiplication, ] and does not form a group.

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

CS 330 Formal Methods and Models

SWEN 224 Formal Foundations of Programming WITH ANSWERS

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

NFAs continued, Closure Properties of Regular Languages

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

MATH 573 FINAL EXAM. May 30, 2007

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

CMSC 330: Organization of Programming Languages

MTH 505: Number Theory Spring 2017

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Coalgebra, Lecture 15: Equations for Deterministic Automata

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7

1 Structural induction

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

CSE396 Prelim I Answer Key Spring 2017

Lecture 6 Regular Grammars

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Transcription:

CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00) 0 0 (00) (11) 1 1 0 0 1

(00) (11) 01 1 1 0 0 0 1 ((00) (11) 01) 1 1 0 0 0 1 2. Use the procedure descried in Lemm 1.60 to convert the following DFA M to regulr expression., 1 2 3 Answer: First convert DFA M into n equivlent GNFA G. 2

s 1 2 t 3 Next, we eliminte the sttes of G (except for s nd t) one t time. The order in which the sttes re eliminted does not mtter. However, eliminting sttes in different order from wht is done elow my result in different (ut lso correct) regulr expression. We first eliminte stte 3. To do this, we need to ccount for the pths 2 3 1, which will crete n rc from 2 to 1 lelled with ; 2 3 2, which will crete n rc from 2 to 2 lelled with ; nd 2 3 t, which will crete n rc from 2 to t lelled with =. We comine the previous rc from 2 to 2 lelled with the new one lelled to get the new lel. s 1 2 t We next eliminte stte 1. To do this, we need to ccount for the following pths: s 1 2, which will crete n rc from s to 2 lelled with ( ) =. s 1 t, which will crete n rc from s to t lelled with =. 2 1 2, which will crete n rc from 2 to 2 lelled with ( ). We comine this with the existing 2 to 2 rc to get the new lel ( ). 2 1 t, which will crete n rc from 2 to t lelled with =. We comine this rc with the existing rc from 2 to t to get the new lel. 3

s 2 ( ) t Finlly, we eliminte stte 2 y dding n rc from s to t lelled ( )( ( )) ( ). We then comine this with the existing s to t rc to get the new lel ( )( ( )) ( ). s ( )( ( )) ( ) t So regulr expression for the lnguge L(M) recognized y the DFA M is Writing this s ( )( ( )) ( ). }{{} ( ) ( ( )) }{{}}{{} sty in 1 1 to 2 ( ) }{{} (2 to 2) end in 3 or 1 should mke it cler how the regulr expression ccounts for every pth tht strts in 1 nd ends in either 3 or 1, which re the ccepting sttes of the given DFA., 1 2 3 3. Prove tht the following lnguges re not regulr. () A 1 = {www w {,} } Answer: Suppose tht A 1 is regulr lnguge. Let p e the pumping length of the Pumping Lemm. Consider the string s = p p p. Note tht s A 1 4

since s = ( p ) 3, nd s = 3(p + 1) p, so the Pumping Lemm will hold. Thus, we cn split the string s into 3 prts s = xyz stisfying the conditions i. xy i z A 1 for ech i 0, ii. y > 0, iii. xy p. Since the first p symols of s re ll s, the third condition implies tht x nd y consist only of s. So z will e the rest of the first set of s, followed y p p. The second condition sttes tht y > 0, so y hs t lest one. More precisely, we cn then sy tht x = j for some j 0, y = k for some k 1, z = m p p for some m 0. Since p p p = s = xyz = j k m p p = j+k+m p p, we must hve tht j +k +m = p. The first condition implies tht xy 2 z A 1, ut xy 2 z = j k k m p p = p+k p p since j + k + m = p. Hence, xy 2 z A 1 ecuse k 1, nd we get contrdiction. Therefore, A 1 is nonregulr lnguge. () A 2 = {w {,} w = w R }. Answer: Suppose tht A 2 is regulr lnguge. Let p e the pumping length of the Pumping Lemm. Consider the string s = p p. Note tht s A 2 since s = s R, nd s = 2p+1 p, so the Pumping Lemm will hold. Thus, we cn split the string s into 3 prts s = xyz stisfying the conditions i. xy i z A 2 for ech i 0, ii. y > 0, iii. xy p. Since the first p symols of s re ll s, the third condition implies tht x nd y consist only of s. So z will e the rest of the first set of s, followed y p. The second condition sttes tht y > 0, so y hs t lest one. More precisely, we cn then sy tht x = j for some j 0, y = k for some k 1, z = m p for some m 0. Since p p = s = xyz = j k m p = j+k+m p, we must hve tht j + k +m = p. The first condition implies tht xy 2 z A 2, ut xy 2 z = j k k m p 5 = p+k p

since j + k + m = p. Hence, xy 2 z A 2 ecuse ( p+k p ) R = p p+k p+k p since k 1, nd we get contrdiction. Therefore, A 2 is nonregulr lnguge. (c) A 3 = { 2n 3n n n 0}. Answer: Suppose tht A 3 is regulr lnguge. Let p e the pumping length of the Pumping Lemm. Consider the string s = 2p 3p p. Note tht s A 3, nd s = 6p p, so the Pumping Lemm will hold. Thus, we cn split the string s into 3 prts s = xyz stisfying the conditions i. xy i z A 3 for ech i 0, ii. y > 0, iii. xy p. Since the first p symols of s re ll s, the third condition implies tht x nd y consist only of s. So z will e the rest of the first set of s, followed y 3p p. The second condition sttes tht y > 0, so y hs t lest one. More precisely, we cn then sy tht x = j for some j 0, y = k for some k 1, z = m 3p p for some m 0. Since 2p 3p p = s = xyz = j k m 3p p = j+k+m 3p p, we must hve tht j +k +m = 2p. The first condition implies tht xy 2 z A 3, ut xy 2 z = j k k m 3p p = 2p+k 3p p since j + k + m = 2p. Hence, xy 2 z A 3 ecuse k 1, nd we get contrdiction. Therefore, A 3 is nonregulr lnguge. (d) A 4 = {w {,} w hs more s thn s}. Answer: Suppose tht A 4 is regulr lnguge. Let p e the pumping length of the Pumping Lemm. Consider the string s = p p+1. Note tht s A 4, nd s = 2p + 1 p, so the Pumping Lemm will hold. Thus, we cn split the string s into 3 prts s = xyz stisfying the conditions i. xy i z A 4 for ech i 0, ii. y > 0, iii. xy p. Since the first p symols of s re ll s, the third condition implies tht x nd y consist only of s. So z will e the rest of the s, followed y p+1. The second condition sttes tht y > 0, so y hs t lest one. More precisely, we cn then 6

sy tht x = j for some j 0, y = k for some k 1, z = m p+1 for some m 0. Since p p+1 = s = xyz = j k m p+1 = j+k+m p+1, we must hve tht j +k +m = p. The first condition implies tht xy 2 z A 4, ut xy 2 z = j k k m p+1 = p+k p+1 since j + k + m = p. Hence, xy 2 z A 4 ecuse it doesn t hve more s thn s since k 1, nd we get contrdiction. Therefore, A 4 is nonregulr lnguge. 4. Suppose tht lnguge A is recognized y n NFA N, nd lnguge B is the collection of strings not ccepted y some DFA M. Prove tht A B is regulr lnguge. Answer: Since A is recognized y n NFA, we know tht A is regulr since lnguge is regulr if nd only if it is recognized y n NFA (Corollry 1.20). Note tht the DFA M recognizes the lnguge B, the complement of B. Since B is recognized y DFA, y definition, B is regulr. We know from prolem on the previous homework tht B eing regulr implies tht its complement B is regulr. (B is the complement of the complement of B.) But B = B, so B is regulr. Since A nd B re regulr, their conctention A B is regulr y Theorem 1.23. 5. () Prove tht if we dd finite set of strings to regulr lnguge, the result is regulr lnguge. Answer: Let A e regulr lnguge, nd let B e finite set of strings. We know from clss (see pge 1-95 of Lecture Notes for Chpter 1) tht finite lnguges re regulr, so B is regulr. Thus, A B is regulr since the clss of regulr lnguges is closed under union (Theorem 1.22). () Prove tht if we remove finite set of strings from regulr lnguge, the result is regulr lnguge. Answer: LetAeregulrlnguge,ndletB efinitesetofstringswithb A. Let C e the lnguge resulting from removing B from A, i.e., C = A B. As we rgued in the previous prt, B is regulr. Note tht C = A B = A B. Since B is regulr, B is regulr since the clss of regulr lnguges is closed under complement. We proved in n erlier homework tht the clss of regulr lnguges is closed under intersection, so A B is regulr since A nd B re regulr. Therefore, A B is regulr. 7

(c) Prove tht if we dd finite set of strings to nonregulr lnguge, the result is nonregulr lnguge. Answer: Let A e nonregulr lnguge, nd let B e finite set of strings. We wnt to dd B to A, so we my ssume tht none of the strings in B rein A, i.e., A B =. Let C e the lnguge otined y dding B to A, i.e., C = A B. Suppose tht C is regulr, nd we now show this is impossile. Since A B =, we hve tht A = C B. Since C nd B re regulr, the previous prt of this prolem implies tht C B should e regulr, ut we ssumed tht A = C B is nonregulr, so we get contrdiction. (d) Prove tht if we remove finite set of strings from nonregulr lnguge, the result is nonregulr lnguge. Answer: Let A e nonregulr lnguge, nd let B e finite set of strings, where B A. Let C e the lnguge otined y removing B from A, i.e., C = A B. Suppose tht C is regulr, nd we now show this is impossile. Since we removed B from A to get C, we must hve tht C B =, so A = C B. Now C is regulr y ssumption nd B is regulr since it s finite, so C B must e regulr y Theorem 1.25. But we ssumed tht A = C B is nonregulr, so we get contrdiction. 6. Consider the following sttement: If A is nonregulr lnguge nd B is lnguge such tht B A, then B must e nonregulr. If the sttement is true, give proof. If it is not true, give counterexmple showing tht the sttement doesn t lwys hold. Answer: The sttement is not lwys true. For exmple, we know tht the lnguge A = {0 j 1 j j 0} is nonregulr. Define the lnguge B = {01}, nd note tht B A. However, B is finite, so we know tht it is regulr. 8