1 / 16

LING/C SC/PSYC 438/538

LING/C SC/PSYC 438/538. Lecture 10 9/27 Sandiway Fong. Administrivia. Homework 2 graded, you should have email from me this afternoon Review Set of states construction exercise Homework Install SWI-Prolog on your machines. Review. From lecture 7 NDFSA equivalent to deterministic FSA

xannon
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 10 9/27 Sandiway Fong

  2. Administrivia • Homework 2 • graded, you should have email from me this afternoon • Review • Set of states construction exercise • Homework • Install SWI-Prolog on your machines

  3. Review • From lecture 7 • NDFSA equivalent to deterministic FSA • Set of states construction • Exercise: • eliminate ε-transitions using the set-of-states construction • ε-transition implies non-determinism (can be in more than one state at a time)

  4. Set-of-states construction • Converting a NDFSA into a DFSA a b > 1 2 3 a b ε {1,2} {2} {3} b

  5. Set-of-states construction • Converting a NDFSA into a DFSA a b a b > 1 2 3 ε {1,3} {2} {3}

  6. Regular Languages and FSA • Formal (constructive) definition of a regular language • Correspondence between REs and Regular Languages • concatenation (juxtaposition) • union (| also [ ]) • Kleene closure (*) = (x+ = xx*) • Note: • Perl backreferences are too powerful, e.g. L = {ww} and prime number testing

  7. Regular Languages and FSA • Other closure properties: • Not true higherup: e.g. context-free grammars as we’ll see later

  8. Equivalence: FSA and REs JM gives one direction only • Case by case: • Empty set • Any character from the alphabet • Empty string

  9. Equivalence: FSA and REs • Concatenation: • Link final state of FSA1 to initial state of FSA2 using an empty transition Empty transition can be eliminated using set of states construction

  10. Equivalence: FSA and REs • Kleene closure: • Repetition operator: zero or more times • use empty transitions for loop and bypass

  11. Equivalence: FSA and REs • Union: aka disjunction • Non-deterministically run both FSAs at the same time, accept if either accepts

  12. Regular Languages and FSA • Other closure properties: Let’s consider building the composite FSA machinery for each of these guys in turn…

  13. Regular Expressions from FSA Textbook Exercise: find a RE for • Examples (* denotes string not in the language): • *ab*ba • bab • λ (empty string) • bb • *baba • babab

  14. Regular Expressions from FSA • Draw a FSA and convert it to a RE: b b [Powerpoint Animation] > 1 2 3 4 b a b ε b* b ( )+ ab+ = b+(ab+)* | ε

  15. Regular Expressions from FSA • Perl implementation: $s = "abbabab bb babababab"; while ($s =~ /\b(b+(ab+)*)\b/g) { print "<$1> match!\n"; } • Output: perltest.prl <bab> match! <bb> match! <babab> match! Note: doesn’t include the empty string case Note: /../g global flag for multiple matches (see lecture 9)

  16. Homework • We’re going to take a detour from the textbook • when we look at Regular Grammars • the programming language Prolog has great facilities for handling phrase structure grammar rules • Install SWI-Prolog on your machines • Freely available from • http://www.SWI-Prolog.org/ • Read about Prolog on the internet • Lots of tutorials etc. available online… • http://www.swi-prolog.org/www.html

More Related