NON-DETERMINISTIC FSA

Similar documents
Nondeterministic Finite Automata

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS 573 Automata Theory and Formal Languages

1 Nondeterministic Finite Automata

Regular expressions, Finite Automata, transition graphs are all the same!!

Nondeterministic Automata vs Deterministic Automata

Minimal DFA. minimal DFA for L starting from any other

Regular languages refresher

Lecture 08: Feb. 08, 2019

Convert the NFA into DFA

= state, a = reading and q j

State Minimization for DFAs

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Finite State Automata and Determinisation

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

Worked out examples Finite Automata

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

NFAs continued, Closure Properties of Regular Languages

Homework 3 Solutions

Lecture 09: Myhill-Nerode Theorem

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

2.4 Theoretical Foundations

3 Regular expressions

Formal Languages and Automata

Formal languages, automata, and theory of computation

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

CMSC 330: Organization of Programming Languages

First Midterm Examination

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Nondeterminism and Nodeterministic Automata

Chapter 2 Finite Automata

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

NFAs continued, Closure Properties of Regular Languages

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

Let's start with an example:

Theory of Computation Regular Languages

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

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

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

FABER Formal Languages, Automata and Models of Computation

First Midterm Examination

Homework Solution - Set 5 Due: Friday 10/03/08

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata-cont d

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Harvard University Computer Science 121 Midterm October 23, 2012

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

1 From NFA to regular expression

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

CISC 4090 Theory of Computation

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Fundamentals of Computer Science

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

Finite-State Automata: Recap

Coalgebra, Lecture 15: Equations for Deterministic Automata

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Parse trees, ambiguity, and Chomsky normal form

Designing finite automata II

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Thoery of Automata CS402

Closure Properties of Regular Languages

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α

CS 275 Automata and Formal Language Theory

CHAPTER 1 Regular Languages. Contents

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

Deterministic Finite Automata

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

TOPIC: LINEAR ALGEBRA MATRICES

State Complexity of Union and Intersection of Binary Suffix-Free Languages

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

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

Some Theory of Computation Exercises Week 1

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

Myhill-Nerode Theorem

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Prefix-Free Regular-Expression Matching

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

Java II Finite Automata I

Name Ima Sample ASU ID

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

Transcription:

Tw o types of non-determinism: NON-DETERMINISTIC FS () Multiple strt-sttes; strt-sttes S Q. The lnguge L(M) ={x:x tkes M from some strt-stte to some finl-stte nd ll of x is proessed}. The string x = is epted only y strting t stte q,nd x = is epted only y strting stte q 2. Tw o strt-sttes q nd q 2 : q, q 3 q 2 L(M) ={,,,,,, } (2) Non-unique trnsitions; δ(q i, j )isset of sttes Q. The lnguge L(M) ={x:xtkes M for some hoie of suessive trnsitions from the strt-stte to some finl-stte nd ll of x is proessed}. δ(q, ) ={q,q 2 } q q q 2 x= n e fully proessed in only 2 wys, nd one of them epts x. For eh NFS M, there is n equivlent deterministi FS M suh tht L(M) =L(M ).

opyright@995 6.2 REVERSING N FS MY CRETE NFS, C B M; L(M) = (+)* + ( + )*, C B M r ; L(M r) = ( + )* +(+)* Reversing n FS: Reverse diretion of eh trnsition (my rete non-determinism). Mke the strt-stte the finl-stte. Mke eh finl-stte strt-stte (my rete non-determinism). Reverse of Lnguge L: L r ={x r :x L}, where x r = k k 2 if x = 2 k k. If L is regulr, then L r is lso regulr. In M: q q 2 q 2 3 k q k k q k In M r : q q 2 q 2 3 k q k k q k Question: If M hs n error-stte, then wht will hppen to it in M r? Cn the reversl proess rete unrehle sttes?

opyright@995 6.3 λ-trnsition: MULTIPLE STRT-STTES ELIMINTION USING λ-trnsitions n FS n hnge stte y using λ-trnsition nd without reding n input symol. Elimintion of Multiple Strt-sttes: dd new stte s nd mke itthe only strt-stte. dd λ-trnsition from s to eh of the originl strt-stte. Nohnge in finl-sttes or other trnsitions. q q 2 q 3 s λ λ q q 2 q 3 q s,, q 2 q 3, (i) Strt-sttes = {q, q 2 }. Question:, (ii) n equivlent FS with strt-stte nd λ-moves., (iii) nother equivlent FS with strt-stte.? Give n exmple FS to show tht it is not enough to dd new stte s, mke itthe only strt-stte, nd for eh j dd the following trnsitions t s: δ(s, j )= δ(q i, j ), union over ll strt-sttes in M. qi (We hve to mke the new strt-stte s lso finl-stte if one or more the originl strt-sttes is finl-stte.)? Show the resulting FS when we pply the ove onstrution to the FS shown t the top left. Does it hnge the lnguge?

opyright@995 6.4 SUBSET-CONSTRUCTION METHOD FOR CONVERTING NFS TO FS The new FS M nnot simulte ll lterntive pths π (x) in the originl FS M for n input string x, euse the numer of π (x) n e exponentilly lrge (in x ) nd M hs finitely mny sttes. Insted, M keeps trk of the end points E(x) ofthe pths π (x); x is epted E(x) ontins one or more finl-sttes of M. The end-points of the pths π (x) form suset of Q in M, nd there re only 2 Q mny different susets. If x = 2 j nd x = x j+,then E(x ) = δ(q i, j+ ). q i E(x) 2 4 3 2 2 2 3 2 4 3 4 #(pths π (x) for proessing x = n )=n+2. {} {2} {2,3} {2,4} {2,3,4} {2,3,4} Use the susets of Q s the sttes of the new FS.

opyright@995 6.5 THE SUBSET-CONSTRUCTION v oid onstrution of unrehle sttes: () Choose the set of ll strt-sttes in M s the strt-stte S of the new FS M. (2) While there is stte S j for whih the trnsitions hve not een determined, do the following: For eh input symol Σin M, (i) Let S = δ (q i, ). (It my hppen tht S =.) (ii) q i S j If S is not lredy stte in M, then dd it s new stte. (iii) dd the trnsition δ(s j, ) =Sin M. (3) Mke eh stte S j in M finl-stte if it ontins one or more finl-sttes of M 2 4 n NFS 3 {} {2} {4} {2,3} {2,3,4} {2,4} The FS otined y the suset-onstrution Note: If we did not hve the ded-stte 4 in the ove exmple, then 4 would e removed from ll sttes in the new FS; the stte {4} would now eome.

opyright@995 6.6 EXERCISE. Complete the prtil desription of the stte in the finite-stte utomton M hs- elow for the lnguge L hs- (= the inry strings ontining ""), sed on the desriptions of sttes B nd C, to justify the trnsitions to nd from. Note tht eh stte-desription is in terms of the "pst", i.e., the prt of the input whih is proessed to rrive t the stte. M hs- :, B = hve not seen "" nd C B = hve not seen "" nd just seen C = seen "" Let M r hs- e the non-deterministi utomton otined y pplying the reversl-opertion to M hs- ; L(M r hs-) =L r hs- = L hs-. () Give suitle desription in English for the sttes of Mhs- r tht would justify its trnsitions. Wht is the onnetion etween these desriptions nd the previous desriptions? () Show the FS otined from M r hs- y the suset-onstrution. lso desrie the sttes of the new FS in simple English in terms of the desriptions in (). 2. Remove the redundnt stte 4 in the NFS in pge 6.4 nd then pply the suset-onstrution. How does the result differ from the FS shown ove; dothey ept the sme lnguge? 3. pply the suset-onstrution for the NFSs in pge 6.. 4. Consider deterministi FS for verifying multiplition of inry numers y 3, with the usul lest signifint it on the right. lso, onsider similr FS for verifying multiplition y 2. The input lphet for these mhines should e {,, 2, 3 }. Now, otin non-deterministi FS for verifying multiplition y either of 2 nd 3; onvert it to deterministi form.

opyright@995 6.7 Projetion: PROJECTION OF LNGUGEND λ-trnsition IN N FSM If x = x x 2 x 3 x k,where some of x i s n e λ, none of x i ontins, nd k, then the projetion Π (x) =x x 2 x k,whih is simply x minus ll ourrenes of. Π (L) ={Π (x): x L}. Theorem: For ny lnguge L nd the symols, Π (Π (L))) = Π (Π (L))). If L is regulr lnguge, then there is NFSM for Π (L) ontining λ-trnsitions. Exmple. M: d 2 d 3 Π d (M): λ 2 λ 3

opyright@995 6.8 λ-trnsition: ELIMINTION OF λ-trnsitions The FS n hnge its stte without reding n input symol. M: λ 2 λ 3 L(M): λ 2 3 L(M): λ 2 3 λ 2 3 Elimintion of λ-moves inmgives possily n NFS M : M nd M hve the sme sttes, nd the sme finl-sttes. M my hve multiple strt-sttes (due to λ-trnsitions from strtstte of M) nd non-deterministi trnsitions. Define: λ(q i )={q j :q j is rehle from q i y zero or more λ-trnsitions}; q i λ(q i ). lgorithm: () Mke eh stte in λ(q )strt-stte in M. (2) For eh δ(q i, j )=q k in M for j λ, let δ(q i, j )=λ(q k )inm. Exmple. For ove M, λ() = {, 2}, λ(2) = {2}, nd λ(3) = {2, 3}., M : 2 3

opyright@995 6.9 THE EFFECT OF INTRODUCING ERRORS IN REGULR LNGUGE Lnguge L modified y one replement error: RE (L) ={x:xdiffers from some y L in one position}. L nd RE (L) hve the sme lphet. If L is regulr, then RE (L) islso regulr. Exmple. If L = L -div-2 = L -even,then RE (L) =L -odd. L -even ={λ,,,,,,,, } L -odd = {,,,,,,, } Building n M(RE (L)) from M(L): The onstrution elow pplies to ny FS. M even B NFS for RE (L -div-2 ) B B trnsitions efore error error-trnsitions trnsitions fter error M(RE (L -even )): {, B } {, B} redued M(RE (L -even )): ( merged with B )

opyright@995 6. EXERCISE. pply the ove method to otin n FS for RE (L hs- ). Show ll detils of oversion of NFS to FS nd the detils of stteminimiztion. 2. How will you generlize the ove onstrution for extly k ( 2) replement errors? Illustrte the onstrution using k = 2 nd M -div-2.(the generliztion to errors is lso esy.) 3. Show tht RE L (L) ={uv w: v L, v = v, nd uvw L} is regulr if oth L nd L re regulr. Note tht v my equl v. (Hint: n NFS for RE L (L) will hve three phses: for the prt u (efore the error), v, nd w (fter the error).) 4. Let DE (L) ={xy: xy L for some x,, nd y} =the set of strings otined y deletion of symol from strings in L. One n show tht DE (L) isregulr y giving method for the onstrution of NFS for DE (L) from n FS for L where the deletion opertion is modeled y λ-trnsitions. Illustrte your method y using M hs- s n exmple; show the NFS fter the introdution of λ-trnsitions (keep the sttes "efore deletion" distint from those "fter deletion" similr to tht for the se of RE (L)). 5. similr result holds for the insertion error. Stte the result lerly.