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

Size: px
Start display at page:

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

Transcription

1 CMSC 330: Orgniztion of Progrmming Lnguges DFAs, nd NFAs, nd Regexps (Oh my!) CMSC330 Spring 2018

2 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt (NFA) My hve mny sequences of steps for ech string Accepts if ny pth ends in finl stte t end of string More compct thn DFA Ø But more expensive to test whether string mtches CMSC 330 Spring

3 Quiz 1: Which DFA mtches this regexp? b(b +b?) A. B. C. 0 b 1 b 2 b 3 b 4 b 0 1 b b b 1 02,b D. None of the bove CMSC 330 Spring

4 Quiz 1: Which DFA mtches this regexp? b(b +b?) A. B. C. 0 b 1 b 2 b 3 b 4 b 0 1 b b b 1 02,b D. None of the bove CMSC 330 Spring

5 Compring DFAs nd NFAs NFAs cn hve more thn one trnsition leving stte on the sme symbol DFAs llow only one trnsition per symbol I.e., trnsition function must be vlid function DFA is specil cse of NFA CMSC 330 Spring

6 Compring DFAs nd NFAs (cont.) NFAs my hve trnsitions with empty string lbel My move to new stte without consuming chrcter ε e-trnsition DFA trnsition must be lbeled with symbol DFA is specil cse of NFA CMSC 330 Spring

7 DFA for ( b)*bb CMSC 330 Spring

8 NFA for ( b)*bb b Hs pths to either S0 or S1 Neither is finl, so rejected bbbb Hs pths to different sttes One pth leds to S3, so ccepts string CMSC 330 Spring

9 NFA for (b b)* b Hs pths to sttes S0, S1 bb Hs pths to S0, S1 Need to use ε-trnsition CMSC 330 Spring

10 Compring NFA nd DFA for (b b)* DFA NFA CMSC 330 Spring

11 NFA Acceptnce Algorithm Sketch When NFA processes string s NFA must keep trck of severl current sttes Ø Due to multiple trnsitions with sme lbel Ø ε-trnsitions If ny current stte is finl when done then ccept s Exmple After processing Ø NFA my be in sttes S1 S2 S3 S1 S2 ε S3 CMSC 330 Spring

12 Forml Definition A deterministic finite utomton (DFA) is 5-tuple (Σ, Q, q 0, F, δ) where Σ is n lphbet Q is nonempty set of sttes q 0 Î Q is the strt stte F Q is the set of finl sttes δ : Q x Σ Q specifies the DFA's trnsitions Ø Wht's this definition sying tht δ is? A DFA ccepts s if it stops t finl stte on s CMSC 330 Spring

13 Forml Definition: Exmple Σ = {0, 1} Q = {S0, S1} q 0 = S0 F = {S1} input stte symbol δ 0 1 S0 S0 S1 S1 S0 S1 or s { (S0,0,S0),(S0,1,S1),(S1,0,S0),(S1,1,S1) } CMSC 330 Spring

14 Nondeterministic Finite Automt (NFA) An NFA is 5-tuple (Σ, Q, q 0, F, δ) where Σ, Q, q0, F s with DFAs δ Q x (Σ È {ε}) x Q specifies the NFA's trnsitions S1 S2 ε Exmple S3 Σ = {} Q = {S1, S2, S3} q 0 = S1 F = {S3} δ = { (S1,,S1), (S1,,S2), (S2,ε,S3) } An NFA ccepts s if there is t lest one pth vi s from the NFA s strt stte to finl stte CMSC 330 Spring

15 Relting REs to DFAs nd NFAs Regulr expressions, NFAs, nd DFAs ccept the sme lnguges! DFA cn reduce NFA cn trnsform cn reduce RE CMSC 330 Spring

16 Reducing Regulr Expressions to NFAs Gol: Given regulr expression A, construct NFA: <A> = (Σ, Q, q 0, F, δ) Remember regulr expressions re defined recursively from primitive RE lnguges Invrint: F = 1 in our NFAs Ø Recll F = set of finl sttes Will define <A> for bse cses: σ, ε, Where σ is symbol in Σ And for inductive cses: AB, A B, A* CMSC 330 Spring

17 Reducing Regulr Expressions to NFAs Bse cse: σ σ <σ> = ({σ}, {S0, S1}, S0, {S1}, {(S0, σ, S1)} ) CMSC 330 Spring

18 Reduction Bse cse: ε <ε> = (, {S0}, S0, {S0}, ) Bse cse: < > = (, {S0, S1}, S0, {S1}, ) CMSC 330 Spring

19 Reduction: Conctention Induction: AB <A> <B> <A> = (Σ A, Q A, q A, {f A }, δ A ) <B> = (Σ B, Q B, q B, {f B }, δ B ) CMSC 330 Spring

20 Reduction: Conctention Induction: AB <A> <B> <A> = (Σ A, Q A, q A, {f A }, δ A ) <B> = (Σ B, Q B, q B, {f B }, δ B ) <AB> = (Σ A È Σ B, Q A È Q B, q A, {f B }, δ A È δ B È {(f A,ε,q B )} ) CMSC 330 Spring

21 Reduction: Union Induction: A B <A> = (Σ A, Q A, q A, {f A }, δ A ) <B> = (Σ B, Q B, q B, {f B }, δ B ) CMSC 330 Spring

22 Reduction: Union Induction: A B <A> = (Σ A, Q A, q A, {f A }, δ A ) <B> = (Σ B, Q B, q B, {f B }, δ B ) <A B> = (Σ A È Σ B, Q A È Q B È {S0,S1}, S0, {S1}, δ A È δ B È {(S0,ε,q A ), (S0,ε,q B ), (f A,ε,S1), (f B,ε,S1)}) CMSC 330 Spring

23 Reduction: Closure Induction: A* <A> = (Σ A, Q A, q A, {f A }, δ A ) CMSC 330 Spring

24 Reduction: Closure Induction: A* <A> = (Σ A, Q A, q A, {f A }, δ A ) <A*> = (Σ A, Q A È {S0,S1}, S0, {S1}, δ A È {(f A,ε,S1), (S0,ε,q A ), (S0,ε,S1), (S1,ε,S0)}) CMSC 330 Spring

25 Quiz 2: Which NFA mtches *? A. B. C. D. CMSC 330 Spring

26 Quiz 2: Which NFA mtches *? A. B. C. D. CMSC 330 Spring

27 Quiz 3: Which NFA mtches b*? A. B. C. D. CMSC 330 Spring

28 Quiz 3: Which NFA mtches b*? A. B. C. D. CMSC 330 Spring

29 Reduction Complexity Given regulr expression A of size n... Size = # of symbols + # of opertions How mny sttes does <A> hve? Two dded for ech, two dded for ech * O(n) Tht s pretty good! CMSC 330 Spring

30 Reducing NFA to DFA DFA cn reduce NFA cn reduce RE CMSC 330 Spring

31 Reducing NFA to DFA NFA my be reduced to DFA By explicitly trcking the set of NFA sttes Intuition Build DFA where Ø Ech DFA stte represents set of NFA current sttes Exmple S1 S2 ε S3 S1 S1, S2, S3 NFA DFA CMSC 330 Spring

32 Algorithm for Reducing NFA to DFA Reduction pplied using the subset lgorithm DFA stte is subset of set of ll NFA sttes Algorithm Input Ø NFA (Σ, Q, q 0, F n, δ) Output Ø DFA (Σ, R, r 0, F d, d) Using two subroutines Ø ε-closure(d, p) (nd ε-closure(d, S)) Ø move(d, p, ) (nd move(d, S, )) CMSC 330 Spring

33 ε-trnsitions nd ε-closure ε We sy p q If it is possible to go from stte p to stte q by tking only e-trnsitions in δ If $ p, p 1, p 2, p n, q Î Q such tht Ø {p,ε,p 1 } Î δ, {p 1,ε,p 2 } Î δ,, {p n,ε,q} Î δ ε-closure(δ, p) Set of sttes rechble from p using ε-trnsitions lone Ø Set of sttes q such tht p ε q ccording to δ Ø ε-closure(δ, p) = {q p ε q in δ } ε Ø ε-closure(δ, Q) = { q p Î Q, p q in δ } Notes Ø ε-closure(δ, p) lwys includes p Ø We write ε-closure(p) or ε-closure(q) when δ is cler from context CMSC 330 Spring

34 ε-closure: Exmple 1 Following NFA contins ε S1 S2 ε S2 S3 ε S1 S3 ε ε Ø Since S1 S2 nd S2 S3 ε ε S1 S2 S3 ε-closures ε-closure(s1) = ε-closure(s2) = ε-closure(s3) = { S3 } ε-closure( { S1, S2 } ) = { S1, S2, S3 } { S2, S3 } { S1, S2, S3 } È { S2, S3 } CMSC 330 Spring

35 ε-closure: Exmple 2 Following NFA contins ε S1 S3 ε S3 S2 ε S1 S2 ε ε Ø Since S1 S3 nd S3 S2 b S1 S2 S3 ε ε ε-closures ε-closure(s1) = ε-closure(s2) = ε-closure(s3) = { S1, S2, S3 } { S2 } { S2, S3 } ε-closure( { S2,S3 } ) = { S2 } È { S2, S3 } CMSC 330 Spring

36 ε-closure Algorithm: Approch Input: NFA (Σ, Q, q 0, F n, δ), Stte Set R Output: Stte Set R Algorithm Let R = R Repet Let R = R Let R = R È {q p Î R, (p, e, q) Î d} Until R = R // strt sttes // continue from previous // new ε-rechble sttes // stop when no new sttes This lgorithm computes fixed point see note linked from project description CMSC 330 Spring

37 ε-closure Algorithm Exmple Clculte ε-closure(d,{s1}) R R ε ε S1 S2 S3 {S1} {S1} {S1} {S1, S2} {S1, S2} {S1, S2, S3} Let R = R Repet Let R= R Let R = R È {q p Î R, (p, e, q) Î d} Until R = R {S1, S2, S3} {S1, S2, S3} CMSC 330 Spring

38 Clculting move(p,) move(δ,p,) Set of sttes rechble from p using exctly one trnsition on Ø Set of sttes q such tht {p,, q} Î δ Ø move(δ,p,) = { q {p,, q} Î δ } Ø move(δ,q,) = { q p Î Q, {p,, q} Î δ } i.e., cn lift move() to strt from set of sttes Q Notes: Ø move(δ,p,) is Ø if no trnsition (p,,q) Î δ, for ny q Ø We write move(p,) or move(r,) when δ cler from context CMSC 330 Spring

39 move(,p) : Exmple 1 Following NFA Σ = {, b } Move move(s1, ) = move(s1, b) = move(s2, ) = move(s2, b) = move(s3, ) = move(s3, b) = { S2, S3 } Ø Ø { S3 } Ø Ø b S1 S2 S3 move({s1,s2},b) = { S3 } CMSC 330 Spring

40 move(,p) : Exmple 2 Following NFA Σ = {, b } Move move(s1, ) = move(s1, b) = move(s2, ) = move(s2, b) = move(s3, ) = move(s3, b) = { S2 } { S3 } { S3 } Ø Ø Ø S1 S2 S3 b move({s1,s2},) = {S2,S3} ε CMSC 330 Spring

41 NFA DFA Reduction Algorithm ( subset ) Input NFA (Σ, Q, q 0, F n, δ), Output DFA (Σ, R, r 0, F d, d ) Algorithm Let r 0 = e-closure(δ,q 0 ), dd it to R While $ n unmrked stte r Î R Mrk r For ech Î S Let E = move(δ,r,) Let e = e-closure(δ,e) If e Ï R Let R = R È {e} Let d = d È {r,, e} Let F d = {r $ s Î r with s Î F n } // DFA strt stte // process DFA stte r // ech stte visited once // for ech letter // sttes reched vi // sttes reched vi e // if stte e is new // dd e to R (unmrked) // dd trnsition r e // finl if include stte in F n CMSC 330 Spring

42 NFA DFA Exmple 1 Strt = e-closure(δ,s1) = { {S1,S3} } R = { {S1,S3} } r Î R = {S1,S3} move(δ,{s1,s3},) = {S2} Ø e = e-closure(δ,{s2}) = {S2} Ø R = R È {{S2}} = { {S1,S3}, {S2} } Ø d = d È {{S1,S3},, {S2}} move(δ,{s1,s3},b) = Ø b S1 S2 S3 {1,3} NFA DFA {2} ε CMSC 330 Spring

43 NFA DFA Exmple 1 (cont.) R = { {S1,S3}, {S2} } r Î R = {S2} move(δ,{s2},) = Ø move(δ,{s2},b) = {S3} Ø e = e-closure(δ,{s3}) = {S3} Ø R = R È {{S3}} = { {S1,S3}, {S2}, {S3} } Ø d = d È {{S2}, b, {S3}} b S1 S2 S3 {1,3} NFA DFA {2} ε b {3} CMSC 330 Spring

44 NFA DFA Exmple 1 (cont.) R = { {S1,S3}, {S2}, {S3} } r Î R = {S3} Move({S3},) = Ø Move({S3},b) = Ø Mrk {S3}, exit loop F d = {{S1,S3}, {S3}} Ø Since S3 Î F n Done! b S1 S2 S3 {1,3} NFA DFA {2} ε b {3} CMSC 330 Spring

45 Quiz 4: Which DFA is equiv to this NFA? NFA: b S0 S1 S2 ε A. S0 S1 b S1, S2 b B. C. S0 S1 S2, S0 S0 S1 b S2, S0 D. None of the bove CMSC 330 Spring b

46 Quiz 4: Which DFA is equiv to this NFA? NFA: b S0 S1 S2 ε A. S0 S1 b S1, S2 b B. C. S0 S1 S2, S0 S0 S1 b S2, S0 D. None of the bove CMSC 330 Spring b

47 Actul Answer b S0 S1 S2 NFA: ε S0 S1 b S2, S0 b S1, S0 CMSC 330 Spring

48 Subset Algorithm s Fixed Point Input: NFA (Σ, Q, q 0, F, δ) Output: DFA M Algorithm Let q 0 = ε-closure(δ, q 0 ) Let F = {q 0 } if q 0 F, or otherwise Let M = (Σ, {q 0 }, q 0, F, ) DFA // strting pproximtion of Repet Let M = M // current DFA pprox For ech q Î sttes(m), Î Σ // for ech DFA stte q nd letter Let s = ε-closure(δ, move(δ, q, )) // new subset from q Let F = {s} if s F, or otherwise, // subset contins finl? M = M È (, {s},, F, {(q,, s)}) // updte DFA Until M = M // reched fixed point CMSC 330 Spring

49 Redux: DFA to NFA Exmple 1 q ' ε-closure(δ,s1) = {S1,S3} F = {{S1,S3}} since {S1,S3} {S3} NFA b S1 S2 S3 {1,3} M = { Σ, {{S1,S3}}, {S1,S3}, {{S1,S3}}, } Q q 0 ' F δ' DFA ε CMSC 330 Spring

50 Redux: DFA to NFA Exmple 1 (cont) M = { Σ, {{S1,S3}}, {S1,S3}, {{S1,S3}}, } q = {S1, S3} = s = {S2} Ø since move(δ,{s1, S3},) = {S2} Ø nd e-closure(δ,{s2}) = {S2} F = Ø Ø Since {S2} {S3} = where s = {S2} nd F = {S3} b S1 S2 S3 {1,3} CMSC 330 Spring NFA DFA M = M È ( { S2}},, { S1,S3},,{S2 } { Σ, {{S1,S3},{S2}}, {S1,S3}, {{S1,S3}}, {({S1,S3},,{S2})} } {2} Q q 0 ' F δ' ε

51 Redux: DFA to NFA Exmple 1 (cont) M = { Σ, {{S1,S3},{S2}}, {S1,S3}, {{S1,S3}}, {({S1,S3},,{S2})} } q = {S2} = b s = {S3} Ø since move(δ,{s2},b) = {S3} Ø nd e-closure(δ,{s3}) = {S3} F = {{S3}} Ø Ø Since {S3} {S3} = {S3} where s = {S3} nd F = {S3} {1,3} M = M È { S3 {{S3}} { S2 b S3 } NFA b S1 S2 S3 DFA { Σ, {{S1,S3},{S2},{S3}}, {S1,S3}, {{S1,S3},{S3}}, {({S1,S3},,{S2}), ({S2},b,{S3})} } Q q 0 ' F δ' CMSC 330 Spring {2} ε b {3}

52 Anlyzing the Reduction Cn reduce ny NFA to DFA using subset lg. How mny sttes in the DFA? Ech DFA stte is subset of the set of NFA sttes Given NFA with n sttes, DFA my hve 2 n sttes Ø Since set with n items my hve 2 n subsets Corollry Ø Reducing NFA with n sttes my be O(2 n ) CMSC 330 Spring

53 Reducing DFA to RE DFA cn reduce NFA cn trnsform cn trnsform RE CMSC 330 Spring

54 Reducing DFAs to REs Generl ide Remove sttes one by one, lbeling trnsitions with regulr expressions When two sttes re left (strt nd finl), the trnsition lbel is the regulr expression for the DFA CMSC 330 Spring

55 Other Topics Minimizing DFA Hopcroft reduction Complementing DFA Implementing DFA CMSC 330 Spring

56 Minimizing DFAs Every regulr lnguge is recognizble by unique minimum-stte DFA Ignoring the prticulr nmes of sttes In other words For every DFA, there is unique DFA with minimum number of sttes tht ccepts the sme lnguge b S1 S2 S3 c CMSC 330 Spring S1 c S3 S2 b

57 J. Hopcroft, An n log n lgorithm for minimizing sttes in finite utomton, 1971 Minimizing DFA: Hopcroft Reduction Intuition Look to distinguish sttes from ech other Ø End up in different ccept / non-ccept stte with identicl input Algorithm Construct initil prtition Ø Accepting & non-ccepting sttes Itertively split prtitions (until prtitions remin fixed) Ø Split prtition if members in prtition hve trnsitions to different prtitions for sme input Two sttes x, y belong in sme prtition if nd only if for ll symbols in Σ they trnsition to the sme prtition Updte trnsitions & remove ded sttes CMSC 330 Spring

58 Splitting Prtitions No need to split prtition {S,T,U,V} All trnsitions on led to identicl prtition P2 Even though trnsitions on led to different sttes S P1 X P2 T Y U V Z CMSC 330 Spring

59 Splitting Prtitions (cont.) Need to split prtition {S,T,U} into {S,T}, {U} Trnsitions on from S,T led to prtition P2 Trnsition on from U led to prtition P3 S P1 X P2 P4 U T Z Y b P3 CMSC 330 Spring

60 Resplitting Prtitions Need to reexmine prtitions fter splits Initilly no need to split prtition {S,T,U} After splitting prtition {X,Y} into {X}, {Y} we need to split prtition {S,T,U} into {S,T}, {U} P4 S U T P1 CMSC 330 Spring b P3 X b P2 Y

61 Minimizing DFA: Exmple 1 DFA b S T R Initil prtitions b Split prtition CMSC 330 Spring

62 Minimizing DFA: Exmple 1 DFA Initil prtitions Accept { R } = P1 b P2 P1 Reject { S, T } = P2 Split prtition? Not required, minimiztion done move(s,) move(t,) = T P2 = T P2 b S T R b move(s,b) move (T,b) = R P1 = R P1 CMSC 330 Spring

63 Minimizing DFA: Exmple 2 b S T R b CMSC 330 Spring

64 Minimizing DFA: Exmple 2 DFA P2 b S T R P1 Initil prtitions Accept Reject { R } { S, T } = P1 = P2 Split prtition? Yes, different prtitions for B move(s,) move(t,) = T P2 = T P2 b P3 move(s,b) move (T,b) DFA lredy miniml = T P2 = R P1 CMSC 330 Spring

65 Complement of DFA Given DFA ccepting lnguge L How cn we crete DFA ccepting its complement? Exmple DFA Ø Σ = {,b} CMSC 330 Spring

66 Complement of DFA Algorithm Add explicit trnsitions to ded stte Chnge every ccepting stte to non-ccepting stte & every non-ccepting stte to n ccepting stte Note this only works with DFAs Why not with NFAs? CMSC 330 Spring

67 Implementing DFAs (one-off) It's esy to build progrm which mimics DFA cur_stte = 0; while (1) { symbol = getchr(); switch (cur_stte) { cse 0: switch (symbol) { cse '0': cur_stte = 0; brek; cse '1': cur_stte = 1; brek; cse '\n': printf("rejected\n"); return 0; defult: printf("rejected\n"); return 0; } brek; } } cse 1: switch (symbol) { cse '0': cur_stte = 0; brek; cse '1': cur_stte = 1; brek; cse '\n': printf("ccepted\n"); return 1; defult: printf("rejected\n"); return 0; } brek; defult: printf("unknown stte; I'm confused\n"); brek; CMSC 330 Spring

68 Implementing DFAs (generic) More generlly, use generic tble-driven DFA given components (Σ, Q, q 0, F, d) of DFA: let q = q 0 while (there exists nother symbol s of the input string) q := d(q, s); if q Î F then ccept else reject q is just n integer Represent d using rrys or hsh tbles Represent F s set CMSC 330 Spring

69 Running Time of DFA How long for DFA to decide to ccept/reject string s? Assume we cn compute d(q, c) in constnt time Then time to process s is O( s ) Ø Cn t get much fster! Constructing DFA for RE A my tke O(2 A ) time But usully not the cse in prctice So there s the initil overhed But then processing strings is fst CMSC 330 Spring

70 Summry of Regulr Expression Theory Finite utomt DFA, NFA Equivlence of RE, NFA, DFA RE NFA Ø Conctention, union, closure NFA DFA Ø e-closure & subset lgorithm DFA Minimiztion, complement Implementtion CMSC 330 Spring

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 Tble of Contents: Week 1: Preliminries (set lgebr, reltions, functions) (red Chpters 1-4) Weeks

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

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

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

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

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

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

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

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

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

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

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

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

1.4 Nonregular Languages

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

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

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

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

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

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

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

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

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

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

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

More information

Lecture 6 Regular Grammars

Lecture 6 Regular Grammars Lecture 6 Regulr Grmmrs COT 4420 Theory of Computtion Section 3.3 Grmmr A grmmr G is defined s qudruple G = (V, T, S, P) V is finite set of vribles T is finite set of terminl symbols S V is specil vrible

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

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

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

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

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

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

More information

Where did dynamic programming come from?

Where did dynamic programming come from? Where did dynmic progrmming come from? String lgorithms Dvid Kuchk cs302 Spring 2012 Richrd ellmn On the irth of Dynmic Progrmming Sturt Dreyfus http://www.eng.tu.c.il/~mi/cd/ or50/1526-5463-2002-50-01-0048.pdf

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

Automata and Languages

Automata and Languages Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering Lb. The University of Aizu Jpn Grmmr Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Regulr Lnguges Context Free Lnguges Context Sensitive

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

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

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

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

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

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

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

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

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

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

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

Today s Topics Automata and Languages

Today s Topics Automata and Languages Tody s Topics Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn DFA to Regulr Expression GFNA DFAèGNFA GNFA è RE DFA è RE Exmples 2 DFA è RE NFA DFA -NFA REX GNFA 3 Definition

More information

Automata and Languages

Automata and Languages Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Tody s Topics DFA to Regulr Expression GFNA DFAèGNFA GNFA è RE DFA è RE Exmples 2 DFA è RE NFA DFA -NFA REX GNFA 3 Definition

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

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model? CS125 Lecture 11 Fll 2016 11.1 Finite Automt Motivtion: TMs without tpe: mybe we cn t lest fully understnd such simple model? Algorithms (e.g. string mtching) Computing with very limited memory Forml verifiction

More information

Turing Machines Part One

Turing Machines Part One Turing Mchines Prt One Wht problems cn we solve with computer? Regulr Lnguges CFLs Lnguges recognizble by ny fesible computing mchine All Lnguges Tht sme drwing, to scle. All Lnguges The Problem Finite

More information

Turing Machines Part One

Turing Machines Part One Turing Mchines Prt One Hello Hello Condensed Condensed Slide Slide Reders! Reders! Tody s Tody s lecture lecture consists consists lmost lmost exclusively exclusively of of nimtions nimtions of of Turing

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

Deterministic Finite-State Automata

Deterministic Finite-State Automata Deterministic Finite-Stte Automt Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 12 August 2013 Outline 1 Introduction 2 Exmple DFA 1 DFA for Odd number of

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

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

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

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

This lecture covers Chapter 8 of HMU: Properties of CFLs

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

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

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

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

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

Finite Automata Part Three

Finite Automata Part Three Finite Automt Prt Three Hello Hello Wonderful Wonderful Condensed Condensed Slide Slide Reders! Reders! The The first first hlf hlf of of this this lecture lecture consists consists lmost lmost exclusively

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

Normal Forms for Context-free Grammars

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

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

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

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

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/ Midterm 1 Prctice CS 350 Fll 2018 gilry.org/clsses/fll2018/cs350/ 1 Midterm #1: Thursdy, Septemer 27! Bring less stuff, if possile. Keep ny gs under the tle. You my hve out: pencil, pen, nd/or erser. My

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES nd REGULAR EXPRESSIONS TUESDAY Jn 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w hs equl numer of

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

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

CS5371 Theory of Computation. Lecture 20: Complexity V (Polynomial-Time Reducibility)

CS5371 Theory of Computation. Lecture 20: Complexity V (Polynomial-Time Reducibility) CS5371 Theory of Computtion Lecture 20: Complexity V (Polynomil-Time Reducibility) Objectives Polynomil Time Reducibility Prove Cook-Levin Theorem Polynomil Time Reducibility Previously, we lernt tht if

More information

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

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Mehryr Mohri Cournt Institute nd Google Reserch mohri@cims.nyu.com Preliminries Finite lphet Σ, empty string. Set of ll strings over

More information

19 Optimal behavior: Game theory

19 Optimal behavior: Game theory Intro. to Artificil Intelligence: Dle Schuurmns, Relu Ptrscu 1 19 Optiml behvior: Gme theory Adversril stte dynmics hve to ccount for worst cse Compute policy π : S A tht mximizes minimum rewrd Let S (,

More information