Presentation is loading. Please wait.

Presentation is loading. Please wait.

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Similar presentations


Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."— Presentation transcript:

1 INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2 THE REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w 1 …w k | k ≥ 0 and each w i  A }

3 1 0 1 0 1 0,1 0

4 NON -DETERMINISM 1 0 1 0 1 0,1 0 An NFA accepts if there is a series of choices that take it to an accept state

5 Deterministic Computation Non-Deterministic Computation accept or rejectaccept reject

6 Theorem: Every NFA has an equivalent DFA Corollary: A language is regular iff it is recognized by an NFA

7 FROM NFA TO DFA Input: N = (Q, Σ, , Q 0, F) Output: M = (Q, Σ, , q 0, F) accept reject To learn if NFA accepts, we could do the computation in parallel, maintaining the set of states where all threads are Q = (Q) Idea:

8  (R,  ) =  ε(  (r,  ) ) Q = (Q)  : Q  Σ → Q  (R,  ) =  ε(  (r,  ) ) rRrR q 0 = ε(Q 0 ) F = { R  Q | f  R for some f  F } FROM NFA TO DFA Input: N = (Q, Σ, , Q 0, F) Output: M = (Q, Σ, , q 0, F)  (R,  ) =  ε(  (r,  ) )

9 EXAMPLES: NFA TO DFA 1 0,1 ε0 2 3 1 a b 1

10 REGULAR LANGUAGES CLOSED UNDER CONCATENATION Given DFAs M 1 and M 2, construct NFA by connecting all accept states in M 1 to start states in M 2 ε ε L(M 1 )=A L(M 2 )=B

11 REGULAR LANGUAGES ARE CLOSED UNDER REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w 1 …w k | k ≥ 0 and each w i  A }

12 REGULAR LANGUAGES CLOSED UNDER STAR Let L be a regular language and M be a DFA for L We construct an NFA N that recognizes L* 0 0,1 0 0 1 1 1 ε ε ε

13 Formally: Input: M = (Q, Σ, , q 1, F) Output: N = (Q, Σ, , {q 0 }, F) Q = Q  {q 0 } F = F  {q 0 }  (q,a) = {  (q,a)} {q1}{q1} {q1}{q1}  if q  Q and a ≠ ε if q  F and a = ε if q = q 0 and a = ε if q = q 0 and a ≠ ε  else

14 L(N) = L* Assume w = w 1 …w k is in L*, where w 1,…,w k  L We show N accepts w by induction on k Base Cases: k = 0 k = 1 Inductive Step: Assume N accepts all strings v = v 1 …v k  L*, and let u = u 1 …u k u k+1  L* Since N accepts u 1 …u k and M accepts u k+1, N must accept u

15 Assume w is accepted by N, we show w  L* If w = ε, then w  L* If w ≠ ε accept ε ε

16 REGULAR LANGUAGES ARE CLOSED UNDER REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w 1 …w k | k ≥ 0 and each w i  A }

17 REGULAR EXPRESSIONS

18  is a regular expression representing {  } ε is a regular expression representing {ε}  is a regular expression representing  If R 1 and R 2 are regular expressions representing L 1 and L 2 then: (R 1 R 2 ) represents L 1  L 2 (R 1  R 2 ) represents L 1  L 2 (R 1 )* represents L 1 *

19 PRECEDENCE *  

20 R2R2 R1*R1*( EXAMPLE R 1 *R 2  R 3 = ())  R3R3

21 { w | w has exactly a single 1 } 0*10*

22 { w | w has length ≥ 3 and its 3rd symbol is 0 } 000(0  1)*  010(0  1)*  100(0  1)*  110(0  1)*

23 { w | every odd position of w is a 1 }


Download ppt "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."

Similar presentations


Ads by Google