Post on 17-Dec-2014
description
Admission in India 2015Admission in India 2015By:
admission.edhole.com
Finite Automata andFinite Automata andNon DeterminismNon Determinism
http://cis.k.hosei.ac.jp/~yukita/
admission.edhole.com
Definition 1.1: Finite AutomatonDefinition 1.1: Finite Automaton
. theis 5.
and , theis 4.
, theis : 3.
, thecalledset finite a is 2.
, thecalledset finite a is 1.
where),,,,,( tupple-5 a is A
0
0
states accept of set
state start
function transition
alphabet
states
automatonfinite
QF
Q
FqQ
3admission.edhole.com
State Diagram for State Diagram for MM11
4
q3q1 q2
0 1
10
0, 1
admission.edhole.com
Data Representation for MData Representation for M11
.}{ 5.
and state,start theis 4.
,
10
as described is 3.
{0,1} 2.
},,{ 1.
2
1
223
232
211
321
qF
q
qqq
qqq
qqq
qqqQ
5admission.edhole.com
Task 01Task 01DFADFA
1. Implement M1 with your favorite programming language.
2. GUI• Two buttons for input 0 and 1• State chart with the current state
highlighted
6admission.edhole.com
Language of MLanguage of M11
}1last thefollow 0s ofnumber even an
and 1 oneleast at contains |{)(
. say that can We
accepts. machine that strings all ofset theis
),( as written , The
1 wwML
AM
M
MLM
recognizes
machine oflanguage
7admission.edhole.com
State Diagram for MState Diagram for M55
8
q2
q1
q0
0
1
12
2, <RESET>
1, <RESET>
2
0, <RESET> 0
admission.edhole.com
Data Representation for MData Representation for M55
.}{ 5.
and state,start theis 4.
,
210
as described is 3.
,0,1,2}RESET{ 2.
},,{ 1.
0
0
10202
02101
21000
210
qF
q
qqqqq
qqqqq
qqqqq
R
qqqQ
9admission.edhole.com
Informal Description of Informal Description of MM55
M5 keeps a running count of the sum of the numerical symbols it reads, modulo 3.
Every time it receives the <RESET> symbol it resets the count to 0.
M5 accepts if the sum is 0, modulo 3.
10admission.edhole.com
Definition 1.7: Regular Definition 1.7: Regular LanguageLanguage
A language is called a regular language if some finite automaton recognizes it.
11admission.edhole.com
Example 1.9: A finite automaton Example 1.9: A finite automaton EE22
E2 recognizes the regular language of all strings that contain the string 001 as a substring.
0010, 1001, 001, and 1111110011110 are all accepted,
but 11 and 0000 are not.
12admission.edhole.com
Find a set of states of Find a set of states of EE22
You1. haven’t just seen any symbols of the
pattern,2. have just seen a 0,3. have just seen 00 or,4. have just seen the entire pattern 001.Assign the states q,q0,q00, and q001 to these
possibilities.
13admission.edhole.com
Draw a State Diagram for Draw a State Diagram for EE22
14
q00 q001
0 0, 1
1
1
0q0
0
q
1
admission.edhole.com
Regular Operations on Regular Operations on LanguagesLanguages
operation. a onelast theand
,operations are operations first two The
}.each and 0|{ :
}. and |{ :
}.or |{ :
languages. be and Let
21*
unary
binary
AxkxxxA
ByAxxyBA
BxAxxBA
BA
ik
Star
ionConcatenat
Union
15admission.edhole.com
Example 1.11Example 1.11
}. ,goodbadbad
d,goodbadgoo goodbad, good od,goodgoodgo
badbad, goodbad, goodgood, bad, good, ,{
and },badgirl badboy, goodgirl, goodboy,{
},girl boy, bad, good,{
have weThen, }.girl boy,{ and }bad good,{Let
}.z,,ba,{ be alphabet Let the
*
A
BA
BA
BA
16admission.edhole.com
Theorem 1.12 Closedness for Theorem 1.12 Closedness for UnionUnion
. is so
languages,regular are and if s,other wordIn
operation.union the
under closed is languagesregular of class The
21
21
AA
AA
17admission.edhole.com
Proof of Theorem 1.12Proof of Theorem 1.12
on.constructi theof scorrectnes check the Then,
.),,,,( where
, recognize toConstruct
.),,,,( where, recognize and
),,,,,( where, recognize Let
21
2222222
1111111
FqQM
AAM
FqQMAM
FqQMAM
Proof of Th 1.12 18admission.edhole.com
Construction of Construction of MM
}.or |),{()()( 5.
).,( 4.
)),(),,(()),,((;,),( 3.
(Why?) .alphabet
same thehave and that assumecan We2.
}. and |),{( 1.
2211212121
210
22112121
21
22112121
FrFrrrFQQFF
qqq
arararraQrr
MM
QrQrrrQQQ
Proof of Th 1.12 19admission.edhole.com
CorrectnessCorrectness
You should check the following.1. For any string recognized by M1 is
recognized by M.2. For any string recognized by M2 is
recognized by M.3. For any string recognized by M is
recognized by M1 or M2.
Proof of Th 1.12 20admission.edhole.com
Theorem 1.13 Closedness for Theorem 1.13 Closedness for concatenationconcatenation
. is so
languages,regular are and if s,other wordIn operation.
ionconcatenatunder closed is languagesregular of class The
21
21
AA
AA
21admission.edhole.com
NondeterminismNondeterminism
To prove Theorem 1.13, we need nondeterminism.
Nondeterminism is a generalization of determinism. So, every deterministic automaton is automatically a nondeterministic automaton.
22admission.edhole.com
Nondetermistic Finite AutomataNondetermistic Finite Automata
A nondeterministic finite automaton can be different from a deterministic one in that◦for any input symbol, nondeterministic one can
transit to more than one states.◦epsilon transition
NFA and DFA stand for nondeterministic finite automaton and deterministic finite automaton, respectively.
23admission.edhole.com
NFA NFA NN11
24
q3q1 q2
0,1
1 0, q4
0,1
1
admission.edhole.com
Parallel world and NFAParallel world and NFA25
... ...accept
admission.edhole.com
Example 1.14 NFA Example 1.14 NFA NN22
26
q3q1 q2
0,1
1 0, q4
0,1
Let language A consist of all strings over {0,1} containing a 1 in the third position from the end. N2 recognizes A.
admission.edhole.com
A DFA equivalent to A DFA equivalent to NN22
27
q010q000 q100
0
0 0 q110
q011q001 q101
q111
1
0
1
00
10
11
01
1admission.edhole.com
Example 1.15 NFA Example 1.15 NFA NN33
28
0
Let language A consist of all strings 0k , where k is a multiple of 2 or 3. N3 recognizes A.
0
0
0
0
admission.edhole.com
A DFA equivalent to A DFA equivalent to NN33
29
0q 2q 1 q3
q50
q0
0 0 0 q4
0
q-1
11
1 1 1
1
0, 1
admission.edhole.com
Example 1.16 NFA Example 1.16 NFA NN44
30
q1
q2q3
a
b
a,b
a
N4 accepts , a, baba, and baa. N4 does not accept b, nor babba.
admission.edhole.com
Definition 1.17: NFADefinition 1.17: NFA
. theis 5.
and , theis 4.
, theis 2: 3.
, thecalledset finite a is 2.
, thecalledset finite a is 1.
where),,,,,( tupple-5 a is A
0
0
states accept of set
state start
function transition
alphabet
states
automatonfinite nistic nondetermi
QF
Q
Q
FqQ
Q
31admission.edhole.com
Example 1.18 NFA Example 1.18 NFA NN11}.{ 5.
state.start theis 4.
}{}{
}{
}{}{
},{}{
10
asgiven is 3.
}1,0{ 2.
},,,,{ 1.
4
1
444
43
332
2111
4321
qF
q
qqq
qqq
qqqq
qqqqQ
32
q3q1 q2
0,1
1 0,q4
0,1
1
admission.edhole.com
In what situation is Non In what situation is Non Determinism relevant?Determinism relevant?
Von Neumann machines are deterministic.However, there are many cases where
machine specification is all we need.
33admission.edhole.com
Theorem 1.19Theorem 1.19
Every nondeterministic finite automaton has an equivalent deterministic finite automaton.◦Def. The two machines are equivalent is they
recognize the same language.
34admission.edhole.com
Proof of Th. 1.19Proof of Th. 1.19
}.|{ 4.
and },{ 3.
,),(),( 2.
,2 1.
such that ),,,,(Construct
arrows. no has first that assume usLet
. language some grecognizinNFA thebe ),,,,(Let
00
0
0
FRQRF
araR
Q
FqQM
N
AFqQN
Rr
Q
Proof of Th 1.19 35admission.edhole.com
Incorporate Incorporate arrows arrows
0
0 0
( ) { | can be reached from by traveling along zero or
more arrows.}
We modify as follows.
( , ) { | ( ( , )) for some }.
We modify as follows.
({ }).
We omit the correctness p
E R q q R
R a q Q q E r a r R
q
q E q
roof.
Proof of Th 1.19 36admission.edhole.com
Corollary 1.20Corollary 1.20
A language is regular if and only if some nondeterministic finite automaton recognizes it.
37admission.edhole.com
Example 1.21 NFA Example 1.21 NFA NN44 to DFA to DFA
}}.3,2,1{},3,2{},3,1{},2,1{},3{},2{},1{,{2
as takesbemay set state s' The .DFA equivalentan
construct want to we,}}3{,1,},,{},3,2,1{{Given
}3,2,1{
4
DD
baN
38
1
2 3a
b
a,b
a
admission.edhole.com
Task 02Task 02Parallel WorldParallel World
1. Write a program that simulates N4. 2. GUI
◦ Three buttons for input 0, 1, and epsion.◦ State chart that reflect the branching of the
world.
39admission.edhole.com
Start and Accept statesStart and Accept states
follows. asgiven is diagram state The
}}.3,2,1{},3,2{},3,1{},3{{ is statesaccept ofset The
}.3,1{})1({ is statestart The E
40admission.edhole.com
The state diagram of The state diagram of DD41
{1} {2} {1,2}
{3} {1,3} {2,3} {1,2,3}
a,b
a,b
a
aa
a
a
a
b
b bb
b
b
admission.edhole.com
Theorem 1.22Theorem 1.22 The class of regular The class of regular languages is closed under the union languages is closed under the union operation.operation.
42
N1
N2
N
admission.edhole.com
Proof of Th. 1.22Proof of Th. 1.22
. and for
and for },{
for ),(
for ),(
),( 4.
3.
of statestart theis state The 2.
}{ 1.
. recognize to),,,,{ Construct
. recognize ),,,,(
and , recognize ),,,,(Let
0
021
22
11
21
0
210
210
222222
111111
aqq
aqqqq
Qqaq
Qqaq
aq
FFF
N.q
QQqQ
AAFqQN
AFqQN
AFqQN
43admission.edhole.com
Theorem 1.23Theorem 1.23 The class of regular The class of regular languages is closed under the languages is closed under the concatenation operation.concatenation operation.
44
N1N2
N
admission.edhole.com
Proof of Th. 1.23Proof of Th. 1.23
.for ),(
and for }{),(
and for ),(
and for ),(
),( 4.
of that as same theis statesaccept ofset The 3.
. of that as same theis statestart The 2.
1.
. recognize to),,,,{ Construct
. recognize ),,,,(
and , recognize ),,,,(Let
22
121
11
111
2
11
21
2121
222222
111111
Qqaq
aFqqaq
aFqaq
FqQqaq
aq
N
Nq
QQQ
AAFqQN
AFqQN
AFqQN
45admission.edhole.com
Theorem 1.24Theorem 1.24 The class of regular The class of regular languages is closed under the star languages is closed under the star operation.operation.
46
N1
N
admission.edhole.com
Proof of Th. 1.24Proof of Th. 1.24
. and for
and for }{
and for }{),(
and for ),(
and for ),(
),( 4.
}{ 3.
state.start new theis statestart The 2.
}{ 1.
. recognize to),,,,{ Construct
. recognize ),,,,(Let
0
01
111
11
111
10
0
10
*10
111111
aqq
aqqq
aFqqaq
aFqaq
FqQqaq
aq
FqF
q
QqQ
AFqQN
AFqQN
47admission.edhole.com