Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 2670 Introduction to Theory of Computing September 1, 2005.

Similar presentations


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

1 CSCI 2670 Introduction to Theory of Computing September 1, 2005

2 Agenda Last class –Equivalence of DFA’s and NFA’s Today –Some work on designing NFA’s –Closure of regular languages under regular operators –Another method for describing regular languages

3 Group project For each NFA –Informally describe the behavior of the NFA –Construct a DFA accepting the same language

4 Group 1 ε ε 1 0 1 0 1 1 0 0 All strings containing an even number of 0’s or an even number of 1’s

5 Group 2 0,ε 0110 All prefixes of the string 0110 Proper prefixes may be followed by a 0

6 Group 3 ε ε 1 1 1 1 0 0 0 0 1 0 All strings with a zero count divisible by 2 or 3

7 Group 4 10,1 All strings that have a 1 in one of the last three positions ε ε

8 Group 5 0 1 0 1 All strings with alternating 0’s and 1’s that start with a 0

9 Group 6 1 1 1 0 0 0 ε All strings containing either zero 1’s or three or more 1’s

10 Closure of NFA’s under regular operations Recall the following are the regular operators –Union –Concatenation –Kleene star

11 Union is a regular operation Theorem: The class of regular languages is closed under the union operation Proof approach: Assume A 1 and A 2 are both regular languages with A 1 =L(M 1 ) and A 2 =L(M 2 ) and create an NFA M such that L(M) = A 1  A 2 Method: Proof by construction

12 M Construct M from M 1 and M 2 M1M1 M2M2 ε ε

13 Concatenation is a regular operation Theorem: The class of regular languages is closed under the concatenation operation Proof approach: Assume A 1 and A 2 are both regular languages with A 1 =L(M 1 ) and A 2 =L(M 2 ) and create an NFA M such that L(M) = A 1  A 2 Method: Proof by construction

14 M Construct M from M 1 and M 2 M1M1 M2M2 εε

15 Kleene star is a regular operation Theorem: The class of regular languages is closed under the Kleene operation Proof approach: Assume A 1 is a regular language with A 1 =L(M 1 ) and create an NFA M such that L(M) = A 1 * Method: Proof by construction

16 M Construct M from M 1 M1M1 ε ε ε

17 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  *

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

19 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 * ) where R 1 is a regular expression

20 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,ε}

21


Download ppt "CSCI 2670 Introduction to Theory of Computing September 1, 2005."

Similar presentations


Ads by Google