1 / 25

CSCI 2670 Introduction to Theory of Computing

Understand regular expressions (RE) and automata equivalence with examples, conversions, and properties. Learn to convert DFAs to GNFA for RE representation. Explore RE's in relation to regular languages.

elainewest
Download Presentation

CSCI 2670 Introduction to Theory of Computing

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 2670Introduction to Theory of Computing September 6, 2005

  2. Announcements • Homework due next Tuesday (9/13) • 1.7(d,h), 1.16b, 1.21b (show the GNFA steps),1.19a, 1.46c, 1.55(c,f,j) • Old text numbers 1.5(d,g), 1.12b, 1.16b, 1.14a, 1.23d, 1.38(same instructions on (0010*1*, , and Σ*) • If you ask me a question on a homework problem by email, please email me the problem in question • Quiz tomorrow • Section 1.2 & Formal definition of RE

  3. Agenda • Last week • Section 1.2 • NFA’s • Regular expression intro (Section 1.3) • Today • Continue regular expressions • This week • Sections 1.3 and 1.4

  4. Abuse of notation. These should be sets! RE inductive definition R is a regular expression if R is • a for some a   • ε •  • R1R2 where R1 and R2 are both regular expressions • R1R2 where R1 and R2 are both regular expressions • (R1*) where R1 is a regular expression

  5. RE’s and regular languages Theorem: A language is regular if and only if some regular expression describes it. • i.e., every regular expression has a corresponding DFA and vice versa

  6. RE’s and regular languages Lemma: If a language is described by a regular expression, then it is regular. • find an NFA corresponding to any regular expression • use inductive definition of RE’s

  7. a q1 q2 1. R=a for some a N = {{q1,q2},,,q1,{q2}} where (q1,a)={q2} and (r,x)= whenever r=q2 or x≠a

  8. q1 2. R=ε N = {{q1},,,q1,{q1}} where (q1,x)= for all x

  9. q1 3. R= N = {{q1},,,q1,} where (q1,x)= for all x

  10. Remaining constructions • R = R1R2 • R = R1R2 • R = R1* • These were all shown to be regular operators • We know we can construct NFA’s for R provided they exist for R1 and R2

  11. 0 R1 = 0 1 R2 = 1 R = Σ1 0 0 ε R3 = 01 ε 1 ε 1 ε ε 1 ε Example • R = 1 • R = (01)1

  12. 1 R1 = 1 0,1 R3 = * ε R = 1(0ε)* 0 R2 = 0ε ε 0 ε ε ε 0,1 1 ε ε ε ε ε ε Example2 • R = 1(0ε)*

  13. Equivalence of RE’s and DFA’s • We have seen that every RE has a corresponding NFA • Therefore, every RE has a corresponding DFA • I.e, every RE describes a regular language • We need to show that every regular language can be described by a RE • Begin by converting all DFA’s into GNFA’s • Generalized Non-deterministic Finite Automata

  14. GNFA’s • A GNFA is an NFA with the following properties: • The start state has transition arrows going to every other state, but no arrows coming in from any other state • There is exactly one accept state and there is an arrow from every other state to this state, but no arrows to any other state from the accept state • The start state is not the accept state

  15. GNFA’s (continued) • Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself • Instead of being labeled with symbols from the alphabet, transitions are labeled with regular expressions

  16. 01  0  1 0  10  Example GNFA

  17. Equivalence of DFA’s and RE’s • First show every DFA can be converted into a GNFA that accepts the same language • Then show that any GNFA has a corresponding RE that accepts the same language

  18. Converting a DFA into a GNFA • Add two new states • New start state with an ε jump to the original DFA’s start state • New accept state with an ε jump from each of the original DFA’s accept states • This new state will be the only accept state • All transition labels with multiple labels are relabeled with the union of the previous labels • All pairs of states without transitions get a transition labeled 

  19. 0 q2 1 qs qt q1 1 ε ε 0 q3 q4 0,1 0,1 Converting a DFA to a GNFA Add two new states

  20. qs qt ε ε Converting a DFA to a GNFA • All transition labels with multiple labels are relabeled with the union of the previous labels 0 q2 1 q1 1 0 q3 q4 0,1 01 0,1 01

  21. qs qt ε ε Converting a DFA to a GNFA • All pairs of states without transitions get a transition labeled  0 q2 1 q1 1 0 q3 q4 01 01

  22. qs qt ε ε Converting a DFA to a GNFA • The resulting state diagram is a GNFA • All GNFA properties are satisfied 0 q2 1 q1 1 0 q3 q4 01 01

  23. qs qt ε ε Converting a DFA to a GNFA • No step changed the strings accepted by the machine 0 q2 1 q1 1 0 q3 q4 01 01

  24. Converting a GNFA to a RE • If the GNFA has two states, then the label connecting the states is the RE • Otherwise, remove one state at a time without changing the language accepted by the machine until the GNFA has two states

  25. a12 q2 q1 a32 a13 q3 a33 Removing one state from a GNFA a12a13a33*a32 q1’ q2’

More Related