1 / 8

LING/C SC/PSYC 438/538

LING/C SC/PSYC 438/538. Lecture 15 Sandiway Fong. Midterm Instructions. By the end of the class 538 Answer any 5 questions 438 Answer any 4 questions Collect all answers into ONE file and email to sandiway@email.arizona.edu Good luck!. Question 1.

devlin
Download Presentation

LING/C SC/PSYC 438/538

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. LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong

  2. Midterm Instructions • By the end of the class • 538 Answer any 5 questions • 438 Answer any 4 questions • Collect all answers into ONE file and email to sandiway@email.arizona.edu • Good luck!

  3. Question 1 • Alphabet = {(,)} (set of left and right parentheses) • Language L = set of all non-empty strings with properly balanced parentheses, i.e. each left parenthesis has a properly-nested corresponding right parenthesis • Examples: • () *)( • ()()() *()(() • (()())((())()) • Give a context-free grammar for L (grammar rules in either Prolog or non-Prolog format are acceptable)

  4. Question 2 • A grammar is ambiguous if there are two (or more) separate ways to derive the (same) string using the rules • Consider regular grammar G below Start symbol: a, alphabet = {0,1} • a --> [1], b. • b --> [0], b. • b --> [0], c. • c --> [0], b. • c --> [1], c. • c --> [1]. • Show that G is ambiguous, i.e. give an example of a string that has two distinct derivations in G • Submit both the string and its derivations • Examples: • strings 101, 1011, 1001 are members of the language generated by G

  5. Question 3 • Consider again regular grammar G from Question 2 Start symbol: a, alphabet = {0,1} • a --> [1], b. • b --> [0], b. • b --> [0], c. • c --> [0], b. • c --> [1], c. • c --> [1]. • Construct an equivalent deterministic FSA for G • Show your steps (e.g. conversion into a NDFSA, conversion into a deterministic FSA) (diagrams okay)

  6. Question 4 • Consider again regular grammar G from Question 2 Start symbol: a, alphabet = {0,1} • a --> [1], b. • b --> [0], b. • b --> [0], c. • c --> [0], b. • c --> [1], c. • c --> [1]. • Give an equivalent unambiguous regular grammar to G

  7. Question 5 • Argue (convincingly) whether regular expressions (1) and (2) are equivalent or not • a(ba)* • (ab)*a

  8. Question 6 • Define a Perl regexp as regular expressions + backreferences. • We have seen in class that Perl regexps are more powerful than regular languages, e.g. the prime number testing example. • Decide whether these languages can be described using Perl regexps. • (Submit Perl regexps for the ones you decide can be described.) • L1 = {anbn | n ≥ 1} • L2 = {anbmanbm | n,m ≥ 1} • L3 = {anbnbn | n ≥ 1}

More Related