Automata Theory TEST 1 Answers Max points: 156 Grade basis: 150 Median grade: 81%

Similar documents
Assignment No.4 solution. Pumping Lemma Version I and II. Where m = n! (n-factorial) and n = 1, 2, 3

Glynda, the good witch of the North

CHAPTER TWO LANGUAGES. Dr Zalmiyah Zakaria

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

JNTUWORLD. Code No: R

ITEC2620 Introduction to Data Structures

Chapter 4: Regular Expressions

Proof Techniques Alphabets, Strings, and Languages. Foundations of Computer Science Theory

Finite Automata Part Three

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

UNIT I PART A PART B

Finite Automata Part Three

Multiple Choice Questions

Compiler Construction

1. Which of the following regular expressions over {0, 1} denotes the set of all strings not containing 100 as a sub-string?

QUESTION BANK. Unit 1. Introduction to Finite Automata

Chapter 18: Decidability

CMPSCI 250: Introduction to Computation. Lecture #28: Regular Expressions and Languages David Mix Barrington 2 April 2014

Finite Automata Part Three

CS402 - Theory of Automata FAQs By

CS 3100 Models of Computation Fall 2011 This assignment is worth 8% of the total points for assignments 100 points total.

CMSC 330, Fall 2009, Practice Problem 3 Solutions

Ambiguous Grammars and Compactification

Regular Expressions. Lecture 10 Sections Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2016

1.3 Functions and Equivalence Relations 1.4 Languages

Notes for Comp 454 Week 2

Languages and Strings. Chapter 2

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

Lexical Analyzer Scanner

KHALID PERVEZ (MBA+MCS) CHICHAWATNI

CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2]

Front End: Lexical Analysis. The Structure of a Compiler

AUBER (Models of Computation, Languages and Automata) EXERCISES

CMSC 330 Practice Problem 4 Solutions

DVA337 HT17 - LECTURE 4. Languages and regular expressions

Lexical Analyzer Scanner

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Strings, Languages, and Regular Expressions

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

HKN CS 374 Midterm 1 Review. Tim Klem Noah Mathes Mahir Morshed

1. Provide two valid strings in the languages described by each of the following regular expressions, with alphabet Σ = {0,1,2}.

Welcome! CSC445 Models Of Computation Dr. Lutz Hamel Tyler 251

I BSc(Computer Science)[ ] Semester - II Allied:DISCRETE MATHEMATICS - 207D Multiple Choice Questions.

Automata Theory CS S-FR Final Review

Bayesian Networks and Decision Graphs

Concepts Introduced in Chapter 3. Lexical Analysis. Lexical Analysis Terms. Attributes for Tokens

AUTOMATA THEORY AND COMPUTABILITY

Data Compression Fundamentals

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Turing Machine Languages


Lesson 18: Counting Problems

LECTURE NOTES THEORY OF COMPUTATION

Actually talking about Turing machines this time

CMPSCI 250: Introduction to Computation. Lecture #36: State Elimination David Mix Barrington 23 April 2014

LECTURE NOTES THEORY OF COMPUTATION

1. [5 points each] True or False. If the question is currently open, write O or Open.

Lexical Analysis. COMP 524, Spring 2014 Bryan Ward

CS 314 Principles of Programming Languages. Lecture 3

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

Learn Smart and Grow with world

UNION-FREE DECOMPOSITION OF REGULAR LANGUAGES

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

CS143 Midterm Fall 2008

Formal Languages. Grammar. Ryan Stansifer. Department of Computer Sciences Florida Institute of Technology Melbourne, Florida USA 32901

Section 1.7 Sequences, Summations Cardinality of Infinite Sets

Come & Join Us at VUSTUDENTS.net

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

CS375: Logic and Theory of Computing

Regular Languages. MACM 300 Formal Languages and Automata. Formal Languages: Recap. Regular Languages

Models of Computation II: Grammars and Pushdown Automata

Section 2.4 Sequences and Summations

2068 (I) Attempt all questions.

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

Formal Languages and Automata

Where We Are. CMSC 330: Organization of Programming Languages. This Lecture. Programming Languages. Motivation for Grammars

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Name: Finite Automata

MA/CSSE 474. Today's Agenda

2010: Compilers REVIEW: REGULAR EXPRESSIONS HOW TO USE REGULAR EXPRESSIONS

Theory and Compiling COMP360

Lec-5-HW-1, TM basics

Architecture of Compilers, Interpreters. CMSC 330: Organization of Programming Languages. Front End Scanner and Parser. Implementing the Front End

Languages and Finite Automata

Midterm I (Solutions) CS164, Spring 2002

Implementation of Lexical Analysis

COMP 330 Autumn 2018 McGill University

CS164: Midterm I. Fall 2003

Implementation of Lexical Analysis

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5

Formal Languages and Compilers Lecture VI: Lexical Analysis

Chapter Seven: Regular Expressions

CT32 COMPUTER NETWORKS DEC 2015

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

CS402 - Theory of Automata Glossary By

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

CS143 Handout 20 Summer 2011 July 15 th, 2011 CS143 Practice Midterm and Solution

CS52 - Assignment 10

Transcription:

Automata Theory TEST 1 Answers Max points: 156 Grade basis: 150 Median grade: 81% 1. (2 pts) See text. You can t be sloppy defining terms like this. You must show a bijection between the natural numbers and elements of the set. 2. (6 pts) First, this set is infinite, so you can t simply enumerate it. You can t start with (0, 0), (0, 1), (0, 2)... because it will never terminate. You have to use the zig-zag approach: (0, 0), (0, 1), (1, 0), (0, 2), (1, 1), (2, 0),... 3. (4 pts) a, aa, bb, aaa, abb, bba, aaaa, aabb, bbaa, bbbb 4. (4 pts) It s a problem that has a yes/no answer. 5. (4 pts) You need to use the proper symbols. (q 1, abbaba) (q 2, bbaba) (q 4, baba) (q 3, aba) (q 4, ba) (q 3, a) (q 4, ɛ) 6. (6 pts) Create an FA M for the original language. Create a new machine M from M constructed as follows: M has all of M s states, with S now the only accepting state. Create a new start state S and create epsilon transitions to M s original accepting states; these states are no longer accepting in M. Reverse the direction of all transitions that were in M. M now accepts the reverse of the language thet M accepted. Convert this new machine into canonical form, as well as the machine in question. See if they are the same machine (see text for details). 7. (6 pts) XOR of three bits produces a single output: 0 when there are an even number of ones, or 1 for an odd number. 8. (6 pts) An NFA is slightly simpler. 9. (6 pts) b a + b + a The key here is that once an a is encountered, it can be followed by any number of a s, but once a b follows, any additional a s must be followed only by more a s and nothing else. 1

10. (a) (6 pts) S e L e + S e + e L e + e S e + e e (b) (6 pts) (c) (4 pts) Yes. Right hand sides all contain a single terminal or a single terminal followed by a single nonterminal.. (d) (3 pts) No. Cannot get more than one parse tree for the same string. Many answered yes because the grammar generates more than one string. That would make every grammar ambiguous. 11. (a) (3 pts) ɛ, aa, bb, abba, aaaa, bbbb, aabbaa, etc. NOTE: aabaa is NOT a member; these strings must be even length. (b) (4 pts) No. Consider catenating aa and bb to get aabb, which is not in the language. 12. (10 pts) 2

13. (10 pts) 14. (10 pts) (a) (2 pts) See diagram. Null transitions are not included. Note that if you included them, there are none into state q1 and none out of state a. (b) (6 pts) 13 : b ab = b 14 : ab a = ab a 1a : ab = 33 : b b = b 34 : a b a = a 3a : b = 43 : b b = b 44 : b = 4a : ɛ b = ɛ 3

15. (8 pts) Strings in the language are ɛ, b, ab, bb, abb, bab, bbb, abab, abbb, bbba, bbbb, A string cannot have aa as a substring. The following doesn t consider every string in lexicographic order; just the important ones. [ɛ, b, ab, bb, abb, bab, bbb,...] adding anything to any of these have the same results. Conceptually, these are all strings that end in a b. Consider a: When adding an a to any string in the ɛ class the result is still valid; but adding an a to a results in a rejected string, so a belongs in a new class. [a, ba, aba, bba,...] These are the legal strings that end in a. Consider aa: No matter what is added the result is rejected, which is not the case for the other two. So we need a separate case for strings with aa as a substring. [aa, aaa, aab, baa,...] These are the illegal strings with aa as a substring. 16. (6 pts) 17. (10 pts) Start off with classes [c, d, e] and [a, b, f] (accepting and non-accepting). For [a, b, f] a 1 distinguishes between a, b and f (a, b transition to accepting, f does not). This results in three classes: [c, d, e], [a, b], and [f]. At this point, all elements within each class transition to the same classes on 0 and 1, so no more distinctions can be made. In the DFA, you can t forget the accepting states: 18. (4 pts) 4

19. (8 pts) Proof: Let w = (ab) k/2 b k. (Many of you used (ab) k b 2k.) xy falls in (ab) k/2 and xy k; w k. If x = ɛ and y = (ab) k/2, then pumping y in or out will upset the m/n balance. But we have to consider y as various subsets of (ab) k/2. If y = (ab) i, i < k/2, the same argument holds. If y = (ba) i, i < k/2, the balance is again not maintained. Also, y could be just a single s or b, both of which must be discussed. Most had the right idea; they just didn t consider ALL possible cases for y (and many only consideed the case when x = ɛ!.) 20. (6 pts) Consider w = (ab) k/2 (a b). This meets the criteria of the pumping theorem. y is a suffix of (ab) k/2. Consider any non-empty value for y. If it is just b, we have a string of the form (ab) k/2 1 ab (a b) L: if we pump out, then m = k/2 1 and the a is part of (a b). If we pump in, then the first pumped b is part of the (ab) k/2 and the remaining b s part of (a b). No matter what we let y be, the prefix of the string will have the form (ab) m, and what follows is part of the (a b) suffix. 21. (6pts) False. Consider languages a n b n c n and a n b n, n 0, both of which are not regular. Their intersection is ɛ, which is regular. 22. (8 pts) Create an FA, or RE, or RG. Show it is finite. Show it has a finite number of equivalence classes. 5