Post on 22-Dec-2015
transcript
Fall 2004 COMP 335 2
{ }{ } *10=
...,101010,1010,10,λ=)(ML
0q 1q 2q0
11,0
Language accepted
(redundant state)
Fall 2004 COMP 335 3
Remarks:
•The symbol never appears on the input tape
0q2M
0q1M
{}=)M(L 1 }λ{=)M(L 2
•Simple automata:
Fall 2004 COMP 335 4
0q
2q
1qa
a
a
0q 1qa
}{=)( 1 aML
2M1M
}{=)( 2 aML
NFA DFA
•NFAs are interesting because we can express languages easier than DFAs
Fall 2004 COMP 335 5
Formal Definition of NFAs FqQM ,,,, 0
:Q
::0q
:F
Set of states, i.e. 210 ,, qqq
: Input aphabet, i.e. ba,
Transition function
Initial state
Final states
Fall 2004 COMP 335 13
Formally
wqq ij ,* : there is a walk from to with label
iq jqw
iq jq
w
kw 211 2 k
iq jq
Fall 2004 COMP 335 19
FormallyThe language accepted by NFA is:
where
and there is some
M
,...,, 321 wwwML
},,...,,{),(* 0 kjim qqqwq
Fqk (final state)
Fall 2004 COMP 335 22
Equivalence of FA
Definition:
An FA is equivalent to FA
if that is if both accept the same language.
1M 2M
21 MLML
Fall 2004 COMP 335 23
Example of equivalent FA
0q 1q
0
1
0q 1q 2q
0
11
0
1,0
NFA
DFA
*}10{1 ML
*}10{2 ML
1M
2M
Fall 2004 COMP 335 24
We will prove:
Languages acceptedby NFA
RegularLanguages
That is, NFA and DFA have the same computation power
Languages acceptedby DFA
Fall 2004 COMP 335 25
Languages acceptedby NFA
RegularLanguages
Step 1
Proof: Every DFA is trivially an NFA
Any language accepted by a DFAis also accepted by an NFA
L
Fall 2004 COMP 335 26
Languages acceptedby NFA
RegularLanguages
Step 2
Proof: Any NFA can be converted into anequivalent DFA
Any language accepted by an NFAis also accepted by a DFA
Fall 2004 COMP 335 34
NFA to DFA: Remarks
We are given an NFA
We want to convert it into an equivalent DFA
That is,
M
M
)(MLML
Fall 2004 COMP 335 35
If the NFA has states
Then the DFA has states in the powerset
,...,, 210 qqq
,....,,,, 2110 qqqq
Fall 2004 COMP 335 38
Procedure NFA to DFA
2. For every DFA’s state
Compute in the NFA
Add the following transition to the DFA
},...,,{ mji qqq
...
,,*
,,*
aq
aq
j
i
},...,,{ mji qqq
},...,,{},,...,,{ mjimji qqqaqqq
Fall 2004 COMP 335 40
Procedure NFA to DFA
Repeat step 2 for all symbols in the alphabet ∑, until no more transitions can be added.
Fall 2004 COMP 335 42
Procedure NFA to DFA
3. For any DFA state:
If some is a final state in the NFA
Then, is a final state in the DFA
},...,,{ mji qqq
jq
},...,,{ mji qqq
Fall 2004 COMP 335 44
Theorem Take NFA M
Apply the procedure to obtain DFA M
Then, and are equivalent:M M
MLML
Fall 2004 COMP 335 49
0q mq
naaav 211a 2a na:M
}{ 0q
1a 2a na:M },{ iq
iq jq lq
},{ jq },{ lq },{ mq
More generally, we will show that if in :M
(arbitrary string)
Fall 2004 COMP 335 51
Induction hypothesis: kv ||1
0q dq1a 2a ka:M iq jq cq
}{ 0q
1a 2a ka:M },{ iq },{ jq },{ cq },{ dq
kaaav 21
Fall 2004 COMP 335 52
Induction Step: 1|| kv
0q dq1a 2a ka:M iq jq cq
}{ 0q
1a 2a ka:M },{ iq },{ jq },{ cq },{ dq
1121
kk
v
k avaaaav
v
v
Fall 2004 COMP 335 53
Induction Step: 1|| kv
0q dq1a 2a ka:M iq jq cq
}{ 0q
1a 2a ka:M },{ iq },{ jq },{ cq },{ dq
1121
kk
v
k avaaaav
v
v
eq1ka
1ka
},{ eq