equivalence, dfa, ndfa
DESCRIPTION
Equivalence, DFA, NDFA. Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 2. Updated and modified by Marek Perkowski. Equivalence Relation on A. An Equivalence Relation (Not Relation ship ) Is Not an Equality Relation - PowerPoint PPT PresentationTRANSCRIPT
Equivalence, DFA, NDFAEquivalence, DFA, NDFA
Sequential Machine Theory
Prof. K. J. HintzDepartment of Electrical and Computer
Engineering
Lecture 2
Updated and modified by Marek Perkowski
Equivalence Relation on AEquivalence Relation on A
• An Equivalence Relation (Not Relationship) Is Not an Equality Relation
• A Relation is an Equivalence Relation if and only if (iff) it is:– Reflexive– Symmetric– Transitive
Equivalence Relation on AEquivalence Relation on A
A
A
A
A
on ~ relation eequivalenc an is
e)(transitiv '',','','',' ',
)(symmetric ',,' ',
)(reflexive ', ,
R
RRR,
RR
R
then
aaaaaaaaa
and
aaaaaa
and
aaaa
if
Non-Algebraic Equivalence Relation Example
Non-Algebraic Equivalence Relation Example
Equivalence Relation on the Set of All Triangles on a Plane
“is congruent to” or “is similar to”
– Reflexive, each triangle is similar to itself,
Equivalence Relation ExampleEquivalence Relation Example
Symmetric, if
is similar to
then
is similar to
Equivalence Relation ExampleEquivalence Relation Example
Transitive, if
is similar to
and
is similar to
then
is similar to
Inclusion RelationInclusion Relation
ji
jiji
jjjj
iiii
ji
iff
then
, also are states all
)" in included is " as (read
,,,
,,,
, states, ofset theon defined partitions 2 Given
321
321
BBB
BBB
BBB
S
Inclusion Relation ExampleInclusion Relation Example
, in" included is"
,
5,4,3,2,1
5,4,3,2,1
5,4,3,2,1
21
21
2
14131211
1
or,
then
and
let
BBBB
Partition NotationPartition Notation
• Overbar Indicates States Which Are Elements of the Same -block.
• Single States Are Not Normally Listed
1
11 12 13 14
1 2
1 2 3 4 5
1 2 3 4 5
1 2 1 2 3 4 5
, , ,
,
,
B B B B
is written as
and
Relations May Be OrderingsRelations May Be Orderings
• Partial Ordering
• Total Ordering, aka Chain
• Well Ordering (not discussed here)
Partial OrderingPartial Ordering
• Given an Inclusion Relation, R: s s’, Defined on some Elements of the Set S such that s, s’ S, R Is a Partial Ordering If It Is:– Reflexive– Anti-Symmetric (asymmetric)– Transitive– Not all orderings are specified, therefore partial
Properties of POProperties of PO
– Reflexive• s s for all s S
– Anti-Symmetric (asymmetric)If
and
then
s s
s s
s s s s
'
, S
e.g., let : “older than”
if Sam is older than Bill,
then Bill cannot be older
than Sam
Properties of POProperties of PO
– TransitiveIf
and
then
s s
s s
s s
'
e.g., If the Redskins beat the Patriots
and the Patriots beat the Cowboys
then the Redskins will beat the Cowboys
Total OrderingTotal Ordering
• aka– Chain, simply ordered set, totally ordered set
• A Partial Ordering for Which All Orderings Are Specified
• A Chain Is “Connected” Because
s s s s s s or , S
POSETPOSET
• Partially Ordered SET– A set on which a partial ordering is specified– ( S, ) where is defined– Not a chain since not all elements are
connected
• We Will Revisit This Concept in a later part of the Course
Finite AutomataFinite Automata
A Deterministic semi-automaton*, aka Completely Specified Deterministic Semi-automaton Is a Triple
with no Mealy machine output function, Beta ()
* Ginzburg, 1968
,,
or ,,,
ΣK
IS
M
M
FSM Set PropertiesFSM Set Properties
,,,,,,,,,
,
inputs ofset finite A,,,,
states ofset finite A,,,,
1210
1210
ihgfedcba
m
n
sississis
S
iiiiI
ssss
ISSIS
KS
SIsa sc
ib
Language RecognizerLanguage Recognizer
• aka, Rabin-Scott Automata (machine), Automaton, Language Recognizer
• A Recognizer Is a Quintuple of Sets
with S, I, as before
M rs S I F, , , , s0
s
s sp q
0
the single, unique, initial state
A finite set of final statesF S, ,
Kleene StarKleene Star
• a* = e, a, aa, aaa, aaaa, ...
• The Kleene Star, *, means NONE or more occurrences of something
• Star is an overloaded operator so be aware of context
• a+= ONE or more occurrences of something.
• a+ is Kleene Star less the null string, .
Kleene ClosureKleene Closure
• Kleene Closure Is Not Identical to Kleene Star– “*” Symbol is the same (overloaded)
• Kleene Closure/Star Closure– Found in descriptions of formal language– Language consisting of all strings over some
alphabet
StringString
• An Ordered Concatenation of Symbols From an Alphabet
• Used in Place of “Word” to Decouple From Common Concept of Word in Informal Language
• If = { a, 1, 0, b, % } then a “1%0b” is a string.
RecognizerRecognizer
If x I*, i.e., a string of input symbols selected from the set of allowable input symbols,
and the application of x to the recognizer results in a final state F,
then the recognizer “accepts” the string.
StringsStrings
A String, x, Is Accepted by a Recognizer Left-most Letter First, i.e.,
if the input to a recognizer is a string w,
and if w = w’
then is the first letter of the string which causes a state
transition. Subsequent letters from left to right do the same.
State TransitionState Transition
Let There Be Two Configurations for a Machine
somefor
',',
relation, by the related are which',' and ,
1 ww
iff
wqwq
wqwqM
R,
1
q q’S
String ExampleString Example
Let
w = a b b a
then
w = a w’
and
w’ = b b a
Recognizer as Directed GraphRecognizer as Directed Graph
• Arbitrary State
• State Transition
• Start (initial) State
• Final State
1
q
q q’
-
+ or
or
Let I = { a, b }
• Accepts no strings since no final state
• Accepts all strings
• Dead State
Recognizer ExamplesRecognizer Examples
a, b
-
a, b
a, b
Recognizer ExamplesRecognizer Examples
• Accepts only , the null string
a,b
a,b
+/-
Recognizer ExampleRecognizer Example
This Recognizer Accepts the Language
L= { ab, a (aa) b, a (aa) (aa) b, ...
ab (bb), ab (bb) (bb), ... }
L = a (aa)* b ( b (aa)* b )*
- a
a
b
b
Rabin-Scott ExampleRabin-Scott Example
S
F
1 2 3 4
1
40
, , ,
, , ;I a
s
M rs S I F, , , , s0
ps\input a + ;1 2 3 32 3 1 43 3 3 34 3 3 3
4
Rabin-Scott ExampleRabin-Scott Example
L (M) = { x I* |* ( 1, x ) = 4 }
L (M) = { a; , a+a; , a+a+a; , ... }
aa
2
3 4
+
+ ;
;
a + ;
a + ;
1
Non-Deterministic FSMNon-Deterministic FSM
A Non-deterministic Finite Automata Is a Quintuple with S, I, s0, F
as in a recognizer, but, M nd S I F, , , , s0
,,,,,,
,,,,,,
functiona not relation,a is
,,* *
jhged
fedcba
sssxs
sxssxs
SISSIS
Non-Deterministic FSMNon-Deterministic FSM
• State May Change– to two different states in response to the same
input at the same state– in response to a string rather than just a single
element from the set of inputs– in response to a null string input
DFA-NDFA TheoremDFA-NDFA Theorem
• Every NDFA Can Be Replaced by an Equivalent DFA
• Equivalent Means Not Only Accepting All Strings Accepted by the NDFA, but Also NOT Accepting Any Others
NDFA ExampleNDFA Example
Non-deterministic Since
( ( 1, a ), 2 ) and ( ( 1, a ), 3 )
1
ab
2
3 4a
b
1
NDFA ExampleNDFA Example
Non-deterministic Since Not Completely Specified
ab
4
1
abb
L = ab abb,
NDFA ExampleNDFA Example
Non-deterministic Since State Changes in Response to a Null String.
ab
2
3 4a
1
bb
NDFA to DFANDFA to DFA
• Theorem– For each NDFA there is an equivalent DFA
• Constructive Proof• 4 Difficulties to Resolve
– Missing transitions– Single transitions due to | strings | > 1– Transitions due to strings– Multiple transitions
Problem: Missing TransitionsProblem: Missing Transitions
• I = { a, b }
• In DFA, all i I must be accounted for in each state
a
b ?
Solution: Missing TransitionsSolution: Missing Transitions
Add a “sink” state which is not a final state and terminate all missing transitions there.
a
b
a, b
a, b
Problem: | strings | > 1Problem: | strings | > 1
• Single transition due to string of size > 1
• Add intermediate states and “sink”, other characters in those states go to “sink” state
a
ab
a, b
b
a
Problem: StringsProblem: Strings
Can’t just combine states sincea
ab
a bb
a
b
Solution: Strings & Multiple Transitions
Solution: Strings & Multiple Transitions
• Eliminate by defining the set of next states which occur in response to no input, call this function E( )
• E( ) is called the “equivalents of ( )
NDFA ExampleNDFA Example
> 1
2
3
4
a b
b a
b
a
State EquivalentsState Equivalents
E( 1 ) = {self, explicit alternative} = { 1, 3 }
E( 2 ) = { 2 }
E( 3 ) = { 3 }
E( 4 ) = { 4 }
• Define a new machine based on the old using the E( ) states
New MachineNew Machine
E a
E b
E a
E b
E a
E b
E a
E b E E b
1 2 3 4
1 5
2 5
2 3
3 3 4
3 5
4 5
4 1 4 4 1 3 4
, , , ,
, , ,
, ,
, ,
, , ,
, ,
, ,
, , , , , , ,
state 5 is new dead state
New Machine Transition TableNew Machine Transition Table
Equivalent
OldState
NewState
Inputa
Inputb
E ( 1 ) { 1, 3 } A { 2,3,4 } = F 5 = EE ( 2 ) 2 B 5 = E 3 = CE ( 3 ) 3 C { 3, 4 } = G 5 = EE ( 4 ) 4 D 5 = E { E( 1 ), 4 }
{ 1, 3, 4 } = H
New Machine Transition TableNew Machine Transition Table
Equivalent
Old State
New State
Input a
Input b
E ( 5 ) 5 E 5 = E 5 = E 2, 3, 4 F { 5, 3, 4 } = I { 3, 5, E(1), 4}
{ 1, 3, 4, 5} = J 3, 4 G { 3, 4, 5 } = I { 5, E(1), 4}
{ 1, 3, 4, 5} = J
1, 3, 4 H 2, 3, 4, 5 = L { 5, E(1), 4} { 1, 3, 4, 5} = J
New Machine Transition TableNew Machine Transition Table
OldState
NewState
Inputa
Inputb
3, 4, 5 I { 3, 4, 5 } = I { 5, E(1), 4}{ 1, 3, 4, 5} = J
1, 3, 4, 5 J { 2, 3, 4, 5 }= L { 5, E(1), 4}{ 1, 3, 4, 5} = J
2, 3, 4, 5 L { 5, 3, 4 } = I { 3, 5, 4, E(1) }{ 1, 3, 4, 5} = J
DFA Equivalent of NDFADFA Equivalent of NDFA
Reduced DFA EquivalentReduced DFA Equivalent