text stringlengths 0 8.13M |
|---|
of our topic, whereas algorithm and programemphasizes the logical and math- |
ematical side. |
2.1.5 Alphabets, Strings and Numbers |
Numbers and strings of symbols are fundamental to computer science. Just |
as a computation can be thought of as the calculation of numerical values of |
a function, it can as well be regarded as the processing of strings of symbols. |
The equivalence follows from the fact that any finite set of finite strings of |
symbolsdrawnfromafinitealphabetcanbeputinaone-to-onecorrespondence |
4This is necessary in order to implement if < condition >then < statement > else |
<statement>,andwhile<condition>do<statement> programmingprimitives. |
16 |
with a subset of the natural numbers. Any enumeration of the strings in some |
lexicographicorderwilldo. Wewillmaketheseconceptssomewhatmoreprecise. |
Numbers |
Byanumberwemean,unlessotherwisestated,anaturalnumber,i.e. amember |
of the infinite set N = 0,1,2,... . This set can be defined inductively start- |
{ } |
ing from the number 0 and adding, in a step by step fashion, the successors. |
Informally, |
0 is a natural number, |
(cid:26)If n is a natural number, then the succesor n+1 is a natural number. |
This is not really a gooddefinition, since in writing n+1 for the successorof n |
weareinfactpresupposingthenumberstogetherwithaddition. Butitcaptures |
the idea behind the following more formal definition. |
The set N of natural numbers are defined by the clauses |
0 N |
β (2.1) |
(cid:26)n N S(n) N |
β β β |
where S(n) denotes the successor of n. |
Arithmetical operations, like addition and multiplication can be defined on |
this basis [14]. |
By Nd we denote the set of all d-tuples (n ,n ,...,n ) of numbers. |
1 2 d |
Strings and languages |
The concept of a symbol, or a token, will be taken to be intuitively given and |
not further analyzed. An alphabet is non-empty a set of symbols, generically |
denoted by Ξ£. A string (over an alphabet) results when the symbols taken |
from an alphabet are written consecutively. The order in which the symbols |
are written within the string matters. There must be no blanks or commas or |
other separators between the symbols in a string, instead, if blanks or other |
separatorsare needed they should be included among the symbols. A language |
is a set of strings. The following notation is useful to have at hand. |
The set of all strings over the alphabet Ξ£ is denoted by Ξ£ and it includes |
β |
the empty string . An equivalent term for string is word. Ξ£+ denotes the set |
E |
of strings with the empty string excluded. In some contexts, strings will be |
enclosed by β β, as is prevalent in computer programming languages. Now, a |
language is an arbitrary subset of Ξ£ . This is all we will need from the general |
β |
theory of formal languages (cf. [15]). |
Bit strings |
One particular important kind of strings are the bit strings. They are based |
on the alphabet 0,1 . A bit string is any combination of the symbols 0 and 1 |
{ } |
written without any blank separators. By the notation 0,1 k we mean a bit |
{ } |
17 |
string of length k which will also be more explicitly denoted by βb b b β. |
1 2 k |
Β·Β·Β· |
Such a string is naturally interpreted as a k-bit binary number. Then the |
corresponding base-10 representation of the binary number can be used as a |
shorthand for the string, as in the example β0101β=5. |
2.1.6 Functions |
The concept of a function is supposed to be well-known, but we record the |
basic definition here for completeness and fixing our notation. A function can |
be regarded as a mapping between two sets X and Y, taking an element x in |
X and mapping it into a unique element y in Y. This is formally written as |
f :X Y. When we want to focus on generic, or particular elements that are |
β |
connected by the mapping, we write y =f(x) or b=f(a). The element b in Y |
is called the image (under the mapping f) of the element x in X. |
A more formal definition of functions is based on the concept of a relation. |
A relation is a subset of all ordered pairs (x,y) where x X and x Y. A |
β β |
function f is a special kind of relation for which we require: if (x,y) f and |
β |
(x,z) f, then y = z. This condition expresses the uniqueness requirement, |
β |
that for each x in X there is a unique y in Y. This is the only restriction on a |
function, and consequently, the concept of a function is very general indeed.5 |
IfthefunctionisdefinedforallelementsinX,itisatotalfunction,otherwise |
it is a partial function. The elements of X for which the function is defined is |
calledthedomain ofdefinition. TheelementsofY whichareimagesofelements |
of X are called the range. |
We willalmostexclusivelyconsiderfunctions fromNd to N,from 0,1 k to |
{ } |
0,1 l, or from Ξ£ to Ξ£ . |
β β |
{ } |
Enumerations |
A function is said to be one-to-one if the image of two different elements in the |
domainaredifferent. IfeveryelementinthesetY isthe imageofanelementin |
the set X (i.e. the range of the function is the whole set Y) then the function |
is said to be onto. |
Furthermore, a total function which is both one-to-one and onto is called a |
one-to-onecorrespondence. Suchfunctionsareusefulforcomparingthenumbers |
of elements in two sets, as they as the name suggests, sets up a one-to-one |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.