0% found this document useful (0 votes)
16 views3 pages

1 1 Basic Notions

Uploaded by

Alina Erkulova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

1 1 Basic Notions

Uploaded by

Alina Erkulova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Theory of Programming Zsolt Borsi

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:

N – the set of all natural numbers (including 0)


N+ – the set of all positive integers
Z – the set of all integers
L – the set of logical values
∅ – the empty set

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.

Remark: Let f : A → B be an arbitrary function (now we know that f is a special relation


that assigns a single element to every element of set A. Let a ∈ A and f (a) = {b} where
b ∈ B denotes the only element assigned to a. In this case, for the sake of simplicity, the
image f (a) can be written as the value b instead of the set {b}.

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

Definition: Let A1 , . . . , An (where n ∈ N+ ) be typevalue-sets and let v1 , . . . , vn be unique


labels (more precisely: variables) identifying the typevalue-sets. The set {v1 : a1 , . . . , vn : an }
(where ∀i ∈ [1..n] : ai ∈ Ai ) constructed from the variables and sets mentioned beforehand,
is called state.

In case a statespace contains only one component, the notation a1 can be used instead of
{v1 : a1 } to denote a state.

Definition: Let A1 , . . . , An (where n ∈ N+ ) be typevalue-sets and let v1 , . . . , vn be unique


labels (more precisely: variables) identifying the typevalue-sets. The set of all possible {v1 :
a1 , . . . , vn : an } variables (where ∀i ∈ [1..n] : ai ∈ Ai ) constructed from the variables and sets
mentioned beforehand, is called statespace and denoted by (v1 : A1 , . . . , vn : An ).

(v1 : A1 , . . . , vn : An ) ::= {v1 : a1 , . . . , vn : an } |∀i ∈ [1..n] : ai ∈ Ai

Definition: The labels (variables) of the statespace A = (v1 : A1 , . . . , vn : An ) are considered


as vi : A → Ai functions, where vi (a) = ai for any a = {v1 : a1 , . . . , vn : an } state.

Definition: Let A = (v1 : A1 , . . . , vn : An ) and B = (u1 : B1 , . . . , un : Bm ) any statespaces


(n, m ∈ N+ and m 6 n). We say that statespace B is a subspace of statespace A (B ≤ A), if
there exist an injective function ϕ : [1..m] → [1..n], where ∀i ∈ [1..m] : Bi = Aϕ(i) .

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

2. ∀a ∈ A: ∀α ∈ S(a) : |α| ≥ 1 and α1 = a

3. ∀α ∈ RS : (∀i ∈ N+ : i < |α| → αi 6= f ail)

4. ∀α ∈ RS : (|α| < ∞ → α|α| ∈ A ∪ {f ail})

You might also like