Finite Automata
Finite Automata
Chapter 5
Finite Automata
Theory of Automata
Lecturer: Sana Rehman
2 4. Finite Automaton
Example:
Pieces are set up on a playing board.
Dice are thrown and a number is generated at random.
Depending on the number, the pieces on the board must be rearranged in a fashion completely
specified by the rules.
The child has no options about changing the board.
Everything is determined by the dice.
Then some other child's turn to throw the dice and make his or her move, but this hardly matters,
since no skill or choice is involved.
The one who win the game is dependent entirely on what sequence of numbers is generated by the
dice, not on who moves them.
3 Continued…
All the possible positions of the pieces on the board are called the states.
The game changes from one state to another in a fashion determined by the input of a certain
number.
For each possible number there is one and only one resulting state.
A possibility is allowed that after a number is entered the game is still in the same state as it was
before.
Final State
After a certain number of rolls, the board arrives at a state that means a victory for one of the players
and the game is over.
This state is called final state.
More than one final states can be possible called halting, terminal or accepting states
4 Continued…
This model is called finite automaton, “finite" because the number of possible states and number of
letters in the alphabet are both finite, and "automaton" because the change of states is totally
governed by the input
"Automaton“ comes to us from the Greek, so its correct plural is "automata.“
Finite Automaton is abbreviated as FA
5 Continued…
Definition
A finite automaton is a collection of three things:
1. A finite set of states, one of which is designated as the initial state, called the start state, and some
(maybe none) of which are designated as final states.
2. An alphabet Σ of possible input letters, from which are formed strings, that are to be read one letter at
a time.
3. A finite set of transitions that tell for each state and for each letter of the input alphabet which state to
go to next.
6 Continued…
Mathematical Definition
If an input string is made up of only the letter a repeated some number of times, then the action of the
FA will be to jump back and forth between state x and state y.
No such word can ever be accepted.
To get into state z, it is necessary for the string to have the letter b in it.
As soon as a b is encountered in the input string, the FA jumps immediately to state z no matter what
state it was in before.
11 Transition Diagram / State Diagram/
Finite State Machine
Graphical representation of transition table
A state machine reads a series of inputs.
When it reads an input, it will switch to a different state.
Each state specifies which state to switch to, for a given input.
Each state is represented by a small circle
Two states are connected with arrows
If a certain letter makes a state go back to itself, it is indicated by an arrow that returns to the same
circle-called a loop.
The start state can be indicated by labeling it with the word "start" or by a minus sign,
The final states can be indicated by labeling them with the word "final" or plus signs.
12 Continued…
13 Continued…
Sometimes a start state is indicated by an arrow and a final state by drawing a box or another circle
around its circle.
14 Usage of State Machines
The output of a state machine is its final state.
It goes through all its processing, and then the final state is read, and then an action is taken.
A state machine doesn’t do anything as it moves from state to state.
It processes, and when it gets to the end, the state is read and something external triggers the desired
action (for example, dispensing a soda can).
15 Continued…
Example:
Input strings aaaabba and bbaabbbb.
16 Continued…
Example:
One edge from the state on the right back has been drawn into itself and given this loop the two
labels a and b, separated by a comma meaning that this is the path traveled if either letter is read.
(drawing repeated loops is avoided)
The first letter of the input takes us to the right-hand state and, once there, we are trapped forever.
It omits the possibility that the input is the null string Ʌ.
If the input string is the null string, we are left back at the left-hand state, and we never get to the
final state.
17 Continued…
By convention we shall say that Ʌ starts in the start state and then ends right there on all FA’s.
The language accepted by this machine is the set of all strings except Ʌ
This has the regular expression definitions
18 Continued…
Example:
One of the many FA's that accepts all words is:
The sign ± means that the same state is both a start and a final state.
There is only one state and no matter what happens we must stay there, the language for this machine
is:
19 Continued…
Example:
Build a finite automaton that accepts all the words in the language that is, all the strings that begin
with the letter a.
a
Start at state x
If the first letter b is read, machine go to a dead-end state y. (A "dead-end state“ is an informal way
of describing a state that no string can leave once it has entered.)
If the first letter a is read, machine go to the dead-end state z, where z is a final state.
20 Continued…
How Language will be accepted by Machine
21
This machine will accept all words with b as the third letter and reject all other words.
Example
36
FA, one that accepts only the word baa.