Figure 1: NFA N. Figure 2: Equivalent DFA N obtained through function nfa2dfa

Similar documents
False. They are the same language.

CS 322 D: Formal languages and automata theory

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

CS 154, Lecture 3: DFA NFA, Regular Expressions

Theory of Computation Prof. Raghunath Tewari Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Exam 1 CSU 390 Theory of Computation Fall 2007

Uses of finite automata

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

CMSC 330: Organization of Programming Languages

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

Nondeterministic Finite Automata and Regular Expressions

CS 133 : Automata Theory and Computability

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

Name: Student ID: Instructions:

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 311 Lecture 25: Relating NFAs, DFAs, and Regular Expressions. Emina Torlak and Kevin Zatloukal

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

Theory of Computation

Regular expressions and Kleene s theorem

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

CS 455/555: Finite automata

TDDD65 Introduction to the Theory of Computation

CS375 Midterm Exam Solution Set (Fall 2017)

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

CS311 Computational Structures Regular Languages and Regular Expressions. Lecture 4. Andrew P. Black Andrew Tolmach

Closure under the Regular Operations

Theory of Computation

CMPSCI 250: Introduction to Computation. Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013

Recap from Last Time

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

Deterministic Finite Automaton (DFA)

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

Chapter 6: NFA Applications

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

A non-turing-recognizable language

Regular Expressions [1] Regular Expressions. Regular expressions can be seen as a system of notations for denoting ɛ-nfa

Lecture 2: Connecting the Three Models

Closure Properties of Regular Languages

Finite-State Machines (Automata) lecture 12

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

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

CSE 355 Homework One Sample Solutions

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Regular languages, regular expressions, & finite automata (intro) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

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

COMP4141 Theory of Computation

Foundations of

1. Induction on Strings

Nondeterministic Finite Automata

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

Sri vidya college of engineering and technology

Author: Vivek Kulkarni ( )

10. The GNFA method is used to show that

Kleene Algebras and Algebraic Path Problems

Inf2A: Converting from NFAs to DFAs and Closure Properties

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

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

CSCI 340: Computational Models. Regular Expressions. Department of Computer Science

Author: Vivek Kulkarni ( )

Regular expressions and Kleene s theorem

Regular expressions and Kleene s theorem

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

Theory of Languages and Automata

CS 455/555: Mathematical preliminaries

Nondeterministic Finite Automata

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

Lecture 3: Nondeterministic Finite Automata

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

CSE 105 THEORY OF COMPUTATION

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

CDM Closure Properties

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

Sample Midterm. Understanding the questions is part of the exam; you are not allowed to ask questions during the exam.

Theory of Computation (II) Yijia Chen Fudan University

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions

More Properties of Regular Languages

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

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

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

Applied Computer Science II Chapter 1 : Regular Languages

front pad rear pad door

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

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

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Theory of Computation (I) Yijia Chen Fudan University

Regular Expressions and Language Properties

Formal Languages, Automata and Models of Computation

CPS 220 Theory of Computation REGULAR LANGUAGES

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

CONCATENATION AND KLEENE STAR ON DETERMINISTIC FINITE AUTOMATA

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

What we have done so far

Section 1 (closed-book) Total points 30

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

Nondeterministic finite automata

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

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

CS 154 Formal Languages and Computability Assignment #2 Solutions

Transcription:

CS 3100 Models of Computation Fall 2011 FIRST MIDTERM CLOSED BOOK 100 points I ve standardized on @ for representing Epsilons in all my figures as well as my code (liked equally by dot and our Python programs). 1. (20 pts) Convert this NFA N into an equivalent DFA D Figure 1: NFA N Answer: See Figure 2. Figure 2: Equivalent DFA N obtained through function nfa2dfa 2. (25 pts) Using the GNFA method, convert N into an equivalent RE R. Eliminate states in the order S3, S1, S4, S2, S0. Answer: See Figures 4 through 9. The RE can be read off Figure 9. To further validate that this RE is correct, we provide Figures 10 which turns this RE into an NFA using function re2nfa in reparse.py, and then 11 using re2dfa, and finally 12 using re2mindfa. 1

Figure 3: NFA N repeated for your convenience the final RE is (ab)* (a+ab+bb) 3. (25 pts) Minimize this DFA, showing the steps. Figure 4: Initial GNFA obtained through mk gnfa N Show your minimization table with its X n entries for n = 0, 1, 2,... here. Also draw the minimized DFA on this page. Answer: The minimization is straightforward (ask us if you are unsure). The table of minimization is as shown in Figure 14. See Figure 15 and 16 for the minimized DFAs (the latter showing the merged equivalence classes). 4. (3 pts) What is list(map(lambda y:2*y, map(lambda x:x+1, [30, 21, 31]))) Answer: [62, 44, 64] 5. (3 pts) What is the concatenation of {a, ab, ε} and {a, b, ε}? 2

Figure 5: Result of eliminating S3 from Figure 4, obtained using del state from gnfa N Figure 6: Result of eliminating S1 from Figure 5, obtained using del state from gnfa N Answer: a, ab, aba, abb, b, ε 6. (3 pts) Draw an NFA corresponding to the RE (a+ab)* (b+ab)* (concatenation of (a+ab)* and (b+ab)*) using the standard approach. Just show the final NFA, but don t simpilify anything (to facilitate grading). Answer: The final answer was obtained using re2nfa( (a+ab)* (b+ab)* ), as in Figure 17. 7. (3 pts for EACH string) Write down two strings not in the language of (a+ab)* (b+ab)*, providing the reasons. Answer: We must begin the construction involving the first RE. But the first RE itself can t end in an a after a b, so we must employ the second RE. But the second RE can t end in an a. 8. (2 pts) Draw a DFA D 3 for the language of strings over {0, 1} that, when interpreted as binary numbers, are divisible by 3 without remainder (the mod-3 language ). Answer: Figure 15 gives this! 9. (2 pts) Now draw the Kleene-star of D 3 as an NFA using the standard construction, drawing it as N 3. 3

Figure 7: Result of eliminating S4 from Figure 6, obtained using del state from gnfa N Figure 8: Result of eliminating S2 from Figure 7, obtained using del state from gnfa N Answer: We essentially obtain back Figure 15! 10. (3 pts) Now convert N 3 by inspection to a DFA D 3. What is the relationship between D 3 and D 3, and why is there such a relationship (answer with respect to the languages of these machines)? Answer: We essentially obtain back Figure 15! Concatenating strings divisible by 3 is tantamount to weighing these strings by powers of 2 and adding. This does not change divisibility by 3. 11. (3 pts) Draw the NFA N for a language L for which its DFA D is exponential (with respect to the NFA-size); in addition, for the reverse of this language L, there must exist a DFA that is linear in size. Answer: This is the language where the N-th from last is a 1. 12. (2 pts) Explain in one sentence why the DFA D of Question 11 is exponentially sized. Answer: The DFA must keep track of the last N bits in all combinations, to accurately know, at each point, what the Nth-last bit was. 13. (3 pts) Why is the language of regular expressions over any alphabet (when viewed as strings) not regular? Answer: It is context-free due to needing paranthesis matching ((..)), which requires counting, which can t be done using an FSA. 4

Figure 9: Result of eliminating S0 from Figure 8, obtained using del state from gnfa N Figure 10: Apply re2nfa to the RE of Figure 9 5

Figure 11: Apply re2dfa to the RE of Figure 9 Figure 12: Apply re2mindfa to the RE of Figure 9 6

1X0 2X0. 3X0 X2 X3 4X0 X2 X3. 5X0 X2 X3.. ------------------------------------------- 0 1 2 3 4 Figure 13: DFA to be minimized Figure 14: DFA minimization table for the DFA in Figure 13 Figure 15: Minimized DFA with representative states obtained through mindfa(mk q3 dfa(), brief ) 7

Figure 16: Minimized DFA with representative states obtained through mindfa(mk q3 dfa(), verbose ) Figure 17: NFA obtained through re2nfa( (a+ab)* (b+ab)* ) 8