CSE396 Prelim I Answer Key Spring 2017

Similar documents
Homework 3 Solutions

1 Nondeterministic Finite Automata

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

Improper Integrals. The First Fundamental Theorem of Calculus, as we ve discussed in class, goes as follows:

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

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

Lecture 08: Feb. 08, 2019

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Minimal DFA. minimal DFA for L starting from any other

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

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

Finite Automata-cont d

Convert the NFA into DFA

First Midterm Examination

First Midterm Examination

Some Theory of Computation Exercises Week 1

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

Designing finite automata II

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

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.

Name Ima Sample ASU ID

State Minimization for DFAs

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

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

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

Formal Languages and Automata

1 From NFA to regular expression

Bases for Vector Spaces

Harvard University Computer Science 121 Midterm October 23, 2012

2.4 Linear Inequalities and Interval Notation

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

Let's start with an example:

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

Formal languages, automata, and theory of computation

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.

Lecture 3: Equivalence Relations

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

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

Worked out examples Finite Automata

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.

Theory of Computation Regular Languages

CS 330 Formal Methods and Models

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

Lecture 2e Orthogonal Complement (pages )

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

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

p-adic Egyptian Fractions

Lecture 09: Myhill-Nerode Theorem

Parse trees, ambiguity, and Chomsky normal form

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

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

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CMSC 330: Organization of Programming Languages

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

CS 330 Formal Methods and Models

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

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

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.

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

10. AREAS BETWEEN CURVES

GNFA GNFA GNFA GNFA GNFA

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

3 Regular expressions

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

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

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

Handout: Natural deduction for first order logic

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

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

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

Linear Systems with Constant Coefficients

Lexical Analysis Finite Automate

The Regulated and Riemann Integrals

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

CSCI FOUNDATIONS OF COMPUTER SCIENCE

Coalgebra, Lecture 15: Equations for Deterministic Automata

Nondeterminism and Nodeterministic Automata

CS 330 Formal Methods and Models

Deterministic Finite Automata

Duality # Second iteration for HW problem. Recall our LP example problem we have been working on, in equality form, is given below.

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

7. Indefinite Integrals

Designing Information Devices and Systems I Spring 2018 Homework 7

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

Quadratic Forms. Quadratic Forms

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

CM10196 Topic 4: Functions and Relations

Infinite Geometric Series

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

Lecture 2 : Propositions DRAFT

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

CHAPTER 1 Regular Languages. Contents

Name Solutions to Test 3 November 8, 2017

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

SWEN 224 Formal Foundations of Programming WITH ANSWERS

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

Transcription:

Nme nd St.ID#: CSE96 Prelim I Answer Key Spring 2017 (1) (24 pts.) Define A to e the lnguge of strings x {, } such tht x either egins with or ends with, ut not oth. Design DFA M such tht L(M) = A. A node-rc digrm tht shows the strt nd finl sttes clerly is good enough, plus the correctness of your M must e cler either from your theoreticl technique or from strtegic comments on how M works. Answer: First let us design DFA M 1 for the ends with property: strt 1 2 Now tke M 1 to e complementry mchine in which sttes 1 nd 2 re ccepting nd stte is not. We design M to hve two non-ccepting sttes s nd p plus copy of ech mchine, for 8 sttes in ll. At s, if the first chr of the input x is then we know it didn t strt with, so y the XOR we need x to end in. Since we lredy hve one, the rc goes to stte 2 of M 1, not stte 1. If x egins with n then we go to stte p. At p, if we then get we know gin tht x doesn t strt with, nd we re ctully in the sme sitution s when x egins with, so we go to stte 2 of M 1. If we get n t stte p, then tht s the second t the strt, so we shift mode into not wnting to end in. So we go to the strt stte 1 of the complementry mchine M 1. Tht completes M such tht L(M) = A nd lso its verifiction: p 1 2 strt s 1 2

The other good wy ws to drw second smll DFA M 2 such tht L(M 2 ) = ( ) nd then mke M to e the Crtesin product of M 1 nd M 2 using XOR. M 2 is in some wys simpler to drw thn M 1 ut it hs ded stte which techniclly mkes 4 sttes totl nd since the processing hs to go on even fter the prt is ded you cn t mke it ded stte for ll of M. So you re doing 4 Crtesin product which could mke you lile for 12 sttes, ut if you crry it out in n economicl s-needed mnner then you get the sme 8 sttes s ove. Let s cll the sttes of M 2 s s 2, q 2, r 2, d 2 to go with 1, 2, for M 1 s ove. With Crtesin lels, the sttes 1, 2, in the ove digrm ecome (1, d 2 ), (2, d 2 ), (, d 2 ) since they re pired with the ded stte of M 1. And s = (1, s 2 ) since it is the strt stte of oth mchines, nd p = (1, q 2 ). Then 1 = (1, r 2 ) nd since r 2 is nirvn stte of M 2, the remining lels re 2 = (2, r 2 ) nd = (, r 2 ). The finl sttes re (, d), (1, r 2 ), nd (2, r 2 ), eing the rechle sttes tht hve either from M 1 or r 2 from M 2, ut not oth. (2) (18 + + 6 = 27 pts.) Let N = (Q, Σ, δ, s, F ) e the NFA with Q = { 1, 2, }, Σ = {, }, s = 1, F = { }, nd δ given y the rcs (1, ɛ, ), (1,, 1), (1,, 2), (2,, 1), (2,, ), nd (,, 2), shown y: ɛ 1 2 () Clculte DFA M such tht L(M) = L(N) (no comments needed if the method is cler). () Find string x such tht N cn process x from 1 to ny one of its three sttes figurtively speking, such tht x lights up ll three sttes of N. (c) Are there strings w tht N cnnot process t ll, so tht N dies? Most in prticulr, cn w hve the form xz tht is, egin with your string x from prt () which turned ll sttes on? Answer: The ɛ-rc gives us Whenever 1, then lso nd in prticulr mkes the strt stte of the DFA e {1, } not just {1}. This is crucil ecuse ɛ elongs to L(N) ut we need the to recognize tht the strt stte of M is ccepting. Strting this wy lso lets us henceforth only hve to worry out triling ɛ s y the Romn soldier resoning in lecture. We cn thus mke tle tht is IMHO more useful thn wht the text does: δ ) = {1, 2, } δ (1, ) = (1, δ ) = {1, } δ (2, ) = {} (2, δ ) = δ (, ) = {2}. (, Doing redth-first serch from S = {1, } then gives us: (S, ) = δ (1, ) δ (, ) = {1, 2, } = {1, 2, } (S, ) = δ (1, ) δ (, ) = {2} = {2}.

Notice we lredy lit ll the lights on n. Since we got there on n, we utomticlly know tht ({1, 2, }, ) = {1, 2, }, ut this need not e true of ({1, 2, }, ). Indeed, we get ({1, 2, }, ) = δ (1, ) δ (2, ) δ (1, ) = {} {2} = {2, } only, which is wht egins the long decline nd ultimte fll of the Nondeterministic Empire. Soldiering on with redth-first serch, we need to expnd the new sttes {2} nd {2, }. We get: ({2}, ) = δ (2, ) = {1, } (ck to strt) ({2}, ) = δ (2, ) = {} (ut this counts s new) ({2, }, ) = δ (2, ) δ (, ) = {1, } = {1, } ({2, }, ) = δ (2, ) δ (, ) = {} {2} = {2, } (not new) ({}, ) = δ (, ) = (our 6th stte ut it s ded) ({}, ) = δ (, ) = {2} (not new). Since we utomticlly know (, ) = (, ) =, we re done we ve closed the mchine M. The finl sttes of M re everything with so we get: strt {1, } {1, 2, } {2, }, {2} {} Note we lredy nswered prt () with x =. For (c) note from the DFA digrm tht there is long nd tortuous pth from the ll-on stte {1, 2, } to the ded stte in five steps processing z =. This mkes xz = unprocessle y N. The shortest dying string from the strt is, ut hs the extr insult-plus-injury of first turning ll the sttes on. (Grding ws 4 points for w = ut xz = (or the equivlent) needed for the full 6 points.) () (5 5 = 25 pts.) Multiple Choice. Note the first three questions refer to the NFA N in prolem (2). 1. When we eliminte stte 2 from the NFA N in prolem (2), we need to updte which items involving only sttes 1 nd : () Just the two rcs in the digrm, (1,, 1) nd (1, ɛ, ). () Besides those two rcs, we need to dd self-loop (,, ), ut nothing from ck to 1. (c) Becuse stte 2 hs incoming nd outgoing rcs from oth 1 nd, we need to updte 2 2 = 4 entries. (d) Becuse of the ɛ-rc, we cn just comine the sttes 1 nd together, getting simple 1-stte GNFA fter eliminting stte 2.

Answer: (c). 2. Regrding the lnguges L 1,1 nd L 1, of N whether efore or fter eliminting stte 2 it doesn t mtter which of the following is true for this prticulr mchine? () L 1,1 L 1,. () L(N) = L 1,1 L 1,. (c) L 1,1 contins ( ), which simplifies to. (d) All of the ove. Answer: (d) All of the ove. Prt () comes ecuse of the ɛ-rrow it isn t true in generl nd () follows from tht nd the fct tht L(N) = L 1, y definition. When you crry out the step of of eliminting stte 2 ove, you get loop on s well s the originl loop on t stte 1. Since the -loop cn e simulted y two go-rounds of the -loop, which is nother wy of sying (), you cn just discrd it, which mens ( ) =. And ws lredy prt of L 1,1.. A vlid regulr expression for L(N) is: () ( ( ɛ)() ) (ɛ )(). () ( ) since stte 1 could e ccepting too. (c) ( ) since N ccepts ll even-length strings. (d) ( () ) (). Answer: Without going through the whole NFA-to-regesx exercise, we cn eliminte () ecuse ( ) is ll strings nd we know there re strings tht N rejects. And we cn eliminte (c) ecuse we found n odd-length string tht N ccepts (nd N doesn t ccept ll even-length strings nywy, it s fke news ). Tht leves () versus (d), oth of which look close. Well, the troule with (d) is tht the prt in the middle is mde mndtory, which rules out not only ɛ ut lso the ll-lights-on string s possiilities. Hence it s too strict. Item () hppens to e right ut there re unch of other right ones including tking the hint from 2(c) nd simplifying it to ( () ) (ɛ )(). 4. The symmetric difference of lnguge A with its complement à in Σ lwys equls: (). () { ɛ }. (c) A. (d) A no wit! Σ. Answer: Well, I intended to mke question whose nswer ws, ut this wsn t it correct is Σ. One might sy (d) ws closest ut CSE96 isn t horseshoes or tom oms, so ny nswer hd to e ccepted nd this ecme free 5 points. 5. For generl lnguge L, the reltion x L y when xy L is: () An equivlence reltion. () Reflexive nd symmetric, ut not trnsitive. (c) Symmetric, ut not reflexive or trnsitive. (d) Neither reflexive, symmetric, nor trnsitive (in generl).

Answer: Consider L = {, }. Since L hs no doule words, there is no string x such tht xx L, so x L x never hppens, so the reltion is s irreflexive s cn e. Nor is it symmetric, ecuse L ut not vice-vers (likewise L ut not vice-vers). This lredy torpedos (,,c) ut let s consider trnsitive : We hve L nd L, ut not L ecuse / L. So the nswer is (d). Very few got this; so mny sid () tht this ecme n instnce of ewring rosy expecttions in fvor of colf logic which is one of the ulterior messges of the course. [This, the xz prt of 2(c), prt (c) ove, nd getting prolem 4 exctly right were the min A-level points on the grding scheme, plus the points for comments/strtegy in prolem 1. In fct, prolem 1 hd scores verging 2- points lower thn expected, ut the freeie on (d) offset this so the difficulty tuning for the pre-set curve ws pretty-much on-trget.] (4) (24 pts.) Over Σ = {0, 1}, define L = { x : #00(x) = #10(x) }. Recll from Prolem Set 4 tht for ny u, x Σ, #u(x) is the numer of times u occurs s sustring of x, counting occurrences tht overlp. Prove vi the Myhill-Nerode technique tht L is not regulr lnguge. Answer: Tke S = (00), which is clerly infinite. Let ny x, y S (x y) e given. Then there re numers m, n 0 such tht x = (00) m nd y = (00) n. (We could lso postulte m < n without loss of generlity ut we won t need this.) Consider tking, ummm..., z = (10) m Then xz = (00) m (10) m which looks like it is in L, ut wit ecuse of the overlps string like w = (00) 2 (10) 2 = 00001010 hs #00(w) = #00(x) =, not 2, which #10(w). So we ctully need to tke z = (10) 2m 1 to mke xz L. Then yz = (00) n (10) 2m 1 nd since #00(yz) = 2n 1 2m 1 = #10(yz), we do get yz / L. Since x, y S re ritrry, S is PD for L, nd since S is infinite, L is not regulr y the Myhill-Nerode Theorem. Except there s one little niggle: tking S = (00) llows m = 0, ut wht does z = (10) 2m 1 ) men when m = 0? It sys (10) 1 ut we don t hve negtive powers of strings. If we stipulte tht it mens ɛ then we re still OK since then xz = ɛ ɛ = ɛ nd ɛ L. But we cn totlly void this onoxious edge cse y tking S = (00) + insted. Then we get m, n 1 nd the ove proof ecomes irtight. We cn lso tke S = 0 + = 00 (note tht 00 is not the sme s (00), which ws n unforseen error). Then when we let ny x, y S e given we get x = 0 m+1 nd y = 0 n+1 with n m. Then we cn exctly sy #00(x) = m nd tke z = (01) m fter ll. This ws nother completely-correct nswer given y severl. [Most, however, did the simple xz = (00) m (10) m thing nd fell victim to opticl ppernces to sy xz L, forgetting the overlps. This ws 4-point deduction, mitigted to if there ws some ttempt to justify with ecuse nd something tngile, not just sying xz L nd moving on. The A-level points were reckoned s on prolem 1, 2 on 2, 8 for (c) nd (e) not 10 ecuse 2 pts. prt credit ws given for nswering d on (c) nd 4 here, mking 17, ut I figured prolem 1 rought more ecuse it ws little longer thn comprle prolems in pst yers, so tht mde the usul 20 out of 100.] End of Exm