1 / 28

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. q 1. 1. 0. 0,1. 1. M. q 0. q 2. 0. 0. 1. q 3. M = (Q, Σ , , q 0 , F) where. Q = {q 0 , q 1 , q 2 , q 3 }. Σ = {0,1}.  : Q  Σ → Q transition function *. q 0  Q is start state.

pascal
Download Presentation

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS

  2. q1 1 0 0,1 1 M q0 q2 0 0 1 q3 M = (Q, Σ, , q0, F) where Q = {q0, q1, q2, q3} Σ = {0,1}  : Q Σ→ Q transition function* q0 Q is start state F = {q1, q2} Q accept states *

  3. THE REGULAR OPERATIONS Negation: A = { w | w  A } Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Reverse: AR = { w1 …wk | wk …w1 A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w1 …wk | k ≥ 0 and each wi A }

  4. REGULAR EXPRESSIONS

  5. REGULAR EXPRESSIONS • is a regular expression representing {} ε is a regular expression representing {ε}  is a regular expression representing  If R1 and R2 are regular expressions representing L1 and L2 then: (R1R2) represents L1L2 (R1  R2) represents L1 L2 (R1)* represents L1*

  6. REGULAR EXPRESSIONS (+ ∪- ∪ε) {0…9}* (. ∪ε) {0…9}+ * NICK STINKS * CSCI {1...4}{0...9}{0...9}{0…9} * NICK RULES *

  7. PRECEDENCE *  EXAMPLE R1R2*  R3 = (R1 (R2*)) ∪R3

  8. { w | w has exactly a single 1 } 0*10* { w ||w|≥ 3 and its 3rd symbol is 0 } ΣΣ0Σ* { w | every odd position of w is a 1 } (1Σ)*(1∪ε)

  9. EQUIVALENCE L can be represented by a regexp  L is a regular language

  10. EQUIVALENCE Given regular expression R, we show there exists NFA N such that R represents L(N) L can be represented by a regexp  L is a regular language Induction on the length of R:

  11. Given regular expression R, we show there exists NFA N such that R represents L(N) Induction on the length of R:  L can be represented by a regexp  L is a regular language Base Cases (R has length 1): R =  R = ε R = 

  12. Inductive Step: Assume R has length k > 1 and that any regular expression of length < k represents a language that can be recognized by an NFA Three possibilities for R: R = R1 R2 R = R1R2 R = (R1)*

  13. L can be represented by a regexp  L is a regular language

  14. Transform (1(0  1))* to an NFA ε 1 1,0 ε

  15. CONVERT TO NFAs a*(b∪ε)a* (1)*∪1(1)* (lol∪zomg)*

  16. 0 0 01*0 1 Proof idea: Transform an NFA for L into a regular expression by removing states and re-labeling the arrows with regular expressions L can be represented by a regexp  L is a regular language 

  17. a∪b a q2 GENERALIZED NFAs a*b qs qa G accepts w if it finds q0q1…qk, w1…wk: wi∈R(qi,qi+1) w = w1w2…wk q0=qs, qk=qa R(qs,q2) = a*b R(qa,q) = Ø R(q,qs) = Ø

  18. ε ε ε ε ε NFA TO GNFA NFA Add unique and distinct start and accept states

  19. ε ε ε ε ε GNFA TO REGEXP NFA While machine has more than 2 states: Pick an internal state, rip it out and re-label the arrows with regular expressions to account for the missing state

  20. a a,b (a*b)(ab)* ε b ε a*b q1 q2 q3 q0 R(q0,q3) = (a*b)(ab)*

  21. b bb a q1 q2 a ε b ε b a ε q3

  22. b bb a q1 q2 a  ba a ε b ε b a ε

  23. b = R(q1,q1) bb  (a  ba)b*a bb a q1 q2 a  ba ε ε b  (a  ba)b* b

  24. Convert the NFA to a regular expression a, b (a  b)b*b(bb*b)* b q1 q2 (a  b)b*b ε b (a  b)b*b(bb*b)*a bb*b a b ε q3 ε

  25. ((a  b)b*b(bb*b)*a)*  ((a  b)b*b(bb*b)*a)*(a  b)b*b(bb*b)*

  26. Formally: Add qstart and qaccept to create G Run CONVERT(G): If #states = 2 return the expression on the arrow going from qstart to qaccept If #states > 2

  27. Formally: Add qstart and qaccept to create G Run CONVERT(G): If #states > 2 select qripQ different from qstart and qaccept define Q = Q – {qrip} define Ras: R(qi,qj) = R(qi,qrip)R(qrip,qrip)*R(qrip,qj)  R(qi,qj) return CONVERT(G)

  28. NFA DFA DEF Regular Language Regular Expression

More Related