Professional Documents
Culture Documents
hni al University
Aleksandras KRYLOVAS
and
Eugenijus PALIOKAS
DISCRETE MATHEMATICS
Textbook
UDK 510(075.8)
Kr242
ISBN 9986-05-958-5
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 . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
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.
3. 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
4. INFORMATION CODING
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.2.
5.3.
5.4.
5.5.
5.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
6. COMBINATORIAL ALGORITHMS
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
Problems
4.
5.
x + 3 < x + 4.
I always lie.
DEFINITIONS
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
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:
R true.
DEFINITION
12
Examples
Problems
1. Let P mean
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,...
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
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
Problems
DEFINITIONS
Problems
1. Determine whether ea
h of the following is a tautology, a
on-
16
Example.
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
of logi .
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)
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.
Exer
ises
1. Prove by
ontradi
tion
tautology.
Solution. By double negation, (A & B) (A & B). By de Morgan's laws, (A & B) A B . Thus, (A B) (A B) 1.
Problems
1.
2.
3.
4.
5.
DEFINITIONS
x
.
x y
We say that
is a valid argument .
x
x y
20
inferen e rule :
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 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
22
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.
(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
23
Remarks
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-
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
DEFINITIONS
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
DEFINITIONS
Sheer's
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
2.
f1 (x1 , x2 , . . . , xn ) = f 2 (x1 , x2 , . . . , xn ).
Let's note that
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 (x1 , . . . , xn ) = f (x1 , . . . , xn ).
Then
DEFINITION
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
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
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
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
THEOREM
Arbitrary Boolean fun tion (ex ept f = const = 0) has its perfe t
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
Example
xy x z = xyz xyz xyz x y z.
DEFINITION
A
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
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.
preserves
preserves zero by T0 .
pre-
self-dual
fun tions by T :
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
Exer ise
is not a linear
Boolean
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
DEFINITION
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:
Emil Leon Post (1897 1954) Ameri an mathemati ian and logi ian.
35
DEFINITION
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
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 .
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
DEFINITIONS
Example
DEFINITIONS
Problems
1. Find sub-formulas of formula
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
Problems
1. Negate the
41
2.
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}.
42
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
13
For
14
Leonhard Euler (1707 1783) Swiss mathemati ian, me hani ian and
physi ist.
15
43
Problems
1.
2.
3.
4.
5.
2.1.3. Permutations
DEFINITIONS
"One-to-one" orresponden e. More pre ise denition of the bije tion you
an nd in 3.5.1..
44
DEFINITION
of n 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
We read: "
fa torial".
45
DEFINITION
(A = B) (a(x) b(x)).
(A = B) (A B) & (B A).
Example
Problem
Find the number of all subsets of set {1, 2, 3, 4, 5} and write out
these subsets.
notation
XY
X Y, Y X
proper
46
subset:
In this ase
X Y, X 6= Y, X 6= .
n(n 1)
subsets,
ontaining 2 elements ea
h:
2!
Cnk =
n!
(n k + 1) (n k + 2) (n 1) n
=
.
(n k)! k!
k!
DEFINITION
Cn0 =
n
.
k
n
n
= Cnn =
= 1.
0
n
47
(x + y)n =
n
X
Cnk xk y nk .
k=0
DEFINITION
n
P
Cnk = 2n .
k=0
power
|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
Exer
ises
1. Let's write
A37 =
7!
7!
=
= 5 6 7 = 210.
(7 3)!
4!
Problems
1. Find the
49
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:
Example
DEFINITION
B:
A \ B = {x U : x A & x
/ B} = {x U : a(x) & b(x)}.
50
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
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-
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
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 ,
1) Bj 6= ;
2) Bi Bj = , when i 6= j ;
k
S
3)
Bj = A.
j=1
set
A. Sets
Examples
1. Let A = {1, 2, 3}.
DEFINITION
54
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
55
DEFINITION
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
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
DEFINITION
Set
is alled a
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, 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
THEOREM
(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
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
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
A B = {(ai , bj ), i = 1, 2, . . . , n, j = 1, 2, . . . , m}
Example
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
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
Exer ise
DEFINITION
THEOREM
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
DEFINITION
Sets
T A1 , A2 , . . . , An are disjoint sets , i
Ai Aj = for all i 6= j, i, j = 1...n.
k=1
64
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?
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 } =
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
{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
is alled the
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
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
2.
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.
(Prove yourself.)
DEFINITION
The
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
l
X
s ls
Cm
Ck .
s=0
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.
F (x) =
= 1 + x + x2
Fn x = 1 + x +
n=0
Fn2 xn2 + x
n=2
25
26
n=2
X
n=2
Fn1 xn1 + 1 1
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 .
!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
THEOREM
(1)
(2)
(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,
Exer ise
THEOREM
Example
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
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
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
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
are alled
f (x)
= 0.
xx0 g(x)
Please note that symbols o and are equivalent a
ording to
their denitions
Problems
1. Compare the growth of fun
tions lnn, n, n2 , n5 , 5n .
Prove your
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
76
DEFINITIONS
ab-
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
Relation
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
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
Examples
1.
DEFINITION
relation R A B
Examples
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
THEOREM
Transitive relations
inverse relation
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,
union , the interse tion , the dieren e and the omplement of relations are understood as the orresponding set opera-
The
tions.
Examples
1 = {(m, n) : m n},
2 = {(m, n) : m > n},
Then
2 1 , 1 2 = 1 ,
1 2 = 2 , 3 = 1 ,
1 \ 2 = IZ .
DEFINITION
omposition
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 = IA , R = R, R = R R, . . . , R = R
ntimes
n1
R.)
THEOREM
Problems
1. Prove this theorem
84
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.
is alled an
LEMAS
1) a A : [a]R 6= ;
85
DEFINITION
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.
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
Examples
1. Relations
Problems
1. Prove the above examples statements.
2. Determine the type of relation {(1, 2),
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 <.
DEFINITION
Relation
is said to be
Remark
DEFINITION
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),
Example
Problems
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
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
Inje
tion
Surje
tion
Bije
tion
90
THEOREM
Problems
1. Prove this
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
91
Thus, permutation
a1 a2
a2 a3
an1 an
an a1
Remark
DEFINITIONS
1 2 3 4 5 6
4 5 6 3 1 2
92
Problem
93
4.
INFORMATION CODING
DEFINITIONS
Am = A
{z A}
| A
mtimes
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.
these alphabets.
DEFINITION
ode .
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 .
Symbol
Any available te hni al, physi al and other reasons of these types of dis-
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
pa =
P (001|Ha )P (Ha )
= 1 p = 0.95,
P (001)
P (001|Hb )P (Hb )
pb =
= p = 0.05.
P (001)
error .
DEFINITION
blo k ode .
k is alled the
(C1 )
blo
k
ode.
Let the se
ond
ode be
(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
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
iphers .
ryp-
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
101
J
K
L
N
O
P
H
Z
R
Q
I
1
3
5
7
9
V
W
X
Y
Samuel Finley
Breese
Morse
(1791
painter.
102
1872)
Ameri an
inventor and
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
writer.
35
103
friendliness)36 :
a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 .
Example
5 430 02548 8.
5 + 8 + 9 + 0 + 0 + 12 + 35 + 32 + 72 =
173 = 15 11 + 8 8
(mod 11).
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
Digits
a5 . . . a 9
104
(mod 10).
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).
nia).
105
GRAPH THEORY
l = (vi , vj , k) V V N.
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).
DEFINITION
DEFINITION
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
vertex to the
Remark
The
+ (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
outdegree
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
39
111
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
Example
Problems
1. Sket
h few
graph isomor-
THEOREM
DEFINITION
Remark
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
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.
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
k=0
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
Remark
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
DEFINITION
118
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
Remark
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.
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,
DEFINITION
of
Remarks
1. The number of all
onne
ted
omponents of any graph does not
THEOREM
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(
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
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
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
Problems
Find the longest paths of the graphs in Fig 16. and Fig 20.
DEFINITION
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
met-
Distan
es between the verti
es of the graph in Fig 18. are: (1, 2) =
1, (3, 6) = 3, (5, 3) = 2.
Remark
DEFINITIONS
1. The diameter of a graph
2.
4.
The
Problems
1. Find all metri
hara
teristi
s of graphs in Figs 16 and 20.
2. Prove the statement of the above remark.
DEFINITION
G1 G2 = (V1 V2 , E1 E2 ), G1 G2 = (V1 V2 , E1 E2 ).
127
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
Problems
1. Prove the statements of
orollaries.
2. Prove that G1 (G1 G2 ) and (G1 G2 ) G2
V = {v V1 V2 : {v, w} E}.
129
Problems
1. Prove that
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
removal :
if (v, w) E is an
131
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
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.
({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
DEFINITIONS
graph .
THEOREMS
1. A graph is a tree, i any pair of graph verti
es
an be
onne
ted
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
THEOREM
{{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
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.
DEFINITION
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
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
Problems
1. Prove the theorem.
2. Determine Eulerian graphs in the pi
tures of this book.
mine graphs that
ontain Eulerian paths.
Deter-
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
42
143
William Rowan Hamilton (1805 1865) Irish mathemati ian and as-
tronomer.
144
THEOREM
If p(v) >
n
2
(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
145
THEOREM
n
1P
p2 (vi ) m edges (m = |E|).
2 i=1
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
tonian
y
les.
Edge graph Ge of Hamiltonian graph G is Hamiltonian graph itself.
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.
DEFINITION
M Rm , m = |E|, where
Ve
tor of walk M is ve
tor
M = (c1 , c2 , . . . , cm ), cj = rj qj ,
Example
Let us onsider the digraph in Fig 35.. Our task is to nd ve tor
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
Exer ise
= (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
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
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
149
m2 = m1
m3 = m1
Problems
1. Graph G
M
M
m3 = m3
m2 = m2
M
M
m1 ,
m1 .
DEFINITION
Exer ise
THEOREM
THEOREM
(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
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
THEOREM
DEFINITION
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
of graph
verti
es that any two verti
es in S are not adja
ent verti
es:
u, v S {u, v}
/ E.
153
154
DEFINITION
The
THEOREM
(G) >
n
X
i=1
1
.
1 + p(vi )
(Without proof.)
Example
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
156
DEFINITIONS
Corollaries
1. Any dominating
set
DEFINITIONS
imal size.
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
Examples
1. Set {c6,
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
THEOREM
(Without proof.)
Problems
DEFINITION
The adja
en
y
matrix:
matrix
A of digraph
a11 a12
a21 a22
A = (aij ) =
an1 an2
0
1
0
0
a1n
a2n
.
ann
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
m=
n X
n
X
aij .
i=1 j=1
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.
of G:
A = AT = ||aji ||nn .
DEFINITION
m=
1 XX
aij .
2
i=1 j=1
THEOREM
Examples
1. Let us
onsider
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
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
L = {l1 , l2 , . . . , lm }, m = |L|.
163
DEFINITION
1, lr = (vk , w) L,
ikr = 1, lr = (w, vk ) L,
DEFINITION
Example
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
A = I T I 2Im ,
Example
1 0
I = 1 1 .
0 1
165
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
DEFINITION
semi-walk
of
Remark
and
semi- y le
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
Corollary
THEOREMS
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.)
DEFINITIONS
1) (l)P6 (l) l L; P
2)
(li ) =
i:li =(v,vi )
(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
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
DEFINITION
171
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
al-Khwarizmi ( a.
780 a.
The Arabi
174
Exer ise
E ,
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).
Turing's 49 ma hine
Alan Mathison Turing (1912 1954) British mathemati ian, logi ian,
ryptographer.
176
DEFINITION
177
Kurt Gdel (1906 1978) Cze h mathemati ian, logi ian and philoso-
51
ian.
52
ables to be integers.
53
178
DEFINITION
Exer ise
179
DEFINITION
Example
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.
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
Denoting mi =
n
P
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
DEFINITIONS
The best and the worst ases orrespond to the situations when the re-
183
Average performan e
mated in the
DEFINITION
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,
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
THEOREM
algorithms is a
DEFINITION
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
186
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.
DEFINITIONS
188
P N P.
But the question of whether all NP problems are a
tually P problems is still open .56
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
This problem is known as "P versus NP" problem and on 24 May, 2000 it
problems .
Millennium Prize
problems, whi
h were proposed in 1900 and have a substantial impa
t on the
20th
entury mathemati
s.
57
be harder.
189
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
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
is not.
Kernel.
192
Referen es
al. 11,
10223 Vilnius
Spausdino UAB "Biznio mainu
kompanija",
Gedimino pr. 60, 01110 Vilnius