1 1 Basic Notions
1 1 Basic Notions
Basic notations
1 Sets
Informally, a set is a collection of objects, which are called the elements of the set. The
elements of a set do not certainly have a common property, except that they are elements of
the same set. For example, here is a set:
√
3
{Budapest, α, ∅, 2}
One way to define a set is by listing the elements of the set inside curly-brackets (for exam-
ple, the set of logical values: )
L ::= {igaz, hamis}
or by providing a condition (for example, the set of integer numbers that can be divided by
5 and are not greater than 100: )
{ x ∈ Z | x 6 100 ∧ 5|x }
Definition: The set [a..b] ::= { x ∈ Z | a 6 x ∧ x 6 b } is called interval (where a and b are
integer numbers). It is empty, if b > a.
Notation: The cardinality of a set H is denoted by |H|. The fact, that set H is finite, can be
expressed in this way: |H| < ∞.
Special sets:
2 Sequences
Notation: Let H ∗∗ denote the set of all finite and infinite sequences of the elements of set
H. H ∞ includes the infinite sequences; H ∗ contains the finite ones. So, H ∗∗ = H ∗ ∪ H ∞ and
H ∗ ∩ H ∞ = ∅. The length of the sequence α ∈ H ∗∗ is |α|, in case of infinite sequence this
value is denoted by ∞.
1
Theory of Programming Zsolt Borsi
3 Relations
Definition: Let A and B be arbitrary not empty sets. The Cartesian product A × B is the
set of all ordered pairs (a, b) where a ∈ A and b ∈ B:
A × B ::= { (a, b) | a ∈ A ∧ b ∈ B }
Definition: Let A and B be arbitrary not empty sets. Any subset R (including the empty
set) of A × B is called a relation.
A relation can be considered as a mapping from the set A to B. In case (x, y) ∈ R, then we
say that R assigns (or associates) y to x.
Definition: Let A and B be arbitrary not empty sets and let R ⊆ A × B be any relation. The
domain of relation R:
DR ::= { a ∈ A|∃b ∈ B : (a, b) ∈ R }
the range of relation R:
RR ::= { b ∈ B|∃a ∈ A : (a, b) ∈ R }
the image of a (where a ∈ A) by R:
R(a) ::= { b ∈ B|(a, b) ∈ R }
Definition: Let A and B arbitrary not empty sets and let R ⊆ A × B be any relation. We
say that R is deterministic, if
∀a ∈ A : |R(a)| 6 1
Deterministic relations are called functions. The function R ⊆ A × B, as a special relation,
has a particular notation: R ∈ A → B.
Notation: In case for the function f ∈ A → B it also holds, that its domain equals to set A,
then the following notation is used: f : A → B. Notice that in this case the following holds:
∀a ∈ A : |f (a)| = 1
Remark: Such f ∈ A → B functions, which does not associate exactly one single element
to every element of A (in other words, their domain is not equal to A), are called partial
functions.
4 Statespace
Problems are about data, programs also deal with data. The typevalue-set of a data is a set
containing all possible values of the given data.
2
Theory of Programming Zsolt Borsi
In case a statespace contains only one component, the notation a1 can be used instead of
{v1 : a1 } to denote a state.
5 Problem
Definition: Let A by an arbitrary statespace. Any F ⊆ A × A relation is called problem.
The definition of problem is based on our approach, where we consider the problem as a
mapping from the statespace to the same statespace. In this relation, for every element of
the statespace we determine the goal states we intend to get starting from the given element
of the statespace.
6 Program
Definition: Let A be the so-called base state space and Ā be
S the set of all states which
belong to the state spaces B whose subspace is A, i.e. Ā = B. Ā does not contain the
A≤B
∗∗
state fail. The relation S ⊆ A × (Ā ∪ {fail}) is called program over A, if
1. DS = A