Module 7 –
Recursive and Recursively Enumerable
Languages
Recursive and Recursively Enumerable Languages, Language that is not Recursively
Enumerable (RE) – computable functions – Chomsky Hierarchy – Undecidable
problems -Post’s Correspondence Problem
Topic: Post’s Correspondence Problem, Computable functions
5
Post Correspondence Problem
(PCP)
• Devised by Emli Post
• An abstract problem that involves string rather than
TMs.
• Tool for proving problems in logic or in formal
language theory to be undecidable.
Definition
Example 1
Solution
Decidable – able
to find the
solution
Example: 2
List A List B
a ble
–
1) 1 111 d ab ele
c i
2) 10111 10 De nd th
fi
to t ion
u
3) 10 0 sol
(3) w 101111110
(2) w 10111 x 101111110
x 10
w=x
(1) w 101111
solution: 2 1 1 3
x 10111
(1) w 1011111 2113211321132113
x 10111111
Example: 3
List A List B
a ble
1) bbab a le –
id ab e
c
2) ab abbb De nd th
fi
to t ion
u
3) baa aa sol
4) b bbb
(3) w abbbabbbaa
(2) w ab x abbbabbbaa
x abbb
(1) w abbbab w=x
x abbba solution: 2 1 4 3
(4) w abbbabb 214321432143
x abbbabbb
Example: 4
List A List B ot
n
1) 10 101 b le–
id a t he
2) 011 11 ndec find
U e to
abl tion
3) 101 011 sol
u
(1) w 10 (3) w 10101101
x 101 x 101011011
(1) w 1010
x 101101
(3) w 10101 This problem has no solution.
x 101011
Example: 5
List A List B
not
1) aab aba b le–
id a t he
2) bb bba ndec find
U e to
3) aaaa b abl tion
u
sol
(2) w bb (3) w bbaaaa
x bba x bbab
(1) w bbaab
x bbaaba This problem has no solution.
(1) w bbaabaab
x bbaabaaba
Computable Functions
A recursive function is defined in terms of itself.
1. The recursive definition of factorial is
n! = n * (n-1)! for n ≥1
2. The recursive definition of the exponential xn is defined as
xn = x * xn-1 for n ≥1
• A recursive function can be generalized by defining it in
addition to in terms of itself, possibly in terms of some other
functions.
• Such generalization defines primitive recursion.
• Turing machine is viewed as a mathematical model of partial
recursive function.
Some basic properties:
f : A → B A = N , B = N , N is a set of natural
numbers
1. Total function
A total function from A to B assigns a unique
element of B to every element of A.
f(x) = 2x is a total function.
2. Partial function
A partial function from A to B assigns at most one
element of B to every element of A.
f(x) = + is a partial function.
f(x) is not defined if x is a negative real number.
3. Function of k-variables
A function of k-variables is represented as f(x1, x2, . . . ,
xk).
f(x1, x2) = x1+2x2 is a function of two variables.
4. Primitive recursive function
Some initial functions are taken as primitive recursive
functions. These initial functions are:
a) Zero function
b) Successor function
c) Projection function
A function derived from combination / composition of
primitive recursive functions is primitive recursive.
The zero function z is defined by z(x) = 0
The successor function S is defined by S(x) = x + 1
The Projection function is defined by
(x1, x2, . . . , xn ) = xi
The Projection function selects ith element from a tape
containing n elements.
For example, (3, -9, 2, 6, 9) = 2
5. Composition
If f1, f2, . . . , fk are partial functions of n variables, and g is a partial
function of k variables, then the composition of g with f1, f2, . . . , fk
is a partial function of n variables defined by
g(f1(x1, x2, . . . , xn), f2(x1, x2, . . . , xn), . . . , fk(x1, x2, . . . , xn) )
For example:
If f1(x, y) = x + y , f2(x, y) = 3x , f3(x, y) = xy and g(x, y, z) = x + y
+ 2z be functions over N, then
g(f1(x, y), f2(x, y), f3(x, y)) = ( (x + y) + (3x) + 2(xy)) = (x + y + 3x
+ 2xy)
= (4x + y +
2xy)
If the composition g with f1, f2 and f3 is by a function h, then
h(x, y, z) = 4x + y + 2xy
Def: A function is called primitive recursive if and only if it can be
constructed from the basic functions z, S, by successive composition
and primitive recursion.
Example:1 f(x, y) = x + y
Define f(x, 0) = x = (x)
f(x, y+1) = f(x, y) + 1 = S(f(x, y))
To add 2 and 3,
f(2, 3) = f(2, 2) + 1
= f(2, 1) + 1 + 1
= f(2, 0) + 1 + 1 + 1
=2+1+1+1=5
Example: 2 f(x, y) = x*y
Define f(x, 0) = 0 = z(x)
f(x, y+1) = x + f (x, y) = h( x , f(x, y)) h(x,
y) = x + y
= h( (x, y, f(x, y)) , (x, y, f(x, y)))
multiply 2 and 3
f(2, 3) = 2 + f(2, 2)
= 2 + 2 + f(2, 1)
= 2 + 2 + 2 + f(2, 0)
= 2 + 2+ 2 + 0 = 6
Example:3
f(x, y) = x – y if x ≥ y
=0 if x < y
Now, we define the predecessor function
pred(0) = 0
pred(y + 1) = y
And from it, the subtraction function
subtr(x, 0) = x
subtr(x, y+1) = pred(subtr(x, y))
To prove that 5 – 3 = 2
subtr(5, 3) = pred(subtr(5, 2))
= pred(pred(subtr(5, 1)))
= pred(pred(pred(subtr(5, 0))))
= pred(pred(pred(5)))
= pred(pred(4))
= pred(3)
=2
Example:4
f(n) = n!
fact(0) = 1
fact(x+1) = (x+1)*fact(x)
= S(x)*fact(x)
= g(x, fact(x))
= S( = (x + 1) * fact(x)
n=5
fact(5) = fact(4+1) = 5 * fact(4) = 5 * fact(3 + 1) = 5 * 4 * fact(3) =5 * 4 *
fact(2 + 1)
= 5 * 4 * 3 * fact(2) = 5 * 4 * 3 * fact(1 + 1) = 5 * 4 * 3
* 2 * fact(1)
= 5 * 4 * 3 * 2 * fact ( 1 + 0) = 5 * 4 * 3 * 2 * 1* fact(0)
= 5 * 4 * 3 * 2 * 1 * 1 = 120