1 / 20

Introduction to the Theory of Computation

Introduction to the Theory of Computation. John Paxton Montana State University Summer 2003. Humor.

kira
Download Presentation

Introduction to the 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. Introduction to the Theory of Computation John Paxton Montana State University Summer 2003

  2. Humor • A man walks up to the Marine guard at the White House front gate and asked to see President Clinton. The guard says "Sorry sir but Clinton is no longer president."       The man comes back the next day and again approaches the same guard and asks to see President Clinton. Again the guard says "Sir, Clinton is no longer president." The man leaves but comes back the third day and again asked to see President Clinton.       The guard says "Sir...you have been here three days in a row asking to see President Clinton...and I have told you each time that Clinton is no longer president...what gives?"       The man says "I know... I just like hearing it."

  3. 1.3 Regular Expression • Pattern Recogniton • Unix (GREP) • Perl • Text Editors

  4. Formal Definition R is a regular expression if R is • a for some a in the alphabet S • e • {} • (R1 U R2) where R1 and R2 are both regular expressions • (R1 R2) • (R1*)

  5. Exercise: Describe the Language • 0*10* • S*1S* • (SS)* • 01 U 10 • (0 U e)1* • 0S*0 U 1S*1 U 0 U 1 • 1*{} • {}*

  6. Exercise: Give the Regular Expression • {w | w begins with a 1 and ends with a 0} • {w | w contains at least 3 0s} • {w | w starts with a 0 and has odd length or starts with a 1 and has even length} • {w | the length of w is at most 5} • {w | w contains at least two 0s and at most one 1} • All strings except the empty string

  7. Theorem • A language is regular if and only if some regular expression describes it. • Part I. If a language is described by a regular expression, then it is regular. • Part II. If a language is regular, then it is described by a regular expression.

  8. Part 1: Show constructions • R = a • R = e • R = {} • R = R1 U R2 • R = R1 R2 • R = R1* #1 a

  9. Exercises • Build an NFA from the regular expression (ab U a)*. • Build an NFA from the regular expression (0 U 1)*000(0 U 1)*.

  10. Part II • A generalized nondeterministic finite automaton (GNFA): • The start state has transition arrows going to every other state but no arrows coming in from any other state. • There is only a single accept state, and it has arrows coming in from every other state but no arrows going to any other state. Furthermore, the accept state is not the same as the start state

  11. GNFA • Except for the start state and accept state, one arrow goes from every state to every other state and also from each state to itself. a U b a e qstart q1 qaccept a*

  12. GNFA Definition • A generalized nondeterministic finite automaton, (Q, S, d, qstart, qaccept) is a 5-tuple where • Q is the finite set of states • S is the input alphabet • d : (Q – {qaccept}) x (Q – {qstart})  R is the transition function • qstart is the start state • qaccept is the accept state

  13. GNFA Acceptance • A GNFA accepts a string w in S* if w = w1w2…wk where each wi is in S* and a sequence of states q0,q1,…qk exists such that • q0 = qstart • qk = qaccept • for each i, wie L(Ri) where Ri = d(qi-1,qi)

  14. Part II: Proof Process • Start with a k state DFA • Construct a k+2 state GNFA • Map to a k+1 state GNFA • ….. • Map to a 2 state GNFA • Read off the regular expression!

  15. Conversion Example • 2 state DFA a a, b b 1 2

  16. Conversion Example • 4 state GNFA a a U b b 1 2 {} e e {} {}

  17. Conversion Example • 3 state GNFA a U b ea*b 2 e ea*{} U {}

  18. Conversion Example • 3 state GNFA (simplified) a U b a*b 2 e {}

  19. Conversion Example • 2 state GNFA Regular Expression: a*b(a U b)* {} U a*b(a U b)*e

  20. Exercise • Convert to a regular expression a b 1 3 2 e

More Related