0% found this document useful (0 votes)
90 views

Chapter-II Enumerators: Universal Turing Machine

An enumerator is a Turing machine with a printer that can print strings. An enumerator enumerates a language by printing all strings in the language, possibly with repetitions and in any order. A language is Turing-recognizable if some enumerator enumerates it. A universal Turing machine takes the code of a Turing machine and a string as input, and checks if the string is recognized by the Turing machine. Godel numbering encodes strings as numbers based on prime factorizations.

Uploaded by

Dinaol Habtamu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Chapter-II Enumerators: Universal Turing Machine

An enumerator is a Turing machine with a printer that can print strings. An enumerator enumerates a language by printing all strings in the language, possibly with repetitions and in any order. A language is Turing-recognizable if some enumerator enumerates it. A universal Turing machine takes the code of a Turing machine and a string as input, and checks if the string is recognized by the Turing machine. Godel numbering encodes strings as numbers based on prime factorizations.

Uploaded by

Dinaol Habtamu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Chapter-II

ENUMERATORS
An enumerator is a Turing machine with an attached printer. The Turing machine can use that
printer as an output device to print strings. Every time the Turing machine wants to add a
string to the list, it sends the string to the printer.
An enumerator E starts with a blank input on its work tape. If the enumerator doesn’t halt, it
may print an infinite list of strings. The language enumerated by E is the collection of all the
strings that it eventually prints out. Moreover, E may generate the strings of the language in
any order, possibly with repetitions. Now we are ready to develop the connection between
enumerators and Turing recognizable languages.

A language is Turing-recognizable if and only if some enumerator enumerates it.


PROOF First we show that if we have an enumerator E that enumerates a language A, a TM
M recognizes A. The TM M works in the following way.
M = “On input w:
1. Run E. Every time that E outputs a string, compare it with w.
2. If w ever appears in the output of E, accept.”

UNIVERSAL TURING MACHINE


In the previous section, a separate TM designed for each Language. For
example, for the language L= (anbn|n>=1) we designed a TM. For the
language L= (anbncn|n>=1) we designed another TM and so on. A
Universal Turing Machine takes of the code normal TM and a string w and
checks whether w is recognized by TM.

Consider the following TM, TM = ( Q, ∑, Γ, δ, q0, #, h) ,Where Q={q0,q1,qf }, ∑={a,b},


Γ={a,b,,#}, Q0=q0, #=#, h=qf.
Transition function are defined as
δ(q0,a)=(q0,a,R)
δ(q0,b)=(q0,b,R)
δ(q0,#)=(q1,#,L)
δ(q1,b)=(qf,b,R)
the codes of the TM is to be made first we encode all the components of this
TM using binary coding. In the binary coding only symbols 0 and 1 are
available. Here 0 is used for transition function and 1 is used for separator.

States of the TM are Q={q0,q1,qf },States can be coded as Q0=0 Q1=00 Qf=000,
Tape symbols are Γ={a,b,,#},Tape symbols can be coded a=0,b=00,#=000

Direction of motion can be coded L=0,R=00


Transition function are coded
δ(q0,a)=(q0,a,R) = 0101010100
δ(q0,b)=(q0,b,R) = 010010100100
δ(q0,#)=(q1,#,L) = 01000100100010
δ(q1,b)=(qf,b,R) = 001001000100100

in the coding of TM, TM end with 111, transition functions are separator by 11.
State, tape symbol and direction are separator by 1.
Completed TM is 0101010100110100101001001101000100100010110010
01000100100111.

Let w=abbb be the string to be checked on the TM, M. the input UTM willbe,
0101100100100110100010010000101100100010001000
01001100010000100001000001001100001000101000010111abbb
UTM uses the binary code of the Turing machine ,M on string abbb and will
check. if true UTM will halt to say yes and if false UTM will stop to say no.
Godelization:

Godelization is a encoding technique which encodes a string as a number.


This is called Godel numbering. Godel numbering is based on the concept
that every positive integer can be factored into a unique set of prime factor.
For example.
6 = 2 * 3;
8 = 2 * 2 * 2;
9 = 3 * 3;
10 = 2 * 5;
20 = 2 * 2 * 5;
30 = 2 * 3 * 5;
50 = 2 * 5 * 5;
100 = 2 * 2 * 5 * 5;
571725 = 3 * 3 * 3 * 5 * 5 * 7 * 11 * 11;
Also its possible to assign a serial number to each prime number, as
1 to 2
2 to 3
3 to 5
4 to 5
7 to 11 and so on. Now the number.
571725 = 3*3*3*5*5*7*11*11=20 x 33 x 52 x 70 x 112 can be
represented in the form of a sequence (0,3,2,1,2). In terms of Godel
numbering. We say that the Godel number associated with the sequence
(0,3,2,1,1) is 571725.
Decidability and Undesirability language

In this chapter, we will learn about the decidability and undecidability. In order understand
above mentioned terms the following definition needs to know.

Recursive language

The language L is said to be recursive if there exists a Turing machine,which will accept all
the strings in ‘L’ and reject all the strings are not in ‘L’.The turing machine will halt every
time and give an answer(accepted or rejected) for each and every string input.

Recursively Enumerable Language

The language L is said to be recursively enumerable language if there exists a Turing machine
(and therefore halt), which will accept all the input strings which are in ‘L’. But may or may
not halt for all input strings which are not in L

Decidable Language

A language ‘L’ is decidable if it is a recursive language. All decidable languages are recursive
language and vice versa.

Partial Decidable Language

A language ‘L’ is partial decidable language if it is a recursively enumerable language

Undecidable Language

A language ‘L’ is undecidable if it is not decidable. An undecidable language is sometimes


may partially decidable but not decidable. If a language is even not partially decidable, then
there exists no Turing machine for that language.

The above definitions are given in below table for quick understating.

Recursive language TM will always halt


Recursively Enumerable Language TM will halt sometime and may not halt
sometimes

Decidable Language Recursive language


Partially Decidable Language Recursively Enumerable language
Undecidable language No TM for that language
Language Decidability

A language is called Decidable or Recursive if there is a Turing machine which accepts and
halts on every input string w. Every decidable language is Turing-Acceptable.

A decision problem P is decidable if the language L of all yes instances to P is decidable. For
a decidable language, for each input string, the TM halts either at the accept or the reject state
as depicted in the following diagram:

Example 1
Find out whether the following problem is decidable or not:
Is a number ‘m’ prime?
Solution
Prime numbers = {2, 3, 5, 7, 11, 13, …………..}
Divide the number ‘m’ by all the numbers between ‘2’ and ‘√m’ starting from ‘2’.If any of
these numbers produce a remainder zero, then it goes to the “Rejected state”, otherwise it
goes to the “Accepted state”. So, here the answer could be made by ‘Yes’ or ‘No’.
Hence, it is a decidable problem.
Example 2
Given a regular language L and string w, how can we check if w∈ L?
Solution
Take the DFA that accepts L and check if w is accepted

Some more decidable problems are:


1. Does DFA accept the empty language?
2. Is L1∩ L2=Ø for regular sets?

Note:
1. If a language L is decidable, then its complement L' is also decidable.
2. If a language is decidable, then there is an enumerator for it.

Note:
1. If a language L is decidable, then its complement L' is also decidable.
2. If a language is decidable, then there is an enumerator for it.
The acceptance problem for DFAs of testing whether a particular deterministic finite
automaton accepts a given string can be expressed as a language, ADFA. This language
contains the encodings of all DFAs together with strings that the DFAs accept. Let
ADFA = { < B, w > | B is a DFA that accept s input string w }.
The problem of testing whether a DFA B accepts an input w is the same as the problem of
testing whether a <B,w> is a member of the language ADFA. Similarly we can formulate other
computational problem in terms of testing membership in a language.
In the following theorem we show that ADFA is decidable. Hence this theorem shows that the
problem of testing whether a given finite automaton accepts a given string is decidable.
Theorem 1.
ADFA is decidable language.
Proof Idea: we simply need to present a TM M that decides ADFA.
M= “ On input <B,w>, where B is DFA and w is a string.
1. Simulate B on input w.
2. If the simulation ends in an accept state, accept. If it ends in a non accepting state,
reject.”
Let’s examine the input <B,w>. it is a representation of a DFA B together with a string w.
one reasonable representation of B is simply a list of its five components, Q,,δ,q0 and F.
when M receives its input, M first determines whether it properly represents a DFA B and a
string w. if not, M rejects.
Then M carries out the simulation directly. It keeps track of B’s current state and B’s current
position in the input w by writing this information on the tape. Initially, B’s current state is q 0
and B’s current input position is the leftmost symbol of w. The states and position are
updated according to the specified transition function δ. When M finishes the last symbol of
w, M accepts the input if B is in an accepting state; M reject the input if B is in a non-
accepting state.
We can prove similar theorem for nondeterministic finite automata. Let
ANFA = {< B, w > | B is a NFA that accept s input string w }.
Theorem 2.
ANFA is decidable language.
PROOF: we present a TM N that decides A NFA. We could design N to operate like M,
simulating an NFA instead of a DFA. Instead, we will do it differently to illustrate a new idea
have N use M as a subroutine. Because M is designed to work with DFA. N first converts the
NFA it receives as input to a DFA before passing it to M.
N= “On input <B,w> where B is a NFA and w is a string
1. Convert NFA B to an equivalent DFA C by using the procedure for this conversion.
2. Run TM M from Theorem 1 on input <C,w>.
3. If M is accepts, then string w is accepted. Otherwise rejected”.
Similarly, we can determine whether a regular expression generates a given string.
Let AREX = {<R,w> R is a regular expression that generates string w}.
Theorem 3.
AREX is decidable language.
PROOF: The following TM P decides AREX.
P=”On input <R,w> where R is a regular expression and w is a string.
1. Convert regular expression R to equivalent NFA A by using the procedure for this
conversion.
2. Run TM N on input <A,w>.
3. If N is accepts, then string w is accepted. Otherwise rejected”.
Theorem 1, 2 and 3 illustrate that, for decidability purposes, presenting the Turing machine
with DFA, NFA, or regular expression are all equivalent because the machine is able to
convert one form to another.
Now we turn to a different kind of problem concerning finite automata: emptiness testing for
the language of a finite automaton. In the preceding three theorems we had to determine
whether a finite automaton accepts a particular string. In the next proof we must determine
whether a finite automaton accepts any string at all.
Theorem 4.
EDFA is decidable language.
PROOF: A DFA accepts some string iff reaching an accepts state from the start state by
travelling along the arrows of a DFA is possible. To Test is condition we design a TM T that
uses a marking algorithm.
T=”On input <A> where A is a DFA.
1. Mark the start state of A.
2. Repeat until no new states get marked.
3. Mark any state that has a transition coming into it from any state that is already
marked.
4. If no accept state is marked, accept; otherwise reject”.
The next theorem states that determining whether two DFAs recognize the same language is
decidable. Let
Theorem 5.
EQDFA = {<A,B>| A and B are DFAs and L(A) = L(B)}.
PROOF: we convert a new DFA C from A and B, Where C accepts only those strings that are
accepted by either a or B not by both. Thus, A and B recognize the same language, C will
accept nothing. The language of C is

This expression is some time called the symmetric different of L(A) and L(B) and illustrate in
the following figure. Here L(A)1 is the complement of L(A). The symmetric different is
useful here because L(C)=Ø iff L(A)=L(B).
We constructed C from the theorem 4 to test whether L(C) is empty. If it is empty, L(A) and
L(B) must be equal.
F=”On input <A,B>, where A and B are DFAs.
1. Construct DFA C as described.
2. Rum TM T from Theorem 4 on input <C>.
3. If T is accepts, accept. If T rejects, reject.”

FIGURE : The symmetric different of L(A) and L(B).

DECIDABLE PROBLEMS CONCERNING CFL


Here, we describe algorithms to determine whether a CFG generates a particular string and to
determine whether the language of a CFG is empty. Let
ACFG = {<G,w>| G is a CFG that generates string w}.
Theorem 6:
ACFG is a decidable language.
PROOF IDEA: For CFG G and string w, we want to determine whether G generates w. One
idea is to use G to go through all derivations to determine whether any is a derivation of w.
This idea doesn’t work, as infinitely many derivations may have to be tried. If G does not
generate w, this algorithm would never halt. This idea gives a Turing machine that is a
recognizer, but not a decider, for ACFG.
PROOF The TM S for ACFG follows.
S = “On input <G,w>, where G is a CFG and w is a string:
1. Convert G to an equivalent grammar in Chomsky normal form.
2. List all derivations with 2n−1 steps, where n is the length of w; except if n = 0, then
instead list all derivations with one step.
3. If any of these derivations generate w, accept ; if not, reject .”
Let’s turn now to the emptiness testing problem for the language of a CFG. As we did for
DFAs, we can show that the problem of determining whether a CFG generates any strings at
all is decidable. Let ECFG = {<G>| G is a CFG and L(G) = Ø}.
Theorem 7:
ECFG is a decidable language.
PROOF IDEA To find an algorithm for this problem, we might attempt to use TM S from
Theorem 6. It states that we can test whether a CFG generates some particular string w. To
determine whether L(G) =Ø, the algorithm might try going through all possible w’s, one by
one. But there are infinitely many w’s to try, so this method could end up running forever.
We need to take a different approach.
In order to determine whether the language of a grammar is empty, we need to test whether
the start variable can generate a string of terminals. The algorithm does so by solving a more
general problem. It determines for each variable whether that variable is capable of
generating a string of terminals. When the algorithm has determined that a variable can
generate some string of terminals, the algorithm keeps track of this information by placing a
mark on that variable.
First, the algorithm marks all the terminal symbols in the grammar. Then, it scans all the rules
of the grammar. If it ever finds a rule that permits some variable to be replaced by some
string of symbols, all of which are already marked, the algorithm knows that this variable can
be marked, too. The algorithm continues in this way until it cannot mark any additional
variables. The TM R implements this algorithm.
PROOF
R = “On input <G>, where G is a CFG:
1. Mark all terminal symbols in G.
2. Repeat until no new variables get marked:
3. Mark any variable A where G has a rule A U1U2 · · ·Uk and each symbol
U1, . . . ,Uk has already been marked.
4. If the start variable is not marked, accept; otherwise, reject.”
Next, we consider the problem of determining whether two context-free grammars generate
the same language. Let
EQCFG = {<G,H>| G and H are CFGs and L(G) = L(H)}.
Theorem 5 gave an algorithm that decides the analogous language EQ DFA for finite automata.
We used the decision procedure for EDFA to prove that EQDFA is decidable. Because ECFG also
is decidable, you might think that we can use a similar strategy to prove that EQ CFG is
decidable. But something is wrong with this idea! The class of context-free languages is not
closed under complementation or intersection EQCFG is not decidable. Now we show that
context-free languages are decidable by Turing machines.
Theorem 8:
Every context-free language is decidable.
PROOF IDEA Let A be a CFL. Our objective is to show that A is decidable. One (bad) idea
is to convert a PDA for A directly into a TM. That isn’t hard to do because simulating a stack
with the TM’s more versatile tape is easy. The PDA for A may be nondeterministic, but that
seems okay because we can convert it into a nondeterministic TM and we know that any
nondeterministic TM can be converted into an equivalent deterministic TM. Yet, there is a
difficulty. Some branches of the PDA’s computation may go on forever, reading and writing
the stack without ever halting. The simulating TM then would also have some non halting
branches in its computation, and so the TM would not be a decider. A different idea is
necessary. Instead, we prove this theorem with the TM S that we designed in Theorem 7 to
decide ACFG.
PROOF Let G be a CFG for A and design a TM MG that decides A. We build a copy of G
into MG. It works as follows.
MG = “On input w:
1. Run TM S on input <G,w>.
2. If this machine accepts, accept ; if it rejects, reject .”
Undecidable Language
For an undecidable language, there is no Turing Machine which accepts the language and
makes a decision for every input string w (TM can make decision for some input string
though). A decision problem P is called “undecidable” if the language L of all yes instances
to P is not decidable. Undecidable languages are not recursive languages, but sometimes,
they may be recursively enumerable languages.
Example:
 The halting problem of Turing machine
 The mortality problem
 The mortal matrix problem
 The Post correspondence problem, etc.

Turing Machine Halting problem

Input: A Turing machine and an input string w.


Problem: Does the Turing machine finish computing of the string w in a finite number of
steps? The answer must be either yes or no.
Proof: At first, we will assume that such a Turing machine exists to solve this problem and
then we will show it is contradicting itself. We will call this Turing machine as a Halting
machine that produces a ‘yes’ or ‘no’ in a finite amount of time. If the halting machine
finishes in a finite amount of time, the output comes as ‘yes’, otherwise as ‘no’. The
following is the block diagram of a Halting machine:
Now we will design an inverted halting machine (HM)’ as:
 If H returns YES, then loop forever.
 If H returns NO, then halt.

The following is the block diagram of an ‘Inverted halting machine’:

Now we will design an inverted halting machine (HM)’ as:


If H returns YES, then loop forever.

If H returns NO, then halt.


The following is the block diagram of an ‘Inverted halting machine’:
Further, a machine (HM)2 which input itself is constructed as follows:
If (HM)2 halts on input, loop forever.
Else, halt.

Here, we have got a contradiction. Hence, the halting problem is undecidable

Rice Theorem
Rice’s theorem states that, every non-trivial property of a recursively enumerable language is
undecidable.

Proof -A non-trivial property is one that is possessed by some objects of a class, but not all.
For example, being a mathematician is a property that is possessed by some humans but not
by all. Some cats are black but not all. So black colour property cannot be trivially
associated with cats.
Let χ be a non-trivial property that is not posse,ssed by all recursively enumerable
languages. This problem can be reduced to one consisting of a pair (M, w) such that L
possesses χ iff w ∈ L(M ). We take a UTM U that takes a pair (M, w); its output is yes iff χ
is possessed by L.
Since L is a recursively enumerable language, there must be a TM, ML that accepts L. Let
x be a string belonging to L. Now, we design a machine M J to decide χ as shown below:
Here U is a UTM.
UTM, U takes the pair (M, w) and checks if w ∈ L(M ). If the output is yes, then the
machine ML that accepts the string x starts and the output of the machine M J is yes. Thus
the decidability of the problem of possessing the trivial property reduces to the problem
of Lu . If the pair (M, w) ∈ Lu , then L possesses χ ; otherwise not. Since Lu is not
recursive, possession of χ by L is also not decidable.

Post Correspondent problem.


The Post Correspondence Problem (PCP), introduced by Emil Post in 1946, is an undecidable
decision problem.
Definition of PCP

Let there be two series, x series and y series of size n with same charactere set Σ with
their ith element as xi and yi, respectively; does there exist a solution that forms the same x
series and y series?
The generic solution of PCP can be written as,
xi1 xi2 xi3 xik = yi1 yi2 yi3 yik

Example 1:

Let there be two series of strings, say x series and y series as shown below:
i xi yi
1 10 101
2 01 100
3 0 10
4 100 0
5 1 010

Both X series and Y series contains 5 strings.


Let us call the strings in X
series as X substrings,
and the strings in Y series
as Y substrings.
If we concatenate X substrings x1x5x2x3x4x4x3x4,
we get 1010101001000100. If we concatenate
Y substrings y1y5y2y3y4y4y3y4, we get
1010101001000100. Let us call these strings as x
string and y string.
It can be seen that x string and y string are same.
Here we say that this instance of PCP has a solution in the form 15234434.

If we take 23,
x string is, x2x3 =010
y string is, y2y3 =10010.
Here x string and ys tring are different. Hence 23 is not a solution to this instance of PCP.
Example 2:

Find the solution to the instance of PCP given in the following table.
i xi yi
1 0 000
2 0100 01
0
3 01 1
Solution,
x2x1x1x3= 010000001
y2y1y1y3= 010000001

Hence, 2113 is a solution to this instance of PCP

Example 3:

Find why the instance of PCP given below cannot have a solution.
i xi yi
1 0 000
2 010 0100
3 01 100
4 11 110
It can be seen that for every pair, |xi| > |yi|.
So, in whatever way we concatenate the string, the length of the x string will be longer
than the corresponding y string. Thus there is no solution for this instance of PCP.

You might also like