Automata & Complexity Theory
CoSc3025
Chapter One
Introduction
Contents
What is automata?
Alphabets & Strings
Languages & Grammars
Finite automata, DFA & NDFA
Automata Theory
Automata Theory is a branch of
computer science that deals with
designing abstract self-propelled
computing devices that follow a
predetermined sequence of
operations automatically.
Automata – What is it?
The term "Automata" is derived from the
Greek word "αὐτόματα" which means "self-
acting".
An automaton (Automata in plural) is an
abstract self-propelled computing device
which follows a predetermined sequence of
operations automatically.
Automata?
Automata is the kind of machine which takes some
string as input and this input goes through a finite
number of states and may enter in the final state.
This automaton consists of states and transitions.
The State is represented by circles, and
the Transitions is represented by arrows.
An automaton with a finite number of states is
called a Finite Automaton (FA) or Finite State
Machine (FSM).
Finite Automaton (FA)
An automaton with a finite number of states is called a Finite
Automaton (FA) or Finite State Machine (FSM).
Finite automata are used to recognize patterns.
It takes the string of symbol as input and changes its state accordingly.
When the desired symbol is found, then the transition occurs.
At the time of transition, the automata can either move to the next
state or stay in the same state.
Finite automata have two states, Accept state or Reject state. When
the input string is processed successfully, and the automata reached its
final state, then it will accept.
Formal Definition of Finite
Automata (FA)
A finite automaton is a collection of 5-tuple
(Q, ∑, δ, q0, F), where:
Q: finite set of states
∑: finite set of the input symbol
q0: initial state
F: final state
δ: Transition function
Basic terminologies
Alphabets
Alphabets are a finite set of symbols. It is denoted
by ∑.
Examples:
∑ = {a, b}
∑ = {A, B, C, D}
∑ = {0, 1, 2}
∑ = {0, 1, ....., 5]
∑ = {#, β, Δ}
Symbols
Symbols are an entity or individual objects, which can be
any letter, alphabet or any picture.
Example: 1, a, b, #
Cont.….
String
It is a finite collection of symbols from the alphabet. The
string is denoted by w.
If ∑ = {a, b}, various string that can be generated from ∑
are {ab, aa, aaa, bb, bbb, ba, aba.....}.
A string with zero occurrences of symbols is known as an
empty string. It is represented by ε.
The number of symbols in a string w is called the length of
a string. It is denoted by |w|.
Example:
o If W = ‘cabcad’, |W|= 6
o If |W|= 0, it is called an empty string (Denoted
by λ or ε)
o w = 010 , then the number of Sting |w| = 3
Kleene Star
Definition − The Kleene star, ∑*, is a unary operator on
a set of symbols or strings, ∑, that gives the infinite set
of all possible strings of all possible lengths
over ∑ including λ.
Representation − ∑* = ∑0 ∪ ∑1 ∪ ∑2 ∪……. where
∑p is the set of all possible strings of length p.
Example − If ∑ = {a, b}, then
∑* = {λ, a, b, aa, ab, ba, bb,………..}
Kleene Closure / Plus
Definition − The set ∑+ is the infinite set of all possible
strings of all possible lengths over ∑ excluding λ.
Representation − ∑+ = ∑1 ∪ ∑2 ∪ ∑3 ∪…….
∑+ = ∑* − { λ }
Example − If ∑ = { a, b } , ∑+ = { a, b, aa, ab, ba, bb,
………..}
Language
A language is a collection of appropriate string.
A language is a subset of ∑* for some alphabet ∑.
It can be finite or infinite.
Example − If the language takes all possible strings of
length 2 over ∑ = {a, b}, then
L = { ab, aa, ba, bb }
Language Examples
L1 = {Set of string of length 2} = {aa, bb, ba, bb} its an
example of Finite Language
L2 = {Set of all strings starts with 'a'} = {a, aa, aaa, abb,
abbb, ababb} - Infinite Language
Transition Diagram
A transition diagram or state transition diagram is a
directed graph which can be constructed as follows:
There is a node for each state in Q, which is
represented by the circle.
There is a directed edge from node q to node p labeled
a if δ(q, a) = p.
In the start state, there is an arrow with no source.
Accepting states or final states are indicating by a
double circle.
Some Notations that are used in the
transition diagram:
Example
In the above diagram, the machine
initially is in start state q0 then on
receiving input 1 the machine changes its
state to q1.
From q0 on receiving 0, the machine
changes its state to q2, which is the dead
state. From q1 on receiving input 0, 1 the
machine changes its state to q1, which is
the final state.
The possible input strings that can be generated are 10, 11, 110, 101,
111......., that means all string starts with 1.
Transition Table
The transition table is basically a tabular representation of the
transition function.
It takes two arguments (a state and a symbol) and returns a
state (the "next state").
A transition table is represented by the following things:
Columns correspond to input symbols.
Rows correspond to states.
Entries correspond to the next state.
The start state is denoted by an arrow with no source.
The accept state is denoted by a star.
Example
Types of Finite Automaton
Can be classified into two types −
Deterministic Finite Automaton (DFA)
Non-deterministic Finite Automaton (NDFA / NFA)
Deterministic Finite Automata (DFA)
Deterministic refers to the uniqueness of the computation.
The finite automata are called deterministic finite automata if
the machine is read an input string one symbol at a time.
In DFA, there is only one path for specific input from the
current state to the next state.
DFA does not accept the null move, i.e., the DFA cannot
change state without any input character.
DFA can contain multiple final states. It is used in Lexical
Analysis in Compiler.
Example
In the following diagram, we can
see that from state q0 for input a,
there is only one path which is
going to q1.
Similarly, from q0, there is only
one path for input b going to q2.
NFA (Non-Deterministic finite automata)
It is easy to construct an NFA than DFA for a given regular
language.
The finite automata are called NFA when there exist many
paths for specific input from the current state to the next state.
Every NFA is not DFA, but each NFA can be translated into
DFA.
NFA is defined in the same way as DFA but with the
following two exceptions, it contains multiple next states, and
it contains ε transition.
Example
From the image, we can see
that from state q0 for input
a, there are two next states
q1 and q2,
similarly, from q0 for input
b, the next states are q0 and
q1.
Thus it is not fixed or determined that with a particular input where to
go next. Hence this FA is called non-deterministic finite automata.
Example
Design a NFA for the transition table as given
below:
Conversion from NFA to DFA
In this section, we will discuss the method of
converting NFA to its equivalent DFA.
In NFA, when a specific input is given to the
current state, the machine goes to multiple
states.
It can have zero, one or more than one
move on a given input symbol.
On the other hand, in DFA, when a specific
input is given to the current state, the
machine goes to only one state.
DFA has only one move on a given input
symbol
Steps for converting NFA to DFA:
Step 1: Initially Q' = ϕ
Step 2: Add q0 of NFA to Q'. Then find the
transitions from this start state.
Step 3: In Q', find the possible set of states
for each input symbol. If this set of states is
not in Q', then add it to Q'.
Step 4: In DFA, the final state will be all the
states which contain F(final states of NFA)