1 / 11

CS 461 – Sept. 2

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

alaric
Download Presentation

CS 461 – Sept. 2

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

  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…

  4. NFA DFA answer

  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 M1 and M2 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 M1, turn it into a reject state and add ε-trans to M2’s start. • Example L1 = { does not contain 00 } L2 = { has even # of 1’s } Let’s draw NFA for L1L2. • 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)*

More Related