text
stringlengths
0
8.13M
correspondence between the sets. If the one-to-one correspondence is between
a set X and a subset of the natural numbers, then it can be used to count, or
enumerate, the elements in X. Such an enumeration also provides an ordering
ofthe elements inthe set, as the following paragraphmakesexplicit in the case
of strings.
The number of elements in a set is called its cardinality. A finite set has a
cardinality which is a natural number. An infinite set, the elements of which
5As we will see, when the sets X and Y are infinite, just a denumerable subset of all
possiblefunctionsaccordingtothisdefinitionareactuallypossibletocomputebyalgorithmic
methods.
18
can be put in a one-to-one correspondence with the set N of natural numbers,
is said to have cardinality .
0
Lexicographic ordering
Itis oftenusefultobe abletoorderstringsinalexicographicorder. Thedefini-
tionis mimickedonthe orderingof wordsinthe Englishlanguage. Anexample
makes the concept clear. Suppose Σ = S ,S ,S , then the lexicographic
1 2 3
{ }
ordering of the strings is the infinite list
[ ,S ,S ,S ,S S ,S S ,S S ,S S ,S S ,S S ,...].
1 2 3 1 1 1 2 1 3 2 1 2 2 2 3
E
We can define a function lex from set of all strings Σ to the set of integers
N,
lex:Σ N,
where in particular lex( )=0.
E
Clearly,the lexicographicorderingprovidesanenumerationofthe stringsin
the language.
2.1.7 Decision procedures and Computation procedures
Itissometimesusefultodistinguishbetweenalgorithmsforcomputingvaluesof
functionsandalgorithmsforyes/nodecisions. Inthefirstcase,theobjectofthe
algorithm is to compute values for functions f : Nd N. Such an algorithm
can be called a computation procedure. Since it is possible to set up one-to-one
correspondencesbetweennaturalnumbersandstrings,computationprocedures
can also be viewed as string processing; an input string w is processed into an
output string f(w). In this case we are considering functions f :Σ Σ . But
∗ ∗
it is often natural to think of computation procedures as computing values of
numerical functions.
In the second case, the object is to decide questions like for example; Is the
numbernprime? Doesthenumberadividethenumberb? Suchquestionsdefine
properties P(n), binary relations R(a,b), or in the general case, n-ary relations
R(a ,...,a ). Algorithms for such questions are called decision procedures.
1 n
Decisionprocedures areoften formulatedinterms of languages. A language
is a set of strings constructed in some way or satisfying certain properties. The
problem is to determine for an arbitrary string over the alphabet whether it
belongs to the language or not. This is a typical decision problem, having a
yes or no answer. In fact, all decision problems can be formulated in terms of
language membership. We will return to these notions in section 2.3.4.
19
2.2 A note on the connection to everyday com-
puting
The contents of this chapter might seem remote from everyday computers and
their uses, and it is perhaps interesting to make a comment on the connection.
As already remarked, many algorithms are not meant to terminate. We could
takeawordprocessorasanexample. Awordprocessorisacomplicatedpieceof
software, which apart from presenting the user with a graphical interface, also
should respond to input from the keyboard as well as files read from storage
media. Such programs are said to be event-driven. This means that they only
perform actions when called for by request from the user, otherwise they are
idle. (Theremightbe actionslike rewritingthe screeninvokedbyotherparallel
running processes.) When the user hits a key, this triggers a computation that
results in the text stored in the memory and displayed on the screen being
altered. This can in fact be seen as a computation of a function, or better still,
asstringprocessing. Theinputisthepresenttextstored(thecodedtextreally)
together with the code for the key. The output is the new text. Depending
on what action is requested, different computations are performed on the text.
Thus the concept of a computation is very strong and in fact incorporates all
types of data processing made by digital computers.
2.3 The classical Turing machine model of com-
putation
In a mathematical oriented approach to the theory of computability the dis-
tinction between passive algorithm and active computation can easily be over-
looked. Just one example will suffice to make the point clear. Most popular
or semi-popular accounts of Turing Machines abound with animistic phrases
like reading, writing, moving etc. This conjures up the image of a magnetic
read-and-write head moving along the tape, erasing and writing information.
Exact mathematical notions can replace this suggestive but imprecise termi-
nology, one classic example of which is [16]. On the other hand, upon reading
such a mathematical account of computability, it seems that the mathematical
formulation has got rid of all reference to motion or time steps. Close scrutiny
howeverrevealsthedistinctionbetweenalgorithmandcomputationeveninthis
case. The Turing machine program is the set of instructions for the machine
together with specification how to present the machine with data and how to
read off data. This is clearly passive. However in order to actually perform the
computation inherent in the set of instructions, someone, machine or human,
has to perform the computational steps.
20
2.3.1 Informal description of Turing machines
A very good description of Turing machines can be found i Turing’s original