Class 1 Intro
Class 1 Intro
OF
COMPUTATION
U19CS503 THEORY OF COMPUTATION 3003
COURSE OUTCOMES
Construct finite automata from regular expression and identify the properties of
regular language
Design recognizers for different formal languages and Push Down Automata
Convert CFG to normal forms and design turing machines for various problems
UNIT V UNDECIDABILITY 9
Introduction to
Automata Theory,
Languages and
Computation
J.E. Hopcroft, R.
Motwani, J.D.
Ullman
2nd Edition
INTRODUCTION
8
Computability theory
Computability theory deals primarily with the question of the extent
to which a problem is solvable on a computer.
Eg:
Halting problem cannot be solved by a Turing machine
10
Why do we study theory of computation?
a computer is what??
it is simply a machine made of hardware??
Recursively Enumerable
Recursive
Context Sensitive
Context Free
Regular
16
Language recognizers
Language Type Recognizer
Linear Bounded
Context Sensitive 1
Automata
Recursive 0 Turing Machine
Unrestric
ted or
Recursively Turing
recogniza Turing Machine
Enumerable ble
Non Recursively
NO DEVICE
Enumerable
17
Mathematical Preliminaries
Set
•Set is defined as collection of objects.
•These objects are called elements of the
set.
A= {a,b,c}, B={0,1,2}
Subset
The subset A is called subset of set B, if
every element of set A is present in the set
B but reverse is not true.
It is denoted by A ⊆ B
Eg: A={1,2,3} and B={1,2,3,4,5}, then A ⊆ B
Empty Set
The set having no element in it is called
empty set. It is denoted by A={ } and it can
be written as Φ.
Power Set
The power set is a set of all the subsets of
its element.
Eg: A={1,2,3}
Find power set of Q is,
Power set of Q={{Φ},{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}
The number of elements are always equal to 2 n where
n is number of elements in original set. As in set A
there are 3 elements.
Therefore in power set Q there are 2 3=8 elements
Equal Set
The two sets are said to be equal (A=B) if A ⊆ B and
B ⊆ A, i.e, every element of set A is an element of B
and every element of B is an element of A.
A={1,2,3} and B={1,2,3} then A=B
Alphabet and Strings
•An alphabet is a finite, non-empty set of
symbols.
-{0,1 } is a binary alphabet.
-{ A, B, …, Z, a, b, …, z } is an English alphabet.
Example:
1. Σ = {a,b}, an alphabet of 2 symbols a
and b.
2. Σ = {0,1,2} an alphabet of 3 symbols
0,1,2
A string or word over an alphabet set Σ is a
finite sequence of symbols from Σ
-0, 1, 11, 00, and 01101 are strings over {0, 1 }.
-Cat, CAT, and compute are strings over the
English alphabet.
Examples:
1. Σ = {a,b} then abab, aabba, aaabba are all strings over the
alphabet Σ ={a,b}
2. Σ ={a} then a,aa,aaa are all string over the alphabet Σ ={a}
Let Σ = {a, b, …, z}
length(automata) = 8
length(computation) = 11
length(ε) = 0
i) x = 010 y = 1
xy = 0101 yx= 1010
ie W= a1a2……am
WR = am…….a2a1
Ex:
Let u= 0101011
uR = 1101010
Power of an alphabet:
Let Σ be an alphabet
Σ * denotes the set of all strings over the alphabet Σ .
Σ m denotes the set of all strings over the alphabet Σ of length m.
Ex:
If Σ = {0,1} then
Σ 0 ={ ε } empty string
Σ 1 ={0,1} set of all strings of length one over Σ = {0,1}
Σ 2 = {00,01,10,11} set of all strings of length two over Σ = {0,1}
Σ 3 ={000,001,010,011,100,101,110,111} set of all strings of length
three over Σ = {0,1}
Kleene closure:
Let Σ be an alphabet. Then “Kleene closure Σ *” denotes the set
of all strings (including ε, empty string ) over the alphabet Σ.
Ex:
i) If Σ = {a} then Σ* = { ε,a,aa,aaa,…..} that is
Σ 0 ={ ε }
Σ1={a}
Σ 2 = {aa}
Therefore Σ * = Σ 0 U Σ 1 U Σ 2 U………….
Substring:
A string v appears within another string w(w=uv) is
called “ substring of w”. If w=uv, the substrings u & v
are said to be prefix and suffix of w respectively.
Ex:
i) w = abbab be a string over an alphabet Σ = {a,b}
then a,ab,abb,ba,bab,….. are all substrings of w.
ii) w = 123
prefixes = { ε , 1,12,123}
suffixes = { ε , 3, 23, 123}
iii) w= abbab
prefixes = { ε ,a,ab,abb,abba,abbab}
suffixes = { ε ,b,ab,bab,bbab,abbab}
Palindrome:
A palindrome is a string which is same whether
written forward or backward.
Ex:
X = abc Y = 123
XY = abc123
|XY| = 6 i.e |X| = 3 |Y| = 3
Hence |XY| = |X| + |Y|.
Σ*
• The set of strings created from any number
(0 or 1 or …) of symbols in an alphabet is
denoted by *.
• That is, * = i=0 i
– Let = {0, 1}.
* = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, … }.
Σ +
Example:
Let Σ = {0, 1} be the alphabet.
Le = {Σ* | the number of 1’s in is even}.
Le= {Σ* | the number of 1’s in is not even}.
Le= {Σ* | the number of 1’s in is odd}.
Union
Let L1 and L2 be languages over an alphabet Σ.
The union of L1 and L2, denoted by L1L2, is {x | x is in
L1 or L2}.
Example:
{x{0,1}*|x begins with 0} {x{0,1}*|x ends with 0}
= {x {0,1}*| x begins or ends with 0}
Intersection
Let L1 and L2 be languages over an alphabet Σ.
The intersection of L1 and L2, denoted by L1L2, is { x |
x is in L1 and L2}.
Example:
{ x{0,1}*| x begins with 0} { x{0,1}*| x ends with 0}
= { x{0,1}*| x begins and ends with 0}
Concatenation
Let L1 and L2 be languages over an alphabet Σ.
The concatenation of L1 and L2, denoted by L1L2, is {w1w2| w1 is in
L1 and w2 is in L2}.
Example
{ x {0,1}*| x begins with 0}{x {0,1}*| x ends with 0}
= { x {0,1}*| x begins and ends with 0 and length(x) 2}
{ x {0,1}*| x ends with 0}{x {0,1}*| x begins with 0}
= { x {0,1}*| x has 00 as a substring}
Reversal
Let L be a language over an alphabet Σ.
The reversal of L, denoted by Lr, is {wr| w is in L}.
Example
{x {0,1}*| x begins with 0} r
= {x {0,1}*| x ends with 0}
{x {0,1}*| x has 00 as a substring} r
= {x {0,1}*| x has 00 as a substring}
Consider the string X=110 and Y=0110 then
find
i) xy
ii) yx
iii) x2
iv) ϵ y
Answer
xy = 1100110
yx= 0110110
x2 =110110
ϵ y = 0110