1 / 26

Intro to Theory of Computation

L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism. Intro to Theory of Computation. CS 464. Sofya Raskhodnikova. Homework 0 due Homework 1 handed out. JFLAP http://www.cs.duke.edu/csed/jflap/. aaa. a aa. a a a. aa a. q 1. 1. 0. 0,1. 1. M.

kalkin
Download Presentation

Intro to Theory of Computation

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. LECTURE2 • Theory of Computation • Finite Automata • Operations on languages • Nondeterminism Intro to Theory of Computation CS 464 Sofya Raskhodnikova Homework 0 due Homework 1 handed out SofyaRaskhodnikova; based on slides by Nick Hopper

  2. JFLAP http://www.cs.duke.edu/csed/jflap/ aaa aaa aaa aaa SofyaRaskhodnikova; based on slides by RakeshVerma

  3. q1 1 0 0,1 1 M q0 q2 0 0 1 q3 Formal definition of FA 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 * SofyaRaskhodnikova; based on slides by Nick Hopper

  4. Language of FA The language of M, L(M), is the set of strings that M accepts A language is regularif it is recognized by a finite automaton L = { w | w contains 001} is regular L = { w | w has an even number of 1s} is regular SofyaRaskhodnikova; based on slides by Nick Hopper

  5. Regular languages Many interesting programs accept regular languages NETWORK PROTOCOLS COMPILERS GENETIC TESTING ARITHMETIC Sofya Raskhodnikova; based on slides by Nick Hopper

  6. INTERNET TRANSMISSION CONTROL PROTOCOL Let TCPS = { w | w is a complete TCP Session} Theorem. TCPSis regular Sofya Raskhodnikova; based on slides by Nick Hopper

  7. Compilers COMMENTS : Are delimited by /* */ Cannot have NESTED /* */ Must be CLOSED by */ */ is ILLEGAL outside a comment COMMENTS = {strings with legal comments} Theorem. COMMENTS is regular. Sofya Raskhodnikova; based on slides by Nick Hopper

  8. Genetic testing DNA SEQUENCES are strings over the alphabet {A,C,G,T} GENES are special substrings A GENETIC TEST searches a DNA SEQUENCE for a GENE Theorem. Every GENETIC TEST is regular. Sofya Raskhodnikova; based on slides by Nick Hopper

  9. Arithmetic { [ ],[ ],[ ],[ ], [ ],[ ],[ ],[ ]} 0 0 0 0 0 1 0 1 0 0 1 1 LET 3 = • A string over 3 has three ROWS • Each ROW b0b1b2…bN represents the integer b0+ 2b1 + … + 2NbN. • Let ADD = {S | ROW1+ ROW2 = ROW3 } Theorem. ADD is regular. 1 0 0 1 0 1 1 1 0 1 1 1 Sofya Raskhodnikova; based on slides by Nick Hopper

  10. Regular Operations on languages Complement: A = { w | w  A } Union: A  B = { w | w  A or w  B } 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 } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w1 …wk | k ≥ 0 and each wi A } Star: A* = { w1 …wk | k ≥ 0 and each wi A } Sofya Raskhodnikova; based on slides by Nick Hopper

  11. Closure properties of the class of regular languages THEOREM. The class of regular languages is closedunder all 6 operations. If A and B are regular, applying any of these operation yields a regular language. Sofya Raskhodnikova; based on slides by Nick Hopper

  12. Closure properties Complement: A = { w | w  A } Union: A  B = { w | w  A or w  B } Sofya Raskhodnikova; based on slides by Nick Hopper

  13. Closure under union Theorem. The union of two regular languages is also a regular language Proof: Let M1 = (Q1, Σ, 1, q0, F1) be finite automaton for L1 and M2 = (Q2, Σ, 2, q0, F2) be finite automatonfor L2 1 2 Construct a finite automaton M = (Q, Σ, , q0, F) that recognizes L = L1 L2 Sofya Raskhodnikova; based on slides by Nick Hopper

  14. 0 0 1 q0 q1 1 1 1 0 p0 p1 0 Example M1 M2 M = ? Sofya Raskhodnikova; based on slides by Nick Hopper

  15. = pairs of states, one from M1 and one from M2 Q = { (q1, q2) | q1 Q1 and q2  Q2 } = Q1 Q2 1 2 q0 = (q0, q0) Proof (continued) Idea: Run both M1 and M2 at the same time! F = { (q1, q2) | q1 F1or q2  F2 } ( (q1,q2), ) = (1(q1, ), 2(q2, )) Sofya Raskhodnikova; based on slides by Nick Hopper

  16. 0 0 1 q0 q1 1 1 1 0 p0 p1 0 Example (continued) intersection union M M1 1 q0,p0 q1,p0 1 0 0 0 0 M2 1 q0,p1 q1,p1 1 Sofya Raskhodnikova; based on slides by Nick Hopper

  17. Closure properties Complement: 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 } Sofya Raskhodnikova; based on slides by Nick Hopper

  18. Closure under reverse Theorem. The reverse of a regular language is also regular language Proof: Let L be a regular language and M be a finite automaton that recognizes it. Construct a finite automaton MR recognizing LR Idea: Define MR as M with the arrows reversed Swap start and accept states Sofya Raskhodnikova; based on slides by Nick Hopper

  19. Closure under reverse MR IS NOT ALWAYS A DFA! It may have many start states Some states may have too many outgoing edges, or none Sofya Raskhodnikova; based on slides by Nick Hopper

  20. Example 0,1 1 0 0 0 1 1 Sofya Raskhodnikova; based on slides by Nick Hopper

  21. NONDETERMINISM 0,1 1 0 0 0 1 1 What happens with 100? Nondeterministic Finite Automaton (NFA) acceptsif there is a way to make it reach an accept state SofyaRaskhodnikova; based on slides by Nick Hopper

  22. Nondeterminism Deterministic Computation Nondeterministic Computation reject accept accept or reject SofyaRaskhodnikova; based on slides by Nick Hopper Ways to think about nondeterminism parallel computation tree of possible computations guessing the “right” choice

  23. Example 1 ε 0 0 ε L(M)={1,00} Sofya Raskhodnikova; based on slides by Nick Hopper

  24. Example 0,1 0,1 1 0,ε 1 L(M)={w | w contains 101 or 11} Sofya Raskhodnikova; based on slides by Nick Hopper

  25. Formal Definition An NFAis a 5-tuple M = (Q, Σ, , q0, F) Q is the set of states Σ is the alphabet  : Q Σε→ P(Q) is the transition function q0 Q is the start state F  Q is the set of accept states P(Q) is the set of subsets of Q and Σε = Σ {ε} Sofya Raskhodnikova; based on slides by Nick Hopper

  26. Example 0,1 0,1 1 0,ε 1 q3 q1 q0 q2 N = (Q, Σ, , q0, F) {q0, q1} (q0,1) = Q = {q0, q1, q2, q3} (q1,ε) = {q1,q2} Σ = {0,1} F = {q3} (q2,0) =  Sofya Raskhodnikova; based on slides by Nick Hopper

More Related