You are on page 1of 68

Asimplemodelof

computation
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 2
Deterministicfiniteautomata(DFA)
HowaDFAworks
HowtoconstructaDFA
Non-deterministicfiniteautomata(NFA)
HowanNFAworks
HowtoconstructanNFA
EquivalenceofDFAandNFA
Closurepropertiesoftheclassoflanguages
acceptedbyFA
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 3
FiniteAutomata(FA)
CONTROL
UNIT
INPUT TAPE
TAPE
HEAD
Finite set of states
Move to the right one cell
at a time
Store input of the DFA
Can be of any length
Start state
Final state(s)
is in exactly one
state at a time
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 4
WhatdoesanFAdo?
Readaninputstringfromtape
Determineiftheinputstringisinalanguage
Determineiftheanswerfortheproblemis
YESorNOforthegiveninputonthetape
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 5
HowdoesanFAwork?
Atthebeginning,
anFAisinthestartstate(initialstate)
itstapeheadpointsatthefirstcell
Foreachmove,FA
readsthesymbolunderitstapehead
changesitsstate(accordingtothetransitionfunction)to
thenextstatedeterminedbythesymbolreadfromthe
tapeanditscurrentstate
moveitstapeheadtotherightonecell
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 6
WhendoesanFAstopworking?
Whenitreadsallsymbolsonthetape
Then,itgivesanansweriftheinputisinthe
specificlanguage:
AnswerYESifitslaststateisafinalstate
AnswerNOifitslaststateisnotafinalstate
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 7
ExampleofaDFA
q a o(q,a)
s 0 s
s 1 f
f 0 f
f 1 s
s
f
0 1
0
1
Transition diagram
Transition function
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 8
a5-tuple(Q,E,o,s,F),where
asetofstatesQisafiniteset
analphabetEisafinite,non-emptyset
astartstatesinQ
asetoffinalstatesFcontainedinQ
atransitionfunctionoisafunctionQEQ
Seeformaldefinition
Thats why its called
a finite automaton.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 9
HowanFAworks
s
f
0 1
0
1
Input: 001101
Input: 01001
0 0 1 1 0 1
0 1 0 0 1
ACCEPT
REJECT
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 10
Definition
LetM =(Q,E,o,s,F)beadeterministicfiniteautomaton.
AconfigurationofMisanelementofQE
-
configurations of M
(s, c), (s, 00),
(s, 01101), (f, c),
(f, 0011011001),
(f, 1111), (f, 011110)
s
f
0 1
0
1
Transition diagram of M
Unread input string
Current state
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 11
Definition
LetM=(Q,E,o,s,F)beadeterministicfiniteautomaton,
and(q
0
,e
0
)and(q
1
,e
1
)betwoconfigurationsofM.
Wesay(q
0
,e
0
)yields(q
1
,e
1
)inonestep,denotedby(q
0
,e
0
)
(
M
(q
1
,e
1
),ifo(q
0
, a)=q
1
,ande
0
=a e
1
,forsomea eE.
Whenaconfigurationyieldsanotherconfiguration,thefirst
symbolofthestringisreadanddiscardedfromthe
configuration.
Onceasymbolinaninputstringisread,itdoesnoteffect
howtheDFAworksinthefuture.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 12
Example:yieldingnextconfiguration
(s, 001101)
(
M

(s, 01101)
(
M

(s, 1101)
(
M

(f, 101)
(
M

(s, 01)
(
M

(s, 1)
(
M

(f, c)
s
f
0 1
0
1
0 0 1 1 0 1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 13
Yieldinzerostepormore
Definition
LetM=(Q,E,o,s,F)beaDFA,and(q
0
,e
0
)and
(q
1
,e
1
)betwoconfigurationsofM.(q
0
,e
0
)yields
(q
1
,e
1
)inzerostepormore,denotedby(q
0
,e
0
)
( *
M
(q
1
,e
1
),if
q
0
= q
1
ande
0
=e
1
,or
(q
0
,e
0
)(
M
(q
2
,e
2
)and(q
2
,e
2
)(*
M
(q
1
,e
1
)for
someq
2
ande
2
.
This definition is an inductive definition, and it is often
used to prove properties of DFAs.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 14
Example:Yieldinzerostepormore
(s, 001101)
(*
M

(f, 101)
(*
M

(s, 01)
(*
M

(f, c)
(*
M

(f, c)
s
f
0 1
0
1
(s, 01001)
(*
M

(f, 001)
(*
M

(f, 001)
(*
M

(f, 1)
(*
M

(s, c)
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 15
Definition
LetM=(Q,E,o,s,F)beaDFA,andeeE*.
WesayMacceptseif(s, e)(*
M
(f, c),whenf
eF.Otherwise,wesayMrejectse.

(s, 001101)(*
M

(f, c) Maccepts001101
(s, 01001) (*
M

(s, c) Mrejects01001
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 16
LetM=(Q,E,o,s,F )beaDFA.Thelanguageacceptedby
M,denotedbyL(M )isthesetofstringsacceptedbyM.
Thatis,L(M)={eeE*|(s, e)(*
M
(f,c)forsomefeF }
Example:
L(M) = {x e {0,1}* |thenumberof1sinxisodd}.
s
f
0 1
0
1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 17
s
0
1
1
1
1
1
1
1
0
0
0
0
0
0, 1
0
0, 1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 18
DeterminewhataDFAneedtomemorizeinorderto
recognizestringsinthelanguage.
Hint:thepropertyofthestringsinthelanguage
Determinehowmanystatesarerequiredtomemorize
whatwewant.
finalstate(s)memorizesthepropertyofthestringsinthe
language.
Findouthowthethingwememorizeischangedonce
thenextinputsymbolisread.
Fromthischange,wegetthetransitionfunction.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 19
Consider L= {ee{0,1}*| e has both 00 and 11 as
substrings}.
Step 1: decide what a DFA need to memorize
Step 2: how many states do we need?
Step 3: construct the transition diagram
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 20
s
0
1
1
1
1
1
1
1
0
0
0
0
0
0, 1
0
0, 1
Got
nothing
Got 0 as
substring
Got 00 as
substring
Got 11
and got 0
Got 00 and 11
as substrings
Got 1 as
substring
Got 11 as
substring
Got 00
and got 1
Got 11 and 00
as substrings
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 21
Consider L= {ee{0,1}*| e represents a binary number divisible by
3}.
L = {0, 00, 11, 000, 011, 110, 0000, 0011, 0110, 1001, 00000, ...}.
Step 1: decide what a DFA need to memorize
remembering that the portion of the string that has been read so far is
divisible by 3
Step 2: how many states do we need?
2 states remembering that
the string that has been read is divisible by 3
the string that has been read is indivisible by 3.
3 states remembering that
the string that has been read is divisible by 3
the string that has been read - 1 is divisible by 3.
the string that has been read - 2 is divisible by 3.
Choose this!!
Why?
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 22
Reading a string w representing a number divisible
by 3.
Next symbol is 0. w 0, which is 2*w, is also divisible by
3.
If w=9 is divisible by 3, so is 2*w=18.
Next symbol is 1. w 1, which is 2*w +1, may or may
not be divisible by 3.
If 8 is indivisible by 3, so is 17.
If 4 is indivisible by 3, but 9 is divisible.
Using these two states is not sufficient.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 23
Eachstaterememberstheremainderofthe
numberdividedby3.
Iftheportionofthestringthathasbeenreadso
far,sayw,representsthenumberwhose
remainderis0(or,1,or2),
Ifthenextsymbolis0,whatistheremainderofw0?
Ifthenextsymbolis1,whatistheremainderofw1?
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 24
Current
number
Current
remainder
Next
symbol
New
number
New
remainder
3n 0 0 6n 0
3n 0 1 6n+1 1
3n+1 1 0 6n+2 2
3n+1 1 1 6n+3 0
3n+2 2 0 6n+4 1
3n+2 2 1 6n+5 2
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 25
Current
number
Current
remainder
Next
symbol
New
number
New
remainder
3n 0 0 6n 0
3n 0 1 6n+1 1
3n+1 1 0 6n+2 2
3n+1 1 1 6n+3 0
3n+2 2 0 6n+4 1
3n+2 2 1 6n+5 2
Current
state
Next
state
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 26
Current
state
Next
symbol
Next
state
q
0
0 q
0
q
0
1 q
1
q
1
0 q
2
q
1
1 q
0
q
2
0 q
1
q
2
1 q
2
M = ({q
0
, q
1
, q
2
}, {0, 1},
o, q
0
, {q
0
})
q
0
q
1
q
2
0
1
0
0
1
1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 27
SimilartoDFA
Nondeterministicmove
Onreadinganinputsymbol,theautomatoncanchooseto
makeatransitiontooneofselectedstates.

Withoutreadinganysymbol,theautomatoncanchooseto
makeatransitiontooneofselectedstatesornot.
0
0
c
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 28
a5-tuple(Q, E, o, s, F),where
asetofstatesQisafiniteset
analphabetEisafinite,non-emptyset
astartstatesinQ
asetoffinalstatesFcontainedinQ
atransitionfunctionoisafunctionQ(E{c})2
Q
Seeformaldefinition
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 29
AnNFAaccepting{we{0,1}
-
|wendswith11}
0,1
1 1
0
0 0
1
1
1
0
1
1
0
1 0
1
0
DFA
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 30
Definition
LetM=(Q,E,o,s,F)beanon-deterministic
finiteautomaton,and(q
0
,e
0
)and(q
1
,e
1
)betwo
configurationsofM.
Wesay(q
0
,e
0
)yields(q
1
,e
1
)inonestep,
denotedby(q
0
,e
0
)(
M
(q
1
,e
1
),ifq
1
e o (q
0
, a,),
ande
0
=a e
1
,forsomea e E {c}.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 31
Definition
LetM=(Q,E,o,s,F)beanNFA,and(q
0
,e
0
)
and(q
1
,e
1
)betwoconfigurationsofM.(q
0
,
e
0
)yields(q
1
,e
1
)inzerostepormore,
denotedby(q
0
,e
0
)(*
M
(q
1
,e
1
),if
q
0
= q
1
ande
0
=e
1
,or
(q
0
,e
0
)(
M
(q
2
,e
2
)and(q
2
,e
2
)(*
M
(q
1
,
e
1
)forsomeq
2
ande
2
.
Same as that for DFA
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 32
Definition
LetM=(Q,E,o,s,F)beanNFA,andee
E*.WesayMacceptseif(s, e)(*
M
(f, c),
whenfeF.Otherwise,wesayMrejectse.
Same as the
definition for
a DFA
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 33
LetM=(Q,E,o,s,F)beanNFA.
ThelanguageacceptedbyM,denotedby
L(M)isthesetofstringsacceptedbyM.That
is,L(M)={eeE*|(s,e)(*
M
(f,c)forsome
feF}
Same as the
definition for
a DFA
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 34
(s,01111)(- (s,1111) (- (s,111)
(- (s,11) (- (s,1) (- (s,c)
(s,01111)(-(s,1111) (- (s, 111)
(- (s,11) (- (s,1) (- (q,c)
(s,01111)(-(s, 1111) (- (s, 111)
(- (s,11) (- (q,1) (- (f, c)
(s,01111)(-(s, 1111) (- (s, 111)
(- (q,11) (- (f,1)
(s,01111)(-(s, 1111) (- (q, 111)
(- (f,11)
0,1
1 1
s, 01111
s q f
s, 1111
s, 111 q, 111
s, 11
f, c
q, 1
q, 11
s, c
s, 1
q, c
f, 1
f, 11
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 35
{w e {0,1}* | whaseither00
or11assubstring}

{w e {0,1}* | whas00and
11assubstringsand00
comesbefore11}
0,1
0
0,1
0,1
1 1
0
c
c
0
1 1
0
c
0,1
0,1
0,1
0,1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 36
M
d
andM
n
areequivalentL(M
d
) = L(M
n
).

DFAandNFAareequivalent
ForanyDFAM
d
,thereexistsanNFAM
n
suchthat
M
d
andM
n
areequivalent.(part1)
ForanyNFAM
n
,thereexistsaDFAM
d
suchthatM
d

andM
n
areequivalent.(part2)

Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 37


ForanyDFAM
d
,thereexistsanNFAM
n
suchthat
M
d
andM
n
areequivalent.
Proof:LetM
d
beanyDFA.Wewanttoconstructan
NFAM
n
suchthatL(M
n
) = L(M
d
).
FromthedefinitionsofDFAandNFA,ifMisaDFA
thenitisalsoanNFA.
Then,weletM
n
= M
d
.
Thus,L(M
d
) = L(M
n
).
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 38
ForanyNFAM
n
,thereexistsaDFAM
d
suchthat
M
d
andM
n
areequivalent.
Proof:LetM
n
= (Q, E, o, s, F)beanyNFA.Wewantto
constructaDFAM
d
suchthatL(M
d
) = L(M
n
).
Firstdefinetheclosureofq,denotedbyE(q).
Second,constructaDFAM
d
=(2
Q
, E, o', E(s), F')
Finally,prove eeE
-
- f e F (s,e) |-
*
Mn
(f, c)
- f 'eF ' (E(s), e) |-
*
Md
(f ' , c).
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 39
Eliminatingtransitionstomultiplestates
s q f
0,1
1 1
s s,q
1
s,q,f
1
0
0
1
0
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 40
Eliminatingempty-stringtransitions
s p q
r f
0
0
0

,1
1
1 1


s p,q, r
r p,q,r,f
0
0,1
1
1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 41
LetM = (Q, E, o, s, F)beanNFA,andqeQ.
Theclosureofq,denotedbyE(q),is
thesetofstateswhichcanbereachedfromq
withoutreadinganysymbol.
{peQ| (q, c) |-
M
*
(p, c)}
IfanNFAisinastateq,itcanalsobeinany
stateintheclosureofqwithoutreadingany
inputsymbol.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 42
s q f
a b c
c c
M=({s, q, f}, {a, b, c}, o, s, {f})
where o is defined below.
L(M)={a
i
b
j
c
k
| i, j, k > 0}
state closure
s q f s, q, f
q f q, f
f f
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 43
q
0
q
1
q
2
q
3
q
4
1 q
1
q
2
, q
3
q
3

2 q
2
, q
3
3
q (q,a,r) (q,b,r) (q,c,r)
q
0
q
2
q
1
q
1
q
0
,q
4
q
2
,

q
3
q
2
q
4
q
3
q
4
q
4
q
3
q
0
q
1
q
2
q
3
q
4
b
c
c
c
a
b
c
a
a
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 44
LetM
n
= (Q, E, o, s, F)beanyNFA.Weconstructa
DFAM
d
=(2
Q
, E, o', E(s), F'),where:
o'(q',a) =

{reE(p)| p e o(q,a) }and
F' = {f _ Q | f F = C})
qeq'
q
p r
a
a



DFA
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 45
E(q
0
)

E(q
1
) E(q
2
) E(q
3
) E(q
4
)
q
0
, q
1
,
q
2
, q
3

q
1
, q
2
,
q
3

q
2
q
3
q
3
,q
4
q
0
q
1
q
2
q
3
q
4
b
c
c
c
a
b
c
a
a
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 46
q
0
,q
1
,q
2
,q
3
q
0
,q
1
,q
2
,q
3
,q
4
q
2
,q
3
,q
4
q
3
,q
4

C
a
b
b
a
a
b
b
a
a,b
E(q
0
)

E(q
1
) E(q
2
)E(q
3
) E(q
4
)
q
0
, q
1
,
q
2
, q
3

q
1
,
q
2
, q
3

q
2
q
3
q
3
,q
4
o (q,a,r) (q,b,r) (q,c,r)
q
0
q
2
q
1
q
1
q
0
q
4
q
2
q
3
q
2
q
4
q
3
q
4
q
4
q
3
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 47
LetM
n
= (Q, E, o, s, F)beanyNFA,andM
d
= (2
Q
, E, o',
E(s), F')beaDFA,where
o'(q', a) = {reE(p)| peo(q,a)}and
F' = {f _ Q | f F = C}
Prove eeE
-
, - feF (s,e) |-
*
Mn
(f, c) - f 'eF ' (E(s), e)
|-
*
Md
(f', c)andfef'byinduction.
Proveamoregeneralstatement eeE
-
, p, qeQ
(p,e) |-
*
Mn
(q, c) (E(p), e) |-
*
Md
(q', c) and qeq'.
qeq'
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 48
PartI:
Foranystringein*,andstatesqandrinQ,
thereexistsR _ Qsuchthat
(q, e) ,*
Mn
(r, ) (E(q), e) ,*
Md
(R, )and
reR.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 49
Basis:
Letebeastringin*,qandrbestatesinQ,and(q, e)
,*
Mn
(r, )in0step.
Because(q, e) ,*
Mn
(r, )in0step,weknow(1)q=r,
and(2)e=.
Then,(E(q), e) = (E(r), ).
Thus,(E(q), e) ,*
Md
(E(r), ).
Thatis,thereexistsR=E(r)suchthatr e Rand(E(q),e)
,*
Md
(R, ).
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 50
Inductionhypothesis:
Foranynon-negativeintegerk,stringein*,and
statesq andrinQ,thereexistsR _ Q:
(q, e) ,*
Mn
(r, )inksteps->(E(q), e) ,*
Md
(R, )and
reR.
Inductionstep:
Prove,foranynon-negativeintegerk,stringein*,
andstatesqandrinQ,thereexistsR _ Q:
(q, e) ,*
Mn
(r, )ink+1steps->(E(q), e) ,*
Md
(R, )
andreR.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 51
Letebeastringin*,qandrbestatesinQ,
and(q, e) ,*
Mn
(r, )ink+1steps.

Because(q, e) ,*
Mn
(r, )ink+1stepsandk>0,
thereexistsastatepinQandastringoe*
suchthat(q, e) ,*
Mn
(p, a)inkstepsand(p, a)
,
Mn
(r, )forsomea e{}.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 52
Fromtheinductionhypothesisand(q, e) ,*
Mn
(p, a)in
ksteps,weknowthatthereexistsP_Qsuchthat
(E(q), e) ,*
Md
(P, a) and peP.
Since(p, a) ,
Mn
(r, ), reo(p, a).
Fromthedefinitionofo'ofM
d
, E(o(p, a)) _ o'(P, a)
becausepeP.
Becausereo(p, a)andE(o(p, a)) _ o'(P, a), reo'(P, a).
Then,forR=o'(P, a),(P, a) ,*
Md
(R, ) and reR.
Thus,(E(q), e) ,*
Md
(P, a) ,*
Md
(R, ) and reR.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 53
Part II:
For any string e in *, and states q and r in Q, there exists R _ Q
such that reR and
(E(q), e) ,*
Md
(R, ) -> (q, e) ,*
Mn
(r, ).
E(q)
R
q
r
reR
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 54
Basis:
Letebeastringin*,qandrbestatesinQ, Rbea
subsetofQsuchthatr e Rand(E(q), e) ,*
Md
(R, )
in0step.
Because(E(q),e) ,*
Md
(R, )in0step,E(q)=Rande=.
FromthedefinitionofE, o'(q, )=RbecauseE(q)=R.
Then,foranyreR, (q, e) ,*
Mn
(r, ).
Thatis,thereexistsR=E(q)suchthatr e Rand(q, e)
,*
Mn
(r, ).
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 55
Inductionhypothesis:
Foranynon-negativeintegerk,stringein*,andstatesq
andrinQ,thereexistsR _ QsuchthatreRand:
(E(q), e) ,*
Md
(R, )ink steps->(q, e) ,*
Mn
(r, ).
Inductionstep:
Prove,foranynon-negativeintegerk,stringein*,and
statesqandrinQ,thereexistsR _ QsuchthatreR:
(E(q),e),*
Md
(R, )ink+1steps->(q, e) ,*
Mn
(r, ).
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 56
Letebeastringin*,qandrbestatesinQ,and(E(q), e) ,*
Md

(R, )ink+1steps.
Because(E(q), e) ,*
Md
(R, )ink+1stepsandk>0,thereexists
Pe2
Q
(i.e.P_Q)andastringoe*suchthate=oa,(E(q), o)
,*
Md
(P,)inkstepsand(P, a) ,
Md
(R, )forsomeae.
E(q)
R
q
r
reR
P
k+1 steps
a
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 57
Fromtheinductionhypothesisand(E(q), o) ,*
Md
(P, )ink
steps,weknowthatthereexistspePsuchthat(q, o),
*
Mn
(p,)
(i.e. (q, oa) ,*
Mn
(p, a) ).
Since(P, a) ,
Md
(R, ),thereexistsreRsuchthatr= o(p, a).
Then,forsomereR,(p, a) ,*
Mn
(r, ).
Thus,(q, e) ,*
Mn
(p, a) ,*
Mn
(r, )forsomereR.
E(q)
R
q
r reR
P
p
peP
k+1 steps
a
a
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 58
ClosureProperties
TheclassoflanguagesacceptedbyFAsis
closedundertheoperations
Union
Concatenation
Complementation
Kleenesstar
Intersection

Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 59


Theclassoflanguagesaccepted
byFAisclosedunderunion.
Proof:
LetM
A
= (Q
A
, , o
A
, s
A
, F
A
)and
M
B
= (Q
B
, , o
B
, s
B
, F
B
)beanyFA.
WeconstructanNFAM =
(Q, , o, s, F)suchthat
Q = Q
A


Q
B
{s}
o = o
A


o
A
{(s, , {s
A
, s
B
})}
F = F
A
F
B

s
A

s
B

WeprovethatL(M) = L(M
A
)L(M
B
).
s


Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 60
ToproveL(M) = L(M
A
) L(M
B
),weprove:
I. Foranystringee*eeL(M
A
) or eeL(M
B
) eeL(M)&
II. Foranystringee*eeL(M
A
) and eeL(M
B
). eeL(M)
ForI,consider(a)eeL(M
A
)or(b)eeL(M
B
).
For(a),leteeL(M
A
).
FromthedefinitionofstringsacceptedbyanFA,thereisa
statef
A
inF
A
suchthat(s
A
,e)|-*
MA
(f
A
,).
Becauseo
A
co,(s
A
, e) |-*
M
(f
A
, ) also.
Becauses
A
eo(s,), (s, e) |-
M
(s
A
, e).
Thus,(s, e) |-
M
(s
A
, e) |-*
M
(f
A
, ).
Becausef
A
e F, eeL(M).
Similarlyfor(b).
s
s
A

s
B



Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 61
For(II),leteeL(M
A
)L(M
B
).
Because(s, , {s
A
, s
B
})eo,either(s,e) |-
M
(s
A
,e)or(s, e) |-
M
(s
B
, e)only.
BecauseeeL(M
A
),thereexistsnof
A
inF
A
suchthat(s
A
,e) |-*
MA
(f
A
,).
BecauseeeL(M
B
),thereexistsnof
B
inF
B
suchthat(s
B
, e) |-*
MB
(f
B
, ).
SincethereisnotransitionbetweenstatesinQ
A
andQ
B
inM,there
existsnostatefinF=F
A
F
B
suchthat(s, e) |-
M
(s
A
, e) |-*
M
(f
A
, )
or(s, e) |-
M
(s
B
, e) |-*
M
(f
B
, ).
Thatis,eeL(M).
Thus,L(M) = L(M
A
)L(M
B
).
s
s
A

s
B



Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 62



s
A

M
A
s
B

M
B
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 63
s
A

M
A
DFA only
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 64

s
A
f
A
s

f

c c
c
c
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 65
TheclassoflanguagesacceptedbyFAisclosedunderintersection.
Proof:LetL
1
andL
2
belanguagesacceptedbyFA.
L
1
L
2
=(L
1
L
2
)
Bytheclosurepropertyundercomplementation,thereareFA
acceptingL
1
andL
2
.
Bytheclosurepropertyunderunion,thereisanFAacceptingL
1

L
2
.
Bytheclosurepropertyundercomplementation,thereisanFA
accepting(L
1
L
2
).
Thus,theclassoflanguagesacceptedbyFAisclosedunder
intersection.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 66
DFAacceptingtheintersectionoftwo
languages
LetM
A
= (Q
A
, , o
A
, s
A
, F
A
)and
M
B
= (Q
B
, , o
B
, s
B
, F
B
)beanyFA.
WeconstructanNFAM = (Q, , o, s, F)such
that
Q = Q
A
Q
B

o = o
A


o
A
(i.e.o((q
A
,q
B
),a) = o
A
(q
A
,a)o
B
(q
B
,a))
s = (s
A
, s
B
)
F = F
A
F
B

Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 67
q
0
q
1
q
2
0
1
0
0
1
1
0,1
1 1
p
0
p
1
p
2
p
0
,q
1
p
0
,q
0
p
0
,q
2
0
1
0
0
1
1
p
1
,q
1
1
p
1
,q
0
1
p
1
,q
2
1
p
2
,q
0
1
p
2
,q
1
1
p
2
,q
2
1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 68
Basic
ExplainhowDFA/NFAwork
(configuration,yieldnext
configuration)
Findthelanguageacceptedby
DFA/NFA
ConstructDFA/NFAacceptinga
givenlanguage
Findclosureofastate
ConvertanNFAintoaDFA
ProvealanguageacceptedbyFA
ConstructFAfromotherFAs
Advanced
ProveDFA/NFAacceptinga
language
ProvepropertiesofDFA/NFA
Configurationchange
Undersomemodification
etc.
Provesomepropertiesof
languagesacceptedby
DFA/NFA
Undersomemodification
Surprise!

You might also like