1 / 18

CSCI 2670 Introduction to Theory of Computing

This lecture covers the introduction to regular expressions in the context of the Theory of Computing. It discusses the formal definition of regular expressions, examples, and their relationship with regular languages. The equivalence of regular expressions and DFA's is also explored.

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 7, 2004

  2. Agenda • Last week • Section 1.2 • NFA’s • Today • Start Section 1.3 • Regular expressions • This week • Sections 1.3 and 1.4 • May not complete Section 1.4

  3. Announcement • Homework due next Tuesday (9/14) • 1.5e, 1.12a, 1.16a (show the GNFA steps), 1.17b, 1.39 • Quiz tomorrow • Section 1.2 & Formal definition of RE

  4. Regular expressions (RE’s) • So far we have had to describe languages either with finite automata or with words • Potentially clumsy or imprecise • Today we learn precise expression to describe regular languages • Example: All strings with at least one 1 becomes *{1}*, or more simply *1*

  5. Where have you seen RE’s? • Grep • Awk • Perl • Search expressions within emacs or vi

  6. 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*) R1 is a regular expression

  7. Examples • 0*10*10* • {w | w contains exactly two 1’s} • 11 • {w | w contains two consecutive 1’s} • 1(0ε)1 • {w | w contains two 1’s separated by at most one 0} • (0ε)(1ε) • {0,1,01,ε}

  8. 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

  9. 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

  10. 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=b

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

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

  13. 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

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

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

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

  17. 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

  18. 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

More Related