1. A finite automaton is defined by a finite set of states, with one start state and some accepting states, an input alphabet, and transitions between states based on the input letters.
2. A word is accepted if it takes the automaton from the start state to an accepting state. The language accepted is the set of all accepted words.
3. There are two approaches to studying finite automata - analyzing an automaton to determine its language, or building an automaton from a given language description.
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
FInite Automata
1. Introduction to Formal Languages
Finite Automata
Mobeen Mustafa1
Chapter 5: Finite Automata
We introduce the simplest deterministic theoretical
machines: Finite Automata.
2. Chapter 5: Finite Automata
Mobeen Mustafa2
A finite automaton (FA) is the following 3 things:
1. a finite set of states, one of which is designated as the
start state, and some (maybe none) of which are
designated the final states (or accepting states)
2. an alphabet Σ of input letters
3. a finite set of transitions that indicate, for each state
and letter of the input alphabet, the state to go to next
state state
letter
3. Chapter 5: Finite Automata
Mobeen Mustafa3
The language defined or accepted by a finite
automaton is the set of words that end in a final
state.
If w is in the language defined by a finite
automaton, then we also say that the finite
automaton accepts w.
4. Chapter 5: Finite Automata
Mobeen Mustafa4
Example: ∑= {a,b}
states = {x,y,z}
start state : x
final states: {z}
a b
x y z
y x z
z z z
aaa: a
x ya ax y y is not final;
aaa is not accepted
aaba: a
x ya bx z z is final;
aaba is accepted
za
transitions:
5. Chapter 5: Finite Automata
5
x
–
y
z
+
a
a
a
b b
b
a b
x y z
y x z
z z z
Regular expression: (a+b)*b(a+b)*
aaaabba?
bbaabbbb?
Transition Diagram
6. Chapter 5: Finite Automata
Mobeen Mustafa6
x
–
y
z
+
a
a
a
b b
b
x
–
y
z
+
a
a
a
b
b
a
a
b
x
–
y
z
+a
b
a
b
b
bb
aaaabba?
bbaabbbb?
7. Chapter 5: Finite Automata
Mobeen Mustafa7
+ a,b
(a+b)(a+b)* = (a+b)+
– +
a
b
a,b
(a+b)*
8. Chapter 5: Finite Automata
8
No final state
The middle state is not a final state and all transitions that go
into this state do not exit.
–
a
b
a,b
–
a,b
a,b
+a,b
Finite Automata that Accept No Words
9. Chapter 5: Finite Automata
Mobeen Mustafa9
Two Ways to Study Finite Automata
1. Starting with a finite automaton (FA), analyze it to determine
the language it accepts.
2. Starting from a language, build an FA.
10. Chapter 5: Finite Automata
Mobeen Mustafa10
Example of 2: The language of all words with an even
number of letters over the alphabet {a,b}:
● Two states: 1 – even number, 2 – odd number
● Start state: 1
● Final state: 1
● The transitions:
a b
1 2 2
2 1 1
1+ 2
a,b
a,b
11. Chapter 5: Finite Automata
Mobeen Mustafa11
x
–
y
z
+
a,b
a,b
b
a
a(a+b)*
Not necessarily unique:
–
+
a,b
a,b
b
a
+
a,b
Remark: 2 final states
12. Chapter 5: Finite Automata
Mobeen Mustafa12
From Languages to Finite Automata
There is not necessarily a unique FA that accepts a given
language.
Is there always at least one FA:
that accepts each possible language?
that defines a language associated with a given regular
expression?
13. Chapter 5: Finite Automata
Mobeen Mustafa13
Example: Build an FA that accepts all words containing a
triple letter (either aaa or bbb).
1.Build an FA that accepts aaa
2.Add a path that accepts bbb.
3.Add paths for words that contain a’s and b’s before or
after the aaa or bbb.
14. Chapter 5: Finite Automata
Mobeen Mustafa14
Does this FA accept the word ababa?
The word babbb?
2 ways to get to state 4
The only way to get to state 2 is by reading an input a.
The only way to get to state 3 is by reading an input b.
What language?
1–
2
4
+
a,ba
b 3
a
a
b
b
This example shows that it is
possible to characterize
states by the purposes they
serve.
From Finite Automata to Languages
15. Chapter 5: Finite Automata
Mobeen Mustafa15
The third letter is b.
(aab + abb + bab + bbb)(a+b)*
(a+b)(a+b)b(a+b)*
The regular expression is not unique.
Is there always at least one regular expression defining the
language accepted by an FA?
+
a,b
a,b
a
b
– a,ba,b
16. Chapter 5: Finite Automata
Mobeen Mustafa16
Regular expression: baa
A “collecting bucket” state for all other words.
–
a,b
b +a
a
a
bb a,b
17. Chapter 5: Finite Automata
Mobeen Mustafa17
Regular expression: baa + ab
–
a,b
b +aa
bb a,b
+ b a
a,b a
18. Chapter 5: Finite Automata
Mobeen Mustafa
18
+
a,b
a,b
+
b
a
ba
– +
a
a
bb
– +
a
b
ab
Λ (a+b)*a + Λ
Words that do not end in b.
(a+b)*a
Words that end
in a.
?
19. Chapter 5: Finite Automata
Mobeen Mustafa19
The only letter that can change state is a.
(b*ab*)(ab*ab*)*
an odd number of a’s
– +
a
a
bb
20. Chapter 5: Finite Automata
Mobeen Mustafa20
Words that contain a double a
(a+b)*aa(a+b)*
Start state: the previous letter (if there is one) was not an a.
Middle state: we have just seen an a that was not preceded
by an a.
Final state: we have seen a double a.
– +
a
b
a,bb
a
21. Chapter 5: Finite Automata
Mobeen Mustafa21
+
b
a
ba
+
a
b
a
b
–
b
a
+
ba
–
a
a
a
b
b
b
aabbaabb
22. Chapter 5: Finite Automata
Mobeen Mustafa22
1
+
2
b
b
a
3 4
b
b
a a a
The Language EVEN-EVEN