1 / 9

Homework #3 Solutions

Homework #3 Solutions. #1. True or False. a a b a matches a* + b* T F b) babab matches b (ab)* T F c) If A = F then A B = F for all languages B T F d) If A = { e } then A B = F for all languages B T F

toyah
Télécharger la présentation

Homework #3 Solutions

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. Homework #3 Solutions

  2. #1. True or False • a a b a matches a* + b* T F b) babab matches b (ab)* T F c) If A = F then A B = F for all languages B T F d) If A = {e} then A B = F for all languages B T F e) If A = a* and S = {a,b}, then S* - A = b* T F

  3. #2. Write regular expressions for the set of strings of 0’s and 1’s with at most one pair of consecutive 1’s • Exercise says “at most one” occurrence of “11”, so start with (e + 1 + 11) • Now build around it the combination of 1’s and 0’s that will prevent another occurrence of “11”: In front: (0 +10)* After: (0 + 01)* • So altogether: (0 +10)* (e + 1 + 11) (0 +10)*

  4. #3. Draw the graph for the following DFA and then convert to regular expression. This gives you an idea how messy these are, and how you’d really like to plug them into a computer program! 1. Using Sudkamp method: Eliminating “r”:

  5. #3 continued • Then eliminating “s” • Eliminating “q” • Now we * the expression on the loop to get the • regular expression: • (1 + (0(0 + 10*1))(1(0 + 10*1))*0)* • Whew!

  6. #3 continued Using Kozen Method removing q apppqrs = appprs + apqprs (aqqprs )* aqpprs appprs = 1* apqprs = 1*0 (0 +10*1) aqqprs = 01*0 (0 + 10*1) + 1 (0 +10*1) aqpprs = 01* So apppqrs = 1* + 1*0 (0 +10*1) (01*0 (0 + 10*1) + 1(0+10*1 )* 01* I’m sure this can be simplified. If anyone wants to send me their simplification, I’ll post it with full credit to the sender!

  7. #4. Does (R +S)* S = (R*S)* ? Justify your answer • No • Counter-example: if e is not in S, then they are not equal.

  8. #5. What does the Perl expression: s/(^[A_Z]{1})([az]+)\.sgml/\1\2\.html/g tr/a-z/A-Z/say to do? • Converts file names with extension “sgml” to file names with extension “html”, • and changes all letters to upper-case

  9. #6. What do you think the regular expression on the Module 3 page represents? • Looks like “social security numbers”

More Related