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

Similar documents
Harvard University Computer Science 121 Midterm October 23, 2012

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

Name Ima Sample ASU ID

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

Worked out examples Finite Automata

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.

Homework 3 Solutions

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

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

Finite Automata-cont d

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

Lecture 08: Feb. 08, 2019

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

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

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

Lecture 09: Myhill-Nerode Theorem

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

State Minimization for DFAs

Minimal DFA. minimal DFA for L starting from any other

1 From NFA to regular expression

CHAPTER 1 Regular Languages. Contents

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Languages & Automata

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

Some Theory of Computation Exercises Week 1

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

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

Deterministic Finite Automata

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

First Midterm Examination

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.

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Let's start with an example:

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

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.

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

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Fundamentals of Computer Science

1 Nondeterministic Finite Automata

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

input tape head moves current state

Convert the NFA into DFA

Non-deterministic Finite Automata

CS 330 Formal Methods and Models

CSE396 Prelim I Answer Key Spring 2017

Theory of Computation Regular Languages

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

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

NFAs continued, Closure Properties of Regular Languages

CS 330 Formal Methods and Models

Formal languages, automata, and theory of computation

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

Formal Languages and Automata

CS375: Logic and Theory of Computing

Non-deterministic Finite Automata

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

Designing finite automata II

GNFA GNFA GNFA GNFA GNFA

Coalgebra, Lecture 15: Equations for Deterministic Automata

CS 330 Formal Methods and Models

Closure Properties of Regular Languages

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

2.4 Linear Inequalities and Interval Notation

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

SWEN 224 Formal Foundations of Programming WITH ANSWERS

Tutorial Automata and formal Languages

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

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 Structural induction

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

3 Regular expressions

Java II Finite Automata I

CMSC 330: Organization of Programming Languages

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

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

First Midterm Examination

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

Finite-State Automata: Recap

Parse trees, ambiguity, and Chomsky normal form

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

Lexical Analysis Finite Automate

CSC 311 Theory of Computation

Nondeterminism and Nodeterministic Automata

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

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

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

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

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

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

CISC 4090 Theory of Computation

Formal Language and Automata Theory (CS21004)

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

Chapter 2 Finite Automata

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

Transcription:

CS 311 Homework 3 due 16:30, Thursdy, 14 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [15 pts.; 5 pts. ech] Drw stte digrms for NFAs recognizing the following lnguges:. L = {w w {0, 1} nd w ends with 00}.. L is the lnguge represented y the regulr expression ( + ) ( + ). q0 q1 c. L = {0101, 101, 1100}. 1

Question 2. [30 pts.;, 5 pts.; c 20 pts.] L R is the lnguge of strings which re the reverse of the strings in the lnguge L. For L = {w w {, } nd in ech initil sustring of w, numer of s the numer of s 2} complete the following exercises:. Construct the digrm of DFA which ccepts strings in the lnguge L. 2

. Construct the digrm of n NFA which ccepts strings in the lnguge L R. q0 λ λ q5 λ q3 λ q4 c. Convert the NFA to DFA. Be sure to provide ll five components of the DFA, show the trnsition tle for δ, nd provide digrm. You my relel the sttes for 3

convenience, if you like. releling tkes plce. If you do, e sure to show the intermedite steps where Using the lzy construction method, we do ε-closure on stte q5 to otin the initil stte q0q1q2q3q4q5 nd then uild the trnsition tle from there. Note the releling in the sme tle. δ q0q1q2q3q4q5 A q0q1q3q4 B q0q1q2q3 C q0q1q3q4 B q0q3q4 D q0q1q2q3 C q0q1q2q3 C q0q1q3q4 B q0q1q2 F q0q3q4 D q3q4 G q0q1q3 H q0q1q2 F q0q1q3 H q1q2 I q3q4 G q4 L q0q3 J q0q1q3 H q0q3q4 D q0q1q2 F q1q2 I q0q1 K q2 M q0q3 J q3q4 G q0q1 K q0q1 K q0q3 J q1q2 I q4 L Q q3 N q2 M q1 O Q q3 N q4 L q0 P q1 O q0 P q2 M q0 P q3 N q1 O Q Q Q We use ll sttes tht contin q0 s ccepting sttes giving Where δ is s defined in the tle, we hve F = {A, B, C, D, F, H, J, K, P }. M = {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q}, {, }, δ, A, {A, B, C, D, F, H, J, K, P } Here is the digrm. Look how pretty it is! 4

H P Q C K F O I M Cn you find the oddity in this solution? I mde mistke in converting the NFA ut ws le to fix it y just simple deletion... Cn you see wht it is? Question 3. [25 pts.;,, c 5 pts; c 10 pts] Given lnguges L 1 = {w w {, }, w 3}, L 2 = {w w {, }, w contins },. Construct the digrms of the DFAs which ccept strings in the lnguges L 1 nd L 2. 5

. Construct the digrm of n NFA which ccepts strings in the lnguge L 1 L 2. 6

c. Convert the NFA to DFA, in the sme wy s in Question 2c. We define new initil stte sed on the ε-closure of the initil stte q0 giving q0q1q5. Now we lzily construct the trnsition tle. δ q0q1q5 A q2q5 B q2q6 C q2q5 B q3q5 D q3q6 E q2q6 C q3q5 D q3q7 F q3q5 D q4q5 G q4q6 H q3q6 E q4q5 G q4q7 I q3q7 F q4q7 I q4q7 I q4q5 G q4q5 G q4q6 H q4q6 H q4q5 G q4q7 I q4q7 I q4q7 I q4q7 I The ccepting sttes re those sttes tht re ccepted y either one mchine or the other. Tht would e ll the sttes tht include q4 or q7. Thus we hve F = {F, G, H, I} nd we cn define the entire mchine with δ from the trnsition tle ove. M = {A, B, C, D, E, F, G, H, I}, {, }, δ, A, {F, G, H, I} And the pretty picture, with no minimiztion... 7

d. Define new set of ccepting sttes tht will mke the DFA ccept strings in the lnguge L 1 L 2. Explin riefly the difference etween this new set of ccepting sttes nd the set defined in prt c. of this question. The set of ccepting sttes for the union of two DFAs is simply the set of ll sttes in the union which contin one of the ccepting sttes from the originl mchines. Formlly this is denoted F = {F 1 Q 2 Q 1 F 2 } For the intersection of two DFAs we wnt the ccepting sttes to e those sttes which include ccepting sttes from oth mchines. Formlly this would e F = {F 1 F 2 } In the cse of this specific prolem the new set of ccepting sttes would e F = {I}. Question 4. [25 pts; 7 pts; 18 pts.]. Descrie the lnguge ccepted y the following NFA: 8

This NFA ccepts ll strings over {, } tht egin with nd end with. This cn e descried y the regulr expression ( + ).. Prove tht this NFA ccepts the lnguge tht you descried in prt (). In your proof, use induction on the length of the input. Be sure to stte your induction hypothesis explicitly. Hint: You will use wht Hopcroft et l. cll mutul induction ( 1.4.4) (end of hint). We will complete this proof using mutul induction, where set of conditions is creted to descrie the ction of the mchine. This set of conditions will demonstrte tht the mchine ehves s descried ove. First, the three conditions. () q0 ˆδ(q0, w) w = ε. () q1 ˆδ(q0, w) w egins with (c) q2 ˆδ(q0, w) w egins with nd ends with Our tsk is to verify tht these conditions hold for ll input nd tht the pproprite input leds to cceptnce. Bse Cse For w = 0, we know the only string with mgnitude 0 is ε, so w = ε. () Becuse q0 is the initil stte of the mchine, nd there re no ε-trnsitions from q0, then q0 ˆδ(q0, w) so the left hnd side holds. Since w = ε, the right hnd side holds s well nd the iconditionl is true. 9

() Since there re no ε-trnsitions from the initil stte to q1, it follows tht q1 ˆδ(q0, w) nd the left hnd side is flse. It is cler tht w does not strt with nd so the right hnd side is flse s well. Therefore the iconditionl is true. (c) By the sme resoning s (), it follows tht condition (c) is lso true. Inductive Hypothesis Assume tht for w = n, ll three conditions hold. Inductive Step We now prove tht the three conditions hold for w = n + 1. Let w = xz where x = n nd z Σ. Thus w = x + 1 = n + 1. () There re no trnsitions into q0, so for ny w such tht w 1, q0 / ˆδ(q0, w) nd the left hnd side is flse. Since clerly w ε, the right hnd side is lso flse nd the iconditionl is true. () Consider the prefix string x. By the inductive hypothesis, ll the conditions hold for x, which mens tht condition () holds for x. This mens there re two cses to consider. The first, x strts with, mens tht q1 ˆδ(q0, x). Since there is trnsition from q1 to q1 on oth or, it does not mtter wht symol z is, it follows tht q1 ˆδ(q0, w). In this cse, no mtter wht z is, x will still strt with nd thus w will strt with. Thus the iconditionl will lwys e true. The second cse, x strts with, mens tht q1 / ˆδ(q0, x). Further, ecuse there is no trnsition out of q0 on, the mchine is stuck. Thus is does not mtter wht symol z is, it will lwys e the cse tht q1 / ˆδ(q0, w). Since x strts with it follows tht no mtter wht z is, w will lso strt with. Thus oth sides of the iconditionl will lwys e flse nd the iconditionl itself will lwys e true. (c) The only trnsition into q2 is on from q1. So ny cse which does not ensure q1 ˆδ(q0, x) implies tht q2 / ˆδ(q0, w) nd from condition () we know tht if x does not strt with then q1 / ˆδ(q0, x) nd it follows tht q2 / ˆδ(q0, w). Thus in this sitution, the iconditionl will lwys e true. Now consider the sitution where q1 ˆδ(q0, x). By the inductive hypothesis nd (), we know this implies tht x strts with. Here we hve two cses: z = nd z =. In the first cse, z =, it follows tht w ends with, nd not. Since there is no trnsition from q1 to q2 on n, then we cn conclude tht q2 / ˆδ(q0, w). Likewise, if q2 / ˆδ(q0, w) then we cn surmise tht the trnsition from q1 to q2 on ws not tken nd therefore, w does not end in. Thus the iconditionl is true in oth directions. In the second cse, z =, it follows tht w ends in. Since we know q1 ˆδ(q0, x) nd there is trnsition from q1 to q2 on, it follows tht q2 ˆδ(q0, w). Likewise, if q2 ˆδ(q0, w), since the only trnsition into q2 is from q1 on, then it follows tht w ends with. Agin the iconditionl is true in oth directions. Since in condition (c), it is required to pss through q1 to get to q2, nd q2 is the only ccepting stte of the mchine, it follows tht q1 ˆδ(q0, x) is necessry for cceptnce, 10

nd thus w must strt with. Agin, y condition (c), for q2 ˆδ(q0, w) to e true, then w must end with. Thus we show tht cceptnce y this mchine only occurs for strings tht strt with nd end with. I don t hold tht this proof is completely ullet-proof. If there re ny holes, plese feel free to point them out, nd I ll mke corrections. It is tricky there re lot of cses to consider ll the wy through. But hopefully, this proof illustrtes the process resonly well. 11