# Convert the NFA into DFA

Size: px
Start display at page:

Transcription

1 Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm: Constructing deterministic finite utomton from nondeterministic one. Input: n NF N. Output: F ccepting the sme lnguge. Method: Ech stte of is set of sttes which N could e in fter reding some sequence of input symols. Thus is le to simulte ll possile moves N cn mke on given input string. The initil stte of is the set consisting of S0, the initil stte of N, together with ll sttes of N tht cn e reched from S0 y mens of -trnsition only. The ccepting sttes of re those sets of sttes tht contin t lest one ccepting sttes of N. Let us define the function -CLOSURE (s) to e the set of sttes of N uilt y pplying the following rules:- 1- S is dded to -CLOSURE (s). 2- If t is in -CLOSURE (s), nd there is n edge leled from t to u, then u is dded to -CLOSURE (s) if u is not lredy there. Rule 2 is repeted until no more sttes cn e dded to -CLOSURE (s). Thus, -CLOSURE (s) is just the set of sttes tht cn e reched from S on - trnsition lone. If T is set of sttes, then -CLOSURE (T) is just the union over ll sttes S in T of -CLOSURE (S). The computtion of -CLOSURE (T) is typicl process of serching grph for nodes rechle from given set of nodes. In this cse the nodes of T re the given set, nd the grph consists of the - leled edge of the trnsition digrm only. simple lgorithm to compute -CLOSURE (T) is shown in Fig.14 31

2 egin Push ll sttes in T onto STCK; -CLOSURE (T):=T; While STCK not empty do Pop S, the top element of STCK, off of stck; For ech stte t with n edge from S to t leled do End End If t is not in -CLOSURE (T) then egin End dd t to -CLOSURE (T); Push t onto STCK; Fig.14: Computtion of -CLOSURE The sttes of nd their trnsition re constructed s follows. Initilly, let - CLOSURE (S0) e stte of. This stte is the strt stte of. We ssume ech stte of is initilly "unmrked". Then perform the lgorithm of Fig.15. While there is n unmrked stte x= (S1, S2... S n ) of do egin Mrk x; For ech input symol do egin Let T e the set of sttes to which there is trnsition on '' from some stte Si in x; End y: = -CLOSURE (T); If y hs not yet een dded to the set of sttes of then Mke y n "unmrked" stte of ; dd trnsition from x to y leled if not lredy present End Fig.15: The Suset Construction 32

3 Exmple Convert the NF shown in Fig.16 into F Fig.16: NF N for ()*. Fig.16 shows NF N ccepting the lnguge ()*. The initil stte of the equivlent F is -CLOSURE (0), which is = {0, 1, 2, 4, 7}, since these re exctly the sttes rechle from stte 0 vi pth in which every edge is leled. Note tht 0 is reched from itself y such pth, the pth hving no edges. The lgorithm of Fig.15 tell us to set x to nd compute T, the set of sttes of N hving trnsitions on from memers of. mong the sttes 0, 1, 2, 4 nd 7, only 2 nd 7 hve such trnsition, to 3 nd 8, so y= -CLOSURE ({3, 8}) = {1, 2, 3, 4, 6, 7, 8} Let us cll this set. mong the sttes in, only 4 hs trnsition on to 5, so the F hs trnsition on from to C= -CLOSURE ({5}) = {1, 2, 4, 5, 6, 7} Then we hve two trnsitions:- C We continue this lgorithm for stte nd C. 33

4 1- For set - If the input is symol "", then only stte 2 nd 7 give trnsition on symol "" to stte 3 nd 8, therefore -CLOSURE({3,8})=, then we hve this trnsition - If the input is symol "", then only stte 4 nd 8 give trnsition on symol "" to stte 5 nd 9, therefore -CLOSURE ({5, 9}) = {1, 2, 4, 5, 6, 7, 9} Let us cll this set. ecuse stte not dded to the stte of F, then we dd it, with trnsition:- 2- For set C - If the input symol is "", then only stte 2 nd 7 hve trnsition on "" to stte 3 nd 8, therefore -CLOSURE ({3, 8}) =, then the trnsition is: C - If the input symol is "", then only stte 4 gives trnsition on to stte 5, therefore -CLOSURE (5) =C, then the trnsition is:- C C 3- For set :- - If the input symol is "", then only stte 2 nd 7 gives trnsition on "" to stte 3 nd 8, therefore -CLOSURE ({3, 8}) =, then the trnsition is - If the input symol is "" then only stte 4 nd 9 gives trnsition on "" to stte 5, nd 10, therefore:- -CLOSURE ({5, 10}) = {1, 2, 4, 5, 6, 7, 10} Let us cll this E, then the trnsition:- 4- For set E E 34

5 - If the input symol is "", then only stte 2 nd 7 given trnsition on "" to stte 3 nd 8, therefore:- -CLOSURE ({3, 8}) =, then the trnsition is E - If the input symol is "", then only stte 4 gives trnsition on "" to stte 5, therefore -CLOSURE (5) =C, then the trnsition is:- E C The trnsition tle for NF is shown in Fig.17, nd the F equivlent to NF of Fig.16 is shown in Fig.18. The finl stte is E ecuse it contin the stte 10 which is the finl stte for NF in Fig.16. (Strt) (ccept) Stte Input C C C E E C Fig.17: Trnsition Tle Strt C E Fig.18: F ccepting ()*. 35

6 Minimizing the Numer of sttes of F The F of Fig (18) constructed from the NF of Fig (16) is not the smllest possile. In prticulr, we show Fig (12), nother F with only four sttes tht lso ccept ()*. Prt of the reson for this nonminimlity of the suset construction lies in the fct tht we did not include in the lgorithm, for converting NF to F, some ovious stte identifictions tht could e mde. There re two methods for minimizing the numer of sttes nd trnsitions:- 1-Empiricl Method: This method minimized the numer of sttes nd trnsitions ccording to the following steps:- - We merge two sttes in F in one stte if they hve the sme importnt sttes. The importnt stte is the stte with no -trnsition - We merge two sttes if they either oth include or oth exclude ccepting sttes of the NF. Exmple: Minimize the F shown in Fig.19 ccording to the Empiricl method. Strt C Fig.19: F ccepting ()* = {0}, = {1, 2, 8, 3, 5}, C= {4, 7, 8, 2, 3, 5}, = {6, 7, 8, 2, 3, 5} Finl is stte 8. From Fig.19 we know tht the lnguge tht NF re shown in Fig.20 36

7 0 Letter 1 2 Letter 3 4 igit Fig.20: NF ccepting ()* The importnt sttes in Fig.20 re {0, 3, 5}. We see tht stte nd C contin the sme importnt nd contin the finl stte (8), therefore we cn merge these two sttes into one stte nmed C, nd then the result is C C= {1, 2, 3, 4, 5, 6, 7, 8} fter tht we look to the stte C nd stte nd see tht they hve the sme importnt stte nd the sme finl stte, therefore we cn merge these sttes into nother stte clled C then the minimized F is shown in Fig.21. C Fig.21: NF ccepting ()* 37

8 2- Forml Method In this method we don t need to experience for deciding which of the stte tht re legl for merging, insted of stte we must use the following lgorithm:- lgorithm: - Minimizing the numer of sttes of F Input: - F M with set of sttes S, inputs, trnsitions defined for ll sttes nd inputs, initil stte S0, nd set the finl stte F. Output: - F M ' ccepting the sme lnguge s M nd hving s few sttes s possile. Method:- 1- We construct prtition T of the set of sttes Initilly, T consist of two groups, the finl sttes F, nd the non finl sttes S-F. Then we construct new prtition Tnew y the procedure of Fig (22). Tnew will lwys e refinement of T, mening tht Tnew consists of the groups of T, ech split into one or more pieces. If Tnew = T, then no more chnges cn ever occur, so we terminte this prt of the lgorithm: For ech group G of T do egin Prtitions G into sugroups such tht two sttes S nd t of G re in the sme sugroup iff for ll input symol, sttes S nd t hve trnsitions on to sttes in the sme group of T; End. Plce ll sugroups so formed in Tnew; Fig (22). New prtition Tnew 2- When the finl prtition T hs een constructed in step (1), select representtive for ech group, tht is, n ritrry stte in the group. The representtive will e the sttes of the reduced F M '. Let S e representtive stte, nd suppose on input there is trnsition of M from s to t. Let r e the representtive of t's group (r my e t). Then M ' hs trnsition from S to r on. Let the initil stte of M ' e the representtive of the group contining the initil S0 38

9 of M, nd let the finl sttes of M ' e the representtive which re in F. Note tht ech group of T either consists only of sttes in F or hs no sttes in F. 3- If M ' hs ded stte, tht is, stte d which is not finl nd with trnsitions to itself on ll input symol, then remove d from M '. lso remove ny stts not rechle from the initil stte. ny trnsitions to d from other sttes ecome undefined. Exmple:- Minimize The F shown in Fig.18 Solution: The initil prtition of T consists of two groups: 1- The finl sttes:- which contins (E) 2- The non finl sttes:- which contins (C). To construct Tnew y the lgorithm of Fig (22), (1) We first consider (E), since this consists of one stte, it cnnot e further split, so we plce (E) in Tnew. (2) Now consider (C) nd do the following:- () If the input is, then ech of these sttes goes to, so they could ll e plced in one group s fr s input is consumed. () If the input is, then,, nd C go to memers of the group (C) of T, while goes to E, memer of nother group. Thus, in Tnew (C) must e split into groups (C) nd (). The new vlue of T is thus (C)() (E). Constructing the next Tnew, we given hve no splitting on input, ut (C) must e split into two groups (C) (), since on input nd C ech go to C, while goes to, memer of group of T different from tht of C. Thus the next vlue of T is (C) () () (E). When we construct Tnew from this, we cnnot split ny of the groups consisting of single stte. The only possiility is tht (C) could e split. ut nd C go to the sme stte,, on input, nd they go to the sme stte, C, on input. Hence, Tnew=T, nd the finl prtition T from step (1) of lgorithm is (C) () () (E). 39

10 Let us now choose representtives. Of course, nd E represent the group contining only themselves. Let us choose to represent the group (C). Then the trnsition tle for the reduce utomton is shown in Fig.23. (Strt) (ccept) Stte Input E E Fig.23: Reduced utomton For exmple, E goes to C on input in the utomt of Fig.18. Since is the representtive of the group for C, we hve trnsition from E to on input in Fig.23. similr chnge hs tken plce in entry for on input, nd ll other trnsitions re copied from Fig.18. There is no ded stte in Fig.23, nd ll sttes re rechle from the initil stte. Fig.24 shows the minimized F. Strt E Fig.24: Minimized F ccepting ()*. 40

### Minimal DFA. minimal DFA for L starting from any other

Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

### 1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

### Designing finite automata II

Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

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

Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

### CMSC 330: Organization of Programming Languages

CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

### Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert

### AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

### Lexical Analysis Finite Automate

Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition

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

CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

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

CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

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

CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

### Finite Automata-cont d

Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

### CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

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

CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

### Formal languages, automata, and theory of computation

Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

### Formal Languages and Automata

Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

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

Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

### CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

### 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.

York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

### 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.

Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

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

CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

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

CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

### First Midterm Examination

Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

### Nondeterminism and Nodeterministic Automata

Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

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

CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

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

The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook

### Java II Finite Automata I

Jv II Finite Automt I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz Finite Automt I p.1/13 Processing Regulr Expressions We lredy lerned out Jv s regulr expression

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

NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

### Homework 3 Solutions

CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

### CISC 4090 Theory of Computation

9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

### Closure Properties of Regular Languages

Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

### CHAPTER 1 Regular Languages. Contents

Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

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

Non-Deterministic Finite Automt Fll 2018 Costs Busch - RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch - RPI 2 Nondeterministic Finite Automton (NFA) Alphbet

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

Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion

### Bases for Vector Spaces

Bses for Vector Spces 2-26-25 A set is independent if, roughly speking, there is no redundncy in the set: You cn t uild ny vector in the set s liner comintion of the others A set spns if you cn uild everything

### CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

CMSC 330: Orgniztion of Progrmming Lnguges DFAs, nd NFAs, nd Regexps (Oh my!) CMSC330 Spring 2018 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All

### First Midterm Examination

24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

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

Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

### Lexical Analysis Part III

Lexicl Anlysis Prt III Chpter 3: Finite Automt Slides dpted from : Roert vn Engelen, Florid Stte University Alex Aiken, Stnford University Design of Lexicl Anlyzer Genertor Trnslte regulr expressions to

### Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1

Chpter 1, Prt 1 Regulr Lnguges CSC527, Chpter 1, Prt 1 c 2012 Mitsunori Ogihr 1 Finite Automt A finite utomton is system for processing ny finite sequence of symols, where the symols re chosen from finite

### Lecture 08: Feb. 08, 2019

4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

### 3 Regular expressions

3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

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

CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

### NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

CMPU 240 Lnguge Theory nd Computtion Spring 2019 NFAs nd Regulr Expressions Lst clss: Introduced nondeterministic finite utomt with -trnsitions Tody: Prove n NFA- is no more powerful thn n NFA Introduce

### Chapter 2 Finite Automata

Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

### Thoery of Automata CS402

Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...

### Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes

### Closure Properties of Regular Languages

of Regulr Lnguges Dr. Neil T. Dntm CSCI-561, Colordo School of Mines Fll 2018 Dntm (Mines CSCI-561) Closure Properties of Regulr Lnguges Fll 2018 1 / 50 Outline Introduction Closure Properties Stte Minimiztion

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

University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite

### NFAs continued, Closure Properties of Regular Languages

Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

### Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices

### State Minimization for DFAs

Stte Minimiztion for DFAs Red K & S 2.7 Do Homework 10. Consider: Stte Minimiztion 4 5 Is this miniml mchine? Step (1): Get rid of unrechle sttes. Stte Minimiztion 6, Stte is unrechle. Step (2): Get rid

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

Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive

### 5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

CSC4510 AUTOMATA 5.1 Definitions nd Exmples 5.2 Deterministic Pushdown Automt Definitions nd Exmples A lnguge cn be generted by CFG if nd only if it cn be ccepted by pushdown utomton. A pushdown utomton

### 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

CS4 45- Determinisitic Finite Automt -: Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother

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

CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

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

Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

### More on automata. Michael George. March 24 April 7, 2014

More on utomt Michel George Mrch 24 April 7, 2014 1 Automt constructions Now tht we hve forml model of mchine, it is useful to mke some generl constructions. 1.1 DFA Union / Product construction Suppose

### CS 275 Automata and Formal Language Theory

CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed

### NFAs continued, Closure Properties of Regular Languages

lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions

### Non-deterministic Finite Automata

Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent

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

Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.

### This lecture covers Chapter 8 of HMU: Properties of CFLs

This lecture covers Chpter 8 of HMU: Properties of CFLs Turing Mchine Extensions of Turing Mchines Restrictions of Turing Mchines Additionl Reding: Chpter 8 of HMU. Turing Mchine: Informl Definition B

### Theory of Computation Regular Languages

Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

### Lecture 09: Myhill-Nerode Theorem

CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

### 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.

York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

### Myhill-Nerode Theorem

Overview Myhill-Nerode Theorem Correspondence etween DA s nd MN reltions Cnonicl DA for L Computing cnonicl DFA Myhill-Nerode Theorem Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute

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

Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

### Model Reduction of Finite State Machines by Contraction

Model Reduction of Finite Stte Mchines y Contrction Alessndro Giu Dip. di Ingegneri Elettric ed Elettronic, Università di Cgliri, Pizz d Armi, 09123 Cgliri, Itly Phone: +39-070-675-5892 Fx: +39-070-675-5900

### Normal Forms for Context-free Grammars

Norml Forms for Context-free Grmmrs 1 Linz 6th, Section 6.2 wo Importnt Norml Forms, pges 171--178 2 Chomsky Norml Form All productions hve form: A BC nd A vrile vrile terminl 3 Exmples: S AS S AS S S

### Worked out examples Finite Automata

Worked out exmples Finite Automt Exmple Design Finite Stte Automton which reds inry string nd ccepts only those tht end with. Since we re in the topic of Non Deterministic Finite Automt (NFA), we will

### Some Theory of Computation Exercises Week 1

Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether

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

C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,

### Deterministic Finite Automata

Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

### Languages & Automata

Lnguges & Automt Dr. Lim Nughton Lnguges A lnguge is sed on n lphet which is finite set of smols such s {, } or {, } or {,..., z}. If Σ is n lphet, string over Σ is finite sequence of letters from Σ, (strings

### 1 From NFA to regular expression

Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work

### CSC 473 Automata, Grammars & Languages 11/9/10

CSC 473 utomt, Grmmrs & Lnguges 11/9/10 utomt, Grmmrs nd Lnguges Discourse 06 Decidbility nd Undecidbility Decidble Problems for Regulr Lnguges Theorem 4.1: (embership/cceptnce Prob. for DFs) = {, w is

### Name Ima Sample ASU ID

Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to

### Non-deterministic Finite Automata

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion

### Free groups, Lecture 2, part 1

Free groups, Lecture 2, prt 1 Olg Khrlmpovich NYC, Sep. 2 1 / 22 Theorem Every sugroup H F of free group F is free. Given finite numer of genertors of H we cn compute its sis. 2 / 22 Schreir s grph The

### PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA RIGHT LINEAR LANGUAGES. Right Liner Grmmr: Rules of the form: A α B, A α A,B V N, α V T + Left Liner Grmmr: Rules of the form: A Bα, A α A,B V N, α V T

### In-depth introduction to main models, concepts of theory of computation:

CMPSCI601: Introduction Lecture 1 In-depth introduction to min models, concepts of theory of computtion: Computility: wht cn e computed in principle Logic: how cn we express our requirements Complexity:

### SWEN 224 Formal Foundations of Programming WITH ANSWERS

T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Time Allowed: 3 Hours EXAMINATIONS 2011 END-OF-YEAR SWEN 224 Forml Foundtions of Progrmming

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

Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions

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

CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

### The size of subsequence automaton

Theoreticl Computer Science 4 (005) 79 84 www.elsevier.com/locte/tcs Note The size of susequence utomton Zdeněk Troníček,, Ayumi Shinohr,c Deprtment of Computer Science nd Engineering, FEE CTU in Prgue,

### Chapter 7. Kleene s Theorem. 7.1 Kleene s Theorem. The following theorem is the most important and fundamental result in the theory of FA s:

Chpte 7 Kleene s Theoem 7.1 Kleene s Theoem The following theoem is the most impotnt nd fundmentl esult in the theoy of FA s: Theoem 6 Any lnguge tht cn e defined y eithe egul expession, o finite utomt,

### FABER Formal Languages, Automata and Models of Computation

DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte

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

Nondeterminism Nondeterministic Finite Automt Nondeterminism Subset Construction A nondeterministic finite utomton hs the bility to be in severl sttes t once. Trnsitions from stte on n input symbol cn

### Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

Overview H9 Vertlerouw H 9: Prsing: op-down & LL(1) do 3 mei 2001 56 heo Ruys h. 8 - Prsing 8.1 ontext-free Grmmrs 8.2 op-down Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough

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

CS 311 Homework 3 due 16:30, Thursdy, 14 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [15 pts.; 5 pts. ech] Drw stte digrms for NFAs recognizing the following lnguges:. L = {w

### Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Non Deterministic Automt Forml Lnguges nd Automt - Yonsei CS 1 Nondeterministic Finite Accepter (NFA) We llow set of possible moves insted of A unique move. Alphbet = {} Two choices q 1 q2 Forml Lnguges

### GNFA GNFA GNFA GNFA GNFA

DFA RE NFA DFA -NFA REX GNFA Definition GNFA A generlize noneterministic finite utomton (GNFA) is grph whose eges re lele y regulr expressions, with unique strt stte with in-egree, n unique finl stte with

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

5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

### Section: Other Models of Turing Machines. Definition: Two automata are equivalent if they accept the same language.

Section: Other Models of Turing Mchines Definition: Two utomt re equivlent if they ccept the sme lnguge. Turing Mchines with Sty Option Modify δ, Theorem Clss of stndrd TM s is equivlent to clss of TM

### Parse trees, ambiguity, and Chomsky normal form

Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

### 1.4 Nonregular Languages

74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll