1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos...
-
date post
19-Dec-2015 -
Category
Documents
-
view
250 -
download
11
Transcript of 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos...
![Page 1: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/1.jpg)
1
Introduction to Computability Theory
Lecture2: Non Deterministic Finite Automata
Prof. Amos Israeli
![Page 2: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/2.jpg)
Roadmap for Lecture
In this lecture we:• Present the three regular operations.• Present Non-Deterministic Finite Automata.• Prove that NFA-s and DFA-s are equivalent.• Use NFA-s to show that when each of the
regular operation is applied on regular languages it yields yet another regular language.
2
![Page 3: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/3.jpg)
Let and be 2 regular languages above the same alphabet, . We define the 3 Regular Operations:
• Union: .
• Concatenation: .
• Star: .
The Regular Operations
3
A B
BxAxxBA or |
ByAxxyBA and |
AxkxxxA kk and 0|,...,, 21*
![Page 4: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/4.jpg)
Elaboration
• Union is straight forward.• Concatenation is the operation in which each
word in A is concatenated with every word in B.
• Star is a unary operation in which each word in A is concatenated with every other word in A and this happens any finite number of times.
4
![Page 5: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/5.jpg)
,...,
,,,,,*
badbadbadgoododbadgoodgoodgo
goodbadgoodgoodbadgoodA
•
• .
•
The Regular Operations - Examples
5
boygirl,B badgoodA , boygirlbadgoodBA ,,,
badboybadgirlgoodboygoodgirlBA ,,,
![Page 6: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/6.jpg)
Motivation for Nondeterminism
The Regular Operations give us a way to construct all regular languages systematically.
In the previous lecture, we showed that the union operation preserves regularity:
Given two regular languages L1 and L2 and their recognizing automata, M1 and M2 ,we constructed an automaton that recognizes .21 LL
6
![Page 7: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/7.jpg)
Motivation for Nondeterminism
This approach fails when trying to prove that concatenation and star preserve regularity.
To overcome this problem we introduce nondeterminism.
7
![Page 8: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/8.jpg)
Example of an NFA
0,10,1
0q 4q2q 3q1 1 ,0
1. A state nay have 0-many transitions labeled with the same symbol.2. transitions are possible.
NFA – Nondeterministic Finite Automaton
8
![Page 9: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/9.jpg)
Computation of an NFA
• When several transitions with the same label exist, an input word may induce several paths.
• When 0 transition is possible a computation may get “stuck”.
Q:Which words are accepted and which are not?A: If word w induces (at least) a single accepting
computation, the automaton “chooses” this accepting path and w is accepted.
9
![Page 10: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/10.jpg)
Computation of an NFA - Example
On the input word w=010110 there exist an accepting path and w is accepted.
Can we characterize (find) the language recognized by this automaton?
Words containing 101 or 11 as substrings
1q
0,1
4q2q 3q1 1 ,0
0,1
10
![Page 11: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/11.jpg)
Why do we Care About NFAs?
• NFA-s and DFA-s are equivalent (Meaning: They recognize the same set of languages). In other words: Each NFA recognizing language L has an equivalent DFA recognizing L.
(Note: This statement must be proved.)• But usually, the NFA is much simpler.• Enables the proof of theorems. (e.g. about
regular operations)
11
![Page 12: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/12.jpg)
Example
• An automaton over unary alphabet accepting words whose length is divided either by 2 or by 3.
12
![Page 13: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/13.jpg)
What is the language of this DFA?
13
![Page 14: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/14.jpg)
14
![Page 15: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/15.jpg)
Bit Strings that have 1 in position third from the end
15
![Page 16: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/16.jpg)
Can you verify it now?
16
![Page 17: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/17.jpg)
A finite automaton is a 5-tupple where:
1. is a finite set called the states.2. is a finite set called the alphabet.3. is the transition function.4. is the start state, and5. is the set of accepting states.
DFA – A Formal Definition(Rerun)
17
,
,
FqQ ,,,, 0
Q
QQ :
Qq 0
QF
![Page 18: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/18.jpg)
A finite automaton is a 5-tupple where:
1. is a finite set called the states.2. is a finite set called the alphabet.3. * is the transition function.4. is the start state, and5. is the set of accept states.
*
QPQ :
NFA – A Formal Definition
18
,
,
FqQ ,,,, 0
Q
Qq 0
QF
![Page 19: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/19.jpg)
Differences between NFA-s and DFA-s
There are two differences:1. The range of the transition function is now
. (The set of subsets of the state set ) 2. The transition function allows transitions.
QP Q
19
![Page 20: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/20.jpg)
Possible Computations
hqgqfq
eqdq
cq
DFA
0q
bqjq
aq
.
.
.. . . .
iq kq lq
NFAAt each step of the computation: DFA - A single state is occupied.NFA - Several states may be occupied.
20
![Page 21: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/21.jpg)
Computations of NFA-s
In general a computation of an NFA, N, on input w, induces a computation tree.
Each path of the computation tree represents a possible computation of N.
The NFA N accepts w, if its computation tree includes at least one path ending with an accepting state.
21
![Page 22: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/22.jpg)
Computations of NFA-s
There are two ways to look at computations of an NFA:
• The first is to say that the NFA N “chooses” the right path on its tree of possible computations.
• The second is to say that the NFA N traverses its computation tree “in parallel”.
22
![Page 23: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/23.jpg)
Equivalence Between DFAs and NFAs
Now we prove that the class of NFAs is
Equivalent to the class of DFA:
Theorem: For every NFA , there exists a DFA
, such that .
Proof Idea: The proof is Constructive: We
assume that we know , and construct a
simulating DFA, . 23
NMM N
NMLNL
N
M
![Page 24: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/24.jpg)
Proof
Let recognizing some language A. the state set of the simulating DFA M, should reflect the fact that at each step of the computation, N may occupy several sates.
Thus we define the state set of M as the power-set of the state set of N.
24
FqQN ,,,, 0
QP
![Page 25: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/25.jpg)
Proof (cont.)
Let recognizing some language A. First we assume that N has no - transitions.
Define where .
25
FqQN ,,,, 0
FqQM ,',',,' 0 QPQ '
![Page 26: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/26.jpg)
Proof (cont.)
Our next task is to define M’s transition function, : For any and define
If R is a state of M, then it is a set of states of N. When M in state R processes an input symbol a, M goes to the set of states to which N will go in any of the branches of its computation.
26
'
RrarqQqaR somefor ,|,' 'QR a
![Page 27: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/27.jpg)
Proof (cont.)
An alternative way to write the definition of M’s transition function, is: For any and define
And the explanation is just the same.Note: if than Which is OK since .
27
'
araR Rr ,,'
arRr , aR,' QP
'QR a
![Page 28: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/28.jpg)
Proof (cont.)
The initial state of M is: .
Finally, the final state of M is:
Since M accepts if N reaches at least one accepting state.
The reader can verify for her/him self that M indeed simulates N .
28
00 ' qq
NRQRF of state finitea contains |''
![Page 29: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/29.jpg)
RrarEqQqaR somefor ,|,'
Proof (cont.)
It remains to consider - transitions. For any state of define to be the
collection of states of R unified with the states reachable from R by - transitions. The old definition of is:
And the new definition is:
29
REMR
RrarqQqaR somefor ,|,' aR,'
![Page 30: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/30.jpg)
Proof (end)
In addition, we have to change the definition of , the initial state of . The previous definition, , is replaced with .
Once again the reader can verify that the new definition of satisfies all requirements.
30
M'0q 00 ' qq
00 ' qEq
M
![Page 31: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/31.jpg)
Corollary
A language L is regular if and only if there exists an NFA recognizing L .
31
![Page 32: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/32.jpg)
Let and be 2 regular languages above the same alphabet, . We define the 3 Regular Operations:
• Union: .
• Concatenation: .
• Star: .
The Regular Operations (Rerun)
32
A B
BxAxxBA or |
ByAxxyBA and |
AxkxxxA kk and 0|,...,, 21*
![Page 33: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/33.jpg)
•
• .
• .
The Regular Operations - Examples
33
boygirl,B badgoodA , boygirlbadgoodBA ,,,
badboybadgirlgoodboygoodgirlBA ,,,
,...,
,,,,,*
badbadbadgoododbadgoodgoodgo
goodbadgoodgoodbadgoodA
![Page 34: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/34.jpg)
The class of Regular languages is closed under the all three regular operations.
.
Theorem (rerun)
34
![Page 35: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/35.jpg)
If and are regular, each has its own recognizing automaton and , respectively.
In order to prove that the language is regular we have to construct an FA that accepts exactly the words in .
Proof for union Using NFA-s
35
1A 2A
1N 2N
21 AA
21 AA
![Page 36: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/36.jpg)
A Pictorial proof
36
1N1q
3f2f1f
2N2q
5f4f
0q
F
![Page 37: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/37.jpg)
Let recognizing A1 , and
recognizing A2 .
Construct to recognize ,
Where , ,
a
a
aq
aq
aq
and
and ,
,
,
,
1
1
2
1
21
2
1
Proof for union Using NFA-s
37
21 AA
11111 ,,,, FqQN
22222 ,,,, FqQN
FqQN ,,,,
210 QQqQ 21 FFF
![Page 38: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/38.jpg)
The class of Regular languages is closed under the concatenation operation. .
Theorem
38
![Page 39: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/39.jpg)
Given an input word to be checked whether it belongs to , we may want to run until it reaches an accepting state and then to move to .
Proof idea
39
21 AA 1N
2N
![Page 40: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/40.jpg)
The problem: Whenever an accepting state is reached, we cannot be sure whether the word of is finished yet.
The idea: Use non-determinism to choose the right point in which the word of is finished and the word of starts.
Proof idea
40
1A
1A
2A
![Page 41: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/41.jpg)
A Pictorial proof
41
0q
0q
F
4f
2N
2q3f
2f
1N
1q1f
![Page 42: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/42.jpg)
Let recognizing A1 , and
recognizing A2 .
Construct to recognize ,
Where , ,
and
and
and
,
,
,
,
,
1
2
1
1
1
1
21
1
1
a
a
F q
Fq
Fq
aq
qaq
aq
aq
aq
Proof using NFAs
42
21 AA
1111 ,,,, FqQN
2222 ,,,, FqQN
FqQN ,,,, 1
21 QQQ 2FF
![Page 43: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/43.jpg)
The class of Regular languages is closed under the star operation. .
Theorem
43
![Page 44: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/44.jpg)
A Pictorial proof
44
1N
1q
3f
2f
0q
F0q
![Page 45: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/45.jpg)
Let recognizing A1 .
Construct to recognize
Where , , and
a
aa
a
F q
qqFq
Fq
qqaq
aq
aq
aq
and
and and
and
and
,
,
,
,
1
0
0
1
1
1
1
11
1
1
Proof using NFAs
45
*1A
1111 ,,,, FqQN
FqQN ,,,, 0
10 QqQ 10 FqF
![Page 46: 1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.](https://reader030.fdocuments.net/reader030/viewer/2022012910/56649d2c5503460f94a020a5/html5/thumbnails/46.jpg)
Wrap Up
In this lecture we:• Motivated and defined the three Regular
Operations.• Introduced NonDeterministic Finite
Automatons.• Proved equivalence between DFA-s and NFA-s.• Proved that the regular operations preserve
regularity.
46