Upload
vladimir-kulyukin
View
135
Download
13
Tags:
Embed Size (px)
Citation preview
Theory of Computation
Decision Algorithms for Regular Sets;Finite Automata in Robot Navigation
Vladimir Kulyukin
http://www.vkedco.blogspot.com/
Outline
● Decision Algorithms for Regular Languages:Emptiness InfinityEquivalence
● Finite Automata in Robot Navigation
Emptiness & Infinity Theorem
Theorem: The language of a DFA M with n > 0
states is
1) L(M) is not empty iff M accepts a string s such that |s| < n2) L(M) infinite iff M accepts s such that n <= |s| < 2n
Emptiness Proof
1) If M accepts a string s such that |s|<n then L(M) is obviously not empty.
2) If M is not empty, then let s be a string as short as any other string in L(M). If |s|<n, we are done. If |s| >= n, then, by the Pumping Lemma, s = uvw and |v| > 0 so that uw is also in the language, but then s is not a shortest string, which is a contradiction.
Infinity Proof
1) Let s be is in L(M) and n<=|s|<2n, then, by the Pumping Lemma, L(M) is infinite, because uviw is in L(M) for all i.
2) If L(M) is infinite, there is s in L(M), where |s| >= n. If |s| < 2n, we are done. Assume that there are no words whose length is in the range [n, 2n-1]. Let |s| be a shortest string such that |s|>=2n. Let s = uvw. But then, by the Pumping Lemma, uv is also in L(M). Thus, either s is not a shortest string or |uv| is in the range [n, 2n-1]. A contradiction in either case.
Emptiness & Infinity Algorithms
● An algorithm to decide if L(M) is empty: Generate all strings in the range [0, n-1] If one of them is accepted, L(M) is not empty
● Can you think of a better algorithm to decide the emptiness of L(M)?● An algorithm to decide if L(M) is infinite:
Generate all strings in the range [n, 2n-1] If one of them is accepted, L(M) is infinite
● Can you think of a better algorithm that decides the infinity of L(M)?
Better Emptiness & Infinity Algorithms
There is a more efficient algorithm to check the emptiness & infinity properties. Let M be a DFA.
1) Represent M as a graph.
2) Determine all states that are not reachable from the start state. If at least one final state is reachable, L(M) is not empty.
3) Delete all states from which no final state is reachable. L(M) is a infinite if M has a cycle.
Equivalence Theorem
There is an algorithm that determines if two DFAs M1 and
M2 accept the same language.
Proof
. iffempty not is 7.
.for DFA a be Let 6.
regular. is 5.
regular. is 4.
regular. is 3.
regular. is 2.
regular. is 1.
Then . and
such that DFAs twobe and Let
213
12213
1221
12
1
21
2
2211
21
LLML
LLLLM
LLLL
LL
L
LL
L
MLLMLL
MM
Summary
● Deciding if the language of an FA is not empty is effectively computable
● Deciding if the language of an FA is infinite is effectively computable● Deciding if two FAs accept the same language is effectively
computable
Finite Automata in Robot Navigation
Junun Mark III Robot
Line Following Problem
How can we make a robot follow a black line on the floor?
Line Following
Left Sensor
Middle Sensor
Right Sensor
Left Sensor returns black_on_left when it detects blackness.Middle Sensor returns black_on_center when it detects blackness.Right Sensor returns black_on_right when it detects blackness.
Line Following
if ( black_on_center ) move_forward;
We assume that the robotstarts with the middle sensoraligned with the line. So, ifthe middle sensor detectsblackness, the robot movesforward.
LEFT CENTER RIGHT
Line Following
if ( black_on_left ) turn_left;
If the left sensor detectsblackness, the robot turnsleft to align the middlesensor with the line.
LEFT CENTER RIGHT
Line Following
if ( black_on_right ) turn_right;
If the right sensor detectsblackness, the robot turnsright to align the middlesensor with the line.
LEFT CENTER RIGHT
An FA for Line Following
read_sensors
turn_left
black_on_left
move_completed
turn_right
black_on_rightmove_completed
move_forward
black_on_center/no_black
move_completed
References
● Brooks Webber. Formal Language: A Practical Introduction, Franklin, Beedle & Associates, Inc
● Hopcroft and Ullman. Introduction to Automata Theory, Languages, and Computation, Narosa Publishing House
● Davis, Weyuker, Sigal. Computability, Complexity, and Languages, 2nd Edition, Academic Press
● http://docs.oracle.com/javase/tutorial/essential/regex/