Sunteți pe pagina 1din 195

Vilnius Gediminas Te

hni al University

Aleksandras KRYLOVAS
and
Eugenijus PALIOKAS

DISCRETE MATHEMATICS
Textbook

Vilnius "Te hnika" 2006

UDK 510(075.8)
Kr242

Aleksandras Krylovas, Eugenijus Paliokas. Dis rete


Mathemati s. Textbook. Vilnius: Te hnika, 2006. 195 p.
This textbook is for students of universities and other high s hools
who study dis rete mathemati s. It is the rst part of the ourse
on dis rete mathemati s.

Reviewed by Asso . Prof., Dr. A. Domarkas


and Asso . Prof., Dr. S. irba

VGTU leidyklos Te hnika 832 mokomosios


metodin
es literat
uros knyga

ISBN 9986-05-958-5

A. Krylovas, E. Paliokas, 2006



VGTU leidykla "Te hnika", 2006

Contents

Introdu tion

1. MATHEMATICAL LOGIC

1.1. INTRODUCTION . . . . . . . . . . . . . . . . .
1.1.1. Propositions . . . . . . . . . . . . . . . . .
1.1.2. Logi Operations . . . . . . . . . . . . .
1.2. PROPOSITIONAL ALGEBRA . . . . . . . . . .
1.2.1. Propositional Formulas . . . . . . . . . . .
1.2.2. Depth of Formula . . . . . . . . . . . . . .
1.3. SEMANTIC OF FORMULAS . . . . . . . . . . .
1.3.1. Tautologies . . . . . . . . . . . . . . . . .
1.3.2. Truth Tables . . . . . . . . . . . . . . . .
1.3.3. Laws of Logi . . . . . . . . . . . . . . . .
1.3.4. Proofs of Tautologies . . . . . . . . . . .
1.4. CALCULATION OF PROPOSITIONS . . . . . .
1.4.1. Logi Inferen es . . . . . . . . . . . . . . .
1.4.2. Axiomati Method . . . . . . . . . . . . .
1.5. BOOLEAN FUNCTIONS . . . . . . . . . . . . .
1.5.1. Denition of Boolean Fun tions . . . . . .
1.5.2. Formulas of Fun tions . . . . . . . . . . .
1.5.3. Dual Fun tions . . . . . . . . . . . . . . .
1.5.4. Normal Propositional Forms . . . . . . . .
1.5.5. Complete Systems of Fun tions . . . . . .
1.6. PREDICATE LOGIC . . . . . . . . . . . . . . .
1.6.1. Quantiers and Predi ates . . . . . . . . .
1.6.2. Terms and Formulas . . . . . . . . . . .
1.6.3. Constrained and Un onstrained Variables
1.6.4. Laws of Predi ate Cal ulus . . . . . . . .

2. SET THEORY AND COMBINATORICS

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

2.1. SET THEORY . . . . . . . . . . . . . . . . . . . .


2.1.1. Con ept of A Set . . . . . . . . . . . . . .
3

9
9
10
12
12
13
15
15
17
17
19
20
20
22
24
24
25
27
29
32
36
36
38
39
40

42
42
42

2.2.
2.3.
2.4.

2.5.
2.6.

2.7.

2.1.2. Denition of Sets from Predi ates . . . . . .


2.1.3. Permutations . . . . . . . . . . . . . . . . .
2.1.4. Subsets . . . . . . . . . . . . . . . . . . . .
2.1.5. Combinations and Arrangements . . . . . .
SET OPERATIONS . . . . . . . . . . . . . . . . .
2.2.1. Denition of Set Operations . . . . . . . . .
2.2.2. Properties of Set Operations . . . . . . .
COMBINATORIAL NUMBERS . . . . . . . . . .
2.3.1. Partitions . . . . . . . . . . . . . . . . . . .
2.3.2. Cy les . . . . . . . . . . . . . . . . . . . . .
COMBINATORIAL PRINCIPLES . . . . . . . . .
2.4.1. Multipli ation of Combinations . . . . . . .
2.4.2. Addition Rule for Disjoint Sets . . . . . . .
2.4.3. Addition Rule for Arbitrary Sets . . . . .
GENERATING FUNCTIONS . . . . . . . . . . . .
2.5.1. Properties of Generating Fun tions . . . . .
2.5.2. Fibona i Numbers . . . . . . . . . . . . . .
LINEAR RECURRENT EQUATIONS . . . . . . .
2.6.1. Linear Homogeneous Re urrent Equations .
2.6.2. Linear Nonhomogeneous Re urrent Equations . . . . . . . . . . . . . . . . . . . . . .
ASYMPTOTICS . . . . . . . . . . . . . . . . . . .
2.7.1. Con ept of Asymptoti . . . . . . . . . . .
2.7.2. Samples of Asymptoti al Fun tions . . . . .

3. RELATIONS

3.1. BASIC CONCEPTS . . . . . . . . . . .


3.1.1. Samples of Relations . . . . . . .
3.1.2. Binary Relations . . . . . . . .
3.1.3. Properties of Binary Relations
3.1.4. Set Operations on Relations .
3.2. EQUIVALENCE RELATIONS . . . . .

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

42
44
45
46
50
50
52
53
53
56
60
60
63
63
65
67
69
71
71
73
74
74
76

78
78
78
79
81
83
85

3.2.1. Denition and Samples of an Equivalen e


Relation . . . . . . . . . . . . . . . . . . . .
3.2.2. Equivalen e Classes . . . . . . . . . . . . .
3.3. ORDER RELATIONS . . . . . . . . . . . . . . . .
3.3.1. Denitions and Examples of Order Relations . . . . . . . . . . . . . . . . . . . . . .
3.3.2. Ordered Sets . . . . . . . . . . . . . . . . .
3.4. CLOSURES OF RELATIONS . . . . . . . . . . . .
3.4.1. Transitive Closure . . . . . . . . . . . . . .
3.4.2. Reexive Closure . . . . . . . . . . . . . .
3.5. FUNCTIONS . . . . . . . . . . . . . . . . . . . . .
3.5.1. Inje tion, Surje tion, Bije tion . . . . . . .
3.5.2. PERMUTATIONS . . . . . . . . . . . . . .

4. INFORMATION CODING

4.1. BASIC CONCEPTS . . . . . . . . . . . . .


4.1.1. Sour e of Information . . . . . . . .
4.1.2. Code Con ept . . . . . . . . . . . .
4.2. METHODS OF CODING . . . . . . . . . .
4.2.1. Prote tion against the Distortion of
mation . . . . . . . . . . . . . . . . .
4.2.2. Data Compression . . . . . . . . . .
4.2.3. Se re y of Information . . . . . . . .
4.3. FEW SAMPLES OF CODES . . . . . . . .
4.3.1. Code of Two of Five . . . . . . . . .
4.3.2. Morse Code . . . . . . . . . . . . . .
4.3.3. Caeser Code . . . . . . . . . . . . . .
4.3.4. Book Numeration . . . . . . . . . . .
4.3.5. European Arti le Numeration . . .

5. GRAPH THEORY

. . . .
. . . .
. . . .
. . . .
Infor. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .

85
85
86
86
87
88
88
89
90
90
91

94
94
94
94
95

95
98
100
101
101
102
103
103
105

106

5.1. BASIC NOTIONS . . . . . . . . . . . . . . . . . . 106


5.1.1. Multi-graph . . . . . . . . . . . . . . . . . . 106
5.1.2. Dire ted Graph . . . . . . . . . . . . . . . . 107
5

5.2.

5.3.

5.4.

5.5.

5.6.

5.1.3. Undire ted Graph . . . . . . . . . .


5.1.4. Order of Vertex . . . . . . . . . . . .
ISOMORPHIC GRAPHS . . . . . . . . . .
5.2.1. Con ept of Isomorphism . . . . . . .
5.2.2. Labeled and Unlabeled Graphs . . .
5.2.3. Invariants . . . . . . . . . . . . . . .
5.2.4. Number of Graphs . . . . . . . . . .
5.2.5. Planar Graphs . . . . . . . . . . . .
GRAPH CONNECTIVITY . . . . . . . . .
5.3.1. Walks and Cir uits . . . . . . . . . .
5.3.2. Conne ted Components of a Graph .
5.3.3. Conne tivity Relation . . . . . . . .
5.3.4. The Longest Path . . . . . . . . . .
5.3.5. Metri Chara teristi s of a Graph
GRAPH OPERATIONS . . . . . . . . . . .
5.4.1. Graph Union and Graph Interse tion
5.4.2. Subgraph. Graph Complement . . .
5.4.3. Cy li al Sum of Graphs . . . . . . .
5.4.4. Vertex Removal . . . . . . . . . . . .
5.4.5. Edge Removal . . . . . . . . . . . . .
5.4.6. Superposing Verti es . . . . . . . . .
SEPARABILITY OF GRAPHS . . . . . . .
5.5.1. Arti ulation Points . . . . . . . . . .
5.5.2. Graph Blo ks . . . . . . . . . . . . .
5.5.3. Trees and Forests . . . . . . . . . . .
5.5.4. A Separating Set and a Cut . . . . .
GRAPH CYCLES . . . . . . . . . . . . . .
5.6.1. Seven Bridges of Knigsberg . . . . .
5.6.2. Eulerian Graphs . . . . . . . . . . .
5.6.3. Fleury's Algorithm . . . . . . . . . .
5.6.4. Hamiltonian Graph . . . . . . . . . .
5.6.5. Edge Graph . . . . . . . . . . . . . .
5.6.6. Independent Graph Cy les . . . . . .
6

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

107
109
112
112
113
114
115
117
118
118
120
122
123
125
127
127
128
129
130
131
131
132
132
133
134
136
137
137
138
142
144
145
147

5.6.7. Graph Cy lomati Number . . . . . . . . .


5.7. INDEPENDENT AND DOMINATING SETS OF
A GRAPH . . . . . . . . . . . . . . . . . . . . . . .
5.7.1. Independent Subset . . . . . . . . . . . . .
5.7.2. Dominating Set of a Graph . . . . . . . . .
5.7.3. Graph Kernel . . . . . . . . . . . . . . . . .
5.8. GRAPH MATRICES . . . . . . . . . . . . . . . . .
5.8.1. Adja en y Matrix . . . . . . . . . . . . . . .
5.8.2. In iden e Matrix . . . . . . . . . . . . . . .
5.9. DIRECTED GRAPHS . . . . . . . . . . . . . . . .
5.9.1. Semi-walk . . . . . . . . . . . . . . . . . . .
5.9.2. Strong and Weak Conne tivity . . . . . . .
5.9.3. Flow network . . . . . . . . . . . . . . . . .

6. COMBINATORIAL ALGORITHMS

6.1. CONCEPT OF AN ALGORITHM . . . . . . .


6.1.1. Few Samples of Algorithms . . . . . . .
6.1.2. Eu lidian Algorithm . . . . . . . . . . .
6.1.3. Turing's Ma hine . . . . . . . . . . . . .
6.1.4. Question of Solvability . . . . . . . . . .
6.1.5. Brute For e Algorithms . . . . . . . . .
6.2. DIMENSION OF A PROBLEM . . . . . . . .
6.2.1. Classes of Problems . . . . . . . . . . .
6.2.2. Various Informational Models of Graphs
6.3. COMPLEXITY OF AN ALGORITHM . . . .
6.3.1. Con ept of Algorithm Complexity . . .
6.3.2. Polynomial-Time Algorithms . . . . . .
6.4. HARD PROBLEMS . . . . . . . . . . . . . . .
6.4.1. NP Problems . . . . . . . . . . . . . . .
6.4.2. Investigation of NP Problems . . . . . .
6.4.3. Samples of NPC problems . . . . . . . .

Referen es

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

150
153
153
156
159
160
160
163
166
166
168
169

174
174
174
175
176
178
179
180
180
181
183
183
185
187
187
189
191

193
7

Introdu tion

There exist a lot of modern bran hes of mathemati s whi h are outside al ulus: mathemati al logi , graph theory, set theory, ombinatori s, oding theory, theory of omputing, et . They are widely
applied, among the others, in omputer s ien e, ele troni banking, business, informational se urity, et .
Mathemati s in these bran hes is alled dis rete mathemati s or,
sometimes, nite mathemati s. We an say that nite mathemati s
overs the on epts of dis rete mathemati s for business, when dis rete mathemati s itself emphasizes its ideas for omputer s ien e
majors. "Dis rete" here is used as the opposite of " ontinuous".
We an determine dis rete mathemati s as the study of mathemati al stru tures whi h are fundamentally dis rete. Most of the
obje ts studied in dis rete mathemati s are ountable sets.
Mathemati s annot be done without proofs. We give proofs of
the theorems we state wherever possible. We must understand
that no one is able to learn mathemati s without solving the problems. Thus the reader is advised to answer the questions stated in
the text and only after that to go to the next hapter.
Authors express their gratitude to Asso iated Professors S.irba
and A.Domarkas for their attention and useful remarks.

1.

MATHEMATICAL LOGIC

1.1. INTRODUCTION
1.1.1. Propositions

Logi is the study and analysis of a valid argument, the reasoning


tool by whi h we draw valid inferen es from given fa ts or inferen es. In other words, subje ts of logi are the laws of thinking
that guarantee both the regularity and onsisten y. One of initial,
basi and main on epts of logi is the on ept of proposition .
DEFINITIONS

A proposition is a statement to whi h we an assign a truth value


of either true, or false, but not both.
For example, the statement "2>5" is false, so it is a proposition,
but de larative senten e " = " is not, be ause it ould be true
or false depending on the value of and . Senten es of this type
are alled predi ates and we will study them later (see 1.6.1.).
The ontent of a ertain proposition is not important for us now:
the subje t of mathemati al logi is the validity of argumentation
as well as of dierent forms of on lusions. Only values of propositions are signi ant for us: either they are true or false.
We all them logi onstants and denote by "TRUE", "FALSE",
"T", "F", "t", "f", "1", "0" . . .. Propositions are alled logi variables and are denoted by symbols A, B, . . . , c, d, e, . . . , f1, h2 , . . ..

Problems

De ide whi h of the following are propositions:


1. 127 is an even integer.
2. All triangles have three sides.
3. If x = 0.3, then x > x.
9

4.
5.

x + 3 < x + 4.
I always lie.

1.1.2. Logi Operations


Various symbols and formulas are used in mathemati al logi .
New propositions are built using logi operations .
Suppose that x, y are arbitrary propositions. Below we will dene
the main logi operations that we will use later.

DEFINITIONS

Unary 1 logi operation  negation  is dened as "not x","opposite

statement to x" and is denoted by symbol x. Truth value of variable x is hanged then to opposite value: 0 = 1, 1 = 0.
Binary logi operations are:
disjun tion denoted by ("x or y"): proposition x y is true
i2 at least one of propositions x or y is true;
onjun tion denoted by & ("x and y"): proposition x & y is true
i both propositions x and y are true;
impli ation denoted by ("if x then y", or "x implies y"):
proposition x y is false, if x is true and y is false, otherwise it is true;
equivalen y denoted by ("x if and only if y", "x i y", "x is
equivalent to y "): proposition x y is true when both x and y
are true, otherwise it is false.
Let's put all values of these propositions whi h we have dened
into the table:
1

A unary operation is an operation over one logi al variable (operand),

when a binary operation is an operation over two variables.

Let's agree to use abbreviation "i" instead of "if and only if".

10

x y

x&y

x y

x y

0
0
1
1

0
1
0
1

1
1
0
0

0
1
1
1

0
0
0
1

1
1
0
1

1
0
0
1

Remarks
1. Sometimes

disjun tion is alled logi al addition and onjun tion - logi al multipli ation . If 0 and 1 are possible values
of x and y , then x&y = xy , x y = x y xy . Logi al
operation is alled ex lusive disjun tion or ex lusive or :
0 0 = 1 1 = 0, 0 1 = 1 0 = 1.
2. Impli ation an be dened using the following inferen e rules :
a) a true premise implies a true on lusion ;
b) a false on lusion is implied by a false premise only.
3. Logi operations sometimes are denoted by other symbols:
, (negation), ( onjun tion), , (impli ation), , ,
(equivalen e).

Problems
1. Negate the following propositions:

a) Some birds have feathers;


b) Cat isn't bla k;
) John is smart or Simas isn't tall.
2. Let P denote the statement "John has passed mathemati s
with mark 10", Q  "John is happy", R  "John has a job". Write
out the following propositions:
a) P Q; b) Q (P Q); ) (Q P ); d) P (Q R); e)
P (Q R).
3. Suppose P be true, Q, R  both false. Determine the truth of
propositions in Problem 2. Do the same assuming P, Q to be false,
11

R  true.

1.2. PROPOSITIONAL ALGEBRA


1.2.1. Propositional Formulas
As we have mentioned above, the regularity of logi al formulas
(or logi al forms) does not depend on the ontent of these forms3 .
In the ase when we are not interested in exa t values of logi al
formulas and treat these forms as some formal algebrai expressions, we use the name of propositional variables instead of the
name logi al variables as well as the name of propositional onne tives instead of the name logi al operations and the name of
propositional formulas instead of the name logi al formulas.

DEFINITION

An alphabet of propositional algebra is a set


A={a, b, . . . , A, B, . . . , x1 , . . . , Y2 , . . . , , &, , , , (, )}.
Elements of this set A  propositional variables, propositional onne tives and bra kets  are said to be letters of an alphabet. Any
nite sequen es of letters of alphabet A are said to be words over
alphabet A.
We will all some spe ial type of these words propositional formulas (forms) over alphabet A. Let's agree that propositional
formulas satisfy the following rules:
(1) a, b, . . . , A, B, . . . , x1 , , Y2, are formulas;
(2) if A is a formula, then (A) is also a formula;
(3) if A and B are formulas, then (A&B), (A B), (A B),
(A B) are also formulas;
(4) there are no other formulas ex ept thoses whi h are dened
a ording to (1), (2) and (3) .
3

These formulas an be dened in a quite dierent way using an axiomati

approa h. Look 1.4.2.

12

Examples

Word z1 = A&B is not a formula be ause it doesn't satisfy rules


(1)- (4).
Word F = ((p)&((x y) z)) is a formula be ause variable p
is a formula a ording to rule (1) , word F1 = (p) is a formula
a ording to rule (2) and variables x, y and z are formulas a ording to rule (1) .
Rule (3) implies that both F2 = (x y) and F3 = (F2 z) are
formulas.
Finally, rule (3) implies that F = (F1 &F3 ) is a formula.
Formulas that are in luded into other formulas are alled subformulas .
Consequently, formulas F1 , F2 ir F3 are sub-formulas of formula
F.

Problems
1. Let P mean

the proposition "The earth is round", Q  "All


birds sing", R  "The Nemunas is a river". Write out propositions:
a) The earth is round or all birds sing;
b) Some birds do not sing and the Nemunas is a river;
) This is not the ase when all birds sing and the earth is round;
d) Either the Nemunas is a river or it is the ase when both the
earth is round and birds sing;
e) The earth is round and this is not the ase when either all birds
sing or the Nemunas is a river.
2. Find all subformulas of formulas that orrespond to the propositions of Problem 1.

1.2.2. Depth of Formula


Let's dene set F of all possible formulas.
13

DEFINITION

F0 = a, b, . . . , A, B, . . . , x1 , , Y2 , ;
Fn+1 = Fn {(x) : x Fn }
{(x&y) : x, y Fn } {(x y) : x, y Fn }
{(x
S y) : x, y Fn } {(x y) : x, y Fn };
F=
Fn .
n=0,1,...

Number n0 = min n is alled the


F Fn

depth of formula F .

Consequently, any elements of set F0 (i.e., the propositional variables) are formulas of zero depth. Set F1 onsists of all propositional variables and of all formulas that in lude any of them and
exa tly one of propositional onne tives. Elements of set F2 are
formulas from set F1 or formulas that are got from these formulas
using exa tly one propositional onne tive.
Hen e, of the previous example F = ((p)&((x y) z)), both
sub-formulas F1 and F2 are formulas of depth 1, sub-formula F3
has depth 2 and the depth of formula F is 3.
Word z1 = A&B , as we remember, does not satisfy rules (1)(4) and, onsequently, it is not a formula. We an improve this
situation by introdu ing additional bra kets: z1 = (A&(B)).
On the other hand, the meaning of these bra kets is evident, so
there is no dire t ne essity to use them. Let us skip any external
bra kets . Then z1 = A&(B) is a formula.
The agreement about the priority of operations is even more
important. Conne tives , &, , , are ordered a ording to
the de reasing priority, i.e. the negation () is a onne tive of the
highest priority when the equivalen y () is an operation of the
lowest priority. Thus, if A&(B) is a formula, then A&B also
14

is a formula. If (A&B) C is a formula, then A&B C is a


formula too.
The introdu tion of the priority of onne tives an not repla e the
usage of bra kets at all.
For example, formula A B&C is equivalent to the se ond of the
following two essentially dierent formulas: x = (A B)&C and
y = A (B&C). We would not be able to distinguish them if they
were written without bra kets.

DEFINITION

Formulas without bra kets that are written in the style of "connective
variable" are alled prex formulas when formulas of type "variables
connectives" - postx formulas. Usual formulas with bra kets are
alled inx formulas.
Both prex and postx styles allow us to write any formulas without bra kets. For example,
x = & ABC = ABC &,
y = &ABC = ABC&,
F = p&(x y z) = &p xyz .
Let's agree, however, to

use the inx style in this book.

Problems

Determine the depth of formulas:


a) P (Q R); b) P (Q R); ) (P Q) (P R.

1.3. SEMANTIC OF FORMULAS


1.3.1. Tautologies
Suppose that X = (x1 , x2 , . . . , xn ) are logi al variables and F (X)
is an arbitrary logi al formula.
15

DEFINITIONS

Any element of set { = (1 , 2 , . . . , n )} (where k = 0 or k =


1, k = 1...n - are values of variable xk ) of all available values of
logi al variables X is alled the interpretation of these variables.
Formula F is said to be exe utable over interpretation i F () =
1.
For example, formula x&y is exe utable over interpretation (1, 1).
Formula F is said to be a tautology i (if and only if) it is always
true .
In other words, a tautology is exe utable over arbitrary interpretation.
Formula F is a ontradi tion , i it is always false.
Thus, F () = 0 over arbitrary interpretation .
Obviously, F is a ontradi tion, i its negation F is a tautology.
Formulas F and G are equivalent formulas i F () = G() with
arbitrary interpretation .
Consequently, formulas F ir G are equivalent formulas i formula
(F ) (G) is a tautology.

Problems
1. Determine whether ea h of the following is a tautology, a on-

tradi tion or a ontingen y:


a) (P Q) (P Q); b) (P (P Q)) Q; ) (P Q)
(P Q).
2. Determine in whi h of the following pairs forms are equivalent:
a) P Q and P Q; b) P Q and P Q; ) P (Q R) and
(P Q) R; d) P Q R and (P Q) (P R.

16

1.3.2. Truth Tables


A truth table is a table of all possible logi al values of propositional formula. Using a truth table we an determine the truth
value of a propositional form when truth values of all their variables are known.

Example.

The values of formula f (x1 , x2 , x3 ) = (x1 x2 ) & (x1 x3 )


and of subformulas x1 , x2 , x1 x2 , x1 x3 you an see in
the table:

x1

x2

x3

x1

x2

x1 x2

x1 x3

f (x1 , x2 , x3 )

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
1
1
1
0
0
0
0

1
1
0
0
1
1
0
0

1
1
1
1
1
1
0
0

0
1
0
1
1
1
1
1

0
1
0
1
1
1
0
0

Problems

Write out truth tables for ea h of the following propositions:


a) P (Q R); b) (P Q) Q; ) (P Q) (R Q); d)
P Q R.

1.3.3. Laws of Logi


Tautologies are alled laws
nd the main of them 4 .
4

Please note that equivalen y

of logi .

In the table below you an

is a logi operation (a logi al onne tive).

Also keep in mind that truth values of a tautology equal


interpretation of its logi variables.

17

over arbitrary

Name

Formula

ommutativity

(x & y) (y & x)

of onjun tion
ommutativity
of disjun tion
asso iativity
of onjun tion
asso iativity
of disjun tion

(x y) (y x)
((x & y) & z) (x & (y & z))
((x y) z) (x (y z))

third impossible

x x

law
double

x x

negation
ontradi tion

hypotheti al
syllogism
disjun tive
syllogism
distributivity

idempotentum

ontraposition
de Morgan's
laws

x&x
((x y) & (y z)) (x z)
((x y) & y) x
(x & (y z)) ((x & y) (x & z))
(x (y & z)) ((x y) & (x z))
(x x) x
(x & x) x
(x y) (y x)

x & y (x y)
(x y) (x & y)

Obviously, all laws an be proved by examining their truth tables.


Let's prove the rst de Morgan's law 5 :
5

Augustus de Morgan (1806  1871)  S ot h mathemati ian and logi ian.

18

x&y

x&y

x y

0
0
1
1

0
1
0
1

1
1
0
0

1
0
1
0

0
0
0
1

1
1
1
0

1
1
1
0

x&y

(x y)
1
1
1
1

Problems
1. Prove the main logi laws using their truth tables.
2. Prove hypotheti al syllogism, applying ommutativity, asso iativity, distributivity and de Morgan's laws.
3. Negate P Q without using symbols and .
4. Using the main logi laws, prove that P Q is equivalent to
Q P.

1.3.4. Proofs of Tautologies


The method of truth tables is ee tive for the proof of logi laws,
however, it is not e ient. In many ases the ontradi tion
method leads us to the nal result faster. The method of equivalent rearrangements is also useful.

Exer ises
1. Prove by ontradi tion
tautology.

that formula F = (A (B A)) is a

Solution. Let's solve equation F = 0. An impli ation has zero


value i (if and only if) 1 0. Consequently, A = 1, (B A) = 0.
Then (B 1) = 0, that is impossible for any B . Therefore, equation F = 0 has no solutions, thus F = 1 for any values of variables.
Consequently, F is a tautology.
2. Using equivalent rearrangements, prove that
(A & B) (A B) is a tautology.
19

Solution. By double negation, (A & B) (A & B). By de Morgan's laws, (A & B) A B . Thus, (A B) (A B) 1.

Problems

Prove these tautologies:


(A B) (A B).
(A B) (A B), use the ontradi tion method.
(A B) (A B), use de Morgan's and ontradi tion laws.
(A B) (A B) (A B).
(A B) (A B).

1.
2.
3.
4.
5.

1.4. CALCULATION OF PROPOSITIONS


1.4.1. Logi Inferen es
Now we will formulate one ex lusive rule whi h we will use to derive new logi al laws. After that(look 1.4.2.)we will study the main
initial laws - axioms of logi - that will give us the basis for the
proof of arbitrary laws of logi .

DEFINITIONS

Logi al formula y is said to be logi al inferen e of formulas


x1 , x2 , . . . , xn i impli ation (x1 &x2 & . . . &xn ) y is a tautology.
For example, if x is a tautology, then x y is also a tautology.
This fa t an be written as the following

x
.
x y
We say that

is a valid argument .

x
x y
20

inferen e rule :

In the table below we an nd the main inferen e rules:


(1)

x (x y)

x
x y

(2)

(x & y) x

x&y
x

(3)

((x y) & x) y

x y, x
y

(4)

((x y) & y) x

x y, y
.
x

(5)

(((x y) & (z w)) &

(x y)&(z w), x z
yw

(x z)) (y w)
(6)

(x y) (y x)

xy
y x

(7)

(x y) & (y z))

xy , y z
x z

(x z)

x y, y
x
We assign the following names to these rules: (1)  addition ; (2)
 simpli ation ; (3)  modus ponens ; (4)  modus tollens ; (5) 
onstru tive dilemma ; (6)  ontraposition ; (7)  hypotheti al syllogism ; (8)  disjun tive syllogism.
(8)

((x y) & y) x

Problems
1. Write symboli ally and determine the validity of the following
arguments:

21

a) if my friend is razy (P), he likes mathemati s (R). My friend


likes mathemati s. Therefore, my friend is razy.
b) If Jo looks smart (P), he will be ele ted (Q). If Jo attends inema
(R), he looks smart (P). Either Jo attends inema or he will go to
the meeting (O). Jo annot go to the meeting. Thus Jo will be
ele ted.
) Either Peter will laugh (A) or Marry will sing (B). If Marry
sings, then Willy dan es (C) and the river runs fast (D). The river
is not running fast. Thus Peter will laugh.
(x y) z, z w, w y
2. Prove
.
x

1.4.2. Axiomati Method


Formal mathemati al theories T usually are dened by using some
basi rules. Now we will determine these rules and after that we
will onsider the al ulus of propositions L as an example of
su h kind of mathemati al theories.
Formulas. Symbols of theory L ( onsequently, an alphabet of
theory ) are dened. Finite sequen es of these symbols are alled
words of theory. Symbols of formal theory of al ulation of propositions were dened earlier in hapter 1.2.1.. We remind you that
they were letters, logi al operations and bra kets. Now we add one
additional symbol - the omma (, ) to them that will be used in
inferen e rules. The rules that allow us to re ognize formulas between all available words over a given alphabet were dened before
(look. 1.2.1.). Consequently, we an on lude that formulas of
the theory are dened.
Axioms. Some formulas of the theory are pla ed in the position
of axioms. There an be various axiomati bases to be used in
propositional al ulus. One of possible axiomati systems of

22

the theory of propositional logi is 6 :


(A1)
(A (B A)),
(A2) (A (B C)) ((A B) (A C)),
(A3)
(B A) ((B A) B)),
where A, B, C are arbitrary formulas.
Modus Ponens. The inferen e rules, that allow us to derive new
formulas, must be dened. In the theory of propositional logi
we will use only one inferen e rule - modus ponens : B is dire t
inferen e of A and A B :

A, A B
.
B

DEFINITION

Any formulas of propositional al ulus that are derived from axioms (A1)  (A3) using modus ponens inferen e rule are said to be
theorems of propositional al ulus and are denoted by symbols
|= or ).

THEOREM. A A.

Proof. Let's substitute B = (A A) and C = A into(A2):

(1)
(A ((A A) A)) ((A (A A)) (A A)).
Substituting B = (A A) into (A1), we get
(2)
(A ((A A) A)).
Now we apply modus ponens to the formulas (1) and (2):
(3)
(((A (A A)) (A A)).
Let B = A, then (A1) implies
(4)
(A (A A)).
Finally, (3), (4) and modus ponens lead to the statement of theorem:
(5)
(A A).
6

Please note again that here we onsider only one of possible formalizations

of the theory of propositional logi .

23

Remarks

Let's noti e that only two logi al operations - negation () and


impli ation () - are used in axioms (A1)  (A2). Thus, on the
one hand, formulas of propositional al ulus an be written without using onjun tion, disjun tion and equivalen y. On the other
hand, these operations an be dened as follows:
(D1)
(A & B) ((A B));
(D2)
(A B) ((A) B));
(D3) (A B) ((A B) & (B A)).

Theorem A A of formal theory L of propositional al ulus,


whi h was just proved, is a tautology. In general, any theorem of
theory L is a tautology. Opposite impli ation is also valid: if some
formula is a tautology then it is a theorem of theory L. It means
that theory L is a omplete theory. Another important property
of the theory of propositional al ulus L is its onsisten y : there
are no formulas A in L su h that both A and A would be theorems
(tautologies) of L.

Problems
1. Negate P Q not using symbols and .
2. Negate (P Q) R) not using symbol .
3. Write out all logi al onne tives using only negation
jun tion.

and dis-

1.5. BOOLEAN FUNCTIONS


1.5.1. Denition of Boolean Fun tions
Assume that the range of values of independent variables x1 , x2 , . . . , xn
and of fun tion f (x1 , x2 , . . . , xn ) is 0, 1. We all variables and fun tions of these type respe tively Boolean 7 variables and Boolean
7

George Boole (1815  1864)  British mathemati ian and logi ian.

24

fun tions . Let's onsider Boolean fun tion of two variables f (x1, x2 ).

Sin e ea h variable of the fun tion and the fun tion itself have exa tly two available values (0 or 1), there exist exa tly 16 really
dierent Boolean fun tions of two independent variables. Let's
write out them into the table below.

x1
0
0
1
1
x1
0
0
1
1

x2
0
1
0
1
x2
0
1
0
1

f0
0
0
0
0
f8
0
0
0
1

f1
1
0
0
0
f9
1
0
0
1

f2
0
1
0
0
f10
0
1
0
1

f3
1
1
0
0
f11
1
1
0
1

f4
0
0
1
0
f12
0
0
1
1

f5
1
0
1
0
f13
1
0
1
1

f6
0
1
1
0
f14
0
1
1
1

f7
1
1
1
0
f15
1
1
1
1

1.5.2. Formulas of Fun tions


Please note that Boolean fun tions f0 and f15 from the table above
are in fa t onstant fun tions: f0 0, f15 1. Fun tion f10 = x2
does not depend on variable x1 and f12 = x1 does not depend on
x2 .

DEFINITIONS

Variable xj of Boolean fun tion f (x1 , x2 , . . . , xn ) (0 6 j 6 n) is


alled a  titious variable of that fun tion i

f (. . . , xj1 , 0, xj+1 , . . .) = f (. . . , xj1 , 1, xj+1 , . . .),


xk {0, 1}, k 6= j, k = 1, 2, ..., n.

Variable that is not a  titious variable is said to be an essential


variable of a fun tion.
Thus, fun tions f0 and f15 both have no essential variables. Essential variables of fun tions f10 and f12 are x2 and x1 while x1
and x2 are  titious ones.
25

Fun tions f3 , f5 , f8 , f9 , f11 , f13 , f14 an be written using only one


propositional onne tive:

f3
x1

f5
x2

f8
x1 &x2

f9
x1 x2

f11
x1 x2

f13
x2 x1

f14
x1 x2

But we ne essarily need more than one onne tive in the formulas
of fun tions f1 ,f2 ,f4 ,f6 ,f7 :

f1

f2

f4

f6

f7

x1 x2

x2 x1

x1 x2

(x1 x2 )&(x1 x2 )

x1 &x2

Fun tion named ex lusive or and denoted by the symbol was


dened in hapter 1.1.2.. It is easy to prove an equivalen y

(x1 x2 ) ((x1 x2 )&(x1 x2 )).


omparing the truth tables of both fun tions. Below we use symbol
(=) between dierent expressions of the same Boolean fun tion.
Then
f6 (x1 , x2 ) = x1 x2 = (x1 x2 )&(x1 x2 ).

DEFINITIONS

Fun tion f1 is alled Peir e's 8 arrow and is denoted by symbol


:
f1 (x1 , x2 ) = x1 x2 = x1 x2 = x1 &x2 .

Fun tion f7 is denoted by symbol | and is alled


stroke :
f7 (x1 , x2 ) = x1 | x2 = x1 &x2 = x1 x2 .

Sheer's

Consequently, we have two new and very important, as we will see


soon, logi al onne tives: and |.
8

Charles Peir e (1839  1914)  Ameri an mathemati ian, philosopher and

logi ian.

Henry Sheer (1883  1964)  Ameri an logi ian.

26

THEOREM

Any Boolean fun tion an be written using only one logi al onne tive: either or |.
Proof. It is easy to see that the negation an be expressed in the
following way: x = (x|x). Then (x&y) = ((x|y) | (x|y)). Applying
these formulas and de Morgan's laws, we get the expressions for
disjun tion using only Sheer's stroke. Then it is easy to get a
formula for equivalen y using only Sheer's stroke. Applying evident equivalen y (x y) = (x y) to these formulas, we re eive
the expressions of the main logi operations that are written using
only logi al onne tive - Peir e's arrow.

Problems
1. Find formulas for Boolean fun tions of two variables, dierent

from the formulas given in the table.


Find expli it formulas of all logi al onne tives using only
a) Sheer's stroke;
b) Peir e's arrow.
3. Find the number of all available Boolean fun tions:
a) of 3 variables;
b) of n variables, n N .

2.

1.5.3. Dual Fun tions


DEFINITION

Fun tion f1 (x1 , x2 , . . . , xn ) is said to be a


tion f2 (x1 , x2 , . . . , xn ) i

dual fun tion to fun -

f1 (x1 , x2 , . . . , xn ) = f 2 (x1 , x2 , . . . , xn ).
Let's note that

f2 (x1 , x2 , . . . , xn ) = f 2 (x1 , x2 , . . . , xn ) = f 1 (x1 , x2 , . . . , xn ).


27

It is easy to see that, if fun tion f1 is a dual fun tion to fun tion
f2 , then f2 is a dual fun tion to f1 . For instan e, if f1 (x, y) = x y
and f2 (x, y) = x&y , we have the following equations:

f 1 (x, y) = x y = x&y = x & y = f2 (x, y),


f 2 (x, y) = x&y = x y = x y = f1 (x, y).

We will denote the


f (x1 , . . . , xn ):

dual fun tion

to fun tion f (x1 , . . . , xn ) by

f (x1 , . . . , xn ) = f (x1 , . . . , xn ).
Then

f1 (x, y) = f2 (x, y), f2 (x, y) = f1 (x, y).

DEFINITION

Fun tion f (x1 , . . . , xn ) is said to be a

self-dual fun tion i

f (x1 , . . . , xn ) = f (x1 , . . . , xn ).
For example, f (x, y, z) = x&y x&z y&z is a self-dual fun tion.

Problems
1. Find the

simplest formula of above fun tion f (x, y, z) when

z = x y.
Write out the simplest formulas of dual fun tions to all Boolean
fun tions of two variables.
3. Determine all self-dual fun tions of two variables.
4. Find the dual fun tion to fun tion (A B) (A A). Find the
simplest formulas for both the original and the dual fun tions.
5. Determine whether (((A B) A)|C) is a self-dual fun tion or
it is not.

2.

28

1.5.4. Normal Propositional Forms


Boolean logi al fun tion of two independent variables an be written in the following expanded form:

f (x1 , x2 ) = x1 &f (1, x2 ) x1 &f (0, x2 ).


Applying the same idea with respe t to the se ond variable we
derive the disjun tive normal form of fun tion f (x1 , x2 ):

x1 &x2 &f (1, 1) x1 &x2 &f (1, 0) x1 &x2 &f (0, 1) x1 &x2 &f (0, 0).
Let's agree to skip the onjun tion symbol & and the terms of type
f ( ) = 0.

Exer ise

Let's derive the disjun tive normal form of the fun tion given by
the following truth table:

x1

x2

x3

f (x1 , x2 , x3 )

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

0
1
0
0
1
1
0
0

Solution. There are exa tly three interpretations of the argument,

under whi h this fun tion takes the non-zero value: f (0, 0, 1),
f (1, 0, 0) and f (1, 0, 1).
Therefore, the disjun tive normal form of this fun tion is:

f (x1 , x2 , x3 ) = x1 x2 x3 x1 x2 x3 x1 x2 x3 .
29

DEFINITION
The

power of Boolean variable is:


(
x, = 0
x =
x, = 1.

Consequently, xx = 1 and xy = 0 if x 6= y . Let's note that


x = x = x .

THEOREM

Arbitrary Boolean fun tion (ex ept f = const = 0) has its perfe t

disjun tive normal form :

f (x1 , x2 , . . . , xn ) =

f (1 ,2 ,...,n )=1

x1 1 x1 2 xnn .

(Without proof.)
In an arbitrary disjun tive term of a perfe t disjun tive normal
form we an see all independent variables x1 , x2 , . . . , xn presented.
Applying the following equivalen y rearrangements:

x xy = x(x y) = x, xy xy = x, x xy = x

any disjun tive normal form an be transformed into its perfe t


disjun tive normal form.

Example
xy x z = xyz xyz xyz x y z.

DEFINITION
A

perfe t onjun tive normal form is dened by analogy:


f (x1 , x2 , . . . , xn ) =

f (1 ,2 ,...,n )=1

30

(x1 1 x2 2 xnn ) .

THEOREM

Any Boolean fun tion f (x1 , x2 , . . . , xn ) (ex ept the onstant fun tion f 1) has its perfe t onjun tive form.
Proof. Applying the denition of a dual fun tion to a perfe t disjun tive normal form of fun tion f (x1 , x2 , . . . , xn ), we have:

f (x1 , x2 , . . . , xn ) = f (x1 , x2 , . . . , xn ) =
_
=
x1 1 &x2 2 & &xnn =
f (1 ,2 ,...,n )=1

f (1 ,2 ,...,n )=1

(x1 1 x2 2 xnn ) =

f (1 ,2 ,...,n )=0



x1 1 x2 2 xnn .

For example, a perfe t onjun tive normal form of fun tion f (x1 , x2 , x3 )
given by the truth table on page 29 is

(x1 x2 x3 )&(x1 x2 x3 )&(x1 x2 x3 )&(x1 x2 x3 )&(x1 x2 x3 ).


Let's onsider the fun tion f (x1 , x2 , x3 ):

x1

x2

x3

f (x1 , x2 , x3 )

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
0
1
0
1
1
1
0
31

Problems

Find both perfe t onjun tive and disjun tive normal forms of
fun tions:
1. f (x1 , x2 , x3 ) given by the above truth table.
2. xz yxz xy.

1.5.5. Complete Systems of Fun tions


DEFINITIONS

(T0 ) We say that Boolean fun tion f (x1 , x2 , . . . , xn )


zero , i
f (0, 0, . . . , 0) = 0.
We denote the lass of fun tions that

preserves

preserves zero by T0 .

(T1 ) By analogy we dene the lass of Boolean fun tions that


serves unit :
T1 = {f : f (1, 1, . . . , 1) = 1}.

pre-

Su h fun tions as f (x) = x, g(x, y) = x y , h(x, y) = x&y belong


to both lasses T0 and T1 , but fun tion w(x) = x does not belong
to any of them.
(T ) We denote the lass of all

self-dual

fun tions by T :

T = {f : f (x1 , x2 , . . . , xn ) = f (x1 , x2 , . . . , xn )}.


Representatives of self-dual fun tions are fun tions f (x) = x and
w(x) = x.
(T6) Let = (1 , 2 , . . . , n ) and = (1 , 2 , . . . , n ) be two multidimensional Boolean variables (any their omponent is a Boolean
variable itself). By denition, 4 ( or < ), i j 6 j for
32

any j = 1, 2, . . . , n. Please keep in mind that there exist multidimensional Boolean variables and that satisfy no one of
onditions 4 or < . For example, (0, 0) 4 (0, 1) 4 (1, 1),
but neither (0, 1) 4 (1, 0) nor (0, 1) < (1, 0).
Let's dene the lass of monotoni fun tions:

T6 = {f : 4 f () 6 f ()}.
For example, fun tions g(x, y) = x y and h(x, y) = x&y both are
monotoni fun tions.
(TL )The lass of

linear fun tions is dened as below:

TL = {f : f (x1 , x2 , . . . , xn ) = c0 c1 &x1 c2 &x2 cn &xn },

where cj {0, 1} are alled oe ients ( Boolean onstants ) of


the linear Boolean fun tion. Fun tions f (x) = x and w(x) = x are
linear fun tions, be ause
f (x) = x = 0 1&x, w(x) = x = x 1 = 1 1&x.

Exer ise

Prove that fun tion g(x, y) = x y


fun tion.
Solution. Really, if otherwise, then

is not a linear

Boolean

g(x, y) = x y = c0 c1 &x c2 &y.


where c0 , c1 and c2 are ertain Boolean onstants. It is easy to
understand that

g(0, 0) = 0 0 = 0 = c0 c1 &0 c2 &0 = c0 ,


g(0, 1) = 0 1 = 1 = 0 c1 &0 c2 &1 = c2 ,

g(1, 0) = 1 0 = 1 = 0 c1 &1 c2 &0 = c1 .


33

These equations give us the value of all oe ients:


c0 = 0, c1 = 1, c2 = 1. But g(1, 1) = 1 1 = 1 6= 1 1 = 0, thus
x y 6= x y . We got a ontradi tion. Consequently, our premise
was false, thereby the proof is nished.
Suppose that Boolean fun tions

f (x1 , x2 , . . . , xn ), f1 (x1 , x2 , . . . , xn ),
f2 (x1 , x2 , . . . , xn ), . . ., fn (x1 , x2 , . . . , xn )
all belong to the same lass: T0 , or T1 , or T , or T6, or TL .
It is easy to prove that then the omposite fun tion

f (f1 (x1 , x2 , . . . , xn ), f2 (x1 , x2 , . . . , xn ), . . . , fn (x1 , x2 , . . . , xn ))


belongs to the same lass. We name this property saying that
lasses of Boolean fun tions T0 , T1 , T , T6, TL are losed lasses
of fun tions.

DEFINITION

System F = {f1 , f2 , . . . , fm } is said to be a omplete system of


fun tions, i arbitrary Boolean fun tion an be expressed using
only the fun tions of this system.
We know that any Boolean fun tion has its normal disjun tive and
normal onjun tive forms. Consequently, the system of Boolean
fun tions {, &, } is a omplete system of fun tions. Applying
de Morgan's laws, the onjun tion an be expressed using only
negation and disjun tion, as well, as disjun tion an be expressed
only in the terms of negation and onjun tion. Consequently, we
have other two omplete systems of Boolean fun tions: {, } and
{, &}. Please remember that we already know other three omplete systems of fun tions: {, } (see 1.4.2.), {|}, {} (see 1.5.2.).
34

Theorem of Post 10 helps us to determine whereas the system of


fun tions is a omplete system or it is not.

THEOREM

System of Boolean fun tions F is omplete i (if and only if) for
any lass T0 , T1 , T , T6, TL there exists a fun tion of system
F that does not belong to this lass, i.e. there is at least one
fun tion that is not a fun tion preserving zero, is not a fun tion
preserving unit, et .

( Without proof.)

Exer ise

Let's prove that system {0, 1, &, } is a omplete system of fun tions.
Solution. Boolean onstants 0 and 1 do not belong to lasses T1 and
T0 and are not self-dual fun tions. Fun tion is not a monotoni
fun tion, fun tion & is not a linear fun tion. Thus, all onditions
of Post theorem are satised and, onsequently, the given system
of fun tions is a omplete system.

Problems
1. Determine, to whi h of T0 , T1 , T , T6, TL belongs:

a) arbitrary Boolean fun tion of two variables;


b) fun tion ((x y) (y z)) y ;
) fun tion ((x|y) z) x.
2. Prove that {|, } is a omplete system of fun tions.
3. Determine whether {, } is a omplete system of fun tions
or it is not.
10

Emil Leon Post (1897  1954)  Ameri an mathemati ian and logi ian.

35

1.6. PREDICATE LOGIC


1.6.1. Quantiers and Predi ates
Let's introdu e two new logi operations named as existential
(denoted by ) and universal () quantiers . Existential quantier tells us that a ertain obje t exists: p() (we say "there
is su h that the property p" is satised). Universal quantier
pres ribes that property p is a ommon property for obje ts :
p() (we read "for any property p" is satised).
We have mentioned (see 1.1.1.) that the statement " = " is not a
proposition be ause it an be false as well as it an be true depending on the value of and . If the study of this type of statements
is anyway ne essary for us, we need to spe ify the nature of its
variables , : are they numbers, matri es, fun tions or something
else? Variables of this kind are alled predi ate variables or simply variables and are denoted by x, y, z, . . . , x1 , y2 , . . .. We will
denote values of these variables by symbols , , . . . , 1 , 2 , . . .

DEFINITION

Fun tion P (x1 , x2 , . . . , xn ) is said to be a predi ate (n-pla e


predi ate ) i over arbitrary feasible interpretation 1 , 2 , . . . , n
of variables x1 , x2 , . . . , xn statement P (1 , 2 , . . . , n ) is a proposition.

For example, if x and y are real numbers, we have the following predi ates: P (x, y) = x2 > y, G(x) = sin x > cos x,
R(y) = y 2 = ey . Parti ularly, P (1, 0) is true and G(0) is a false
proposition. Proposition R() takes true value when satises
equation 2 e = 1.

DEFINITION
By

universe of dis ourse U we understand some nonempty set


36

of values, in whi h predi ate variables may assume their value.


For instan e, if U = Z, then P (x, y) = x y = 12 is a two-pla e
predi ate. If x = 4 is xed, then P (4, y) = 4 y = 12 is a onepla e predi ate. It is easy to see that P (4, 1) is false while P (4, 3)
is a true proposition.

DEFINITION

When we spe ify the value for a variable, we say that we bind
variable . Variables that are not bound are said to be free .

A predi ate be omes a proposition only after ea h of its variables


has been bound.

Quantiers and predi ates are used in logi al formulas. Even we

an get propositions with predi ates and quantiers inside of them


(we mean that the value of these statements (propositions) does
not depend on the value of predi ate variables that are ontained
inside the statements).
For example, xyP (x, y) and xG(x) are true propositions and
yR(y) is false proposition.

Problems
1. Let U = R, P (x) = x2 0, Q(x) = 3 x > 10.

Determine
the truth of predi ates xP (x), xP (x), xQ(x), xQ(x).
2. Let U = Z. Determine the truth of:
a) xyP (x, y) when P (x, y) = x + y = 0;
b) xyP (x, y) when P (x, y) = x y = 0;
) xyP (x, y) when P (x, y) = x y = 1;
d) xyP (x, y) when P (x, y) = x y > 0.
3. Let U = R, P (x, y, z) = x + y = z. Determine the truth of:
a) xyzP (x, y, z); b) xyzP (x, y, z); ) zxyP (x, y, z).
37

1.6.2. Terms and Formulas

Predi ate logi

an be built by analogy with the propositional


logi : an alphabet, formulas, axioms and inferen e rules an be
dened. Here we restri t our attention to the rst two questions.

When operating with predi ate variables we need to formalize the


investigation of expressions that we are studying. Let's denote
the permissible expressions of predi ate value and of onstants by
f, g, . . . , f1 , g2 , . . . and let's all them fun tional letters . They
an be, for example, arithmeti operations or trigonometri fun tions. Hereafter we will study any available expressions ontaining
fun tional letters.

DEFINITIONS

Terms are any expressions that satisfy the following rules:

(a) any onstant or a variable is a term by denition;


(b) if f is a fun tional letter and t1 , t2 , . . . , tn are terms, then
f (t1 , t2 , . . . , tn ) is a term;
( ) any term an be got using rules (a), (b) (i.e., there are no terms
that are not omposed a ording to these rules).
An alphabet of predi ate logi is dened as a set, the elements
of whi h are:
1) logi operations: , &, , , ;
2) bra kets () and the omma (,);
3) quantiers: , ;
4) variables;
5) onstants;
6) fun tional letters;
7) predi ates.
38

If t1 , t2 , . . . , tn are terms and P is a predi ate, then P (t1 , t2 , . . . , tn )


is alled an elementary formula .

Formulas of predi ate al ulus


rules :

are dened by the following

(a) elementary formulas are formulas (of predi ate al ulus);


(b) if A and B are formulas and x is a variable, then

(A), (A&B), (A B), (A B), (A B), (xA), (xA)


all are formulas;
( ) there are no other formulas (i.e., all available formulas are
omposed a ording to (a) and (b) rules).

1.6.3. Constrained and Un onstrained Variables


DEFINITION

input of a variable into a formula is determined by the


symbol of a variable and by the number of position of this
The

variable in this formula.

Example

In formula P (x, z) z(Q(y, z) y = z) we see:


unique input of variable x;
two inputs of variable y ;
three inputs of variable z .
By analogy with propositional algebra we an dene (see 1.2.1.)
sub-formulas of predi ate algebra . In the last formula we an
see sub-formulas y = z, Q(y, z), Q(y, z) y = z , et .

DEFINITIONS

An input of variable x into formula F is free , i x does not belong


to any sub-formula of F , that begins with x or x. Otherwise,
an input of variable x in F is onstrained . A variable is alled
39

un onstrained variable of formula F , i it has at least one


free input into F . A formula is said to be a losed formula , i
an

it has no un onstrained variables.

Problems
1. Find sub-formulas of formula

zyzP (x, y, z) zy(Q(y, z) (x y = z)) (z x).


2. Determine the onstrained and the un onstrained variables of
formula in problem 1.

1.6.4. Laws of Predi ate Cal ulus


Here we give the main laws of predi ate al ulus. Everyone is able
to verify them omparing the value of left- and right-side predi ates
over available interpretations of their variables.

xP (x) xP (x)
xP (x) xP (x)
xP (x) x P (x)
xP (x) x P (x)
x(P1 (x)&P2 (x)) xP1 (x)&xP2 (x)
x(P1 (x) P2 (x)) xP1 (x) xP2 (x)
xyP (x, y) yxP (x, y)
xyP (x, y) yxP (x, y)
x(P (x)&Y ) xP (x)&Y
x(P (x) Y ) xP (x) Y
x(P (x)&Y ) xP (x)&Y
x(P (x) Y ) xP (x) Y
40

(xP1 (x) xP2 (x)) x(P1 (x) P2 (x))


(xP1 (x)&xP2 (x)) (xP1 (x)&xP2 (x))

Problems
1. Negate the

following predi ates in a way that the symbol of


negation (of type A) does not appear outside the square bra kets:
a) x[x2 > 0];
b) x[x 10 = 1];
c)xy[x + y = 2];
d) xy[x > y x2 > y 2 ].
2. Determine whether the following predi ates are equivalent or
they are not:
a) (P (x) Q(x)) and (xP (x)) (xQ(x));
b) (P (x) Q(x)) and (xP (x)) (xQ(x));
) (P (x) Q(x)) and (xP (x)) (xQ(x));
d) (P (x) Q(x)) and (xP (x)) (xQ(x)).

41

2.

SET THEORY AND COMBINATORICS

2.1. SET THEORY


2.1.1. Con ept of A Set
One of the basi on epts of modern mathemati s is the on ept
of a set . George Cantor11 treated a set on ept to be lear by
intuition . Under this understanding, a set is totality (or whole,
or sum) of its elements . The elements of a set an be anything:
numbers, people, letters of the alphabet, other sets, and so on.
Sets are onventionally denoted by apital letters, A, B, C, et .
The fa t that a is an element of set A is denoted by a A. If y
isn't an element of this set, we write y
/ A or yA.

Examples

A = {a1 , a2 , . . . , an };
N = {1, 2, 3, . . .}  a set of positive integers;
P = {2, 3, 5, 7, 11, 13, 17, 19, 23, . . .}  a set of primary numbers;
L = {n N : n = 2k, k = 1, 2, . . .}  a set of even positive
integers;
C = {{1, 2}, {1}, {2}};
D = {N}.

2.1.2. Denition of Sets from Predi ates


As we have learned from above examples of sets, sets an be nite
(A, C , D ) or innite (N, P, L). Sets an play a role of elements
of other sets (for example, elements of sets C and D are sets). A
set an be dened by listing all its elements (like in the ase of sets
A, C and D) or by pres ribing its ertain property (N, P, L).
11

George Cantor (1845  1918)  German mathemati ian.

42

Russel's 12 paradox refers to the in orre tness of the se ond type

denition of a set (when we dene a set de laring ertain property


of its elements) . Let's denote set by Y the elements of whi h are
all available sets X that are not themselves elements:

Y = {X : X
/ X}.
Let's try to answer a question: is Y Y or not? On the one
hand, if Y Y , then Y
/ Y a ording to the denition of Y .
On the other hand, if Y
/ Y , then Y Y for the same reason.
Consequently, we are not able to get a satisfa tory answer to this
question.
Trying to avoid ontradi tions of this type, the on ept of universal set 13 U an be introdu ed and set P is dened by de laring a
ertain property p(x) of its elements x. Thus, set P an be dened
from the predi ate p(x):

P = {x U : p(x)}.
If there are no elements x U that satisfy property p(x), then P
has no elements. This set is alled an empty set and is denoted
by symbol .
In Fig 1. you see a universal set U and sets A, B , C , D . Su h
pi tures are alled Euler's 14 or Venn's 15 diagrams .
12

Bertrand Arthur William Russel (1872  1970)  British mathemati ian,

logi ian and philosopher.

13

Universal set an depend on a parti ular problem (or appli ation).

For

instan e, if we are studying the properties of positive integers, the role of


universal set

an be played by the set of rational numbers, or by the set of

real numbers and even by set of omplex numbers.

14

Leonhard Euler (1707  1783)  Swiss mathemati ian, me hani ian and

physi ist.

15

John Venn (1834  1923)  British logi ian.

43

Fig 1. Universal set U and sets A,B ,C ,D

Problems

Choose a universal set and dene from predi ates:


The set of even integers;
The set {1, 5, 9, 13, ...};
The set of real positive numbers;
The set of rational fun tions;
The set of integrable on (, ) fun tions.

1.
2.
3.
4.
5.

2.1.3. Permutations
DEFINITIONS

The ardinality of set A equals to the number of elements in the


ase of a nite set and is denoted by |A|: || = 0, |{a1 , a2 , . . . , an }| =
n. We say that two innite sets have the same ardinality ,
i (if and only if) there is a bije tion 16 from one to the other.
16

"One-to-one" orresponden e. More pre ise denition of the bije tion you

an nd in 3.5.1..

44

In ase when |A| = n is a su iently small number, it is possible


to name and then to list all the elements of A. Noti e, please that
the order of listing the elements doesn't matter. For instan e, set
{1, 2, 3} an be written in six dierent ways:

{1, 2, 3} = {1, 3, 2} = {2, 1, 3} = {2, 3, 1} = {3, 1, 2} = {3, 2, 1}.

DEFINITION

These dierent re ordings of set elements are alled permutations

of n elements .

In general, the elements of the set whi h ontains n elements an


be ordered in
n! = 1 2 (n 1) n
ways17 . In other words, the number of permutations of n elements
is n!. Consequently, an arbitrary nite set A an be expressed in
|A|! dierent ways by de laring its elements.

Problems
1. In how many ways an 8 workers be assigned to 8 jobs?
2. In how many ways an 10 persons be seated around the round
table?

2.1.4. Subsets
DEFINITION

Set A is a subset of set B , i any element of A is an element of


B . We write A B or B A.
In ase when sets are dened from predi ates A = {x U : a(x)}
17

We read: "

 fa torial".

45

and B = {x U : b(x)}, the subset A B an be dened as


below:
(A B) (x a(x) b(x)).

Then for any set B we have B . Really, be ause set A = has


no elements, formula x a(x) b(x) implies a(x) = const = 0,
thus impli ation 0 b(x) is valid with arbitrary predi ate b(x).
By analogy, A A, be ause a(x) a(x) has true value independently on the value of a(x) 18 .

DEFINITION
(A = B) (a(x) b(x)).

This denition an be written as here:

(A = B) (A B) & (B A).

Example

Set A = {0, 1, {0, 1}} has three elements: 0 A, 1 A, {0, 1} A


and eight subsets:
, {0}, {1}, {{0, 1}}, {0, 1}, {0, {0, 1}}, {1, {0, 1}}, {0, 1, {0, 1}}.

Problem

Find the number of all subsets of set {1, 2, 3, 4, 5} and write out
these subsets.

2.1.5. Combinations and Arrangements


Let's ount the subsets of nite set A = {a1 , a2 , . . . , an }.
One of them has no elements: .
There are n subsets ontaining exa tly one element n:
18

{a1 }, {a2 }, . . . , {an }.


Additional symbols

notation

XY

X Y, Y X

means the so alled

sometimes are dened.

proper
46

subset:

In this ase

X Y, X 6= Y, X 6= .

Fig 2. Sets A, B , C satisfy A B , C B , C A


There are Cn2 =

n(n 1)
subsets, ontaining 2 elements ea h:
2!

{a1 , a2 }, {a1 , a3 }, . . . , {a1 , an }, . . . , {an1 , an }.


The number of subsets, ontaining k elements ea h, k N, k n,
is:

Cnk =

n!
(n k + 1) (n k + 2) (n 1) n
=
.
(n k)! k!
k!

It is easy to prove it using the prin iple of mathemati al indu tion.

DEFINITION

Value Cnk is alled the

number of ombinations


of k elements


given n. It also an be denoted


Let's noti e that

Cn0 =

n
.
k

 
 
n
n
= Cnn =
= 1.
0
n
47

Consequently, set A has Cn0 + Cn1 + Cn2 + + Cnn subsets. We


will nd this value applying a well-known Newton's 19 formula
of power of binomial :

(x + y)n =

n
X

Cnk xk y nk .

k=0

This formula gives us our value when x = y = 1:


Thus, the number of all subsets of A is 2n .

DEFINITION

n
P

Cnk = 2n .

k=0

A set of all subsets of set A = {a1 , a2 , . . . , an } is alled a


set of A and is denoted by

power

2A = {, {a1 }, {a2 }, . . . , {a1 , a2 }, . . . , {a1 , a2 , a3 }, , A}.


Consequently, we have got a beautiful formula

|2A | = 2|A| .
Sometimes the order of ertain k elements drawn from set A =
{a1 , a2 , . . . , an } k is signi ant for us. As we remember, the subset
of A, made of these k elements, an be re orded in k! ways.

DEFINITION

Ordered olle tions of k elements, that are drawn from a set with
n elements, are alled arrangements of k elements given n
elements . Their number is denoted by Akn .
Then:

Akn = k!Cnk =
19

n!
= (n k + 1) (n k + 2) (n 1) n.
(n k)!

Isaak Newton (1643  1727)  British physi ian and mathemati ian.

48

Let's noti e that Ann = n! is a number of permutations of n elements.

Exer ises
1. Let's write

all arrangements of two elements that are drawn


from set A = {a, b, c}.
Solution. They are: (a, b), (b, a), (a, c), (c, a), (b, c), (c, b). Their
3!
= 2 3 = 6.
number is A23 =
(3 2)!
2. Let's ount three-striped ags that ould be made of materials
of seven olors (all strips are horizontal and of equal size).
Solution. It is lear that this problem is equivalent to the following
one: in how many ways an we draw three elements ( olors) given
seven (order of drawing is important)? Thus, the wanted number
is the number of arrangements of three elements given seven:

A37 =

7!
7!
=
= 5 6 7 = 210.
(7 3)!
4!

Problems
1. Find the

number of dierent bridge-hands (bridge-hand onsists of 4 ards given 52 ards).


2. In a oded telegram letters are arranged in groups of 5 letters,
alled words. Find the number of words, ontaining ea h letter
on e in one word.
3. Of a lot of 10 items 2 are defe tive. Find the number of:
a) dierent samples of four;
b) dierent samples of four ontaining no defe ts;
) dierent samples of four ontaining two defe ts.

49

2.2. SET OPERATIONS


2.2.1. Denition of Set Operations
Assume that sets A and B are dened by predi ates a(x), b(x):

A = {x U : a(x)}, B = {x U : b(x)}.

DEFINITIONS

The union of sets A and B is the set that ontains all elements
of A and B , but nothing else. We denote it by A B .
If sets A and B are dened from predi ates a(x) and b(x), the
union of sets A and B an be dened as follows:

A B = {x U : a(x) b(x)}.

The interse tion of sets A and B is the set that ontains all
elements of A that also belong to B , but no other elements. Of
ourse, we an dene this set interse tion as the set of all elements
of B that also belong to A. Set interse tion is denoted by A B
and dened from predi ates as below:

A B = {x U : a(x) & b(x)}.

Example

Assuming A = {1, 2, 3} and B = {2, 3, 4}, A B = {1, 2, 3, 4} and


A B = {2, 3}.

DEFINITION

The relative omplement of set B in set A, also known as the


set dieren e of A and B , is the set of elements in A, but not in

B:

A \ B = {x U : x A & x
/ B} = {x U : a(x) & b(x)}.
50

Fig 3. Union A B of sets A and B

Fig 4. Interse tion A B of sets A and B


51

Example

Given A = {1, 2, 3} and B = {2, 3, 4}, A\B = {1} and B\A = {4}.
Please noti e that

A \ B 6= B \ A.

All set operations that were dened earlier are binary operations
be ause ea h one of them has two inputs of arguments (argument
sets). Now we will dene a unary set operation - the omplement of a set.

DEFINITION

The omplement A of set A is the relative omplement of A in


the universal set U :

A = U \ A = {x U : x
/ A} = {x U : a(x)}.
The set omplement sometimes is alled the
ment of a set.

Problems
1. Write out

absolute omple-

the relative omplements of set N in sets Z and Q


(the set of rational numbers) by predi ates.
2. Let A be any nite set. What an you say about 2A \ A, A \ 2A ,
A 2A and A 2A ?
3. When A B = A B ?

2.2.2. Properties of Set Operations


Basi properties of set operations are:
52

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

AB = BA
AB = BA
(A B) C = A (B C)
(A B) C = A (B C)
A (B C) = (A B) (A C)
A (B C) = (A B) (A C)
AB = AB
AB = AB
AA = A
AA = A
A=A
AU =A
AA=U
AA=

A =A

ommutative
laws
asso iative
laws
distributive
laws
de Morgan's
laws
idempotentum
laws

U  universal set

double negation law

These laws an be proved using predi ates. Let's prove, for example, the 10'th formula:
A A = {x U : a(x)&a(x)} = {x U : a(x)} = A.

Problems
1. Prove distributive and de Morgan's laws.
2. Let given predi ates p(x), q(x), r(x) and the universal set U ,

sets A, B and C be dened by: A = {x U : p(x)},


B = {x U : q(x)}, C = {x U : p(x) q(x)}.
Express C in terms of A and B .

2.3. COMBINATORIAL NUMBERS


2.3.1. Partitions
DEFINITIONS

Assume that all subsets B1 , B2 , ..., Bk , where (Bj A), satisfy


onditions:
53

1) Bj 6= ;
2) Bi Bj = , when i 6= j ;
k
S
3)
Bj = A.
j=1

Then {B1 , B2 , ..., Bk } is said to be a partition of


Bj , j = 1, ..., k are alled blo ks of this partition .

set

A. Sets

Simply, a set partition of a set A is a olle tion of disjoint subsets


of A whose union is A.

Examples
1. Let A = {1, 2, 3}.

Then B1 , B2 , where B1 = {1, 2} and B2 = 3


is one of available two-blo ks-partitions of set B .
2. Sets B1 = {1, 2} and B2 = {2, 3} an't be blo ks of the same
partition of set A be ause they do not satisfy ondition 2).
3. {B1 , B2 }, where B1 = {1} and B2 = {2}, also is not a partition
of A be ause ondition 3) is not satised.
4. Set B1 = {3, 4} is not a blo k of any partition of set A be ause
it is not a subset of A.
5. Set {1, 2, 3, 4} has seven two-blo ks-partitions:

{{1, 2, 3}, {4}}, {{1, 2, 4}, {3}}, {{1, 3, 4}, {2}},


{{2, 3, 4}, {1}}, {{1, 2}, {3, 4}}, {{1, 3}, {2, 4}}, {{1, 4}, {2, 3}}.

DEFINITION

The number of all available partitions of a nite set A (|A| = n),


whi h ontains exa tly k blo ks ea h, is alled Stirling's 20 number of the se ond kind and is denoted by S(n, k).
20

James Stirling (1692  1770)  S ottish mathemati ian.

54

The denition implies that S(n, k) = 0 when k > n and


S(n, n) = 1. Let's agree that S(0, 0) = 1.

Stirling's numbers of the se ond kind S(n, k)

n
0
1
2
3
4
5
6
7
8
9

k
4

1
0
0
0
0
0
0
0
0
0

1
1
1
1
1
1
1
1
1

1
3
7
15
31
63
127
255

1
6
25
90
301
966
3025

1
10
65
350
1701
7770

1
15
140
1050
6951

1
21
266
2646

1
28
462

1
36

THEOREM

Stirling's numbers of the se ond kind satisfy equation21

S(n, k) = S(n 1, k 1) + kS(n 1, k).

Proof. Suppose that S is the set of all available k-blo ks-partitions


of set A = {1, 2, . . . , n}. Let's denote the subset of S , an arbitrary
element of whi h (a partition of A) ontains blo k {n}, by S1 and
the relative omplement of set S1 in set S  by S2 . Then S1 S2 =
and S1 S2 = S . The equation |S1 | = S(n 1, k 1) is evident
and |S2 | = kS(n 1, k) is valid be ause any partition of A that is
an element of S2 an be got nding the proper k-blo ks-partition
of set {1, 2, . . . , n 1} and after adding element n to any blo k of
21

Equations of this type are alled re urrent equations (see 2.6.).

55

that partition. Thus,

S(n, k) = |S| = |S1 | + |S2 | = S(n 1, k 1) + kS(n 1, k).

DEFINITION

The number of all available partitions of set A (|A| = n) is alled


n
P
Bell's22 number : B(n) = S(n, k), B(0) = 1.
k=0

Bell's numbers Bn

n
0
1
2
3
4
5
6
7

n
1
1
2
5
15
52
203
877

8
9
10
11
12
13
14
15

4140
21147
115975
678570
4213597
27644437
190899322
1382958545

Problems
1. Write out all 4 - blo ks partitions of set {1, 2, 3, 4,
2. Write out all available partitions of set {a, b, c, d}.

5}.

2.3.2. Cy les
Let A, B and C be verti es of a regular triangle. Let's read their
names lo kwise in the triangle. We an get, for instan e, two
dierent triangles (A, B, C) and (A, C, B). Any triangle an be
22

Eri Temple Bell (1893  1960)  Ameri an mathemati ian.

56

obtained turning one of these two triangles around their enters (if
only the enumeration of verti es is important). Then the re ordings of a triangle vertex set elements

(A, B, C), (C, A, B), (B, C, A)


are equivalent from this point of view.

DEFINITION
Set

is alled a

{(A, B, C), (C, A, B), (B, C, A)}

y le of set {A, B, C}.

Another y le of this set is

{(A, C, B), (C, B, A), (B, A, C)}.


Sets
and

{(a, b, c, d), (d, a, b, c), (c, d, a, b), (b, c, d, a)}


{(a, b, d, c), (b, d, c, a), (d, c, a, b), (c, a, b, d)}

are dierent y les of set {a, b, c, d}.

Let's agree that a y le an be represented by its arbitrary element. Thus, the last y le an be re orded as (a, b, d, c).
Set {a} has only one y le {(a)}. Set {a, b} has only a y le

{(a, b), (b, a)}.


As we have learned earlier, set {a, b, c}, has two y les.
You an see all available y les of {a, b, c, d} represented in Fig 5.
Given set {a, b, c, d}, exa tly eleven pairs of y les an be ompounded using the elements of this set:
57

Fig 5. All y les of set {a, b, c, d}

((a, b, c), (d)), ((a, c, b), (d)), ((a, b, d), (c)), ((a, d, b), (c)),
((a, c, d), (b)), ((a, d, c), (b)), ((b, c, d), (a)), ((b, d, c), (a)),
((a, b), (c, d)), ((a, c), (b, d)), ((a, d), (b, c)).

DEFINITION

Stirling's numbers of the rst kind

s(n, k), where k, n


N {0}, given s(n, n) = 1 for n and s(n, 0) = 0 for n =
6 0 are
dened by the equations
s(n, k) = s(n 1, k 1) (n 1)s(n 1, k), k < n.

THEOREM

Given n elements, k y les an be omposed in |s(n, k)| ways.

(Without proof.)

We remember that there are exa tly 11 pairs of y les of set of four
elements. Really, |s(4, 2)| = s(4, 2) = 11.
58

Stirling's numbers of the rst kind s(n, k)

n
0
1
2
3
4
5
6
7

1
0
0
0
0
0
0
0

1
1
2
6
24
120
720

1
3
11
50
274
1764

k
3

1
6
35
225
1624

1
10
85
735

1
15
175

1
21

Exer ise

Find the number of repartitions of 10 pen ils of 10 dierent olors


to 10 pen il- ases under the ondition that some pen il- ases an
be empty.
Solution. 10 pen ils an be put to 1 ase in S(10, 1) = 1 ways, to
2 ases - in S(10, 2) = 511 ways, et . Thus, the answer is:
S(10, 2) + ... + S(10, 10) = 115975.

Problems
1. In how many

ways an seven post- ards be put into ve envelopes, if some envelopes are allowed to stay empty?
2. Eight s hool-friends are pretending to be students of three universities. Find the number of all available out omes for them.
3. In how many ways 6 persons an be seated around 3 round
tables under ondition that tables order doesn't matter?
4. In how many ways 6 persons an be divided to 3 groups?

59

2.4. COMBINATORIAL PRINCIPLES


2.4.1. Multipli ation of Combinations
DEFINITION

Let A = {a1 , a2 , . . . , an } and B = {b1 , b2 , . . . , bm }. Set

A B = {(ai , bj ), i = 1, 2, . . . , n, j = 1, 2, . . . , m}

is said to be a Cartesian 23 produ t of sets A and B .


A ording to the rule of multipli ation of ombinations there
an be n m available pairs of elements (a, b) if element a has n
and b has m available values.
Consequently,
|A B| = n m = |A| |B|.

Example

Let's assign any element of set A = {a, b, c} to one of digits


1, 5, 7, 8. All possible assignments of set A an be represented
as elements of set
A B = {(a, 1), (a, 5), (a, 7), (a, 8), (b, 1), (b, 5), (b, 7), (b, 8), (c, 1),
(c, 5), (c, 7), (c, 8)}.
We see that |A B| = 12 = 3 4 = |A| |B|.

DEFINITION

A B C = {(a, b, c) : a A, b B, c C},
A B C D = {(a, b, c, d) : a A, b B, c C, d D},
et .

Exer ise

How many four-digital even numbers an be omposed of digits


0, 1, 2, 3, 7, 8?
23

Ren Des artes (1596  1650)  Fren h philosopher and mathemati ian

60

Solution. 0 an't be the rst digit, thus it must be drawn from set

1, 2, 3, 7, 8. The se ond and the third digits have six possible values
ea h. The omposed number must be even, thus the fourth digit
must be drawn from set 0, 2, 8. Consequently, there are 5 6 6 3 =
540 dierent possible even numbers of wanted type.

DEFINITION

A1 = A,
A2 = A A,
A3 = A A2 = A2 A,
......................................
Ak = Ak1 A = A Ak1 .
Let's noti e that for any nite A:

|Ak | = |A|k .

DEFINITION

a = ak1 ak2 ....a2 a1 a0 is said to be a k-digital binary number


i
a = a0 + a1 2 + a2 22 + + ak1 2k1 , aj {0, 1}, j = 0, 1, ..., k 1.

Exer ise

Let's nd the (de imal) number of 8-digital binary numbers.


Solution. These binary numbers are:
0 = (0, 0, 0, 0, 0, 0, 0, 0) = 0 + 0 2 + + 0 128,
1 = (0, 0, 0, 0, 0, 0, 0, 1) = 1 + 0 2 + + 0 128,
..............................................................................
255 = (1, 1, 1, 1, 1, 1, 1, 1) = 1 + 1 2 + 1 4 + + 1 128.
Now it is lear that the number of 8-digital binary numbers is

|{0, 1}|8 = 28 = 256.


61

DEFINITION

Let the words, whi h are ompounded of the letters of alphabet


A = {a1 , a2 , . . . , an }, ontain exa tly k letters ea h. Let letter aj
be repeated pj > 0 times in all words (then p1 + p2 + + pn = k).
These words are alled multiple arrangements of elements of
set A.

THEOREM

The number of multiple arrangements of k elements given n


elements equals

k
p 1 , p 2 , . . . , pn

k!
.
p1 !p2 ! pn !

(Prove it!)

Exer ise

How many words an be omposed using all the letters of the word
MATHEMATICS?
Solution. We see n = 8 dierent letters in this word. Few of them
are repeated in this word: pA = 2, pM = 2, pT = 2, and the other
are not: pC = 1, pE = 1, pH = 1, pI = 1, pT = 1 .
n = 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 = 11. Consequently, the requested
value is


11
11 10 9 7 6 5 4 3 2
= 4989600.
=
1
2!, 2!, 2!, 1!, 1!, 1!, 1!, 1!

Problems
1. How many

li en e plates an be made, showing three letters


followed by three digits assuming 26 letters in the alphabet?
2. If, when manufa turing s rews, from 100 s rews 5 items are
too long, 10 items are too short and the remaining 85 items are
62

regular,what is the number of all arrangements of this amount of


s rews?

2.4.2. Addition Rule for Disjoint Sets


DEFINITION

Sets A and B are disjoint


.

sets , i they do not interse t: A B =

If A and B are two disjoint sets, for any element x of union of


them (x (A B)) there is x A & x
/ B or x B & x
/ A.
Consequently, union of disjoint sets A B has exa tly |A| + |B|
elements:
A B = |A B| = |A| + |B|.
This formula is known as the

addition rule for disjoint sets .

DEFINITION

Sets
T A1 , A2 , . . . , An are disjoint sets , i
Ai Aj = for all i 6= j, i, j = 1...n.

If so, then the

union of disjoint sets has




n
n
[
X


Ak =
|Ak |



k=1

elements. We got the


sets .

k=1

generalized addition rule for disjoint

2.4.3. Addition Rule for Arbitrary Sets


Let's prove an

addition rule for any sets A and B :


63

Fig 6. Addition rule for arbitrary sets

|A B| = |A| + |B| |A B|.

Proof. Let's denote A \ B = X1 , B \ A = X2 , A B = X3 . Then


Xi Xj = i 6= j , thus, the generalized addition rule for disjoint

sets implies equation

|A B| = |X1 | + |X2 | + |X3 |.


Let's noti e that A = (A \ B) (A B) = X1 X3 and B =
(B \ A) (A B) = X2 X3 , thus |X1 | = |A| |X3 | = |A| |A B|
and |X2 | = |B| |X3 | = |B| |A B|. Consequently,

|A B| = |A| + |B| |A B|.


This formula an be

generalized to the ase of three sets:

|AB C| = |A|+|B|+|C||AB||AC||B C|+|AB C|.


(Prove it!)

64

For any given nite number n of sets we have:




[
X
n
X
n



A
=
|Aj |
|Aj Ai | +
j

j=1 j=1
16j<i6n
X
n1
|Aj Ai Ak | + (1)
|A1 A2 An |.
16j<i<k6n

Example

There are 1000 students in the fa ulty. 800 of them study English,
500  German and 100  no one of these languages. How many
students study both English and German?
Solution. Let's denote by the set of all students of the fa ulty,
by E  the set of students that study English and by G  the
set of students that study German. Then || = 1000, |E| = 800,
|G| = 500 and |A V | = 100. The last equation and de Morgan's
law (see 2.2.2.) imply A V = A V = \ (A V ). Thus,
|A V | = || |A V | = 1000 100 = 900.
We want to nd the value of |AV |. It is easy to see that |AV | =
|A| + |V | |A V | = 800 + 500 900 = 400. Consequently, both
English and German are studied by 400 students of the fa ulty.

Problem

There are 30 students in a group. 10 of them have passed mathemati s and physi s, 25 - mathemati s or physi s, 15 - mathemati s.
How many students passed physi s?

2.5. GENERATING FUNCTIONS


DEFINITION

Let's denote an innite sequen e of numbers by {an }= {a0 , a1 , a2 . . .}.

P
The series
an xn = F (x) is alled the generating fun tion of
n=0

65

sequen e {an }.
If series {an } is nite (an = o if n > k), then its generating fun tion
is a polynomial .

Examples
n
P

{an } = {1, 1, . . . , 1, 0, 0, . . .}
{an } = {1, 4, 6, 4, 1, 0, 0, . . .}
{an } =

{Cn0 , Cn1 , . . . , Cnn1 , Cnn , 0, 0, . . .}

k=0
4
P
k=0
n
P

xk =

1 xn+1
;
1x

C4k xk = (1 + x)4 ;
Cnk xk = (1 + x)n .

k=0

Few of generating fun tions are well known in al ulus:

{an } = {1, 1, . . . , 1, 1, 1, . . .}

xk =

k=0

1
;
1x

1
;
1+x
k=0

P
1
{an } = {1, a, a2 , a3 , a4 , a5 , . . .}
ak xk =
;
1 ax
k=0

P
1
{an } = {1, 2, 3, 4, 5, 6, . . .}
(k + 1)xk =
;
(1 x)2
k=0
xk
P
1
1 1 1 1
= ln
{an } = {0, 1, , , , , . . .}
;
2 3 4 5
1x
k=1 k
(1)k+1
P
1 1 1 1
{an } = {0, 1, , , , , . . .}
xk =ln(1 + x);
2 3 4 5
k
k=1
xk
P
1 1 1 1
{an } = {1, 1, , , ,
, . . .}
= ex ;
2 6 24 120
k!
k=0

P
(1)k
1
1
{an } = {0, 1, 0, , 0,
, 0, . . .}
x2k+1 =sin x;
6
120
(2k
+
1)!
k=0
(1)k
P
1
1
{an } = {1, 0, , 0, , 0, . . .}
x2k =cos x.
2
24
(2k)!
k=0
{an } = {1, 1, 1, 1, 1, 1, . . .}

66

(1)k xk =

DEFINITION

The polynomial of order n

(x)n = x(x 1)(x 2) (x n + 1)

is alled the

falling fa torial 24.

Please note that (n)n = n!. The below formulas give us interesting
relations between Stirling's numbers of the rst and of the se ond
kinds (see 2.3.1.) and the falling fa torial (n > 0):

(x)n =
xn =

n
X

s(n, k)xk ,

k=0
n
X

S(n, k)(x)k .

k=0

(Without proof.)

Problems
1. Find the sequen e generated by fun tion ln(1 2x).
2. Determine the generating fun tion of sequen e {6, 4, 16, 64, 256,
1024, ...} among the fun tions
6 20x 6 20x
,
.
1 4x 4x + 1

24x + 6 6x + 6 6x + 6 24x + 6
,
,
,
,
1 4x 4x + 1 1 4x 4x + 1

2.5.1. Properties of Generating Fun tions


1. Assume that Fa (x) and Fb (x) are generating

fun tions of sequen es {an } and {bn }. Then fun tion Fa (x) + Fb (x) generates
sequen e {an + bn } for any numbers and . (Prove it!)
24

The

rising fa torial

is dened by

67

hxin = x(x + 1)(x + 2)...(x + n 1).

2.

Sequen e an = bn bn1 , n > 1, a0 = b0 generates the fun tion


Fa (x) = Fb (x)(1 x).

P
P
P
Proof. Fa (x) =
(bk bk1 )xk =
bk xk
bk1 xk1 x.
k=1
k=0 !
k=1

P
Thus, Fa (x) = Fb (x)
bk xk x = Fb (x) xFb (x).
k=k1=0

3.

Sequen e an = bn+1 bn is generated by fun tion


1 x b0
Fa (x) = Fb (x)

and sequen e an = nbn  by fun tion


x
x
d
Fa (x) = x Fb (x).
dx

(Prove yourself.)

DEFINITION
The

produ t of generating fun tions Fa (x) =

and Fb (x) =

cn =

bn xn is Fa (x)Fb (x) =

n=0
a0 bn + a1 bn1

+ a2 bn2 + +

an xn

n=0

cn xn , where
n=0
ak bnk + + an b0 .

Remark

We skip here the question about the onditions, under whi h this
formula really represents the produ t of given fun tions, and even
the question of the onvergen e of series.
Multiplying fun tions (1 + x)m and (1 + x)k , we have:
m

(1 + x) (1 + x) =

m
X

i i
Cm
x

i=0

= (1 + x)m+k =

k
X
j=0

m+k
X
l=0

68

Ckj xj =
l
Cm+k
xl .

We got

Cau hy's 25 identity :


l
Cm+k

l
X

s ls
Cm
Ck .

s=0

Everyone an prove that binomial oe ients are symmetri with


i = C 2ni . This fa t and Cau hy's
respe t to the upper index: C2n
2n
formulas imply the following interesting formula:
n
C2n
=

n
X

(Cns )2 .

s=0

Problem

Assuming that Fa (x) and Fb (x) are generating fun tions of sequen es {an } and {bn }, nd the generating fun tion of sequen e
an = bn+1 3bn + 2bn1 , n > 1.

2.5.2. Fibona i Numbers

Fibona i 26 numbers Fn are dened by a re urrent equation :


F0 = F1 = 1, Fn+1 = Fn + Fn1 , n 1.
Let sequen e {Fn } = {1, 1, 2, 3, 5, 8, 13, 21, . . .} be generated by
fun tion F (x):

F (x) =
= 1 + x + x2

Fn x = 1 + x +

n=0

Fn2 xn2 + x

n=2

25
26

(Fn2 + Fn1 )xn =

n=2

X
n=2

Fn1 xn1 + 1 1

= 1 + x + x2 F (x) + x(F (x) 1) = 1 + (x + x2 )F (x).


Augustin Louis Cau hy (1789  1857)  Fren h mathemati ian.
Fibona i (Leonardo Pisano, 1180  1240)  Italian mathemati ian.

69

1
1
Noti e, that27 F (x) =
=
,
2
1 x
x
(1 ax)(1 bx)

1+ 5
1 5
where a =
,b=
.
2
2
a
a
and B =
, then
Let's denote A =
ab
ab

X
X
A
B
+
=A
F (x) =
an xn + B
bn xn =
1 ax 1 bx
n=0

n=0

X
an+1 bn+1

n=0

ab

xn .

From here we get an expli it formula for Fibona i numbers :

!n+1
!n+1
1 1+ 5
1 5
.
Fn =

2
2
5

27

Everyone an get these values expanding this fra tion as the sum of ele-

mentary fra tions and applying the method of unknown oe ients.

70

2.6. LINEAR RECURRENT EQUATIONS


2.6.1. Linear Homogeneous Re urrent Equations
DEFINITION

Assume that p1 , p2 , . . . pk are given numbers and pk 6= 0. Equation

(HE) an+k + p1 an+k1 + p2 an+k2 + + pk an = 0


is alled a linear homogeneous re urrent equation of order k.
The solution of this equation is sequen e {an } = {a0 , a1 , . . . , an , . . .}.

THEOREM

(1)

(2)

If sequen es {an } and {an } are both the solutions of equation


(1)
(2)
(HE), then any their linear ombination {1 an + 2 an } is also
the solution.

(Prove yourself.)
Assume that {an } = {n } satises equation (HE). Substituting
{an } for (HE) and applying obvious relation an+k = n+k = n k ,
we get a hara teristi equation of our re urrent equation:

(CHE) k + p1 k1 + p2 k2 + + pk1 + pk = 0.

THEOREM

If the hara teristi equation (CHE) has exa tly k dierent roots
1 , 2 , . . ., k , then

{an } = {C1 n1 + C2 n2 + + Ck nk }, Ci R, i = 1, . . . , k,

is the general solution of homogeneous equation (HE)


(Without proof. Prove yourself that sequen e {an } satises (HE).)
71

Exer ise

Solve equation an+2 4an1 + 3an = 0 under the following initial


onditions a0 = 2, a1 = 4.
Solution. The hara teristi equation of a given re urrent equation
is 2 4 + 3 = 0, 1 = 1 and 2 = 3 are roots of it. A ording to the last theorem, the general solution of re urrent equation
is {an } = {C1 + C2 3n }. Substituting the given initial values for
the expression of a general solution, we get a0 = 2 = C1 + C2 ,
a1 = 4 = C1 + C2 3. Thus C1 = C2 = 1 and an = 1 + 3n . Consequently, sequen e {1+3n } is a solution of our initial value problem.

THEOREM

Suppose, that 0 is r -multiple root of (CHE). Then (HE) has


exa tly r lineary independent solutions, that orrespond to 0 :

{n0 }, { nn0 }, { n2 n0 }, . . . , {nr1 n0 }.


(Without proof. Prove yourself that the sequen es given above satisfy HE .)
Noti e that a ording to the rst theorem of this subse tion any
linear ombination of these sequen es is a solution of homogeneous
equation (HE).

Example

Let's onsider re urrent homogeneous equation


an+2 4an+1 + 4an = 0. It's hara teristi equation

2 4 + 4 = ( 2)2 = 0
has unique root 0 = 2 of multipli ity 2. Thus, the general solution
of re urrent equation is {an } = {2n (C1 + nC2 )}, where C1 , C2 are
arbitrary onstants.
72

Problems
1. Solve re urrent

equation an+2 6an+1 + 8an = 0 when a0 =


1, a1 = 0.
2. Find the Fibona i numbers as the solutions of homogeneous
re urrent equation Fn+1 = Fn + Fn1 , n 1, satisfying initial
onditions F0 = F1 = 1.

2.6.2. Linear Nonhomogeneous Re urrent Equations


DEFINITION

Linear nonhomogeneous re urrent equation of order k is an

equation

(N HE) an+k + p1 an+k1 + p2 an+k2 + + pk an = (n),


where (n) is a given fun tion.

THEOREM

A general solution of linear nonhomogeneous equation an be expressed as a sum of a general solution of homogeneous equation
and of a single solution of nonhomogeneous equation.
(Prove this theorem using the fa t that a given equation is linear.)

Corollary

The general solution of equation (N HE) an be expressed as a


sum of the general solution of (HE) and of a single solution of
(N HE).

Hint .

Consequently, we know the way for nding a general solution of (HE) and need at least one single solution of (N HE).
Sear h for an , where {an } is a single solution of (N HE), among
73

the fun tions of argument n that are similar to (n). For example,
if (n) is a polynomial with respe t to n, look for an in the form
of a polynomial. If (n) is an exponential fun tion of argument n,
try to nd an as an exponential fun tion.

Examples
1. Re urrent

nonhomogeneous equation an+2 + pan+1 + qan =


n + has a single solution {an }, where an is a polynomial:
an = An + B , if 1 + p + q 6= 0;
an = n(An + B), if 1 + p + q = 0 and p 6= 2;
an = n2 (An + B), if p = 2, q = 1.
2. Equation an+2 + pan+1 + qan = n has a single solution {an },
where:
an = An , if 2 + p + q 6= 0;
an = nAn , if 2 + p + q = 0 and 2 + p 6= 0.
In this ase fun tion (n) is a onstant fun tion (i.e., the polynomial of order 0.

Problems
1. Find the general solution of equation an+2 2an+1 3an = n.
2. Solve the initial value problem an+2 3an+1 + 2an = 2n + 2,
a0 = 2, a1 = 1.

2.7. ASYMPTOTICS
2.7.1. Con ept of Asymptoti

Denitions

Let fun tions f (n) and g(n) innitely in rease when n tends
innity (n N).
We say that fun tion g(n) grows faster than fun tion f (n) (or
that fun tion g(n) has a higher growth rate than fun tion f (n)):
f (n)
f (n) g(n) (or g(n) f (n)), i lim
= 0.
n g(n)
74

Then vanishing when n tends innity fun tions f (n) and g(n)
an be ompared as below:
1
1
f (n) g(n)

.
g(n)
f (n)
Innitely in reasing fun tions an be ordered with respe t to
their growth rates (when n ). For example,

n
1 ln ln n ln n n n n2 nln n en nn nn .
Assume that innitely in reasing fun tions f (n) and g(n) satisfy
ondition C > 0 : |f (n)| 6 C|g(n)| (for any n N). We say that
the growth rate of fun tion f (n) does not ex eed the growth rate
of fun tion g(n) and denote it by f (n) = O(g(n)).
For example, n2 + 5n 3 = O(n2 ), 2n + n2 = O(2n ).
We say that fun tions f (n) and g(n) are of the same growth
rate , i there C > 0 : |f (n)| 6 C|g(n)| & |g(n)| 6 C|f (n)| (for
any positive integers n). We denote that fa t by f (n) g(n).
f (n)
Assume that lim
= 1. Then we write f (n) g(n), n ,
n g(n)
and say that fun tions g(n) and f (n) are asymptoti ally equivalent when n tends to innity. In this ase fun tion f (n) is said
to be an asymptoti al fun tion of fun tion g(n), as well as g(n)
is alled an asymptoti al fun tion of fun tion f (n).

Remarks
1. The ideas of these denitions an be applied to fun tions of real

argument x f (x) and g(x), when x x0 , x0 R or x .


For example, sin x x when x 0, x5 ex when x +.
2. Sometimes symbol O is dened by more strong onditions:
f (x)
f (x) = O(g(x)) (x x0 ) lim
= C > 0. Then O means
xx0 g(x)
the same as , a ording to our denition.
3. The other well known mathemati al symbol o (both O and o
75

are alled

Landau 28 symbols ) is dened below:

f (x)
= 0.
xx0 g(x)
Please note that symbols o and are equivalent a ording to
their denitions

f (x) = o(g(x)) i x x0 lim

Problems
1. Compare the growth of fun tions lnn, n, n2 , n5 , 5n .

Prove your

results basing on denitions.


2. Compare the behavior of fun tions n10 and 10n , 45n and 45n +
5n4 , (ln100)n n and (lnn)n 100 when n .

2.7.2. Samples of Asymptoti al Fun tions


1. Let n be any positive integer and (n) be the number of primary
numbers that does not ex eed n. It an be proved that (n)

n
ln n

when n .
1
1
2. For any , 0 < < 1 we have
1 (prove!). Thus,
n
ln n

3.Stirling's formula

n1 (n) n.
(or

Stirling's approximation ):

n!

2nnn en

is valid when n .
Sometimes in al ulations it is useful to repla e f (n) by it's asymptoti al fun tion F (n). It is often said that F (n) is an asymptoti al approximation of fun tion f (n).

28

Edmund Georg Hermann Landau (1877 1938)  German mathemati ian.

76

DEFINITIONS

We say that asymptoti al approximation F (n) f (n) has an

solute error of order O(g(n)) i F (n) = f (n) + O(g(n)).

ab-

Equation F (n) = f (n)(1+O(g(n))) means that this approximation


has a relative error of order O(g(n)).

Examples



n
n
n
+
(n) =
+O
;
ln n (lnn)2
(ln n)2
 



n n
1
1
1
n! = 2n
+
O
.
1+
+
e
12n 288n2
n3

In the table below you will nd values of fa torial n! and of its
approximations al ulated a ording to the last asymptoti al formula.

n!

1
2
3
4
5
10
11
13
15
20
30
50
100

1
2
6
24
120
3628800
3.991660 107
6.227021 109
1.307674 1012
2.432902 1018
2.652529 1032
3.041409 1064
9.332622 10157

2n

 n n 
e

1
1
+
1+
12n 288n2

1.002184
2.000629
6.000578
24.00099
120.0025
3628810.
3.991688 107
6.227028 109
1.307675 1012
2.432903 1018
2.652529 1032
3.041409 1064
9.332622 10157
77

3.

RELATIONS

3.1. BASIC CONCEPTS


3.1.1. Samples of Relations
DEFINITIONS

Relation

A and B is an arbitrary subset of


Cartesian produ t of these sets: R A B . This relation is alled
a binary relation be ause it has two input sets.
R is said to be a relation between sets A, B and C i R
A B C . Relations between any nite number of sets an be
dened by analogy.
Any subset R An is said to be a n-relation in A. When n = 1
we say that R is an unary relation in A.
In this ase we understand that any element a R A has some
property assigned with R.
R

between sets

Examples
1. The identity relation IA = {(a, , a) : a A} An .
2. The universal relation UAB = {(a, b) : a A & b B} =

A B.

3. Empty relation An .
4. Let's denote the set of all integers

by Z and let x Z, y Z.
Let dene the following binary relations in Z:
R1 = {(x, y) : y divides x}, R2 = {(x, y) : x y},
R3 = {(x, y) : x = 2y}.
5. Assume that C is a list of personal odes (ID) of students, N
is the list of their names, B  the list of their birth-dates, G  the
list of all student groups , M  the list of students evaluation data.
Then any relation C N B G G M an be said to be a
database .
78

3.1.2. Binary Relations


DEFINITIONS
The
The

domain of relation R A B is the set


D(R) = {x : y (x, y) R} A.

range of relation R A B is the set

R(R) = {y : x (x, y) R} B.

Example
R = {(1, 1), (2, 1), (6, 1), (6, 2)}, D(R) = {1, 2, 6}, R(R) = {1, 2}.

Remark

Binary relation R A2 an be expressed as aRb, where a A,


b B . For example, a > b, a = b, a 6 b.
Binary relations an be represented graphi ally. In Fig 7. we see
the graph of relation R A B , A = {1, 2, 3}, B = {a, b, c, d},
R = {(1, a), (1, b), (1, d), (2, a), (2, c), (3, c)}.

Examples
1.

R1 = {(a1 , b1 ), (a1 , b2 ), (a2 , b3 )}, R1 A B , A = {a1 , a2 },


B = { b1 , b2 , b3 }.
2. R2 = {(a, a), (a, b), (a, c), (b, c), (d, c)}, R2 A2 , A = {a, b, c, d}.

DEFINITION

Matrix MR = kmij knm , where


(
1, when (ai , bj ) R,
mij =
0, when (ai , bj )
/ R,
79

Fig 7. Binary relation


is the matrix of binary
(n = |A| and m = |B|).

relation R A B

Examples

Matri es of relations R1 and R2 are:

1 1 0
MR1 = 0 0 1 , MR2
0 0 0
Matrix of relation R, represented in

1 1 0
1 0 1
0 0 1

Problems

1
0
=
0
0

Fig 7. is:

1
0 .
0

1
0
0
0

1
1
0
1

0
0
.
0
0

Represent graphi ally and write out the matrix of binary relation
R A2 when:
80

1.

A = {1, 2, 3, 4, 5}, R = {(1, 1), (1, 2), (2, 3), (1, 3), (1, 4),
(4, 5), (5, 1), (1, 5), (4, 1)}.
y
2. A = {2, 3, 4, 6, 8, 9, 12}, R = {(x, y) : N}.
x

3.1.3. Properties of Binary Relations


DEFINITIONS

A ertain relation R in set A is said to be a reexive relation in


A i a A (a, a) R. I a A (a, a) / R, R is said to
be an irreexive relation .
Common mis on eption is that a relation is either reexive or irreexive. A binary relation an be reexive, irreexive or neither.
Irreexivity is a stronger ondition than failure of reexivity.
I (a, b) R (b, a) R, relation R is alled a symmetri
relation . R is alled an antisymmetri relation i (a, b)
R & (b, a) R a = b.
Note that antisymmetri is not the logi al negative of symmetri .
There are relations whi h are both symmetri and antisymmetri
(for instan e, the identity relation ) and there are relations whi h
are neither symmetri nor antisymmetri (for instan e, divisibility
on N).
In some texts any relation that fails to be symmetri is said to be
an asymmetri relation. By our denition, R A2 is said to be
asymmetri relation , i (a, b) R (b, a) / R.

THEOREM

The asymmetry is equivalent to antisymmetry plus irreexivity.


(Prove it! )
81

Transitive relations

R, by denition, are only these relations


whi h satisfy ondition (a, b) R & (b, c) R (a, c) R. Relation R is said to be a omplete relation , i a, b A & a 6= b
(a, b) R (b, a) R.
Relation R1 = {(a, b) : (b, a) R} is alled an
to the relation R.

inverse relation

In other words, aR1 b bRa. Let noti e that R1

Examples

1

= R.

1. (>)1 = <;
2. ()1 = ;
3. (=)1 = =.

THEOREMS

R A2 is a:
1) reexive relation IA R;
2) irreexive relation R IA = ;
3) symmetri relation R = R1 ;
4) antisymmetri relation R R1 IA ;
5) omplete relation R IA R1 = UA .
(Prove these statements! )

Problems
1. Let A = {a,

b, c, d, e, f }. Sket h graphs of some reexive,


irreexive, symmetri , antisymmetri , transitive relations R A2
and also of the omplete binary relation in A.
2. Find relations that are not reexive nor irreexive relations.
3. Determine the types of relations onsidered in the problems of
se tion 3.1.2..
82

3.1.4. Set Operations on Relations

union , the interse tion , the dieren e and the omplement of relations are understood as the orresponding set opera-

The

tions.

Examples

Let's onsider few binary relations in the set of integers Z:

1 = {(m, n) : m n},
2 = {(m, n) : m > n},

3 = {(m, n) : m < n}.

Then

2 1 , 1 2 = 1 ,
1 2 = 2 , 3 = 1 ,

1 \ 2 = IZ .

(Prove these statements!)

DEFINITION

Let and both be binary relations in set A. The

of relations and is the relation

omposition

= {(a, b) : c A, (a, c) & (c, b) }.


Noti e that the omposition of relations in general is a

ommutative operation : 6= .
Examples

1 2 = 2 1 = 2 ,

1 3 = 3 1 = 2 3 = 3 2 = UZ = Z 2 .
83

not-

The proofs of below statements follow dire tly from the previous
denitions:

THEOREMS

, , A2 :
1) IA = IA = ;
2) = = ;
3) ( ) = ( );
4) ( )1 = 1 1 .

(Prove them!)

DEFINITION

The power
relations:

of relation

R A2 is the following omposition of


Rn = R
R},
| {z

( R = IA , R = R, R = R R, . . . , R = R

ntimes
n1

R.)

THEOREM

Relation R is a transitive relation i (if and only if) R R R.

Problems
1. Prove this theorem

using the denitions of transitivity and of


omposition of relations.
2. Prove that Rn R for any transitive relation R.
y
3. Let A = {1, 2, 3, 4, 5, 6} and R = {(x, y) :
N},
x
x+y
P = {(x, y) :
N}. Graph P R and R P .
2

84

3.2. EQUIVALENCE RELATIONS


3.2.1. Denition and Samples of an Equivalen e Relation
DEFINITION

R A2 is an equivalen e relation i it is:


1) reexive;
2) symmetri ;
3) transitive.
Set A together with an equivalen e relation R is alled a

setoid .

Examples
1. The identity relation IA is an equivalen e relation in set A.
2. The subset of even integers is equivalen y in Z.
3. = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3)} is equivalen y in set {1, 2, 3}.
Problems
1. Prove the above statements.
2. Let A be the set of words of arbitrary length.

Let aRb i a, b A
and both a and b are words of the same length. Determine whether
R is equivalen y or it is not.

3.2.2. Equivalen e Classes


DEFINITION

Suppose that R A2 is an equivalen e relation. Subset [a]R A:

[a]R = {b A : (a, b) R},

is alled an

equivalen e lass of element a A.

LEMAS
1) a A : [a]R 6= ;
85

2) (a, b) R [a]R = [b]R ;


3) (a, b) / R [a]R [b]R = .
THEOREM

Let's denote by B = {B1 , B2 , . . .} the set of all equivalen e lasses


of set A with respe t to relation R. Then
[
Bj B Bj 6= ; i 6= j Bi Bj = ;
Bi = A.
i

(Prove the above statements.)


Consequently, an equivalen e relation determines a partition (see
2.3.1.) B of set A. Blo ks of this partition are equivalen e lasses
of elements of A.

DEFINITION

The set of all equivalen e lasses A/R = {[a]R }aA in A given an


equivalen e relation R is alled the quotient set of A by R.

Problems
1. Let R5 be

the relation in Z, dened as follows: xRy if 5 divides x y . Prove that R5 is equivalen y. Determine equivalen e
lasses.
2. Prove that R = {(a, a), (a, b), (b, a), (b, b), (b, c), (c, b), (c, c), (a, c),
(c, a), (d, d), (d, e), (e, d), (e, e)} is equivalen y in {a, b, c, d, e}. Determine equivalen e lasses.

3.3. ORDER RELATIONS


3.3.1. Denitions and Examples of Order Relations
DEFINITIONS

Binary relation in set A is

order relation , i it is antisymmetri


86

and transitive relation. I, additionally, relation is reexive (irreexive), then it is alled the relation of a stri t (weak) order.
Relation is the relation of a total (partial) order i it is (is not)
omplete relation.
Relation
Order relation
Weak order relation
Stri t order relation
Total order relation
Partial order relation

Main properties
antisymmetri and transitive
reexive
irreexive
omplete
is not omplete

Symbols of order relations are , , , .

Examples
1. Relations

, (<, >) are weak (stri t) order relations in sets


of numbers: N, Z, R, et .
2. Relations , are weak order relations in power set (see 2.1.5.)
2A of set A.

Problems
1. Prove the above examples statements.
2. Determine the type of relation {(1, 2),

(1, 5), (1, 4), (2, 5),


(3, 2), (3, 5), (4, 2), (4, 2)} in the set {1, 2, 3, 4, 5}.

3.3.2. Ordered Sets


DEFINITIONS

A set is totaly (partially) ordered , i some relation of a total


(partial) order is dened on this set.
m A is said to be a minimal element of set A i

a A : a m & a 6= m.
87

THEOREM

Any nonempty nite partially ordered set has its minimal element.
Any nonempty nite totaly ordered set has unique minimal element

(Prove it!)

Examples
1. Sets of numbers N, Z, R are totaly ordered by relations or <.

Any of these sets has no minimal elements.


2. The power set P(A) = 2A of set A is a partially ordered set, if
the order is introdu ed by relation . Then is a minimal element
in P.

3.4. CLOSURES OF RELATIONS


3.4.1. Transitive Closure
Let R be any binary relation in set A.

DEFINITION
Relation

R+ = {(a, b) A2 : c1 , c2 , . . . , ck A, (a, c1 ) R &

& (c1 , c2 ) R & & (ck , b) R}

is said to be

transitive losure of relation R.

Remark

R+ = R i R is transitive relation itself. (Prove that!)


Below you will nd interesting expressions for transitive losure R+
of relation R and for the matrix of transitive losure MR+ when R
is any relation in nite set A.
88

DEFINITION

Let M = (mij ) and N = (nij ) be arbitrary m n matri es. By


denition,
W
M N = K = (kij ), i = 1, 2, ..., m, j = 1, 2, ..., n,
where

kij = 0 if mij + nij = 0,


kij = 1 if mij + nij 6= 0.

THEOREM

For R A2 , |A| = n:

n1
S
S
S
1) R+ = Ri = Ri = Ri ;
i=1
n
W

2) MR+ =

i=1

MRi =

i=1

n
W

i=1

(MR )i .

i=1

Examples
1. R = {(x, y) : y = x + 1} N 2 R+ = {(x, y) : x < y}.
2. R = {(x, y) : x < y} Q2 R+ = R.
Problems
1. Find the transitive losure of relation R = {(a, a), (b, b), (b, c),

(c, b), (d, c)} in set A = {a, b, c, d}.


2. Test the statements of above theorem for R from Problem 1.
3. R R2 is dened by: xRy if x, y R and y = x + 1. Find R+ .

3.4.2. Reexive Closure


DEFINITION
The

reexive losure R of relation R is the relation


R = R+ IA .
89

Example

R = {(x, y) : x, y R, x < y} R = {(x, y) : x, y R, x y}.

Problems

Find the reexive losures of both relations of problems in se tion


3.4.1.

3.5. FUNCTIONS
3.5.1. Inje tion, Surje tion, Bije tion
DEFINITIONS

Relation f A B is said to be a

fun tion i

(a, b) f & (a, c) f b = c.


Fun tion (a, b) f is usually denoted by b = f (a). Variable a A
is alled an argument of fun tion f and variable b B  value
of a fun tion.
The domain fA and the range fB of fun tion f are the following
sets:

fA = {a A : b B b = f (a)}, fB = {b B : a A b = f (a)}.
In a below table you will nd the denitions of

je tion and bije tion .

A fun tion is said to be

Inje tion
Surje tion
Bije tion

inje tion, sur-

I (if and only if)


b = f (a1 ) & b = f (a2 ) a1 = a2
b B a A b = f (a)
It is both inje tion and surje tion

90

THEOREM

If f A B is bije tion and fA = A, then inverse fun tion


f 1 B A is bije tion, too.

Problems
1. Prove this

theorem by verifying the basi properties of the

bije tion.
2. Determine whether R = {(a, b), (b, c), (d, a)} and
P = {(a, a), (b, b), (c, a), (d, f ), (g, c)} are fun tions.
3. Determine whether R = {(a, a), (b, c), (c, a), (d, c), (e, b), (f, a)}
and P = {(a, b), (c, d), (b, a), (e, f ), (d, e), (f, c)} are bije tions in
A = {a, b, c, d, e, f }.

3.5.2. PERMUTATIONS
DEFINITIONS

Permutation is bije tion in a nite set.


Let this nite set be A and its ardinality is |A| = n. Permutation
: A A an be represented as below:


1 2 3 4 5 6
=
,
5 6 3 1 4 2
or:
(1) = 5, (2) = 6, . . . , (6) = 2.
In other words, permutation is the rearrangement of set A elements.
A permutation y le is a subset of permutation whi h elements
hange pla es ea h with other.

91

Thus, permutation


a1 a2
a2 a3

an1 an
an a1

is a n- y le itself. It an be re orded as (a1 , a2 , , an1 , an ), what


means that starting from the original ordering (a1 , a2 , a3 , , an1 ,
an ), the rst element is repla ed by the se ond, the se ond by the
third, the third by the fourth, et . This n- y le of permutation
an also be represented as a1 a2 a3 an a1 .

 

 
1 4 5
2 6
3
Permutations
,
and
represent y les
5 1 4
6 2
3
that an be written as (1, 5, 4), (2, 6) and (3).

Remark

Everyone is able to re ognize that previous and former denitions


of permutations are equivalent. But the permutation y les and
the y les (as dened before) are quite dierent obje ts. But if we
agree additionally that any rotation of a given permutation y le
spe ies the same y le, these on epts be ome equivalent.

DEFINITIONS

The produ t of permutations is the omposition of these permutations.


Compositions of permutations are understood as the ompositions of relations.
For example, if

 

1 2 3 4 5 6
5 6 3 1 4 2
=
=
,
3 2 6 1 4 5
4 5 6 3 1 2
then

1 2 3 4 5 6
4 5 6 3 1 2
92

Sometimes it is useful to represent some given permutation as the


totality of its disjoint y les . For instan e, permutation


1 2 3 4 5 6
=
5 6 3 1 4 2
an be represented as follows:

= (1, 5, 4) (3) (2, 6).


There is great freedom in re ording any y li de omposition of
given permutation, be ause permutation y les are disjoint and
any rotation of a given y le spe ies the same y le. Thus,

= (3) (5, 4, 1) (2, 6) = (6, 2) (4, 1, 5) (3) = .

Problem

Write out the y li de omposition of permutation




1 2 3 4 5 6
.
3 2 4 5 6 1

93

4.

INFORMATION CODING

4.1. BASIC CONCEPTS


4.1.1. Sour e of Information
Assume that any abstra t sour e
bols aj A = {a1 , a2 , . . . , an }.

of information generates sym-

DEFINITIONS

Set A is said to be an alphabet of a sour e of information, while


its elements aj are alled letters of this alphabet. Any nite sequen e a = ai1 ai2 aim is alled a word over that alphabet. The
length of a word a is denoted by |a| = m.
We denote the set of all words of length m over alphabet A by
Am . Thus, Am an be represented as Cartesian produ t :

Am = A
{z A}
| A
mtimes

The number of su h words is |Am | = |A|m = nm .


Let's onsider some subset A of words of various length. Then
[
A
Am .
m=1,2,...

If the words are generated stri tly a ording to the given rules, we
have the automati sour e of information. In ase of a statisti al generator of words probabilities of letters or/and of ombinations of letters must be dened or determined.

4.1.2. Code Con ept


Let aj A = {a1 , a2 , . . . , an } and B = {b1 , b2 , . . . , bk } be two
arbitrary alphabets, A and B  two arbitrary sets of words over
94

these alphabets.

DEFINITION

Any inje tion C : A B is said to be a

ode .

In other words, fun tion C is a ode if C(a) = C(a ) a = a for


any a, a A .
Let's noti e that the existen e of inverse fun tion C 1 is not ne essary (thus C is not bije tion ).

B by B
.
Let's denote the range of fun tion C : C(A ) = B
Then
!a A : C 1 (b) = C 1 (C(a)) = a,29
b B
i.e., the de oding of a ode is available. In this ase we say that
given ode C is de odable .

4.2. METHODS OF CODING


The hoi e of a ertain method of oding depends on the destination of en oding. Below we onsider three main goals that are
supposed to be rea hed by en oding the information and three
oding methods that orrespond to these goals.

4.2.1. Prote tion against the Distortion of Information


Suppose that a sour e of information generates letters {a, b} that
are en oded with symbols {0, 1}. Suppose that for unknown reasons symbol 0 an be taken for 1 or, vi e versa, symbol 1 an be
understood as 0 30 . Let's denote the probability of this distortion
29
30

Symbol

means "exists unique".

Any available te hni al, physi al and other reasons of these types of dis-

tortions are not the subje t of this onsideration.

95

by p. Naturally, the value of p must be small (0 < p << 1), otherwise (if p 0.5) the en oding is senseless.
Let's suppose that p = 0.05 and let's onsider ode a 0, b 1.
Then the word (message ) aabab is en oded to the message 00101.
Let's nd the probability that message 00101 really derives from
the word aabab. The probability of a proper understanding of
any symbol is q = 1 p = 0.95. Thus, the probability that
all ve symbols of this message have been understood properly
is (0.95)5 0.774. Consequently, just about 77% of this type messages will be interpreted without misunderstanding.
Let onsider another ode : a 00, b 11. Now words 01
and 10 do not belong to set B (see 4.1.2.) and the presen e of
these words in a message indi ates the distortion of information.
Let's onsider the message 0000110011 as the one that was just
re eived. Let's nd the probability that this message originates
from the word aabab. If, when transmitting letter b, the message
00 (whi h orresponds to original letter a) was re eived, both of
two symbols in a message were orrupted. The probability of this
double-error is p2 = 0.0025. Hen e a probability of proper transmission of the whole message is (1 p2 )5 = 0.99755 0.988 and
the reliability of this ode is about 99%.
We see that the last onsidered ode is of higher reliability , if
we ompare it with the previous one. Also we an take a note that
this ode allows us to dete t a part of available distortions :
namely, both "syllables" 01 or 10, if they appear in a message are
results of some distortions. Codes of this type are alled error
dete tion odes .
Let the ode be dened by: a 000, b 111. Now we have
six words that indi ate the fa t of distortion:
96

001
010
100

011
101
110

If, for instan e, message 001 is re eived, either one error (if a was
oded originally) or two errors (if the original message was b) have
o urred. Let's denote these two events by Ha and Hb orrespondingly. Let's suppose that P (Ha ) = P (Hb ) = 0.5 and let's nd
aposteriori probabilities pa = P (Ha |001) and pb = P (Hb |001) (by
P (Ha |001) we have denoted the following onditional probability:
the probability of the event "a was oded originally" given the
event "message 001 was re eived nally"). The formula of om-

plete probability

P (001) = P (001|Ha )P (Ha ) + P (001|Hb )P (Hb ) =



= p(1 p)2 + p2 (1 p) 0.5

implies Bayes' formula :

pa =

P (001|Ha )P (Ha )
= 1 p = 0.95,
P (001)
P (001|Hb )P (Hb )
pb =
= p = 0.05.
P (001)

Consequently, following the higher reliability, we de ode oded


messages 001, 010 and 100 for letter a, when 011, 101 and 110
 for letter b.
We see that using this ode we are able to orre t an
Codes of this type are alled error orre tion odes .

error .

When the last onsidered oding system is used, any word w A


is en oded for a blo k of k = 3|w| symbols, ea h of whi h equals 0
or 1.
97

DEFINITION

Any ode of this type is said to be a


length of a blo k .

blo k ode .

k is alled the

It is lear that the reliability of a ode depends on blo k length.


|w|
1
The value
= < 1 asso iates with the "pri e" of the reliability
k
3
of a oding system and it is alled the speed of a blo k ode.
Therefore, one of the main goals of the oding theory is the development of fast and reliable odes.

4.2.2. Data Compression


Let some information sour e generate four letters {a, b, c, d} and
1
1
the probability that a ertain letter will appear is: pa = , pb = ,
2
4
1
pc = pd = .
8
Let's onsider two following odes. The rst one is a blo k ode :

a 00, b 01, c 10, d 11.

(C1 )

Then message 1 2 n (j {a, b, c, d}), when it is en oded,


n
n
has, on an average,
of symbols a,
of symbols b and equally
2
4
n
of ea h c and d. The length of the en oded message is, on an
8
average,
n
n
n
n
l1 = 2 + 2 + 2 + 2 = 2n.
2
4
8
8
l1
Thus,
= 2. Consequently, for the en oding of one letter of an
n
alphabet {a, b, c, d} we need two symbols of a set {0, 1} on an average. In fa t, we need exa tly two symbols be ause our ode is a
98

Fig 8. Coding tree of (C2 )

blo k ode.
Let the se ond ode be

a 0, b 10, c 110, d 111.

(C2 )

Please note that this ode is not a blo k ode. Let's say that the
rst letters of a word form a prex of a word.

DEFINITION

A ode is said to be a prex ode i any word of set B is not a


prex of any other word of B .
It is easy to as ertain that (C2 ) is a prex ode. Any prex ode
an be represented by a oding tree (see the oding tree of ode
C2 in Fig 8.). Using the oding tree, the en oded message an be
easily de oded.
Let's nd the mean length of the message:

l2 = 1

n
n
n
n
7
+ 2 + 3 + 3 = n.
2
4
8
8
4
99

l2
Then
= 1.75. Thereby, the message, if en oded using ode C2 ,
n
will be shorter than if it were en oded with ode C1 .

4.2.3. Se re y of Information
Let message a = ai1 ai2 aim A be a sequen e of symbols
aj {0, 1}, j = 1, 2, ..., m. Let's denote the following 2m 2m
matrix:

0
0

0
0

c0
0
0

0
1

c1

.
(cij ) = .
=
1

1
1
..
0


c2m 1
1
1

1
1
by C . Let's denote ci = (ci1 , ci2 , ..., ci2m ), i = 0, 1, ..., 2m 1.

Let's dene the ode by bj = aj crj . Then the inverse (de oding)
ode is aj = bj crj . Thereby cr is alled a key of a ode . Any
person is able to read a se ret message b = bi1 bi2 bim if that
person possesses the key. But it is almost impossible to nd unknown cr , i.e. the se ret key r . The number of all available keys
(2m ) is really a huge number when n is large enough. For example,
when m = 260 (a message of 52 words of 5 letters ea h) the number of all possible keys r is 2m 1078  it equals the hypotheti al
number of ele trons in the Universe!
Please note that an arbitrary key r {0, 1, . . . , 2m 1} an not be
able to guarantee the se re y of a message. For example, b = a if
r = 0. If the rst elements of cr are null elements, the rst part of
the oded message will stay not-en oded.

100

DEFINITION

The keys that guarantee the se re y are alled

iphers .

The formation and the reliability of iphers is a subje t of


tography 31 .

ryp-

4.3. FEW SAMPLES OF CODES


Below we onsider few samples of well-known odes. They were
reated to solve the below listed oding problems.

4.3.1. Code of Two of Five


This ode en odes de imal digits for ve binary digits:

0
1
2
3
4

11000
00011
00101
00110
01001

5
6
7
8
9

01010
01100
10001
10001
10100

The fth digit is the ontrol digit added at the end of a blo k in
order to equate the number of units in ea h blo k to two.

DEFINITION

Codes of this type are alled parity odes . On this o asion the
last digit of a blo k gets the name of a parity bit .
31

ryptoanalysis .
ryptology .

De oding is a subje t of

toanalysis are parts of

101

Both ryptography and ryp-

4.3.2. Morse Code


The Morse 32 ode is a system of representing letters, numbers and
pun tuation by means of a signal sent intermittently. It uses two
states on and o and a gap . Without the usage of a gap we
would not be able to distinguish EE and I, IE and EI, IE and S,
et .(see the ode list).
A
B
C
D
E
F
G

J

K

L

N

O

P
H

Z

R


Q
I
1
3
5
7
9

V

W

X

Y

The shorter odes orrespond to the letters of higher frequen y.


Morse re eived the ne essary information about the frequen ies of
English letters in a printing-house. It is interesting to ompare the
lengths of the Morse ode with statisti al data on the frequen ies
of English letters in modern letterpress.
32

Samuel Finley

Breese

Morse

(1791

painter.

102

1872)

Ameri an

inventor and

Fig 9. Frequen ies of letters in English letterpress

4.3.3. Caeser Code


Caeser33 used this se ret ipher in his orresponden e with Ci ero34 .
A
D

B
E

C
F

D
G

E
H

F
I

G
J

T
W

U
X

V
Y

W
Z

X
A

Y
B

Z
C

4.3.4. Book Numeration


International standard book numeration system ISBN35 uses 10digital de imal ode (the dashes are introdu ed merely for user33
34

Gaius Julius Caesar (100  44 B.C.)  the emperor of Rome.


Mar us Tillius Ci ero (106  43 B.C.)  Roman politi ian, orator and

writer.

35

International Standard of Book Numeration.

103

friendliness)36 :

a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 .

The rst 9 symbols are de imal digits {0, 1, . . . , 9}.


The last digit a10 is ontrol symbol and has available value of
{0, 1, ..., 8, 9, X}. Its value is the sum
9
X
j=1

jaj a1 0 (mod 11),

where 10 is repla ed by X . Re all, that x y (mod 11) means


that 11 divides x y .
Thus, the ontrol sum of ISBN ode an be written as below:
10
X
j=1

ja11j 0 (mod 11).

Example

Let us onsider ISBN ode of one of Lithuanian issues:

5 430 02548 8.

Prex 5 430 points to Kaunas publishing house "viesa". The


ontrol sum is:
15+24+33+40+50+62+75+84+98 =

5 + 8 + 9 + 0 + 0 + 12 + 35 + 32 + 72 =
173 = 15 11 + 8 8

(mod 11).

The se ond formula leads to the same result:

1 8 + 2 8 + 3 4 + 4 5 + 5 2 + 6 0 + 7 0 + 8 3 + 9 4 + 10 5 =

8 + 16 + 12 + 20 + 10 + 0 + 0 + 24 + 36 + 50 =

36

176 = 16 11 0 (mod 11).


The rst four digits en ode the ountry of issue and the printing-house.

Digits

a5 . . . a 9

en ode the issue itself.

104

4.3.5. European Arti le Numeration

European Arti le Numeration systems EAN13 ode also known


as EAN bar ode onsists of 13 de imal digits:
a1 a2 a3 a4 a12 a13

and has the following ontrol sum :

a1 + 3a2 + a3 + 3a4 + + a11 + 3a12 + a13 0

(mod 10).

Let us onsider the ode of some item made in Lithuania37

477 008048113 1.
The ontrol sum ondition is fullled:

4 + 3 7 + 7 + + 3 1 + 1 + 3 3 + 1 = 90 = 9 10 0

37

The

(mod 10).

prex (477) is pres ribed by the ountry of origin of an item (Lithua-

nia).

105

Fig 10. A multi-graph


5.

GRAPH THEORY

5.1. BASIC NOTIONS


5.1.1. Multi-graph
An obje t des ribed in Fig 10. is a multi-graph . Thus, a multigraph is a olle tion of points and of line segments that onne t
these points. Given points are alled multi-graph verti es and
dire ted line segments  multi-graph lines or ar s .
Let's suppose that the set of multi-graph verti es is
V = {v1 , v2 , . . . , vn }. Then the multi-graph line l an be dened
as an element of the following Cartesian produ t :

l = (vi , vj , k) V V N.

Here vi is an initial vertex of line l, vj is a nal


is line number , N is a set of positive integers.

106

vertex , k N

Two lines are said to be parallel lines , i their initial and nal
verti es oin ide. Thus, lines l1 = (vi , vj , 1) and l2 = (vi , vj , 2) are
parallel. If a graph has no parallel lines , we are able to re ognize
arbitrary line even when the set of lines is not numbered . Line
l, whose initial and nal verti es oin ide, is alled a loop : l =
(v, v, k).

5.1.2. Dire ted Graph


DEFINITION

A multi-graph that ontains no parallel lines is a dire ted graph ,


or a digraph . A dire ted graph without loops is a simple digraph .
Be ause there is no need to introdu e any order in the set of simple
digraph lines, this set an be said to be simply a subset of V V .
We know that this subset is a binary relation in the set of digraph
verti es V . Let us remind you that relation L V V is irreexive
if (v, v)
/ L v V . Consequently, a digraph has no loops, i the
orresponding binary relation is irreexive.
Finally, we an dene simple digraph G as a pair of sets V and
L: G = (V, L), where L V V is any given irreexive relation.
Lines of digraph are alled ar s .

5.1.3. Undire ted Graph


Suppose that simple digraph G = (V, L) is a symmetri graph,
i.e. that L is a symmetri relation: (vi , vj ) L (vj , vi ) L.

DEFINITION

Simple digraph G = (V, L) is said to be a simple undire ted


graph (simple graph), i L additionally is a symmetri relation
107

in V . A graph is understood a simple undire ted graph with additional loops.

DEFINITION

Let G = (V, L) be a simple graph. We repla e any pair of ar s


(vi , vj ), (vj , vi ) with a pair {vi , vj } = e and all it an edge of
simple undire ted graph . Set of simple undire ted graph edges
we denote E = {e} = {vi , vj } when the graph itself G = (V, E).
The order of verti es vi and vj in pair {vi , vj } is not important
now (be ause G is a symmetri graph), thus the set of edges E of
a simple undire ted graph is:

V (2)

E = {{vi , vj }, vi , vj V } V (2) ,
= {{v1 , v2 }, {v1 , v3 }, . . . , {vn1 , vn }} = {{vi , vj }, i < j},
i, j = 1, . . . , n.

Remark

Below we will study mainly the simple graphs and will all them
simply graphs . By digraphs let's understand simple digraphs .
Non-simple undire ted graphs, non-simple digraphs, multi-graphs,
when they will appear, will be identied additionally.
Let us highlight the fa t that the main of further denitions that
will be given below for graphs are appli able to digraphs or even
to multi-graphs as well.

DEFINITIONS

The order n of graph G = (V, E) is the ardinality of its vertex


set: n = |V |.
Graph G = On = (V, ) is alled an empty graph . As usual, n
denotes the order of a graph. Graph G = (, ) is alled a null
graph.
108

The graph of order n that ontains all available edges, is alled a


omplete graph and is denoted Cn .
It is easy to understand that a omplete graph of order n has
n(n 1)
edges when omplete digraph has n(n 1) ar s.
2
Two verti es vi and vj of graph G = (V, E) are said to be adja ent verti es , i {vi, vj } E . Verti es vi and vj are adja ent
verti es of digraph G = (V, L) i (vi, vj ) L (vj , vi ) L.
Any of verti es vi and vj is said to be in ident
edge {vi , vj } (to both ar s (vi , vj ) and (vj , vi )).
Two edges are said to be adja ent edges
a vertex that is in ident to both edges.

vertex to the

(ar s), i there exists

Remark

adja en y is a property of the same kind obje ts when the


in iden e is a property of obje ts that are of dierent nature.

The

5.1.4. Order of Vertex


DEFINITIONS

The neighborhood of vertex v V in graph G = (V, E) is the set


of all adja ent verti es:

(v) = {w V : {v, w} E}.

If G = (V, L) is a digraph, neighborhood (v) of any vertex v an


be represented
(v) = (v) + (v),
where

(v) = {w : w V, (v, w) L}, + (v) = {w : w V, (w, v) L}.


109

Fig 11. Fifth order omplete and empty graphs


Thus, vertex subset (v) is asso iated with the ar s that originate at v when subset + (v)  with the ar s that terminate at
v.
Sin e a digraph has no parallel ar s nor loops,

+ (v) (v) = .
Number p(v) = |(v)| is alled an
G(V, E).
If G(V, L) is a digraph, then

order

of vertex v in graph

p(v) = p(v) + p(v)+ | (v)| + |+ (v)|.


Numbers p (v) and p+ (v) are alled, respe tively, the
and the indegree of vertex v .

outdegree

Vertex v is said to be a sour e of a digraph if p+ (v) = 0, p (v) >


0, and it is said to be a sink if (p+ (v) > 0, p (v) = 0).
110

It is easy to see that any edge is in ident to two verti es in the


graph (please do not forget that we understand under the graph
any simple undire ted graph ). Thus, any edge is ounted twi e
al ulating the orders of verti es. This observation lies in the basis
of proof of Euler 38 theorem:

THEOREM

The sum of orders of all (simple undire ted) graph verti es is twi e
n
1P
the number of graph edges: |E| =
p(vi ), n = |V |.
2 i=1

Corollaries
1. The sum of all vertex orders in any graph is even.
2. The number of verti es, that are of odd order, is

even in any
graph.
3. Any vertex of omplete graph Cn of order n has order n 1.
Any vertex of omplete digraph Cn of order n has order 2(n 1).

Problems
1. Prove the orollaries.
2. Determine the neighborhoods and the orders of verti es of
graphs in Fig 16. and Fig 43.

DEFINITIONS

Any v V is alled an isolated vertex if p(v) = 0.


Any vertex v is said to be a rising vertex if p(v) = 1.
Graph G(V, E) is said to be a homogeneous graph when all its
verti es are of the same order: p(v) = p(w) v, w V .
If, additionally, p(v) = 2, v V , then graph is alled a y le 39
and is denoted Cn (n = |V |).
38

39

Leonhard Euler (1707  1783)  Swiss mathemati ian.


We suppose that our graph initially is a onne ted graph (see 5.3.2.).

Otherwise it would be possible to get few separate y les instead of one y le


a ording to this denition.

111

5.2. ISOMORPHIC GRAPHS


5.2.1. Con ept of Isomorphism
It may happen that the set of graph verti es V of the same graph
G an be denoted by various symbols in dierent appli ations.
The same an happen with the symbols denoting an edge set.
Therefore, it an be that two pairs of sets (V1 , E1 ) and (V2 , E2 )
(|V1 | = |V2 |) are just two dierent notations of the same graph.
So: are G1 = (V1 , E1 ) and G2 = (V2 , E2 ) two really dierent
graphs?
We have a positive answer to this question, if |V1 | =
6 |V2 | or
|E1 | =
6 |E2 |. If otherwise, it is not easy to answer this question.

DEFINITION

Graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are said to be two isomorphi graphs (that is denoted by G1
= G2 ), if there exists
su h bije tion f : V1 V2 , that

{vi1 , vj1 } E1 {f (vi1 ), f (vj1 )} E2 ,

{vi2 , vj2 } E2 {f 1 (vi2 ), f 1 (vj2 )} E1 .

Example

Vertex and edge sets of graphs in Fig 12. an be denoted by:

V1 = {a, b, c}, E1 = {{a, b}, {b, c}},

V2 = {u, v, w}, E2 = {{u, v}, {v, w}.


Bije tion

f (a) = u, f (b) = w, f (c) = v


realizes isomorphism between these graphs.
112

Fig 12. Two isomorphi graphs

Problems
1. Sket h few

isomorphi graphs of the fourth and of the fth


order.
2. Let G1 = (V1 , E1 ) and G2 = (V2 , E2 ) be two isomorphi graphs.
What an you say about the matri es of relations E1 and E2 (see
se tion 3.1.2.)?

5.2.2. Labeled and Unlabeled Graphs


We say that isomorphi graphs are related by
phism relation.

graph isomor-

THEOREM

Graph isomorphism is an equivalen e relation.


Proof. By the denition of an equivalen e relation graph isomorphism is equivalen y i (if and only if) it has three following properties:
1) It is a reexive relation. If so, there must exist graph isomor113

phism of graph G to itself. It is easy to see that this isomorphism


is realized by bije tion f (vi ) = vi .
2) It is a symmetri relation. This statement is valid be ause the
fa t that f : V1 V2 is a proper bije tion (it satises the requirements of graph isomorphism denition) implies that f 1 : V2 V1
also is a proper bije tion.
3) It is a transitive relation. Let f : V1 V2 and h : V2 V3
and both f and g be proper bije tions. Then the omposition
(f h) : V1 V3 is a proper bije tion too. That means that we
have proved the transitivity of graph isomorphism as well as the
whole theorem.

DEFINITION

A lass of graphs, any representatives of whi h are isomorphi


graphs one to another, is said to be unlabeled graph . Any element of this lass is alled a labeled graph .

Remark

In other words, any unlabeled graph is an equivalen y


some labeled graph with respe t to graph isomorphism.

lass

of

Problem

Sket h unlabeled and labeled graphs of the se ond and of the fourth
order.

5.2.3. Invariants
Now we are interested in the properties of an unlabeled graph that
are valid for its any labeled graph. In other words, we are interested
in the properties of labeled graphs that are invariant with respe t
to the graph isomorphism.

114

Fig 13. All labeled graphs of the third order

DEFINITION

Graph hara teristi 40 that has the same value for any isomorphi graphs is said to be a graph invariant .
For example, graph order n(G) = |V |) and the number of all graph
edges m(G) = |B| both are graph invariants. The set of orders of
all graph verti es {p1 , p2 , . . . , pk } also is a graph invariant. Further
we will nd more graph invariants.

5.2.4. Number of Graphs


It is easy to see that there are exa tly 8 dierent labeled graphs of
the third order (look at Fig 13.). Let's try to nd the number of
all available graphs of arbitrary order n = |V |.
2
The
 number of all available pairs of graph
 verti es
 n is m = Cn =
n
n(n 1)
m
k =
2
=
. There are Cm
=
ways to pi k
2
2
k
k
40

Graph hara teristi is a variable whi h value depends on a ertain graph.

115

k is the number of
out k pairs of verti es given m pairs. Thus Cm
all possible graphs of order n, ontaining exa tly k edges. Consequently, the number of all labeled graphs of order n is:
m  
X
m
k=0

 
n
, m=
.
k
2

Let us onsider fun tion


m  
m
X
m k X k k
x =
Gn (x) =
Cm x = (1 + x)m .
k
k=0

k=0

The last equality is a parti ular ase of Newton's formula of power


of binomial. Consequently, the wanted number of all labeled graphs
of order n is
n
Gn (1) = (1 + 1)m = 2( 2 ) .
If n = 3 (look at Fig 13.), we have

m = C32 = 3, G3 (1) = 23 = 8.
The number of all labeled dire ted graphs an be found by analogy. Really, the number of dire ted graphs of order n, that ontain
k
n (1),
exa tly k edges, is Cn(n1)
. Then the number of all graphs is G
where
n(n1)
X
k

Gn (x) =
Cn(n1)
xk = (1 + x)n(n1) .
k=0

Thus,

n (1) = 2n(n1) .
G
n (x)
It is easy to prove the following relation between fun tions G
and G(x):
n (x) = (G(x))2 .
G
116

Fig 14. The third order unlabeled dire ted graphs

Remark

All known formulas of number gn of all unlabeled graphs of order n


are too umbersome. For large n we an use an asymptoti formula
n
2( 2 )
gn
, n .
n!

5.2.5. Planar Graphs


Isomorphi graphs an be denoted using dierent symbols as well
as dierent diagrams an be used to des ribe isomorphi graphs.

DEFINITIONS

Suppose, that all verti es of graph G lie in some plane and that
interse tion points of arbitrary two graph edges are verti es of G.
Then G is said to be a plain graph .
A graph, isomorphi to any plain graph, is said to be a planar
graph .
117

Fig 15. Three well and three houses problem


One of well known planar graph problems is the problem of three
well and three houses : onne t all houses with all wells in su h a
way that no tra ks ross. This simply stated problem has no simple
solution. Even more, Kuratowski 41 has proved in 1930 that this
problem has no solution at all. Consequently, an arbitrary graph
annot be a planar graph.

5.3. GRAPH CONNECTIVITY


5.3.1. Walks and Cir uits
Let G = (V, E) be an arbitrary graph.

DEFINITION

Any nite sequen e of graph verti es and of edges

W = vi0 , ei1 , vi1 , ei2 , . . . , vik , eik , vik ,


41

Kazimierz Kuratowski (1896  1980)  Polish mathemati ian.

118

Fig 16. Routes and ir uits


where eij = {vij1 , vij }, is alled a walk .
For example, the graph in gure 16 has walk M :

a, {a, b}, b, {b, c}, c, {c, e}, e, {e, f }, f,

{d, f }, d, {c, d}, c, {b, c}, b, {b, d}, d.

We an denote this walk simpler:

M = (a, b, c, e, f, d, c, b, d).
There exist other walks in this graph, for instan e:

M1 = (a, b, c, d, e),
M2 = (c, e, g),
M3 = (b, c, e, f, d, b),
M4 = (a, b, d, c, e, f, d, a).

DEFINITIONS

A walk is alled a

ir uit , i all its edges are distin t.


119

Verti es vi0 and vik are alled terminal verti es of a ir uit C


when vij , j = 1, 2, . . . , k 1 are alled internal verti es. vi0 is said
to be an initial (start) ( vertex of a ir uit when vik is alled a
nal (end) vertex of a ir uit.
We say that a given ir uit is an open ir uit , if its terminal
verti es do not oin ide. Otherwise, we have a losed ir uit .
Any open ir uit is alled a path .
Any losed ir uit is said to be a y le .
A ir uit is said to be a simple ir uit , if all its internal verti es
are dierent from ea h other.
Thus, walk M is not a ir uit, but both walks M1 and M2 are
ir uits. Both ir uits M1 and M2 are paths, both M3 and M4 are
y les. Cy le M3 is a simple ir uit, but M4  isn't.

Remark

Walks, ir uits, paths, y les of

digraphs are dened by analogy.

Problems
1. How many walks exist starting at vertex a of the graph in Fig

16?
2. Draw all the ir uits and all simple ir uits that start at vertex
a of the graph in Fig 16.
3. Draw all y les of the graph in Fig 16.

5.3.2. Conne ted Components of a Graph


DEFINITION

Graph G is a onne ted graph , if arbitrary pair of its verti es


an be onne ted with a path. Otherwise, G is said to be a dis onne ted graph .
120

Suppose that G = (V, E) is a dis onne ted graph. Then a set of


its verti es V an be divided into two disjoint blo ks V1 and V2
(V = V1 V2 , V1 V2 = ) that

v, w V : v V1 & w V2 {v, w} E & {w, v} E.

If there exists any pair of verti es of blo k V1 that annot be onne ted with a path, we divide this blo k into blo ks V1 = V3 V4 ,
that satisfy the following ondition: any pair of verti es v and w
where v V3 , w V4 an't be onne ted with a path.
Repeating this pro ess, after some nite number of analogi al steps
we will obtain the partition of set V

V = V1 V2 Vk , Vi Vj = i 6= j,

where any pair of verti es from Vs V an be onne ted with


a path in G(V, E), but any pair of verti es, whi h belong to two
dierent subsets Vi and Vj - an't.
Let us denote by Ej subset of E , whi h elements are su h edges
of graph G = (V, E) that are in ident at least to one vertex from
blo k Vj .

DEFINITION

Graph Gj = (Vj , Ej ) is said to be a


graph G = (V, E).

onne ted omponent

of

Remarks
1. The number of all onne ted omponents of any graph does not

ex eed the order of this graph.


2. If any graph of order n has exa tly n onne ted omponents,
they all are the isolated verti es of this graph. Consequently, this
graph is an empty graph.
3. A onne ted graph of the se ond order has exa tly one edge.
4. A onne ted graph of the third order has two or three edges.
121

Fig 17. All onne ted omponents of a graph

5.3.3. Conne tivity Relation


DEFINITION

Let G = (V, E) be an arbitrary graph. In the set of graph verti es


V we dene a graph vertex onne tivity relation V 2 =
V V:

(u, w) [(u = w) (u, vi1 , . . . , vik , w)].


In other words, vertex u is related to vertex w, i they an be
onne ted with a path in a given graph.

THEOREM

A graph vertex onne tivity relation is an equivalen e relation.


Everyone is able to prove this statement verifying the basi properties of an equivalen e relation :
122

1) v V : vv  reexivity;
2) vw wv  symmetry;
3) vw & wu vu  transitivity.
Therefore, the set of graph verti es V an be represented as a
sum of equivalen e lasses with respe t to a vertex onne tivity
relation. In other words, there exists su h partition of set V that
these equivalen e lasses are blo ks of partition.

THEOREMS
V , E)
G(V, E)
1. Graph G(

where V is any vertex equivalen e

lass with respe t to the graph vertex onne tivity relation and E

is the set of edges that are in ident at least to one vertex from V
is a onne ted omponent of graph G(V, E).
2. A graph is a onne ted graph i its vertex set has only one
equivalen e lass with respe t the graph vertex onne tivity relation.
3. In any dis onne ted graph G there exist two verti es that no
path in G has those verti es as its initial and nal verti es.

Problem

Prove these theorems.

5.3.4. The Longest Path


DEFINITION
The

length of a path is a number of edges in a path.

THEOREM

Any two paths of maximal length in any onne ted graph ontain
at least one vertex that belongs to both of them.
Proof. Assume that P1 = (v0 , v1 , . . . , vk ) and P2 = (v0 , v1 , . . . , vk )
are two paths in graph G = (V, E), both of maximal length. Sin e
123

Fig 18. The longest paths in a graph

G is a onne ted graph, an arbitrary pair of its verti es an be


onne ted with some path. Let's hoose graph verti es vi P1
and vj P2 su h, that it ould be possible to onne t them with
su h path Pa = (vi , . . . , vj ), that any internal vertex of Pa would
not belong to P1 or to P2 (if Pa does not exist, then paths P1 and
P2 have at least one vertex, that is a ommon vertex for both of
them, onsequently, the proof of the theorem is nished in this
ase). Let us denote t1 = (v0 , v1 , . . . , vi ), t2 = (vi , . . . , vk ),t1 =
(v0 , v1 , . . . , vj ), t2 = (vj , . . . , vk ). Let |t1 | > |t2 | ir |t1 | > |t2 | (if
inequalities are opposite, follow analogi al argumentation). Then
the length of path t1 , Pa , t1 is:
|t1 | + |Pa | + |t1 | > |t1 | + |t2 | = k.
This inequality ontradi ts our premiss that both P1 and P2 are
the longest paths. Hen e the theorem is proved.

Example

Graph G = (V, E), V = {1, 2, 3, 4, 5, 6}, E = {{1, 2}, {2, 3}, {2, 4},
{1, 5}, {1, 6}, {2, 5}, {4, 5}} in Fig 18. has, among the others, the
124

following two paths of maximal length:

P1 = (3, 2, 4, 5, 1, 6), |P1 | = 5,

P2 = (6, 1, 2, 4, 5, 1), |P2 | = 5.

Verti es 1, 2, 4, 5, 6 are ommon verti es for both of them.

Problems

Find the longest paths of the graphs in Fig 16. and Fig 20.

5.3.5. Metri Chara teristi s of a Graph


Let G = (V, E) be any onne ted graph and u, w V be arbitrary verti es of G. Let's number all the paths onne ting these
verti es:

Pk = (u, vi1 , vi2 , . . . , vilk , w), k = 1, 2, ..., r.

DEFINITION

The distan e between two verti es u and v is the length of the


shortest path onne ting these verti es:

(u, w) = min |Pk (u, . . . , w)|.


k

Let's note that this fun tion really has the main properties of
ri s :
1) (u, w) > 0, (u, w) = 0 u = w;
2) (u, w) = (w, u) u, w V ;
3) (v, u) + (u, w) > (v, w) v, u, w V .

Problem

Prove these statements.


125

met-

Distan es between the verti es of the graph in Fig 18. are: (1, 2) =
1, (3, 6) = 3, (5, 3) = 2.

Remark

If G is a dis onne ted graph, the denition of the distan e between


its verti es is supplemented by an additional ondition, whi h
states that the distan e between any two verti es v and w, belonging to dierent onne ted omponents of a given graph is innite:
(v, w) = . Then all properties of metri s are to be held.

DEFINITIONS
1. The diameter of a graph

graph verti es:

is the maximal distan e between

d(G) = max (v, w).


v,wV

The e entri ity of a vertex is the maximum of its distan es


to other verti es of a given graph:

2.

e(u) = max (v, u).


vV

3. Vertex c V is alled a enter of


e entri ity among all graph verti es:

a graph , i it has minimal

e(c) = min e(v).


vV

4.

The

radius of a graph is graph enter e entri ity:


r(G) = min e(v).
vV

5. A simple ir uit is said to be a diametri al ir uit , i it is


of length d(G) and it is the shortest path onne ting its terminal
verti es.
The diameter of a graph in Fig 18. equals the radius of this graph:
d(G) = r(G) = 3. E entri ities of graph verti es are: e(1) =
126

Fig 19. Union and interse tion of two graphs

e(2) = 2, e(3) = e(6) = 3. Verti es 1, 2 and 5 all are enters


of this graph. Cir uits (v3 , v2 , v1 , v6 ) and (v4 , v5 , v1 , v6 ) both are
diametri al ir uits.

Problems
1. Find all metri hara teristi s of graphs in Figs 16 and 20.
2. Prove the statement of the above remark.

5.4. GRAPH OPERATIONS


5.4.1. Graph Union and Graph Interse tion
Let G1 = (V1 , E1 ) and G2 = (V2 , E2 ) be arbitrary graphs.

DEFINITION

Union G1 G2 and interse tion G1 G2 of graphs G1 and G2


are:

G1 G2 = (V1 V2 , E1 E2 ), G1 G2 = (V1 V2 , E1 E2 ).
127

Fig 20. A graph and its omplement

5.4.2. Subgraph. Graph Complement


DEFINITIONS

Any graph G = (V , E ) is a subgraph of graph G = (V, E), if


V V and E E . Then we write G G.
Let E be a relative omplement of E in set of edges of the omplete graph whi h has vertex set V . Graph G = (V, E) is alled
the omplement of a graph G(V, E).
For instan e, any onne ted omponent of a graph is its subgraph.
You an see a sample of a graph omplement in Fig 20.

Corollaries
1. G G = Cn , where the omplete graph of order n = |G| = |Cn |
is denoted by Cn .
G G = n is the empty graph of order n = |G|.

2.

128

Fig 21. The y li al sum of graphs

Problems
1. Prove the statements of orollaries.
2. Prove that G1 (G1 G2 ) and (G1 G2 ) G2

for any two


graphs G1 and G2 .
3. Given G1 = {{a, b, c, d, e}, {{a, b}, {a, d}, {b, c}, {b, e}, {c, e}, {d, e}}},
G2 = {{c, d, e, f, g, h}, {{c, d}, {c, e}, {d, e}, {d, g}, {d, h}, {f, h}}},
sket h these graphs and both the union and the interse tion of G1
and G2 . Draw the omplements of both given graphs.

5.4.3. Cy li al Sum of Graphs


DEFINITION

The y li al sum of graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) is


, where
graph G1 G2 = (V , E)

= {{v, w} : [{v, w} E1 & {v, w}


E
/ E2 ]

[{v, w} E2 & {v, w}


/ E1 ]},

V = {v V1 V2 : {v, w} E}.
129

Fig 22. The removal of graph vertex a

Problems
1. Prove that

the y li al sum G1 G2 of arbitrary two graphs


has no isolated verti es.
2. Sket h the y li al sum of graphs G1 and G2 of problem 3 in
se tion 5.4.2.

5.4.4. Vertex Removal


The removal of
(V , E ), where

vertex v on graph G(V, E) is denoted by Gv =

V = V \ {v}, E = E \

wV :{w,v}E

{w, v}.

So, we remove vertex v from set V and also all graph edges, whi h
are in ident to v , from set E .

130

Fig 23. The edge removal

5.4.5. Edge Removal


Let's dene the operation of edge
edge of graph G = (V, E), then

removal :

if (v, w) E is an

G {v, w} = (V, E \ {{v, w}}).


Please note that we remove an edge, but all in ident verti es remain
in the graph (look at Fig 23.).

5.4.6. Superposing Verti es


Two verti es v and w in graph G(V, E) are both repla ed with a
new vertex u. Edges, in ident to any of v or w, are repla ed with
new edges, whi h are in ident to u in su h a way that all verti es,
that were adja ent to any of v or w, be ome adja ent to u (see Fig
24.).

131

Fig 24. Superposing of verti es v and w

5.5. SEPARABILITY OF GRAPHS


5.5.1. Arti ulation Points
DEFINITION

Graph G(V, E) is said to be a separable graph, i it or its onne ted omponent an be dis onne ted removing one vertex alled
graph arti ulation .
A graph that is not separable is said to be a bi onne ted or a
nonseparable graph.

Example

Graph ({u, v, w}, {{u, v}, {u, w}, {v, w}}) is a bi onne ted graph
but ({u, v, w}, {{u, v}, {u, w}}) is a separable graph. Vertex u is
an arti ulation of it.

THEOREMS
1. Vertex v V

is arti ulation of graph G = (V, E) i there are


su h two verti es u, w V , that vertex v belongs to arbitrary path
132

Fig 25. Graph arti ulation v

P , onne ting verti es u and w:


u, w V, u 6= v, w 6= v : v P, P = (u, vi1 , . . . , vik , w).

2. Any nonempty graph has at least two verti es whi h are not
arti ulations of this graph.
Problems
1. Prove theorem 1.
2. Prove theorem 2 at least for some xed order graphs.
3. Determine whether an empty graph G = ({v}, ) is a separable
or a bi onne ted graph.

5.5.2. Graph Blo ks


DEFINITION

Any maximal bi onne ted subgraph is said to be a blo k of a graph.


I a given graph is a bi onne ted graph, it is a graph blo k itself.
133

Fig 26. A graph and it's blo ks


Graph in Fig 26. has six blo ks (see them on the right side of the
pi ture). They all are maximal nonseparable subgraphs : adding any
graph vertex to anyone of them would break their bi onne tivity.
For instan e, blo k

({1, 2, 3, 4}, {{1, 2}, {2, 3}, {3, 4}, {4, 1}, {2, 4}})
an't be augmented with any of sets ({5}, {3, 5}) or ({7}, {3, 7}),
be ause after that operation we will get a separable subgraph. On
the other hand, after removing an arbitrary vertex of a blo k it
will not be a maximal nonseparable subgraph.

Problem

Find all blo ks of the graph in Fig 40.

5.5.3. Trees and Forests


We hoose one of possible denitions of a tree:
134

Fig 27. A two-tree forest

DEFINITIONS

A graph without any y les is said to be an a y li


Any onne ted and a y li graph is alled a tree .

graph .

THEOREMS
1. A graph is a tree, i any pair of graph verti es an be onne ted

with a unique path.


2. Any tree of order n has exa tly n 1 edges.

Problems

Prove the rst theorem following the denitions and the se ond
one using the method of mathemati al indu tion. Keep in mind
that by graphs we understand simple undire ted graphs.

DEFINITION

A y li graph that has k onne ted omponents is said to be a


forest of k trees .
135

It is lear that an arbitrary onne ted omponent of a forest is a


tree. If k = 1, this forest is simply a tree. Thus, the previous
theorem implies the following one:

THEOREM

Any forest of k trees of order n has exa tly n k edges.


(Prove it! )

5.5.4. A Separating Set and a Cut


DEFINITIONS

An edge is said to be a bridge of a onne ted graph, if removing


it we dis onne t this graph. An edge is said to be a bridge of
dis onne ted graph, if it is a bridge of some onne ted omponent
of this graph.
Subset S E is a separating set of onne ted graph G(V, E), i
graph G = (V, E \ S) is a dis onne ted graph.
Any minimal separating set is said to be a ut .
In other words, C E is a ut, i C is a separating set, but
C C, C 6= C  is not. It is evident that any bridge is a
separating set and also a ut.
Set of edges

{{2, 4}, {2, 3}, {3, 4}, {3, 7}, {6, 7}}
of the graph in Fig 28. is a separating set, but not a ut. Set

{{2, 4}, {3, 4}, {6, 7}}


is a ut. This graph has no bridges.
136

Fig 28. A separating set and a ut

Problems

Determine some of separating sets and nd the uts of the graph in
Fig 26.. Determine the edge after the removal of whi h the bridges
would appear in a graph.

5.6. GRAPH CYCLES


5.6.1. Seven Bridges of Knigsberg
City of Knigsberg, Prussia, (now Kaliningrad, Russia) was set on
the Pregel river and in luded two islands whi h were onne ted
with ea h other and the banks of the river by seven bridges (look
at Fig 29.). The question is whether it is possible to walk by the
route whi h rosses ea h bridge exa tly on e and to return to the
starting point.
In 1736 Leonhard Euler (see pg. 111) proved that it was not possible. In the 1750s the prosperous and edu ated townspeople walked
on Sundays trying to solve this problem, but this might be a legend.
137

Fig 29. Seven bridges of Knigsberg

5.6.2. Eulerian Graphs


Let's repla e the islands and both the Pregel's banks by verti es
and all seven bridges by edges. Then the s heme of Knigsberg
bridges an be repla ed by a multi-graph (Fig 30.). Introdu ing
two  titious verti es F1 and F2 on both external edges whi h
are parallel to other ones, we get a simple undire ted graph (on the
right side of the pi ture).

DEFINITION

Eulerian y le is a y le whi h uses ea h graph edge exa tly on e.


A graph that has Eulerian y le is said to be Eulerian graph .
Consequently, the problem of seven bridges of Knigsberg has a
positive solution i the graph in Fig 30. is Eulerian graph.
The above theorems belong to Leonhard Euler .

LEMA

If any graph vertex has the order ex eeding or equal to 2, then the
138

Fig 30. Knigsberg Bridges graph and this graph with additional
 titious verti es
graph has at least one y le.
Proof. Let v0 be an arbitrary vertex of a graph. Sin e p(v) > 2,
vertex v has at least one adja ent vertex v1 , whi h also has adja ent
vertex v2 . If v2 = v , then we have a y le. If otherwise, let us
ontinue the pro ess. The number of all verti es |V | = n is nite,
thus this pro ess is also nite. After k n steps we will get vertex
vk whi h was got before: vk = vl , 0 l < k. Thus, vl , vl1 , , vk
is a y le.

THEOREM

Any onne ted undire ted graph is Eulerian graph, i the order of
any its vertex is even.
Proof. Ne essity of ondition. Any Eulerian graph has a y le
whi h rosses ea h graph edge exa tly on e. Let us move along
this y le in any xed dire tion. Let v0 be the start vertex (of
ourse, v0 an be an arbitrary vertex). When moving we enter
next vertex v1 and leave it by dierent edges, be ause edges do
not repeat in Eulerian y le. Consequently, p(v1 ) > 2. By analo139

Fig 31. Proof of the existen e of Eulerian y le


gy, p(vj ) > 2. If it happens that we meet some vertex twi e, the
se ond time we enter and leave it by two dierent edges, whi h do
not oin ide with the edges that we have used for the rst time.
Thus p(vj ) > 4.
After returning to the start vertex v0 , we on lude that we have
rossed ea h edge exa tly on e and have left ea h vertex on e we
have entered it. Thus, the order of any graph vertex is even.
Su ien y of ondition. (See Fig 31. for illustration.) Using lema,
we on lude that there is at least one y le C1 in a graph. Let's
remove all edges of C1 (see Fig 31.) from a graph. If after that all
graph verti es be ame to be isolated verti es, then C1 is Eulerian
y le. If a part of them remains to be not-isolated verti es, we are
sure that they still all are even order verti es (be ause the order of
any of them either does not vary or de rease by 2, 4, et .). Let us
remove all isolated verti es. A ording to the statement of lema,
the remaining graph has a y le again. Let's denote it by C2 . If
after its edges removal there is no non-isolated verti es in a graph,
140

Fig 32. The envelope puzzler

C1 C2 is Eulerian y le. Otherwise, we ontinue the pro ess.


It is lear that the pro ess will nish after some nite number of
its steps (be ause initial graph is of nite order) and we will get
Eulerian y le:
C = C1 C2 Ck , Ci Cj = .
The proof is nished.
Let us return to the problem of seven bridges of Knigsberg. The
orders of graph verti es are (Fig 30.):

p(A) = 3, p(B) = 5, p(C) = 3, p(D) = 3.


Consequently, graph has no Eulerian y le.

DEFINITION

Eulerian path is any open path whi h rosses ea h graph edge exa tly on e.

141

If we onne ted terminal verti es of Eulerian path by any additional edge, we would get Eulerian y le. Thus, the below theorem
is dire t orollary of the previous theorem.

THEOREM

Any onne ted undire ted graph has Eulerian path, i ea h graph
vertex has even order, ex ept two of them, whi h both are verti es
of odd order.
It is lear that these two verti es are the terminal verti es of
Eulerian path. Consequently, we an draw the envelope (Fig 32.)
by one ontinuous line drawing ea h line segment exa tly on e.

THEOREM
Any

onne ted digraph has Eulerian y le i


p+ (v) = p (v), v V.

Problems
1. Prove the theorem.
2. Determine Eulerian graphs in the pi tures of this book.
mine graphs that ontain Eulerian paths.

Deter-

5.6.3. Fleury's Algorithm


Previous theorems give us the tools for identifying Eulerian graphs
(and graphs whi h have Eulerian path). Fleury's algorithm
gives us a te hnique allowing to nd Eulerian y le (or Eulerian
path) (when they exist, of ourse).

Fleury's algorithm for Eulerian y le .

1) Choose arbitrary graph vertex v V .


2) Choose arbitrary adja ent to v vertex w V
142

(if v has no adja-

ent verti es, nish the pro ess)42 .


3) If edge {v, w} is not a bridge of a graph, pro eed 4. If it is,
nd the other adja ent to v vertex dierent from w, rename it w
and pro eed 4. If {v, w} is a bridge and v has no more adja ent
verti es, pro eed 4.
4) Mark edge {v, w} (for example, paint it red). After that repla e
vertex v with vertex w and pro eed 2 in a graph whi h onsists
of unmarked edges and in ident to these edges verti es of initial
graph.
5) Finish, when you have no unmarked edges.
We see that the main idea of this algorithm is: do not ross any
bridge of unmarked graph when it is possible.
Finally, Eulerian y le will onsist of marked one-after-one edges.
It is onvenient to order these edges when marking them be ause
then we will be able to des ribe our Eulerian y le as a sequen e
of these edges (whi h are edges of Eulerian y le).

Fleury's algorithm for Eulerian path is the same, ex ept step

1.

Now we must start the algorithm by hoosing one of the terminal verti es of Eulerian path. A ording to the se ond Euler
theorem of previous subse tion they both are the only graph verti es of odd order. Then we don't need the algorithms requirement
whi h is given in bra kets in the des ription of step 2.

Problems

Test Fleury's algorithm nding Eulerian y les in graphs of Figs


31. and 35. and Eulerian path in the graph of Fig 44. (assuming
the last graph to be undire ted).

42

This requirement allows us to determine non-Eulerian grahs.

143

Fig 33. Hamiltonian y le

5.6.4. Hamiltonian Graph


DEFINITIONS

A simple y le (path) that in ludes all graph verti es is alled


Hamiltonian y le (path)43. A graph that has at least one
Hamiltonian y le is said to be Hamiltonian graph .
Let us remind you that a simple ir uit rosses its internal verti es
exa tly on e. Thus, it is possible to walk in any Hamiltonian graph
visiting ea h vertex exa tly on e after returning to the start vertex.
The graph represented in Fig 33. is Hamiltonian graph, but it is
not Eulerian graph.
No ondition that would be both a su ient and ne essary ondition for the graph to be Hamiltonian graph is known. One of
known su ient onditions requires to replete a graph with edges.
43

William Rowan Hamilton (1805  1865)  Irish mathemati ian and as-

tronomer.

144

THEOREM
If p(v) >

n
2

v V , then G(V, E) is Hamiltonian graph.

(Without proof.)
Consequently, any omplete graph (then p(v) = n 1, v V )
has Hamiltonian y le. Let us note that this theorem gives us a
su ient, but not-ne essary ondition: any simple y le Cn , whi h
in ludes n verti es, is Hamiltonian graph itself, but does not satisfy
theorem onditions when n > 4, be ause p(v) = 2 < n2 .

Problems
1. Sket h Hamiltonian

graphs that do not satisfy onditions of


this theorem.
2. Find Hamiltonian graphs among the graphs in the pi tures of
this book.

5.6.5. Edge Graph


DEFINITION

Graph Ge = (Ve , Ee ) is said to be an edge graph of graph G =


(V, E) if |Ve | = |E| and there exists su h a bije tion between Ve
and E , that adja ent verti es of graph Ge orrespond to adja ent
edges of graph G:

(v e , we ) Ee [v e = {vi , vj }, we = {vk , vl }],


where

(vi = vk ) (vi = vl ) (vj = vk ) (vj = vl ), vi , vj , vk , vl V.

145

Fig 34. A graph and its edge graph

THEOREM

Any edge graph has exa tly

n
1P
p2 (vi ) m edges (m = |E|).
2 i=1

Orders of verti es of the graph in Fig 34. are:

p(1) = 2, p(2) = 3, p(3) = 2, p(4) = 2, p(5) = 3, m = 6.


Thus,


1 2
2 + 32 + 22 + 22 + 32 6 = 9.
2
As we have no ne essary and su ient ondition for the graph to
be Hamiltonian graph, both theorems below (given without proofs)
seem to be useful on this o asion.

THEOREMS

Edge graph Ge of Eulerian graph G has both Eulerian and Hamil146

tonian y les.
Edge graph Ge of Hamiltonian graph G is Hamiltonian graph itself.

(All this subse tion theorems are given without proof.)

Exer ise

1. Sket h both G = {{a, b, c, d, e, f }, {{a, b}, {a, e}, {b, c}, {b, d}, {b, e},
{b, f }, {c, e}, {e, f }} and its edge graph Ge .
2. Test the statements of both above theorems for arbitrary Eulerian
graph.

5.6.6. Independent Graph Cy les


Let G be any graph or digraph or even a multi-graph. If G is a
graph, let us provide ea h edge with an arbitrary dire tion. Let's
denote a ertain losed walk by M = (vi0 , vi1 , . . . , vik , vi0 ).

DEFINITION

M Rm , m = |E|, where
Ve tor of walk M is ve tor

M = (c1 , c2 , . . . , cm ), cj = rj qj ,

rj is the number of passages of j 'th ar in walk M in a positive


dire tion when qj  the number of its passages in a negative dire tion.

Example

Let us onsider the digraph in Fig 35.. Our task is to nd ve tor

M of losed walk M = (1, 2, 3, 4, 5, 7, 3, 2, 7, 6, 1). Let us number


graph edges:

{1, 2} 1, {2, 3} 2, {3, 4} 3, {4, 5} 4,


{5, 6} 5, {1, 6} 6, {2, 6} 7, {2, 7} 8,

{3, 7} 9, {3, 5} 10, {5, 7} 11, {6, 7} 12.


147

Fig 35. Independent Graph Cy les


Having found all values cj = rj qj , whi h orrespond to graph
edges, we on lude that

M = (1, 1 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1) =
(1,

0 , 1, 1, 0, 1, 0, 1, 1, 0, 1, 1).

DEFINITION

Closed walks M1 , M2 , . . ., Mk are said to be independent walks ,


if their ve tors M1 , M2 , . . ., Mk are lineary independent ve tors.

Exer ise

Determine, whether y les m1 = (1, 2, 6, 1), m2 = (1, 2, 7, 6, 1) and


m3 = (2, 7, 6, 2) are independent y les or not.
Solution. Let us write ve tors of these y les:

= (1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0),
m
1

= (1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1),
m
2

m = (0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1).
3

148

Let's arrange them

1 0

A=
1 0
0 0

as rows in matrix A:

0 0 0 1
1
0 0 0 0
0
0 0 0 1
0 1 0 0 0 1 ,
0 0 0 0 1 1 0 0 0 1

and let's nd the rank 44 of A:

1 1
1
0
0
A 1 1
0 1 1
0 0 1 1 1

1
1
1
0
0
1 1 0 1 0 1 1 0 1 0
0
0
1
1
1

1 1 1
0
0
0 0 1 1 1
0 0 1 1 1

 

1 1 1
0
0
1 1
0

0 0 1 1 1
0 1 1

 

1 1 1
0
0
1 1 0

0 0 1 1 1
0 0 1

 

1 0
1 0

.
0 1
0 1

Thus, rankA = 2. Consequently, a maximal number of lineary


,

independent ve tors of ve tors
m
1 m2 , m3 equals 2. Hen e, y les
m1 , m2 ir m3 are not independent y les.
Everyone is able to assure that:
M
M
m1 = m2
m3 = m3
m2 ,
44

Look at arbitrary book on Linear Algebra.

149

Fig 36. Graph y lomati number

m2 = m1
m3 = m1

Problems
1. Graph G

M
M

m3 = m3
m2 = m2

M
M

m1 ,
m1 .

is determined by neighborhoods of graph verti es:


(k) = {p, j, v, f ), (w) = {v, j, f ), (p) = {k, v, j, f ), (v) =
{j, p, k, f, w), (f ) = {v, p, k, w, j), (j) = {k, f, p, w, v). Find the
number of independent y les of G.
2. Find the number of independent y les among y les
{4, 2, 1, 3, 2, 5, 3, 4}, {4, 2, 5, 3, 4}, {2, 1, 3, 2}, {4, 3, 5, 2, 3, 1, 2, 4},
{5, 3, 1, 5} of the omplete graph of the fth order with vertex set
V = {1, 2, 3, 4, 5}.

5.6.7. Graph Cy lomati Number


Assume that graph G = (V, E) has k onne ted omponents and
|V | = n, |E| = m.
150

DEFINITION

The y lomati number of graph G is (G) = m n + k. The


graph y lomati number is also known as a ir uit rank .

Exer ise

Let's nd the y lomati number of the graph represented in Fig


36..
Solution. k = 4, n = 10, m = 8, thus (G) = 8 10 + 4 = 2.

THEOREM

Graph y lomati number is a nonnegative value.


Proof. In this proof we use the method of mathemati al indu tion.
A null graph has a zero y lomati number: (0) = 0 0 + 0 = 0.
We also have a zero y lomati number for any rst order graph:
(G) = 0 1 + 1.
Assume that the statement of this theorem is valid for any graph
of order n: = (G) = m n + k 0. It is lear that any
graph G of order n + 1 an be made by adding one vertex and
a nite number of in ident edges to a proper graph of order n.
It may happen that G has k + 1 onne ted omponents (if the
additional vertex is an isolated vertex). Then graph y lomati
number = m (n + 1) + (k + 1) = . If the additional vertex
has l in ident edges, a maximal number of onne ted omponents
of the previous graph, that were an eled by these edges, is r l.
Thus, = (m + l) (n + 1) + (k r) 0.
The theorem is proved.

THEOREM

Any graph has exa tly (G) independent y les.

(Without proof.)
For example, the graph in Fig 36. has two independent y les:
(1,2,3,4,1) and (5,6,7,5).
151

Fig 37. Cy le basis

Remarks
1. Graph G has no y les, i (G) = 0.
2. Conne ted graph G is a tree, i (G) = 0.
3. Graph G is k-forest, i it has k onne ted
(G) = 0.
4. Graph G has exa tly one y le, i (G) = 1.

omponents and

Problems

Prove these four statements, also the following theorem.

THEOREM

The y lomati number is the smallest number of su h graph edges


whi h must be removed from a graph that no y les would remain.

DEFINITION

Any maximal set of independent graph y les is said to be a y le


basis of a graph.
152

THEOREMS
1. Any y le basis ontains exa tly (G) y les.
2. Let C1 , C2 , , C be a y le basis of a graph

G. Any y le
C G an be represented
M
M
M
C = Ci1
Ci2
,
Cir , r (G),
where

Cik C1 , C2 , , C , k = 1, 2, , r.
(Without proof.)

Example

Let us onsider the graph in Fig 37.. Its y lomati number is:
= 6 5 + 1 = 2. Cy les C1 = (a, b, c, d, e, a) and C2 = (d, e, a, d)
are independent, thus C1 , C2 is the y le basis of the graph.
L Cy le
C = (a, b, c, d, a) is a sum of these basi y les: C = C1 C2 .

Problems

Find the y lomati numbers of the graphs in the pi tures of this


book.

5.7. INDEPENDENT AND DOMINATING SETS


OF A GRAPH
5.7.1. Independent Subset
DEFINITION

Independent set of graph G(V, E) is any subset S V

of graph
verti es that any two verti es in S are not adja ent verti es:

u, v S {u, v}
/ E.
153

Fig 38. Independent graph subsets


Let us onsider the graph in Fig 38.. Sets S1 = {a, c}, S2 = {a, e}
and S3 = {a, c, e} are independent sets of this graph. It is easy to
see that any subset {v} V, v V also is an independent set of
the graph. Subset {v, w} V is not an independent set of graph
G(V, E), if {v, w} E . Our graph has an independent set ontaining three verti es and has no independent set ontaining four
verti es.
As we have mentioned above, any subset S S of an independent
set of a graph is an independent set of this graph itself. Thus, it is
urious to nd su h independent set that ontains as many graph
verti es as it is possible, or, in other words, to nd the maximal
independent set.

Let us denote the


by FI.

set of all independent sets of graph G(V, E)

154

DEFINITION
The

graph independen e number is:


(G) = max |S|.
SFI

Please note that 0 6 (G) 6 n.

THEOREM
(G) >

n
X
i=1

1
.
1 + p(vi )

(Without proof.)

Example

The graph drawn in Fig 38. has independen e number (G) = 3.


Let's nd the value of the bound of estimate given in the last
theorem:

1
1
1
1
1
+
+
+
+
=
1+3 1+2 1+3 1+1 1+1
1 1 1 1 1
11
= + + + + = .
4 3 4 2 2
6

Eight Queens Problem


What is the maximal number of queens that an be pla ed on a
hessboard so that no two atta k one another?
A single solution of this problem is represented in Fig 39.. Graph
G = (V, E), ontaining 64 verti es V = {a1, a2, . . . , h8} (that orrespond to 64 squares on a hessboard), an play a role of the
mathemati al model of the problem. Two graph verti es are adja ent i two queens he k ea h other when positioned on squares
155

Fig 39. Eight Queens Problem


that orrespond to these verti es. For instan e, all adja ent to
vertex a1 graph verti es are: a2, a3, . . ., a8, b1, c1, . . ., h1, b2, c3,
. . ., h8. Then the problem is: nd the maximal independent set of
graph G.
It is lear that a maximal number of queens an't ex eed 8. Consequently, the independen e number of G is (G) = 8.
If we want to nd all possible solutions, the problem be omes dif ult. Over the years many mathemati ians, in luding Gauss 45
worked on this problem. We nish the onsideration by referring
that this problem has 92 solutions. If we ex lude the symmetry of
solutions, there are exa tly 12 dierent solutions.

5.7.2. Dominating Set of a Graph


Let G(V, E) be an arbitrary graph.
45

Johann Carl Friedri h Gauss (1777-1855) - German mathemati ian and

s ientist, sometimes known as "the prin e of mathemati ians".

156

DEFINITIONS

An open neighborhood of vertex v V is a subset whi h onsists


of all graph verti es, that are adja ent verti es to v . When vertex
v is also in luded into neighborhood, then it is alled a losed
neighborhood for v.
Let S V be an arbitrary subset of graph verti es. An open
( losed) neighborhood of subset S V is the union of all open
( losed) neighborhoods of all verti es v V .
The dominating set of graph G(V, E) is subset S V of graph
verti es whi h losed neighborhood oin ides with the whole vertex
set V .
Subset S V of graph verti es dominates over another subset

S V , i every vertex from set S is an adja ent vertex to some


vertex from set S .

Corollaries
1. Any dominating
set

S V of graph G(V, E) dominates over


any subset S V .
2. Any vertex u that does not belong to dominating set S is an
adja ent vertex to some vertex v S .
3. The vertex set V of any graph G(V, E) is a dominating set of
a graph. Thus, it is urious to nd minimal dominating sets.
The graph in Fig 40. has the following dominating sets: {1, 3, 4, 6},
{1, 4, 6}, {3, 4}. This graph has no dominating sets that ontain
exa tly one vertex.
Let us denote the set of all dominating sets of graph G(V, E) by
FD.

DEFINITIONS

Minimal dominating set of a graph is a dominating set of min157

Fig 40. Dominating set of a graph

imal size.

The domination number (G) of graph G(V, E) is the size of


any minimal dominating set :

(G) = min |S|.


SFD

Five Queens Problem


A good example of a dominating set is Five Queen Problem in
hess. How an anyone position a maximal amount of queens on
a hessboard so that they would ommand every square on the
board? A single solution of this puzzle is represented in Fig 41..
We use the graph of Eight Queen Problem. The task is to nd a
minimal dominating set of this graph. The set {c6, d3, e5, f 7, g4}
is a dominating set of size 5.

Problems
1. Given graph G = {{f, m, p, h, c, a}, {(f, m), (f, p), (f, h), (f, c),

(f, a), (m, c), (h, c), (c, a)}}, determine whether set S = {c, h, m}
158

Fig 41. Five Queens Problem


is an independent or dominating set of the graph. Determine both
the independen e and domination numbers of graph G.
2. Determine both the independen e and domination numbers of
the graph in Fig 35..

5.7.3. Graph Kernel


DEFINITION

Any vertex subset K V is said to be a kernel of graph G =


(V, E) (of digraph G = (V, L)), i it is both an independent and
dominating set of graph G.

Examples
1. Set {c6,

d3, e5, f 7, g4} of the graph of Queens Problems is a

kernel of this graph.

2.
3.

Digraph ({1, 2, 3}, {(1, 2), (1, 3), (2, 3)}) has kernel K = {1}.
Digraph ({1, 2, 3, 4}, {(1, 3), (3, 4), (4, 2), (2, 1)}) has two
159

kernels: K1 = {1, 4} and K2 = {2, 3}.

THEOREM

Any simple onne ted graph has a graph kernel.

(Without proof.)

Problems

Find graph kernels of the graphs in the pi tures of this book.

5.8. GRAPH MATRICES


5.8.1. Adja en y Matrix
Let's assume that G = (V, L) is any digraph (maybe non-simple )
and its vertex set V = {v1 , v2 , , vn }. Let aij equal 1 when graph
G has ar (vi , vj ) and equal 0 when otherwise:
(
1, (vi , vj ) L,
aij =
0, (vi , vj )
/ L.

DEFINITION
The adja en y
matrix:

matrix

A of digraph

a11 a12
a21 a22
A = (aij ) =

an1 an2

The adja en y matrix of the

0
1

0
0

G = (V, L) is the following

a1n
a2n
.

ann

digraph in Fig 42. is:

1 0 0
0 1 1
.
0 1 1
0 0 0
160

Fig 42. Find the adja en y matrix of this graph in pg. 160
Please note that the unit in position aij orresponds to the ar
whi h originates at vj and terminates at vi . Thus, the outdegree
p and the indegree p+ of a vertex an be expressed as below:

p (vi ) =

n
X

aij , p (vj ) =

j=1

n
X

aij .

i=1

The number of digraph ar s m = |L| is:

m=

n X
n
X

aij .

i=1 j=1

If the digraph has a loop (vi , vi ) L, then aii = 1, i.e. loops


orrespond to units on the main diagonal of the adja en y matrix.
Any isolated vertex orresponds to a null row and null olumn of
the adja en y matrix.

Let digraph G have the same vertex set as digraph G and all
its ar s oin ide with digraph G ar s, but of opposite dire tions.

Hen e, its adja en y matrix A is the transposed adja en y matrix


161

of G:

A = AT = ||aji ||nn .

Let G = (V, E) be a graph (undire ted graph, maybe non-simple )


with the edge set E = {{vi1 , vj1 }, . . . , {vim , vjm }}.

DEFINITION

The adja en y matrix of graph G(V, E) is n n


matrix A = (aij ), where
(
1, {vi , vj } E {vj , vi } E,
aij =
0, {vi , vj }
/ E &{vj , vi }
/ E.

Consequently, the adja en y matrix of a undire ted graph is a


symmetri matrix. The number of graph edges m = |E| of the
simple undire ted graph is:
n

m=

1 XX
aij .
2
i=1 j=1

The adja en y matrix of a simple undire ted graph is a symmetri

matrix with null main diagonal.

THEOREM

Element aij of matrix Ak equals to the number of walks in a graph


(in a digraph ), ea h of length k, that originates at vertex vi and
terminates at vj .
(Without proof.)

Examples
1. Let us onsider

the graph in Fig


matrix of this graph. Then

0 1 0
0 1 0 0

1
0
1
1
1 0 1
A2 =
0 0 1 1 0 0 1
0 0 0
0 0 0 0
162

42.. Let A be the adja en y


0
1 0
0 1
1
=
1 0 0
0
0 0

1
1
1
0

1
1
.
1
0

Thus, there is exa tly one walk of length 2, whi h starts and ends
at vertex 1: (1, 2, 1), one walk, whi h starts at 1 and ends at 3:
(1, 2, 3), and one walk, whi h starts at 3 and ends at 4: (3, 3, 4).
There are no walks of length 2 that start at 4 or that go from 2 to
1 either from 3 to 2.
2. Let G = ({1, 2, 3}, {{1, 2}, {2, 3}}) and A be the adja en y
matrix of G:

0 1 0
1 0 1
0 2 0
A = 1 0 1 , A2 = 0 2 0 , A3 = 2 0 2 .
0 1 0
1 0 1
0 2 0
Both (1, 2, 1), (1, 2, 3) are walks, that orrespond to units in the
rst row of matrix A2 when walks (1, 2, 3, 2), (1, 2, 1, 2) orrespond
to 2 in the rst row of A3 .

Problems
1. Given graph

G = (V, E), ompare the adja en y matrix of


graph G and the relation matrix of relation E in set V .
2. Write out the adja en y matrix of the graph in Fig 35.. Determine the number of walks of length 2 and 3 onne ting arbitrary
two graph verti es. Test few results nding the requisite walks of
the required length.
3. Given graph G adja en y matrix, determine whether G is a
onne ted or a dis onne ted graph.
Hint. Use the last theorem.

5.8.2. In iden e Matrix


Let us number all edges of simple digraph G = (V, L):

L = {l1 , l2 , . . . , lm }, m = |L|.

163

DEFINITION

The in iden e matrix I = (ikr )nm of simple digraph G is dened by:

1, lr = (vk , w) L,
ikr = 1, lr = (w, vk ) L,

0, lr 6= (vk , w) & lr 6= (w, vk ) w V.

Therefore, rows of in iden e matrix orrespond to digraph verti es,


when olumns - to the ar s of a digraph. Null element ikr = 0
means that vertex vk is not in ident to ar lr , unit element ikr = 1
- that ar lr originates at vk and ikr = 1 - that ar lr terminates
at vk .

DEFINITION

The in iden e matrix I = (ikr )nm of simple graph G(V, E),


where E = {e1 , e2 , ..., em } is dened by:
(
1, er = {vk , w} E er = {w, vk } E,
ikr =
0, er 6= {vk , w} & er 6= {w, vk } w V.
Simply, ikr = 1 when er is in ident to vk and ikr = 0 when otherwise.

Example

The in iden e matrix of the digraph in Fig 43. is:

I=

0
1
0
1
0
0
1
0
1
0
0
0
1 1
0
0
0
0
0
0 1 1
1
1
0
0
0
0 1
0
0
0
0
0
0 1
164

Fig 43. For the in iden e matrix of this graph see pg.164

THEOREM

Let G = (V, E) be arbitrary simple graph, |V | = n, |E| = m, Ge 


its edge graph, I  the in iden e matrix of graph G and A  the
adja en y matrix of graph Ge . Then

A = I T I 2Im ,

where the identity matrix of order m is denoted by Im .


(Without proof.)

Example

Let's onsider graph G = ({v1 , v2 , v3 }, {{v1 , v2 }, {v2 , v3 }}). Let us


denote graph edges by e1 = {v1 , v2 }, e2 = {v2 , v3 }. Then the edge
graph of this graph is:
Ge = ({e1 , e2 }, {{e1 , e2 }}). The in iden e matrix of G is:

1 0
I = 1 1 .
0 1
165

The adja en y matrix of Ge :

A=

1 1 0
0 1 1

0 1
1 0

Then

0 1
1 0

Problems
1. Graph



1 0
1
0
1 1 2
.
0 1
0 1

G = (V, E) is determined by V = {a, b, c, d, e, f },


E = {{a, b}, {a, e}, {c, e}, {d, e}, {d, f }}. Write out the in iden e
matrix of graph G and the adja en y matrix of its edge graph Ge
and test the statement of the above theorem.
2. Let graph G1 = (V, E1 ) be determined by its adja en y matrix
A and graph G2 = (V, E2 ) - by its in iden e matrix I ( hoose any
proper matri es A and I by yourself). Keep in mind that they
have a ommon vertex set V . Find the edge sets of graphs G1 G2
and G1 G2 .

5.9. DIRECTED GRAPHS


5.9.1. Semi-walk
Assume that G = (V, L) is any digraph: (L V 2 ). Let's denote a
ertain walk whi h starts at vertex u and terminates at vertex w
by M = (vi0 , vi1 , . . . , vik ).

DEFINITION

We say sequen e M = (vi0 , vi1 , . . . , vik ) to be a


digraph G i

semi-walk

(vij , vij1 ) L (vij1 , vij ) L j = 1, 2, k.


166

of

Fig 44. A walk and a semi-walk


In other words, any sequen e of digraph verti es is a semi-walk
if for any pair of neighboring verti es u and v of these sequen e
either (u, v) or (v, u) is an ar of this digraph.
Consequently, any digraph walk is also a semi-walk. Inverse impli ation is invalid.
For instan e, (4, 5, 2) is a semi-walk, but it is not a walk of the
digraph in Fig 44..

Remark

Semi- ir uit, semi-path


ally.

and

semi- y le

DEFINITION

are dened analogi-

Vertex v is said to be rea hable from vertex u, if there exists at


least one path (u, . . . , v) in a graph.
Let's agree that any vertex is rea hable from itself by denition.
167

5.9.2. Strong and Weak Conne tivity


DEFINITION

Digraph G = (V, L) is said to be bi-dire tionally onne ted digraph, i u, v V there exist two following paths P1 = (u, . . . , v)
and P2 = (v, . . . , u). I u, v V a digraph has one of these two
paths, we say it is a strongly onne ted digraph.
In other words, a digraph is a bi-dire tionally onne ted digraph
i it has a path from ea h vertex to any other vertex.
Thus,any vertex of bi-dire tionally onne ted digraph is rea hable from any other vertex. For any pair of strongly onne ted
digraph verti es one of them is ne essary rea hable from the other
one.

DEFINITION

Digraph G = (V, L) is said to be a weakly onne ted digraph, i


any pair of its verti es an be onne ted with a semi-path.
Thus, any digraph is weakly onne ted, i any two its verti es an
be onne ted maybe ignoring the dire tions of used ar s.

Corollary

Consequently, any bi-dire tionally onne ted digraph also is a strongly


onne ted digraph. Any strongly onne ted digraph is also a weakly
onne ted digraph.
In Fig 45. we see bi-dire tionally onne ted ((1), (4)), strongly
onne ted ((2),(5)) and weakly onne ted ((3)) digraphs.

THEOREMS

A graph is bi-dire tionally onne ted, i it has a y le that in ludes


168

Fig 45. Strongly onne ted, dire tionally onne ted and weakly
onne ted graphs
all graph verti es.
A graph is strongly onne ted, i it has a walk that in ludes all
graph verti es.
A graph is weakly onne ted, i it has a semi-walk that in ludes all
graph verti es.
(Without proof.)

5.9.3. Flow network


Let G = (V, L) be any strongly onne ted digraph with exa tly
one sour e and exa tly one sink (see 5.1.4.).

DEFINITIONS

Let nonnegative fun tion (l) : L R+ be dened l L. Then


we say that ow network T = (G, ) is to be dened. Fun tion
(l) is alled apa ity of network T .
Fun tion (l) : L R+ is said to be a ow of network T =
(G, ), if:
169

Fig 46. Flow network.

1) (l)P6 (l) l L; P
2)
(li ) =
i:li =(v,vi )

j:lj =(vj ,v)

(lj ) v V .

Simply, ow network T is a digraph, to ea h ar l of whi h a nonnegative value (l) 0, alled a apa ity of ar l, is assigned. We
see that a ording to the denition, ow an't ex eed the network
apa ity and the outow from any vertex equals the inow to this
vertex.
Null ow is a trivial sample of ow fun tion (l).
Let's nd the maximal ow on a network in Fig 46..
Please re all that graph ut is su h minimal set of graph edges that
its removal from a graph would dis onne t the graph (see 5.5.4.).
All uts of the network in Fig 46. are:
C1 = {(v, x), (v, y), (v, z)}, C2 = {(x, w), (z, w)},
C3 = {(v, x), (y, x), (z, x), (z, w)}, C4 = {(v, z), (y, z), (x, z), (x, w)}.
170

The apa ity of ea h ut Ci , i = 1, 2, 3, 4 is:


X
P (Ci ) =
(l),
l: lCi

thus
P (C1 ) = 4 + 3 + 1 = 8, P (C2 ) = 2 + 4 = 6,
P (C3 ) = 4 + 4 + 1 + 4 = 13, P (C4 ) = 1 + 2 + 1 + 2 = 6.

THEOREM

The value of the maximal ow in a network equals the minimum


of all ut apa ities.
(Without proof.)
Consequently, maximal ow on a network in Fig 46. equals 6.
Thus, any ow through the network in Fig 46. an't ex eed the
value of ow des ribed in Fig 47.. Re all that our network has
exa tly one sour e v and exa tly one sink w.
The above theorem belongs to the authors of Ford-Fulkerson 46
algorithm, whi h omputes the maximum ow through a network.

DEFINITION

A path of positive apa ity from the sour e of digraph G(V, L) to


the sink is alled a ow augmenting path . The initial ow network is said to be the residual network .
The main idea of Ford-Fulkerson algorithm is nding a ow
augmenting path in the digraph and adding the ow through this
path to the ow already established in the residual network. The
maximum ow will be rea hed when no more ow augmenting
46

Lester Randolph Ford, Jr.(1927)  Ameri an mathemati ian, Delbert Ray

Fulkerson  Ameri an mathemati ian.

171

Fig 47. Flow through the network


paths will be found in the digraph.
Let us suppose that the initial value of a ow through the network
(the residual network) in Fig 46. is 0 = 0. Let's nd any path
of positive ow apa ity from sour e v to sink w; for example,
P1 = ((v, x), (x, w)). Maximal ow through this path is:

1 =

min

l(v,x),(x,w)

(l) = 2.

Now P1 is the residual network. Then path P2 = ((v, x), (x, z), (z, w))
is an augmenting path of apa ity 2 = 1. At this moment the
residual network onsists of two paths P1 and P2 . The paths
P3 = ((v, y), (y, z), (z, w)) and P4 = ((v, z), (z, v)) are augmented
with apa ities 3 = 2 and 4 = 1 and no more augmented paths
an be found. Thus, the maximal ow is:
X
=
k = 2 + 1 + 2 + 1 = 6.
k=l, ,4

172

We got a ow of Fig 47.. Please note that this ow is not an unique
maximal ow.

Problem

Find the maximal ow through the network of Fig 46. dierent
from the ow des ribed in Fig 47..

173

6.

COMBINATORIAL ALGORITHMS

6.1. CONCEPT OF AN ALGORITHM


6.1.1. Few Samples of Algorithms
The word alghorithm is the distortion of the name of al-Khwarizmi
and initially in Europe denoted the arithmeti al rules of the de imal system of numbers. After, for a time, only mathemati ians
used this word to denote the rules for solving a ertain type of
problems. Now the on ept of an algorithm is very wide and the
algorithm for making arrot salad an be onsidered as well as
step-by-step instru tions for sending SMS an be said to be an
algorithm. Below you an read a few dierent denitions of an
algorithm.
47

An algorithm is a pro edure or formula for solving problems.


An algorithm is a nite set of well-dened rules for the solution
of a problem in a nite number of steps.
An algorithm is a mathemati al fun tion that is used to en rypt
and de rypt information.
An algorithm is a series of steps that systemati ally outline how
to a omplish a goal.
An algorithm is a method for solving a parti ular problem whi h
is guaranteed to terminate in nite time.
47

al-Khwarizmi ( a.

780  a.

850)  Persian mathemati ian.

The Arabi

title of one of al-Khwarizmi's works about algebrai methods was distorted


into the word algebra

174

Fig 48. Eu lidian algorithm

6.1.2. Eu lidian Algorithm


As a sample of the des ription of a pro edure of solving the problem let's onsider the Eu lidian 48 algorithm used to al ulate the
greatest ommon divisor (highest ommon fa tor ) z of two integers
x and y .
S hemati ally Eu lidian algorithm is des ribed in Fig 48.

Exer ise

Find the greatest ommon divisor of x = 9 and y = 12.


Solution. We order all pro edures of Eu lidian algorithm:
48

E ,

or Eu lid of Alexandria (about 365 B.C. - 275 B.C.)  Greek

mathemati ian, now known as "the father of geometry".

175

1) x := 9, y := 12;
2) x < y y := y x;
3) y := 12 9 = 3, x := 9;
4) x > y x := x y ;
5) x := 9 3 = 6, y := 3;
6) x > y x := x y ;
7) x := 6 3 = 3, y := 3;
8) x = y z := x.
Thus, z = 3 is the highest ommon fa tor of 9 and 12.
We an identify the following parameters that are ommon for
most of known algorithms:
1) initial data (two integers in ase of Eu lidean algorithm);
2) feasible solutions (sometimes the solution of the problem is
not unique or an not be found at all, then the set of possible solutions is very protable);
3) possible intermediate results ;
4) initial rule ;
5) nal rule (Eu lidian algorithm nishes when x = y);
6) the operations performed exe uting the algorithm ( omparison, substra tion, assigning (:=)) in ase of Eu lidian algorithm;
7) nal result (z := x in the last example).

6.1.3. Turing's Ma hine

Turing's 49 ma hine

was introdu ed in 1936 by Alan Turing to


give a pre ise mathemati al denition of an algorithm. It was the
rst omputer (on paper only). The on ept of Turing ma hine is
based on the idea of a person exe uting a well-dened pro edure
by hanging the ontents of an innite number of ordered paper
sheets that an ontain one of symbols from some nite set.
49

Alan Mathison Turing (1912  1954)  British mathemati ian, logi ian,

ryptographer.

176

A simple Touring's ma hine is omposed of a "tape", a ribbon of


paper of innite length, whi h an be moved ba k and forth and
of a "head", whi h possesses a property known as "state" and that
an read and hange the property known as " olor" of the tape
ell under it (the "a tive ell" ), and a set of instru tions how the
head should modify the a tive ell and move the tape. So, at ea h
step the ma hine an hange the olor of the a tive ell, hange
the state of the head and move the tape to the left or right. The
"program" is a list of "transitions" (rules), that is the list whi h
says what should be done given a urrent state and a olor urrently under the head: what olor should be painted on the tape,
what state the head should go and whether the head should move
left or right or should stay in the same position. It is lear that
n-state, m- olor Turing ma hine requires n m rules to fun tion.
We an say that all available olors (symbols) perform a ertain
alphabet. It is evident that the tape is used to store the data. Any
series of transitions is said to be a program. Thus, the head "runs"
these programs. By analogy with modern omputers, the tape is
the memory and the head is the pro essor.

DEFINITION

Turing's ma hine is alled deterministi , if there is pre isely one


rule asso iated with a given pair {state; color}. Otherwise, it is
alled nondeterministi .
A deterministi Turing's ma hine spe ies a single instru tion triplet
{state; color; lef t or right} when a nondeterministi ma hine an
spe ify zero or more instru tions. We an imagine that at ea h step
a omputer bran hes into many opies, ea h of whi h exe utes one
of possible instru tions.

177

6.1.4. Question of Solvability


An important question of algorithm theory is the question of solvability of a given problem: does there exist an algorithm that
solves a problem in a nite number of steps?
In fa t, Gdel 50 has proved that truly unsolvable problems exist.
Problems of this type are the famous three antique geometri al
problems :
1. The problem of trise tion of an angle : divide an arbitrary
angle into three equal angles;
2. The problem of squaring a ir le : onstru t a square of area,
equal to the area of a given ir le;
3. The question of the dupli ation of a ube : onstru t a ube
whi h volume is twi e that of the given ube.
An ient Greeks have restri ted the allowed operations to using a
straightedge and a ompass . These problems lingered until the
19th entury when it was shown that it is impossible to solve them
only with the help of a straightedge and a ompass.
The next sample of an unsolvable problem is Hilbert's Tenth 51
problem : determine the solvability of Diophantine equation 52 :
i.e., nd zero x0 = (x01 , x02 , . . . , x0m ) of polynomial Pn (x1 , x2 , . . . , xm )
su h, that xk Z, k = 1, , m. Matiyasevi h's 53 theorem,
proven in 1970, implies that this problem is unsolvable. Conse50

Kurt Gdel (1906  1978)  Cze h mathemati ian, logi ian and philoso-

pher, well-known for his in ompleteness theorems.

51

David Hilbert (born 1862 in Knigsberg  1943)  German mathemati-

ian.

Hilbert's problems are a list of 23 problems, several of them were very

inuential for the 20th entury mathemati ians.

52

Diophantine equation is a polynomial equation that only allows the vari-

ables to be integers.

53

Yuri Matiyasevi h (born 1947)  Russian mathemati ian.

178

quently, there is no algorithm whi h is able to nd an integer zero


of an arbitrary polynomial equation.

6.1.5. Brute For e Algorithms


The ombinatorial algorithms are applied to solve the nite set
problems. The feasible set of solutions of this type of a problem is
also nite, thus the most dire t and simple way to the solution of
a problem would be the testing of all possible solutions.

DEFINITION

A brute for e algorithm is one that pro eeds in a simple and


obvious way, but requires a huge number (perhaps an unfeasably
large number ) of steps to omplete.

Exer ise

Find all of the fa tors of number 1275.


Solution. First divide 1275 by 2 and look if it omes evenly, then
by 3, by 4, and forth. After you had tried every possible divisor,
you would know whi h ones divided 1275 evenly.
This pro edure is a sample of a brute for e algorithm.
This type algorithms be ame unusable when the number of steps
be ame unfeasably large . Then we need to dis over more lever
and more e ient algorithms. They might be more ompli ated
to des ribe, but the performan e of all their steps will take less
time and eorts.

179

6.2. DIMENSION OF A PROBLEM


6.2.1. Classes of Problems
Any algorithm that solves a ertain parti ular problem usually is
able to solve the whole lass of similar problems . For instan e,
Eu lidian algorithm (see 6.1.2.) nds the highest ommon fa tor
of an arbitrary integers x and y . Thus, we an on lude that there
exists a bije tion between this lass of problems and N 2 = {(x, y) :
x, y N }. For any two integers x and y Eu lidian algorithm
nds their greatest ommon divisor z(x, y) in nite number of steps
k(x, y). Any analysis of the algorithm involves the investigation of
these two fun tions k(x, y) and z(x, y) that usually are not ordinary
fun tions.

DEFINITION

The dimension of a problem (in a ertain lass of problems) is


a number that indi ates the expe ted number of algorithm steps
ne essary for solving the given problem.
For example, in the ase of the problem of nding the highest
ommon fa tor of two integers x and y , a role of the dimension
of a problem an bepplayed by any of the following fun tions:
max{x, y}, x + y or x2 + y 2 . The higher dimension of a problem orresponds to a larger amount of algorithm steps that are
ne essary to solve the problem.

Example

Let A and B be two arbitrary sets. The task is to determine


whether A B = or not. Let's write the algorithm in the form
of a pseudo- ode ( omputer program):

180

begin
x[ ] := A, n := |A|
i := 1 while (x[i]
/ B) if (i < n) i := i + 1
if (i 6 n) then "false"
else "true"
end
Let's note that the number of algorithm steps depends on value
n = |A| only (if we do not in lude the needs of test (x[i]
/ B)).
Thus, n = |A| an be onsidered as the ( onditional) dimension of
the problem.

6.2.2. Various Informational Models of Graphs


DEFINITION

Let's agree that any des ription of graph G = (V, E) in the omputer memory is said to be an informational model of a graph.
For example, all available information about graph G = (V, E) an
be found in the adja en y matrix of the graph (see 5.8.1.):
(
1, {vi , vj } E {vj , vi } E,
A = (aij )nn , n = |V |, aij =
0, {vi , vj }
/ E & {vj , vi }
/ E.
If G is a simple undire ted graph, then A is a symmetri matrix
with the null main diagonal. Thus, all information about graph G
is given by
n(n 1)
k = n2
n
2
elements of matrix A. Available values of ea h element are 0 and 1,
onsequently, a simple undire ted graph an be en oded into
k bits .
181

Suppose, that G = (V, L) is a non-simple digraph. Then the elements of digraph adja en y matrix ould be equal to 0, 1 or (1)
and the matrix is not symmetri , in general. If, additionally, some
positive number is assigned to ea h ar , we have a weighted digraph (for example, a ow network (see 5.9.3.). Any information
about this weighted digraph an be given by n2 + m numbers,
where m = |L|.
Let us onsider the informational model of a graph, when the graph
is represented by its in iden e matrix. An in iden e matrix of a
simple undire ted graph G = (V, E) ontains n m = |V | |E|
elements (see 5.8.2.). Thus the dimension of a problem is n m. If
m is a su iently small number (for example, when a graph has
few edges), we have n m n2 . However, when our graph is lose
to the omplete graph, m n = O(n3 ), thereby, the graph informational model, based of an adja en y matrix, seems to be more
provident in this ase.
Let us onsider two subsets of graph verti es

V1 = {v11 , v12 , . . . , v1m }, V2 = {v21 , v22 , . . . , v2m },


where {v1j , v2j } E, j = 1, , m. If the list of graph edges is
su ient data for a ertain graph problem, subsets V1 and V2 an
play a role of the informational graph model. The dimension of
the problem now is 2m.
It is lear that the informational model of a graph, whi h we are
going to use, must orrespond to the appli ation, i.e., to the problem, whi h we are going to solve.
For example, let our task be the determination of the maximal
vertex order of a simple undire ted graph : max p(vi ).
i=1,2,...,n

A graph representation by the adja en y matrix A = (aij )nn


seems to be onvenient for solving this problem.
182

Denoting mi =

n
P

aij and re alling, that p(vi ) = mi , we have the

j=1

following algorithm :

begin
i := 1 m0 := 0 n := |A|
while (i 6 n) { if (m0 < mi ) m0 := mi
if (i < n) i := i + 1 }
end

6.3. COMPLEXITY OF AN ALGORITHM


6.3.1. Con ept of Algorithm Complexity
Let's study the number of operations performed by algorithms.
Let's start with Eu lidian algorithm (see 6.1.2.) and let's nd estimates for the number of its steps k(x, y). We need to explore ea h
ase when x, y N, therefore, it an happen that the dimension of
a problem (for example, max {x, y}) is innitely large. If one of the
numbers x or y is equal to 1, then Eu lidian algorithm pres ribes
both the substra tion ( x = x 1 or y = y 1) and the omparison
(x < y or y < x) operations to be performed many times, thus
the running time of the algorithm will be mu h longer than its
running time in ase x = y (now z = x = y will be found after
exe uting just few omparisons).

DEFINITIONS

The worst- ase performan e of an algorithm is the one, for whi h


the most operations are performed.54
Let's agree that the running time of any algorithm will be esti54

The best and the worst ases orrespond to the situations when the re-

sour e usage is "at least" and "at most", respe tively.


orresponds to "normal onditions".

183

Average performan e

mated in the

worst- ase performan e.

In pra ti e an average- ase is also important. The investigation


of this ase is quite ompli ated and involves the ne essity of the
knowledge of distribution of various possibilities.
In almost all situations the resour e being onsidered is the running time, but it ould be a memory, for instan e. The real time
of running an algorithm depends on omputer programs, on hardware properties, et .. Under the running time we will understand
the number S(n) of operations (steps) of an abstra t omputing
ma hine (for example, Turing's ma hine (see 6.1.3.)), that are ne essary to solve the problem in its worst- ase performan e. Here n
denotes the dimension of a problem.

DEFINITION

S(n) is alled the


algorithm.

running-time (or the omplexity ) of a given

Expli it formulas of fun tion S(n) are available just in parti ular
ases be ause this fun tion is very sensitive even to minor variations of an algorithm. For instan e, the additional omparison

if (x = 1 y = 1 ) z = 1,

will notedly redu e the running time of Eu lidian algorithm.


Anyone will nd no radi al dieren e between the e ien y of two
algorithms if n 2 and n + 1 are their running-time and the dimension of problem n is large. Re all that argument n of fun tion
S(n) an be dened in various ways (see 6.2.) and its exa t value
remains unknown rather often.
This reasoning an explain us why the investigation of the omplexity of algorithms is based on various estimates of fun tion S(n).
184

For example, the running time of Eu lidian algorithm an be estimated as S(n) = O(n) when n (re all, that O(S(n)) =
O(f (n)) if C : S(n) 6 C f (n)).

Remark

The algorithm of the evaluating the maximal vertex order (see


page 183) is based on operations with graph adja en y matrix.
Its running time is always determined and we have no need for
investigation of its worst- ase. Let's note that estimate S(n) =
O(n2 ) takes pla e.

6.3.2. Polynomial-Time Algorithms


DEFINITIONS

We say that any given algorithm is a polynomial-time algorithm


i S(n) = O(n ) ( > 0).
An algorithm is said to be a omposite algorithm , i the output
data (output ) of another algorithm are used as the input data
(input ) of this algorithm.
For example, the algorithm of determining the disjointness of two
sets (see page 180) an serve as a sample of a omposite algorithm.
It is not di ult to prove this statement:

THEOREM

omposition of any two polynomial-time


polynomial-time algorithm itself.
The

algorithms is a

DEFINITION

I the running time S(n) satises inequalities S(n) > n > 0,


we have the exponential-time algorithm.
For instan e, if the running time of a given algorithm is O(2n ),
185

or O(n!), or O(nn ), in any ase we have an exponential-time algorithm.

Polynomial-time algorithms run faster than the exponential-time

algorithms (if the dimension of problem n is large enough). In the


table you an nd the running time of two algorithms: the rst
is an algorithm of polynomial-time n10 and the se ond is one of
exponential-time nn .
n

n10

nn

5
10
15
20
25

9.77 106
1010
5.77 1011
1.02 1013
9.54 1013

3125
1010
4.38 1017
1.05 1026
8.88 1034

Let's note that for small n the exponential-time algorithm an run


faster than the polynomial-time algorithm.
For example, if n = 15, the value of the polynomial fun tion n100
ex eeds 2n = 32768.
It is known empiri ally that any algorithm of polynomial-time
O(n ) usually an be improved and its running time de reased
to O(n4 ) or even to O(n3 ).

186

6.4. HARD PROBLEMS


6.4.1. NP Problems
DEFINITION

The problem is said to be a hard problem , if there are no polynomialtime algorithms whi h solve this problem.
It is lear that there are problems that an't be solved in polynomial time. An example of this type problem is the following one:
nd all subsets of a given set A (refresh that any nite set A has
2|A| subsets).
Below we talk about de ision problems: algorithm Alg tests
whether a ertain obje t O has some given property or not:


yes
Alg(U )
.
no
Let's list few of them:

Composite numbers.

Test, whether the given positive integer k


an be represented as a produ t of two integers m and n (k = mn),
where m > 1 and n > 1, or an not.
Hamiltonian y le. Determine whether the given graph has any
Hamiltonian y le or not.
Set partition. Let A be any given weighted set : some nonnegative number s(a), alled the weight of an element , is assigned
to arbitrary elementPa A. The weight of any subset B A is
dened by s(B) =
s(a).
aB

Determine, if any two-blo k partitions with the blo ks of equal


weights exist or not.

We an solve these problems using the brute-for e algorithms (for


example, testing all available input data one-by-one). But we an't
187

identify them as hard problems until we have no proof that there


are no polynomial-time algorithms whi h would be able to solve
them. This situation is a reason of introdu ing the lasses of NP 55
problems .
Strong denition of this on ept is rather sophisti ated, thus we
start with the explanation of basi ideas .
Assume, that any pro ess of the solution of any problem has two
stages : presupposition and veri ation . The result of presupposition is a ertain pattern , whi h is veried during polynomial
time in the se ond stage of a pro ess. If the result of this inspe tion
is positive ("yes"), the algorithm nishes. If the result is "no", the
algorithm returns to the rst stage.
If there are no polynomial time algorithms, whi h solve the given
problem but they are veriable in polynomial time, we say that the
problem is NP problem.
For example, let arbitrary graph y les be generated in the rst
stage and they are tested, whether they in lude ea h graph vertex
exa tly on e, or not, in the se ond stage. If answer is "yes", we
have Hamiltonian y le and the algorithm nishes. Otherwise, we
inspe t the next graph y le. It is lear that the veri ation is of
polynomial time. Consequently, this problem belongs to NP lass.

DEFINITIONS

P problem is a problem, for whi h a ertain polynomial-time al-

gorithm, whi h solves this problem is known.

A problem is NP problem if it is veriable in polynomial time by


a nondeterministi Turing ma hine.
A nondeterministi Turing ma hine is a "parallel" Turing ma hine with the restri tion that any parallel Turing ma hines annot
ommuni ate.
55

NP  Nondeterministi ally Polynomial.

188

It is lear that any P-problem is also NP-problem :

P N P.
But the question of whether all NP problems are a tually P problems is still open .56

6.4.2. Investigation of NP Problems


The theory of NP-problems is based on belief that

N P \ P 6= ,
i.e.,

P 6= N P.

It is important to know that few hundred of well-known NP problems an be transformed one to another in polynomial time. Then
the below denitions seem to be signi ant.

DEFINITION

A problem is said to be NP-hard problem i an algorithm for


solving it an be translated into the algorithm for solving any other
NP-problem.57
A problem whi h is both NP and NP-hard is alled NP- omplete
(NPC) problem.
56

This problem is known as "P versus NP" problem and on 24 May, 2000 it

was in luded (together with other 6 problems) into the

problems .

Millennium Prize

Mathemati ians draw a parallel from these problems to Hilbert's

problems, whi h were proposed in 1900 and have a substantial impa t on the
20th entury mathemati s.

57

NP-hard therefore means: at least as hard as any NP problem, but might

be harder.

189

Fig 49. Hard problems

THEOREM

If P 6= N P , then N P C 6= N P .
(Without proof.)
Thus, Fig 49. orresponds to our today's knowledge about
problems .

hard

DEFINITION

P c is the omplement problem of a de ision problem P if it has


an answer, whi h is reverse to an answer of P .
For example, the problem "Primary numbers": determine, whether
the given number is primary number or not, is a omplement problem to the problem "Composite numbers " (see page 187). Both
problems belong to N P lass, but it is not known that they are
also N P C problems.
190

The impli ation U N P U c N P is not proved at this moment. This fa t is a reason of introdu ing one new lass of problems:
o N P = {U c : U N P }.

THEOREM

If there exists (at least one) problem U that U N P C & U c


N P , then
N P = o N P.
(Without proof.)
Thus, in the ase if both "Primary numbers" and the "Composite
numbers" problems belong to N P C , the equivalen y o-N P = N P
will be proved (be ause both are N P problems). But, likely, they
are not N P C problems. A ording to the belief of most today's
mathemati ians, they belong to N P \ N P C .

6.4.3. Samples of NPC problems


Hundreds of NPC problems are known, for example, the problem
of nding Hamiltonian y le. Below we list few of them. Dominating set. (see 5.7.2.) Given graph G = (V, E) and given positive integer k, does dominating set V V of a graph exist that
|V | 6 k?
Independent set. (see 5.7.1.) Given graph G = (V, E) and positive integer k, does independent set V V exist su h, that
|V | > k?
Clique. Let any omplete subgraph of a given graph is alled a
lique . Given graph G = (V, E) and given positive integer k, does
a lique of order ex eeding or equal to k exist?
Graph ontra tion. (see 5.4.6.) Given two graphs G1 = (V1 , E1 )
and G2 = (V2 , E2 ), determine whether it is possible to get a graph
isomorphi to G2 by applying vertex superposing to graph G1 or it
191

is not.

Kernel.

(see 5.7.3.) Conrm or disprove the existen e of a kernel


in a given graph.
Triple test. Given positive integers x, y and z , onrm the existen e of positive integer w su h that w < x and w2 y (mod z)
(i.e., w2 y = k z , where k is any integer).
Exe ution. (see 1.3.1.) Determine, whether the given propositional formula is exe utable or not.

192

Referen es

1. Althoen, S. C.; Bum rot, R. J. Introdu tion to Dis rete


Mathemati s, Boston: PWS-KENT. The Prindle, Weber &
S hmidt series in Mathemati s, 1988. 346 p.
2. Anderson, J. A. Dis rete Mathemati s with Combinatori s.
New Jersey: Prenti e Hall, Upper Saddle River, 2001.
3. Balakrishman, V. K. Introdu tory Dis rete Mathemati s. Englewood Clis (N. J.): Prenti e-Hall International, 1991.
236 p.
4. Bloznelis, M. Kombinatorikos paskaitu iklas: Mokomoji priemon
e. Vilnius: VU leidykla, 1966. 64 p.
5. Cooke, D. J.; Bez, H. E. Computer Mathemati s. Cambridge: Cambridge Universitete Press, 1984.
6. Haggatrty, R. Dis rete Mathemati s for Computing. Harlow:
Pearson Edu ation Limited, Edinburg Gate, 2002.
7. Garey, M. R.; Johnson, D. S. Computer and Intra ability. A
Guide to The Theory of NP-Completeness. Bell Laboratories
Murray Hill, New Jersey, 1979.
8. Griniuvien
e, L. Matematin
e logika: Mokomoji priemon
e. Vilnius, VPU leidykla, 1977. 86 p.
9. Jusas, V. Matematin
e logika: Mokomoji knyga. Kaunas:
Te hnologija, 2oo2. 156 p.
10. Kolman, B.; Busby, R. C. Dis rete Stru tures with Appli ations. Englewood Clis (N. J.): Prenti e-Hall, 1987. 364 p.
11. Lassaigne, R.; de Rougemont, M. Logika ir informatikos pagrindai. Vilnius: odynas, 1996. 243 p.
193

12. Lassaigne, R.; de Rougemont, M. Logika ir algoritmu sud


etingumas: Mokymo priemon
e. Vilnius: ara, 1999. 302 p.
13. Mieikis, F. Diskretin
es matematikos pradmenys: Mokomoji
priemon
e. Vilnius: VU leidykla, 1989. 162 p.
14. Morkeli
unas, A. Binarieji sryiai, grafai ir opera ijos: Mokomoji metodikos knygut
e. Vilnius: VU leidykla, 1998. 63 p.
15. Ni odemi, O. Dis rete Mathemati s. St. Paul a. O.: West
Publ. Co., 1987. 491 p.
16. Norg
ela, S. Matematin
es logikos i vadas. Vilnius: VU leidykla, 1985. 109 p.
17. Norg
ela, S. Matematin
e logika. Vilnius: TEV, 2004. 191 p.
18. Ore, O. Graphs and their uses. New York: Random House,
Singer, 1963. 131 p.
19. Plukas, K.; Maik
enas, E.; Jarai
unien
e, B., Mi kuvien
e, I.
Taikomoji diskreioji matematika: Vadov
elis. Kaunas, Te hnologija, 2003. 330 p.
20. Reingold, E. M.; Nivergelt, J.; Deo, N. Combinatorial Algorithms. Theory and Pra ti e. Prenti e-Hall, In ., Engglewood Clis, New Jersey, 1977.
21. Roman, S. An Introdu tion to Dis rete Mathemati s. San
Diego, CA: Har ourt Bra e Jovanovi h, 1989. 469 p.
22. Stak
enas, V. Informa ijos kodavimas: Mokomoji priemon
e.
Vilnius: VU leidykla, 1966. 127 p.
23. Vilenkinas, N. Kombinatorika. Kaunas: viesa, 1976. 248 p.
24. ilinskas, A.; Leonaviius, g.; Valaviius, E. Informatika:
Vadov
elis auktosioms mokykloms. Vilnius: Aldorija, 2000.
344 p.
194

Aleksandras KRYLOVAS and Eugenijus PALIOKAS


DISCRETE MATHEMATICS
Textbook
DISKREIOJI MATEMATIKA

Mokomo ji knyga (anglu k.)

2006-08-24. 12,25 sp. l. Tiraas 100 egz.


Vilniaus Gedimino te hnikos universiteto
leidykla "Te hnika", Sauletekio

al. 11,
10223 Vilnius
Spausdino UAB "Biznio mainu
kompanija",
Gedimino pr. 60, 01110 Vilnius

S-ar putea să vă placă și