CSE Theory of Computing: Homework 3 Regexes and DFA/NFAs

Size: px
Start display at page:

Download "CSE Theory of Computing: Homework 3 Regexes and DFA/NFAs"

Transcription

1 CSE Theory of Computing: Homework 3 Regexes and DFA/NFAs Version 1: Fe. 6, 2018 Instructions Unless otherwise specified, all prolems from the ook are from Version 3. When a prolem in the International Edition is different from Version 3, the prolem will e listed as V3:x.yy/IE:x.zz, where x.zz is the euivalent numer. When Version 2 is different, it will e listed as V3:x.yy/V2:x.zz. If either IE or V2 do not have a matching numer, the prolem text will e duplicated. You can prepare your solutions however you like (handwriting, L A TEX, etc.), ut you must sumit them in legile PDF. You can scan written solutions on the printer in the ack of the classroom, or using a smartphone (with a scanner app like CamScanner). It is up to you to ensure that sumissions are legile. REMEMBER THAT IF WE CAN T READ IT OR SCAN IS CUT OFF, YOU DON T GET A GRADE FOR IT. The prolems marked as TEAM may e solved in a collaorative fashion with up to 2 other students. In such cases, your sumission should have the word TEAM at the start of the prolem, followed y the names of your collaorators (must e other students in this class). When such prolems are graded, the first sumission encountered y the grader for the team will e used for a common grade for all identified team memers. Please give every PDF file a uniue filename. If you re making a complete sumission (all prolems), name your PDF file netid-hw#.pdf, where netid is replaced with your NetID and # is the homework numer. If you re sumitting some prolems now and other prolems later, name your file netid-hw pdf, where is replaced with just the prolems you are sumitting now. This may e useful for team sumissions. If you use the same filename twice, only the most recent version will e graded. The time of sumission is the time the most recent file was uploaded. If you use L A TEX and want to draw something like a state diagram, consider using the tikz package. A reference document is on the wesite under Assignments. You may also find the wesite a useful tool for drawing state diagrams via drop and drag. It will output oth.png image files and latex in the tikz format. Sumit your PDF file in Sakai to the appropriate directory. Don t forget to click the Sumit (or Resumit) utton! Practice Prolems These prolems are from the ook, and most have solutions listed for them. They are listed here for you to practice on as needed and any answers you generate should not e sumitted. You are free to discuss these with others, ut you are not allowed to post solutions to any pulic forum Regex to NFA Regex to strings a DFA to regex regex to NFA 1

2 a,c Pumping Lemma a CLosure Book Exercises These prolems are found in the text ook and are to e answered and sumitted y each student. If they are not marked as TEAM, you are to solve them individually. If they are marked as TEAM you may sumit the same answer as the others in your team. In any case, use of solution manuals from any source or shared solutions is a violation of the ND Honor Code. You are also not allowed to show your solutions to another student not part of your TEAM. 1. (5pt) 1.12 Language to DFA and regular expression We are given the language: D = {w w contains an even numer of a s and an odd numer of s and does not contain the string a}. We are asked to give a DFA with 5 states that recognizes D and a regular expression that generates D. Right away we can note that we will never e ale to have an a followed y a ecause the sustring a will never e accepted. Using the formal definition of a DFA: (Q, Σ, δ, 0, F ) We can make the following DFA: Q = { 1, 2, 3, 4, 5 } Σ = {a, } 0 = 1 F = { 4 } δ = state a Based on this DFA, we can make the regex: ()*(aa)* 2. (TEAM-5pt) Book 1.19a. Regex to NFA 3. (5pt) Book Regex to NFA 4. (TEAM-5pt) V3:1-41;V2:1-41;IE: Show Closure. Hint Rememer that showing a language is regular is euivalent to showing how to construct a DFA/NFA for any language constructed from operator applied to a regular language. Assume M 1 = (Q 1, Σ, δ 1, s 1, F 1 ) accepts A and M 2 = (Q 2, Σ, δ 2, s 2, F 2 ) accepts B. We want to uild M that alternates etween M 1 and M 2. To do this define Q = Q 1 xq 2 x{1, 2} where the third component says are we looking at A or B. So states are now triples. Now δ(( 1, 2, 1), a) = (δ( 1, a), 2, 2) and δ(( 1, 2, 2), a) = ( 1, δ( 2, a), 1) s = (s 1, s 2, 1) F = {( 1, 2, 1)} where 1 is in F 1 and 2 is in F 2 5. (10pt - Part a only is TEAM) V3:1.46a,c; V2:1-46a,c;IE:11.51a,c. Use Pumping Lemma Part a. Try string 0 p 10 p. x must e 0 a for some a etween 0 and p 1, and y is 0 for some from 1 to p. Thus xy i z for i = 0 is 0 ( p )1o p where 1, which is not in L. Also, you could use i = 2 which yields 0 ( p + )10 p = 0 p 0 10 p, which again fails (0 1 is not a valid 1 m Part c. If a language is regular then so is its complement, and vice versa. So let s look at {w w is a palindrone }. Try the string 0 p 10 p. It does not pump. Non-ook Prolems The following prolems are not found in the text ook. If they are not marked as TEAM, you are to solve them individually. If they are marked as TEAM you may sumit the same answer as the 2

3 others in your team. Use of any resource you used other than the text ook or class notes must e cited. You are also not allowed to show your solutions to another student. 7. (TEAM - 5pt) Assume regular languages L 1 and L 2 are accepted y DFAs M 1 and M 2, where M 1 = (S, Σ, δ 1, s 1, F 1 ), S = {s 1,..., s n }, and M 2 = (R, Σ, δ 2, r 1, F 2 )., R = {r 1,..., r m }. Define L 3 = L 1 L 2 as {w w is in L 1 ut not in L 2 }. Show y construction of an NFA that L 3 is regular. Descrie informally how your construction works. We know that L 1 is regular so there exists a machine M 1 = (Q 1, Σ 1, δ 1, 01, F 1 ), and that L 2 is regular so there exists a machine M 2 = (Q 2, Σ 2, δ 2, 02, F 2 ). We define M 3 to e the product of M 1 and M 2 where the final states of M 3 are those states in M 3, ( i, j ) with i Q 1, j Q 2 s.t. ( i, j ) F 3 if i F 1 and j / F 2. What we mean y the product of two machines is that we take Q 1 Q 2 to e the states of the new machine. The start state is the tuple which has oth the start state of M 1 and the start state of M 2. The alphaet is simply the union of the two alphaets of the original machine, and the delta function does element-wise transition, similar to how the NFA to DFA construction works. Informally, this works y simultaneously checking oth machines since we have their product. When we are done, we simply check if we are in a final state of M 1 paired with not a final state of M 2. If oth were accepting, we reject. If neither were accepting, we still reject. And finally, if it was only accepted y M 2 we also reject. We get precisely the strings we desire. Remark Points No proof y construction (5pt) Show using the Pumping Lemma that the language L = {(a) n (cd) n n 0} is not regular. (Ryan Mackey) I will prove y contradiction that language L is not regular. Assume that language L is regular. Thus, L can e represented y DFA M where M = (Q, Σ, s, δ, F ). The amount of states in M is finite, so assume that ased on the pigeonhole principle and Q that the pumping length is p. Now consider a word x L of length greater than p. x can e written in the form x = uvw where uv p and v 1. Then for i Z, uv i L, according to the definition of regular languages. But if x = (a) p (cd) p, u and v will oth lie in the first half of the word (the a region). Thus, with an i = 2, x = (a) (p+v) (cd) p. x / L. This gives a contradiction and proves that language L is not regular. QED 9. (Team - 5 pt) For the following NFA compute the regular expression accepted y converting it to a GNFA and then using the CONVERT algorithm of from Lemma 1.60 on it. Show work. Feel free to use variales like R i to stand for intermediate expressions on an edge (with R i written out elow), ut show entire final answer. You don t need to simplify. a, p a, a, r s Figure 1: State diagram of NFA for uestion 6 Any DFA/NFA can e converted to a GNFA y adding a start state s and a new accepting state a and y making appropriate transitions such that a is the only accepting state. Then, the procedure to convert a k-state GNFA (G) to regular expression is given elow. CONVERT(G): 1. Let k e the numer of states of G 2. If k = 2, then G must consist of only a start state and an accepting state, with a single arrow connecting the states laeled with regular expression R. Return R. 3. If k > 2, we select any state rip different from s and a and let G e the GNFA (Q, Σ, s, δ, a ), where Q = Q { rip }, 3

4 and for any i Q { a } and any j Q { s }, let Step 1: Step 2: Step 3: Step 4: δ ( i, j ) = (R 1 )(R 2 ) (R 3 ) (R 4 ), for R 1 = δ( i, rip ), R 2 = δ( rip, rip ), R 3 = δ( rip, j ), R 4 = δ( i, j ). 4. Compute CONVERT(G ) and return the value. Starting from the given NFA N : (Q, Σ, 0, δ, F ), where Q = {p,, r, s}, Σ = {a, }, 0 = p, δ can e inferred from the state diagram in figure 1, F = {r, s}, we make a six-state GNFA G : (Q, Σ, 0, δ, F ) y adding a start ( s ) and an accepting state ( a ). Therefore, Q = { s, p,, r, s, a }, 0 = s, δ can e inferred from the figure 2, and F = { a }. We also convert the transitions to formal regular expressions. Since the G has more than 2 states, we need to remove a state rip which is different from s and a. Let rip = p. Thus, as per the CONVERT algorithm, we have i = s and j =. R 1 = δ( s, p) =, R 2 = δ(p, p) =, R 3 = δ(p, ) = and R 4 = δ( s, ) =. Thus, δ( s, ) = ()() () ( ) = () (). The state diagram of the reduced GNFA is given in figure 3. Since the G has more than 2 states, we need to remove a state rip which is different from s and a. Let rip =. Thus, as per the CONVERT algorithm, we have i = s and j = r. R 1 = δ( s, ) = () (), R 2 = δ(, ) =, R 3 = δ(, r) = and R 4 = δ( s, r) =. Thus, δ( s, r) = (() ())() () ( ) = (() ())(). The state diagram of the reduced GNFA is given in figure 4. Since the G has more than 2 states, we need to remove a state rip which is different from s and a. Let rip = s. Thus, as per the CONVERT algorithm, we have i = r and j = a. R 1 = δ(r, s) = (), R 2 = δ(s, s) =, R 3 = δ(s, a ) = and R 4 = δ(r, a ) =. Thus, δ(r, a ) = ()() () () = (). The state diagram of the reduced GNFA is given in figure 5. Step 5: Since the G has more than 2 states, we need to remove a state rip which is different from s and a. Let rip = r. Thus, as per the CONVERT algorithm, we have i = s and j = a. R 1 = δ( s, r) = (a ) ()(a ), R 2 = δ(r, r) =, R 3 = δ(r, a ) = (a ) and R 4 = δ( s, a ) =. Thus, δ( s, a ) = () ()()() (() ) ( ) = () ()()(() ). The state diagram of the reduced GNFA is given in figure 6. Step 6: Since the G has 2 states, the CONVERT algorithm terminates and returns δ( s, a ) = (a ) ()()(() ) as the reuired regular expression. Therefore, the reuired regular expression is () ()()(() ), representing the strings over the alphaet {a, } having a in either the second last or the third last position. s p r s a Figure 2: The GNFA G in step 1 s () () r s a - Figure 3: The GNFA G in step 2 4

5 () ()() s r s a Figure 4: The GNFA G in step 3 () ()() () s r a Figure 5: The GNFA G in step 4 s () ()()(() ) a Figure 6: The final GNFA 10. (5pt) Do the same as aove for the NFA in figure 7, i.e. compute the regex. Any DFA/NFA can e converted to a GNFA y adding a start state s and a new accepting state a and y making appropriate transitions such that a is the only accepting state. Then, the procedure to convert a k-state GNFA (G) to regular expression is given elow. CONVERT(G): 1. Let k e the numer of states of G 2. If k = 2, then G must consist of only a start state and an accepting state, with a single arrow connecting the states laeled with regular expression R. Return R. 3. If k > 2, we select any state rip different from s and a and let G e the GNFA (Q, Σ, s, δ, a ), where Q = Q { rip }, and for any i Q { a } and any j Q { s }, let δ ( i, j ) = (R 1 )(R 2 ) (R 3 ) (R 4 ), for R 1 = δ( i, rip ), R 2 = δ( rip, rip ), R 3 = δ( rip, j ), R 4 = δ( i, j ). 4. Compute CONVERT(G ) and return the value. Step 1: Starting from the given NFA N : (Q, Σ, 0, δ, F ), where Q = {p,, r}, Σ = {a, }, 0 = p, δ can e inferred from the state diagram in figure 7, F = {r}, we make a six-state GNFA G : (Q, Σ, 0, δ, F ) y adding a start ( s ) and an accepting state ( a ). Therefore, Q = { s, p,, r, a }, 0 = s, δ can e inferred from the figure 8, and F = { a }. We also convert the transitions to formal regular expressions. Step 2: Step 3: Since the G has more than 2 states, we need to remove a state rip which is different from s and a. Let rip = r. Thus, as per the CONVERT algorithm, we have i = {, p} and j = a. For i =, R 1 = δ(, r) =, R 2 = δ(r, r) =, R 3 = δ(r, a ) = and R 4 = δ(, a ) =. Thus, δ(, a ) = ()( ) () ( ) =. For i = p, R 1 = δ(p, r) = (c ), R 2 = δ(r, r) =, R 3 = δ(r, a ) = and R 4 = δ(p, a ) =. Thus, δ(p, a ) = (c )( ) () ( ) = c. The state diagram of the reduced GNFA is given in figure 9. Since the G has more than 2 states, we need to remove a state rip which is different from s and a. Let rip =. Thus, as per the CONVERT algorithm, we have i = p and j = {p, a }. 5

6 ,,c p r a,c c, Figure 7: NFA for prolem 7 Step 4: For j = p, R 1 = δ(p, ) = ( ), R 2 = δ(, ) = ( c), R 3 = δ(, p) = (a c) and R 4 = δ(p, p) =. Thus, δ(p, p) = ( )( c) (a c) ( ) = ( )( c) (a c). For j = a, R 1 = δ(p, ) = ( ), R 2 = δ(, ) = ( c), R 3 = δ(, a ) =, R 4 = δ(p, a ) = (c ). Thus, δ(p, a ) = ( )( c) () (c ). The state diagram of the reduced GNFA is given in figure 10. Since the G has more than 2 states, we need to remove a state rip which is different from s and a. Let rip = p. Thus, as per the CONVERT algorithm, we have i = s and j = a. Therefore, R 1 = δ( s, p) =, R 2 = δ(p, p) = ( )( c) (a c), R 3 = δ(p, a ) = ( )( c) () (c ), R 4 = δ( s, a ) =. Thus, δ( s, a ) = ()[( )( c) (a c)] ( )( c) () (c ) = [( )( c) (a c)] ( )( c) () (c ). The state diagram of the reduced GNFA is given in figure 11. Therefore, the reuired regular expression is [( )( c) (a c)] ( )( c) () (c ) c s p r a a c c Figure 8: The GNFA G in step 1 c s p a c a c Figure 9: The GNFA G in step 2 Reason Points Correct small rip 1 Two medium large rips 2 2 = 4 Transitions not regex 0.5 Not following CONVERT 5 Not adding the dummy start and end states 0.5 Tale 1: Ruric for prolem 7 - Note: the errors in the GNFA propagate through the steps. They will e penalized accordingly. 6

7 ( )( c) (a c) ( )( c) () (c ) s p a Figure 10: The GNFA G in step 3 s [( )( c) (a c)] ( )( c) () (c ) a Figure 11: The GNFA G in step 4 7

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES and REGULAR EXPRESSIONS TUESDAY Jan 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w has equal number

More information

Name: Student ID: Instructions:

Name: Student ID: Instructions: Instructions: Name: CSE 322 Autumn 2001: Midterm Exam (closed book, closed notes except for 1-page summary) Total: 100 points, 5 questions, 20 points each. Time: 50 minutes 1. Write your name and student

More information

10. The GNFA method is used to show that

10. The GNFA method is used to show that CSE 355 Midterm Examination 27 February 27 Last Name Sample ASU ID First Name(s) Ima Exam # Sample Regrading of Midterms If you believe that your grade has not been recorded correctly, return the entire

More information

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

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

1.3 Regular Expressions

1.3 Regular Expressions 51 1.3 Regular Expressions These have an important role in descriing patterns in searching for strings in many applications (e.g. awk, grep, Perl,...) All regular expressions of alphaet are 1.Øand are

More information

Theory of Computation (II) Yijia Chen Fudan University

Theory of Computation (II) Yijia Chen Fudan University Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest

More information

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

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

More information

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

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

CSE 355 Homework One Sample Solutions

CSE 355 Homework One Sample Solutions CSE 355 Homework One Sample Solutions Question Give a transition diagram and the transition table, for a DFA to recognize. Part (a) {w {, } : w contains an even number of s and an odd number of s} Solution:

More information

False. They are the same language.

False. They are the same language. CS 3100 Models of Computation Fall 2010 Notes 8, Posted online: September 16, 2010 These problems will be helpful for Midterm-1. More solutions will be worked out. The midterm exam itself won t be this

More information

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity. Midterm Exam CS 341-451: Foundations of Computer Science II Fall 2016, elearning section Prof. Marvin K. Nakayama Print family (or last) name: Print given (or first) name: I have read and understand all

More information

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

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

M = (Q,Σ,δ,q 0,F) Σ is the alphabet over which the transitions are defined.

M = (Q,Σ,δ,q 0,F) Σ is the alphabet over which the transitions are defined. LECTURE 23 10.1 Formal Definition of a DFA Definition 10.1 A Deterministic Finite Automaton (DFA) M, is a five-tuple: where M = (Q,Σ,δ, 0,F) Q is a finite set of states. It is important that the set of

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION FORMAL LANGUAGES, AUTOMATA AND COMPUTATION IDENTIFYING NONREGULAR LANGUAGES PUMPING LEMMA Carnegie Mellon University in Qatar (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

Lecture 4: More on Regexps, Non-Regular Languages

Lecture 4: More on Regexps, Non-Regular Languages 6.045 Lecture 4: More on Regexps, Non-Regular Languages 6.045 Announcements: - Pset 1 is on piazza (as of last night) - If you don t have piazza access but are registered for 6.045, send email to TAs with

More information

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

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

CSC236 Week 11. Larry Zhang

CSC236 Week 11. Larry Zhang CSC236 Week 11 Larry Zhang 1 Announcements Next week s lecture: Final exam review This week s tutorial: Exercises with DFAs PS9 will be out later this week s. 2 Recap Last week we learned about Deterministic

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation 1/26/2016 LECTURE 5 Last time: Closure properties. Equivalence of NFAs, DFAs and regular expressions Today: Conversion from NFAs to regular expressions Proving that a language

More information

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

CSE 105 Homework 3 Due: Monday October 23, Instructions. should be on each page of the submission. CSE 5 Homework 3 Due: Monday October 23, 27 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

More information

CSE 105 Homework 5 Due: Monday November 13, 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. CSE 05 Homework 5 Due: Monday November 3, 207 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

More information

V Honors Theory of Computation

V Honors Theory of Computation V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant

More information

TDDD65 Introduction to the Theory of Computation

TDDD65 Introduction to the Theory of Computation TDDD65 Introduction to the Theory of Computation Lecture 2 Gustav Nordh, IDA gustav.nordh@liu.se 2012-08-31 Outline - Lecture 2 Closure properties of regular languages Regular expressions Equivalence of

More information

CS 4120 Lecture 3 Automating lexical analysis 29 August 2011 Lecturer: Andrew Myers. 1 DFAs

CS 4120 Lecture 3 Automating lexical analysis 29 August 2011 Lecturer: Andrew Myers. 1 DFAs CS 42 Lecture 3 Automating lexical analysis 29 August 2 Lecturer: Andrew Myers A lexer generator converts a lexical specification consisting of a list of regular expressions and corresponding actions into

More information

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

Please give details of your calculation. A direct answer without explanation is not counted. Please give details of your calculation. A direct answer without explanation is not counted. Your answers must be in English. Please carefully read problem statements. During the exam you are not allowed

More information

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

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

Exam 1 CSU 390 Theory of Computation Fall 2007

Exam 1 CSU 390 Theory of Computation Fall 2007 Exam 1 CSU 390 Theory of Computation Fall 2007 Solutions Problem 1 [10 points] Construct a state transition diagram for a DFA that recognizes the following language over the alphabet Σ = {a, b}: L 1 =

More information

Computational Models: Class 3

Computational Models: Class 3 Computational Models: Class 3 Benny Chor School of Computer Science Tel Aviv University November 2, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

front pad rear pad door

front pad rear pad door front pad rear pad door REAR BOTH NEITHER closed FRONT open FRONT REAR BOTH NEITHER Think of this as a simple program that outputs one of two values (states) when provided with the current state and an

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

Finite Automata (contd)

Finite Automata (contd) Finite Automata (contd) CS 2800: Discrete Structures, Fall 2014 Sid Chaudhuri Recap: Deterministic Finite Automaton A DFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a fnite set of states Σ is a fnite input

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

Plan for Today and Beginning Next week (Lexical Analysis)

Plan for Today and Beginning Next week (Lexical Analysis) Plan for Today and Beginning Next week (Lexical Analysis) Regular Expressions Finite State Machines DFAs: Deterministic Finite Automata Complications NFAs: Non Deterministic Finite State Automata From

More information

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES nd REGULAR EXPRESSIONS TUESDAY Jn 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w hs equl numer of

More information

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 Theory of Computation   Professor Jeanne Ferrante CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Announcement & Reminders HW 2: Grades not available yet, will be soon Solutions posted, read even if you did well

More information

CS 420, Spring 2018 Homework 4 Solutions. 1. Use the Pumping Lemma to show that the following languages are not regular: (a) {0 2n 10 n n 0};

CS 420, Spring 2018 Homework 4 Solutions. 1. Use the Pumping Lemma to show that the following languages are not regular: (a) {0 2n 10 n n 0}; CS 420, Spring 2018 Homework 4 Solutions 1. Use the Pumping Lemma to show that the following languages are not regular: (a) {0 2n 10 n n 0}; Solution: Given p 1, choose s = 0 2p 10 p. Then, s is in the

More information

CS 154 Introduction to Automata and Complexity Theory

CS 154 Introduction to Automata and Complexity Theory CS 154 Introduction to Automata and Complexity Theory cs154.stanford.edu 1 INSTRUCTORS & TAs Ryan Williams Cody Murray Lera Nikolaenko Sunny Rajan 2 Textbook 3 Homework / Problem Sets Homework will be

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

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

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission. 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

More information

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018 CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26 Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts

More information

Proving languages to be nonregular

Proving languages to be nonregular Proving languages to be nonregular We already know that there exist languages A Σ that are nonregular, for any choice of an alphabet Σ. This is because there are uncountably many languages in total and

More information

Finite Automata and Languages

Finite Automata and Languages CS62, IIT BOMBAY Finite Automata and Languages Ashutosh Trivedi Department of Computer Science and Engineering, IIT Bombay CS62: New Trends in IT: Modeling and Verification of Cyber-Physical Systems (2

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.4 Explain the limits of the class of regular languages Justify why the

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

Theory of Computation (I) Yijia Chen Fudan University

Theory of Computation (I) Yijia Chen Fudan University Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael

More information

CSE 311: Foundations of Computing. Lecture 25: Languages vs Representations: Limitations of Finite Automata and Regular Expressions

CSE 311: Foundations of Computing. Lecture 25: Languages vs Representations: Limitations of Finite Automata and Regular Expressions CSE 311: Foundations of Computing Lecture 25: Languages vs Representations: Limitations of Finite Automata and Regular Expressions Last time: NFA to DFA 0 a,b 0,1 a 1 0 1 0 c 1 0 0,1 NFA b ɛ 0 c b,c 1

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions

More information

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. UNIT 2 Structure NON-DETERMINISTIC FINITE AUTOMATA

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 1.4 Give an example of a non-regular language Outline two strategies for proving

More information

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA) Deterministic Finite Automata Non deterministic finite automata Automata we ve been dealing with have been deterministic For every state and every alphabet symbol there is exactly one move that the machine

More information

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

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages CSci 311, Models of Computation Chapter 4 Properties of Regular Languages H. Conrad Cunningham 29 December 2015 Contents Introduction................................. 1 4.1 Closure Properties of Regular

More information

LING/C SC/PSYC 438/538. Lecture 17 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 17 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong Today's Topic Review of ungraded homework Closure properties of FSA Practice! Homework out on Thursday From last time Ungraded Homework 6 apply the set-of-states

More information

Chapter 6. Properties of Regular Languages

Chapter 6. Properties of Regular Languages Chapter 6 Properties of Regular Languages Regular Sets and Languages Claim(1). The family of languages accepted by FSAs consists of precisely the regular sets over a given alphabet. Every regular set is

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Today's learning goals Sipser Ch 1.4 Explain the limits of the class of regular languages Justify why the Pumping

More information

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text On the menu today jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text 1 jflap Demo jflap: Useful tool for creating and testing abstract machines Finite automata,

More information

Finite Automata and Regular Languages (part II)

Finite Automata and Regular Languages (part II) Finite Automata and Regular Languages (part II) Prof. Dan A. Simovici UMB 1 / 25 Outline 1 Nondeterministic Automata 2 / 25 Definition A nondeterministic finite automaton (ndfa) is a quintuple M = (A,

More information

Building a befer mousetrap. Transi-on Graphs. L = { abba } Building a befer mousetrap. L = { abba } L = { abba } 2/16/15

Building a befer mousetrap. Transi-on Graphs. L = { abba } Building a befer mousetrap. L = { abba } L = { abba } 2/16/15 Building a efer mousetrap Let s uild an FA that only accepts the string aa from Σ = { a } Models of Computa-on Lecture #5 (a?er quiz) Chapter 6 Building a efer mousetrap Let s uild an FA that only accepts

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automata (FA or DFA) CHAPTER Regular Languages Contents definitions, examples, designing, regular operations Non-deterministic Finite Automata (NFA) definitions, euivalence of NFAs and DFAs, closure

More information

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

Formal Languages, Automata and Models of Computation

Formal Languages, Automata and Models of Computation CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2011 1 Content - More Properties of Regular Languages (RL)

More information

Homework Assignment 6 Answers

Homework Assignment 6 Answers Homework Assignment 6 Answers CSCI 2670 Introduction to Theory of Computing, Fall 2016 December 2, 2016 This homework assignment is about Turing machines, decidable languages, Turing recognizable languages,

More information

CS243, Logic and Computation Nondeterministic finite automata

CS243, Logic and Computation Nondeterministic finite automata CS243, Prof. Alvarez NONDETERMINISTIC FINITE AUTOMATA (NFA) Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ Maloney Hall, room 569 alvarez@cs.bc.edu Computer Science Department voice: (67) 552-4333

More information

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10 Regular Languages Andreas Karwath & Malte Helmert 1 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages

More information

CSCI3390-Assignment 2 Solutions

CSCI3390-Assignment 2 Solutions CSCI3390-Assignment 2 Solutions due February 3, 2016 1 TMs for Deciding Languages Write the specification of a Turing machine recognizing one of the following three languages. Do one of these problems.

More information

CSCE 551 Final Exam, Spring 2004 Answer Key

CSCE 551 Final Exam, Spring 2004 Answer Key CSCE 551 Final Exam, Spring 2004 Answer Key 1. (10 points) Using any method you like (including intuition), give the unique minimal DFA equivalent to the following NFA: 0 1 2 0 5 1 3 4 If your answer is

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 28 2017 Part 2 out of 5 Last week was all about Deterministic Finite Automaton

More information

CSE 355 Test 2, Fall 2016

CSE 355 Test 2, Fall 2016 CSE 355 Test 2, Fall 2016 28 October 2016, 8:35-9:25 a.m., LSA 191 Last Name SAMPLE ASU ID 1357924680 First Name(s) Ima Regrading of Midterms If you believe that your grade has not been added up correctly,

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2 5-25 Great Theoretical Ideas in Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 January 26th, 27 Formal definition: DFA A deterministic finite automaton (DFA) M =(Q,,,q,F) M is

More information

ECS 120 Lesson 15 Turing Machines, Pt. 1

ECS 120 Lesson 15 Turing Machines, Pt. 1 ECS 120 Lesson 15 Turing Machines, Pt. 1 Oliver Kreylos Wednesday, May 2nd, 2001 Before we can start investigating the really interesting problems in theoretical computer science, we have to introduce

More information

1. Induction on Strings

1. Induction on Strings CS/ECE 374: Algorithms & Models of Computation Version: 1.0 Fall 2017 This is a core dump of potential questions for Midterm 1. This should give you a good idea of the types of questions that we will ask

More information

Non-regular languages

Non-regular languages Non-regular languages (Pumping Lemma) Fall 2017 Costas Busch - RPI 1 Non-regular languages { a n n : n 0} { vv R : v{ a, }*} Regular languages a* * c a c( a )* etc... Fall 2017 Costas Busch - RPI 2 How

More information

CS500 Homework #2 Solutions

CS500 Homework #2 Solutions CS500 Homework #2 Solutions 1. Consider the two languages Show that L 1 is context-free but L 2 is not. L 1 = {a i b j c k d l i = j k = l} L 2 = {a i b j c k d l i = k j = l} Answer. L 1 is the concatenation

More information

ECS120 Fall Discussion Notes. October 25, The midterm is on Thursday, November 2nd during class. (That is next week!)

ECS120 Fall Discussion Notes. October 25, The midterm is on Thursday, November 2nd during class. (That is next week!) ECS120 Fall 2006 Discussion Notes October 25, 2006 Announcements The midterm is on Thursday, November 2nd during class. (That is next week!) Homework 4 Quick Hints Problem 1 Prove that the following languages

More information

CpSc 421 Final Exam December 15, 2006

CpSc 421 Final Exam December 15, 2006 CpSc 421 Final Exam December 15, 2006 Do problem zero and six of problems 1 through 9. If you write down solutions for more that six problems, clearly indicate those that you want graded. Note that problems

More information

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1 Properties of Regular Languages BBM 401 - Automata Theory and Formal Languages 1 Properties of Regular Languages Pumping Lemma: Every regular language satisfies the pumping lemma. A non-regular language

More information

Closure under the Regular Operations

Closure under the Regular Operations Closure under the Regular Operations Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have

More information

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama Print family (or last) name: Print given (or first) name: I have read and understand

More information

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

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010 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

More information

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

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA) Languages Non deterministic finite automata with ε transitions Recall What is a language? What is a class of languages? Finite Automata Consists of A set of states (Q) A start state (q o ) A set of accepting

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

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

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet: Languages 1 Languages A language is a set of strings String: A sequence of letters Examples: cat, dog, house, Defined over an alphaet: a,, c,, z 2 Alphaets and Strings We will use small alphaets: Strings

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

Section 1 (closed-book) Total points 30

Section 1 (closed-book) Total points 30 CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes

More information

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

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata : Organization of Programming Languages Theory of Regular Expressions Finite Automata Previous Course Review {s s defined} means the set of string s such that s is chosen or defined as given s A means

More information

CSE 355 Homework Two Solutions

CSE 355 Homework Two Solutions CSE 355 Homework Two Solution Due 2 Octoer 23, tart o cla Pleae note that there i more than one way to anwer mot o thee quetion. The ollowing only repreent a ample olution. () Let M e the DFA with tranition

More information

Text Search and Closure Properties

Text Search and Closure Properties Text Search and Closure Properties CSCI 330 Formal Languages and Automata Theory Siu On CHAN Fall 208 Chinese University of Hong Kong /28 Text Search grep program grep -E regex file.txt Searches for an

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

(Refer Slide Time: 0:21)

(Refer Slide Time: 0:21) Theory of Computation Prof. Somenath Biswas Department of Computer Science and Engineering Indian Institute of Technology Kanpur Lecture 7 A generalisation of pumping lemma, Non-deterministic finite automata

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

COM364 Automata Theory Lecture Note 2 - Nondeterminism

COM364 Automata Theory Lecture Note 2 - Nondeterminism COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly

More information

Chapter Five: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more

More information