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

Size: px
Start display at page:

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

Transcription

1 CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University

2 First Progrmming Project Instruction Scheduling Project hs een posted Due dtes: code Ferury 25, report Mrch 4 - strt erly - prolem is not totlly defined; you my run into situtions where you will need time to redesign your solution - the report is 40% of the grde, code is 60% - need to follow clling conventions since we will use utomtic testing frmework - we minly provide help for C/C++ implementtions - not group project! 2

3 Constructing Scnner Review source code specifictions Scnner Scnner Genertor prts of speech & words Tles nd code The scnner is the first stge in the front end Specifictions cn e expressed using regulr expressions Build tles nd code from DFA 3

4 Review: Gol We show how to construct finite stte utomton to recognize ny RE Overview: Direct construction of nondeterministic finite utomton (NFA) to recognize given RE Requires -trnsitions to comine regulr suexpressions Construct deterministic finite utomton (DFA) to simulte the NFA Use set-of-sttes construction Minimize the numer of sttes Hopcroft stte minimiztion lgorithm Generte the scnner code Additionl specifictions needed for detils 4

5 Non-deterministic Finite Automt Ech RE corresponds to deterministic finite utomton (DFA) My e hrd to directly construct the right DFA Wht out n RE such s ( ) *? S 0 S 1 S 2 S 3 S 4 This is little different S 0 hs trnsition on S 1 hs two trnsitions on This is non-deterministic finite utomton (NFA) 5

6 Non-deterministic Finite Automt An NFA ccepts string x iff pth though the trnsition grph from s 0 to finl stte such tht the edge lels spell x Trnsitions on consume no input To run the NFA, strt in s 0 nd guess the right trnsition t ech step Alwys guess correctly If some sequence of correct guesses ccepts x then ccept Why study NFAs? They re the key to utomte the RE DFA construction We cn pste together NFAs with -trnsitions NFA NFA ecomes n NFA 6

7 Reltionship etween NFAs nd DFAs DFA is specil cse of n NFA DFA hs no trnsitions DFA s trnsition function is single-vlued Sme rules will work DFA cn e simulted with n NFA Oviously NFA cn e simulted with DFA Simulte sets of possile sttes Possile exponentil lowup in the stte spce Still, one stte per chrcter in the input strem (less ovious) 7

8 Automting Scnner Construction To convert specifiction into code: 1 Write down the RE for the input lnguge 2 Build ig NFA 3 Build the DFA tht simultes the NFA 4 Systemticlly shrink the DFA 5 Turn it into code Scnner genertors Lex nd Flex work long these lines Algorithms re well-known nd well-understood Key issue is interfce to prser You could uild one in weekend! (define ll prts of speech) 8

9 Review: Automting Scnner Construction RE NFA (Thompson s construction) Build n NFA for ech term Comine them with -moves NFA DFA (suset construction) Build the simultion DFA Miniml DFA Hopcroft s lgorithm The Cycle of Constructions RE NFA DFA miniml DFA DFA RE (Not prt of the scnner construction) All pirs, ll pths prolem Tke the union of ll pths from s 0 to n ccepting stte 9

10 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for 10

11 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for 11

12 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 1 S 2 S 3 S 4 NFA for 12

13 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 1 S 2 S 0 S 3 S 4 S 5 NFA for 13

14 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 1 S 2 S 0 S 5 S 3 S 4 NFA for 14

15 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 0 S 1 S 2 S 3 S 4 NFA for S 5 S 1 S 3 NFA for * 15

16 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 0 S 1 S 2 S 3 S 4 NFA for S 5 S 1 S 3 NFA for * 16

17 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 0 S 1 S 2 S 3 S 4 NFA for S 5 S 3 S 4 NFA for * 17

18 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 0 S 1 S 2 S 3 S 4 NFA for S 5 NFA for * S 3 S 4 18

19 RE NFA using Thompson s Construction Key ide NFA pttern for ech symol nd ech opertor Ech NFA hs single strt nd ccept stte Join them with moves in precedence order S 3 S 4 NFA for NFA for S 0 S 1 S 2 S 3 S 4 NFA for S 5 NFA for * S 3 S 4 Ken Thompson, CACM,

20 Exmple of Thompson s Construction Let s try ( c ) * 1.,, & c c 2. c S 1 S 2 S 0 S 5 c S 3 S 4 3. ( c ) * S 2 S 3 S 6 S 7 c S 4 S 5 20

21 Exmple of Thompson s Construction Let s try ( c ) * 1.,, & c c 2. c S 1 S 2 S 0 S 5 c S 3 S 4 3. ( c ) * S 2 S 3 S 6 S 7 S 4 c S 5 21

22 Exmple of Thompson s Construction (con t) 4. ( c ) * S 4 S 5 S 2 S 3 S 8 S 9 S 6 c S 7 Of course, humn would design something simpler... c But, we cn utomte production of the more complex one... 22

23 Review: Automting Scnner Construction RE NFA (Thompson s construction) Build n NFA for ech term Comine them with -moves NFA DFA (suset construction) Build the simultion DFA Miniml DFA Hopcroft s lgorithm The Cycle of Constructions RE NFA DFA miniml DFA DFA RE (Not prt of the scnner construction) All pirs, ll pths prolem Tke the union of ll pths from s 0 to n ccepting stte 23

24 NFA DFA with Suset Construction Need to uild simultion of the NFA Two key functions Move(s i, ) is set of sttes rechle from s i y -closure(s i ) is set of sttes rechle from s i y The lgorithm: Strt stte derived from s 0 of the NFA Tke its -closure S 0 = -closure(s 0 ) Tke the imge of S 0, move(s 0, ) for ech Σ, nd tke its -closure, dd it to the stte set S For ech stte S, compute move(s, ) for ech Σ, nd tke its -closure Iterte until no more sttes re dded Sounds more complex thn it is 24

25 NFA DFA with Suset Construction The lgorithm: s 0 -closure(q 0 ) dd s 0 to S while ( S is still chnging ) for ech s i S for ech Σ s? -closure(move(s i,)) if ( s? S ) then dd s? to S s s j T[ s i,] s j else T[ s i,] s? Let s think out why this works 25

26 NFA DFA with Suset Construction The lgorithm: s 0 -closure(q 0 ) dd s 0 to S while ( S is still chnging ) for ech s i S for ech Σ s? -closure(move(s i,)) if ( s? S ) then dd s? to S s s j T[ s i,] s j else T[ s i,] s? The lgorithm hlts: 1. S contins no duplictes (test efore dding) 2. 2 Q is finite 3. while loop dds to S, ut does not remove from S (monotone) the loop hlts S contins ll the rechle NFA sttes It tries ech symol in ech s i. It uilds every possile NFA configurtion. S nd T form the DFA Let s think out why this works 26

27 NFA DFA with Suset Construction Exmple of fixed-point computtion Monotone construction of some finite set Hlts when it stops dding to the set Proofs of hlting & correctness re similr These computtions rise in mny contexts Other fixed-point computtions Cnonicl construction of sets of LR(1) items Quite similr to the suset construction Clssic dt-flow nlysis Solving sets of simultneous set equtions DFA minimiztion lgorithm (coming up!) We will see mny more fixed-point computtions 27

28 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1 28

29 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, q 4, q 6, q 9 none none 29

30 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, q 4, q 6, q 9 s 1 q 1, q 2, q 3, q 4, q 6, q 9 none none 30

31 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, q 4, q 6, q 9 s 1 q 1, q 2, q 3, none q 4, q 6, q 9 none none 31

32 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, q 4, q 6, q 9 none none s 1 q 1, q 2, q 3, q 4, q 6, q 9 none q 5 q 7 32

33 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, q 4, q 6, q 9 none s 1 q 1, q 2, q 3, none q 5, q 8, q 9, q 4, q 6, q 9 q 3, q 4, q 6 none q 7, q 8, q 9, q 3, q 4, q 6 33

34 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, q 4, q 6, q 9 none s 1 q 1, q 2, q 3, none q 5, q 8, q 9, q 4, q 6, q 9 q 3, q 4, q 6 s 2 q 5, q 8, q 9, q 3, q 4, q 6 none q 7, q 8, q 9, q 3, q 4, q 6 34

35 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, none none q 4, q 6, q 9 s 1 q 1, q 2, q 3, q 4, q 6, q 9 none q 5, q 8, q 9, q 3, q 4, q 6 q 7, q 8, q 9, q 3, q 4, q 6 s 2 q 5, q 8, q 9, q 3, q 4, q 6 none s 2 s 3 35

36 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, none none q 4, q 6, q 9 s 1 q 1, q 2, q 3, q 4, q 6, q 9 none q 5, q 8, q 9, q 3, q 4, q 6 q 7, q 8, q 9, q 3, q 4, q 6 s 2 q 5, q 8, q 9, none s 2 s 3 q 3, q 4, q 6 s 3 q 7, q 8, q 9, q 3, q 4, q 6 36

37 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, none none q 4, q 6, q 9 s 1 q 1, q 2, q 3, none q 5, q 8, q 9, q 7, q 8, q 9, q 4, q 6, q 9 q 3, q 4, q 6 q 3, q 4, q 6 s 2 q 5, q 8, q 9, none s 2 s 3 q 3, q 4, q 6 s 3 q 7, q 8, q 9, none s 2 s 3 q 3, q 4, q 6 37

38 NFA DFA with Suset Construction ( c )* : q 0 q 1 q 4 q 5 q q 3 q 2 8 q 9 q 6 c q 7 Applying the suset construction: -closure(move(s,*)) NFA sttes c s 0 q 0 q 1, q 2, q 3, none none q 4, q 6, q 9 s 1 q 1, q 2, q 3, none q 5, q 8, q 9, q 7, q 8, q 9, q 4, q 6, q 9 q 3, q 4, q 6 q 3, q 4, q 6 s 2 q 5, q 8, q 9, none s 2 s 3 q 3, q 4, q 6 s 3 q 7, q 8, q 9, none s 2 s 3 q 3, q 4, q 6 Finl sttes 38

39 NFA DFA with Suset Construction The DFA for ( c ) * s 0 s 1 c s 2 s 3 c c δ c s 0 s s 1 - s 2 s 3 s 2 - s 2 s 3 s 3 - s 2 s 3 Ends up smller thn the NFA All trnsitions re deterministic 39

40 Automting Scnner Construction RE NFA (Thompson s construction) Build n NFA for ech term The Cycle of Constructions Comine them with -moves NFA DFA (suset construction) Build the simultion DFA Miniml DFA Hopcroft s lgorithm RE NFA DFA miniml DFA DFA RE (not relly prt of scnner construction) All pirs, ll pths prolem Union together pths from s 0 to finl stte 40

41 DFA Minimiztion The Big Picture Discover sets of equivlent sttes Represent ech such set with just one stte 41

42 DFA Minimiztion The Big Picture Discover sets of equivlent sttes Represent ech such set with just one stte Two sttes re equivlent if nd only if: Σ, trnsitions on led to equivlent sttes (DFA) -trnsitions to distinct sets sttes must e in distinct sets 42

43 DFA Minimiztion The Big Picture Discover sets of equivlent sttes Represent ech such set with just one stte Two sttes re equivlent if nd only if: Σ, trnsitions on led to equivlent sttes (DFA) -trnsitions to distinct sets sttes must e in distinct sets A prtition P of S Ech stte s S is in exctly one set p i P The lgorithm itertively prtitions the DFA s sttes 43

44 DFA Minimiztion Detils of the lgorithm Group sttes into mximl size sets, optimisticlly Itertively sudivide those sets, s needed Sttes tht remin grouped together re equivlent Initil prtition, P 0, hs two sets: {F} & {Q-F} (D =(Q,Σ,δ,q 0,F)) Splitting set ( prtitioning set y ) Assume q, & q s, nd δ(q,) = q x, & δ(q,) = q y If q x & q y re not in the sme set, then s must e split q hs trnsition on, q does not splits s 44

45 DFA Minimiztion The lgorithm P { F, {Q-F}} while ( P is still chnging) T { } for ech set S P T T split(s) P T split(s): for ech Σ if splits S into S 1, S 2, then return {S 1, S 2, } else return S Why does this work? Prtition P 2 Q Strt off with 2 susets of Q {F} nd {Q-F} While loop tkes P i P i+1 y splitting 1 or more sets P i+1 is t lest one step closer to the prtition with Q sets Mximum of Q splits Note tht Prtitions re never comined 45

46 DFA Minimiztion The lgorithm P { F, {Q-F}} while ( P is still chnging) T { } for ech set S P T T split(s) P T split(s): for ech Σ if splits S into S 1, S 2, then return {S 1, S 2, } else return S Why does this work? Prtition P 2 Q Strt off with 2 susets of Q {F} nd {Q-F} While loop tkes P i P i+1 y splitting 1 or more sets P i+1 is t lest one step closer to the prtition with Q sets Mximum of Q splits Note tht Prtitions re never comined This is fixed-point lgorithm! 46

47 Bck to our DFA Minimiztion exmple Then, pply the minimiztion lgorithm Split on Current Prtition c P 0 { s 1, s 2, s 3 } {s 0 } none none none s 0 s 1 c s 2 c finl sttes s 3 c To produce the miniml DFA s 0 s 1 c We oserved tht humn would design simpler utomton thn Thompson s construction & the suset construction did. Minimizing tht DFA produces the one tht humn would design! 47

48 Arevited Register Specifiction Strt with regulr expression r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 The Cycle of Constructions RE NFA DFA miniml DFA 48

49 Arevited Register Specifiction Thompson s construction produces r 0 r 1 s 0 r 2 r 8 s f r 9 The Cycle of Constructions RE NFA DFA miniml DFA 49

50 Arevited Register Specifiction The suset construction uilds s 0 r 0 s f s f 1 s f8 s f2 s f9 This is DFA, ut it hs lot of sttes The Cycle of Constructions RE NFA DFA miniml DFA 50

51 Arevited Register Specifiction The DFA minimiztion lgorithm uilds s 0 r 0,1,2,3,4, 5,6,7,8,9 s f This looks like wht skilled compiler writer would do! The Cycle of Constructions RE NFA DFA miniml DFA 51

52 Homework nd Next clss Syntx Anlysis Red EC:

FABER Formal Languages, Automata and Models of Computation

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

More information

Lexical Analysis, II Comp 412

Lexical Analysis, II Comp 412 COMP 412 FALL 2017 Lexicl Anlysis, II Comp 412 source code IR Front End OpMmizer Bck End IR trget code Copyright 2017, Keith D. Cooper & Lind Torczon, ll rights reserved. Students enrolled in Comp 412

More information

CMSC 330: Organization of Programming Languages

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

More information

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

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

More information

Lexical Analysis Finite Automate

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

More information

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

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

More information

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

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

More information

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

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

More information

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

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

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

More information

Lexical Analysis Part III

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

More information

Convert the NFA into DFA

Convert the NFA into DFA 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:

More information

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

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

More information

Java II Finite Automata I

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

More information

Minimal DFA. minimal DFA for L starting from any other

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

More information

Deterministic Finite Automata

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

More information

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

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

More information

1 Nondeterministic Finite Automata

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

More information

Lecture 08: Feb. 08, 2019

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

More information

Chapter 2 Finite Automata

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

More information

Nondeterminism and Nodeterministic Automata

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

More information

Finite Automata-cont d

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

More information

Designing finite automata II

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

More information

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.

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

More information

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

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

More information

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

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

More information

Homework 3 Solutions

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

More information

2. Lexical Analysis. Oscar Nierstrasz

2. Lexical Analysis. Oscar Nierstrasz 2. Lexicl Anlysis Oscr Nierstrsz Thnks to Jens Plserg nd Tony Hosking for their kind permission to reuse nd dpt the CS132 nd CS502 lecture notes. http://www.cs.ucl.edu/~plserg/ http://www.cs.purdue.edu/homes/hosking/

More information

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

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

More information

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

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

More information

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

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014 CS125 Lecture 12 Fll 2014 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

More information

Formal Languages and Automata

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

More information

Non-deterministic Finite Automata

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

More information

Non-deterministic Finite Automata

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

More information

State Minimization for DFAs

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

More information

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

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

More information

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

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 information

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

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

More information

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt Forml Lnguge

More information

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

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

More information

CISC 4090 Theory of Computation

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

More information

Theory of Computation Regular Languages

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

More information

NFAs continued, Closure Properties of Regular Languages

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,

More information

Formal languages, automata, and theory of computation

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

More information

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

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

More information

CHAPTER 1 Regular Languages. Contents

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

More information

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

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

More information

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

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

More information

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

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

More information

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

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

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

More information

Some Theory of Computation Exercises Week 1

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

More information

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck. Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent

More information

First Midterm Examination

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

More information

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

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

More information

Let's start with an example:

Let's start with an example: 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

More information

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

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

More information

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

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

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

More information

Nondeterministic Automata vs Deterministic Automata

Nondeterministic Automata vs Deterministic Automata Nondeterministi Automt vs Deterministi Automt We lerned tht NFA is onvenient model for showing the reltionships mong regulr grmmrs, FA, nd regulr expressions, nd designing them. However, we know tht n

More information

Review for the Midterm

Review for the Midterm Review for the Midterm Stephen A. Edwrds Columi University Fll 2018 The Midterm Structure of Compiler Scnning Lnguges nd Regulr Expressions NFAs Trnslting REs into NFAs: Thompson s Construction Building

More information

1 From NFA to regular expression

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

More information

Fundamentals of Computer Science

Fundamentals of Computer Science Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,

More information

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

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

More information

Worked out examples Finite Automata

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

More information

GNFA GNFA GNFA GNFA GNFA

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

More information

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

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

More information

Closure Properties of Regular Languages

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

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q

More information

Lexical Analysis Part II: Constructing a Scanner from Regular Expressions

Lexical Analysis Part II: Constructing a Scanner from Regular Expressions Lexical Analysis Part II: Constructing a Scanner from Regular Expressions CS434 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper, Ken Kennedy

More information

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

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers 80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES 2.6 Finite Stte Automt With Output: Trnsducers So fr, we hve only considered utomt tht recognize lnguges, i.e., utomt tht do not produce ny output on ny input

More information

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

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

More information

DFA Minimization and Applications

DFA Minimization and Applications DFA Minimiztion nd Applictions Mondy, Octoer 15, 2007 Reding: toughton 3.12 C235 Lnguges nd Automt Deprtment of Computer cience Wellesley College Gols for ody o Answer ny P3 questions you might hve. o

More information

Myhill-Nerode Theorem

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

More information

Lecture 09: Myhill-Nerode Theorem

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

More information

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa CS:4330 Theory of Computtion Spring 208 Regulr Lnguges Equivlences between Finite utomt nd REs Hniel Brbos Redings for this lecture Chpter of [Sipser 996], 3rd edition. Section.3. Finite utomt nd regulr

More information

CSC 311 Theory of Computation

CSC 311 Theory of Computation CSC 11 Theory of Computtion Tutoril on DFAs, NFAs, regulr expressions, regulr grmmr, closure of regulr lnguges, context-free grmmrs, non-deterministic push-down utomt, Turing mchines,etc. Tutoril 2 Second

More information

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

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

More information

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

More information

First Midterm Examination

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

More information

NFAs continued, Closure Properties of Regular Languages

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

More information

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

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

More information

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6 CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized

More information

3 Regular expressions

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

More information

Introduction to ω-autamata

Introduction to ω-autamata Fridy 25 th Jnury, 2013 Outline From finite word utomt ω-regulr lnguge ω-utomt Nondeterministic Models Deterministic Models Two Lower Bounds Conclusion Discussion Synthesis Preliminry From finite word

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages C 314 Principles of Progrmming Lnguges Lecture 6: LL(1) Prsing Zheng (Eddy) Zhng Rutgers University Ferury 5, 2018 Clss Informtion Homework 2 due tomorrow. Homework 3 will e posted erly next week. 2 Top

More information

ɛ-closure, Kleene s Theorem,

ɛ-closure, Kleene s Theorem, DEGefW5wiGH2XgYMEzUKjEmtCDUsRQ4d 1 A nice pper relevnt to this course is titled The Glory of the Pst 2 NICTA Resercher, Adjunct t the Austrlin Ntionl University nd Griffith University ɛ-closure, Kleene

More information

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

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

More information

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

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

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

CS 275 Automata and Formal Language Theory

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

More information

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

More information

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.

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

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks

More information

Non-Deterministic Finite Automata

Non-Deterministic Finite Automata Non-Deterministic Finite Automt http://users.comlb.ox.c.uk/luke. ong/teching/moc/nf2up.pdf 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q1 q2 2 Alphbet ={} Two choices q1 q2 3 Alphbet ={} Two choices

More information

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

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.

More information

CS 573 Automata Theory and Formal Languages

CS 573 Automata Theory and Formal Languages Non-determinism Automt Theory nd Forml Lnguges Professor Leslie Lnder Leture # 3 Septemer 6, 2 To hieve our gol, we need the onept of Non-deterministi Finite Automton with -moves (NFA) An NFA is tuple

More information

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.

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.

More information

Model Reduction of Finite State Machines by Contraction

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

More information