INTRODUCTION TO THEORY
OF COMPUTATION
INTRODUCTION
Theory of computation is the branch that deals with
whether and how efficiently problems can be solved
on a model of computation, using an algorithm.
It is mainly about what kind of things can you really
compute mechanically, how fast and how much
space does it take to do so
The field is divided into three major branches:
Automata theory,
Computability theory,
Computational complexity theory.
Automata theory
Deals with the definition & properties of various
mathematical model of computation.
Eg.
Finite automata
Context free grammer
Turing machine
Computability theory
It deals with what can and cannot be computed by the
model.
Complexity theory
It group the computable problem based on the hardness.
Basic definitions
Symbol:
Symbol is a character
Eg.
a,b,c,……..z
A,B,C…….Z
0,1,2,3…….9
+,-,/,*……..SPECIAL CHARACTER
Alphabet:
An alphabet is a finite non empty set of symbol.
In this each letter called symbol.
It is denoted by ∑
Eg.
∑={0,1} set of binary alphabet.
∑={a,b,….z} set of all lowercase letters
∑={+,&,/….} set of all special character
String or word:
A string is a finite set sequence of symbols chosen from
some alphabets.
Ex.
011100110 is a string from binary alphabet ∑={0,1 }
aabbaacab is a string from alphabet ∑={a,b,c }
Symbol Alphabet String or word
0,a,+ {0,1 } 011100110
{a,b,c } aabbaacab
Empty string:
The empty string is a string with zero occurrence of
symbols i.e. no symbol.
It is denoted by € means no symbol { }
Length of string:
The length of string is the no of the symbols in the string.
It is denoted by |W|
Ex.
W=010110101 from binary alphabet
Length of string |W|= 9
Concatenation of string:
Join two or more strings
Let x=a1a2 a3……..an &
Y= b1 b2 b3 ……..bn
Concatenation of string xy= a1a2 a3..an b1 b2 b3 ..bn
Ex. S=ababa & T= cdcddc
Concatenation of string ST= ababacdcddc
Power of an alphabet
If“∑” is an alphabet we can express set of all string of
of certain length from that alphabet by using
exponential notation .
∑0= set of all string of length 0 ∑^0={€}
∑^1= set of all string of length 1 ∑^1={0,1}
∑^2= set of all string of length 2 ∑^2={00,01,10,11}
∑^3= set of all string of length 3
∑^3={000,001,010,011,100,101,110,111}
Itis denoted by ∑k is the set of the strings of length k.
Ex.
∑={0,1 } has two symbols
∑^1={0,1 } i.e 2^1=2
∑^2={00,01,10,11} i.e 2^2=4
∑^3={000,001,010,011,100,101,110,111} i.e 2^3=8
The set of strings over an alphabet ∑ is usually denoted by
∑ * =kleen closure
For instance
∑
* ={0,1 } *
= {€ , 0,1,00,10,11,……. }
Empty set
Kleenclosure ∑*= ∑0 U ∑1 U ∑2……..
With ∑ symbol
Power of alphabet can be represented as kleen closure
∑*= ∑0 U ∑1 U ∑2
={€} U {0,1} U {00,01,10,11} U….
= Set of all possible strings of all length over {0,1}
It is infinite set
Cardinality:
number of elements in a set
n n
∑ =2
The set of strings over an alphabet ∑ excluding € is
usually denoted by ∑+=kleen closure+
For instance ∑+= {0,1 }+
={0,1,00,01,10,11…..}
(∑+= ∑*-{€ }) ……….kleen plus
∑+= ∑1 U∑2U ∑3….. ) Without empty set €
So power of an alphabet is two types without empty
set ∑+ and with empty set ∑*
Languages: (Finite set of non empty string)
Single ‘a’ character also called as language
If ∑ is an alphabet and L ∑* , then L is a language.
Ex.
The set of legal English words is a language.
The set of c programs is a language.
The set of strings consisting of n 0’s followed by n is …
{∑ 01,0011,000111,…..} is a language.
Language is set of strings
Ex. ∑ ={0,1 }
L1= Set of all strings of length 2.
= {00,01,10,11}
L2= Set of all strings of length 3.
= {000,001,010,011,100,101,110,111} finite
L3= Set of all strings begin with 0
= {0,00,01,000,001,010,011,0000,….} infinite
Finite Automata
Finite Automata is an abstract computing device. It is a
mathematical model of a system with discrete inputs,
outputs, states and set of transitions from state to state
that occurs on input symbols from alphabet ∑.
It representations:
Graphical(Transition Diagrams on Transition Table)
Tabular (Transition Table)
Mathematical(Transition function of Mapping function)
Formal definition of finite Automata
A finite automata is a 5-tupples, they are
M=(Q, ∑,∂, q0,F)
Where,
Q: is a finite set called the states
∑: is a finite set called the alphabet
∂: Q X ∑ Q is the transition function
q0€Q is the start state also called initial state
F C Q is the set of accept states, also called final state.
q0-initial state
F- Final state
Transition Diagrams (Transition graph)
It is a directed graph associated with the vertices of the
graph corresponds to state of finite automata.
Ex. 1
0 1
1 0
q0 q1 q2
Start or initial state final state or
accepting state
{0,1} are inputs
q0- initial state
q1- intermediate state
q2- final state
Transition Table
It is basically a tabular representation of the
transition function that takes two arguments ( a state
and a symbol) and returns a value (the “next
state”).
Rows corresponds to states
Column corresponds to input symbols
Entries corresponds to next state
The start state is marked with an arrow()
The accept or final state are marked with a star(*)
∑ ∑ ∑ ∑
Q √ √ √ √
Q √ √ √ √
*Q √ √ √ √
Next state
∂=Q X ∑Q
The transition function returns a state which can be
called as next state
∂(current_state,current_input_symbol)=next_state
Ex.
∂(q0,a)=q1
∂(q0,1)=q1
Applications
It plays an important role in compiler design.
In switching theory and design and analysis of digital
circuits automata theory is applied.
Design and analysis of complex s/w and h/w systems.
To prove correctness of the program automata theory is
used.
To design finite state machines such as moore and
mealy m/c.
It is base for the formal languages and these formal
languages are useful of the programming languages.
Deterministic Finite Automata (DFA)
0
1
a
b
1
0
0
1
c
0
Then A AND B are equivalent A=B
1
Example 2. Minimize the following DFA
Mealy machine
Example
Moore machine
Mealy to moore machine
Present state a b o/p
Moore to Mealy machine