cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Similar documents
cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

2017 PRACTICE MIDTERM SOLUTIONS

CS 455/555: Finite automata

Finite Automata. Warren McCulloch ( ) and Walter Pitts ( )

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

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

CMSC 330: Organization of Programming Languages

CSE 105 THEORY OF COMPUTATION

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

Nondeterministic Finite Automata

Closure under the Regular Operations

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Finite Automata. Seungjin Choi

Theory of Computation Lecture 1. Dr. Nahla Belal

Languages, regular languages, finite automata

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Theory of Computation

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Lecture 1: Finite State Automaton

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

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

CpSc 421 Homework 9 Solution

Nondeterminism. September 7, Nondeterminism

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

Lecture 3: Nondeterministic Finite Automata

Name: Student ID: Instructions:

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Closure under the Regular Operations

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

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

Undecidable Problems and Reducibility

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 105 THEORY OF COMPUTATION

(Refer Slide Time: 0:21)

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

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

Computer Sciences Department

1 Alphabets and Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

Formal Definition of a Finite Automaton. August 26, 2013

Finite Automata. Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Chapter 5. Finite Automata

CSC173 Workshop: 13 Sept. Notes

Computability and Complexity

Theory of Computation

Announcements. Problem Set Four due Thursday at 7:00PM (right before the midterm).

Automata: a short introduction

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

CS375 Midterm Exam Solution Set (Fall 2017)

Student#: CISC-462 Exam, December XY, 2017 Page 1 of 12

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

CSE 105 Theory of Computation

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

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Chapter Five: Nondeterministic Finite Automata

Chapter Two: Finite Automata

CS 154 Introduction to Automata and Complexity Theory

Computational Models Lecture 2 1

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

3515ICT: Theory of Computation. Regular languages

Finite-State Machines (Automata) lecture 12

Computational Models Lecture 2 1

Pushdown Automata. Reading: Chapter 6

Nondeterministic Finite Automata

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

CS 581: Introduction to the Theory of Computation! Lecture 1!

Computational Models - Lecture 5 1

Finite Automata and Regular Languages (part III)

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Author: Vivek Kulkarni ( )

Sri vidya college of engineering and technology

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Finite Automata and Regular Languages

CSE 105 THEORY OF COMPUTATION

CSC236 Week 10. Larry Zhang

Theory of Computation (I) Yijia Chen Fudan University

CSE 105 THEORY OF COMPUTATION

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

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

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

INSTITUTE OF AERONAUTICAL ENGINEERING

Learning Regular Sets

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

Deterministic Finite Automata (DFAs)

Formal Definition of Computation. August 28, 2013

Author: Vivek Kulkarni ( )

Automata Theory CS F-04 Non-Determinisitic Finite Automata

Nondeterministic Finite Automata and Regular Expressions

Computational Models - Lecture 4 1

CpSc 421 Homework 1 Solutions

Transcription:

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

LECTURE 6a

REVIEW for Q2 Q2 covers Lecture 5 and Lecture 6 Chapter 2 - Deterministic Finite Automata DFA Chapter 2 - Nondeterministic Finite Automata NDFA 1. Some YES- NO Questions 2. Some Very Short Questions 3. Some Homework Problems

CHAPTER 2 PART 1 Deterministic Finite Automata DFA Nondeterministic Finite Automata NDFA

Short YES/NO Questions Here are solutions to some short YES/NO Questions for material covered in Chapter 2, Part 1 Solving Quizzes and Tests you have to write a short solutions and circle the answer You will get 0 pts if you only circle your answer without providing a solution, even if it is correct Here are some questions Q1 Alphabet Σ of any deterministic finite automaton M is always non-empty no An alphabet Σ is, by definition, any finite set, hence it can be empty Q2 The set K of states of any deterministic finite automaton is always non-empty yes s K

Short YES/NO Questions Q3 A configuration of a DF Automaton M = (K, Σ, δ, s, F) is any element of K Σ K no Configuration is any element (q, w) K Σ Q4 Given an automaton M = (K, Σ, δ, s, F), a binary relation M (K Σ ) (K Σ ) is a transition relation iff he following condition holds (q, aw) M (q, w) iff δ(q, a) = q no Proper condition is: (q, aw) M (q, w) iff δ(q, a) = q Q5 A configuration of a non- deterministic finite automaton M = (K, Σ,, s, F) is any element of K Σ yes by definition

Short YES/NO Questions Q6 Given M = (K, Σ, δ, s, F) we define L(M) = {w Σ : ((s, w) M(q, e)) for some q K} no Must be: for some q F Q7 Given M = (K, Σ, δ, s, F) we define L(M) = {w Σ : q K ((s, w) M(q, e))} no Must be: q F ((s, w) M(q, e)) Observe that Q7 is really the Q6 written in symbolic way correctly using the symbol of existential quantifier

Short YES/NO Questions Q8 If M = (K, Σ, δ, s, F) is a deterministic, then M is also non-deterministic yes The function δ is a (special) relation on K Σ K, i.e. δ K Σ K K Σ {e} K K Σ K Q9 no For any automata M, we have that L(M) Take M with Σ = or F = then we get L(M) = Q10 For any DFA M = (K, Σ, δ, s, F), e L(M) if and only if s F yes this is the DFA Theorem

Short YES/NO Questions Q11 M = (K, Σ,, s, F) is non-deterministic when K Σ K no we must say: is finite Q12 M = (K, Σ,, s, F) is non-deterministic when K (Σ {e}) K yes this is book definition; do not need to say is a finite set, as the set K (Σ {e}) K is always finite Q13 The set of all configurations of any non-deterministic state automata is always non-empty yes the set of all configuration of NDFA is by definition K Σ = {(q, w) : q K, w Σ } and we have that (s, e) K Σ even when Σ = as always s K, e Σ

Short YES/NO Questions Q14 We say that two automata M 1, M 2 (deterministic or nondeterministic) are the same, i.e. M 1 = M 2 if and only if L(M 1 ) = L(M 2 ) no we say that M 1, M 2 are equivalent, i.e. M 1 M 2 if and only if L(M 1 ) = L(M 2 ) Q15 For any DFA M, there is is a NDFA M M yes This is the Equivalency Theorems 1 M, such that Q16 For any NDFA M, there is is a DFA M, such that M M yes This is the Equivalency Theorems 2

Short YES/NO Questions Q17 If M = (K, Σ,, s, F) is a non-deterministic as defined in the book, then M is also non-deterministic, as defined in the lecture yes Σ {e} Σ Q18 We define, for any (deterministic or non-deterministic M = (K, Σ,, s, F) a computation of the length n from (q, w) to (q, w ) as a sequence (q 1, w 1 ), (q 2, w 2 ),..., (q n, w n ), n 1 of configurations, such that q 1 = q, q n = q, w 1 = w, w n = w and (q i, w i ) M(q i+1, w i+1 ) for i = 1, 2,..n 1 Statement: For any M a computation (q, w) exists yes By definition a computation of length one (case n=1) always exists

Very Short Questions For all short questions given on Quizzes and Tests you will have to do the following 1. Decide and explain whether the diagram represents a DFA, NDFA or does not 2. List all components of M when it represents DFA, NDFA 3. Describe L(M) as a regular expression when it represents DFA, NDFA

Very Short Questions Consider a diagram M1 1. Yes, it represents a DFA; δ is a function on {q 0, q 1 } {a} and initial state s = q 0 exists 2. K = {q 0, q 1 }, Σ = {a}, s = q 0, F = {q 1 }, δ(q 0, a) = q 1, δ(q 1, a) = q 1 3. L(M1) = aa

Very Short Questions Consider a diagram M2 1. Yes, it represents a DFA; δ is a function on {q 0 } {a} and initial state s = q 0 exists 2. K = {q 0 }, Σ = {a}, s = q 0, F =, δ(q 0, a) = q 0 3. L(M2) =

Very Short Questions Consider a diagram M3 1. Yes, it represents a DFA; initial state s = q 0 exists 2. K = {q 0 }, Σ =, s = q 0, F =, δ = 3. L(M3) =

Very Short Questions Consider a diagram M4 1. Yes, it represents a DFA; initial state s = q 0 exists 2. K = {q 0 }, Σ = {a}, s = q 0, F = {q 0 }, δ(q 0, a) = q 0 3. L(M4) = a Remark e L(M4) by DFA Theorem, as s = q 0 F = {q 0 }

Very Short Questions Consider a diagram M5 1. NO! it is NOT neither DFA nor NDFA - initial state does not exist

Very Short Questions Consider a diagram M6 1. It is not a DFA; Initial state does exist, but δ is not a function; δ(q 0, b) is not defined and we didn t say plus trap states 2. It is a NDFA 3. L(M6) =

Consider a diagram M7 Very Short Questions 1. Yes! it is a DFA with trap states Initial state exists and we can complete definition of δ by adding a trap state as pictured below

Very Short Questions Consider again diagram M7 2. If we do not say plus trap states it represents a NDFA with = {(q 0, a, q 1 ), (q 1, a, q 1 ), (q 1, b, q 1 )} 3. L(M7) = as F =

Very Short Questions There is much more Short Questions examples in the section SHORT PROBLEMS at the end of Lecture 5

Some Homework Problems Problem 1 Construct deterministic M such that L(M) = {w Σ : w has an odd number of a s and an even number of of b s } Solution Here is the short diagram - we must say: plus trap states

Some Homework Problems Problem 2 Construct a DFA M such that L(M) = {w {a, b} : every substring of length 4 in word w contains at least one b } Solution Here is a short pattern diagram (the trap states are not included)

Some Homework Problems Problem 3 Construct a DFA M such that L(M) = {w {a, b} : every word w contains an even number of sub-strings ba } Solution Here is a pattern diagram Zero is an even number so we must have that e L(M), i.e. we have to make the initial state also a final state

Some Homework Problems Problem 4 Construct a DFA M such that L(M) = {w {a, b} : w has abab as a substring } Solution The essential part of the diagram must produce abab and it can be surrounded by proper elements on both sides and can be repeated Here is the essential part of the diagram

Problem 4 Solutions We complete the essential part following the fact that it can be surrounded by proper elements on both sides and can be repeated Here is the diagram of M Observe that this is a pattern diagram; you need to add names of states only if you want to list all components M does not have trap states

Some Homework Problems Problem 5 Use book or lecture definition (specify which are you using) to construct a non-deterministic finite automaton M, such that L(M) = (ab) (ba) Specify all components K, Σ,, s, F diagram of M and draw a state Justify your construction by listing some strings accepted by the state diagram

Problem 5 Solutions Solution 1 We use the lecture definition Components of M are: Σ = {a, b}, K = {q 0, q 1 }, s = q 0, F = {q 0, q 1 } We define as follows = {(q 0, ab, q 0 ), (q 0, e, q 1 ), (q 1, ba, q 1 )} Strings accepted: ab, abab, abba, babba, ababbaba,...

Problem 5 Solutions Solution 2 We use the book definition Components of M are: Σ = {a, b}, K = {q 0, q 1, q 2, q 3 }, s = q 0, F = {q 2 } We define as follows = {(q 0, a, q 1 ), (q 1, b, q 0 ), (q 0, e, q 2 ), q 2, b, q 3 ), (q 3, a, q 2 )} Strings accepted: ab, abab, abba, babba, ababbaba,...

Some Homework Problems Problem 6 Let M = (K, Σ, s,, F ) for K = {q 0, q 1, q 2, q 3, }, s = q 0, Σ = {a, b, c}, F = {q 3 } and = {(q 0, abc, q 0 ), (q 0, ab, q 1 ), (q 1, bb, q 3 ), (q 0, b, q 2 ), (q 2, aa, q 3 )} Find the regular expression describing the L(M). Simplify it as much as you can. Explain your steps Solution L(M) = (abc) abbb abbb (abc) baa ba = (abc) abbb (abc) baa(abc) (abbb baa) We used the property: LL 1 LL2 = L(L 1 L 2 )

Some Homework Problems Problem 7 Let M = (K, Σ, s,, F ) for K = {q 0, q 1, q 2, q 3, }, s = q 0, Σ = {a, b, c}, F = {q 3 } and = {(q 0, abc, q 0 ), (q 0, ab, q 1 ), (q 1, bb, q 3 ), (q 0, b, q 2 ), (q 2, aa, q 3 )} Write down (you can draw the diagram) an automaton M such that M M and M is defined by the BOOK definition. Solution We apply the stretching technique to M and the new M is is as follows. M = (K {p 1, p 2,..., p 5 } Σ, s = q 0,, F = F ) = {(q 0, b, q 2 ), (q 0, a, p 1 ), (p 1, b, p 2 ), (p 2, c, q 0 ), (q 0, a, p 3 ), (p 3, b, q 1 ), (q 1, b, p 4 ), (p 4, b, q 3 ), (q 0, b, q 2 ), (q 2, a, p 5 ), (p 5, a, q 3 )}

Some Homework Problems I will NOT include this problem on Q2, but you have to know how to solve similar problems for Midterm Problem 8 Let M be defined as follows M = (K, Σ, s,, F ) for K = {q 0, q 1, q 2 }, s = q 0, Σ = {a, b}, F = {q 0, q 2 } and = {(q 0, a, q 1 ), (q 1, b, q 2 ), (q 1, b, q 0 ), (q 2, a, q 0 )} Write 4 steps of the general method of transformation a NDFA M, into an equivalent M, which is a DFA

Problem 8 Reminder E(q) = {p K : (q, e) M(p, e)} and δ(q, σ) = {E(p) : q Q (q, σ, p) } p K Step 1 Evaluate δ(e(q 0 ), a) and δ(e(q 0 ), b) Step i+1] Evaluate δ on all states that result from Step i

Problem 8 Solution δ(q, σ) = {E(p) : q Q (q, σ, p) } p K Step 1 E(q 0 ) = {q 0 }, E(q 1 ) = {q 1 }, E(q 2 ) = {q 2 } δ({q 0 }, a) = E(q 1 ) = {q 1 }, δ({q 0 }, b) = } Step 2 δ(, a) =, δ(, a) =, δ({q 1 }, a) =, δ({q 1 }, b) = E(q 0 ) E(q 2 ) = {q 0, q 2 } F

Problem 8 Solution δ(q, σ) = {E(p) : q Q (q, σ, p) } Step 3 p K δ({q 0, q 2 }, a) = E(q 1 ) E(q 0 ) = {q 0, q 1 }, δ({q 0, q 2 }, b) = Step 4 δ({q 0, q 1 }, a) = E(q 1 ) = {q 1 }, δ({q 0, q 1 }, b) = E(q 0 ) E(q 2 ) = {q 0, q 2 } F