DFA (Deterministic Finite Automata) q a

Size: px
Start display at page:

Download "DFA (Deterministic Finite Automata) q a"

Transcription

1 Big pictur All lngugs Dcidl Turing mchins NP P Contxt-fr Contxt-fr grmmrs, push-down utomt Rgulr Automt, non-dtrministic utomt, rgulr xprssions

2 DFA (Dtrministic Finit Automt) 0 q q

3 DFA (Dtrministic Finit Automt) 0 q q Stts, this DFA hs 4 stts Trnsitions llld with lmnts of th lpht S = {0,}

4 DFA (Dtrministic Finit Automt) 0 q 0 0 Computtion on input w: Bgin in strt stt 0 q 0 0 q Rd input string in on-wy fshion Follow th rrows mtching input symols Whn input nds: ACCEPT if in ccpt stt REJECT if not

5 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

6 DFA (Dtrministic Finit Automt) lwys strt in strt stt q q 0 Exmpl: Input string w = 00

7 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

8 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

9 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

10 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

11 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00 ACCEPT cus nd in ccpt stt

12 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

13 DFA (Dtrministic Finit Automt) lwys strt in strt stt q q 0 Exmpl: Input string w = 00

14 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

15 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

16 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00

17 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 00 REJECT cus dos not nd in ccpt stt

18 DFA (Dtrministic Finit Automt) 0 q q 0 Exmpl: Input string w = 0 ACCEPT w = 00 REJECT w = 00 ACCEPT w = 000 REJECT

19 Exmpl: 00 is n lmnt of L(M), 00 L(M) M := DFA (Dtrministic Finit Automt) q 0 0 M rcognizs lngug L(M) = { w : w strts with 0 nd nds with } L(M) is th lngug of strings cusing M to ccpt q

20 Exmpl S = {0,} M := q 0 q cuss M to ccpt, so 00 is in L(M) 00 L(M) 0 dos not cus M to ccpt, so 0 not in L(M), 00 L(M) 0000 L(M) 000 L(M) 0 L(M)

21 Exmpl M := q 0 q S = {0,} 0 0 L(M) = {w : w hs n vn numr of } Not: If thr is no, thn thr r zro, zro is n vn numr, so M should ccpt. Indd L(M)

22 Exmpl S = {0,} M := 0 L(M) =?

23 Exmpl S = {0,} M := 0 L(M) = vry possil string ovr {0,} = {0,}*

24 Exmpl S = {0,} M := 0 0 q 0 0 L(M) =?

25 Exmpl S = {0,} M := 0 0 q 0 0 L(M) = ll strings ovr {0,} xcpt mpty string = {0,}* - { }

26 Exmpl S = {0,} M := 0 q 0 L(M) =?

27 Exmpl S = {0,} M := 0 q L(M) = { w : w strts nd nds with sm symol } Mmory is ncodd in wht?

28 Exmpl S = {0,} M := 0 q Rmmr 0 Rmmr L(M) = { w : w strts nd nds with sm symol } Mmory is ncodd in stts. DFA hv finit stts, so finit mmory

29 M := Convntion: q 0 0 W lrdy sw tht 0 0 L(M) = { w : w strts with 0 nd nds with } 0 q Th rrow q 0 lds to sink stt. If followd, M cn nvr ccpt

30 Convntion: M := q q Don't nd to writ such rrows: If, from som stt, rd symol with no corrsponding rrow, imgin M gos into sink stt tht is not shown, nd REJECT. This mks picturs mor compct.

31 Anothr convntion: List multipl trnsition on sm rrow: 0,,2 Mns 2 0 This mks picturs mor compct.

32 Exmpl = {0,} M = 0, 0, L(M) =?

33 Exmpl = {0,} M = 0, 0, L(M) = 2 = {00,0,0,}

34 Exmpl from progrmming lngugs: Rcogniz strings rprsnting numrs: S = {0,,2,3,4,5,6,7,8,9, +, -,. } + - 0,...,9 0,...,9. 0,...,9 0,...,9 Not: 0,...,9 mns 0,,2,3,4,5,6,7,8,9: 0 trnsitions

35 Exmpl from progrmming lngugs: Rcogniz strings rprsnting numrs: S = {0,,2,3,4,5,6,7,8,9, +, -,. } + - 0,...,9 0,...,9. 0,...,9 Possily put sign (+, -) 0,...,9 Follow with ritrrily mny digits, ut t lst on Possily put dciml point Follow with ritrrily mny digits, possily non

36 Exmpl from progrmming lngugs: Rcogniz strings rprsnting numrs: S = {0,,2,3,4,5,6,7,8,9, +, -,. } + - 0,...,9 0,...,9. 0,...,9 Input w = 7 ACCEPT Input w = + REJECT Input w = ACCEPT Input w = REJECT 0,...,9

37 Exmpl S = {0,} Wht out { w : w hs sm numr of 0 nd } Cn you dsign DFA tht rcognizs tht? It sms you nd infinit mmory W will prov ltr tht thr is no DFA tht rcognizs tht lngug!

38 Nxt: forml dfinition of DFA Usful to prov vrious proprtis of DFA Espcilly importnt to prov tht things CANNOT rcognizd y DFA. Usful to prctic mthmticl nottion

39 Stt digrm of DFA: On or mor stts Exctly on strt stt Som numr of ccpt stts Llld trnsitions xiting ch stt, for vry symol in S

40 Dfinition: A finit utomton (DFA) is 5-tupl (Q, S, d, q 0, F) whr Q is finit st of stts S is th input lpht d : Q X S Q is th trnsition function q 0 in Q is th strt stt F Q is th st of ccpt stts Q X S is th st of ordrd pirs (,) : Q, Exmpl {q,r,s}x{0,}={(q,0),(q,),(r,0),(r,),(s,0),(s,)}

41 q 0 q 0 0 Exmpl: ov DFA is 5-tupl (Q, S, d, q0, F) whr Q = { q 0, q } S = {0,} d(q0,0) =?

42 q 0 q 0 0 Exmpl: ov DFA is 5-tupl (Q, S, d, q0, F) whr Q = { q 0, q } S = {0,} d(q0,0) = q 0 d(q 0,) =?

43 q 0 q 0 0 Exmpl: ov DFA is 5-tupl (Q, S, d, q0, F) whr Q = { q 0, q } S = {0,} d(q0,0) = q 0 d(q 0,) = q d(q,0) = q d(q,) = q 0 q 0 in Q is th strt stt F =?

44 q 0 q 0 0 Exmpl: ov DFA is 5-tupl (Q, S, d, q0, F) whr Q = { q 0, q } S = {0,} d(q0,0) = q 0 d(q 0,) = q d(q,0) = q d(q,) = q 0 q 0 in Q is th strt stt F = { q0 } Q is th st of ccpt stts

45 Dfinition: A DFA (Q, S, d, q0, F) ccpts string w if w = w w 2 w k whr, i k, w i is in S (th k symols of w) Th squnc of k+ stts r 0, r,.., r k such tht: () r 0 = q 0, nd (2) r i+ = d(r i,w i+ ) 0 i < k hs r k in F (r i = stt DFA is in ftr rding i-th symol in w)

46 Exmpl q 0 q 0 0 Aov DFA (Q, S, d, q0, F) ccpts w = 0

47 Exmpl q 0 q 0 0 Aov DFA (Q, S, d, q0, F) ccpts w = 0 w = 0 = w w 2 w 3 w = 0 w 2 = w 3 =

48 Exmpl q 0 q 0 0 Aov DFA (Q, S, d, q0, F) ccpts w = 0 w = 0 = w w 2 w 3 w = 0 w 2 = w 3 = W must show tht Th squnc of 3+=4 stts r 0, r, r 2, r 3 such tht: () r 0 = q 0 (2) r i+ = d(r i,w i+ ) 0 i < 3 hs r 3 in F

49 Exmpl q 0 q 0 0 Aov DFA (Q, S, d, q0, F) ccpts w = 0 w = 0 = w w 2 w 3 w = 0 w 2 = w 3 = r 0 = q 0 r :=?

50 Exmpl q 0 q 0 0 Aov DFA (Q, S, d, q0, F) ccpts w = 0 w = 0 = w w 2 w 3 w = 0 w 2 = w 3 = r 0 = q 0 r = d(r 0,w )=d(q 0,0 ) = q 0 r 2 :=?

51 Exmpl q 0 q 0 0 Aov DFA (Q, S, d, q0, F) ccpts w = 0 w = 0 = w w 2 w 3 w = 0 w 2 = w 3 = r 0 = q 0 r = d(r 0,w )=d(q 0,0 ) = q 0 r 2 = d(r,w 2 )=d(q 0, ) = q r 3 :=?

52 Exmpl q 0 q 0 0 Aov DFA (Q, S, d, q0, F) ccpts w = 0 w = 0 = w w 2 w 3 w = 0 w 2 = w 3 = r 0 = q 0 r = d(r 0,w )=d(q 0,0 ) = q 0 r 2 = d(r,w 2 )=d(q 0, ) = q r 3 = d(r 2,w 3 )=d(q, ) = q 0 r 3 = q 0 in F OK DONE!

53 Dfinition: For DFA M, w dnot y L(M) th st of strings ccptd y M: L(M) := { w : M ccpts w} W sy M ccpts or rcognizs th lngug L(M) Dfinition: A lngug L is rgulr if $ DFA M : L(M) = L

54 In th nxt lcturs w wnt to: Undrstnd powr of rgulr lngugs Dvlop ltrnt, compct nottion to spcify rgulr lngugs Exmpl: Unix commnd grp '\<c.*h\>' fil slcts ll words strting with c nd nding with h in fil

55 Undrstnd powr of rgulr lngugs: Suppos A, B r rgulr lngugs, wht out not A := { w : w is not in A } A U B := { w : w in A or w in B } A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i } Ar ths lngugs rgulr?

56 Undrstnd powr of rgulr lngugs: Suppos A, B r rgulr lngugs, wht out not A := { w : w is not in A } A U B := { w : w in A or w in B } A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i } Trminology: Ar rgulr lngugs closd undr not, U, o, *?

57 Thorm: If A is rgulr lngug, thn so is (not A)

58 Thorm: If A is rgulr lngug, thn so is (not A) Proof id:?????????? th st of ccpt stts

59 Thorm: If A is rgulr lngug, thn so is (not A) Proof id: Complmnt th st of ccpt stts Exmpl

60 Thorm: If A is rgulr lngug, thn so is (not A) Proof id: Complmnt th st of ccpt stts Exmpl: M := L(M) = q 0 q 0 0 { w : w hs vn numr of }

61 Thorm: If A is rgulr lngug, thn so is (not A) Proof id: Complmnt th st of ccpt stts Exmpl: M := q 0 q 0 0 M' := q 0 q 0 0 L(M) = { w : w hs vn numr of } L(M') = not L(M) = { w : w hs odd numr of }

62 Thorm: If A is rgulr lngug, thn so is (not A) Proof: Givn DFA M = (Q, S, d, q 0, F) such tht L(M) = A. Dfin DFA M' =?????????????????????????? This dfinition is th crtiv stp of this proof, th rst is (prhps complictd ut) mchnicl unwrpping dfinitions

63 Thorm: If A is rgulr lngug, thn so is (not A) Proof: Givn DFA M = (Q, S, d, q 0, F) such tht L(M) = A. Dfin DFA M' = (Q, S, d, q 0, F'), whr F' := not F. W nd to show L(M') = not L(M), tht is: for ny w,??????????????????????????

64 Thorm: If A is rgulr lngug, thn so is (not A) Proof: Givn DFA M = (Q, S, d, q 0, F) such tht L(M) = A. Dfin DFA M' = (Q, S, d, q 0, F'), whr F' := not F. W nd to show L(M') = not L(M), tht is: for ny w, M' ccpts w M dos not ccpt w. So lt w ny string of lngth k, nd considr th k+ stts r 0, r,.., r k from th dfinition of ccpt: () r 0 = q 0, nd (2) r i+ = d(r i,w i+ ) 0 i < k. How do w conclud?

65 Thorm: If A is rgulr lngug, thn so is (not A) Proof: Givn DFA M = (Q, S, d, q 0, F) such tht L(M) = A. Dfin DFA M' = (Q, S, d, q 0, F'), whr F' := not F. W nd to show L(M') = not L(M), tht is: for ny w, M' ccpts w M dos not ccpt w So lt w ny string of lngth k, nd considr th k+ stts r 0, r,.., r k from th dfinition of ccpt: () r 0 = q 0, nd (2) r i+ = d(r i,w i+ ) 0 i < k. Not tht r k in F' r k not in F, sinc F' = not F.

66 Wht is proof? A proof is n xplntion, writtn in English, of why somthing is tru. Evry sntnc must logiclly connctd to th prvious ons, oftn y so, hnc, sinc, tc. Your udinc is humn ing, NOT mchin.

67 Thorm: If A is rgulr lngug, thn so is (not A) Proof: DFA M = (Q, S, d, q 0, F) such tht L(M) = A. DFA M' = (Q, S, d, q 0, F'), whr F' := not F. L(M') = not L(M) M' ccpts w M dos not ccpt w k+ stts r 0, r,.., r k () r 0 = q 0, nd (2) r i+ = d(r i,w i+ ) 0 i < k. r k in F' r k not in F, F' = not F.

68 To know proof mns to know ll th pyrmid Wht is proof? Complmnt th st of ccpt stts Givn DFA M = (Q, S, d, q 0, F) such tht L(M) = A. Dfin DFA M' = (Q, S, d, q 0, F'), whr F' := not F. W nd to show L(M') = not L(M), tht is: for ny w, M' ccpts w M dos not ccpt w Considr th k+ stts r 0, r,.., r k such tht: () r 0 = q 0, nd (2) r i+ = d(r i,w i+ ) 0 i < k. Not tht r k in F' r k not in F, sinc F' = not F.

69 Exmpl = {0,} M = 0, 0, L(M) = 2 = {00,0,0,} Wht is DFA M' : L(M') = not 2 = ll strings xcpt thos of lngth 2?

70 Exmpl = {0,} M' = 0, 0, 0, 0, L(M') = not 2 = {0,}* - {00,0,0,} Do not forgt th convntion out th sink stt!

71 Suppos A, B r rgulr lngugs, wht out not A := { w : w is not in A } REGULAR A U B := { w : w in A or w in B } A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i }

72 Thorm: If A, B r rgulr, thn so is A U B Proof id: Tk Crtsin product of stts In pir (q,q'), q trcks DFA for A, q' trcks DFA for B. Nxt w s n xmpl. In it w rvit with

73 Exmpl 0 M M A := B := c d 0 0 L(M L(M A ) = A =? B ) = B =?

74 Exmpl 0 M M A := B := c d 0 0 L(M A ) = A = L(M B ) = B = { w : w hs vn numr of } { w : w hs odd numr of 0} M AUB := How mny stts?

75 Exmpl 0 M M A := B := c d 0 0 L(M A ) = A = L(M B ) = B = { w : w hs vn numr of } { w : w hs odd numr of 0} M AUB :=,c,c L(M AUB ) = AUB = { w : w hs vn numr of, or odd numr of 0} 0,d,d 0

76 Thorm: If A, B r rgulr, thn so is A U B Proof: Givn DFA M A = (Q A,S, δ A,q A, F A ) such tht L(M) = A, DFA M B = (Q B,S, δ B,q B, F B ) such tht L(M) = B. Dfin DFA M = (Q, S, d, q 0, F), whr Q :=?

77 Thorm: If A, B r rgulr, thn so is A U B Proof: Givn DFA M A = (Q A,S, δ A,q A, F A ) such tht L(M) = A, DFA M B = (Q B,S, δ B,q B, F B ) such tht L(M) = B. Dfin DFA M = (Q, S, d, q 0, F), whr Q := Q A X Q B q 0 :=?

78 Thorm: If A, B r rgulr, thn so is A U B Proof: Givn DFA M A = (Q A,S, δ A,q A, F A ) such tht L(M) = A, DFA M B = (Q B,S, δ B,q B, F B ) such tht L(M) = B. Dfin DFA M = (Q, S, d, q 0, F), whr Q := Q A X Q B q 0 := (q A, q B ) F :=?

79 Thorm: If A, B r rgulr, thn so is A U B Proof: Givn DFA M A = (Q A,S, δ A,q A, F A ) such tht L(M) = A, DFA M B = (Q B,S, δ B,q B, F B ) such tht L(M) = B. Dfin DFA M = (Q, S, d, q 0, F), whr Q := Q A X Q B q 0 := (q A, q B ) F := {(q,q') Q : q F A or q' F B } δ( (q,q'), v) := (?,? )

80 Thorm: If A, B r rgulr, thn so is A U B Proof: Givn DFA M A = (Q A,S, δ A,q A, F A ) such tht L(M) = A, DFA M B = (Q B,S, δ B,q B, F B ) such tht L(M) = B. Dfin DFA M = (Q, S, d, q 0, F), whr Q := Q A X Q B q 0 := (q A, q B ) F := {(q,q') Q : q F A or q' F B } δ( (q,q'), v) := (δ A (q,v), δ B (q',v) ) W nd to show L(M) = A U B tht is, for ny w: M ccpts w M A ccpts w or M B ccpts w

81 Proof M ccpts w M A ccpts w or M B ccpts w Suppos tht M ccpts w of lngth k. From th dfinitions of ccpt nd M, th squnc (s 0, t 0 ) = q 0 = (q A, q B ), (s i+,t i+ )=d((s i,t i ),w i+ )=( δ A (s i,w i+ ), δ B (t i,w i+ ) 0 i< k hs (s k,t k )?

82 Proof M ccpts w M A ccpts w or M B ccpts w Suppos tht M ccpts w of lngth k. From th dfinitions of ccpt nd M, th squnc (s 0, t 0 ) = q 0 = (q A, q B ), (s i+,t i+ )=d((s i,t i ),w i+ )=( δ A (s i,w i+ ), δ B (t i,w i+ ) 0 i< k hs (s k,t k ) F. By our dfinition of F, wht cn w sy out (s k,t k )?

83 Proof M ccpts w M A ccpts w or M B ccpts w Suppos tht M ccpts w of lngth k. From th dfinitions of ccpt nd M, th squnc (s 0, t 0 ) = q 0 = (q A, q B ), (s i+,t i+ )=d((s i,t i ),w i+ )=( δ A (s i,w i+ ), δ B (t i,w i+ ) 0 i< k hs (s k,t k ) F. By our dfinition of F, s k F A or t k F B. Without loss of gnrlity, ssum s k F A. Thn M A ccpts w cus th squnc s 0 = q A, s i+ = δ A (s i, w i+ ) 0 i < k, hs s k F A.

84 Proof M ccpts w M A ccpts w or M B ccpts w W/out loss of gnrlity, ssum M A ccpts w, w =k. From th dfinition of M A ccpts w, th squnc r 0 := q A, r i+ := δ A (r i,w i+ ) 0 i < k, hs r k in?

85 Proof M ccpts w M A ccpts w or M B ccpts w W/out loss of gnrlity, ssum M A ccpts w, w =k. From th dfinition of M A ccpts w, th squnc r 0 := q A, r i+ := δ A (r i,w i+ ) 0 i < k, hs r k in F A. Dfin th squnc of k+ stts t 0 := q B, t i+ := δ B (t i,w i+ ) 0 i < k. M ccpts w cus th squnc?????????? (rcll stts in M r pirs)

86 Proof M ccpts w M A ccpts w or M B ccpts w W/out loss of gnrlity, ssum M A ccpts w, w =k. From th dfinition of M A ccpts w, th squnc r 0 := q A, r i+ := δ A (r i,w i+ ) 0 i < k, hs r k in F A. Dfin th squnc of k+ stts t 0 := q B, t i+ := δ B (t i,w i+ ) 0 i < k. M ccpts w cus th squnc (r 0, t 0 ) = q = (q A, q B ), (r i+,t i+ ) =d((r i,t i ),w i+ )=(δ A (r i,w i+ ),δ B (t i,w i+ ) 0 i< k hs (r,t ) in F, y our dfinition of F.

87 Suppos A, B r rgulr lngugs, wht out not A := { w : w is not in A } REGULAR A U B := { w : w in A or w in B } REGULAR A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i } Othr two r mor complictd! Pln: w introduc NFA prov tht NFA r quivlnt to DFA rprov A U B, prov A o B, A* rgulr, using NFA

88 Big pictur All lngugs Dcidl Turing mchins NP P Contxt-fr Contxt-fr grmmrs, push-down utomt Rgulr Automt, non-dtrministic utomt, rgulr xprssions

89 Non dtrministic finit utomt (NFA) DFA: givn stt nd input symol, uniqu choic for nxt stt, dtrministic: Nxt w llow multipl choics, non-dtrministic W lso llow -trnsitions: cn follow without rding nything

90 Exmpl of NFA q 0 q q, 2 Intuition of how it computs: Accpt string w if thr is wy to follow trnsitions tht nds in ccpt stt Trnsitions llld with symol in S = {,} must mtchd with input trnsitions cn followd without mtching

91 Exmpl of NFA q 0 q q, 2 Exmpl: Accpt (first follow -trnsition ) Accpt

92 ANOTHER Exmpl of NFA q 0 q q 3, q 2 Exmpl: Accpt (two ccpting pths, on Rjct uss th -trnsition) (two possil pths, ut nithr hs finl stt = q )

93 Dfinition: A non-dtrministic finit utomton (NFA) is 5-tupl (Q, S, d, q 0, F) whr Q is finit st of stts S is th input lpht d : Q X (S U {} ) Powrst(Q) q 0 in Q is th strt stt F Q is th st of ccpt stts Rcll: Powrst(Q) = st of ll susts of Q Exmpl: Powrst({,2}) =?

94 Dfinition: A non-dtrministic finit utomton (NFA) is 5-tupl (Q, S, d, q 0, F) whr Q is finit st of stts S is th input lpht d : Q X (S U {} ) Powrst(Q) q 0 in Q is th strt stt F Q is th st of ccpt stts Rcll: Powrst(Q) = st of ll susts of Q Exmpl: Powrst({,2}) = {, {}, {2}, {,2} }

95 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) =?

96 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) = {q 0 } d(q 0,) =?

97 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) = {q 0 } d(q 0,) = {q 0, q } d(q 0,) =?

98 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) = {q 0 } d(q 0,) = {q 0, q } d(q 0,) = d(q,0) =?

99 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) = {q 0 } d(q 0,) = {q 0, q } d(q 0,) = d(q,0) = d(q,) =?

100 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) = {q 0 } d(q 0,) = {q 0, q } d(q 0,) = d(q,0) = d(q,) = d(q,) =?

101 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) = {q 0 } d(q 0,) = {q 0, q } d(q 0,) = d(q,0) = d(q,) = d(q,) = {q 0 } q 0 in Q is th strt stt F =?

102 0, q 0 q Exmpl: ov NFA is 5-tupl (Q, S, d, q0, F) Q = { q 0, q } S = {0,} d(q0,0) = {q 0 } d(q 0,) = {q 0, q } d(q 0,) = d(q,0) = d(q,) = d(q,) = {q 0 } q 0 in Q is th strt stt F = { q } Q is th st of ccpt stts

103 Dfinition: A NFA (Q, S, d, q0, F) ccpts string w if $ intgr k, k strings w = w w 2 w k (th symols of w, or ) w, w 2,, w k such tht whr i k, w i S U {} $ squnc of k+ stts r0, r,.., r k in Q such tht: r 0 = q 0 r i+ d(r i,w i+ ) 0 i < k r k is in F Diffrncs with DFA r in grn

104 Bck to first xmpl NFA: q 0 q q, 2 Accpts w = w =, w 2 =, w 3 =, w 4 =, w 5 = Accpting squnc of 5+ = 6 stts: r 0 =?

105 Bck to first xmpl NFA: q 0 q q, 2 Accpts w = w =, w 2 =, w 3 =, w 4 =, w 5 = Accpting squnc of 5+ = 6 stts: r 0 = q 0, r =?

106 Bck to first xmpl NFA: q 0 q q, 2 Accpts w = w =, w 2 =, w 3 =, w 4 =, w 5 = Accpting squnc of 5+ = 6 stts: r 0 = q 0, r = q, r 2 =? Trnsitions: r d(r 0,) = {q }

107 Bck to first xmpl NFA: q 0 q q, 2 Accpts w = w =, w 2 =, w 3 =, w 4 =, w 5 = Accpting squnc of 5+ = 6 stts: r 0 = q 0, r = q, r 2 = q 2, r 3 =? Trnsitions: r d(r 0,) = {q } r 2 d(r,) = {q,q 2 }

108 Bck to first xmpl NFA: q 0 q q, 2 Accpts w = w =, w 2 =, w 3 =, w 4 =, w 5 = Accpting squnc of 5+ = 6 stts: r 0 = q 0, r = q, r 2 = q 2, r 3 = q 0, r 4 =? Trnsitions: r d(r 0,) = {q } r 2 d(r,) = {q,q 2 } r 3 d(r 2,) = {q 0 }

109 Bck to first xmpl NFA: q 0 q q, 2 Accpts w = w =, w 2 =, w 3 =, w 4 =, w 5 = Accpting squnc of 5+ = 6 stts: r 0 = q 0, r = q, r 2 = q 2, r 3 = q 0, r 4 = q 2, r 5 =? Trnsitions: r d(r 0,) = {q } r 2 d(r,) = {q,q 2 } r 3 d(r 2,) = {q 0 } r 4 d(r 3,) = {q 2 }

110 Bck to first xmpl NFA: q 0 q q, 2 Accpts w = w =, w 2 =, w 3 =, w 4 =, w 5 = Accpting squnc of 5+ = 6 stts: r 0 = q 0, r = q, r 2 = q 2, r 3 = q 0, r 4 = q 2, r 5 = q 0 Trnsitions: r d(r 0,) = {q } r 2 d(r,) = {q,q 2 } r 3 d(r 2,) = {q 0 } r 4 d(r 3,) = {q 2 } r 5 d(r 4,) = {q 0 }

111 NFA r t lst s powrful s DFA, cus DFA r spcil cs of NFA Ar NFA mor powrful thn DFA? Surprisingly, thy r not: Thorm: For vry NFA N thr is DFA M : L(M) = L(N)

112 Thorm: For vry NFA N thr is DFA M : L(M) = L(N) Construction without trnsitions Givn NFA N (Q, S, d, q, F) Construct DFA M (Q', S, d', q', F') whr: Q' := Powrst(Q) q' = {q} F' = { S : S Q' nd S contins n lmnt of F} d'(s, ) := U s S d(s,) = { t : t d (s,) for som s S }

113 It rmins to dl with trnsitions Dfinition: Lt S st of stts. E(S) := { q : q cn rchd from som stt s in S trvling long 0 or mor trnsitions } W think of following trnsitions t ginning, or right ftr rding n input symol in S

114 Thorm: For vry NFA N thr is DFA M : L(M) = L(N) Construction including trnsitions Givn NFA N (Q, S, d, q, F) Construct DFA M (Q', S, d', q', F') whr: Q' := Powrst(Q) q' = E({q}) F' = { S : S Q' nd S contins n lmnt of F} d'(s, ) := E( U s S d(s,) ) = { t : t E( d (s,) ) for som s S }

115 Exmpl: NFA DFA convrsion NFA DFA 2 3, {,3} {3} {2} {2,3} {,2,3} Q DFA = Powrst(Q NFA ) = Powrst({,2,3}) = {,{},{2},{3},{,2}...} {} {,2}

116 Exmpl: NFA DFA convrsion NFA DFA 2 3, q DFA = E({q NFA }) = E({}) = {,3} {,3} {3} {2} {2,3} {,2,3} {} {,2}

117 Exmpl: NFA DFA convrsion NFA DFA 2 3, {,3} {3} {2} {2,3} {,2,3} F DFA = {S : S contins n lmnt of F NFA } {} {,2}

118 Exmpl: NFA DFA convrsion NFA DFA 2 3, {,3} {3} {2} {2,3} {,2,3} d DFA ({}, ) = E(d NFA (, )) = E( ) = {} {,2}

119 Exmpl: NFA DFA convrsion NFA DFA 2 3, {,3} {3} {2} {2,3} {,2,3} d DFA ({}, ) = E(d NFA (, )) = E({2}) = {2} {} {,2}

120 Exmpl: NFA DFA convrsion NFA DFA 2 3, {,3} {3} {2} {2,3} {,2,3} d DFA ({2}, ) = E(d NFA (2, )) = E({2,3}) = {2,3} {} {,2}

121 Exmpl: NFA DFA convrsion NFA DFA {,3} {3} 2 3, {2} {2,3} {,2,3} d DFA ({2}, ) = E(d NFA (2, )) = E({3}) = {3} {} {,2}

122 Exmpl: NFA DFA convrsion NFA DFA {,3} {3} 2 3, {2} {2,3} {,2,3} d DFA ({3}, ) = E(d NFA (3, )) = E({}) = {,3} {} {,2}

123 Exmpl: NFA DFA convrsion NFA DFA {,3} {3} 2 3, {2} {2,3} {,2,3} d DFA ({3}, ) = E(d NFA (3, )) = E( ) = {} {,2}

124 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({2,3}, ) = E(d NFA (2,) U d NFA (3,)) = E({2,3} U {}) = {,2,3} {,3} {3} {2} {2,3} {} {,2} {,2,3}

125 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({2,3}, ) = E(d NFA (2,) U d NFA (3,)) = E({3} U ) = {3} {,3} {3} {2} {2,3} {} {,2} {,2,3}

126 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({,3}, ) = E(d NFA (,) U d NFA (3,)) = E( U {}) = {,3} {,3} {3} {2} {2,3} {} {,2} {,2,3}

127 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({,3}, ) = E(d NFA (,) U d NFA (3,)) = E({2} U ) = {2} {,3} {3} {2} {2,3} {} {,2} {,2,3}

128 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({,2}, ) = E(d NFA (,) U d NFA (2,)) = E( U {2,3}) = {2,3} {,3} {3} {2} {2,3} {} {,2} {,2,3}

129 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({,2}, ) = E(d NFA (,) U d NFA (2,)) = E({2} U {3}) = {2,3} {,3} {3} {2} {2,3}, {} {,2} {,2,3}

130 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({,2,3}, ) =E(d NFA (,) U d NFA (2,) U d NFA (3,)) =E( U {2,3} U {}) = {,2,3} {,3} {3} {2} {2,3}, {} {,2} {,2,3}

131 Exmpl: NFA DFA convrsion NFA DFA 2 3, d DFA ({,2,3}, ) =E(d NFA (,) U d NFA (2,) U d NFA (3,)) =E({2} U {3} U ) = {2,3} {,3} {3} {2} {2,3}, {} {,2} {,2,3}

132 Exmpl: NFA DFA convrsion NFA DFA, 2 3, d DFA (, ) = d DFA (, ) = {,3} {3} {2} {2,3}, {} {,2} {,2,3}

133 Exmpl: NFA DFA convrsion NFA DFA, 2 3, {,3} {3} {2} {2,3} {,2,3} W cn dlt th unrchl stts.

134 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 DFA {3} {} {,2,3} Q DFA = Powrst(Q NFA ) = Powrst({,2,3}) = {,{},{2},{3},{,2}...} {2,3} {2} {,3} {,2}

135 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 DFA {3} {} {,2,3} q DFA = E({q NFA }) = E({}) {2,3} {2} {,3} {,2} = {}

136 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 DFA {3} {} {,2,3} F DFA = {S : S contins n lmnt of F NFA } {2,3} {2} {,3} {,2}

137 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 DFA {3} {} {,2,3} d DFA ({}, ) = E(d NFA (, )) = E( ) = {2,3} {2} {,3} {,2}

138 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 DFA {3} {} {,2,3} d DFA ({}, ) = E(d NFA (, )) {2,3} {2} {,3} {,2} = E({2,3}) = {,2,3}

139 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 DFA {3} {} {,2,3} d DFA ({2}, ) = E(d NFA (2, )) {2,3} {2} {,3} {,2} = E({3}) = {,3}

140 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({2}, ) NFA 3 = E(d NFA (2, )) = E( ) = {3} {} {,2,3} {2} DFA {,3} {2,3} {,2}

141 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({3}, ) NFA 3 = E(d NFA (3, )) = E( ) = {3} {} {,2,3} {2} DFA {,3} {2,3} {,2}

142 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({3}, ) NFA 3 = E(d NFA (3, )) = E( ) = {3} {}, {,2,3} {2} DFA {,3} {2,3} {,2}

143 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({,2}, ) NFA = E(d NFA (,) U d NFA (2,)) = E( U {3}) = {,3} 3 {3} {}, {,2,3} {2} DFA {,3} {2,3} {,2}

144 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({,2}, ) NFA = E(d NFA (,) U d NFA (2,)) = E({2,3} U ) = {,2,3} 3 {3} {}, {,2,3} {2} DFA {,3} {2,3} {,2}

145 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({,3}, ) NFA = E(d NFA (,) U d NFA (3,)) = E( U ) = 3 {3} {}, {,2,3} {2} DFA {,3} {2,3} {,2}

146 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({,3}, ) NFA = E(d NFA (,) U d NFA (3,)) = E({2,3} U ) = {,2,3} 3 {3} {}, {,2,3} {2} DFA {,3} {2,3} {,2}

147 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({2,3}, ) NFA = E(d NFA (2,) U d NFA (3,)) = E({3} U ) = {,3} 3 {2,3} {3} {}, {,2,3} {2} DFA {,3} {,2}

148 ANOTHER Exmpl: NFA DFA convrsion 2 d DFA ({2,3}, ) NFA = E(d NFA (2,) U d NFA (3,)) = E( U ) = 3 {2,3} {3} {}, {,2,3} {2} DFA {,3} {,2}

149 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 d DFA ({,2,3}, ) =E(d NFA (,) U d NFA (2,) U d NFA (3,)) =E( U {3} U ) = {,3} {2,3} {3} {}, {,2,3} {2} DFA {,3} {,2}

150 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 d DFA ({,2,3}, ) =E(d NFA (,) U d NFA (2,) U d NFA (3,)) =E({2,3} U U ) = {,2,3} {2,3} {3} {}, {,2,3} {2} DFA {,3} {,2}

151 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 d DFA (, ) = d DFA (, ) = {2,3} {3} {}, {,2,3} {2} DFA, {,3} {,2}

152 ANOTHER Exmpl: NFA DFA convrsion 2 NFA 3 W cn dlt th unrchl stts. DFA {}, {,2,3} {,3}

153 Summry: NFA nd DFA rcogniz th sm lngugs W now rturn to th qustion: Suppos A, B r rgulr lngugs, wht out not A := { w : w is not in A } REGULAR A U B := { w : w in A or w in B } REGULAR A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i }

154 Thorm: If A, B r rgulr lngugs, thn so is A U B := { w : w in A or w in B } Proof id: Givn DFA M A : L(M A ) = A, DFA M B : L(M B ) = B, Construct NFA N : L(N) = A U B N M A M B U =

155 Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q :=? M A N M U B =

156 M A Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := {q} U Q A U Q B, F :=? N M U B =

157 Construction: M A Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: M U B = Q := {q} U Q A U Q B, F := F A U F B d(r,x) := { da (r,x) } if r in Q A nd x N d(r,x) :=? if r in QB nd x

158 Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := {q} U Q A U Q B, F := F A U F B d(r,x) := { da (r,x) } if r in Q A nd x d(r,x) := { db (r,x) } if r in Q B nd x d(q,) :=? M A M U B = N

159 Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := {q} U Q A U Q B, F := F A U F B d(r,x) := { da (r,x) } if r in Q A nd x d(r,x) := { db (r,x) } if r in Q B nd x d(q,) := {qa, q B } M A W hv L(N) = A U B M U B = N

160 Exmpl Is L = {w in {0,}* : w is divisil y 3 OR w strts with } rgulr?

161 Exmpl Is L = {w in {0,}* : w is divisil y 3 OR w strts with } rgulr? OR is lik U, so try to writ L = L U L 2 whr L, L 2 r rgulr

162 Exmpl Is L = {w in {0,}* : w is divisil y 3 OR w strts with } rgulr? OR is lik U, so try to writ L = L U L 2 whr L, L 2 r rgulr L = {w : w is div. y 3} L 2 = {w : w strts with }

163 Exmpl Is L = {w in {0,}* : w is divisil y 3 OR w strts with } rgulr? OR is lik U, so try to writ L = L U L 2 whr L, L 2 r rgulr L = {w : w is div. y 3} L 2 = {w : w strts with } M = 0, 0, 0, L(M ) = L

164 Exmpl Is L = {w in {0,}* : w is divisil y 3 OR w strts with } rgulr? OR is lik U, so try to writ L = L U L 2 whr L, L 2 r rgulr L = {w : w is div. y 3} L 2 = {w : w strts with } M = 0, M 2 = 0, 0, 0, L(M ) = L L(M 2 ) = L 2

165 Exmpl Is L = {w in {0,}* : w is divisil y 3 OR w strts with } rgulr? OR is lik U, so try to writ L = L U L 2 whr L, L 2 r rgulr L = {w : w is div. y 3} L 2 = {w : w strts with } M = 0, L(M) = L(M 0, 0, ) U L(M 2 ) = L U L 2 0, = L L is rgulr.

166 W now rturn to th qustion: Suppos A, B r rgulr lngugs, thn not A := { w : w is not in A } REGULAR A U B := { w : w in A or w in B } REGULAR A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i }

167 Thorm: If A, B r rgulr lngugs, thn so is A o B := { w : w = xy for som x in A nd y in B }. Proof id: Givn DFAs M A, M B for A, B M A construct NFA N : L(N) = A o B. M ob = N

168 M A o M B = N Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q :=?

169 M A o M B = N Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := Q A U Q B, q :=?

170 M A o M B = N Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := Q A U Q B, q := q A, F :=?

171 M A o M B = N Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := Q A U Q B, q := q A, F := F B d(r,x) :=? if r in QA nd x

172 M A o M B = N Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := Q A U Q B, q := q A, F := F B d(r,x) := { da (r,x) } if r in Q A nd x d(r,) :=? if r in F A

173 M A o M B = N Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := Q A U Q B, q := q A, F := F B d(r,x) := { da (r,x) } if r in Q A nd x d(r,) := { q B } if r in F A d(r,x) :=? if r in QB nd x

174 M A o M B = N Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, DFA M B = (Q B, S, d B, q B, F B ) : L(M B ) = B, Construct NFA N = (Q, S, d, q, F) whr: Q := Q A U Q B, q := q A, F := F B d(r,x) := { da (r,x) } if r in Q A nd x d(r,) := { q B } if r in F A d(r,x) := { db (r,x) } if r in Q B nd x W hv L(N) = A o B

175 Exmpl Is L = {w in {0,}* : w contins ftr 0} rgulr? Not: L = {0, 00000, 00, }

176 Exmpl Is L = {w in {0,}* : w contins ftr 0} rgulr? Lt L 0 = {w : w contins 0} L = {w : w contins }. Thn L = L 0 o L.

177 Exmpl Is L = {w in {0,}* : w contins ftr 0} rgulr? Lt L 0 = {w : w contins 0} L = {w : w contins }. Thn L = L 0 o L. M 0 = 0, 0 L(M 0 ) = L 0

178 Exmpl Is L = {w in {0,}* : w contins ftr 0} rgulr? Lt L 0 = {w : w contins 0} L = {w : w contins }. Thn L = L 0 o L. M 0 = 0, M = 0 0, 0 L(M 0 ) = L 0 L(M ) = L

179 Exmpl Is L = {w in {0,}* : w contins ftr 0} rgulr? Lt L 0 = {w : w contins 0} L = {w : w contins }. Thn L = L 0 o L. M = 0, 0 0, 0 L(M) = L(M 0 ) o L(M ) = L 0 o L = L L is rgulr.

180 W now rturn to th qustion: Suppos A, B r rgulr lngugs, thn not A := { w : w is not in A } REGULAR A U B := { w : w in A or w in B } REGULAR A o B := { w w 2 : w A nd w2 B } REGULAR A* := { w w 2 w k : k 0, w i in A for vry i }

181 Thorm: If A is rgulr lngug, thn so is A* := { w : w = w...w k, w i in A for i=,...,k } Proof id: Givn DFA M A : L(M A ) = A, Construct NFA N : L(N) = A* N M A * =

182 M A N * = Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, Construct NFA N = (Q, S, d, q, F) whr: Q :=?

183 M A N * = Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, Construct NFA N = (Q, S, d, q, F) whr: Q := {q} U Q A, F :=?

184 M A N * = Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, Construct NFA N = (Q, S, d, q, F) whr: Q := {q} U Q A, F := {q} U F A d(r,x) :=? if r in QA nd x

185 M A N * = Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, Construct NFA N = (Q, S, d, q, F) whr: Q := {q} U Q A, F := {q} U F A d(r,x) := { da (r,x) } if r in Q A nd x d(r,) :=? if r in {q} U FA

186 M A N * = Construction: Givn DFA MA = (Q A, S, d A, q A, F A ) : L(M A ) = A, Construct NFA N = (Q, S, d, q, F) whr: Q := {q} U Q A, F := {q} U F A d(r,x) := { da (r,x) } if r in Q A nd x d(r,) := { qa } if r in {q} U F A W hv L(N) = A*

187 Exmpl Is L = {w in {0,}* : w hs vn lngth} rgulr?

188 Exmpl Is L = {w in {0,}* : w hs vn lngth} rgulr? Lt L 0 = {w : w hs lngth = 2}. Thn L = L 0 *.

189 Exmpl Is L = {w in {0,}* : w hs vn lngth} rgulr? Lt L 0 = {w : w hs lngth = 2}. Thn L = L 0 *. M 0 = 0, 0, L(M 0 ) = L 0

190 Exmpl Is L = {w in {0,}* : w hs vn lngth} rgulr? Lt L 0 = {w : w hs lngth = 2}. Thn L = L 0 *. M = 0, 0, L(M) = L(M 0 )* = L 0 * = L L is rgulr.

191 W now rturn to th qustion: Suppos A, B r rgulr lngugs, thn not A := { w : w is not in A } A U B := { w : w in A or w in B } A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i } r ll rgulr!

192 W now rturn to th qustion: Suppos A, B r rgulr lngugs, thn not A := { w : w is not in A } A U B := { w : w in A or w in B } A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i } Wht out A B := { w : w in A nd w in B }?

193 W now rturn to th qustion: Suppos A, B r rgulr lngugs, thn not A := { w : w is not in A } A U B := { w : w in A or w in B } A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i } D Morgn's lws: A B = not ( (not A) U (not B) ) By ov, (not A) is rgulr, (not B) is rgulr, (not A) U (not B) is rgulr, not ( (not A) U (not B) ) = A B rgulr

194 W now rturn to th qustion: Suppos A, B r rgulr lngugs, thn not A := { w : w is not in A } A U B := { w : w in A or w in B } A o B := { w w 2 : w in A nd w 2 in B } A* := { w w 2 w k : k 0, w i in A for vry i } A B := { w : w in A nd w in B } r ll rgulr

195 Big pictur All lngugs Dcidl Turing mchins NP P Contxt-fr Contxt-fr grmmrs, push-down utomt Rgulr Automt, non-dtrministic utomt, rgulr xprssions

196 How to spcify rgulr lngug? Writ pictur complictd Writ down forml dfinition complictd d(q 0,0) = q 0, Us symols from S nd oprtions *, o, U good ({0} * U {}) o {00}

197 Rgulr xprssions: nything you cn writ with, ε, symols from S, nd oprtions *, o, U Convntions: Writ instd of {} Writ AB for A o B Writ for U So if = {,} thn = U Oprtion * hs prcdnc ovr o, nd o ovr U so U 0* mns U(0()*) Exmpl: 0, 0*, S*, S*00S*, (SS)*, 0 U 0

198 Dfinition Rgulr xprssions RE ovr r: Ø ε if in S R R' if R, R' r RE R U R' if R, R' r RE R* if R is RE

199 Dfinition Th lngug dscrid y RE: L(Ø) = Ø L( ε ) = { ε } L() = {} if in L(R R') = L(R) o L(R') L(R U R') = L(R) U L(R') L(R*) = L(R)*

200 Exmpl = {, } RE Lngug U? * ( U )* ** * * * * ( )* (***)* ** Ø

201 Exmpl = {, } RE Lngug U {, } * ( U )* ** * * * * ( )* (***)* ** Ø

202 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ** * * * * ( )* (***)* ** Ø

203 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ** ll strings * * * * ( )* (***)* ** Ø

204 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ll strings ** {w : w hs xctly on } * * * * ( )* (***)* ** Ø

205 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ll strings ** {w : w hs xctly on } * * {w : w hs t lst on } * * ( )* (***)* ** Ø

206 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ll strings ** {w : w hs xctly on } * * {w : w hs t lst on } * * ( )* {w : w contins th string } (***)* ** Ø

207 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ll strings ** {w : w hs xctly on } * * {w : w hs t lst on } * * ( )* (***)* {w : w contins th string } {w : w hs vn lngth} ** Ø

208 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ll strings ** {w : w hs xctly on } * * {w : w hs t lst on } * * {w : w contins th string } ( )* {w : w hs vn lngth} (***)* {w : w contins vn numr of } ** Ø

209 Exmpl = {, } RE Lngug U {, } * {ε,,, } = { w : w hs only } ( U )* ll strings ** {w : w hs xctly on } * * {w : w hs t lst on } * * {w : w contins th string } ( )* {w : w hs vn lngth} (***)* {w : w contins vn numr of } ** Ø Ø (nything o Ø = Ø)

210 Thorm: For vry RE R thr is NFA M: L(M) = L(R)

211 Thorm: For vry RE R thr is NFA M: L(M) = L(R) Construction: R = M :=?

212 Thorm: For vry RE R thr is NFA M: L(M) = L(R) Construction: R = M := R = M :=?

213 Thorm: For vry RE R thr is NFA M: L(M) = L(R) Construction: R = M := R = M := R = M :=?

214 Thorm: For vry RE R thr is NFA M: L(M) = L(R) Construction: R = M := R = M := R = M := R = R U R'?

215 Thorm: For vry RE R thr is NFA M: L(M) = L(R) Construction: R = M := R = M := R = M := R = R U R' us construction for A U B sn rlir R = R o R'?

216 Thorm: For vry RE R thr is NFA M: L(M) = L(R) Construction: R = M := R = M := R = M := R = R U R' us construction for A U B sn rlir R = R o R' us construction for A o B sn rlir R = R*?

217 Thorm: For vry RE R thr is NFA M: L(M) = L(R) Construction: R = M := R = M := R = M := R = R U R' us construction for A U B sn rlir R = R o R' us construction for A o B sn rlir R = R* us construction for A* sn rlir

218 Exmpl: RE NFA RE = ( U )*

219 Exmpl: RE NFA RE = ( U )* M = L(M )=L()

220 Exmpl: RE NFA RE = ( U )* M = M = L(M )=L() L(M )=L()

221 Exmpl: RE NFA RE = ( U )* M = L(M )=L()

222 Exmpl: RE NFA RE = ( U )* M = M = L(M )=L() L(M )=L()

223 Exmpl: RE NFA RE = ( U )* M U = L(M U )=L( U )

224 Exmpl: RE NFA RE = ( U )* M ( U )* = L(M ( U )* )=L(( U )*)=L(RE)

225 ANOTHER Exmpl: RE NFA RE =( U )*

226 ANOTHER Exmpl: RE NFA RE =( U )* M = L(M )=L()

227 ANOTHER Exmpl: RE NFA RE =( U )* M = M = L(M )=L() L(M )=L()

228 ANOTHER Exmpl: RE NFA RE =( U )* M U = L(M U )=L( U )

229 ANOTHER Exmpl: RE NFA RE =( U )* M U = M = L(M )=L() L(M U )=L( U )

230 ANOTHER Exmpl: RE NFA RE =( U )* M ( U ) = L(M ( U ) )=L(( U ))

231 ANOTHER Exmpl: RE NFA RE =( U )* M ( U ) = M = L(M )=L() L(M ( U ) )=L(( U ))

232 ANOTHER Exmpl: RE NFA RE =( U )* M ( U ) = M * = L(M * )=L(*) L(M ( U ) )=L(( U ))

233 ANOTHER Exmpl: RE NFA RE =( U )* M ( U )* = L(M ( U )* )=L(( U )*)=L(RE)

234 Rcp: Hr mns cn convrtd to W hv sn: RE NFA DFA Nxt w s: DFA RE In two stps: DFA Gnrlizd NFA RE

235 Gnrlizd NFA (GNFA) U * q 0 ** q Nondtrministic Trnsitions llld y RE Rd locks of input symols t tim

236 Gnrlizd NFA (GNFA) U * q 0 ** q Convntion: Uniqu finl stt Exctly on trnsition twn ch pir of stts xcpt nothing going into strt stt nothing going out of finl stt If rrow not shown in pictur, ll =

237 Dfinition: A gnrlizd finit utomton (GNFA) is 5-tupl (Q, S, d, q 0, q ) whr Q is finit st of stts S is th input lpht d : (Q - {q }) X (Q {q 0 }) Rgulr Exprssions q 0 in Q is th strt stt q in Q is th ccpt stt

238 Dfinition: GNFA (Q, S, d, q 0, q ) ccpts string w if intgr k, k strings w, w 2,, w k S* such tht w = w w 2 w k (divid w in k strings) $ squnc of k+ stts r0, r,.., r k in Q such tht: r 0 = q 0 w i+ L(d(r i,r i+ )) 0 i < k r k = q Diffrncs with NFA r in grn

239 Exmpl * * q 0 q q Accpts w = w =?

240 Exmpl * * q 0 q q Accpts w = w = w 2 =?

241 Exmpl * * q 0 q q Accpts w = w = w 2 = w 3 = r 0 =q 0 r =?

242 Exmpl * * q 0 q q Accpts w = w = w 2 = w 3 = r 0 =q 0 r =q r 2 =? w = L(d(r 0,r )) = L(d(q 0,q )) = L(*)

243 Exmpl * * q 0 q q Accpts w = w = w 2 = w 3 = r 0 =q 0 r =q r 2 =q r 3 =? w = L(d(r 0,r )) = L(d(q 0,q )) = L(*) w 2 = L(d(r,r 2 )) = L(d(q,q )) = L(*)

244 Exmpl * * q 0 q q Accpts w = w = w 2 = w 3 = r 0 =q 0 r =q r 2 =q r 3 = q w = L(d(r 0,r )) = L(d(q 0,q )) = L(*) w 2 = L(d(r,r 2 )) = L(d(q,q )) = L(*) w 3 = L(d(r 2,r 3 )) = L(d(q,q )) = L()

245 Thorm: DFA M GNFA N : L(N) = L(M) Construction: To nsur uniqu trnsition twn ch pir: U 0 0 To nsur uniqu finl stt, no trnsitions ingoing strt stt, no trnsitions outgoing finl stt:

246 Rpt until 2 stts rmin Thorm: GNFA N RE R : L(R) = L(N) Construction: If N hs 2 stts, thn N = thus R := S q 0 S q If N hs > 2 stts, limint som stt q r q 0, q : for vry ordrd pir q i, q j (possily qul) tht r connctd through q r R 2 R R R 2 *R 3 U R q R 4 i q 3 r q j q i q j R 4

247 Exmpl: DFA GNFA RE DFA q,c q 2

248 Exmpl: DFA GNFA RE GNFA q 0 q U c q 2 q

249 Exmpl: DFA GNFA RE q 0 q U c q 2 q Elimint q : r-drw GNFA with ll othr stts q 0 q 2 q

250 Exmpl: DFA GNFA RE q 0 q U c q 2 q Elimint q : find pth through q q 0 q 2 q

251 Exmpl: DFA GNFA RE Ø q 0 q U c q 2 q Elimint q : dd dg to nw GNFA Don't forgt: no rrow mns ll Ø q 0 * ( U c) U Ø q 2 q

252 Exmpl: DFA GNFA RE q 0 q U c q 2 q Elimint q : simplify RE on nw dg q 0 * ( U c) q 2 q

253 Exmpl: DFA GNFA RE q 0 q U c q 2 q Elimint q : if no mor pths through q, strt ovr q 0 * ( U c) q 2 q

254 Exmpl: DFA GNFA RE q 0 * ( U c) q 2 q Elimint q 2 : r-drw GNFA with ll othr stts q 0 q

255 Exmpl: DFA GNFA RE q 0 * ( U c) q 2 q Elimint q 2 : find pth through q 2 q 0 q

256 Exmpl: DFA GNFA RE q 0 * ( U c) q 2 q Elimint q 2 : dd dg to nw GNFA q 0 * ( U c) * U Ø q

257 Exmpl: DFA GNFA RE q 0 * ( U c) q 2 q Elimint q 2 : simplify RE on nw dg q 0 * ( U c) * q

258 Exmpl: DFA GNFA RE q 0 * ( U c) q 2 q Elimint q 2 : if no mor pths through q 2, strt ovr q 0 * ( U c) * q

259 Exmpl: DFA GNFA RE q 0 * ( U c) * q Only two stts rmin: RE = * ( U c) *

260 ANOTHER Exmpl: DFA GNFA RE DFA q c c q 2 q 3

261 ANOTHER Exmpl: DFA GNFA RE GNFA q 0 q c c q 2 q 3 q

262 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q r-drw GNFA with ll othr stts q 3 q q 0 q 2

263 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q find pth through q q 3 q q 0 q 2

264 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q dd dg to nw GNFA * U Ø q 3 q q 0 q 2

265 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q find nothr pth through q * U Ø q 3 q q 0 q 2

266 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q dd dg to nw GNFA * U Ø q 3 q q 0 *c U Ø q 2

267 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q find nothr pth through q * U Ø q 3 q q 0 *c U Ø q 2

268 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : dd dg to nw GNFA q c q 0 c q 2 q 3 * U Ø q q 3 don't forgt currnt q 2 q 3 dg! This tim is not Ø! q *c U Ø q 2 c* U

269 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q find nothr pth through q * U Ø q 3 q q 0 *c U Ø q 2 c* U

270 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : dd dg to q c c q 2 q 3 q don't forgt currnt q 2 q 2 dg! nw GNFA * U Ø q 3 q q 0 *c U Ø q 2 c* U c*c U

271 ANOTHER Exmpl: DFA GNFA RE q 0 Elimint q : q c c q 2 q 3 q whn no mor pths through q, strt ovr (nd simplify * q 3 q REs) q 0 *c c* U q 2 c*c U

272 ANOTHER Exmpl: DFA GNFA RE * q 3 q q 0 *c q 2 c* U Elimint q 2 : c*c U r-drw GNFA with ll othr stts q 0 * q 3 q

273 ANOTHER Exmpl: DFA GNFA RE * q 3 q q 0 *c q 2 c* U Elimint q 2 : c*c U find pth through q 2 q 0 * q 3 q

274 ANOTHER Exmpl: DFA GNFA RE * q 3 q q 0 *c q 2 c* U Elimint q 2 : c*c U dd dg to nw GNFA q 0 *c(c*c U )*(c* U ) U * q 3 q

275 ANOTHER Exmpl: DFA GNFA RE * q 3 q q 0 Elimint q 2 : *c whn no mor pths through q 2, strt ovr q 2 c* U c*c U q 0 *c(c*c U )*(c* U ) U * q 3 q

276 ANOTHER Exmpl: DFA GNFA RE q 0 *c(c*c U )*(c* U ) U * q 3 q Elimint q 3 : r-drw GNFA with ll othr stts q 0 q

277 ANOTHER Exmpl: DFA GNFA RE q 0 *c(c*c U )*(c* U ) U * q 3 q Elimint q 3 : find pth through q 3 Ø Ø don't forgt: no rrow mns Ø q 0 q

278 ANOTHER Exmpl: DFA GNFA RE q 0 *c(c*c U )*(c* U ) U * q 3 q Elimint q 3 : dd dg to nw GNFA Ø Ø (*c(c*c U )*(c* U ) U *) Ø* ε U Ø q 0 q

279 ANOTHER Exmpl: DFA GNFA RE q 0 *c(c*c U )*(c* U ) U * q 3 q Elimint q 3 : whn no mor pths through q 3, strt ovr (nd simplify REs) don't forgt: Ø*= ε q 0 *c(c*c U )*(c* U ) U * q

280 ANOTHER Exmpl: DFA GNFA RE q 0 *c(c*c U )*(c* U ) U * q Only two stts rmin: RE = *c(c*c U )*(c* U ) U *

281 Rcp: Hr mns cn convrtd to RE DFA NFA Any of th thr rcogniz xctly th rgulr lngugs (initilly dfind using DFA)

282 Ths convrsions r usd vry tim you ntr n RE, for xmpl for pttrn mtching using grp Th RE is convrtd to n NFA Thn th NFA is convrtd to DFA Th DFA rprsnttion is usd to pttrn-mtch Optimiztions hv n dvisd, ut this is still th gnrl pproch.

283 Wht lngug is NOT rgulr? Is { 0 n n : n 0 } = {ε, 0, 00, 000, } rgulr?

284 Pumping lmm: L rgulr lngug p 0 w L, w p x,y,z : w= xyz, y > 0, xy p i 0 : xy i z L Rcll y 0 =, y = y, y 2 = yy, y 3 = yyy,...

285 Pumping lmm: L rgulr lngug p 0 W will not s th proof. But hr's th id: p := Q for DFA rcognizing L w L, w p If w L, w p, thn during computtion 2 stts must th sm q Q y = portion of w tht rings ck to q cn rpt y nd still ccpt string x,y,z : w= xyz, y > 0, xy p i 0 : xy i z L

286 Pumping lmm: L rgulr lngug p 0 A w L, w p x,y,z : w= xyz, y > 0, xy p i 0 : xy i z L Usful to prov L NOT rgulr. Us contrpositiv: L rgulr lngug A sm s (not A) L not rgulr

287 Pumping lmm (contrpositiv) p 0 not A w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L L not rgulr To prov L not rgulr it is nough to prov not A Not A is th stuff in th ox.

288 Proving somthing lik l l l l l mns winning gm Thory is ll out winning gms!

289 Exmpl NAME THE BIGGEST NUMBER GAME Two plyrs: You, Advrsry. Ruls: First Advrsry sys numr. Thn You sy numr. You win if your numr is iggr. Cn you win this gm?

290 Exmpl NAME THE BIGGEST NUMBER GAME Two plyrs: You, Advrsry. Ruls: First Advrsry sys numr. Thn You sy numr. You win if your numr is iggr. You hv winning strtgy: if dvrsry sys x, you sy x+

291 Exmpl NAME THE BIGGEST NUMBER GAME Two plyrs: You, Advrsry. Ruls: First Advrsry sys numr. Thn You sy numr. You win if your numr is iggr., x y : y > x You hv winning strtgy: if dvrsry sys x, you sy x+ Clim is tru

292 Anothr xmpl: Thorm: NFA N DFA M : L(M) = L(N) W lrdy sw winning strtgy for this gm Wht is it?

293 Anothr xmpl: Thorm: NFA N DFA M : L(M) = L(N) W lrdy sw winning strtgy for this gm Th powr st construction.

294 Gms with mor movs: Chss, Chckrs, Tic-Tc-To You cn win if mov of th Advrsry mov You cn mk mov of th Advrsry mov You cn mk : You chckmt

295 Pumping lmm (contrpositiv) p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L Ruls of th gm: Advrsry picks p, You pick w L of lngth p, L not rgulr Advrsry dcomposs w in xyz, whr y > 0, xy p You pick i 0 Finlly, you win if xy i z L

296 Thorm: L := {0 n n : n 0} is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := 0 p p Advrsry movs x,y,z You mov i := 2 You must show xyyz L: p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L Sinc xy p nd w = xyz = 0 p p, y only hs 0 So xyyz = 0 p + y p Sinc y > 0, this is not of th form 0 n n DONE

297 Thorm: L := {w : w hs s mny 0 s } not rgulr Sm Proof: Us pumping lmm Advrsry movs p You mov w :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

298 Thorm: L := {w : w hs s mny 0 s } not rgulr Sm Proof: Us pumping lmm Advrsry movs p You mov w := 0 p p Advrsry movs x,y,z You mov i :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

299 Thorm: L := {w : w hs s mny 0 s } not rgulr Sm Proof: Us pumping lmm Advrsry movs p You mov w := 0 p p Advrsry movs x,y,z You mov i := 2 You must show xyyz L: p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L Sinc xy p nd w = xyz = 0 p p, y only hs 0 So xyyz =?

300 Thorm: L := {w : w hs s mny 0 s } not rgulr Sm Proof: Us pumping lmm Advrsry movs p You mov w := 0 p p Advrsry movs x,y,z You mov i := 2 You must show xyyz L: p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L Sinc xy p nd w = xyz = 0 p p, y only hs 0 So xyyz = 0 p + y p Sinc y > 0, not s mny 0 s DONE

301 Thorm: L := {0 j k : j > k} is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

302 Thorm: L := {0 j k : j > k} is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := 0 p+ p Advrsry movs x,y,z You mov i :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

303 Thorm: L := {0 j k : j > k} is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := 0 p+ p Advrsry movs x,y,z You mov i := 0 You must show xz L: p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L Sinc xy p nd w = xyz = 0 p+ p, y only hs 0 So xz = 0 p + - y p Sinc y > 0, this is not of th form 0 j k with j > k

304 Thorm: L := {uu : u {0,}* } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

305 Thorm: L := {uu : u {0,}* } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := 0 p 0 p Advrsry movs x,y,z You mov i :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

306 Thorm: L := {uu : u {0,}* } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := 0 p 0 p Advrsry movs x,y,z You mov i := 2 You must show xyyz L: p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L Sinc xy p nd w = xyz = 0 p 0 p, y only hs 0 So xyyz = 0 p + y 0 p Sinc y > 0, first hlf of xyyz only 0, so xyyz L

307 Thorm: L := { n2 : n 0 } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

308 Thorm: L := { n2 : n 0 } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := p2 Advrsry movs x,y,z You mov i :=? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

309 Thorm: L := { n2 : n 0 } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := p2 Advrsry movs x,y,z You mov i := 2 You must show xyyz L: Sinc xy p, xyyz? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

310 Thorm: L := { n2 : n 0 } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := p2 Advrsry movs x,y,z You mov i := 2 You must show xyyz L: Sinc xy p, xyyz p 2 + p < (p+) 2 Sinc y > 0, xyyz >? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

311 Thorm: L := { n2 : n 0 } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := p2 Advrsry movs x,y,z You mov i := 2 You must show xyyz L: Sinc xy p, xyyz p 2 + p < (p+) 2 Sinc y > 0, xyyz > p 2 So xyyz cnnot wht? p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

312 Thorm: L := { n2 : n 0 } is not rgulr Proof: Us pumping lmm Advrsry movs p You mov w := p2 Advrsry movs x,y,z You mov i := 2 You must show xyyz L: Sinc xy p, xyyz p 2 + p < (p+) 2 Sinc y > 0, xyyz > p 2 So xyyz cnnot squr. xyyz L p 0 w L, w p x,y,z : w = xyz, y > 0, xy p i 0 : xy i z L

313 Big pictur All lngugs Dcidl Turing mchins NP P Contxt-fr Contxt-fr grmmrs, push-down utomt Rgulr Automt, non-dtrministic utomt, rgulr xprssions

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata CSE303 - Introduction to th Thory of Computing Smpl Solutions for Exrciss on Finit Automt Exrcis 2.1.1 A dtrministic finit utomton M ccpts th mpty string (i.., L(M)) if nd only if its initil stt is finl

More information

FSA. CmSc 365 Theory of Computation. Finite State Automata and Regular Expressions (Chapter 2, Section 2.3) ALPHABET operations: U, concatenation, *

FSA. CmSc 365 Theory of Computation. Finite State Automata and Regular Expressions (Chapter 2, Section 2.3) ALPHABET operations: U, concatenation, * CmSc 365 Thory of Computtion Finit Stt Automt nd Rgulr Exprssions (Chptr 2, Sction 2.3) ALPHABET oprtions: U, conctntion, * otin otin Strings Form Rgulr xprssions dscri Closd undr U, conctntion nd * (if

More information

Last time: introduced our first computational model the DFA.

Last time: introduced our first computational model the DFA. Lctur 7 Homwork #7: 2.2.1, 2.2.2, 2.2.3 (hnd in c nd d), Misc: Givn: M, NFA Prov: (q,xy) * (p,y) iff (q,x) * (p,) (follow proof don in clss tody) Lst tim: introducd our first computtionl modl th DFA. Tody

More information

Notes on Finite Automata Department of Computer Science Professor Goldberg Textbooks: Introduction to the Theory of Computation by Michael Sipser

Notes on Finite Automata Department of Computer Science Professor Goldberg Textbooks: Introduction to the Theory of Computation by Michael Sipser Nots on Finit Automt Dprtmnt of Computr Scinc Profssor Goldrg Txtooks: Introduction to th Thory of Computtion y Michl Sipsr Elmnts of th Thory of Computtion y H. Lwis nd C. Ppdimitriou Ths nots contin

More information

Winter 2016 COMP-250: Introduction to Computer Science. Lecture 23, April 5, 2016

Winter 2016 COMP-250: Introduction to Computer Science. Lecture 23, April 5, 2016 Wintr 2016 COMP-250: Introduction to Computr Scinc Lctur 23, April 5, 2016 Commnt out input siz 2) Writ ny lgorithm tht runs in tim Θ(n 2 log 2 n) in wors cs. Explin why this is its running tim. I don

More information

Finite Automata. d: Q S Q. Finite automaton is M=(Q, S, d, q 0, F) Ex: an FA that accepts all odd-length strings of zeros: q 0 q 1. q i. q k.

Finite Automata. d: Q S Q. Finite automaton is M=(Q, S, d, q 0, F) Ex: an FA that accepts all odd-length strings of zeros: q 0 q 1. q i. q k. Finit Automt Bsic id: FA is mchin tht chngs stts whil procssing symols, on t tim. Finit st of stts: Q = {q 0, q 1, q 3,..., q k } Trnsition function: Initil stt: Finl stts: d: Q S Q q 0 Q F Q Finit utomton

More information

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued...

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued... Progrssiv Printing T.M. CPITLS g 4½+ Th sy, fun (n FR!) wy to tch cpitl lttrs. ook : C o - For Kinrgrtn or First Gr (not for pr-school). - Tchs tht cpitl lttrs mk th sm souns s th littl lttrs. - Tchs th

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

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

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

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

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

Section 3: Antiderivatives of Formulas

Section 3: Antiderivatives of Formulas Chptr Th Intgrl Appli Clculus 96 Sction : Antirivtivs of Formuls Now w cn put th is of rs n ntirivtivs togthr to gt wy of vluting finit intgrls tht is ct n oftn sy. To vlut finit intgrl f(t) t, w cn fin

More information

Minimum Spanning Trees

Minimum Spanning Trees Minimum Spnning Trs Minimum Spnning Trs Problm A town hs st of houss nd st of rods A rod conncts nd only houss A rod conncting houss u nd v hs rpir cost w(u, v) Gol: Rpir nough (nd no mor) rods such tht:

More information

The Course covers: Lexical Analysis Syntax Analysis Semantic Analysis Runtime environments Code Generation Code Optimization. CS 540 Spring 2013 GMU 2

The Course covers: Lexical Analysis Syntax Analysis Semantic Analysis Runtime environments Code Generation Code Optimization. CS 540 Spring 2013 GMU 2 CS 540 Spring 2013 Th Cours covrs: Lxicl Anlysis Syntx Anlysis Smntic Anlysis Runtim nvironmnts Cod Gnrtion Cod Optimiztion CS 540 Spring 2013 GMU 2 Pr-rquisit courss Strong progrmming ckground in C, C++

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

Multi-Section Coupled Line Couplers

Multi-Section Coupled Line Couplers /0/009 MultiSction Coupld Lin Couplrs /8 Multi-Sction Coupld Lin Couplrs W cn dd multipl coupld lins in sris to incrs couplr ndwidth. Figur 7.5 (p. 6) An N-sction coupld lin l W typiclly dsign th couplr

More information

COMP108 Algorithmic Foundations

COMP108 Algorithmic Foundations Grdy mthods Prudn Wong http://www.s.liv..uk/~pwong/thing/omp108/01617 Coin Chng Prolm Suppos w hv 3 typs of oins 10p 0p 50p Minimum numr of oins to mk 0.8, 1.0, 1.? Grdy mthod Lrning outoms Undrstnd wht

More information

Integration Continued. Integration by Parts Solving Definite Integrals: Area Under a Curve Improper Integrals

Integration Continued. Integration by Parts Solving Definite Integrals: Area Under a Curve Improper Integrals Intgrtion Continud Intgrtion y Prts Solving Dinit Intgrls: Ar Undr Curv Impropr Intgrls Intgrtion y Prts Prticulrly usul whn you r trying to tk th intgrl o som unction tht is th product o n lgric prssion

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

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

1 Introduction to Modulo 7 Arithmetic

1 Introduction to Modulo 7 Arithmetic 1 Introution to Moulo 7 Arithmti Bor w try our hn t solvin som hr Moulr KnKns, lt s tk los look t on moulr rithmti, mo 7 rithmti. You ll s in this sminr tht rithmti moulo prim is quit irnt rom th ons w

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

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes.

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes. Nm: UCA ID Numr: Stion lttr: th 61 : Disrt Struturs Finl Exm Instrutor: Ciprin nolsu You hv 180 minuts. No ooks, nots or lultors r llow. Do not us your own srth ppr. 1. (2 points h) Tru/Fls: Cirl th right

More information

More Foundations. Undirected Graphs. Degree. A Theorem. Graphs, Products, & Relations

More Foundations. Undirected Graphs. Degree. A Theorem. Graphs, Products, & Relations Mr Funtins Grphs, Pruts, & Rltins Unirt Grphs An unirt grph is pir f 1. A st f ns 2. A st f gs (whr n g is st f tw ns*) Friy, Sptmr 2, 2011 Ring: Sipsr 0.2 ginning f 0.4; Stughtn 1.1.5 ({,,,,}, {{,}, {,},

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

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

1 Finite Automata and Regular Expressions

1 Finite Automata and Regular Expressions 1 Fini Auom nd Rgulr Exprion Moivion: Givn prn (rgulr xprion) for ring rching, w migh wn o convr i ino drminiic fini uomon or nondrminiic fini uomon o mk ring rching mor fficin; drminiic uomon only h o

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

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem) 12/3/12 Outlin Prt 10. Grphs CS 200 Algorithms n Dt Struturs Introution Trminology Implmnting Grphs Grph Trvrsls Topologil Sorting Shortst Pths Spnning Trs Minimum Spnning Trs Ciruits 1 Ciruits Cyl 2 Eulr

More information

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs Prt 10. Grphs CS 200 Algorithms n Dt Struturs 1 Introution Trminology Implmnting Grphs Outlin Grph Trvrsls Topologil Sorting Shortst Pths Spnning Trs Minimum Spnning Trs Ciruits 2 Ciruits Cyl A spil yl

More information

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

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

Walk Like a Mathematician Learning Task:

Walk Like a Mathematician Learning Task: Gori Dprtmnt of Euction Wlk Lik Mthmticin Lrnin Tsk: Mtrics llow us to prform mny usful mthmticl tsks which orinrily rquir lr numbr of computtions. Som typs of problms which cn b on fficintly with mtrics

More information

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018 CSE 373: Mor on grphs; DFS n BFS Mihl L Wnsy, F 14, 2018 1 Wrmup Wrmup: Disuss with your nighor: Rmin your nighor: wht is simpl grph? Suppos w hv simpl, irt grph with x nos. Wht is th mximum numr of gs

More information

Lecture 4: Lexical and Syntax Analysis

Lecture 4: Lexical and Syntax Analysis CS 515 Progrmming Lngug nd Compilrs I Lctur 4: Lxicl nd Syntx Anlysis Zhng (Eddy) Zhng Rutgrs Univrsity Fll 2017, 9/26/2017 1 2 Lctur 4A: Lxicl nd Syntx Anlysis II (Th lcturs r sd on th slids copyrightd

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

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

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs.

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs. Pths.. Eulr n Hmilton Pths.. Pth D. A pth rom s to t is squn o gs {x 0, x 1 }, {x 1, x 2 },... {x n 1, x n }, whr x 0 = s, n x n = t. D. Th lngth o pth is th numr o gs in it. {, } {, } {, } {, } {, } {,

More information

EEO 401 Digital Signal Processing Prof. Mark Fowler

EEO 401 Digital Signal Processing Prof. Mark Fowler EEO 401 Digital Signal Procssing Prof. Mark Fowlr Dtails of th ot St #19 Rading Assignmnt: Sct. 7.1.2, 7.1.3, & 7.2 of Proakis & Manolakis Dfinition of th So Givn signal data points x[n] for n = 0,, -1

More information

CS 6353 Compiler Construction, Homework #1. 1. Write regular expressions for the following informally described languages:

CS 6353 Compiler Construction, Homework #1. 1. Write regular expressions for the following informally described languages: CS 6353 Compilr Construction, Homwork #1 1. Writ rgular xprssions for th following informally dscribd languags: a. All strings of 0 s and 1 s with th substring 01*1. Answr: (0 1)*01*1(0 1)* b. All strings

More information

Module graph.py. 1 Introduction. 2 Graph basics. 3 Module graph.py. 3.1 Objects. CS 231 Naomi Nishimura

Module graph.py. 1 Introduction. 2 Graph basics. 3 Module graph.py. 3.1 Objects. CS 231 Naomi Nishimura Moul grph.py CS 231 Nomi Nishimur 1 Introution Just lik th Python list n th Python itionry provi wys of storing, ssing, n moifying t, grph n viw s wy of storing, ssing, n moifying t. Bus Python os not

More information

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths.

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths. How os it work? Pl vlu o imls rprsnt prts o whol numr or ojt # 0 000 Tns o thousns # 000 # 00 Thousns Hunrs Tns Ons # 0 Diml point st iml pl: ' 0 # 0 on tnth n iml pl: ' 0 # 00 on hunrth r iml pl: ' 0

More information

TOPIC 5: INTEGRATION

TOPIC 5: INTEGRATION TOPIC 5: INTEGRATION. Th indfinit intgrl In mny rspcts, th oprtion of intgrtion tht w r studying hr is th invrs oprtion of drivtion. Dfinition.. Th function F is n ntidrivtiv (or primitiv) of th function

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

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

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

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

INTEGRALS. Chapter 7. d dx. 7.1 Overview Let d dx F (x) = f (x). Then, we write f ( x)

INTEGRALS. Chapter 7. d dx. 7.1 Overview Let d dx F (x) = f (x). Then, we write f ( x) Chptr 7 INTEGRALS 7. Ovrviw 7.. Lt d d F () f (). Thn, w writ f ( ) d F () + C. Ths intgrls r clld indfinit intgrls or gnrl intgrls, C is clld constnt of intgrtion. All ths intgrls diffr y constnt. 7..

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

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

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

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

Garnir Polynomial and their Properties

Garnir Polynomial and their Properties Univrsity of Cliforni, Dvis Dprtmnt of Mthmtis Grnir Polynomil n thir Proprtis Author: Yu Wng Suprvisor: Prof. Gorsky Eugny My 8, 07 Grnir Polynomil n thir Proprtis Yu Wng mil: uywng@uvis.u. In this ppr,

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

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

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

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s?

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s? MATH 3012 Finl Exm, My 4, 2006, WTT Stunt Nm n ID Numr 1. All our prts o this prolm r onrn with trnry strings o lngth n, i.., wors o lngth n with lttrs rom th lpht {0, 1, 2}.. How mny trnry wors o lngth

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

Lecture 11 Waves in Periodic Potentials Today: Questions you should be able to address after today s lecture:

Lecture 11 Waves in Periodic Potentials Today: Questions you should be able to address after today s lecture: Lctur 11 Wvs in Priodic Potntils Tody: 1. Invrs lttic dfinition in 1D.. rphicl rprsnttion of priodic nd -priodic functions using th -xis nd invrs lttic vctors. 3. Sris solutions to th priodic potntil Hmiltonin

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

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

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints) C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,

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

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology!

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology! Outlin Computr Sin 331, Spnnin, n Surphs Mik Joson Dprtmnt o Computr Sin Univrsity o Clry Ltur #30 1 Introution 2 3 Dinition 4 Spnnin 5 6 Mik Joson (Univrsity o Clry) Computr Sin 331 Ltur #30 1 / 20 Mik

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

Propositional Logic. Combinatorial Problem Solving (CPS) Albert Oliveras Enric Rodríguez-Carbonell. May 17, 2018

Propositional Logic. Combinatorial Problem Solving (CPS) Albert Oliveras Enric Rodríguez-Carbonell. May 17, 2018 Propositional Logic Combinatorial Problm Solving (CPS) Albrt Olivras Enric Rodríguz-Carbonll May 17, 2018 Ovrviw of th sssion Dfinition of Propositional Logic Gnral Concpts in Logic Rduction to SAT CNFs

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

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA.

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA. S i m p l i y i n g A l g r SIMPLIFYING ALGEBRA www.mthltis.o.nz Simpliying SIMPLIFYING Algr ALGEBRA Algr is mthmtis with mor thn just numrs. Numrs hv ix vlu, ut lgr introus vrils whos vlus n hng. Ths

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

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS C 24 - COMBINATIONAL BUILDING BLOCKS - INVST 3 DCODS AND NCODS FALL 23 AP FLZ To o "wll" on this invstition you must not only t th riht nswrs ut must lso o nt, omplt n onis writups tht mk ovious wht h

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

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

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

Ch 1.2: Solutions of Some Differential Equations

Ch 1.2: Solutions of Some Differential Equations Ch 1.2: Solutions of Som Diffrntil Equtions Rcll th fr fll nd owl/mic diffrntil qutions: v 9.8.2v, p.5 p 45 Ths qutions hv th gnrl form y' = y - b W cn us mthods of clculus to solv diffrntil qutions of

More information

CSC Design and Analysis of Algorithms. Example: Change-Making Problem

CSC Design and Analysis of Algorithms. Example: Change-Making Problem CSC 801- Dsign n Anlysis of Algorithms Ltur 11 Gry Thniqu Exmpl: Chng-Mking Prolm Givn unlimit mounts of oins of nomintions 1 > > m, giv hng for mount n with th lst numr of oins Exmpl: 1 = 25, 2 =10, =

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

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1 CSC 00 Disrt Struturs : Introuon to Grph Thory Grphs Grphs CSC 00 Disrt Struturs Villnov Univrsity Grphs r isrt struturs onsisng o vrs n gs tht onnt ths vrs. Grphs n us to mol: omputr systms/ntworks mthml

More information

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management nrl tr T is init st o on or mor nos suh tht thr is on sint no r, ll th root o T, n th rminin nos r prtition into n isjoint susts T, T,, T n, h o whih is tr, n whos roots r, r,, r n, rsptivly, r hilrn o

More information

Basic Polyhedral theory

Basic Polyhedral theory Basic Polyhdral thory Th st P = { A b} is calld a polyhdron. Lmma 1. Eithr th systm A = b, b 0, 0 has a solution or thr is a vctorπ such that π A 0, πb < 0 Thr cass, if solution in top row dos not ist

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

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

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2 Grt Thortil Is In Computr Sin Vitor Amhik CS 15-251 Ltur 9 Grphs - II Crngi Mllon Univrsity Grph Isomorphism finition. Two simpl grphs G n H r isomorphi G H if thr is vrtx ijtion V H ->V G tht prsrvs jny

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

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

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

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

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

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

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

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari Grphs CSC 1300 Disrt Struturs Villnov Univrsity Grphs Grphs r isrt struturs onsis?ng of vr?s n gs tht onnt ths vr?s. Grphs n us to mol: omputr systms/ntworks mthm?l rl?ons logi iruit lyout jos/prosss f

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

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

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

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

CS 361 Meeting 12 10/3/18

CS 361 Meeting 12 10/3/18 CS 36 Mting 2 /3/8 Announcmnts. Homwork 4 is du Friday. If Friday is Mountain Day, homwork should b turnd in at my offic or th dpartmnt offic bfor 4. 2. Homwork 5 will b availabl ovr th wknd. 3. Our midtrm

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

Linear Algebra Existence of the determinant. Expansion according to a row.

Linear Algebra Existence of the determinant. Expansion according to a row. Lir Algbr 2270 1 Existc of th dtrmit. Expsio ccordig to row. W dfi th dtrmit for 1 1 mtrics s dt([]) = (1) It is sy chck tht it stisfis D1)-D3). For y othr w dfi th dtrmit s follows. Assumig th dtrmit

More information

Recall that by Theorems 10.3 and 10.4 together provide us the estimate o(n2 ), S(q) q 9, q=1

Recall that by Theorems 10.3 and 10.4 together provide us the estimate o(n2 ), S(q) q 9, q=1 Chaptr 11 Th singular sris Rcall that by Thorms 10 and 104 togthr provid us th stimat 9 4 n 2 111 Rn = SnΓ 2 + on2, whr th singular sris Sn was dfind in Chaptr 10 as Sn = q=1 Sq q 9, with Sq = 1 a q gcda,q=1

More information