Professional Documents
Culture Documents
Theory of Computati ON: Dept. Cs&It Uet Peshawar
Theory of Computati ON: Dept. Cs&It Uet Peshawar
Theory of Computati ON: Dept. Cs&It Uet Peshawar
COMPUTATI
ON
BY: Muhammad Muneeb Ullah
MS(CS) Batch# IV
Dept.
CS&IT UET
PESHAWAR
THEORY OF COMPUTATION
Contents
UNDECIDIABILITY...................................................................................................................... 2
The Acceptance Problem for TMs:......................................................................................... 2
Theorem:............................................................................................................................... 2
Proof:.................................................................................................................................. 2
Conclusion:......................................................................................................................... 2
The Diagnalization Method:................................................................................................... 2
Some Basic Terminologies:.................................................................................................... 2
Function:............................................................................................................................. 2
Example:............................................................................................................................ 2
One-To-One Function:......................................................................................................... 3
Example:............................................................................................................................ 3
Example:............................................................................................................................ 3
Example:............................................................................................................................... 3
Onto Function:........................................................................................................................... 3
Example................................................................................................................................ 3
Example:............................................................................................................................... 3
Example:............................................................................................................................... 4
Correspondence Function:..................................................................................................... 4
Countable Sets:..................................................................................................................... 4
Example:............................................................................................................................ 4
Example:............................................................................................................................ 5
Answer: yes............................................................................................................................. 5
Uncountable:......................................................................................................................... 6
Example:............................................................................................................................ 6
THEORY OF COMPUTATION
UNDECIDIABILITY
The Acceptance Problem for TMs:
Consider the problem of testing whether a Turing Machine accepts a given
input.
Theorem
ATM
Is undecidable
Proof:
First we observe that is Turing-recognizable. (Hence recognizers are more powerful than deciders).
Requiring a TM to halt on all inputs restricts the kinds of languages that it can recognize.
The following TM U recognizes
U = on input <M,w>, where M is a TM and w is a string:
1. Simulate M on input w.
2. If M ever enters it accept state, accept. If M ever enters its reject state, reject.
Note, this machine loops on input <M,w> if M loops on w. If the algorithm had some way to determine
that M was not halting on w, it could reject Hence the halting problem. I will show an algorithm has no
way to make this determination.
U is an example of universal Turing machine first proposed by Turing. It is capable of simulating any other
Turing machine from the description of that machine. The universal Turing machine played an important
early role in stimulating the development of stored-program computers.
Conclusion:
The general problem of software verification is not solvable algorithmically (by computer).
THEORY OF COMPUTATION
One-To-One Function:
A function f: A B is said to be one-to-one (or injective) if and only if f(x) = f(y) implies
x = y for all x and y in A. That is, for each element b B, there is at most one element from A that maps to
it.
Example:
Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, b), (2, c), (3, a)}. This function is
one-to-one.
Example:
Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, a), (2, b), (3, a)}. This function is not oneto-one since more than one element maps to a.
The requirement for a function to be one-to-one is that no arrows in the diagram point to the same element
of B. If A and B are finite sets then for f: A B to be 1-1 it is necessary for |A| |B|.
A
B
1
Example:
Let A = {a, b, c, d} and B = {1, 2, 3, 4, 5} and f(a) = 4, f(b) = 5, f(c) = 1, and f(d) = 3.
This function is one-to-one.
Onto Function:
A function f: A B is said to be onto (or surjective) if and only if for every element b
B, there is at least one element from A that maps to it.
That is, f: A B is onto if yBxA[f(x) = y].
Example
Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, a), (2, b), (3, a)}. This function is not onto since there is no
element that maps to c.
Example:
Let A = {1, 2, 3} and B = {a, b, c} and f = {(1, b), (2, c), (3, a)}. This function is onto.
The requirement for a function to be onto is that each element of B has at least one arrow pointing
3
THEORY OF COMPUTATION
Into it. If A and B are finite sets then for f: A B to be onto it is necessary for |A| |B|.
Example:
Let A = {a, b, c, d} and B = {1, 2, 3, 4, 5} and f(a) = 4, f(b) = 5, f(c) = 1, and f(d) = 3. This function is not
onto (nothing maps to 2).
Correspondence Function:
A function f is a one-to-one correspondence (or a bijection), if is both one-to-one (injective) and onto
(surjective) .They also allow us to have a concept cardinality for infinite sets.
a1
b1
a2
b2
a3
b3
a4
b4
Countable Sets:
A set A is countable if either it is finite or it has the same size as N.
Example:
Let N be the set of natural numbers {1,2,,} and E is the set of even
natural numbers {2,4,}. Using Cantors definition of size we can see that N and E
have the same size. The correspondence f mapping N to E is simply f(n) = 2n.
n
1
2
3
F(n)
2
4
6
THEORY OF COMPUTATION
Q {
m
: m, n N }.
n
Example:
Answer: yes
In order to show that Q is countable there is a method called Diagnalization.
How to do?
Q seems to be much larger than N, yet these two sets have the same size: Q is countable
Steps:
1. Create a matrix containing all positive rational numbers.
m
n
2. Row, i=
contains all nos with Nominator m.
m
n
3. Column, j=
contains all nos with denominator j.
i
j
4.
, locate it ( i , j ).
5. Then turn this matrix into a list
1
1
3 2 1
2
3
2 3 4
Like from below figure { 1, 2 , , 3, ,4 , ,
, ,}
Note: Skip an element if it would cause a repetition.
THEORY OF COMPUTATION
Uncountable:
( 3.1415926..., 2 1.4142135...)
For some infinite sets no correspondence with N exists. Such sets are called
uncountable. (These sets are simply too big.)
A real number is one that has a decimal representation
Example:
x = 0.4641
We know that x is not f(n) for any n since it differs from f(n) in the nth fractional digit.