LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong
Today's Topic Review of ungraded homework Closure properties of FSA Practice! Homework out on Thursday…
From last time Ungraded Homework 6 apply the set-of-states construction technique to the two machines on the ε- transition slide (repeated below) self-check your answer: verify in each case that the machine produced is deterministic and accurately simulates its ε-transition counterpart 1 a ε 2 3 b > 1 a ε 2 3 b >
Ungraded Homework 6 Review Converting a NDFSA into a DFSA a b Note: this machine with an ε-transition is non-deterministic > 1 2 3 ε {1,3} {2} {3} Note: this machine is deterministic > a b [Powerpoint animation]
Ungraded Homework 6 Review Converting a NDFSA into a DFSA a b Note: this machine with an ε-transition is non-deterministic > 1 2 3 ε {1,2} {2} {3} Note: this machine is deterministic > a b b [Powerpoint animation]
Regular Languages and FSA Formal (constructive) set-theoretic definition of a regular language Correspondence between REs and Regular Languages concatenation (juxtaposition) union (| also [ ]) Kleene closure (*) Note: x+ = xx*) Note: backreferences are memory devices and thus are too powerful e.g. L = {ww} and prime number testing (see earlier lectures)
Regular Languages and FSA Closure properties: i.e. do we still have a regular language afterward applying the operation? Properties not necessarily preserved higher up: e.g. context-free grammars as we’ll see later
Regular Languages and FSA Textbook gives one direction only case by case: Empty string Empty set Any character from the alphabet
Regular Languages and FSA Concatenation: Link final state of FSA1 to initial state of FSA2 using an empty transition Note: empty transition ε can be deleted using the set of states construction
Regular Languages and FSA Kleene closure: repetition operator: zero or more times use empty transitions for loopback and bypass
Regular Languages and FSA Union: aka disjunction Non-deterministically run both FSAs at the same time, accept if either one accepts
Regular Languages and FSA Other closure properties: Let’s consider building the FSA machinery for each of these guys in turn…
Regular Languages and FSA Other closure properties: Final state?
Regular Languages and FSA Other closure properties: Final state?
Regular Languages and FSA Other closure properties: Example: Σ* = {a,b} need arcs for each character in Σ
Regular Languages and FSA Other closure properties: reverse arrows and swap initial/final
Regular Expressions from FSA Recall textbook Exercise: find a RE for Examples (* denotes string not in the language): *ab *ba bab λ (empty string) bb *baba babab
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+)* | ε
Regular Expressions from FSA Example Perl implementation: $s = "ab ba bab bb baba babab"; while ($s =~ /\b(b+(ab+)*)\b/g) { print "<$1> match!\n"; } Output: perl test.perl <bab> match! <bb> match! <babab> match! Note: this doesn’t include the empty string case Note: recall /../g global flag for multiple matches
Converting FSA to REs Example: State by-pass method: Give a RE for the FSA: State by-pass method: Delete one state at a time Calculate the possible paths passing through the deleted state Add the regex calculated at each stage as an arc e.g. eliminate state 3 then 2… 1 2 3 >
Converting FSA to REs Answer: (0(1+0|1)*1+1 | 1)* eliminate state 3 2 3 > eliminate state 3 eliminate state 2 1 1 > 1 > 1 0(1+0|1)*1+1 2 1+1 1+0 1 > 0(1+0|1)*1+1 | 1 Answer: (0(1+0|1)*1+1 | 1)* [Powerpoint animation]