Download presentation
Presentation is loading. Please wait.
Published byHamdani Susanto Modified over 5 years ago
1
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong
2
Today's Topic Review of ungraded homework Closure properties of FSA
Practice! Homework out on Thursday…
3
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 >
4
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]
5
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]
6
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)
7
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
8
Regular Languages and FSA
Textbook gives one direction only case by case: Empty string Empty set Any character from the alphabet
9
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
10
Regular Languages and FSA
Kleene closure: repetition operator: zero or more times use empty transitions for loopback and bypass
11
Regular Languages and FSA
Union: aka disjunction Non-deterministically run both FSAs at the same time, accept if either one accepts
12
Regular Languages and FSA
Other closure properties: Let’s consider building the FSA machinery for each of these guys in turn…
13
Regular Languages and FSA
Other closure properties: Final state?
14
Regular Languages and FSA
Other closure properties: Final state?
15
Regular Languages and FSA
Other closure properties: Example: Σ* = {a,b} need arcs for each character in Σ
16
Regular Languages and FSA
Other closure properties: reverse arrows and swap initial/final
17
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
18
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+)* | ε
19
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
20
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 >
21
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]
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.