Quiz 1: Solutions J/18.400J: Automata, Computability and Complexity. Nati Srebro, Susan Hohenberger

Similar documents
6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

6.045 Final Exam. Name: Please write your name on each page. This exam is open book, open notes.

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Ambiguous Grammars and Compactification

Math 485, Graph Theory: Homework #3

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

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

1.0 Languages, Expressions, Automata

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

ECS 120 Lesson 7 Regular Expressions, Pt. 1

CSE 105 THEORY OF COMPUTATION

Computer Science 236 Fall Nov. 11, 2010

Multiple Choice Questions

To illustrate what is intended the following are three write ups by students. Diagonalization

(Refer Slide Time: 0:19)

where is the transition function, Pushdown Automata is the set of accept states. is the start state, and is the set of states, is the input alphabet,

Automating Construction of Lexers

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

6.045J/18.400J: Automata, Computability and Complexity Final Exam. There are two sheets of scratch paper at the end of this exam.

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

CIT3130: Theory of Computation. Regular languages

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Foundations of Computer Science Spring Mathematical Preliminaries

Converting a DFA to a Regular Expression JP

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

COMP Logic for Computer Scientists. Lecture 25

The clique number of a random graph in (,1 2) Let ( ) # -subgraphs in = 2 =: ( ) We will be interested in s.t. ( )~1. To gain some intuition note ( )

Formal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata

The clique number of a random graph in (,1 2) Let ( ) # -subgraphs in = 2 =: ( ) 2 ( ) ( )

Languages and Finite Automata

CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY

Dr. D.M. Akbar Hussain

Section 13. Basis for a Topology

Lexical Analysis. Prof. James L. Frankel Harvard University

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

Regular Languages and Regular Expressions

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

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C.

Checks and Balances - Constraint Solving without Surprises in Object-Constraint Programming Languages: Full Formal Development

Finite Automata Part Three

Final Exam 2, CS154. April 25, 2010

CS525 Winter 2012 \ Class Assignment #2 Preparation

Implementation of Lexical Analysis

Implementation of Lexical Analysis

Recursion and Structural Induction

Course Project 2 Regular Expressions

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

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.

Computer Sciences Department

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

Formal Languages and Automata

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Formal languages and computation models

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

Problem Set 7 Solutions

Ling/CSE 472: Introduction to Computational Linguistics. 4/6/15: Morphology & FST 2

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

Implementation of Lexical Analysis

Regular Expression Constrained Sequence Alignment

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

Theory of Computation

Context-Free Grammars

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

Chapter Seven: Regular Expressions. Formal Language, chapter 7, slide 1

CT32 COMPUTER NETWORKS DEC 2015

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

CS 432 Fall Mike Lam, Professor. Finite Automata Conversions and Lexing

Finite automata. III. Finite automata: language recognizers. Nondeterministic Finite Automata. Nondeterministic Finite Automata with λ-moves

Final Exam 1, CS154. April 21, 2010

Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

DVA337 HT17 - LECTURE 4. Languages and regular expressions

CSC-461 Exam #2 April 16, 2014

Semantics with Applications 3. More on Operational Semantics

6 NFA and Regular Expressions

1 Finite Representations of Languages

NFAs and Myhill-Nerode. CS154 Chris Pollett Feb. 22, 2006.

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

AUBER (Models of Computation, Languages and Automata) EXERCISES

Final Course Review. Reading: Chapters 1-9

CS 44 Exam #2 February 14, 2001

Sets. Sets. Subset, universe. Specifying sets, membership. Examples: Specifying a set using a predicate. Examples

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Introduction to Sets and Logic (MATH 1190)

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Theory Bridge Exam Example Questions Version of June 6, 2008

Notes for Recitation 8

Formally-Proven Kosaraju s algorithm

Finite Automata Part Three

Non-context-Free Languages. CS215, Lecture 5 c

Fundamental Properties of Graphs

Bases of topologies. 1 Motivation

Lecture 5: Regular Expression and Finite Automata

1 (15 points) LexicoSort

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

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.

4 Generating functions in two variables

Transcription:

6.45J/8.4J: utomata, Computability and Complexity Quiz : Solutions Prof. Nancy Lynch Nati Srebro, Susan Hohenberger Please write your name in the upper corner of each page. (2 Points) Q-

Problem : True or False (8 points) Full credit will be given for correct answers. If you include justification for your answers, you may obtain partial credit for incorrect answers. In all parts of this question, the alphabet is.. True or False: If is a regular language and is a finite language (i.e., a language with a finite number of words), then must be a regular language. True; all finite languages are regular languages and regular languages are closed under union. 2. True or False: If is a regular language, then must be a regular language. (Here, denotes the reverse of string.) False; we can show this language in not regular using techniques similar to Example.4 on page 8 of Sipser. common mistake is confusing the language above with. 3. True or False: Regular expressions that do not contain the star operator can represent only finite languages. True; the star operator in regular expressions is the equivalent of a loop in Fs. If a deterministic finite automata with states does not contain a loop, then at most it can recognize strings of length less than. The set of such strings is finite. 4. True or False: efine "!#%$, for a finite string, to be the string consisting of the symbols of in even-numbered positions. For example, "!& ' ( ' )$+*, ( -. If is a regular language, then. /!#%$ must be regular. True; given a F 2*3!546 879 ;: < ;$ that recognizes, we can build an NF >=?*@!546 879=5 8: < 8$ that recognizes =?*. "!#%$C. Intuitively, the transition function 7= is set so that from every state there are outgoing transitions to any state that is two hops (i.e., reachable in by reading two input characters) away from, where the new transition symbol in = is the second of the two symbols in. Q-2

5. True or False: For every pair of regular expressions and, the languages denoted by6! $ and! $ are the same. True; intuitively, one can see that minimally both expressions are and that when the star operator is exercised they both expand to expressions of alternating Rs and Ss, where both expressions begin and end with. It is possible to prove that they describe equivalent sets using induction. 6. True or False: If and are languages such that,, and are all regular, then must be regular. False; consider * and *>. Q-3

Problem 2: (2 points) Consider the following NF:, C. (6 points) Convert this NF into an equivalent F using the procedure we studied in class. Your answer should be the state diagram of a F. Your diagram should include only the states that are reachable from the start state. (Note: There are not more than a half-dozen states in the resulting F). Please label your states in some meaningful way. You may explain your work, to receive more credit for an incorrect answer. C C C C Q-4

2. (3 points) What language is recognized by your F? Your answer may be either a regular expression or an explicit description of the set. any string in ending in a :!5 $ 9. 3. (3 points) Give a F with two states that recognizes the same language. Q-5

Problem 3: (2 points) Find a regular expression for the language recognized by this machine, using the procedure we have studied in class: Show all your work, in particular, the state diagrams after the removal,, C of each successive state. You may omit before state removal and then remove states in the order ;. -transitions from your diagrams. Please start by giving the GNF GNF before state removal: S U U C fter removing state : S U ( U )* ( U )* Q-6

fter removing state : S ( U )*( U ) ( U )* fter removing state : S [( U )*( U )]*( U )* Regular expression representing the language recognized by the original F:!.$& 9 -!5.$!5 $& Q-7

Problem 4: (2 points) Regular expressions are defined using three operators: union, concatenation, and star. Suppose we define Extended Regular Expressions in the same way as regular expressions, with the addition of the set intersection operator. For example,!!5.$ $!& )! $ $ is an extended regular expression, which denotes the set of words that both begin and end with. Show that adding the intersection operator does not extend the power of ordinary regular expressions. o this by describing a procedure that, given an extended regular expression, produces an ordinary regular expression that represents the same language. You may use procedures described in class and in Sipser s book without saying how they work, e.g., you may say things like convert the NF to a F. The description of your procedure should be concise, but the procedure need not be the most efficient one possible. Input: Extended Regular Expression Procedure: Given, we work recursively to build regular expressions for all its subexpressions, until we get, a regular expression equivalent to. The interesting recursive step is the one where we use the intersection operator (i.e., add this recursive step to the recursive definition of a regular expression that we covered in class). Then, the problem reduces to: Given two ordinary regular expressions and, describe a procedure for producing a regular expression for $. Now, doing this involves several steps: Convert and to NFs, then to Fs, using the procedures given in class. Then construct a F for the intersection %! $! '$, using the product machine construction. Then convert the F to a GNF and then to a regular expression. Output: Regular Expression, which is equivalent to. Q-8

Problem 5: (2 points) Prove that the following language over the alphabet "* ' For example, the word. is not regular: and the number of = in is equal to the number of = in is in. Claim: is not regular. Proof: ssume to the contrary that is regular. Let be the pumping length given by the pumping lemma. Let be the string. ecause is a member of and has length more than, the pumping lemma guarantees that can be split into three pieces, *, satisfying the three conditions of the lemma. We show that this is impossible. Since, by the pumping lemma, we know that and, then for this, we see that is made up of one or more s that all come before the c symbol. If we pump down, by letting *, then the resulting string is =?* <, where the number of s before c is at least one less than the number of s after it. This new string = is not in. Thus, since can not be pumped, is not a regular language. Q-9