Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 2670 Introduction to Theory of Computing September 7, 2004.

Similar presentations


Presentation on theme: "CSCI 2670 Introduction to Theory of Computing September 7, 2004."— Presentation transcript:

1 CSCI 2670 Introduction 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 1.a for some a   2. ε 3.  4.R 1  R 2 where R 1 and R 2 are both regular expressions 5.R 1  R 2 where R 1 and R 2 are both regular expressions 6.(R 1 * ) R 1 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 1. R=a for some a  N = {{q 1,q 2 }, , ,q 1,{q 2 }} where  (q 1,a)=q 2 and  (r,x)=  whenever r=q 2 or x=b a q1q1 q2q2

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

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

13 Remaining constructions R = R 1  R 2 R = R 1  R 2 R = R 1 * These were all shown to be regular operators –We know we can construct NFA’s for R provided they exist for R 1 and R 2

14 Example R =  1 –R = (0  1)1 0 R 1 = 0 R 3 = 0  1 0 1 ε ε 1 R = (0  1)1 0 1 ε ε ε ε 1 R 2 = 1

15 Example2 R = 1(0  ε)  * 1 R 1 = 1 R 2 = 0  ε 0 ε ε ε 0,1 R 3 =  * ε R = 1(0  ε )  * 1 0 ε ε ε ε 0,1 ε ε ε

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: 1.The start state has transition arrows going to every other state, but no arrows coming in from any other state 2.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 3.The start state is not the accept state

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


Download ppt "CSCI 2670 Introduction to Theory of Computing September 7, 2004."

Similar presentations


Ads by Google