Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 461 – Sept. 2 Review NFA  DFA Combining FAs to create new languages –union, intersection, concatenation, star –We can basically understand how these.

Similar presentations


Presentation on theme: "CS 461 – Sept. 2 Review NFA  DFA Combining FAs to create new languages –union, intersection, concatenation, star –We can basically understand how these."— Presentation transcript:

1 CS 461 – Sept. 2 Review NFA  DFA Combining FAs to create new languages –union, intersection, concatenation, star –We can basically understand how these work by drawing a picture. Section 1.3 – Regular expressions –A compact way to define a regular set, rather than drawing an FA or writing transition table.

2 Example #2 NFA transition table given to the right. DFA start state is A. DFA accept state would be anything containing D. inputs State01ε AAAA,C- BD-C C-B- D BD-

3 continued Let’s begin. δ(A, 0) = A δ(A, 1) = AC We need new state AC. δ(AC, 0) = A δ(AC, 1) = ABC Continue from ABC… inputs State01ε AAAA,C- BD-C C-B- D BD-

4 answer NFA DFA inputs State01ε AAAA,C- BD-C C-B- D BD- inputs State01 AAAAC AABC ADABC AD ABCACD ABCABCD

5 Moral NFAs and DFAs have same computational power. NFAs often have fewer states than corresponding DFA. Typically, we want to design a DFA, but NFAs are good for combining 2+ DFAs. After doing NFA  DFA construction, we may see that some states can be combined. –Later in chapter, we’ll see how to simplify FAs.

6 U and ∩ Suppose M 1 and M 2 are DFAs. We want to combine their languages. Union: We create new start state. √ –Do you understand formalism p. 60 ? How can we also do intersection? Hint: A ∩ B = (A’ U B’)’

7 Concatenation Concat: For each happy state in M 1, turn it into a reject state and add ε-trans to M 2 ’s start. Example L 1 = { does not contain 00 } L 2 = { has even # of 1’s } Let’s draw NFA for L 1 L 2. Let’s decipher formal definition of δ on p. 61.

8 Star We want to concat the language with itself 0+ times. Create new start state, and make it happy. Add ε-transitions from other happy states to the start state. Example L = { begins with 1 and ends with 0 } Let’s draw NFA for L*. Formal definition of δ on p. 63.

9 Regular expression A concise way to describe a language –Text representation, straightforward to input into computer programs. Use alphabet symbols along with operators + means “or” * means repetition Concatenation There is no “and” or complement.

10 Examples What do you think these regular expressions mean? 0* + 1* 0*1* 00*11* (a shorthand would be 0 + 1 + ) (0 + 1)* What’s the difference between 10*1 and 1(0+1)*1 ? Does this mean “anything with 1 at beginning and end?”

11 Practice Words with 2 or more 0’s. What’s wrong with this answer: 1*01*01 ? Words containing substring 110. Every even numbered symbol is 0. –What’s wrong with: ((0 + 1)*0)* ? Words of even length. The last 2 symbols are the same. What is the shortest word not in: 1*(01)*0* ? True or false: (111*) = (11 + 111)*


Download ppt "CS 461 – Sept. 2 Review NFA  DFA Combining FAs to create new languages –union, intersection, concatenation, star –We can basically understand how these."

Similar presentations


Ads by Google