faculty.psau.edu.sa · web view.1 euler and hamilton paths: 13 8 5. 9.2 hamilton paths and...
TRANSCRIPT
.
+
DISCRETE MATHEMATICS AND ITS APPLICATIONS
FOR COMPUTER SCIENCE
DR. AWATIF MOHAMMED ALI ELSIDDIEG
SALMAN BIN ABDULAZIZ UNIVERSITY
FACULTY OF SCIENCE AND HUMANITY STUDIES
HOTAT BANI TAMIM
20151
111
100
111
001
010
101
011
110
List of symbols
symbol meaning
¬ p Negation of p
p˄ q Conjunction of p and q
P ˅ q Disjunction of p and q
p⊕q Exclusive of p and q
p→ q The implication of p and q
p↔ q Biconditional of p and q
P ≡ q Equivalence of p and q
T Tautology
F Contradiction
P(x1 , x2 , x3 ,…, xn ¿ Propositional function
∀ x p(x) Universal quantification of p(x )
∃ x p (x) Existential quantification of p(x )
x∈S x is a member of S
x∉S x is not a member of S
N Set of natural numbers
3
Z Set of integers
Z+¿ ¿ Set of positive integers
Q Set of rational numbers
R Set of real numbers
S=T Set equality
∅ The empty set (or null set)
|S| Cardinality of S
P(S) The power set of S
(a,b) Ordered pair
S⊆T S is a subset of T
S⊂T S is a proper subset of T
A × B Cartisian product of A and B
A∪B Union of A and B
A−B The difference of A and b
A Complement of A
a ≡ b(mod m) a is congruent to bmodulu m
a| b a divides b
a∤b a not∣b
a div b Quotient when a is divisable byb
f (a) Value of the functionf ata
f : A→ B Function of A and B
4
f 1+ f 2 Sum of the functions f 1∧¿ f 2
f 1 . f 2 Product of the functions f 1∧f 2
f ° g Composite of f andg
gcd(a,b) Greatest common divisor of a and b
Lcm(a,b) Least common multiple of a and b
¿¿ Base b representation
A∨B Join of A and B
A ˄ b The meet of A and B
A⊙B Boolean product of A and B
n! n factorial
C(a,b) Combination of a and b
P(a,b) Permutation of a and b
∑i=0
10
i The sum of i from 0 to 10
Contents5
Introduction: 12
Chapter 1 (Logic and Proofs) 13
1.1 Logic: 13
1.1.1 Propositions : 13
1.1 2 Converse ,Contraposition and Inverse: 16
1.1.3 Biconditionals: 16
1.1.4 Logic and Bit Operations : 17
Exercises: 19
1.1.5 Logical Equivalence: 20
1.2 Introduction to Proofs : 21
1.2.1 Direct Proofs : 21
1.2.2 Indirect Proofs: 22
1.2.3 Proofs by Contradiction: 23
Exercises: 24
1.2.4 Mathematical Induction: 25
Exercises: 28
Chapter 2
Basic Structures( sets ,Relations and functions)
29
2.1 1 Sets: 29
2.1.2 The Power Set: 32
2.1.3 Cartesian Products: 33
2.1.4 Sets Operations: 34
6
2.1.5 Sets Identities: 37
2.1.6 Computer Representation of Sets: 40
Exercises: 41
2.2. Relations: 42
2.2.1 Relations and their properties: 42
2.2.2 Relations on a set: 43
2 .2. 3 Properties of relations: 44
2.2.4 Combining relations: 47
Exercises: 49
2.2.5 Representing relations using matrices: 50
2.2.6 The matrix for the composite relations: 53
2.2.7 Representing Relations Using Diagraphs: 54
Exercises: 57
2.2.8 Equivalence relations: 58
2.2.9 Equivalence classes: 60
Exercices: 64
2.2.10 Partial ordering: 65
2.2.11 Hasse diagrams: 66
2.2.12 Maximal and minimal elements: 68
2.2.13 The greater element and the least element: 68
2.2.14 Lattices: 72
Exercises: 73
7
2.3 Functions : 74
2.3.1 One-to-one and Onto functions : 77
2.3.2 Inverse functions and compositions of functions : 80
2.3.3 Some important functions: 82
Exercises: 83
Chapter 3
Algorithms ,Integers and Matrices
85
3.1 Algorithms: 85
3.2 Number theory: 87
3.2.1 The integers and division: 87
3.2.2 The division algorithm: 88
3.3 Modular Arithmetic: 89
3.4 Primes and greater common divisor primes: 90
3.5 The Greatest common divisor and the least common multiple: 91
Exercises: 93
3.6 Integers and algorithms: 94
3.6.1 Representation of integers: 94
3.6.2 Base conversion: 95
3.6.3 Algorithms for integers operations: 98
3.6.4 The Euclidean algorithm: 101
Exercises: 102
Chapter 4 (Boolean Algebra) 105
8
4.1.1 Boolean Functions: 105
4.1.2 Boolean Expressions and Boolean Functions: 106
4.1.3 Identities of Boolean algebra: 109
4.2 Duality : 110
4.3 The abstract definition of a Boolean algebra: 111
4.4 Representing Boolean Functions: 111
4.5 Logic Gates: 113
4.6 Combinations of Gates: 115
4.7 Minimization of Circuits: 115
4.8 Karnaugh Maps: 115
Exercises: 117
Chapter 5
An Introduction to Graph Theory
119
5.1 Basic Terminology: 120
5.2 Some special simple graphs: 122
5.3 Bipartite graphs: 124
5.4 Representing Graphs and Graph Isomorphism: 125
5.5 Adjency Matrices: 127
5.6 Incidence Matrices: 128
5.7 Isomorphism of Graphs: 129
Exercises: 131
5.8.1 Paths: 132
9
5.8.2 Connectedness in undirected graphs: 133
5.8.3 Connectedness in directed graphs: 135
5.8.4 Counting path between vertices: 136
5.9.1 Euler and Hamilton Paths: 138
5.9.2 Hamilton Paths and Circuits: 139
5.10 Planar Graphs: 141
Exercises: 144
Chapter 6 (Counting) 145
6.1 Basic Counting Principles: 145
6.2 The sum rule: 145
Exercises: 146
6.3 The Pigeonhole Principle: 147
6.4 Sequences and Summations: 148
6.4.1 Sequences: 148
6.4.2 Summations: 150
Exercises: 152
6. 5 Discrete Probability: 154
6.5.1 Random variables and sample Spaces : 154
Exercises: 157
6.6 Permutations and Combinations: 158
6.6.1 Permutations: 158
6.6.2 Combinations: 159
10
6.6 .3 The Binomial Theorem: 160
6.6 .7 Pascal’s triangle: 165
6.8. 1 Recurrence relations: 165
6.8. 2 Inhomogenious Requrrence Relations : 170
6.8.3 Another method of solving inhomogenous recurrence relations: 172
6.8.4 A formula for Fibonaci numbers : 174
Exercises: 175
References: 177
Discrete Mathematics
Introduction
What is discrete mathematics?
Discrete mathematics is the part of mathematics denoted to the
study of discrete objects.
Why We Study Discrete Mathematics?
11
There are several important reasons for studying discrete
mathematics. First, through this course you can develop your
mathematical maturity: that is, your ability to understand and
create mathematical arguments. You will not get very far in your
studies in the mathematical sciences without these skills.
Second, discrete mathematics is the gate-way to more advanced
courses in all parts of the mathematical sciences. Discrete
mathematics provides the mathematical foundations for many
computer science courses including data structures, algorithms,
database theory, automata theory, formal languages, compiler
theory, computer security and operating systems students find these
courses much more difficult when they have not had the appropriate
mathematical foundations from discrete mathematics.
12
Chapter 1
Logic and Proofs
1.1 Logic:
1.1.1 Propositions:
Def. (1):
A proposition is a declarative sentence (declares a fact) that is
either true or false, but not both.
Example (1): All the following declarative sentences are
propositions
1. Khartoum is the capital of Sudan.
2. 1 + 1 = 2
3. 2 + 2 = 3
Propositions 1 and 2 are true but 3 is false.
Example (2): Consider the following sentences:
1. What time it is?
2. Read this carefully.
3. x + 1 = 2
4. x + y = z
Sentences 1 and 2 are not propositions because they are not
declarative sentences. Sentences 3 and 4 are not propositions because
they are neither true nor false.
Def. (2) : Let p be a proposition. The negation of p denoted by
A×B={1 , a) ,(1 , b ),(1 , c) ,(2 , a) ,(2 , b) ,(2 , c )} is the statement "It is not the case that B× A={ (a ,1 ),( b,1 ),( c,1 )( a,2 )( b, 2) ,( c ,2 )}".A1 , A2 , . . . , Anis read "not A1×A1× A3× . . .× An" the truth value of negation of (a1 , ai),a i∈ A i=1,2 ,. .. . , n is the
opposite of the truth value of .
Example (3): Find the negation of the proposition:
Today is Friday
13
Solution: Today is not Friday.
Example (4): Find the negation of the proposition:
"At least 10 inches of rain fell today in Makka"
Solution: "Less than 10 inches of rain fell today in Makka".
Logic Connectives and Truth Tables of Compound Propositions:
Def. (3) : Let p and q be propositions.
The conjunction of p and q denoted by A×B×C is the proposition
"p and q".
The conjunction A={0,1 } , B= {1,2} is true when both p and q are true and
false otherwise.
The truth table for the conjunction of two propositions:
p q C={0,1,2 }
T
T
F
F
T
F
T
F
T
F
F
F
Def. (4): let p and q be propositions. The disjunction of p and q
denoted by A×B×C={(0,1,0 ),(0,1,1 ) ,(0,1,2 ),( 0,2,0 ) ,(0,2,1 ),( 0,2,2 ),(1,1,0 ),( 1,1,1 ), is the proposition "p or q". The disjunction (1,1,2) , (1,2,0 ),(1,2,1 ),(1,2,2 ) )}
is false when both p and q are false and is true otherwise.
The table for the disjunction of two propositions:
p q A∪B
T
T
F
F
T
F
T
F
T
T
T
F
14
Def. (5): Let p and q be propositions. The exclusive OR of p and
q denoted by A∪B={x | x∈ Avx∈B }, is the proposition that is true when exactly one
of p and q is true and false otherwise.
The truth table for the exclusive or of two propositions:
p q A∪B
T
T
F
F
T
F
T
F
F
T
T
FDef. (6): Let p and q be propositions. The conditional
statement {1,3,5 } is the proposition "if p, then q", the conditional
statement {1,2,3 } is false when p is true and q is false, and true
otherwise. In the conditional statement {1,2,3,5 } , p is called the
hypothesis and q is called the conclusion.
The truth value for the condition statement:
p q A
T
T
F
F
T
F
T
F
T
F
T
TThe following ways express the conditional statement:
"if p then q "p implies q"
"if p, q "p only if q"
'p is sufficient for q" "a sufficient condition for q is p"
"q if p" "q whenever p"
"q when p" "q is necessary for p"
"a necessary condition for p is q"
"q unless Bp" "q follows from p"
15
Example (7): Let p be the statement "Maha learns discrete
mathematics" and q the statement Maha will find a good job"
express the statements A as a statement.
Solution:
If "Maha learns discrete mathematics then she will find a good
job" or "Maha will find a good job when she learns discrete
mathematics" or "for Maha to get a good job, it is sufficient for her
to learn discrete mathematics".
1.1.2 Converse, Contrapositive, and Inverse
The proposition B is called the converse of A∩B , the
contrapositive of A is the propositionB . The proposition A∩B={x | x∈ A∧x∈B }is called the inverse of A∩B .
Example (8):
What are the contrapositive, the converse, and the inverse of the
conditional statement "The home team wins whenever it is raining".
Solution:
Because " p whenever q" is one of the ways to express the
conditional statement {1,3,5 } , the original statement can be written as
"If it is raining, then the home team wins".
The contrapositive of the conditional statement is: "If the home
team does not win, then it is not raining".
The converse is : "If the home team wins, then it is raining"
The inverse is : "If it is not raining, then the home team does not
win".
1.1.3 Biconditionals:
Def. (7): Let p and q be propositions. The biconditional
statement {1,2,3 } is the proposition "p if and only if q". the
biconditional statement {1,3 } is true when p and q have the same
16
truth values, and it is false otherwise biconditional statements are
called bi-implications.
The truth table for the biconditional A={1,3,5,7,9 }
p q B= {2,4,6,8 }
T
T
F
F
T
F
T
F
T
F
F
TSome other common ways to express A∩B=φ
"p is necessary and sufficient for q"
"If p then q, and conversely"
"p iff q"
So ∴
Example (10):
Construct the truth table of the compound proposition
|A∪B|=|A|+|B|−|A∩B|
Solution:
P q ¬q B A BT
T
F
F
T
F
T
F
F
T
F
T
T
T
F
T
T
F
F
F
T
F
T
F
1.1.4 Logic and Bit Operations:
Def. (8):
A bit is a symbol with two values zero and one, a bit string is a
sequence of zero or more bits. The length of this string is the
number of bits in the strings.
17
Example (11):
1 0101 0011 is a bit string of length nine.
The table for the Bit operators OR,AND and XOR:
x y A B A
0
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
0
1
1
0
Truth value Bit T
F
1
0Example (12):
Find the bitwise OR, bit wise AND and bitwise XOR of the bit
strings 01 1011 0110 and 11 0001 1101
Solution:
01 1011 0110
11 0001 1101
11 1011 1111 bit wise OR
01 0001 0100 bit wise AND
10 1010 1011 bitwise XOR
18
Exercises:
1) Which of these sentences are propositions? What are the
truth values of those that are propositions?
(a) London is the capital of America
(b) 2 + 3 = 5
(c) x + 2 = 11
(d) 5 + 7 = 10
(e) Answer this question?
2) What is the negation of each of these propositions
(a) Today is Thursday
(b) 2 + 1 = 3
(c) The summer in Khartoum is hot and sunny.
3) Construct a truth table for each of these compound
propositions:
(a) B (b) A−B={x | x∈ A∧x∉B } (c) {1,3,5 }
(d) {1,2,3 } (e) {5 }
4) Construct a truth table for each of these compound
propositions:
(a) A (b)U−A=A (c) A={x | x∉ A }
(d) A
5) Find the bitwise OR, bitwise AND and bitwise XOR of each
of these pairs of bit strings:
(a) 101 1110 , 010 001
(b) 111 0000 , 1010 1010
(c) 00 0111 0001 , 10 0100 1000
(d) 11 1111 1111 , 00 0000 0000
6) Evaluate each of these expressions
19
(a) 1 1000˄ (1 1011 A∪φ=AA∩U=A 1 1011)
(b) (0 1111 A∪U=UA∩φ=φ 1 010) A∪A=A
A∩A=A 0 1000
(c) (0 1010 ( A )=A 11011) A∪B=AA∩B=A 0 1000
Def.(9):
A Compound proposition that always true is called a tautology,
a compound proposition that is always false is called a contradiction
and a compound proposition that neither a tautology nor a
contradiction is called a contingency.
Examples of a tautology and a contradictionp ¬¿ ¿p p ˅¬¿ ¿p p ˄¬¿ ¿p
T
F
F
T
T
T
F
F1.1.5 Logical Equivalence:
Def.(10):
The compound propositions p and q are called logically
equivalent if A∪( A∩B )=AA∩( A∪B )=A is a tautology. The notation A∪A=U
A∩A=φ denotes that p
and q are logically equivalent.
Example (13):
Show that A={a , e , i , o ,u } and A={b , c ,d , f , g ,h , j ,k , l ,m, n , p ,q ,r , s ,t , v ,w , x , y , z } are logically equivalent
Solution:
p q A={1,2,3,4,5,6,7,8,9,10 } A∩B=A∪B A∩B={x |x∉( A∩B )} {x | ¬ (x∈ (A∩B ) ) {x | ¬ ( x∈ A∧x∈B ) } A∩B=A∪B↔({x | ¬ ( x∈ A∧x∈B ) })T
T
F
F
T
F
T
F
T
T
T
F
F
F
F
T
F
F
T
T
F
T
F
T
F
F
F
T
T
T
T
TExample (14):
Show that {x | ¬ ( x∈ A )∨¬(x∈B ) } is logically equivalent to {x |x∉ A∨x∉B }
20
Solution:
P q {x |x∈ A∨x∈B } {x | x∈( A∪B )} A∪B ({x | x∈( A∪B )}) ↔(A∪B )T
T
F
F
T
F
T
F
F
F
T
T
T
F
T
T
T
F
T
T
T
T
T
TExample (15):
Show that A∩(B∪C )= ( A∩B )∪ (A∩C ) ∀ is a tautology
P q x∈ A∩ (B∪C ) ⇒ x∈ A x∈(B∪C )
T
T
F
F
T
F
T
F
T
F
F
F
T
T
T
F
T
T
T
T1.2 Introduction to Proofs:
Introduction :
In this section we introduce the notation of a proof and describe
methods for constructing proofs. A proof is a valid argument that
establishes the truth of a mathematical statement.
1.2.1The Direct Proofs:
Def(11).: A direct proof of a conditional statement ⇒ x∈ A is
constructed when the first step is the assumption that p is true;
subsequent steps are constructed using rules of inference with the
final step showing that q must also be true.
Def(12).: The integer n is even if there exists an integer k such
that: n = 2k , and n is odd if there exists an integer k such that
n = 2k + 1.
21
Example (16):
Give a direct proof of the theorem "If n is an odd integer, then n2
is odd".
Solution:
This theorem states x∈B where x∈C is "n is an odd
integer" and ⇒ x∈ A is "n2 is odd",
assume that n is odd x∈B
x∈ Ax∈C⇒ x∈ A∩Bx∈ A∩C is odd.
1.2.2 The Indirect Proofs: (Proof by contraposition) ⇒ x∈ ( ( A∩B )∪ (A∪C ) ) . This means that the conditional statement
⇒ A∩(B∪C ) ⊆ (A∩B ) ∪ ( A∩C )can be proved by showing that its contrapositive is
true.
Example (17):
Prove that if n is an integer and 3n + 2 is odd, then n is odd.
Solution:
(x∈( ( A∩B )∪( A∩C ) )) means if 3n + 2 is odd, then n is odd its contrapositive ⇒ x∈(A∩B ) that is n is even implies 3n + 2 is even.
Assume that n is evenx∈( A∩C )
⇒ x∈ Ax∈B
x∈ A∧x∈C
⇒ x∈ Ax∈B is even
22
x∈C If ⇒ x∈ A is odd, then x∈ (B∪C ) is odd.
1.2.3 Proofs by Contradiction:
The proof by contradiction does not prove a result directly.
Example (18): Prove that ⇒ x∈( A∩( B∪C )) is irrational by giving a proof by
contradiction.
Solution: Let p be the proposition "⇒ (A∩B )∪( A∩C )⊆ A∩(B∪C ) is irrational" suppose
that B∪C is true.
Suppose A∩(B∪C ) is rational
A∩B where a and b have no common
factors
A∩C( A∩B )∪( A∩C )
A∪(B∩C )=(C∪B )∩A is an even integerA∪(B∩C )=A∩(B∩C ) is an even integerA∩(B∪C ) Z
(B∪C )∩A
(C∪B )∩A
A={0,2,4,6,8 } is an even integer
B= {0,1,2,3,4 } is an even integer
This contradicts a and b have no common factor
hence C={0,3,6,9 } is irrational.
Example (19): Give a proof by contradiction of the theorem "if A∪B∪C is odd, then A∩B∩C is odd".
Solution: A∪B∪C={0,1,2,3,4,6,8,9 }
Let p be "A∩B∩C={0 } is odd" and q be "n is odd".
23
To construct a proof by contradiction assume that both p and A1∪A2∪…∪An = ¿
i=1
nA iare true
A1∩A2∩…∩An = ¿i=1
nA i is odd and n is not odd
A1∪A2∪…∪An∪…= ¿i=1
∞A i is even
A1∩A2∩…∩An∩…=intersecti=1
∞AiZ
Ai={1,2 , … , i }
i=1,2 , …¿
i=1
∞Ai= ¿
i=1
∞{1,2 ,…, i }i= {1,2,3 ,…}
¿i=1
∞Ai=¿ A i
i=1
∞
{1,2,…,i }i={1}
¿ ¿ a1 , a2 , … ,an is even
This contradict our assumption that ¿ is odd,
hence n is odd .
Exercises:
1) Use a direct proof to show that the sum of two odd integers is
even.
2) Use a direct proof to show that the sum of two even integers
is even.
3) Use a proof by contradiction to prove that the sum of an
irrational number and a rational number is irrational.
4) Show that if n is an integer and n3+5 is odd ,
then n is even using :
a) A proof by contraposition.
b) A proof by contradiction .
5) Prove that if n is an integer and 3n+2 is even , then n is even
using :
a) A proof by contraposition.
b) A proof by contradiction.
24
6) Show that these statements about the integer x are
equivalent;
(i) 3x +5 is even .
(ii) x+5 is odd.
(iii)x2 is even.
1.2.4 Mathematical Induction:
Introduction:
In general, mathematical induction can be used to prove
statements that assert that a i is true for all positive integers a i ,
where {1,2,3,4,6 } is a propositional function. A proof by mathematical
induction has two parts, a basis step, where we show that {1,3,5,7,9 } is true
and inductive step, where we show that for all positive integers ¿ , if {1,2,3,4,5,6,7,9 } is true, then ¿ is true.
Example (1):
Show that if {1,3 } is a positive integer, then ASolution:
Let B be the proposition that the sum of the first A positive
integers is B .
Basis step: A×B is true because A .
inductive step (a ,b )∈ IR holds.
Inductive step:
Assume that aRb is true ----- (1)
we must show that :
(a , b )∉ R is also true? -----(2)
25
Add A to both sides of equation (1)
B
is equal to both sides of equation(2)
Hence R is true
(a , b )is true a .
Example (2):
Use mathematical induction to show that b CS 518
Solution:
Let CS 518be the proposition that CS 518 .
Basis step: R is true because CS 510 CS 510
Inductive step: for the inductive hypothesis, we assume that R is true. That is, we assume that
CS 510 -----(1) is true
To carry out the inductive step using this assumption we must
show that when we assume that CS 510 is true, then R is also true.
That is, we must show that:A={0,1,2 } -----(2) is true. ????
assuming the inductive hypothesis B= {a ,b }is true. Under the
assumption of {(0,0) ,(a , b ) ,(1, a ) ,(2 ,b }, add A to both sides of equation (1)
B
aRais equal to both sides of equation (2)1 Rb is true
Hence A is true A .
26
Example(3):
Use mathematical induction to prove:
ASolution:
Let A be the proposition that
Basis step: A={1,2,3,4 } is true, because R={(a ,b ) |a
Inductive step: Assume that b } is true (a , b )∈ R
i.e a ----(1)
To complete the inductive step, we need to show that if b is
true, then b =R={(1,1 ),(1,2 ), (1,3 ) ,(1,4 ), (2,2 ),(2,4 ),(3,3 ) , (4,4 )} is true ----(2)???
We add 1 to both sides of inequality (1)n is equal to both sides
of inequality (2)
hence A⊆A×A is trueA×A is true n2
.
Example (4):
Use mathematical induction to prove that
ASolution :
Let n be the propositional that A
Basis step: 2n is true because ∴
Inductive step: Assume that (2n )2 is true
A×AWe must show that under this hypothesis 2n2
is also true
n ?
We have
27
232=29=512 (by definition of exponent)
{a ,b , c } (by inductive hypothesis) R (because A )(a ,a )∈ R , ∀a∈ A (by definition of factorial function)
This shows that {1,2,3,4 } is true when R1={(1,1 ) ,(1,2) , (2,1) ,(2,2) ,(3,4 ) ,(4,1 ),( 4,4 )} is true.
Exercises:
1) Prove that ∀ n∈Z
1.2+2.3+…+n (n+1 )=n (n+1 )(n+2)
3
2) Let p(n) be the statement that n!<nn where n>1
a) What is p(2)? b) Show that p(2)
3) Prove that 3n<n !, ∀n>6
4) Prove that 2n>n2 ,∀ n>4
5) Prove that 12+32+52+…+(2 n+1 )= (n+1 ) (2 n+1 ) (2n+3 )3
6) Let p(n) be the statement that 12+22+n2=n (n+1 ) (2n+1 )
6 ,∀ n∈Z+¿ ¿
7) Let p(n) be the statement that 13+23+n3=( n (n+1 )2 )
2
, ∀n∈Z+¿ ¿
a) What is the statement p(1)?
b) Show that p(1) is true.
28
Chapter 2
Basic Structures
1) Sets
2) Relations
3) Functions
2.1 Sets :
Def. (1): A set is a collection of an unordered of objects.
Def. (2): The objects in a set are called the elements, or
members, of the set. A set is said to contain its elements.
We write R2={(1,1 ) ,(1,2) ,(2,1)} to denote R3={(1,1 ) ,(1,2 ) ,(1,4 ) ,(2,1 ) ,(2,2 ) ,(3,3 ) ,(4,1 ) ,(4,4 ) } is an element of the set A. the
notation R4={(2,1 ),(3,1 ),(3,2 ),(4,1) ,( 4,2) ,(4,3 )} denotes that R5 ={(1,1 ), (1,2 ), (1,3 ), (1,4 ) ,(2,2 ) ,(2,3 ) ,(2,4 ) ,(3,3 ) ,(3,4 ) ,( 4,4 )} is not an element of the set A. We use
a notation where all members of the set are listed between braces {a,
b, c, d} represent the set with four elements a, b, c and d.
Example (1):
1) The set V of all vowels in the English alphabet can be written
as: V = {a, e, i, o, u}
2) The set O of odd +ve integers less than 10 can be represented
by : O = {1, 3, 5, 7, 9}
3) The set of +ve integers less than 100 can be denoted by {1, 2,
…., 99}
Another way to describe a set is to use set builder notation. We
characterize all those elements in the set by stating the property or
properties they must have to be members.
e.g., the set O of all odd +ve integers less than 10 can be written
as
O = { x | x is an odd positive integer < 10}
O = { R6= {(3,4 )}| x is odd and x < 10}
Q+ = {R3 | R5 , for some +ve integers p and q}29
U
ax
ux
ox i.
e.V
is the set of all +ve rational numbers
IN = {0, 1, 2, 3, ….} the set of natural numbers.
Z = {…, -1, -1, 0, 1, 2, …} the set of integers
Z + = {1, 2, 3, …} the set of +ve integers
Q = {p/q | p ,q(a , a )Z, q (1,1 ) ,(2,2 ) ,(3,3 ) ,(4,4 ) 0} the set of rational numbers
IR, the set of real numbers.
Def (3).
Two sets are equal if and only if they have the same elements.
Example (2):
The set {1, 2, 3} and {3, 2, 2,1} are equal because they have the
same elements. Note that the order in which the elements of a set are
listed does not matter.
Sets can be represented graphically using Venn diagrams. In
Venn diagrams the universal set U which contains all the objects
under consideration, is represented by a rectangle. In side this
rectangle, circles or other geometrical figures are used to represent
sets.
Example (3):
Draw a Venn diagram that represent V, the set of vowels in the
English alphabet.
Venn diagram for the set of vowels30
ABU
Def (4).:
The set R1 , R2 , R4 is said to be a subset of R6 if and only if every element
of a|a is also an element of a . we use the notation Rdiv to indicate
that A is a subset of the set 0 .
Venn diagram showing 0
Example (4):
The set of all odd positive integers less than 10 is a subset of the
set of all positive integers less than 10.
The set of rational numbers is a subset of real numbers A
Theorem:
For every set S
(i) (b , a )∈ R
(ii) (a ,b )∈ R
Proof:
We will prove (i) and leave the proof of (ii) as an exercise
Let S be a set
∀ a , b∈ A is true because the empty set contains no
elements it follows that R is always false, it follows that the
conditional statement A is always true because its
hypothesis is always false and a conditional statement with a false
hypothesis is true.
31
A×B×C
When we wish to emphasize that a set A is a subset of the set B
but ⊃ we write ∀ a , b∈ A and say that A is a proper subset of B(a , b )∈ R .
If (b ,a )∈R and a=b are sets with A={0,1,2 } and B= {a ,b } , then {(0,0 ) ,(a, b ) ,(1, a ) ,(2,b } = A .
Def. (4):
Let S be a set. If there are exactly n distinct elements in S
where n is a nonnegative integer, we say that S is a finite set and that
n is the cardinality of S.
The cardinality of S is denoted by: |S|.
Examples (5):
1) LetA be the set of odd positive integers less than 10. Then |A|= 5.
2) Let S be the set of letters in the English alphabet.
Then | S | = 26.
3) B .
Def.(6): A set is said to be infinite if it is not finite.
Example (6): The set of positive integers is infinite.
2.1.2 The Power Set:
Def. (1):
Given a set aRa , the power set of R2 is the set of all subsets of the set R3 and is denoted by (b ,a ).
Example (7): What is the power set of the set {0, 1, 2}?
Solution:
(a , b ) is the set of all subsets of {0, 1, 2}. HenceR2
Example (8):
What is the power set of the empty set?
What is the power set of the set (2,1)
32
Solution :
(1,2)∈R2
R3
If a set has n elements, then its power set has 2n elements
2.1.3 Cartesian Products:
Def. (7) : The ordered n–tuple (2,1) ,(1,2)∈R3 is the ordered
collection that has (1,4 ) ,(4,1)∈R3 as its first element R4 , R5 as its second element and R6 as its nth element.
Def. (8): Let A and B be sets. The Cartesian product of R3 , R4 and R6 , denoted by R3 , is the set of all ordered pairs (a=b,a=−b) where b=a
and b=−a R4 = {( a=b⇒b=a, R6) | a+b≤3⇒b+a≤3}
Example (9):
What is the Cartesian product of R1, R2 , R4 = {1,2} and R5 = { R1 ,a≤b,b≤a⇒a=b}?
Solution: R2
Def.(9):A subset R of the Cartesian product a≻b is called a
relation from the set b≻a to the set R4. the elements of R are ordered
pairs.
For example R4 is a relation from
the set R5 to the set a=b+1 .
Example (10):
Show that the Cartesian product b=a+1 where A and B are
the sets in example (9)Rdiv
Rdiv
33
BA
u
BA
u
Def. (10): The Cartesian product of (2,1)∉Rdiv denoted by
b|a is the set of ordered n-tuples a=b where
R .
Example (11):
What is the Cartesian product A where (a ,b )∈ R
and (b , c )∈R ?
Solution:
(a , c )∈R . ∀a ,b , c∈ A
∀ a , b , c∈ A2.1.4 Sets Operations:
Def. (11) : Let A and B sets. The union of the sets A and B,
denoted by (a ,b )∈ R∧(b ,c )∈R→( a,c )∈R, is the set that contains those elements are either in
A or in B, R1 , R2 , R3
R4
Example (12):
The union of the sets R1 and a≤b is the set b≤c⇒a≤c .
Def. (12): Let R2 and a≻b be sets. The intersection of the sets b≻c⇒a≻c and R3 , denoted by a=±b , is the set containing those elements in both b=±c⇒a=±c and R4.
R5
(2,1)
34
Example (13):
The intersection of the sets (1,0)∈R5 and (2,0 )∉R5 is the set R6 .
Def. (13):
Two sets are called disjoint if their intersection is the empty set.
Example (14):
Let (2,1) , (1,2)∈R5
(2,2)∉R6 , Rdiv A and B are disjoint
aDef. (14):
Let b and b sets. The difference of c and k , denoted
by L – such that b=ak, is the set containing those elements that are in c=bL but not in c=a(kL ).
cExample (15):
The difference of Rdiv and A={1,2,3 } is the set B= {1,2,3,4 }
Def. (15) :
Let U be the universal set. The complement of the set A,
denoted by R1={(1,1) ,(2,2) ,( 3,3)}, is complement of A with respect to R2={(1,1 ) ,(1,2) ,(1,3) ,(1,4 )}
R1∪R2={(1,1 ), (1,2 ) ,(1,3) ,(1,4 ) ,(2,2) ,(3,3)}
35
A
A={0,1 } , B={1,2 }
Table (1)
Sets identities
R1∩R2={(1,1 )} Identity laws
R1−R2={(2,2 ) ,(3,3)} Domination laws
R2−R1={(1,2 ), (1,3 ) ,(1,4 )} Idempotent laws
R1 Complementation law
R2Commutative laws
R1={( x , y )|x≺ y } Associative laws
R2={(x , y )|x≻ y } Distributive laws
R1∪R2Demorgans laws
R1∩R2Absorption laws
R1−R2Complement laws
36
Example (16):
Let R2−R1 (where the universal set is the set of the letters
of the English alphabet).
Then R1⊕R2
Example (17):
Let A be the set of positive integers greater than 10 (with
universal set the set of all positive integers).
Then ( x , y )∈R1∪R2 .
2.1.5 Sets Identities:
Table 1 list the most important set identities here we prove
several of these identities using three different methods the proofs of
the remaining identities will be left as exercises.
Example (18): Use set builder notation express the reasoning
establish the 2nd demorgan’s law ( x , y )∈R1
Proof :
( x , y )∈R2 (def of complement)
= ( x , y )∈R1∪R2 (def. of does not belong symbol)
= x≺ y (def . of intersection)
= x≻ y (first demorgan’s law)
= x≺ y (by definition of does not belong symbol)
= x≻ y (by definition of complement)
= x≠ y (by definition of union)
= R1∪R2={( x , y )|x≠ y } (by meaning of set building notation).
Example (19):
Prove the first distributive law from table (1), which states that
37
( x , y )∉R1∩R2 sets A, B and C.
Solution:
(i) Suppose x≺ y
x≻ y and R1−R2=R1
R2−R1=R2 and R1⊕R2=R1∪R2−R1∩R2={( x , y)|x≠ y } or R (or both)A and B or S and B
C or R
S( x , y )∈R1 .
(ii) a∈ A Suppose that c∈C
b∈B or (a ,b )∈ R
(b , c )∈S and R or S SoR and R or S
R and {1,2,3 }
{1,2,3,4 } R={(1,1) ,(1,4 ) ,(2,3) ,(3,1 ),(3,4 )}
From (i), (ii) we complete the proof.
Table (2): A membership table for the distributive property
A B C S {1,2,3,4 } {0,1,2 } S= {(1,0 ),(2,0 ) ,(3,1 ) ,(3,2 ) ,(4,1 )} SoR= {(1,0) ,(1,1) ,(2,1 ),(2,2 ) ,(3,0) ,(3,1)}
1 1 1 1 1 1 1 11 1 0 1 1 1 0 11 0 1 1 1 0 1 11 0 0 0 0 0 0 00 1 1 1 0 0 0 00 1 0 1 0 0 0 00 0 1 1 0 0 0 00 0 0 0 0 0 0 0
38
C
UB
A A
To complete the proof.
Example (20):
Let A, B and C be sets. Show that R .
Solution :
A (First Demorgan’s law)
= Rn ,n=1,2 ,. . .. (2nd Demorgan’s law)
= R1=R (commutative law for intersections)
= Rn+1=RnoR (Commutative law for unions)
Generalized Unions and intersections.
Union of A, B and C Intersection of A, B and C
Example (21):
Let R2=RoR , R3=R2oR=RoRoR , R={(1,1) ,(2,1 ),(3,2 ) ,(4,3 )}
and Rn
what are n=4,5 , .. . . and R2=RoR ∴ R2 {(1,1) ,(2,1 ),(3,1 ) ,(4,2)}
Solution:
R3=R2 oR ∴ R2 {(1,1) ,(2,1 ),(3,1 ) ,(4,2) }
R4=R3
Def. (16):
The union of a collection of sets is the set that contains those
elements that are members of at least one set in the collection
39
BU
Rn=R3
Def. (17):
The intersection of a collection of sets is the set that contains
those elements that are members of all the sets in the collection
n=5,6,7 ,. . .. .. .We can extend the notation we have introduce for unions and
intersections to other families can be denoted by
1) R
2) AExample (22):
Suppose that Rn⊆R for n=1,2 ,. .. .
Then
R
and A={a1 , a2 , .. . , an }
2.1.6 Computer Representation of sets:
There are various ways to represent sets using a computer. One
method is to store the elements of the set in an unordered fashion.
However, if this is done, the operations of computing the union,
intersection or difference of two sets would be time-consuming,
because each of these operations would require a large amount of
searching for elements. We will present a method for storing
elements using an arbitrary ordering of the elements of the universal
40
set. This method of representing sets makes computing combinations
of sets easy.
Assume that the universal set B= {b1 , b2 ,. .. ,bn} is finite. First, specify an
arbitrary ordering of elements of A . Represent a
subset of B with the bit string of length n, where the ith bit in this
string is 1 if A=B belongs to A and 0 if A does not belong to A.
Example (23): Suppose that the universal set U= { 1,2,3,4,…,10}
The bit string for the subsets B and R of U are
11 1101 0000 and 10 1010 1010 respectively. Use bit strings to
find the union and intersection of these sets?
Solution:
1) The bit string for the union of these sets is
11 1101 0000 M R=[mij ]10 1010 1010 = 11 1111 1010 which
corresponds to the set mij=¿ {1 if (ai , b j )∈R ¿ ¿¿¿.
2) The bit string for the intersection of these sets is
11 1101 0000 A={1,2,3 } 10 1010 1010 = 10 1000 000
Which corresponds to the set B= {1,2 }
Exercises:
1) Let A={1,2 , 3 ,4 ,5 } and B= {0 ,3 , 6 }
Find (a) A∪B (b) A ∩ B (c) A−B (d) B−A
2) Find the sets A and B ifA−B = {1 ,5 , 7 , 8 } ,B−A={2 ,10 } and A ∩ B= {3 ,6 , 9 }
3) Determine whether these statements are true or false:
)a (0∈∅) b (∅∈ {0 } )c ({0 }⊂∅) d (∅⊂ {0 }
)e ({0 }∈ {0 }) f ({0 }⊂ {∅ , {∅ }} )g ({ {∅ }}⊂ {{∅ }} , {∅ }}
4) Use Venn diagram to illustrate the subset of odd integers in
the set of all positive integers not exceeding 10.41
5) Use Venn diagram to illustrate the relation ship A⊆B and B⊆C
6) What is the Cartesian product A × B ×C where
A={a , b , c } ,B= {x , y } and C={0 , 1 }
7) Let A={0,2,4,6,8,10 } , B={0 ,1 , 2 ,3 , 4 ,5 ,6 } and C={4,5,6,7,8,9,10 }.
Find: (a) A ∩ B∩ C (b) A∪B∪C (c) ( A∪B )∩C (d) ( A ∩ B )∪C
8) Suppose that the universal set U={1,2,3 ,…, 10 }
Express each of these sets with bit strings where the ith in
the string is 1 if i is the set and 0 otherwise. a) {3 , 4 ,5 }
b¿ {1 ,3 ,6 ,10 } c ({2 , 3 ,4 , 7 ,8 , 9 }
9) Using the same universal set in problem (8) find the set
specified by each of these bit strings
(a) 11 1100 1111 (b) 01 0111 1000 (c) 10 0000 0001
2.2.1 Relations and their properties:
Def. (1):
let R and A be sets. A binary relation from B to (a , b ) is a subset of a∈ A
We use b∈B to denote that a≻b and R to denote that a1=1 , a2=2 , a3=3
Example (1):
Let b=1 , b2=2 be the set of students in your school, and let R={( 2,1),(3,1 ),(3,2 ) } be the set
of courses. Let R be the notation that consists of those pairs M R=[0 01 01 1 ],
where A={a1 ,a2 ,a3 } is a student enrolled in course B= {b1 ,b2 ,b3 , b4 , b5 }. For instance, if Ahmed
and Ali and Zeid are enrolled in M R=[0 1 0 0 01 0 1 1 01 0 1 0 1 ], the pairs( Ahmed, R )
and (Ali, (ai , b j ) ), belong to mij=1, if Ali also enrolled in R={(a1 , b2 ) , (a2 ,b1) , (a2 , b3 ) , (a2 ,b4 ) , then the
pair (Ali, (a3 , b1) , (a3 ,b3) , (a3 , b5 )}) is also in R , however, if Zeid is not enrolled in R
then the pair (Zeid, (ai ,ai )∈R , i=1,2 , .. . ,n) is not in 1 S .
42
Example (2):
Let R and (a ,b )∈R . Then
{ (0 , a ) , (0 , b ) , (1 , a ) , (2 , b )} is a relation from (mij=m ji∀ i=1,2, . .. . , n) to R , (a , b )∈R but b ,a )∈ R⇒a=b.
Relations can be represented graphically as shown in the figure:
R a b
0 . a 0 x x
1 . 1 x
2 . b 2 x
2.2.2 Relations on a set :
Relations from a set m ji=1 to itself are of special interest.
Def. (2):
A relation on the set i≠ j is a relation from m ji=0 to m ji=0
Example (3):
Let mij=0 which ordered pairs are in the relation
i≠ j divides R
Solution :M R=[1 1 0
1 1 10 1 1 ] if and only if R and R are positive integers not
exceeding 4 such that MRdivides R
R R 1 2 3 4
1 1 1 x x x x
2 2 2 x x
3 3 3 x
4 4 4 x
Example (4) :
How many relations are there on a set with ¿¿ elements?
43
Solution:
A relation on a set R1 since R2 has A elements whenM R1
has M R2 elements, hence M R1 has M R2 subsets.
MR1∪R2=MR1
¿M R2 there are MR1∩R2=M R1
¿M R2 subsets of R1 .
Thus there are R2 relations on a set of A elements. For example
there are M R=[1 0 11 0 00 1 0 ] , relations on the set M R2
=[1 0 10 1 11 0 0 ]
2.2.3 Properties of relations:
Def. (3):
A relation R1∪R2 on a set R1∩R2 is called reflexive if M R1∪R2=M R 1
¿M R2=[1 0 1
1 1 11 1 0 ].
Example (5):
On MR1∩R2=M R1
¿M R2=[1 0 1
0 0 00 0 0 ]
A , BCm , n , pSoRRA
Which of these relations are reflexive?
Solution:
The relations B and S are reflexive because they both contain
all pairs of the form B namely C . The other
relations are not reflexive and because they do not contain all of these
ordered pairs. In particular R and S are not reflexive
because (3,3) is not in any of these relations.
Example (6):44
Is the "divides" relation on the set of positive integers reflexive.
Solution:
Since M SoR=[ t ij ] , M R= [r ij ] whenever MS=[Sij ] is a positive integer denoted by m×p
integer, the "divides" relation is reflexive. If we replace the set of
positive integers with the set of all integers the relation is not
reflexive because m×n does not divides n×p.
Def. (4):
A relation on a set (ai , c j )∈ SOR is called symmetric if bk such that (ai , bk )∈R whenever
(bk , c j )∈S ,t ij=1 . A relation r ik=skj=1 on a set k such that M S , if SoR and R , then S is called antisymmetric.
Example (7): Consider the relations on the set of integers:MR=[1 0 1
1 1 00 0 0 ] ,
M S=[0 1 00 0 11 0 1 ]
R3={¿,b)│a = b , or a = - b }
M SoR=M R
M S=[1 1 10 1 10 0 0 ]
MRn
Which of these relations contain each of the pairs (1,1) ,(1,2) ,
(2,1) ,(1,-1) and (2,2)?
Solution: The pair (1,1) is in R1 , R3 , R4∧R6 , (1,2 ) is∈R1∧R6 , (2,1 )is∈R2 , R5∧R6 , (1 ,−1 )is∈R1 ,R3∧R6
and finally, (2,2)is inR1 , R3 ,∧R4
Example (8):
Which of the relations from example (5) are symmetric and
which are antisymmetric.
45
Solution :
The relations MRn=M R
[n ]
andR2 are symmetric because in each case R
belongs to the relation whenever M R=[0 1 00 1 11 0 0 ] does. For R
2 both M
R2=M R[2] = [0 1 1
1 1 10 1 0 ] and
E . For (a , b ) both b and (a , a ) . a ,b , c and d are
antisymmetric.
Example (9):
Which of the relations from example (7) are symmetric and
which are antisymmetric.
Solution:
The relations (a , b ) and (a ,d )are symmetric. (b , b ) is symmetric, for (b , d ) or (c , a ) , then (c , b ) or (d , b )
R={(1,1 ),(1,3 ) ,(2,1) ,(2,3 ),(2,4 ) ,(3,1) ,(3,2) , (4,1) } is symmetric because {1,2,3,4 } .
R is symmetric because ( x , y ) .
non of the other relations is symmetric (verify).
The relations R={(1,3 ),(1,4 ) ,(2,1) ,(2,2 ),(2,3 ) ,(3,1) ,(3,3) ,( 4,1 ) ,( 4,3)} and (2,2 ) are antisymmetric
(3,3 )is antisymmetric because the inequalities ( x , x )and ( y , x )
( x , y )is antisymmetric because it is impossible for x and y .
y is antisymmetric, because two elements are related with
respect to z if and only if they are equal.
n is antisymmetric because it is impossible that R and R .
Example (10):
Is a on the set of positive integers symmetric? Is it
antisymmetric?
46
Solution:
b is not symmetric because but b since 2∤1.
It is antisymmetric, with and a , then b .
Def. (3):
A relation c on a set R is called transitive if whenever a
and b , then b .
Using quantifiers c a .
Example (11):
Which of the relations in example (7) are transitive?
Solution:
The relations c and S are transitive.
S is transitive since (c , a) ,(b , a )∈S and (c ,b)∉S
A is transitive since a and b
a ~bis transitive since a and b
R is clearly transitive.(verify)?
⊃ aRb is not transitive since a−b∈Zand R but R
∀ a∈ R : a−a=0∈Z is not transitive since ∴ aRa ∀ a∈ IRand R but ∀ a ,b∈ R : a−b∈Z
Example (12):
Is b−a∈Zon the set of positive integers is transitive?.
Solution:
Suppose that ∴aRb , bRa divides R and aRb divides bRc. Then there are
positive integers ⇒a−b∈Z ∧ b−c∈Zand a−c=(a−b)+(b−c )∈ Z ∴ aRc and R . Hence m ,
so a divides m∈ Z+ m≻1. Hence m is transitive .
47
21)2,1( divR
Zba , ba
2.2.4 Combining relations:
Example (13):
Let m≻1 and R={(a , b )a≡b(mod m)}|
The relation Z+
and
a≡b mod mCan be combined to obtain:
ma−ba−a=0m
Example (14): Let 0=0 . m be the "less than" relation on the set of
real numbers and let a≡a (mod m ) be the "greater than" relation on the set of
real numbers, that is ∴ R and a≡b(mod m) what are
(1) a−b (2) m (3) a−b=km (4) k∈Z and (5) b−a=(−k )m?
Solution (1) We note that b≡a(mod m) iff a≡b(mod m) or b≡c (mod m).
Hence m iff a−b or b−c . Because the condition k or L is the same as the condition a−b=km it follows that
b−c=Lm
(2) a−c=(a−b )+(b−c )=km+Lm=(k+L )m since a≡c (mod m)and ∴ R is impossible.
Hence ∴ =ϕ
(3) R
(4) (Rdiv )
(5) R rSub { size 8{ ital ÷} } Def. (4):
48
Let Rdiv be a relation from a set 2/4 to the set R rSub { size 8{ ital ÷} } and Z+ be a
relation from R to a set xRy. The composite of x , y∈ IR and |x−y|≺ 1 is the relation
consisting of ordered pairs R where R and |x−x|=0≺ 1, and for which
there exists an element R such that xRy , x , y∈ IR |x , y|≺ 1 and |y−x|=|x− y|≺ 1. We
denote the composite of yRx and R by x=2 .8 , y=1.9.
Example (15):
What is the composite of Z=1. 1 and |x− y|=|2 . 8−1 . 9|=0 .9≺1, where |y− z|=|1 .9−1 .1|=0. 8≺1 is a relation from |x−z|=|2 .8−1 .1|=1. 7≻1 to 2 .8 R 1 .9 , 1 .9 R 1.1 with 2 .8 R 1 .1 and ∴ R is a relation
from R to A with a∈ A
Solution:
aDef. (5):
Let R be a relation on the set [a ]R. The powers R are
defined recursively by [a ] and [a ]R={s|( a , s )∈ R }
(a and so on)
Example (16):
Let a≡0(mod 4 ) find ∴ [0 ]={.. . ,−8 ,−4,0,4,8 , .. . } for a .
Solution:
Since a≡1(mod 4 )
∴ [1 ]= {. . .,−7 ,−3,1,5,9 , . .. }[a ]m . Hence [a ]m= {. . . ,a−2 m, a−m , a, a+m ,a+2m , .. . } for [0 ]4= {. . .,−8 ,−4,0,4,8 , .. . }
Theorem(1) :
The relation [ 1]4= {. .. ,−7 ,−3,1,5,9 , .. .} on a set R is transitive iff A for a ,b∈ A
Exercises:
1) List the ordered pairs in the relation R from A={1,2,3,4} to
B={0,1,2,3}, where (a,b) R if and only if :
49
a) a=b (b) a+b =4 (c) a > b (d) a│b
2) For each of these relations on the set {1,2,3,4}, decide whether it
is reflexive ,symmetric ,antisymmetric and whether it is
transitive:
a){(2,2) ,(2,3),(2,4),(3,2),(3,3),(3,4)}
b) {(1,1),(1,2),(2,1) ,(2,2),(3,3) ,(4,4)}
c) {(1,2),(2,3) ,(3,4)}
d) {(2,4),(4,2)}
3) Determine whether the relation R on the set of all people is
reflexive , symmetric ,antisymmetric and /or transitive ,where
(a,b) R if and only if :
a) a is taller than b
b) a and b were born on the same day.
c) a has the same first name as b.
d) a and b have a common grandparent.
4) Let R1={ (1,2 ) , (2,3 ) , (3,4 )}
And R2={ (1,1 ) , (1,2 ) , (2,1 ) , (2,2 ) , (2,3 ) , (3,1 ) , (3,2 ) ,(3,4)}
be relations from {1,2,3} to {1,2,3,4} find:
a) R1∪R2
b) R1 ∩ R2
c) R1 R2
d) R1−R2
e) R2−R1
5) Let R be the relation {(1,2),(1,3),(2,3),(2,4),(3,1)} and S be the
relation {(2,1),(1,3),(2,3),(2,4),(3,1)} find S°R
2.2.5 Representing Relations Using Matrices:
A relation between finite sets can be represented using a zero –
one matrices. Suppose that aRb is a relation from [a ]= [b ] to
50
[a ]∩ [b ]≠φ (Here the elements of the sets ⇒ and aRb have been
listed in a particular, but arbitrary, order. Furthermore when [a ]= [b ]
we use the same ordering from [a ]⊆ [b ] and [b ]⊆ [a ].
The relation c∈ [a ] can be represented by the matrix where M R=[mij ]
aRbExample (17):
Suppose that R and (bRa) let R be the relation from bRato
aRc containing bRc if c∈ [b ]⇒ [a ]⊆ [b ], [b ]⊆ [a ] , and [a ]= [b ] . What is the matrix
representing [a ]∩ [b ]≠φ if [a ]≠φ (a∈ [a ] )R and [a ]∩ [b ] ?Solution:
Because φ , the matrix for ∃c∈ [a ] is
c∈ [b ]Example (18):
Let aRc and bRc represented by the
matrix
cRbSolution:
Since aRc consists of those ordered pairs cRb⇒ aRb with R , it
follows that A ¿a∈ A [a ]R=A
If the matrix of [a ]R∩ [b ]R is a square matrix, we say that [a ]R≠[b ]R is reflexive if
A (the elements in the diagonal of the matrix are
1's).
51
The relation S is symmetric if S implies S Ai , i∈ I . The relation S is antisymmetric if and only if
Ai≠φ , i∈ I and ( Ai∩A j=φ , i≠ j . Consequently, the matrix of an
antisymmetric relation has the property that if ¿i∈ I A i=S with S= {1,2,3,4,5,6 } then A1={1,2,3 }. Or, in other words, either A2= {4,5 } or {6 } when S
Symmetric relation antisymmetric matrix
Example (19):
Suppose that the relation S on a set is represented by the
matrix.
RIs S reflexive, symmetric, and/or antisymmetric.
Solution:
Because all the diagonal elements of the matrix are equal to 1, R
is reflexive. Moreover, because S is symmetric, it follows that { [A i]−1i∈ I } is
symmetric. It is also easy to see that S is not antisymmetric.
The Boolean operations join and meet R can be used to find
the matrices representing the union and intersection of two relations.
Suppose that Ai , i∈ I and R are relations on a set A1={1,2,3 } represented by the
matrices S and A3= {6 } respectively. The matrix representing the
52
1
1
1
1
0
1
0
0 0
1
union of these relations has a 1 in the position where both S= {1,2,3,4,5,6 } and
R have 1. Thus the matrices representing the union and
intersection of these relations are (a , b )∈ R and
aExample (20):
Suppose that the relations b and (1,1), (1,2) ,(1,3 ) ,(2,1) ,(2,2 ) ,(2,3), (3,2 ) on a set (3,3)∈R are represented
by the matrices:
A1={1,2,3 } (4,4 ) ,( 4,5) ,(5,4 )What are the matrices representing (5,5)∈R and A2= {4,5 }
Solution:
The matrices of these relations are
(6,6 )∈R{6 }
2.2.6 The matrix for the composite relations:
Suppose that R and [0 ]4 , [1 ]4 , [2 ]4 sets have [3 ]4 elements, respectively
let the zero – one matrices for [0]4= {. . .,−8 ,−4,0,4,8 , .. . } ([ 1]4= {. .. ,−7 ,−3,1,5,9 , .. .} is a relation from [2 ]4= {... ,−6 ,−2,2,6 , 10 , ... } to [3 ]4= {. ..,−5 ,−1,3,7 ,11 ,.. . } and R is a relation from S to S ), R and (S ,R ) be
S and ¿ resp, (these matrices have
sizes a≥a∀ a∈Z, >= and A≥b and resp.). The ordered pairs b≥a if
and only if there is an element a=b and >= . It
53
follows that >= iff a≥b∧b≥c for some a≥a∀ a∈Z. From the definition of
the Boolean product, this means that:
>= •(Z ,≥)
Example (21):
Find the matrix representing the relations Z+ , where the
matrices representing (Z+ ,1 ) and func ⊆ are
S A⊆ASolution:
The matrix for A⊆S , func ⊆ is
A⊆B∧B⊆ A • A=B
The matrix representing the composite of two relations can be
used to find the matrix for func ⊆ in particular
A⊆B∧B⊆CExample (22): Find the matrix representing the relation A⊆C,
where the matrix representing func ⊆ is
p( S ). ( p(s ) ,⊆)Solution: The matrix for a is
b2.2.7 Representing Relations Using diagraphs:
54
1 2
34
1 2
34
Def. (6):
A directed graph or diagraph consists of a set V of vertices
(nodes) together with a set (S ,≤) of ordered pairs of elements of V called
edges (arcs). The vertex a is called the initial vertex of the edge a≤b
and the vertex b≤a is called the terminal vertex of this edge.
An edge of the form a is represented using an arc from the
vertex, a back to itself. Such an edge is called a loop.
Example (23): The directed graph with vertices b and S ,
and edges a≤b , b≤a , a , b , (Z+ ,|), {(a , b)|a , and b } is displayed
as in the figure:
Example (24): The directed graph of the relation
{1,2,3,4,6,8 ,12 } on the set A is
shown in the figure:
Example (25):
What are the ordered pairs in the relation B represented by the
directed graph shown in the figure:
55
a
d
c
b
a
bc c
d
a b
Solution :
The ordered pairs f in the relation are:
AEach of these pairs corresponds to an edge of the directed graph
with B and B corresponding to loops.
The directed graph representing a relation can be used to
determine whether the relation has various properties. A relation is
reflexive if and only if there exist a loop at every vertex of the
directed graph, so that every ordered pair of he form A occurs in
the relation.
A relation is symmetric if and only if for every edge between
distinct vertices in its diagraph there is an edge to the opposite
direction, so that A is in the relation whenever A is in the
relation. Similarly a relation is antisymmetric if and only if there are
edges in opposite direction between distinction vertices. A relation is
transitive if and only if whenever there is an edge from a vertex B to
a vertex f : A → B and an edge from a vertex ¿ to a vertex f : A → B, there is an
edge from A × B to z.
Example (26):
Determine whether the relations for the directed graph shown in
the given figure are reflexive, symmetric, antisymmetric, and/or
transitive.
56
a
b c
R S
Solution :
There are loops at every of the directed graph of (a ,b ) , ∀ a∈ A, it is
reflexive, f (a )=b is neither symmetric nor antisymmetric because there is
an edge from (a , b ) to f (a )=b but not one from f : to f ( x)=x2, but there are edges in
both directions connecting {0,1,4 ,, 9 ,… } and ( f 1+ f 2) (x ) = f 1( x )+ f 2 ( x).( f 1 f 2 ) (x )= f 1 ( x )⋅f 2 ( x ) is not transitive because there is an edge from ( f 1) (x ) = x 2 , f 2 ( x )=x−x2 to f 1+ f 2 and an
edge from f 1 f 2 to ( f1+ f 2)( x )= f 1( x )+ f 2( x )=x2+( x−x2)=x but no edge from ( f1 . f2 )( x )= f1 (x ). f 2( x )=x2. (x−x2)=x3−x4 to A .
The loops are not present at all the vertex of the directed graph
of B , this relation is not reflexive. It is symmetric and not
antisymmetric because every edge between distinct vertices is
acompanied by an edge in the opposite direction. It is also A is not
transitive because (c,a) ,(a,b)S but S .
Exercises:
Represent each of these relations on {1 , 2, 3 } with
(a) {(1 ,1 ) , (1,2 ) , (1,3 ) } (b) {(1,2 ) , (2,1 ) , (2,2 ) , (3,3 ) }
(b) {(1 ,1 ) , (1,2 ) , (1,3 ) , (2,2 ) , (2,3 ) , (3,3 ) }(c) {(1 , 3 ) , (3,1 ) }
2) List the ordered pairs in the relations on {1 , 2,3 } corresponding
to these matrices
)a ([1 0 10 1 01 0 1 ]) b ([0 1 0
0 1 00 1 0]) c ([1 1 1
1 0 11 1 1]
3) List the ordered pairs in the relations represented by the
directed graphs
57
)a) (b) (c (
4) Draw the directed graph that represents the relation
{(a ,a ) , (a ,b ) , (b , c ) , (c , b ) , (c , d ) , (d , a ) , (d ,b ) }
2.2.8 Equivalence Relations:
Def. (7):
A relation on a set S is called an equivalence relation if it is
reflexive, symmetric and transitive.
Equivalence relations are important throughout mathematics
and computer science. One reason for this is that are equivalence
relations, when two elements are related it makes sense to say they
are equivalent.
Def. (8):
Two elements f (S ) and f ( S )={ t|∃ s∈S (t=f ( s )) }= {f ( s )|s∈ S} that are related by an equivalence
relation are called equivalent the notation A={a ,b , c ,d , e } is often used to
denote that B= {1,2,3,4 } and f (a )=2that are equivalent elements with respect to a
particular equivalence relation.
Example (27):
Let f (b )=1 be a relation on the set of real numbers f (c )=4 if and
only if f (d )=1 .
Is f (e )=1 an equivalence relation?
Solution:
1) S {b , c ,d } is reflexive since f (S )= {1,4 } f (a )=b
2) a=bis symmetric since a and b∈D f f
3) f (a)∓f (b )is transitive let a∓b and f
∀ a∀b ( f (a )= f (b )→a=b ). Therefore ∀ a∀b (a∓b→ f (a )∓ f (b ))
f58
Hence {a ,b , c , d } is an equivalence relation.
One of the most widely used equivalence relations is conqurence
modulo {1,2,3,4,5 }, where f (a )=4 .
Example (28):
Let f (b )=5 be a positive integer f (c )=1 . Show that the relation
f (d )=3 is an equivalence relation on f
Solution:
1) We have seen that f if and only if f (x )=x+1 divides f .
Note that f ( x )≤ f ( y ) is divisible by f ( x )≺f ( y ), because x≺ y . Hence x y is reflexive.
2) Suppose that f . Then f is divisible by f ( x )≻f ( y ), so f ( x )≥f ( y ) where f ( x )≻f ( y ). It follows that x≺ y , so x . hence is symmetric.
3) Suppose that y and f . Then A divides B and ∀ b∈B ∃a∈ A. Therefore, there are integers f (a )=b and f with {a ,b , c , d } and {1,2,3 } . Adding these two equations f (a )=3
Hence f (b )=2 f (c )=1 is transitive f (d )=3 form (1) , (2) and (3) f ( x )=x2 is
an equivalence relation.
Example (29):
Show that the "divides" relation f of the set of positive
integers is not an equivalence relation.
Solution:
By example (6) and example (12), we show that the x is
reflexive and transitive and by example (10) x2=1 is not symmetric
59
(for instance 2│4 but 4∤2. Hence f ( x )=x=1 on ∀ y∈Z ∃ x∈Z is not an equivalence
relation.
Example (30):
Let f ( x )= y be the relation on the set of real numbers such that f ( x )= y if
and only if x+1= y (real numbers) such that x= y−1 . show that f is
not an equivalence relation.
Solution :
1) {a ,b , c ,d } is reflexive since {1,2,3,4 }
2) f (a )=4 is symmetric since, for if f (b )=2 , which tells us
that f (c )=1 so f (d )=3
3) f is not transitive. Take f and A ,
so that A I A : A→A but
I A( x )=x . That is, I A but f A
is not an equivalence relation.
2.2.9 Equivalence Classes:
Def. (9):
Let B be an equivalence relation on a set a∈ A. The set of all
elements that are related to an element f (a )=b is called the equivalence
class of f . The equivalence class of a with respect to f−1(b)=a is denoted by
f (a )=b. When only one relation is under consideration, we can delete
the subscript f and write {a , b , c } for this equivalence class.
Example (31):
60
What are the equivalence classes of 0 and 1 for congruence module
4?
Solution:
The equivalence class of 0 contains all integers f (a )=2 such that f (b )=3 . The integers in this class are those divisible by 4
f (c )=1
The equivalence class of 1 contains all the integers f such that f . The integers in this class are those that have a
remainder of 1 when divided by 4. Hence
f−1
The equivalence classes of the relation congruence modulo are
called the congruence classes modulo m . The congruence class of an
integer a modulo m is denoted by f−1(1)=c, so
f−1(2 )=a
For instance, it follows that :
f−1(3 )=b and
fTheorem(2) :
Let → be an equivalence relation on a set f ( x )=x+1. These statements
for elements f are equivalent:
(i) f (ii) y=x+1
⇒ x= y−1⇒ f ( y )= y−1 (iii) g
Proof :
1) (i) A implies (ii) Assume that B . We will prove that
f by showing B and C . Suppose ( fog )(a)=f (g (a)).
Then g . Since {a ,b , c } and g(a )=b is symmetric g(b )=c .
Furthermore, since g(c )=a is transitive and f and {a ,b , c }, it
61
A4A5
A7
A1A2
A3
A6
A9A8
follows that {1,2,3 }. Hence f (a )=3 , f (b )=2 is left and
exercise for the reader.
2) (ii) implies (iii). Assume that f (c )=1 . It follows that
f because g is reflexive.
3) (ii) implies (i): suppose that g = f Then ( fog )(a)=f (g (a)) and
(b )=2 . (( fog )(b)= and f (g (b ))= f (c )=1). By the symmetric property, ( fog )(c )=f ( g(c ))= f (a )=3.
Then by transivity, f , g and f ( x )=2 x+3. Because (i) implies
(ii), (ii) implies (iii), and (iii) implies (i), the three statements,
(i), (ii) and (iii) are equivalent.
The union of the equivalence classes of f ( x )=3 x+2is all of f
(1) g
(2) g when f
These two observations show the equivalence classes from a
partition of ( fog) ( x)= f ( g ( x) )=f=2 (3 x+ 2)+3=6 x+7, because they split ( gof )( x)=g (f ( x ))= g(2x+3)=3(2x+3 )+ 2=6 x+11 into disjoint subsets. More
precisely, a partition of a set fog≠gof is a collection of disjoint nonempty
subsets of ( f−1 f )( a )=f−1( f ( a ))=f−1( b)=a that have f (a )=b as their union. In other words, the
collection of subsets ( fof −1)(b )= f ( f −1(b ))= f (a)=b (I is an index set) forms a partition of x
if and only if.
1) x
2) ⌊ x ⌋
3) x
The figure illustrates the concept of a partition of a set
62
Example (32):
Suppose that x . The collection of the sets x , [ x ] and ⌈ x⌉ forms a partition of ⌊12 ⌋= 0 because these sets are disjoint
and their union is ⌈12⌉= 1.
Theorem (3) :
Let ⌊−12 ⌋=−1 be an equivalence relation on a set ⌈−1
2⌉ = 0. Then the
equivalence classes of ⌊3 .1 ⌋ = 3 form a partition of ⌈3. 1⌉ = 4. Conversely, given a
partition {Ai|i∈ I ¿¿ of the set [1008]= 12 . 5 = 13, there is an equivalence relation a1 , a2 , … , an that
has the sets a1 , as its equivalence classes.
Example (33):
List the ordered pairs in the equivalence relation a i produced by
the partition a i , a and b of a≠0 in
example (32).
Solution:
The subsets in the partition are the equivalence classes of a .
The pair b iff c and b=ac are in the same subset of the partition.
The pairs a and b because
a is an equivalence class.
The pairs b and b , because a is an
equivalence class. The pair a|b , because b is an equivalence
class. No pair other than those listed belong to b .
Example (34):63
What are the sets in the partition of the integers arising from
congruence modulo 4?
Solution:
There are four congruence classes, corresponding to 3|7
and 3|12 . They are the sets:
73
3|12
123=4
These congruence classes are disjoint, and every integer is
exactly one of them. In other words, as theorem (2) says, these
congruence classes form a partition.
Exercises :
Which of these relations on {0 , 1 ,2 , 3 } are equivalence relations
)a ({(0,0 ) , (1,1 ) , (2,2 ) , (3,3 ) }
)b ({(0,0 ) , (0,2 ) , (2,0 ) , (2,2 ) , (2,3 ) , (3,2 ) , (3,3 ) }
)c ({(0,0 ) , (1,1 ) , (1,2 ) , (2,1 ) , (2,2 ) , (3,3 ) }
2 (Determine whether the relations represented by these matrices
are equivalence relations:
)a ([1 1 10 1 11 1 1]) b ([1 0
0 11 00 1
1 00 1
1 00 1]) c ([1 1
1 11 01 0
1 10 0
1 00 1]
3 (Which of these collections of subsets are partions of
{0 , 1 ,2 , 3 ,4 , 5 , 6 }?
64
)a ({1 ,2 }, {2 ,3 , 4 } , {4 ,5 , 6 }
)b ({1 } , {2,3,6 }, {4 } , {5 }
)c ({2 , 4 , 6 }, {1 ,3 ,5 }
4 (What is the congruence class [4 ]m when m is
)a (2? (b) 3? (c) 6? (d) -3?
2.2.10 Partial ordering:
Def. (1): A relation n on a set d is called partial ordering if it is
reflexive, antisymmetric, and transitive. A set n together with a
partial ordering d is called a partially ordered set, or poset, and is
denoted by d . Members of dk are called elements of the poset.
Example (1): Show that the "greater than or equal" relation k
is a partial ordering on the set of integers.
Solution:
1) Because d , hence n is reflexive
2) If k and 0≤dk≤n, then 0≤k≤n/d , hence n is antisymmetric.
3) d is transitive since a ,b implies c . Hence a|b is
a partial ordering on the set of integers a|c is a poset.
Example (2):The divisibility relation | is a partial ordering
relation on a|(b+c ), because it is reflexive, antisymmetric and transitive
( Z+¿ ¿ , | ) is a poset.
65
4
8
6
12
Example (3): Show that the inclusion relation a|bc is a partial
ordering on the power set of a set c .
Solution
1) Since a|b when ever, b|c is reflexive.
2) It is antisymmetric because a|c imply that a|b .
3) a|c is transitive, because s imply that t .
Hence b is a partial ordering on P(S), (P(S),) is a poset.
Def. (2): The elements st and b+ c=as+at=a (s+ t ) of a poset b+c are called
comparable if either a , b or c . When a|b and a|c are elements of a|mb+nc such that neither m nor n , a|mc and a|nc are called
incomparable.
Example (4): In the poset m are the integers 3 and 9
comparable? Are 5 and 7 comparable.
Solution : 3 and 9 are comparable since 3|9 .
The integers 5 and 7 are incomparable because 5∤7
and7∤5
2.2.11 Hasse diagrams: The resulting diagram contains sufficient
information to find the partial ordereing is called a Hasse diagram
Example (5): Draw the Hasse diagram representing the partial
ordering n divides a|mb+nc on a .
Solution : Begin with the diagraph for the partial order as
shown in the figure.
66
1(b) (b(a)1
2
4
8
3
6
1222222222
8
4
2
1
12
6
3
2)Remove all loops, as
shown in figure 1(b)
Then delete all the edges implied by the transitive property.
These are (1,4), (1,6) (1,8),
(1,12), (2,8), (2,12) and (3,12)
Arrange all edges to point upward
And delete all arrows to obtain the
Hasse diagram as shown in the figure
(c)
Example (6): Draw the Hasse diagram for the partial ordering {( A , B )|A B } on the power set P(S) where S= {a , b , c }.
Solution: The Hasse diagram for this partial ordering is
obtained from the associated diagraph by deleting all the loops and
all the edges that occur from transitivity, namely (∅ , {a , b } ), (∅ , {a , c } ),
(∅ , {b , c }), (∅ , {a , b , c }), ( {a } , {a ,b ,c } ), ( {b } , {a ,b , c } ), ( {c } , {a , b , c } ). Finally all
edges point upward, and arrows are deleted as shown in figure 2.
67
52
4
12 20
1025
Hasse diagram of (P {a , b , c } , )
2.2.12 Maximal and Minimal Elements:
Def.(3): 1) An element of a poset is called maximal if it is not
less than any element of the poset.
1) An element of a poset is called minimal if it is not greater
than any element of the poset. Maximal and minimal
elements are easy to spot using Hasse diagram. They are
“top” and “bottom” in the diagram.
Example (7): Which elements of the poset ( {2 ,4 ,5 ,10 ,12 , 20 ,25 } ,│ )
are maximal, and which are minimal?
Solution:
For this poset shows that
the maximal elements
are 12, 20 and 25 and
the minimal elements
are 2 and 5.
2.2.13 The greatest element and the least element:
68
d
c
a
b
Def.(8):1) An element b in the poset (S , ≤ ) is called the greatest
element of (S ,≤ ) if b ≤ a ∀a∈S. The greatest element is unique.
2)An element a in the poset (S ,≤ ) is called the least element of
(S ,≤ ) if a ≤ b ∀b∈S. The least element is unique.
Example (8): Determine whether the posets represented by each of
the Hasse diagram in the figure have greatest element and least
element.
b c d d e d
a a b a b
(a) (b) (c) (d)
Solution:
1) The least element of the poset with Hasse diagram (a) is a. this
poset has no greatest element.
2) The poset with Hasse diagram (b) has neither a least nor a
greatest element.
3) The poset with Hasse diagram (c) has no least element. Its
greatest element is d.
69
h
g f
e
c
a
b
d
4) The poset with Hasse diagram (d) has least element a and
greatest element d.
Example (9): Let S be a set. Determine whether there is a
greatest element and a least element in the poset ¿.)
Solution: The least element is the empty set, because ∅ T , T S∀ ∈ .
The set S is the greatest element in this poset, because T S whenever T is a subset of S.
Example (10): Is there a greatest element and least element in
the poset ¿.
Solution: The integer 1 is the least element because 1│ n , ∀n∈Z+¿ ¿,
there is no integer that divide all positive integers, there is no greatest
element.
Def.(4): 1) An element u∈S is called an upper bound of A S if
a ≤ u∀ a∈ A .
2) An element L∈S is called a lower bound of A if
∀a∈ A , L ≤a.
Example (11): Find the lower and upper bounds of the subsets
{a , b , c } , { j ,h } and {a , c , d , f } in the poset with the given Hasse diagram.
Solution:
1) The upper bounds of {a , b , c }
are e , f , jand and its only
lower bound is a.
70
j
2) There are no upper bounds
of { j , h }, and its lower pounds
are a , b , c , d , e and f .
3) The upper bounds of
{a , c , d , f } aref ,h and j, and its
lower bound isa.
Def.(5):
1) The element x is called the least upper bound of the subset A if
x is an upper bound that is less than every other upper bound
of A.
2) The element y is called the greatest lower bound of Aif y is
the lower bound of A.
Example (12): Find the greatest lower bound and the least upper
bound of {b ,d ,g }, if they exist in the poset shown in example (11).
Solution:
1) The upper bounds of b , d ,g are g and because g<h,g is the least
upper bound.
2) The lower bounds of {b ,d , d } are a, and b, because a<b , b is the
greatest lower bound.
Example (13):
Find the greatest lower bound and the least upper bound of the
sets {3 , 9 , 12 } and {1 , 2, 4 ,5 ,10 } if they exist, in the poset ¿.
Solution:
71
f
dc
b
a
ee
h
b dd
aa
b
d
f
e
c
1) An integer is a lower bound of {3 , 9 , 12 } if 3 ,9 and 12 is
divisible by this integer. The only such integers are 1 and 3.
Since 1│3, 3 is the greatest lower bound of {3 , 9 ,12 }.
2) The only lower bound for the set {1 , 2, 4 ,5 , 10 } with respect to │ is the element 1. Hence 1 is the greatest lower bound for
{1 , 2, 4 ,5 , 10 }.
3) An integer is an upper bound for {3 , 9 ,12 } iff it is divisible by
3, 9 and 12. The integers with this property are those
divisible by LCm (3, 9, 12) which is 36. Hence 36 is the least
upper bound of {3 ,9 , 12 }.
4) A positive integer is an upper bound for {1 ,2,4 ,5,10 } iff it is
divisible by 1, 2, 4, 5 and 10. The integers with this property
are those integers divisible by LCm (1, 2, 4, 5, 10) which is
20. Hence 20 is the least upper bound of {1 , 2, 4 ,5 , 10 }.
2.2 .14 Lattices :
Def.(6): A partially ordered set in which every pair of elements
has both least upper bound and greatest lower bound is called a
lattice.
Example (14): Determine whether the posets represented by
each of the Hasse diagrams in the figure are lattices.
Solution:
72
(a) (b) (c)
1) The posets represented by the Hasse diagrams in (a), (c) are
both lattices because in each poset every pair of elements has
both a least upper bound and a greatest lower bound.
(verify).
2) The poset with the Hasse diagram in (b) is not lattice, because
the elements b and c have no least upper bound.
Example (15): Is the poset ¿ a lattice?
Solution: Let a , b∈Z+¿¿. the least upper bound and greatest
lower bound of these two integers are the least common multiple and
the greatest common divisor of these integers resp. (verify). Hence ¿
is a lattice .
Example (16): Determine whether (P ( x ) , ) is a lattice where S is a
set?
Solution: Let A and B be two subsets of S. The least upper
bound and the greatest lower bound of A and B are A B and A B
respectively. Hence (P (S ) , ) is a lattice.
Exercises:
1 (Which of these are posets?
)a (¿) b ((Z , ≠ )) c ((Z , ≥ )) d ((Z ,∤ )
2 (Which of these pairs of elements in these posets?
)a (P ( {0 , 1, 2 } , )) b (( {1 , 2, 4 ,6 , 8 } ,│ )
3 (Draw the Hasse diagram for the “less than or equal to relation on
{0 , 2 ,5 , 10 , 11 ,15 }
73
a
b
de
f
g
cb
d
c
gf
h
e
a
A
bB
f
4 (answer these questions for the poset ( {3,5,9,15,24,45 } , │)
)a (Find the maximal elements.
)b (Find the minimal elements.
)c (Is there a greater elements.
)d (Is there a least element?
)e (Find all upper bounds of {3 , 5 }
)f (Find the least upper pound of {3 ,5 }, if it exists
)g (Find all lower bounds of {15 , 45 }
)h (Find the greatest lower pound of {15,4 5 }, if it exists
5 (Determine whether the posets with these Hasse diagrams are
lattices.
)a) (b(
2.3 Functions:
Def. (1):
Let d and q be non empty sets, a function r from 0≤r≺d to a=dq+r is
an assignment of exactly one element of d to each element of a .
We write f(a) = b if b is the unique element of B assigned by the
function f to the element a of q . If f is a function from r to q=a, we
write r≡a
Remark : Functions are sometimes also called mappings or
transformations
74
C={0,1,2 }
A function ¿ can also be defined in terms of a relation
from A to B. A relation from A to B is just a subset of ∴ . A
relation from A to B that contains one and only one, ordered pair ∴ defines a function from A to B.¿ , wherea is the unique ordered pair in the relation
that has a as its first element.
Def. (2): If a function from A to B, we say that A is the domain of
f. If b we say that b is the image of a and a is a preimage of b.
The range of f is the set of all images of elements of A. also, if f is a
function from A to B, we say that f maps A to B.
Two functions are equal when they have the same domain, have
the same codomain, and map elements of their common domain to
the same elements in their common codomain.
Example(1):
What are the domain, codomain and range of the function that
assigns grades to students shown in the figure
Ahmed AAli B
Fahad COmer DOsman F
Solution: Let g be the function that assigns a grade to a student
1) The domain f of g is {Ahmed, Ali, Fahad, Omer,
Osman}
2) The codomain of g is {A, B, C, D, F}
75
3) The range of g is {A, B, C, F}
Example(2):
Let f be the function that assigns the last two bits of length 2 or
greater to that string e.g. f(11010) = 10. Then, the domain of f is the
set of all bit strings of length 2 or greater, and both the codomain and
range are the set {00, 01, 10, 11}.
Example(3):
Let, m Z→ Z assigns the square of an integer to this integer.
Then a the domain of f is the set of all integers ,the codomain
of f to be the set of all integers and the range of f is the set of all
integers that are perfect squares namely b .
Example(4):
The domain and codomain of functions are often specified in
programming languages. For instance, the Java statement in t floor
(float real) ( …..) and the pascal statement function floor (x : real):
integer both state that the domain of the floor function is the set of
real numbers and its codomain is the set of integers.
Def.(3):
Let f1 + f2 be functions from A to IR then f1 + f2 and f1f2 are also
functions from A to IR defined by
(1) m (2) m
Example(5):
Let f1 and f2 be functions from IR to IR such that
a−b what are the functions
(1) a≡b (2) m
Solution:
(1) a
76
(2) b
Def.(4): Let f be a function from the set m to the set a and let S
be a subset of b . the image of S under the function f is the subset of m that contains of the images of the elements of a≠b we denote the
image of m by a
bExample(6):
Let m and a with b , m , a
, b and m . The image of the subset S={b,c,e} is the set
a=b+km .
2.3.1 One-to-One and Onto functions:
Some functions never assign the same value to two different
domain elements.
These functions are said to be one-to-one
Def.(5): A function f is said to be one-to-one or injective, if and
only if m implies that a≡b for all c≡d andm . A function is
said to be injection if it is one-to-one. Note that a function a+c≡b+d is one-
to-one if and only if f ( a )≠ f (b) whenever a≠ b.
Remark:
We can express that m is one-to-one using quantifiers as
a≡b or equivalently ∀ a ,∀ b a≠b → f (a )≠ f (b) where
the universe of discourse is the domain of the function.
Example(7):
Determine whether the function c≡d from m to ∃s ,t ∈
with b=a+sm , d=c+ tm , b+d=(a+sm )+ (c+tm )=(a+c )+m (s+t ) and bd= (a+sm ) (c+tm )=ac+m (at+cs+stm ) is one-to-one.
77
Solution:
The function a+c≡b+d is one-to-one because m takes on different values
at the four elements of the domain as shown in the figure
a .1
b 2
c 3
d 4
5
Example(8):
Determine whether the function ac≡bd from IR to IR is one-
to-one function.
Solution:
The function ac≡bd is a One-to-One function , note that x+1
≠ y +1 when x≠y.
Def.(6):
A function m whose domain and codomain are subsets of the set
of real numbers is called increasing if m and stricktly
increasing if a whenever b and (a+b ) and m are in the
78
.
..
. .
. .
.
domain of a . Similarly m is called decreasing if b and
stricktly decreasing if m and stricktly decreasing if ab where m and a and m are in the domain of b .
Def.(7):
A function from m to m is called onto or surjective if and only if m with m . A function is called surjective if it is
onto.
Example(9) :
Let a+b𨠨 be the function from a to m defined by m
, b𨠨, b and m is onto function
a . . 1
b . . 2c . . 3d .
An onto function
Example(10):
Is the function m from the set of integers to the set of
integers onto?
Solution:
The function a+b𨠨 is not onto because there is no an integer a with
x2=−1 for instance.
Example (11):
Is the function f ( x )=x+1 from the set of integers to the set of
integers onto?
Solution:79
This function is onto, because m m . To see
this, note that ab𨠨 if and only if a , which holds if and only
if x=y - 1.
Def.(8): The function is a one-to-one correspondence or
bijective, if it is both one-to-one and onto.
Example(12):
Let b be the function from m to m with p , p , p and n is √n a bijection?
Solution:
The function is one-to-one and onto. It is one-to-one because no
two values in the domain are assigned the same function value. It is
onto because all the four elements of the codomain are integers of
elements in the domain.
Hence √101 is a bijection.
Example(13):
Let a be a set. The identity function on b is the function d|a where d|b the function a is bijection function.
2.3.2 Inverse functions and compositions of functions:
Def.(9):
let b be a one-to-one correspondence from the set gcd (a , b ) to the set gcd . The inverse function of is the function assigns to an element
the unique element a b . The inverse function of gcd is
denoted by gcd when gcd .
Example(14):
Let ∴ be the function from gcd to 2min ( 3,2) . 3min (1,0 ). 5min( 1,3) a , b
and a is b invertable, and if it is what is its inverse.
80
Solution:
The function a is invertable because it is one-to-one
correspondence. The inverse function b reverses the
correspondence given by so Lcm(a , b)= , P1max (a1, b1 ) . P2
max (a2 ,b2 ) .. .. Pnmax (an , bn)
and a .
Example(15) :
Let b : R ab=gcd (a, b ). Lcm (a , b) R be such that b . Is n invertable, and if
it is what is its inverse?
Solution:
The function n=ak bk+ak −1 bk−1+ … +a1b+a0 has an inverse because it is a one-to-one
correspondence, as we have shown in example (10) it is invertible. To
find its inverse let
A ,B ,C ,D , EDef.(10).:
Let F be a function from the set A to the set F and let (2 AEOB )16 be a
function from the set (2 AEOB )16 to the set n . The composition of the function
and denoted by n is defined by .
Example(16):
Let b be the function from the set q0=bq1+a1 0≤a1≺b to itself a1 ,
b and n let b be the function from the set b to the
set ∴ (2B 3 EA )16 , ∴ and ( A 8 D )16 what is the composition of 3 , E ,B and C , and what is the composition of (3 EBC ) and n ?
Solution:
81
-1-2-3
-3 -2 -1 1 2 3 o
o
o
o
o
o321
-1-2-3
-3 -2 -1 1 2 3
o
o
o
o
o
The composition is denoted by q :=n = fk :=0 , q≠0 ak :=q and b .
Example(17):
Let q :=Lq /b be the functions from Z to Z defined by k :=k+1
and g(x)=3x+2 what is the composition of n and (ak−1 … a1a0 )b and what is the
composition of a and b ?
Solution:
(1) ( f ° g ) ( x )=f (g ( x ) )=f (3 x+2 )=2 (3 x+2 )=6 x+4
(2) a
Remark:
Note that b if a if b
and a0+b0=c0 .2+s0
2.3.3 Some important functions:
Def.(11):
The floor function assigns to the real number s0 the largest
integer that is less than or equal to a+b and is defined by c0 . The
ceiling function assigns to the real number 0 the smallest integer that
is greater than or equal to 1 .
The value of the ceiling function at a1+b1+c0=c1 .2+s1 is denoted by ⌈ x ⌉
82
3
2
1
The graph of a floor function The graph of the ceiling function.
Example(18) :
There are some values of the floor and ceiling functions
c1 , a+b , an−1 , bn−1 ,
cn−2 ,cn−1. 2+sn−1 , sn=cn−1 , a+b=(sn sn−1 … s1s0)
Example(19) :
Data stored on a computer disk or transmitted over a data
network are usually represented as a string of bytes. Each byte is
made up of 8 bits. How many bytes are required to encode 100 bits
of data?
Solution:
To determine the number of bytes needed, we determine the
smallest integer that is at least as large as the quotient when 100 is
divided by 8, the number of bits is a byte. Consequently,
a=(11101 )2 bytes are required.
Exercises :
1) Why isf not a function from R ¿R if :
83
a) f ( x )=1x
? ( b)f ( x )=√x ? (c) f ( x )=±√ x2+1
2)Determine whether each of these functions from Z to Z is
one- to-one
a) f (n )=n−1 (b) f (n )=n2+1 (c)f (n)=n3 (d)f (n )=⌈ n2⌉
3) Find these values :
a¿ ⌊1.1 ⌋ (b)⌈ 1.1⌉ ( c)⌊−0.1 ⌋ (d)⌈−0.1⌉
(e) ⌈ 34⌉ (f) ⌊ 7
8⌋ (g)⌈ 3⌉ (h) ⌊−1 ⌋
4) Findf ° g wheref ( x )=x2+1 and g ( x )=x+2, are functions from R to
R.
5) Find f +g and f . g for the functions f∧¿ g given in Exercise (4).
6) Let f be the function from R to R denoted byf ( x )=x2 .Find :
a) f−1({1 }) (b)f−1¿)
84
Chapter 3
Algorithms, the integers and matrices
3.1 Algorithms:
Def.(1): An algorithm is a finite set of precise instructions for
performing a computation or for solving a problem.
Example(1):
Describe an algorithm for finding the maximum (largest) value
in a finite sequence of integers.
Solution:
We perform the following steps :
1- Set the temporary maximum equal to the first integer in the
sequence.
2- Compare the next integer in the sequence to the temporary
maximum, and if it is larger than temporary maximum, set
the temporary maximum equal to this integer.
3- Repeat the previous step if there are more integers in the
sequence.
4- Stop when there are no integers left in the sequence. The
temporary maximum at this point is the largest integer in the
sequence.
Algorithm (1): Finding the maximum element in a finite
sequence.
Procedure max (b=(11101 )2: integers)
max : = a0+b 0=0+1=0 . 2+1
for i: = 2 to n
if max < c0=0 then max : = s0=1
{max is the largest element}85
There are several properties that algorithms generally share.
They are useful to keep in mind when algorithms are describes these
properties are:
Input. An algorithms has input values from a specified set.
Output. From each set of input values an algorithm
produces output values from a specified set. The output
values are the solution to the problem.
Definiteness. The steps of an algorithm must be defined
precisely.
Correctness. An algorithm should produce the correct
output values for each set input values.
Finiteness. An algorithm should produce the described
output after a finite (but perhaps large) number of steps for
any input in the set.
Effectiveness. It must be possible to perform each step of an
algorithm exactly and into a finite amount of time.
Generality. The procedure should be applicable for all
problems of the desired farm, not just for a particular set of
input values.
86
3.2 The Number Theory
3.2.1 The integers and division:
Def. (2):
if a1+b1+c1=1+1+0=1 .2+0 and ∴ c1=1 are integers with s1=0 , we saya2+b2+c2=1+1+1=1.2+0 that divides ∴ c2=1 if
there is an integer s2=0 (such that a3+b3+c3=1+1+1=1 .2+1 when c3=1 divides s3=1 we say that s4=c3=1
is a factor of ∴ s=a+b=(11001 )2 and that a ,b : is a multiple of a . The notation b
denoted that a divides (an−1 an−2 … a1 a0 )2. We write a∤b when a doesnot divide (bn−1bn−2 … b1b0 )2.
Example(2):
Determine whether c :=0 and j :=0 .
Solution:
1) n−13∤7 because d :=L (a j+b j+c ) /2 is not an integer
2) s j :=a j+b j+c−2 d because c :=d .
Example(3) :
Let sn :=c and (snsn−1 … s0 )2 be positive integers. Howmany positive integers not
exceeding n are divisible by a ?
Solution:
The positive integers divisible by b are all integers of the form ab=a (b0 20+b1 21+ … +b n−1 2n− 1), where =a(b 0 20 )+a (b1 21)+… +a (bn−12
n−1 ) is a positive integer. Hence, the number of positive
integers divisible by a , b : that donot exceed a equals the number of
integers b with (an−1 an−2 … a1a0 ) 2 or with (bn−1bn−2 … b1b0 )2. Therefore, there are
positive integer not exceeding j :=0 that are divisible by n−1.
Theorem (1):
Let b j=1, and c j :=a be integers. Then
1- if j and c j=0, then c0 , c1 , … , cn−1
2- if p :=0, then j :=0 for all integers n−1.
87
3- if p := p+c j and p , then ab .
Proof:
Using direct proof of (1) suppose that a=(110 )2 and b=(101 )2. Then, from
the definition of divisibility, it follows that there
are integers ab0 . 20=(110)2. 1 .20= (110)2 and ab1.21= (110 )2 .0 .21=( 0000 )2 with ab2 . 22=(110 )2 . 1 .22=(11000 )2= as and (110 )2 = (11000 )2 hence∴ab=(1 .1110 )2
Therefore, a divides 0 1 1 11 0 1 01 1 0 01 0 0 0 .
The proof of (2) and (3) are left as exercise for the reader.
Corollary(1):
If 0 1 1 01 0 0 11 0 0 10 1 1 0 and
0 3 0 23 0 1 10 1 1 22 1 2 0 are integers such that
0 1 1 01 0 0 11 0 0 10 1 1 0 and , then
8 0 0 80 8 8 00 8 8 08 0 0 8
whenever and ¬ p ( p ) are integers.
Proof:
We will give a direct proof. By part (2) of theorem (1) it follows
that p and ¬ p whenever p and p are integers. By part (1) of
theorem (1) it follows that ¬ p .
3 .2.2 The division algorithm:
Theorem (2): The division algorithm let ( p∧q ) be an integer and p∧q a
positive integer. Then there are unique integers p∧q and p∨q with
p∨q such that p∨q .
Def.(3): In the equality in the division algorithm, p⊕q is called the
divisor, p⊕q is called the divided, p→q is called the quotient, and p→q is
called the remainder. This notation is used to express the quotient
and remainder. p→q div d, p→q mod d
Example (4): What are the quotient and remainder when 101 is
divisible by 11?
Solution: We have101 = 11*9 + 2
88
9 = 101 div 11
2 ¬¿ ¿ 101 mod 11
Example (5):
What are the quotient and remainder when -11 is divisible by 3.
Solution: -11 = 3(-4) + 1
p→q q = - 4 and r = 1q→p - 4 = - 11 div 3
1 p→q -11 mod 3
3.3 Modular Arithmetic:
Def.(4):
If p→q and ¬ q→¬ p are integers and ¬ q→¬ p is a positive integer, then p→q is
congruent to p→q modulo p ↔q if p↔q divides p↔q . we use the notation p ↔q mod p↔q to indicate that p ↔q≡( p→q )∧ (q→q ) is congruent to ( p∨¬ q ) → p∧q modulo q . If p∨ ¬q
and p∧q are not congruent modulo ( p∨ ¬ q )→ ( p∧q), we write x∨ y mod x∧ y .
Theorem( 3):
Let x⊕ y and p→¬ q be integers, and let ¬ p ↔q be a positive integer. then
mod if and only if ( p→q )∨ (¬ p→ p )mod = ( p↔q )∨ (¬ p↔q )mod .
Example (6):
Determine whether 17 is congruent to 5 modulo 6 and whether
24 and 14 are not congruent modulo 6.
Solution:
Since 6 divides 17-5 = 12, we say that 17 ≡ 5 mod 6.
Since 24 – 14 = 10 is not divisible by 6
24 ≢ 14 mod 6.
Theorem (4):
Let (¬ p↔¬ q )↔ ( p↔q )be a positive integer. The integers p→ (¬ q∨r ) and ¬ p→ (q→r ) are congruent
modulo ( p→q )∨(¬ p→r ) iff there is an integer ( p↔q )∨(¬ p ↔r ) such that ¿ .
Theorem (5):
89
Let ¿ be a positive integer if ¿ mod and ⊕ (mod ⊕), then p (mod p∨ p) and p∧ p (mod p ↔q).
Proof;
Since p≡q (mod ¬ ( p∨q )) and¬ p∧¬ q (mod p∨q) ¬ ( p∨q ) with ¬ p and ¬ q .
Hence
¬ p∧¬ q .
and p→q .
Hence ¬ p∨q (mod ¬ p) and ¬ p∨q (mod p→q).
Example(7) :
Since 7 ≡ 2 mod 5 and 11 ≡ 1 mod 5
hence 18 = 7 + 11 ≡ 2 + 1 = 3 (mod 5)
and 77 = 7*11 , 2.1 ≡ 2 (mod 5)
Corollary (2);
Let ( p∧q ) → ( p∨q ) be a positive integer and let p∧q and p∨q be integers. Then
( p∧q )→ ( p∨q ) modp→q = ((∀ n p (n)→q ( n)mod p (n )) + (q (n ) mod ⇒ n=2k+1 , k∈ z))
and ⇒ n2= (2k+1)2mod⇒ n2=4 k2+4 k+1 = ((⇒ =2 (2k 2+2k )+1 mod ⇒ n2) (p→q≡¬ q→¬ p mod p→q)) mod ¬ q→¬ p.
Proof:
By the definition mod p→q and the definition of congruence
modulo ¬q→¬p, we know that ⇒ n=2 k , k∈ z(⇒ 3 n=3 (2 k ) mod ⇒ 3n+2=3 (2 k )+2) (mod = 6 k+2) and = 2 (3 k+1 )(⇒ 3 n+2mod ∴ ) (mod 3 n+2)
Hence, from theorem (5) tells us that
n (√2 mod √2) + (¬pmod √2) (mod ⇒ √2 = ab)
and ⇒ 2= a2
b2 (⇒ 2b2=a2 mod ⇒ a2) (⇒ amod ⇒ a=2 c , c∈) (mod ⇒ 2 b2=4c2)
3.4 Primes and greater common divisor primes:
Def.(4):
90
A positive integer ⇒ b2=2c2 greater than 1 is called prime if the only
positive factors of ⇒ b2 are 1 and ⇒ b. A positive integer that is greater
than 1 and is not prime is called composite.
Example(8):
The integer 7 is prime since its only positive factors are 1 and 7,
where the integer 9 is composite because it is divisible by 3.
The primes less than 100 are
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89 , and 97.
Theorem (6): ( The fundamental theorem of arithmetic)
Every positive integer greater than 1 can be written uniquely in
a prime or as the product of two or more primes where the prime
factors are written in order of non decreasing size.
Example(9): Give the prime factorizations of 100, 64, 999 and
1024
Solution:1. 100 = 2.2.5.5 = 22.52
2. 641 = 641
3. 999 = 3.3.3.37 = 33.37
4. 1024 = 2.2.2.2.2.2.2.2.2.2 = 210
Theorem (7): If √2 is a composite integer, then has a prime less
than or equal to 3 n+2.Example(10): Show that 101 is prime
Solution:
The only are exceeding n are 2, 3, 5 and 7. Because 101 is
not divisible by 2, 3, 5 and 7 it follows that 101 is prime.
3.5 Greatest common divisor and least common multiple:
91
Def.(5):
Let p→q ≡¬q→¬p and 3n+2 be integers, not both zero. The largest integer
such that ¬ q and ⇒ 3 n+2 is called the greatest common divisor of ⇒ n and
⇒ n=2 k , k∈ and is denoted by ⇒ 3 n=3 (2 k ).
Example(11) :
What is the greatest common divisor of 24 and 36?
Solution:
The positive common divisors of 24 and 36 are
1, 2, 3, 4, 6 and 12,
Hence ⇒ 3n+3=3 (2k )+2 (24, 36) = 12.
Example(12) :
What is the greatest common divisor of 17 and 22?
Solution:
The integers 17 and 22 have no positive common divisors other
than 1, so that gcd (17, 22) = 1.
Def.(6):
The integers = 6 k+2 and = 2(3 k+1) are relatively prime of their greatest
common divisor is 1. ∴ (17, 22) = 1
Example(12):
Determine whether the integers 10, 17 and 21 are pairwise
relatively prime and whether the integers 10, 19 and 24 are pairwise
relatively prime?
Solution:3 n+2(10, 17) = 1, (10, 21) = 1,3 n+2(17, 21) = 1 hence 10, 17 and 21 are pairwise relatively prime.
Example (13):
1(gcd(300,18)= gcd(12,18)= gcd(12,6)=6
92
2(gcd(101,100)=gcd(1,100)=1
3(gcd(89,55)=gcd(34,55)= gcd(34,21)=gcd(13,21)=gcd(13,8)
=gcd(5,8 )=gcd(5,3)=gcd(2,3)=gcd(2,1)=1
You can check in each case (using a prime factorization of
the numbers ).
Example(14):
The prime factorization of 120 and 500 are 120 = 23 . 3 . 5 and
500 = 22. 53.
p(n ) the n (120, 500) = p(n ) = 22.30.51 = 20
Def.(7):
The least common multiple of the positive integers p(1) and k is
the smallest positive integer that is divisible by both p(k ) and p(k+1 ). The
least common multiple of n and 1+2+. .. ..+n=n( n+1)2 denoted by
p(n ) n Example(15):
Find Lcm (23.35.72, 24.33) = 2max(3,4).3max(5,3).7max(0,2) = 24.35.72
Theorem(8) :
Let n(n+1)2 and p(1) be positive integers. Then 1=
(1+1 )2
Exercises:
1) Does 17 divides each of these numbers :
a) 68 (b) 84 (c) 357 (d) 1001
2) Show that if a is an integer other than 0 , then :
a) 1 divides a (b) a divides 0
3) What are the quotient and remainder when :
a) 19 is divisible by 7?
b) -111 is divisible by 11 ?
c) 789 is divisible by 23 ?
93
d) 1001 is divisible by 13 ?
4) Evaluate these quantities:
a) – 17mod 2 (b) 144mod 7 (c) -101mod13 (d) 199mod19
5) List five integers that are congruent to 4modulo12
6) Decide whether which each of these integers is congruent to
5 modulo17 :
a) 80 (b)103 (c)-29 (d) -122
7) Determine whether each of these integers is prime :
a) 21 (b) 29 (c) 71 (d) 97 (e) 111 (f) 143 (g) 113 (h) 107.
8) Determine whether the integers in each of these sets are
pairwise relatively prime :
a) 21 , 34 , 55 (b) 14 , 17 ,85 (c) 25 ,41,49 ,64 (d) 17 ,18 ,19 ,23.
9) Find gcd(1000,625) and lcm(1000,625) and verify that
gcd(1000,625).lcm(1000,625)= 1000.625.
10) What are the greatest common divisors of these pairs of
integers:
a)37 . 53. 73 , 211 .35 .59
b) 2.3.5.7.11.13,211 .39 .11 .1714
c) 17,1717
d)22 .7 ,53 .13
3.6 Integers and algorithms:
3.6.1 Representation of integers:
In every day life we used decimal notation to express integers.
For example, 965 is used to denote 9.102 + 6.10 + 5.
However, it is often convenient to use bases other than 10. In
particular computers usually use binary notation (with 2 as a base)
when carrying out arithmetic, and octal (base 8) or hexadecimal
(base 16).
94
Theorem(9) :
Let p(k ) be a positive integer greater than 1. Then if 1+2+. . .. .+k= k (k+1)2 is positive
integer, it can be expressed uniquely in the form
1+2+. .. ..+k+(k+1 )=(k+1)(k+1 )+12
=(k+1)(k+2)
2
Example(16):
What is the decimal expansion of the integer that has (1 0101 111)2
as its binary expansion?
Solution:(1 0101 111)2 = 1.28 + 0.27 + 1.26 + 0.25 + 1.24 + 1.23 +1.22 + 1.21
+ 1.20 = 351
Usually, the hexadecimal digits used are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
(k+1 ) and 1+2+ . .. ..+k+(k+1)= k(k+1 )2
+(k+1 )= k(k +1 )+2(k +1 )2
=(k +1 )(k +2)2 , where the letters p(k+1 ) through ∴ p (n) represent the
digits corresponding to the numbers 10 through 15 (in decimal
notation).
Example(17):
What is the decimal expansion of the hexadecimal expansion
∀ n∈ IN
Solution:
We have
1+2+22+. . .+2n=2n+1−1 = 2.164 + 10.163 + 14. 162 + 0.161 + 11 = (175627)10
3.6.2 Base conversion:
We will now describe an algorithm for constructing the base
expansion of an integer ∀ n∈ IN. First, divide p(n ) by 1+2+. . .+2n=2n +1−1 to obtain a quotient
and remainder, that is to obtain
p(0 )
95
We see that 20=21−1=1 is the second digit from the right in the base ∀ n∈ IN
expansion of p(k ). Continue this process, successively dividing the
quotient by 1+2+. . .+2k=2k+1−1, obtaining additional base p(k ) digits as the remainders.
This process terminates when we obtain a quotient equal to zero.
Example(18) :
Find the base 8, or octal, expansion of (12345)10
Solution:
First, divide 12345 by 8 to obtain12345 = 8.1543 + 1
1543 = 8.192 + 7
192 = 8.24 + 0
24 = 8.3 + 0
3 = 8.0 + 3
p(k+1 ) (12345)10 = (30071)8
Example(19) :
Find the hexadecimal expansion of (177130)10
Solution:177130 = 16.11070 + 10
11070 = 16.691 + 14
691 = 16.43 + 3
43 = 16.2 + 11
2 = 16.0 + 2
(177130)10 = 1+2+. ..+2k+2k+1=2(k+1)+1−1=2k+2−1
Example(20):
Find the binary expansion of (241)10
Solution:241 = 2.120 + 1
120 = 2.60 + 0
60 = 2.30 + 0
96
30 = 2.15 + 0
15 = 2.7 + 1
7 = 2.3 + 1
3 = 2.1 + 1
1 = 2.0 +1p(k ) (241)10 = (111 1001)2
Example(21): Find the binary form of the non negative integers
up to 10 ?
Solution:
0 = (0)2
1 = (1)2
2 = (10)2
3 = 2+ 1 = (11)2
2 = 3 + 1 = (100)2
3 = 4+ 1 = (101)2
4 = 4+2+1 = (110)2
5 = 4 + 2 + 1 =(111)2
6 = 7+1 = (1000)2
7 = 8 + 1 = (1001)2
8 = 8 + 2 = (1010)2
Example(22) :
Find the hexadecimal expansion of (11 1110 1011 11 00)2 and binary
expansion of p(k )
Solution:
To convert (11 1110 1011 1100)2 into hexadecimal notation we
group the binary digits into blocks of four adding initial zeros at the
start of the leftmost block if necessary. These blocks are 0011, 1110,
1011 and 1100 which correspond to the hexadecimal digits 2k+1 and
1+2+22+ . . .+2k+2k+ 1=(1+2+22+ . . .+2k)+2k+1 respectively consequently (11 110 1011 1100)2 = =(2k+1−1)+2k+1
¿2 .2k+1−1¿2k+2−1
97
Algorithm(1): constructing base expansion procedure base
expansion (∴ p (k+1): positive integer)p(n )
∀ n∈ IN
While n≺2n ∀ n∈ IN
Begin
p(n )mod p(1)
1≺21=2
p(k )
end {the base ∀ n∈ IN expansion of k≺2k is p(k ) }
Hexadecimal octal and binary representation of the integers 0 -15Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F
Octal 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17
Binary 0 1 10 11 100 101 11
0
111 1000 1001 101
0
1011 1100 110
1
1110 1111
3.6.3 Algorithms for integers operations:
The algorithms for performing operations with integers using
their binary expansions are extremely important in computer
arithmetic. We will describe algorithms for the additional and
multiplication of two integers expressed in binary notation. We will
also analyze the computational complexity of these algorithms, in
terms of the actual number of bit operations used. Throughout this
discussion, suppose that the binary expansion of p(k+1 ) and k+1≺2k+1 are
k+1≺2k+1≤2k+2k=2 . 2k=2k+1
So thatp(k+1 ) and ∴ p(n ) each have bits (putting bits equal to 0 at the
beginning of one of these expansions if necessary).
To add ∀ n∈ IN and 2n≺n ! ∀ n≥4, first add their right most bits p(n )
98
Where 2n≺n ! is the rightmost bit in the binary expansion of p(4 )
and 24=16≺4 !=24 is the carry, which is either p(k ) or 2k≺k ! ∀ k≥4.
Then p(k+1 )
Where 2k+1≺(k+1 )!, is the next bit (from the right in the binary expansion
of 2k+1=2. 2k and ¿2 .k!is the carry. Continue this process, adding the
corresponding bits in the two binary expansions and the carry to
determine the next bit from the right in the binary expansion of ¿( k+1)k !.
At the last stage, add 2≺k+1 and =(k+1 )! to obtain p(k+1 ). The
leading bit of the sum is p(k ) . This procedure produces the
binary expansion of the sum, namely, a∈ A
Example(23) : Add a∉ A and vSolution :
x∈ Z+
So that x∈ℜ and x=p/q
∈¿ and A
BA and B
A⊆B
it follow that B and A⊆B
Q⊆ IRφ⊆ S111
1110
1011
99
11001
Algorithm (2) Addition of integers:
Procedure add (S⊆S positive integers)
{ the binary expansions of ∀ x (x∈φ→ x∈S ) and x∈φ are x∈φ→ x∈S and
A≠B respectively}A⊂B
for ∀ x ( x∈A→ x∈B )∧ x ( x∈B∧x∉ A ) to A
begin
BA⊆B
B⊆ A
end
A
{the binary expansion of the sum is B }
Multiplication of two S -bit integers S and n
The conventional algorithm (used when multiplying with pencil
and paper) works as follows:
SS
Algorithm (3) Multiplying integers:
Procedure multiply (S positive integers)
{the binary expansions of S and |φ|=0are S and
S , respectively}
for S to p( S )
begin
if p ( {0,1,2 } ) then p ({0,1,2 })={φ, {0 } , {1 }, {2} , {0,1 }, {0,2 } , {1,2 }, {0,1,2 }} shifted {φ } places
100
else p (φ )={φ }
end
{ p ( {φ })=¿¿ and partial products}(a1 , a2 ,…, an )
for a1 to a2
an
{A is the value of B }
Example (24): Find the product of A×B and a∈ A
Solution ;
b∈BA×B
a∈ A∧b∈B
To find the product add A and B
A×B = {(1 ,a ),(1 , b ) ,(1 , c ) ,(2 , a ),(2 , b ), (2 , c )}3.6.4 The Euclidean Algorithm:
The method described in section 3.5 for computing the greatest
common divisor of two integers , using the prime factorization of
these integers is inefficient. We will give a more efficient method of
finding the greatest common divisor ,called the Euclidean algorithm .
Before describing the Euclidean algorithm , we will show how it
is used to find gcd(91,287). First ,divide 287 by 91 (the larger of the
two integers by the smaller) to obtain
287 = 91*3+14
Any divisor of 91 and 287 must also be a divisor of 287- 91*3 =
14. Also,any divisor of 91 and 14 must also be a divisor of 287 = 91*3
+ 14. Hence , the greatest common divisor of 91 and 287 is the same
as the greatest common divisor of 91 and 14 . This means that the
101
problem of finding gcd(91 ,287) has been reduced to the problem of
finding gcd(91,14).
Next ,divide 91 by 14 to obtain
91 = 14*6 + 7
Because any common divisor of 91 – 14*6 = 7 and any common
divisor of 14 and 7 divides 91 , it follows that gcd(91,14) = gcd(14,7)
Continuing by dividing 14 by 7, to obtain
14 = 7*2
Because 7 divides 14 ,it follows that gcd(14,7 ) = 7
Hence gcd(287,91) = gcd(91,14) = gcd(14,7) = 7
Lemma:
Let a = bq +r , where a ,b and r are integers . Then
gcd(a,b) = gcd(b,r).
Example (25):
Find gcd(414,662) using the Euclidean algorithm.
Solution:
662 = 414*1+ 248
414 = 248*1 + 166
248 = 166*1 + 82
166 = 82*2 + 2
82 = 2*41
Hence , gcd(414,662) = 2
Algorithm (4) The Eculidean Algorithm:
Procedure gcd(a,b: positive integers )
x :=a
y :=b
while y ≠ 0
begin
102
r := x mod y
x := y
y := r
end {gcd(a,b) is x }
Exercises:
1) Convert these integers from decimal notation to binary
notation :
a) 231 (b) 4532 (c) 97644 (d) 321 (e) 1023 (f) 100632
2) Convert these integers from binary notation to decimal
notation :
a) 1 1111 (b) 10 0000 0001 (c) 1 0 101 0101
d) 110 1001 0001 (e) 1 1011 (f) 10 1011 0101
3) Convert these integers from hexadecimal notation to binary
notation :
a) 80E (b) 135AB (c) ABBA (d) DEFACED
4) Convert ¿ from its hexadecimal expansion to its binary
expansion .
5) Convert these integers from binary notation to its
hexadecimal notation :
a) 1111 0111
b) 1010 1010 1010
c) 111 0111 0111 0111
6)Convert (a) ¿ (b) ¿
to their hexadecimal expansions.
103
7) Convert ¿ to its binary expansion and ¿ to its octal
expansion .
8) Convert ¿ to its hexadecimal expansion and ¿ to its octal
expansion .
9) Use the Euclidean algorithm to find :
(a) gcd(12,18)
(b) gcd(111,201)
(c) gcd(1001,1331)
( d) gcd(12345,54321)
(e) gcd(1000,5040)
(f) gcd(9888,6060)
104
Chapter 4
Boolean Algebra
4.1.1 Boolean Functions:
Introduction :
Boolean algebra provides the operations and the rules for
working with the set (0, 1). Electronic and optical switches can be
studied using this set and the rules of Boolean algebra. The three
operations in Boolean algebra that will use most are
complementation, the Boolean sum, and the Boolean product. The
complement of an element, denoted with a bar, is defined by ō = 1
and I = 0. The Boolean sum, denoted by + or by OR, has the
following values:
1+1 = 1, 0+0=0 , 0+1=1+0 =1
1.1= 1, 1.0 = 0 = 0.1 = 0, 0.0 = 0 ,
Example (1):
Find the value of 1.0+(0+1 )
Solution:
Using the definitions of complementation, the Boolean sum, and
the Boolean product, it follows that :1.0+(0+1 )=0+1=0+0=0
The complement, Boolean sum, and Boolean product
correspond to the logical operators, Ø, Ú and Ù respectively where 0
corresponds to F (false) and 1 corresponds to T (true) Equalities in
Boolean algebra can be directly translated into equivalences of
compound propositions can be translated into equalities in Boolean
algebra.
Example (2): Translate 1.0+(0+1 )=0, into a logical equivalence.105
Solution:
We obtain a logical equivalence when we translate each 1 into a
T, each 0 into a F, each Boolean sum into disjunction, each Boolean
product into a conjunction and each complementation into negation,
we obtain 1.0+(0+1 )=0T F (T F ) F
Example (3): Translate the logical equivalence
(T T ) Ø F º T into an identity in Boolean algebra.
Solution:(T T ) Ø F º (1.1) + ō = 1
4.1.2 Boolean Expressions and Boolean Functions:
Def.(1): Let B = (0,1). Then is the set of all possible n-tuples
of 0s and 1s. The variable x is called a Boolean variable if it assumes
values only from B, that is, if its only possible values are 0 and 1. A
function from to is called a Boolean function of degree n .
f : B2 → B
Example (4): The function f ( x , y )=x y from the set of ordered
pairs of Boolean variables to the set {0 , 1 } is a Boolean function of
degree 2 ,f (1 ,1 )=1. T=1.0=0 , f (1,0 )=1. o=1.1=1
f (0 ,1 )=0.T=0.0=0 and f (0 ,0 )=0. o=0.1=0
x y f (x , y )
1
1
0
0
1
0
1
0
0
1
0
0
Example (5): Find the values of the Boolean function
represented by f ( x , y , z )=xy+z.106
Solution: The values of this function are displayed in the given
table
Example
(6): The function
f ( x , y , z )=xy+z from B3 to B can be represented by distinguishing the
vertices that correspond to the five 3-tuples (1,1,1) , (1,1,0), (1,0,0),
(0,1,0) and (0,0,0) where is shown in the given figure
107
100
010
110
101
011
111
x y z xy z f ( x , y , z )=xy+z
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
0
1
1
0
0
0
0
0
0
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
These vertices are displayed using solid black circles. The Boolean
sum of they function f and g and Boolean product of f and g are given by
1) ( f +g )(x1, x2, …, xn) = f (x1 , x2 , …,xn )+g (x1 , x2 , …,xn )
2) ( f +g )(x1, x2, …, xn) = f (x1 , x2 , xn )+g (x1 , x2 , …, xn )
108
011
4.1.3 Identities of Boolean algebra:
Boolean identities:
Identity Name
x́=x Law of the double complement
x+x=x , x . x=x Idempotent lows
x+0=x , x .1=x Identity laws
x+1=1 , x .0=0 Domination laws
x+ y= y+x , xy= yx Commutative laws
x+( y+z )=( x+ y )+z
x . ( y . z )=( x . y ) . z
Associative laws
( x+ yz )=( x+ y )(x+z)
x ( y+z )=xy+ xz
Distributive laws
( xy )=x+ y , ( x+ y )=x . y Deomorgan’s laws
x+xy=x
x (x+ y )= x
Absorption laws
x+x=1 Unit property
x . x=0 Zero property
109
Example (7):
Translate the distributive lawx+ yz=( x+ y )(x+z) into a logical
equivalenc
Solution :x+ yz=( x+ y ) ( x+z )≡ p (q r )≡ ( p q )(p r )
Example (8):
Prove the absorption law x (x+ y )= x using the other identities of
Boolean algebra.
Solution:
x (x+ y )= ( x+0 )(x+ y) identity law for the Boolean sum
¿ x+0. y distributive law
¿ x+ y .0 commutative law
¿ x+0 domination law
¿ x identity law
4.2 Duality:
Def.(2) The dual of a Boolean expression is obtained by
interchanging Boolean sums and Boolean products and
interchanging 0s and 1s.
Example (9):
Find the duals of (1) x ( y+0 ) (2) x .1+( y+z)
Solution:
1) x+( y .1 )
2) ( x+0 )( y . z)
Example (10): Construct an identity from the absorption law
x (x+ y )= x by taking duals.
Solution :x+x . y=x
110
4 .3 The abstract definition of a Boolean algebra:
Def. (3): A Boolean algebra is a set B with two binary operations v and n, elements 0 and 1, and a unary operation such that these
properties hold ∀ x , y ∀ , z∈B
x∨ x=xx∧ x=x} identity law.x∨ x=1x∧ x=0} Commutative laws.
( x y ) z=x ( y z)( x y ) z=x ( y z)} Associative laws.x y= y xx y= y x } Commutative laws.
x ( y z )=( x y )( x z)x ( y z )=( x z )(x z)} Distributive laws.
4.4 Representing Boolean Functions:
Example (11): Find Boolean expressions that represent the
functions f (x , y , z) and g(x , y , z), which are given in the table x y z f g
1 1 1 0 00
1 0 1 1 01 0 0 0 00 1 1 0 00 1 0
0 0 1 0 00 0 0 0 0
Solution :111
1 1 0 1
0 1
1) An expression that has the value 1 when x=z=1 and y=0 and
value otherwise, is needed to represent f . Such an
expression can be formed by taking the Boolean product of
x , y and z. This product, x y z has the value if x= y=z=1
which holds iff x=z−1 and y=0.
2) To represent g, we need an expression that equals 1 when x= y=1 and z=0 or when x=z=0 and y=1. We can form an
expression with these values by taking the Boolean sum of
two different Boolean products. the Boolean product xy z has
the value 1 iff x= y=1and z=0. Similarly, the product x y z
has the value 1 iff x=z=0 and y=1. The Boolean sum of these
two products xy z+x y z represents g.
Def.(4): A literal is a Boolean variable or its complement. A
minterm of the Boolean variables x1, x2 , …. , xn is the Boolean product y1 y2…. yn where x i= y i or y i=x i. Hence a minterm is a product of n
literals, with one literal for each variable.
Example (12):
Find a minterm that equals 1 if x1=x3=0
and x2=x4= x5=1, and equals 0 otherwise.
Solution:
The minterm x1 x2 x3.x4 x5 has the correct set of values.
Example (13):
Find the sum-of-products expansion of the function
f ( x , y , z )=(x+ y) z.
Solution:f ( x , y , z )=(x+ y) z
¿ x z+ y z distributive law¿ x1 z+1 y z identity law
112
X1+x2+..+xn
¿ x ( y+ y ) z+( x+ x ) y z unit property
¿ xy z+x y z+xy z+ x y z distributive law.¿ xy z+x y z+x y z idempotent laws.
4.5 Logic gates:
Introduction: Boolean algebra is used to model the circuitry
electronic devices. Each input and each output of each device can be
thought of as a member of the set {0 , 1 }. A computer, or other
electronic device, is made up of a number of circuits.
x
y
Inverter OR gate AND gate
X1
X2x
Xn
gates with n inputs
4.6 Combinations of Gates:
Example (14):
Construct circuits that produce the following out puts:
(a) (x+ y )x (b) x ( y+z ) (c) ( x+ y+z ) ( x y z )
Solution:
a)
113
4.7 Minimization of Circuits:
Example (15):
Minimize and construct the out put circuit xyz+x y z
Solution: xyz+x y z=( y+ y ) xz
¿1. xz
¿ xz
4.8 Karnaugh Maps:
To reduce the number of terms in a Boolean expression
representing a circuit, it is necessary to find terms to combine. There
is a graphical method, called a Karnaugh map or K-map for finding
terms to combine for Boolean functions involving a relatively small
number of variables.
Example (2): Find the K-maps for:
(a) xy+x y
(b) x y+x y
(c) x y+x y+x y
115
Solution:y y y y y y
x 11
x 1 x 1
x 1 x 1 x 1 1
(a) (b) (c)
Example (16): Simplify the sum-of-products expansion for
(a) xy+x y (b) x y+x y (c) x y+x y+x y
Solution : (a) xy+x y=( x+ x ) y=1. y= y
b) x y+x y=x y+ x y
c) x y+x y+x y=x y+x ( y+ y )
¿ x y+x .1
= x+ y
Example (17): Use the K-maps to minimize these sum-of-
products expansions
a) xy z+x y z+x yz+ x y z
b) x y z+x y z+ x yz+x y z+x y z
c) xyz+xy z+x y z+x y z+x yz+x y z+x y z
d) xy z+x y z+x y z+x y z
Solution:yz y z y z y z yz y z y z y z
x 1 1 x 1 1
x 1 1 x 1 1 1
(a) x z+ y z+ x yz (b) y+x z
116
x
y
y
x
y
y
x
x
z
yz y z y z y z yz y z y z y z
x 1 1 1 1 x 1 1
x 1 1 1 x 1 1
(c) x+ y+z (d) x z+x y
Exercises:
1 (Find the output of the given circuits:
a (
b(
c(
2 (Construct circuits from inverters, AND gates and OR gates to
produce these out puts.
)a (x+ y) b (( x+ y ) x) c (xyz+x y z) d (( x+z ) ( y+z )
117
3 (Draw a k–map for a function in two variables and put a 1 in the
cell representing x y
4 (Draw the k–maps of these sum-of-products expansions in two
variables:
)a (x y) b (xy+x y) c (xy+x y+x y+x y
118
Jedda
Mekka
Medina
Riadh
Hafoof
Demam
Hafralbatin
Chapter 5
An Introduction to Graph Theory
Def.(1): A graph G=(V ,E) consists of V , a nonempty set of vertices
(nodes) and E, a set of edges. Each edge has either one or two vertices
associated with it , called its endpoints. An edge is said to connect the end
points.
Remark: The set of vertices V of a graph G may be finite. A
graph with an infinite vertex set is called an infinite graph, and in
comparison, a graph with a finite vertex set is called a finite graph,
here we consider only finite graphs.
Now suppose that a network is made up of data centers and
communication links between computers. We can represent the
location of each data center by a point and each communication link
by a line segment as shown in the figure
This computer network can be modeled using a graph in which
the vertices of the graph represent the data centers and edges
represent communication links. A graph in which each edge
connects two different vertices and where no two edges connect the
same pair of vertices is called a simple graph.
119
GH
a f e
c db
e d
b ca
Def.(2): A directed graph (diagraph)(V , E )consists of nonempty
set of vertices V and a set of directed edges (or arcs) E, each directed
edge is associated with an ordered pair of vertices. The directed edge
associated with the ordered pair (u , v ) is said to start a u and end at v.
A graph with no loops and has no simple directed edges is called
a simple directed graph.
5 .1 Basic Terminology:
Def.(3):
Two vertices u and v in an undirected graph G are called
adjacent (neighbours) in G if u and v are endpoints of an edge of G.
If e is associated with {u , v } the edge e is called incident with the
vertices u and v. The edge e is also said to connect u and v. The
vertices u and v called end points of an edge associated with {u , v }.
Def.(4):
The degree of a vertex in an undirected graph is the number of
edges incident with it, except that a loop at a vertex contributes twice
to the degree of that vertex. The degree of the vertex v is denoted by
deg ( v ).
Example (1):
What are the degrees of the vertices in the graphs G and H in the
given figures
120
Crow
Owl Raccoon
Opossum Squirrel
Hawk
Wood pecker Shrew Mouse
Solution:
In G :deg (a ) = 2, deg (b ) = deg (c )= deg ( f )= 4 , deg (d ) = 1 and
deg (g ) = 0.
In H :deg (a ) = 4, deg (b ) = deg (e )= 6, deg (c ) = 1 and deg (d ) = 5.
A vertex of degree zero is called isolated, a vertex is pendant iff it
has degree one.
Example (2):
What does the degree of a vertex in a niche overlap graph
represents? Which vertices in this graph are pendant and which are
isolated in the given figure
Solution:
There is an edge between two vertices in a niche overlap graph
iff the two species represented by these vertices complete. Hence, the
degree of a vertex in a niche overlap graph is the number of species
in the ecosystem that complete with the species represented by this
vertex.
The degree of the vertex representing the squirrel is 4 because
the squirrel competes with four other species: the crow, the
opossum, the raccoon and the wood pecker. The mouse is the only
121
species represented by a pendant vertex. The vertex representing a
species is pendant if this species competes with only one other species.
There are no isolated vertices.
Theorem(1): (The handshaking theorem)
Let G=(V , E) be an undirected graph with e edges. Then
2e=∑v∈V
deg(v)
Example (3): How many edges are there in a graph with 10
vertices each of degree 6?
Solution: Because the sum of the degrees of the vertices is 6.10
= 60, it follows that 2e = 60 Þ e = 30.
Theorem(2): An undirected graph has an even number of
vertices of odd degrees.
5 .2 Some Special Simple Graphs:
Example (4): (Complete graphs) The complete graph on n
vertices, denoted by k n, is the simple graph that contains exactly one
edge between each pair of district vertices as shown in the figures:
. . .
k1 k2
k3 k4 k5 k6
Example (5): (cycles)
122
10
100
000 001
011
111110
101
010
00
10 11
01
The cycles Cn , n≥ 3, consists of n vertices v1 , v2 …,vn and edges
{v1, v2 } , {v2, v3 }…, {vn−1 , vn }∧{vn , v1 } .The cycles C3 , C4 ,C5 ,∧C6 ,are displayed
in the figure:
c3 c4 c5 c6
Example (6): (wheels) We obtain the wheel W nwhen we add
additional vertex to the cycle cn for n≥ 3 and connect this new vertex to
each of n vertices in cn, by new edges th wheels W 3 ,W 4 , W 5 ,W 6 , are
displayed in the figure:
W 3 W 4 W 5 W 6
Example (7): (n-cubes)
The n-dimentional hypercuble or n-cube, denoted by Qn is the
graph that has vertices representing the 2n bit strings of length n.
G1
G2
G3
5.3 Bipartite graphs:
123
Def.(5): A simple graph G is called bipartite if its vertex set V
can be partitioned into two disjoint sets V 1 and V 2 such that every
edge in the graph connects a vertex in V 1 and a vertex in V 2. When
this condition holds, we call the pair (V 1 ,V 2) a bipartition of the vertex
set V of G.
In example (3) c6 is a bipartite.
Example (8):
c6 in the given figure is
bipartite because its vertex
set can be partitioned into
the two sets V 1= {v1 , v3 , v5 } and V 2= {v2 , v4 , v6 } and every edge
of c6 connects a vertex in V 1
and a vertex in V 2.
Theorem(3):
In every graph , the number of nodes with odd degree is even .
Proof: We start with a graph with no edges in which every degree is 0
And so the number of nodes with odd degree is 0 , which is an even
number.
(1) If we connect two nodes by a new edge , we change the parity of
the degrees at these nodes . In particular, if both endpoints of
the new edge have even degree , we increase the number of
nodes with odd degree by 2 .
(2) If both endpoints of the new edge had odd degree , we decrease
the number of nodes with odd degree by 2. ,124
e
c
d
b
a
(3) If one endpoint of the new edge had even degree and the other
had odd degree.
Thus if the number of nodes with odd degree was even before
adding the new edge, it remained even after this step .This proves
the theorem.
Theorem (4): (a) A graph G is a tree if and only if it is connected , but
deleting any of its edges , results in a disconnected graph .
(b) A graph G is a tree if and only if it contains no cycle , but
adding any new edge creates a cycle.
Theorem (5): Every tree on n nodes has n-1 edge.
5. 4 Representing Graphs and Graph Isomorphism:
Representing Graphs ; One way to represent a graph without
multiple edges is to list all the edges of this graph. Another way to
represent a graph with no multiple edges is to use adjacency lists,
which specify the vertices that are adjacent to each vertex of the
graph.
Table ( 1)An adjacency list
for a simple graph
125
vertex Adjacency
vertices
a
b
c
d
e
b, c, e
a
a, d, c
c, e
a, c, d
a
b
c
de
Example (9):
Use adjacency lists to describe the simple graph given in the
above figure.
Solution: Table 1 lists those vertices adjacent to each of the
vertices of the graph.
Example (10): Represent the directed graph shown in figure (2)
by listing all the vertices that are the terminal vertices of edges
starting at each vertex of the graph
directed graph
Figure (2)
Solution: Table (2) represent the directed graph shown in figure
(2) above.
126
Initial vertex Terminal
vertices
a
b
c
d
e
b, c, d, e
b, d
a, c, e b, c, d
5.5 Adjacency Matrices:
The adjacency matrix A of G with respect to the listing of
vertices, is the n × n zero-one matrix with 1 as its (i , j)th entry when vi
and v j are adjacent, and 0 as its (i , j)thentry when they are not
adjacent A=[aij ] , then a ij={10 if {v i , v j } is edge of G otherwise
Example (11): Use an adjacency matrix to represent the graph
shown in the figure :
a b
c d
Solution:
We order the vertices as a, b, c, d. The matrix representing this
graph is[ ]
Example (12):
Draw the graph with this adjacency matrix[ ]
with respect to the ordering of vertices a, b, c, d.
a b
c d
Figure (4)
127
a
d
b
c
Example (13):
Use an adjacency matrix to represent the pseudograph shown in
figure (5)
Figure (5)
A Pseudograph
Solution:
The adjacency matrix using the ordering of vertices a, b, c, d is
[ ]
5.6 Incidence Matrices:
Another common way to represent graphs is to use incidence
matrices. Let G= (V , E ) be an undirected graph. Suppose that v1 , v2 ,…,vn are vertices and e1 ,e2 ,…,em are the edges of G. Then the
incidence matrix with respect to this ordering of V and E is the n × m
matrix M=[mij ], where
mij=¿ {1 whenedge e j is incident with v i
0 otherwise
Example (14):
Represent the graph shown in figure 6 with an incidence matrix.
Solution:
The incidence matrix is:
e1 e2 e3 e4 e5 e6
128
v1 v2
e1 e3
e2 e4 v3
v5
e5e6
e7
v4e8
G
[1 1 00 0 10 0 0
0 0 01 0 10 1 1
1 0 10 1 0
0 0 01 1 0
]Figure 7
A Pseudo graph
Example (15):
Represent the pseudo graph shown in the figure using incidence
matrix
e1 e2 e3 e4 e5 e6 e7 e8
[1 1 10 1 10 0 0
0 0 01 0 11 1 0
010
000
0 0 00 0 0
0 0 00 1 1
10
10]
A Pseudograph
5.7 Isomorphism of Graphs:
Def.(6): The simple graphs G1=(V 1 , E1 ) and G2=(V 2, E2 ) are
isomorphic if there is a one-to-one and onto function from V 1 to V 2
with the property that a and b are adjacent in G1 iff f (a) and f (b) are
adjacent in G2 ∀a ,b∈V 1. such function f is called isomorphism.
Example (16):
Show that the graphs G= (V , E ) and H= (W , F ), displayed in figure
8, are isomorphic.
129
G H
a b c
f e . d
a b
e d c
a . db c
Solution:
The function f with f (u1 )=v1 , f (u2)=v 4 , f (u3)=v3 , f (u4 )=v2 is one-to-
one correspondence between V and W. To see that this
correspondence presents adjacency, note that adjacent vertices in G
are u1 and u2, u1 and u3 , u2 and u4, and u3 and u4, and each of the pairs f (u1 )=v1 and f (u2 )=v4, f (u1 )=v1 and f (u3 )=v3, f (u2 )=v4 and f (u4 )=v2 and f (u3 )=v3 and f (u4 )=v2 are adjacent in H .
Example (17):
Show that the graphs displayed in the figure are not
isomorphic.
Solution:
Both G and H have five vertices and six edges. However, H has
a vertex of degree one, namely e, whereas G has no vertices of degree
one. It follows that G and H are not isomorphic.
Exercises:
In exercise 1 – 3 find the number of vertices, the number of edges,
and the degree of each vertex in the given undirected graph
1 (2(
130
ac
d
b
e
a
c d
b
a
c d
ba c
d
b
e
3 (
4 (Draw these graphs:
)a (K 7) b (K1,8) c (K4,4
)d (C7) e (W 7) f (Q4
5 (In Exercises 1 – 4 use an adjacency list to the given graph
1 (2(
3 (4(
6 (Draw a graph with the given adjacency matrices
131
a) [0 1 01 0 10 1 0 ] (b) [0 0
0 01 11 0
1 11 1
0 11 0]
5.8.1 Paths: A path is a sequence of edges that begins at a vertex
of a graph and travels from vertex to vertex along edges of the graph.
Def. (7): Let n be a nonnegative integer and G an undirected
graph. A path of length n from u to v in G is a sequence of n edges e1 ,e2 ,…,en of G such that e1 is associated with {x0 , x1 }, e2 is associated
with {x1 , x2 } and so on, with en associated with {xn−1 , xn } where x0=u and xn=v. When the graph is simple we denote this path by its vertex
sequence x0 , x1 , …, xn. The path is a circuit if it begins and end at the
same vertex, that is, if u = v, and has length greater than zero. The
path or circuit is said to pass through the vertices x1 , x2 ,…, xn−1 or
traverse the edges e1 ,e2 ,…,en. A path or circuit is simple if it does not
contain the same edge more than once.
Example (18):
In the simple graph in the figure
a b c
d e f
Simple graph
132
a b
e
fd
c
a b
f d
e
c
a, d, c, e, f is a simple path of length 4, because {a , d }, {d , c }, {c , f }
and { f ,e } are all edges.
However, d, e, c, a is not a path, because {e , c } is not an edge. Note
that b, c, f, e, b is a circuit of length 4 because {b , c }, {c , f }, { f ,e } and {e ,b }
are edges, and this path begins and ends at b. The path a, b, e, d, a, b
which is of length 5, is not simple because it contains the edge {a , b }
twice.
5.8.2 Connectedness in Undirected Graphs:
Def. (8): An undirected graph is called connected if there is a
path between every pair of distinct vertices of the graph.
Thus, any two computers in the network can communicate iff
the graph of this network is connected.
Example (19):
The graph G1 in the given figure:
133
d eb
a c
e g
f
is connected, because for every pair of d distinct vertices there is a
path between them. However, the graph G2 in the figure is not
connected. There is no path in G2 between vertices a and d.
Theorem (3):
There is a simple path between every pair of distinct vertices of
a connected undirected graph.
A connected component of a graph G is a connected subgraph of
G that is not proper subgraph of another connected subgraph of G.
That is, a connected component of a graph G is a maximal connected
subgraph of G. a graph G that is not connected has two or more
connected components that are disjoint and have G as their union.
Example (20):
What are the connected components of the graph H shown in the
figure:
134
h
a b
c
e G d
a b
c
e dH
The connected components H 1 , H 2 and H 3
Solution:
The graph H is the union of three disjoint connected subgraphs H 1 ,H 2 and H 3. These three subgraphs are the connected components
of H.
5.8.3 Connectedness in directed graphs:
Def. (9): A directed graph is strongly connected if there is a
path from a to b and from b to a whenever a and b are vertices in the
graph.
Def. (10): A directed graph is weakly connected if there is a
path between every two vertices in the underlying undirected graph.
That is, a directed graph is weakly connected iff there is always
a path between two vertices when the directions of the edges are
disregarded. Any strongly connected directed graph is also weakly
connected.
Example (21):
Are the directed graphs G and H shown in the figure:
The directed graphs G and H.
Strongly connected?. Are they weakly connected?
135
a b
cd
Solution:
G is strongly connected because there is a path between any two
vertices in this directed graph (verify). Hence, G is also weakly
connected. The graph H is not strongly connected. There is no
directed path from a to b in this graph. However, H is weakly
connected, because there is a path between any two vertices in the
underlying undirected graph of H (verify).
5.8.4 Counting paths between vertices:
The number of paths between two vertices in a graph can be
determined using its adjacency matrix.
Example (22):
Let G be a graph with adjacency matrix A with respect to the
ordering v1 , v2 ,…, vn (with directed or undirected edges, with multiple
edges and loops allowed). The number of different paths of length r
from vi to v j, where r is a positive integer, equals the (i, j)th entry of Ar.
Example (23):
How many paths of length 4 are there from a to d in the simple
graph G in the figure
Figure
Solution:
The adjacency matrix of G (ordering the vertices as a, b, c, d) is
136
a b
d c
e
d c
ba
e
ba
d ce
A=[ ]
Hence, the number of paths of length 4 from a to d is the (1,4)th
entry of A4.
A4=[]
Because there are exactly eight paths of length 4 from a to d. By
inspection of the graph, we see that a, b, a, b, d; a, b, a, c, d; a, b, d, b,
d; a, b, d, c, d; a, c, a, c, d; a, c, d, b, d; and a, c, d, c, d are the eight
paths from a to d.
5.9 .1 Eulr and Hamilton Paths:
Def. (11): An Euler circuit in a graph G a simple circuit
containing every edge of G. An Euler path in G is a simple path
containing every edge of G.
Example(24):Which of the undirected graphs in the figure have
an Euler circuit? Of those that do not, which have an Euler path?
137
f
a
b
de
a b
d c
Solution: The graph G1 has an Euler circuit, for example, a, e, c,
d, e, b, a. Neither of the graphs G2 or G3 has an Euler circuit
(verify). However, G3 has an Euler path, namely, a, c, d, e, b, d, a, b. G2 does not have an Euler path (verify).
Example (25): Which of the directed graphs in the figure have
an Euler circuit? Of those that do not, which have an Euler path?
Solution: The graph H2 has an Euler circuit, for example, a, g, c,
b, g, e, d, f, a. Neither H1 nor H3 has an Euler circuit (verify). H3 has
an Euler path namely, c, a, b, c, d, b, but H1 does not (verify)
5.9.2 Hamilton Paths and Circuits:
Def.(12): A simple path in a graph G that passes through every
vertex exactly once is called a Hamilton path, and a simple circuit in
a graph G that passes through every vertex exactly once is called a
Hamilton circuit. That is, the simple path x0 , x1 , …, xn in the graph
138
c d
ba
a b a b a b
e c d c d c e f
d
a
b
Gc
d ea
eb H
c
d
G= (V , E ) is a Hamilton path if V= {x0 , x1, …, xn } and x i≠ x j for 0≤ i< j≤ n,
and the simple circuitx0 , x1 ,…, xn , (n>0 ) is a Hamilton circuit if x0 , x1 , …, xn is
a Hamilton path.
Example (26): Which of the simple graphs in the figure have a
Hamilton circuit or, if not, a Hamilton path?
Simple graphs
Solution:G1 has a Hamilton circuit a, b, c, d, e, a. There is no
Hamilton circuit in G2 (this can be seen by noting that any circuit
containing every vertex must contain the edge {a , b } twice), but G2does
have a Hamilton path, namely, a, b, c, d. G3has neither a Hamilton
circuit nor a Hamilton path, because any path containing all vertices
must contain one of the edges {a ,b }, {e , f } and {c , d } more than once.
Example (27): Show that neither graph displayed in the given
figure has a Hamilton circuit.
Solution: There is no Hamilton circuit in G because G has a
vertex of degree one, namely, e. Now consider H. Because the
degrees of vertices a, b, d and e are all two, every edge incident with
these vertices must be part of any Hamilton circuit. It is now easy to
139
see that no Hamilton circuit can exist in H, for any Hamilton circuit
would have to contain four edges incident with c, which is impossible.
Theorem (4): (Dirac’s Theorem) If G is a simple graph with n
vertices with n ≥ 3 such that the degree of every vertex in G is at least n /¿2¿, then G has a Hamilton circuit.
Theorem (5): (Ore’s Theorem) If G is a simple graph with n
vertices with n≥ 3 such that deg(u) + deg(v) n for every pair of
nonadjacent vertices u and v in G, then G has a Hamilton circuit.
5.10 Planar Graphs:
Def. (13):
A graph is called planar if it can be drawn in the plane without
any edges crossing (where a crossing of edges is the intersection of the
lines or arcs representing them at a point other than their common
endpoint). Such a drawing is called a planar representation of the
graph.
A graph may be planar even if it is usually drawn with
crossings, because it may be possible to draw it in a different way
without crossings.
Example (28):
Is K4 (shown in the given figure with two edges crossing)
planar?
K4 K4
140
drawn with no crossings.
Solution: K4 is planar because it can be drawn without crossings.
Example (29): Is Q3, shown in the given figure, planar?
Q3 Aplanar
representing of Q3
Solution:
Q3 is planar, because it can be drawn without any edges
crossing.
Theorem(6):
(Euler’s Formula): Let G be a connected planar simple graph
with e edges and v vertices. Let r be the number of regions in a
planar representation of G. Then r = e – v + 2.
Example (30):
Suppose that a connected planar simple graph has 20 vertices,
each of degree 3. Into how many regions does a representation of
this planar graph split the plane?
Solution:
This graph has 20 vertices, each of degree 3, so v = 20. Because
of the sum of the degrees of the vertices, 3v = 3.20 = 60, is equal to
twice the number of edges, 2e we have 2e = 60 Þ e = 30.
Consequently, from Euler’s formula, the number of regions is:
r = e – v + 2 = 30 – 20 + 2 = 12.
Corollary (1):
141
If G is a connected planar simple graph with e edges and v
vertices, where v≥ 3, then e≤ 3v−6.
Corollary (2):
If G is a connected planar simple graph, then G has a vertex of
degree not exceeding five.
Example (31):
Show that K5 is nonplanar using corollary (1)
Solution:
The graph K5 has vertices and 10 edges. However, the
inequality e≤ 3v−6 is not satisfied for this graph because e = 10 and
3v−6=9(10 ≤ 9). Therefore, K5 is not planar.
Corollary (3):
If a connected planar simple graph has e edges and v vertices
with v≥ 3 and no circuits of length 3 , then e≤ 2 v−4
Example (32):
Use corollary( 3) to show that K3.3 is nonplanar.
Solution:
Because K3.3 has no circuits of length 3 (this is easy to see
because it is bipartite), corollary (3) can be used. K3.3 has 6 vertices
and 9 edges. Because e=9 and 2v-4 = 8
K3.3 is non planar.
Exercises:
142
a
e
d
c
b
a
b
c f
e
d
1) Does each of these lists of vertices form a path in the following
graphs? Which paths are simple? Which are circuits? What
are the lengths of those that are paths?
)a (a, e, b, c, b (b) a, e, a, d, b, c, a
)c (e, b, a, d, b, e (d) c, b, d, a, e, c
2) Determine whether the given graph is connected
3) Determine whether the given graph has an Euler circuit.
construct such a circuit when one exists. If no Euler circuit
exists, determine whether the graph has an Euler path and
construct such a path if one exists.
4) Does the graph have a Hamilton path? If so find, such a path.
If it doesnot, give an argument to show why no such path exists
143
Chapter 6
Counting6.1 Basic Counting Principles:
We will present two basic counting principles, the product rule
and the sum rule.
The Production Rule: The product rule applies when a
procedure is made up to separate tasks.
Example (1)
There are 32 microcomputers in a computer centre. Each
microcomputer has 24 parts. How many different parts to a
microcomputer in the center are there?
Solution:
Because there are 32 ways to choose the microcomputer and 24
ways to choose the part no matter which microcomputer has been
selected, the product rule shows that there are 32*24 = 768 parts.
Example (2)
How many functions are there from a set with m elements to a
set with n elements?
Solution:
A function corresponds to a choice of one of the n elements in
the codomain for each of the m elements in the domain. Hence by
the product rule there are n.n. ….. n = nm functions
From a set with m elements to one with n elements.
6.2 The Sum Rule:
If a task can be done either in one of n1 ways or in one of n2
ways, where none of the set of n1 ways is the same as any of the set of
n2 ways, there are n1 + n2 ways to do the task.
144
Example (3):
Suppose that either a member of the mathematics faculty or a
student who is a mathematics major is chosen as a representive to a
university committee. How many different choices are there for this
representive if there are 37 members of the mathematics faculty and
83 mathematics majors and no one is both a faculty member and a
student?
Solution:
There are 37 ways to choose a member of the mathematics
faculty and there are 83 ways to choose a student who is mathematics
major. Choosing a member of the mathematics faculty is never the
same as choosing a student who is a mathematics major because no
one is both a faculty member and a student. By the sum rule it
follows that there are 37 + 83 = 120 possible ways to pick this
representive.
Example (4):
A student can choose a computer project from one of three lists.
The three lists contain 23, 15 and 19 possible projects respectively.
No project is on more than one list. How many possible projects are
there to choose from?
Solution:
The student can choose a project by selecting a project from the
first list, the second list, or the third list. Because no project on more
than one list, by the sum rule there are 23 + 15 + 19 = 57 ways to
choose a project.
Exercises:
1) How many +ve integers between 50 and 1000
(a)are divisible by 7? Which integers are these?
145
(b)are divisible by 11? Which integers are there?
(c) are divisible by both 7 and 11? Which integers
2) How many +ve integers less than 1000 are there?
(a) are divisible by 7?
(b)are divisible by 7 but not by 11?
(c) are divisible by both 7 and 11?
3) How many +ve integers between 100 and 999
(a) are divisible by 7?
(b) are odd?
(c) Have the same three decimal digits?
(d)Are not divisible by 4?
(e) Are divisible by 3 or 4.
6.3 The Pigeonhole Principle:
Theorem(1):
If k is a positive integer and k+1 or more objects are placed into
k boxes, then there is at least one box containing two or more of the
objects.
Proof:
We will prove the pigeonhole principle using a proof by
contraposition.
Suppose that none of the k boxes contains more than one object.
Then the total number of objects would be at most k. this
contradiction, because there are at least k+1 objects.
Example (5):
Among any group of 367 people, there must be at least two with
the same birthday, because there are only 366 possible birthdays.
146
Example (6):
In any group of 27 English words, there must be at least two that
begin, with the same letter, because there are 26 letters in the English
alphabet.
Example (7):
How many students must be in a class to guarantee that at least
two students receive the same score on the final exam, if the exam
graded in a scale from 0 to 100 points.
Solution:
There are 101 possible scores on the final. The pigeonhole
principle show that among any 102 students there must be at least 2
students with same score.
6. 4. Sequences and Summations:
6.4.1. Sequences:
A sequence is a discrete structure used to represent an ordered
list . For example ,1,2,3,5,8 is a sequence with five terms and
1,3 9,27,81,…is an infinite sequence .
Def.(1): A Sequence is a function from a subset of integers (usually
either the set {0,1,2,…} or the set {1,2,3,…}to the set S. We use the
notation an to denote the image of the integer n . We call an a term of
the sequence .
Example(1):
Consider the sequence {an } ,where an =1n
The list of the terms of this sequence ,beginning with an ,namely ,a1 , a2 ,a3 , …
Def.(2): A geometric progression is a sequence of the form
a , ar , ar2 , a r3 , …,ar n ,…
Where the initial term a and the common ratio r are real numbers.147
Example (2):
The sequence {bn } with bn = (-1¿n ,{cn }with
cn=2. 5n and {dn } with dn = 6 . (13¿n are geometric progressions with
initial term and common ratio equal to 1 and -1 ; 2and 5 ; and 6 and 13 , respectively , if we start at n=0 . The list of terms
b0 , b1 ,b3 , b4 ,…. begins with 1,-1, 1 ,-1 ,1,…;
The list of terms c0 , c1, c2 ,c3 , …begins with 2, 10, 50, 250, 1250, …;
And the list of terms d0 , d1 , d2 , d3 , …begins with
6, 2, 23 ,2
9 , 227 ,…
Def.(3): An arithmetic progressions is a sequence of the form : a , a+d , a+2d , a+3d , …, a+nd , …
Where the initial term a and the common difference d are real
numbers.
Example(3):
The sequence {sn } with sn = -1+4n and {t n } with t n =7-3n are both arithmetic progressions with initial terms and
common differences equal to -1 and 4 ,and 7 and -3, respectively, if
we start at n=0 . The list of terms s0 , s1 , s2 , s3 , … begins with
-1,3,7,11,…
And the list of terms t 0 ,t 1 , t 2 , t 3 , … begins with 7 ,4 ,1 ,-2,…
Example(4):
Find formula for the sequences with the following first five terms: (a)
1, 12 , 1
4 , 18 , 1
16 (b) 1 ,3 ,5 ,7 ,9 (c) 1 ,-1 , 1 ,-1 ,1.
148
Solution:
(a) We recognize that the denominators are powers of 2.
The sequence with s0 = 12n , n = 0 ,1 ,2 , … is a possible match . The
proposed sequence is a geometric progression with a=1∧r=¿ 12
(b)We note that each term is obtained by adding 2 to the
previous term . The sequence with an = 2n +1 , n= 0 ,1, 2 ,… is a
possible match . This proposed sequence is an arithmetic
progression with a=1∧d=2.
(c) The terms alternate between 1 and -1 . The sequence with an = (-1¿n ,n= 0 ,1, 2 ,… is possible match . This proposed
sequence is a geometric progression with a=1∧r=−1.
Some Useful Sequences
nth Term First 10 Terms
n2 1, 4 , 9 , 16 , 49 , 64 , 81 , 100 ,…
n3 1 , 8 ,27 , 64 , 125 , 216 , 343 , 512 , 729 , 100 ,…
n4 1 , 16 , 81 , 256 , 625 , 1296 , 2401 , 4096 , 6561 , 10000,…
2n 2, 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024,…
3n 3 , 9 , 27 , 81 , 243 , 729 , 2187 , 6561 , 19683, 59049,…
n! 1 , 2 , 6 , 24 , 120 , 720 , 5040 , 40320 , 362880, 3628800,…
6.4.2 Summations:
The sum of terms : am , am+1 , am+2 , , am+3 , …, an form the sequence {an }.
We use the notation :∑j=m
n
a j ,∨∑i ≤ j ≤ n
a j
to represent:
149
am+am+1+am+2 ,+am+3+…+an . The variable j is called the index of
summation , and the choice of the letter j as the variable is arbitrary ;
that is , we could have used any other letter ,such as I or k, in
notation ∑j=m
n
a j=∑i=m
n
a i=∑k=m
n
ak
Here , the index of summation runs through all integers starting with
lower limit m and ending with its upper limit n.
Example(1):
Express the sum of the first 100 terms of the sequence {an },
where an = 1n , for n = 1 ,2 , 3, …
Solution:
The lower limit for the index of summation is 1 , and the
upper limit is 100 .We write the sum as: ∑j=1
100 1j .
Example(2):
What is the value of : ∑j=1
5
j2 ?
Solution: ∑j=1
5
j2 = 12+22+32+42+52= 1+4+9+16+25 =55.
Example (3):
What is the value of : ∑k=4
8
¿¿ ?
Solution : ∑k=4
8
¿¿= ¿
= 1+(-1 )+1+(-1)+ 1
= 1.
Example (4):
Suppose we have the sum : ∑j=1
5
j2
150
But we want the index of summation to run from 0 and 4 rather
than 1 to 5 . To do this ,we let k= j-1 . Then the new summation
index runs from 0 to 4 , and the term j2 becomes ¿ .
Hence ,
∑j=1
5
j2 = ∑k=0
4
¿¿ .
It is easily checked that both sums are 1+4+9+16+25 = 55.
Theorem(1): (Formula for the sum of terms of geometric progression).
∑j=0
n
a r j={arn+1−ar−1
,if r≠ 1
(n+1 )a ,if r=1
Example(5):(Double summations)
∑i=1
4
∑j=1
3
i j .
To evaluate the double sum, first expand the inner summation and
then continue by computing the outer summation :
∑i=1
4
∑j=1
3
i j=∑i=1
4
(i+2 i+3i )=∑i=1
4
6 i=6+12+18+24=60 .
Exercises:
1) What are the terms a0, a1 , a2 ,∧¿ a3 of the sequence { an}
Where an equals :
(a) 2n+1?
(b) (n +1¿n+1?
(c) ⌊ n2⌋ ?
(d) ⌊ n2⌋ + ⌈ n
2⌉ ?
2) What are the terms a0, a1 , a2 , and a3 of the sequence :
{ an} Where an equals :
(a) (-2¿n ? (b) 3 ? (c) 7 + 4n ? (d) 2n+¿
151
3) List the first 10 terms of each of these sequences :
(a) The sequence that begins with 2 and in which each
successive term is 3 more than preceding term.
(b) The sequence that lists each positive integer three times ,
in increesing order .
(c) The sequence that lists the odd positive integers in
increasing order , listing each odd integer twice .
(d) The sequenc whose nth term is n !−2n .
4) List the first 10 terms of these sequences :
(a) The sequence obtained by starting with 10 and obtaining
each term by subtracting 3 from the previous term.
(b) the sequence whose nth term is the sum of the first n positive
integers .
(c) The sequence whose nth term is 3n−2n .
(d) The sequence whose terms are constructed sequentially as
follows : start with 1 , then add 1 , then multiply 1 , then add 2 ,
then multiply by 2 , and so on.
5) What are the values of these sums :
(a)∑k=1
5
(k+1) (b) ∑j=0
4
¿¿ (c) ∑i=1
10
3
(d)∑j=0
8
(2 j+1−2 j)
6) Compute each of these double sums:
(a) ∑i=1
2
∑j=1
3
(i+ j) (b)∑i=0
2
∑j=0
3
(2 i+3 j)
152
(c)∑i=1
3
∑j=0
2
i ∑i=0
2
∑j=1
3
ij
6. 5. Discrete Probability:
6.5.1: Random variables and sample spaces:
Def.(1):
Suppose we have an experiment whose outcome depends on
chance .We represent the outcome of the experiment by a capital
letter ,such that as X called a random variable . The sample space of
the experiment is the set of all possible outcomes . If the sample
space is either finite or countable infinite , the random variable is
called discrete .
We generally denote a sample space by the capital Greek letter Ω .
Example(1):
A die is rolled once , let X denote the out come of this
experiment is the 6- element set , Ω = { 1 , 2 , 3 , 4 , 5 , 6 } where
each outcome i , for i = 1 , … ,6 correspond to the number of dots
on the face which turns up . The event E = { 2 ,4 , 6 }corresponds to
the statement that the result is an even number . The event E can
also be described by saying that X is even . Unless there is
reason to believe the die is loaded , the natural assumption is
that every outcome is equally likely . A dopting this convention
153
means that we assign a probability of 16 to each of the outcomes,
i. e , m(i) = 16 for 1≤ i≤ 6.
Example (2):
Consider an experiment in which a coin is tossed twice .
Let X be the random variable which corresponds to theis
experiment . We note that there are several ways to record the
outcomes of this experiment . We could , for example record the
two tosses , in the order in which they occurred . In this case ,
we have
Ω = { HH , HT , TH , TT }. We also could record the outcomes by
simply noting the number of heads that appeard. In this case ,
we have Ω = { 0 , 1 , 2 }. Finally , we could record the two
outcomes , outcomes , without regard to the order in which they
occurred . In this case , we have Ω = { HH , HT , TT }.
We will use , for the moment , the first of the sample spaces
given above , we will assume that all four outcomes are
generally likely , and define the distribution function m( w ¿ by :
m(HH) = m(HT) = m(TH) = m(TT) = 14
Let E = { HH , HT, TH } be the event that at least one head
comes up .. Then , the probability of E can be calculated as
follows:
P(E) = m(HH) + m(HT) +m(TH) = 14 +1
4 + 14 = 3
4
154
Similarly , if F = { HH , HT } is the event that heads comes up
on the first toss , then we have :
P(F) = m(HH) + m(HT) = 14 + 1
4 = 12
Example (3):
Three people A, B and C , are running for the office ,
and we assume that one and only one of them wins . The sa
sample space may be taken as the 3- element set Ω= { A , B , C}.
Where each element corresponds to the outcome of that
candidates winning , suppose that A and B have the same
chance of winning , but C has only 12 the chance of A and B .
Then we assign :
m(A) = m(B) =2 m( C)
since m(A) + m(B)+m(C)= 1, we see that 5m(C) =1 .
Hence m(A) = 25 , m(B) = 2
5 , m(C) = 15 .
Let E be the event that either A or C wins , then E = { A ,C }
and P(E) = m(A) + m(C) = 25 +1
5 = 35 .
Theorem(1) :
The probabilities assigned to events by a distribution
function on a sample space Ω satisfy the following properties :
(1) 0 ≤ P (E )≤ 1 ,∀ E⊂Ω .
(2)P(Ω ¿=1.
(3) If E ⊆F⊆Ω , then P(E) ≤ P(F) .155
(4) If A and B are disjoint subsets of Ω , then
P(A∪B ¿ = P(A) + P(B).
(5)P(A) = 1 – P(A) , ∀ A⊂Ω .
Theorem(2):
If A1 , A2 , A3 ,…, An are pairwise disjoint subsets of Ω ,
then P( A1∪A2∪ A3∪…∪ An¿ = ∑i=1
n
P(A i).
Theorem(3):
Let A1 , A2 , A3 , …, An be pairwise disjoint events with Ω = A1∪A2∪ A3∪…∪ An and let E be any event . Then
P(E) = ∑i=1
n
P(E∩ A i).
Corrllary:
For any two event A and B
P(A) = P(A ∩ B ¿ + P(A ∩ B ¿ .
Theorem(4):
If A and B are subsets of Ω , then
P( A∪B ¿ = P(A) + P(B) – P(A ∩ B ¿ .
Exercises:
156
1) Let Ω = { a , b , c } be a sample space , let m(a) = 12 , m(b) = 1
3
and m(c) = 16 . Find the probabilities of all eight subsets of Ω .
2) Describe in words the events specified by the following subsets
of Ω = { HHH , HHT , HTH , HTT, THH , THT, TTH , TTT }
a) E = { HHH , HHT , HTH , HTT}.
b) E = { HHH, TTT}.
c) E = { HHT, HTH , THH}.
d) E = { HHT, HTH , HTT, THH, THT ,TTH}.
3) What are the probabilities of the events described in
exercise (2)?
4) Let A and B be events such that P(A ∩ B ¿ = 14 , P(A) = 1
3
and P(B) = 12 .What is P( A∪B ¿ ?
6.6 Permutations and Combinations:
6.6.1 Permutations:
Example (8):
In how many ways can we select three students from a group of
five students to stand in line for a picture?
Solution:
There are 5 ways to select the first student to stand at the start
of the line there are 4 ways to select the 2nd student there are 3 ways
to select the 3rd student in the line. Hence there are 5 – 4 – 3 = 50
157
ways to select three students from a group of 5 students to stand for a
picture.
Example (9):
Let S = {1, 2, 3}. There ordered arrangement 3,1,2 is a
permutation of S. The ordered arrangement 3,2 is a 2 – permutation
of S.
The number of r-permutations of a set with n elements is
denoted by P(n,r).
Theorem(2):
If n and r are integers with 0 ≤ r≤ then P (n , r )= n !(n−r )!
Example (10):
How many ways are there to select a first-prize winner, a
second-prize winner, and a third-prize winner from 100 different
people who have entered a contest?
Solution :
The number of 3-permutations of a set of 100 elements.
P (100,3 )= 100 !(100−3 ) !
=100 !97 !
¿100.99.99 .98 .97 !
97 !=970200
Example (11):
Suppose that there are eight runners in a race. The winner
receives a gold medal, the second-place finisher receives a silver
medal, and the third-place finisher receives a bronze medal. How
many different ways are there to a word these medals, if all possible
outcomes of the race can occur and there are no ties?
Solution:
158
The number of different ways to a word the medals is the
number of 3-penmutations of a set with 8 elements. Hence there are
P (8,3 )=8 !5 ! = 336 possible ways to a ward the medals.
6.6.2 Combinations:
Def .(1): The number of r-combinations of a set with n distinct
elements is denoted by C (n , r )=(nr ).Example (12): c(4,2) = 4!
Theorem (3):
The number of r-combinations of a set with n elements, where n
is a nonnegative integer and r is an integer 0 ≤ r≤ n equals
C (n , r )= n!r ! (n−r ) !
Proof :
P (n , r )= n !r ! (n−r )!
Þ C (n , r )= P(n, r )P (r−r )
= n ! (n−r )!r ! / (r−r )!
= n!r ! (n−r )!
Example (13):
How many poker hands of five cards can be dealt from a
standard deck of 52 cards? Also, How many ways are there to select
37 cards from a standard deck of 52 cards?
Solution:
The order in which the 5 cards are dealt from a deck of 52 cards
does not matter, are
1) C (52,5 )= 52!5 ! .47 !
=52.51 .50.49 .48 .47 !5.4 .3 .2.1 .47 !
=2598960
2) C (52,47 )= 52 !47 ! .5 !
=¿2598960
159
Corollary(1): Let n and r be nonnegative integers r ≤ n. Then c (n , r )=c (n, n−r )
Proof: From theorem (2) it follows that
c (n , r )= n!r !(n−r )
and c (n , n−r )= n!(n−r ! ) (n−(n−r ) ) !
= n!(n−r )! . r !
Hence, c (n , r )=c (n, n−r )
Example (14):
How many ways are there to select 5 players from a 10-member
tennis team to make a trip to match at another school?
Solution:
By theorem (2)
c (10,5 )= 10 !5 !5!
=252
6.6.3 The Binomial Theorem:
The expansion of ( x+ y )3=( x+ y ) (x+ y ) ( x+ y )
¿ x3+ x2 y+x2 y+x y2+ y x2+x y2+ x y2+ y3
¿ x3+3 x2 y+3 x y2+ y3
Theorem (4): (The Binomial Theorem)
Let x and y be variables, and let n be a non negative integer.
Then
( x+ y )n=∑j=0
n
(nj)xn− j y j=(n0)xn+(n1)xn−1 y+(n2) xn−2 y2+…+(nn) yn
Proof:
Using the mathematical induction form:
Let p(n)= ( x+ y )n , p (n )=∑j=0
n
(nj ) xn− j y j
Basic step:
1) Let n = 1, p(1) = ( x+ y )1=x+ y
p(1) is true.160
2) Assume that p (m )=( x+ y )m=∑j−0
m
(mj ) xm− j y j is true
3) The inductive step p (m )→ p (m+1)
p (m+1 )=( x+ y )m+1=(x+ y) ( x+ y )m
¿(x+ y )∑j=0
m
(mj )xm− j y j
¿∑j=0
m
(mj ) xm−k+1 y j+∑j=0
m
(mj ) xm− j y j+1
¿(m0 ) xm+1∑j=1
m
(mj )xm−1+ j y j+∑j=1
m−1
(mj ) xm− j y j+1+(mm) ym+1
¿ xm+1∑j=1
m
(mj ) xm+1− j y j+∑j=1
m
( mj−1) xm+1− j y j+ ym+1
¿ xm+1∑j=1
m
[(mj )∗( mj−1)] xm+1− j y j+ ym+1
¿(m+1o ) xm+1+∑
j=1
m
(m+1j ) xm+1− j+(m+1
m+1) ym+1
¿∑j=0
m+1
(m+1j )xm+1− j y j
Hence p(m+1) is true
P(n) is true, ∀n∈Ν
Example (15): What is the expansion of (x+y)4?
Solution: From the Binomial theorem
( x+ y )4=∑j=0
4
(4j ) x4− j y j
¿(40) x4+(41) x3 y+(42)x2 y2+(43 )xy3+(44) y4
¿ x4+4 x3 y+6 x2 y2+4 x y3+ y4
Example (16):
What is the coefficient of x12 y13 in the expansion of ( x+ y )25?
Solution:
From the Binomial theorem it follows that this coefficient is
161
(2513)= 25 !
13 ! .12!=5200300
Example (17):
What is the coefficient of x12 y13 in the expansion of (2 x−3 y )25?
Solution:
(2 x−3 y )25=(2 x+(−3 y ) )25
∴ (2 x+(−3 y ) )25=∑j=0
25
(25j )(2 x )12 (−3 y )13
The coefficient of x12 y13 in the expansion is obtained when j = 13,
namely
(2513)212 (−3 )13= −25 !
13 ! .12!213 . 313
Corollary (2): Let n be nonnegative integer, then
∑k=0
n
(nk )=2n
Proof: Using the Binomial theorem with x = 1 and y = 1, we see
that
2n= (1+1 )n=∑k=0
n
(nk )1k . 1n−k=∑k=0
n
(nk )Corollary (3): Let n be a positive integer, then
∑k=0
n
(−1)k (nk )=0
Proof: Using the Binomial theorem with x = -1 and y = 1, we see
that 0=0n= ( (1−1 )+1 )n=∑k=0
n
(nk) (−1 )k 1n−k
¿∑k=0
n
(nk ) (−1 )k
Corollary (4): Let n be a nonnegative integer, then
∑k=0
n
2k (nk )=3n
162
Proof:3n=(1+2 )n=∑k=0
n
(nk )1n−k 2k=∑k=0
n
(nk )2k
Theorem (5) : Pascal’s identity
Let n and k be positive integers with n≥ k, then
(n+1k )=( n
k−1)+(nk)
Example(18):
Prove the identity:
(n0)+(n+11 )+(n+2
2 )+…+(n+kk )=(n+k+1
k ) (*)..……
Proof:
We use the mathematical induction on k.
If k = 0 (Basis step):
The identity just says 1=1
So it is trivially true.( we can check it also for k =
1).
n+1 = n+1
The inductive step :
Assume that the identity (*) is true for a given value
k
We want to prove that it also holds for k+1 in place
of k , we want to prove that:
(n0)+(n+11 )+(n+2
2 )+…+(n+kk )+( n
k+1)=(n+k+2k+1 )
163
Here the sum of the first k terms on the left hand
side is: (n+k+1
k ) by induction hypothesis , and so the
left hand side equal to (n+k+1k )+(n+k+1
k+1 )
But this is indeed equal to (n+k+2k+1 )
By the fundamental property of Pascal triangle this
complete the proof by induction .
6.7. Pascal’s triangle:
6.8. 1 Recurrence Relations:Def.(1):
164
(a)
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 61
1 7 21 35 35 21 71
1 8 28 36 70 56 2881
(b)
A recurrence relation for the sequence {an} is an equation
that express an in terms of one or more of the previous
terms of the sequence , namely ,a0 , a1 , a2 , …,an−1, for all
integers n with
n ≥ n0, where n0 is non negative integer . A sequence is called a
solution of a recurrence relation if its terms satisfy the
recurrence relation .
Example(1):
Let {an} be a sequence that satisfies the recurrence relation an = an−1−an−2 for n=2 ,3 ,4 ,… , and suppose that a0=3∧a1=5 .
What are a2∧a3 ?
Solution :
We see from the recurrence relation that
a2=a1−a0=5−3=2∧a3=a2−a1=2−5=−3
We can find a4∧a5 , and each successive term in a similar
way.
Example (2):
The recurrence relation Pn = (1.11)Pn−1 is a linear homogenous
relation of degree one . The recurrence relation Fn = Fn−1+Fn−2
The recurrence relation an = an−5 is a linear homogenous
recurrence relation of degree five.
Example(3):
Determine whether the sequence {an} , where
an=3 n for every nonnegative integer n , is a solution of the
recurrence relation an=2 an−1 – an−2 for n=2,3 ,4 ….
Answerthe same question where an=2n and an=5.
Solution:
Suppose that an=3 n for every nonnegative integer n.Then ,
165
for n ≥ 2 , we see that 2 an−1−an−2=2 [3 (n−1 ) ]−3 (n−2 )=3n=an
Therefore, {an} , where an=3n , isa solutionfor the recurrence relation .
Suppose that an=2n for every nonnegative integer n . Note that a0
¿1, a1=2 ,∧a2=4. Because 2 a1−a0=¿ 2.2 -1=3 ≠ a2 ,
we see that {an}, where an=2n , is not a solution of the recurrence
relation.
Suppose that an=5 for every nonnegative integer n . Then for
n ≥ 2 , we see that an=2an−1−an−2=2.5−5=5=an.
Therefore , {an}, where an=5 ,is a solution of the recurrence relation.
Example (4):The recurrence relation an=an−1−a2n−2 is non linear . The
recurrence relation H n=2 Hn−1+1 is not homogeneous. The recurrence
relation Bn=n Bn−1 does not have constant coefficients.
Example(5): an = 2 an-1 + 3 an-2 and a0 = a1 = 1
Solution by use of the characteristic equation:
1 .Substitute rn for an (rn-1 for an-1, etc.) and simplify the result. For this
example the characteristic equation is rn = 2rn-1 + 3rn-2 which
simplifies to: r2 = 2r + 3
2 .Find the roots of the characteristic equation:
r2 - 2r - 3 = 0 factors as (r - 3)(r + 1) giving roots r1 = 3 and r2 = -1
When there are two distinct roots, the general form of the solution is:
an = a1•r1n + a2•r2
n
where a1 and a2 are constants. In this case, we have :
an = a1•3n + a2•(-1)n
166
3 .Using the initial conditions we can find the constants a1 and a2
a0 = 1 = a1 + a2
a1 = 1 = 3a1 - a2
so a1 = 1/2 and a2 = 1/2 and the final solution is
an = (1/2)•3n + (1/2)•(-1)n.
If a characteristic equation has equal roots, (i.e. r1 =r2), then the general
solution has the form:
an = a1•rn + a2•n•rn
Example( 6): an = 2an-2 – an-4 with a0 = 0, a1 = -2, a2 = 4 and a3 = -4.
In this case, we have a degree four linear homogeneous recurrence whose
characteristic equation is r4 = 2 r2 - 1 or r4 -2 r2 + 1 = 0. This factors as :
) r2 - 1 )(r2 - 1 = (0 so the roots are r1 = r2 = 1 and
r3 = r4 = -1. (The order of the roots is arbitrary.)
Note there are two pairs of equal roots so there will be two terms each with n
as a factor.
The form of the general solution is: an = a1•r1n + a2•n•r2
n + a3•r3n +
a4•n•r4n
Setting up the equations we have:
a0 = 0 = a1 + a3
a1 = -2 = a1 + a2 - a3 - a4
167
a2 = 4 = a1 + 2a2 + a3 + 2a4
a3 = -4 = a1 +3a2 - a3 - 3a4
so a1 = -1/2, a2 = 1/2, a3 = 1/2 and a4 = 3/2 and the final solution is:
an = (-1/2)•1n + (1/2)•n•1n + (1/2)• (-1)n + (3/2)•n•(-1)n
- = 1/2 + n/2 + (1/2)•(-1)n + (3/2)•n•(-1)n
Example( 7): Draw n straight lines on a paper so that every pair of
lines intersect, but no three lines intersect at a common point.
Determine how many regions the plane is divided into if n lines are
used. (Draw yourself some pictures.)
If n = 0 then there is 1 region.
If n = 1 there are 2 regions.
If n = 2 there are 4 regions.
If n = 3 there are 7 regions.
In general, the nth line intersects n -1 others and each intersection
subdivides a region, so the number of regions that are subdivided by
the nth line is: 1 before the first line, 1 after the last line, and n - 2
regions between the n -1 lines. This gives us the following recurrence
relation:
an = an-1 + n This can be solved iteratively by backward
substitution. Specifically,
=an-2 + (n - 1) + n
=an-3 + (n - 2) + (n - 1) + n
168
•
•
•
=a0 + 1 + 2 + ... + (n - 2) + (n - 1) + n = a0 + å i = 1 + n(n + 1)/2
Example( 8): Consider the relation an2 = 5(an-1) 2 where an > 0 and
a0 = 2 .
Make the following change of variable: let bn = an2. Then, b0 = 4 and bn
= 5 bn-1.
Since this is a geometric series, its solution is bn = 4•5n. Now
substituting back ,
an = √bn = 2√5n for n ³ 0.
6.8.2.Inhomogeneous Recurrence Relations:
We now turn to inhomogeneous recurrence relations and look at
two distinct methods of solving them. These recurrence relations in
general have the form an = cn-1an-1 + g(n) where g(n) is a function of n.
(g(n) could be a constant)
One of the first examples of these recurrences usually encountered is
the tower of Hanoi recurrence relation: H(n) = 2H(n-1) + 1 which has
as its solution H(n) = 2n – 1. One way to solve this is by use of
backward substitution as above. We’ll see another method shortly.
Example( 9): Consider the Tower of Hanoi recurrence: H(n) = 2H(n-
1) + 1 with H(1) = 1. The solution to the homogeneous part is a•2n.
Since g(n) = 1 is a constant, the particular solution has the form169
p(n) = b. Substituting into the original recurrence to solve for b we
get: b = 2b +1 so that b = -1. Thus, p(n) = -1. This means that
H(n) = a•2n – 1. Using the fact that H(1) = 1, gives 1 = a•2 –1 so a = 1.
Thus, the solution to the original recurrence is H(n) = 2n – 1. (Note
that alternative ways to get this solution are backward substitution and
the method shown below.)
Example( 10): an = 2an-1 + n2 with a1 = 3.
The homogeneous part an = 2an-1 has a root of 2, so f(n) = a•2n. The
particular solution should have the form an = b2•n2 + b1•n + b0.
Substituting this into the original recurrence gives
b2n2 + b1n + b0 = 2[b2(n-1)2 + b1(n-1) + b0] + n2. Expanding and
combining like terms gives us
0 = n2(b2 + 1) + n(-4b2 + b1) + (2b2 - 2b1 + b0). Notice that each
parenthesized expression must evaluate to 0 since the left hand side of
the equation is 0. This gives us the following values for the constants: b2 = -1, b1 = -4 and b0 = -6. Thus, p(n) = -n2 -4n - 6. Then we have
an = a•2n -n2 -4n - 6. This gives us a = 7 and the final solution is
an = 7•2n -n2 - 4n - 6.
If g(n) consists of two or more terms, then each term is handled
separately using the table above. For example, solving an = 3 an-1 + 6n –
2n, requires finding particular solutions for two recurrences —
an = 3 an-1 + 6n and
an = 3 an-1 – 2n.
170
There is one case in which the particular solutions above will not work.
This happens when the particular solution is a solution of the
homogeneous recurrence. Then, the particular solution that should be
tried is a higher degree polynomial. For example. if g(n) = dn and d is a
solution of the homogeneous part then try b•n•dn as the particular
solution.
Example( 11): an = 3an-1 + 2n with a1 = 5.
The homogeneous part an = 3an-1 has a root of 3, so f(n) = a•3n. The
particular solution should have the form an = b•2n. Substituting this
into the original recurrence gives b•2n = 3 b•2n-1 + 2n. Solving this
equation for b gives us the particular solution p(n) = -2n+1. Thus the
solution has the form an = a•3n - 2n+1. Using the initial condition that
a1 = 5 we get 5 = 3a - 4 which gives a = 3. Thus, the final solution is
an = 3n+1 - 2n+1.
A nother method of solving inhomogeneous recurrence relations: 6.8.3
Let’s consider the Tower of Hanoi recurrence again: H(n) = 2H(n-1)
+ 1 or H(n) – 2H(n-1) = 1. Substitute n – 1 for n in this equation to get
H(n-1) – 2 H(n-2) = 1. Notice what happens if we subtract the second
equation from the first: H(n) – 2H(n-1) – H(n-1) +2H(n-2) = 1 – 1 ,
or H(n) – 3H(n-1) + 2H(n-2) = 0, a homogeneous linear recurrence
relation. The characteristic equation x2 – 3x + 2 = 0 factors as
) x-2)(x-1 = (0 so the general form of the solution is
H(n) = a1• 2n + a2•1n = a1• 2n + a2. Using the initial conditions to
obtain the constants we find that a1 = 1 and a2 = -1 and thus we have
171
H(n) = 2n – 1 as we found before.
Example (12): an – an-1 = 2n with a0 = 0
Using the same method as above we find that an-1 - an-2 = 2(n-1). Now,
subtracting we get
an – an-1 = 2n
- a n-1 + an-2 = -2(n-1)
an -2an-1 + an-2 = 2
This is not yet a homogeneous recurrence but one more application of
the method will give us a linear homogeneous recurrence relation.
an -2an-1 + an-2 = 2
- a n-1 + 2an-2 – an-3 = -2
an -3an-1 +3an-2 –an-3 = 0 has characteristic equation
x3 – 3x2 + 3x - 1 = 0 that factors as (x – 1)3.
The general form of the answer must be an = a1•1n +a2•n•1n + a3•n2•1n
or a1 + a2•n + a3•n2. Since a0=0 we immediately get that a1 = 0. a1 = 2
and a2 = 6 giving us
2 = a2 + a3 and 6 = 2a2 + 4 a3. Solving for a2 and a3 we get a2 = 1 and
a3 = 1 so the solution to the recurrence is an = n + n2 or n(n + 1).
The same method can be used to solve recurrence relations in which
g(n) is a higher order polynomial. The substitute n – 1 for n and
subtract may have to be used several times, but eventually you will
172
obtain a linear homogeneous recurrence relation. (However, factoring
the characteristic equation could turn into a challenge.)
A similar method can be used if the function g(n) is an exponential.
Example( 13): an = 3an-1 + 2n with a1 = 5 .
Rewriting the recurrence relation gives us an - 3an-1 = 2n. First we
multiply by 2 to get
2an - 6an-1 = 2n+1. Now substitute n – 1 for n in this new equation to
get:
2an-1 - 6an-2 = 2n. Now, subtracting this new recurrence from the
original one we get:
an - 3an-1 = 2n
- 2a n-1 + 6an-2 = -2 n
an – 5an-1 + 6an-2 = 0 .
The characteristic equation is x2 – 5x + 6 = 0 which factors as (x - 3)(x
– 2) = 0, so the answer has the form an = a1•3n + a2•2n. Using the facts
that a1 = 5 and a2 = 19 we get
5 = 3a1 + 2 a2 and 19 = 9a1 + 4a2. Solving for the constants we get:
a1 = 3 and a2 = -2 giving us the solution an = 3•3n + (-2)•2n = 3n+1 – 2n+1
6.8.4 .A formula for Fibonacci numbers:Fn+1=Fn+Fn−1, n= 2 ,3 ,4 ,… (*)F1=1 , F2=1 ,F3=2 , F4=3 ,F5=5 , F0=0
Using the equation (*) we can easily determine any number of terms
in this sequence numbers :
173
0 , 1 ,1 2,3, 5,8,13,21,34, 55, 89,144, 233, 377, 610, 987,1597,…
The numbers in this sequence are called Fibonacci numbers .
Example(3): What is the sum of the first n Fibonacci numbers
0 = 0
0 + 1 = 1
0 + 1 +1 = 2
0 +1 + 1+ 2 = 4
0 + 1 +1 + 2 + 3 = 7
0 + 1 + 1 + 2 + 3 + 5 =12
0 + 1 + 1 + 2 + 3 + 5 + 8 = 20
0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 = 33
……….F0+F1+F2+F3+…+Fn=Fn+2−1
F0+F1+…+Fn=(F0+F1+…+Fn−1 )+Fn
¿ (Fn+1−1 )+Fn
= Fn+2−1
Exercises: 1)Find the value of each of these quantities:
a) P(6,3) (b)P(6,5) (c) P(8,1) (d) P(8,5)
e) C(5,1) (f) C(5,3) (g) C(12,6) (h) C(8,8)
2 )Find the number of 5- permutations of a set with nine
elements
3) What is the row of Pascal 's triangle containing the binomial
coefficients (9k) , 0≤ k ≤ 9 ?.
3) Find the expansion of ¿.
4) What is the coefficient of x8 y 9 in the expansion of
5) ¿
6) Prove that ∑k=0
r
(n+kk )=(n+r+1
r ).174
7) Find recurrenc relations that are satisfied by the sequences
formed from the following functions :
(i) an=n2−6n+8
(ii) an=n!
15 ! (iii) an=n !
[15! (n−15 )!] for n > 14
References:
175
]1 [AL Doerr, Ken Levasseur (2003) .Applied Discrete Mathematics.
[2] Charles M. Grinslead Swarthamore College .Introduction to
Probability .
]3 [James L. Hein (2003) Discrete Mathematics .Jones and Bartlett
learning .
]4 [Kenneth H. Rosen (2007) Discrete Mathematics and its
Applications . Sixth Edition . McGROW Hill.
]5 [Laszlo Lovasz and Katlin Vesztergombi, (1999), Discrete
Mathematics Yale University .
]6 [L. Lovaszan K. Vesztergombi(1979).Discrete Mathematics.
Elsevier ,Amesterdam.
]7 [Migual A.Lerma Noteson (2005). Discrete Mathematics.
Northwestern University .
]8 [M .O. Albertson , (1988) .Discrete Mathematics with Algorithms.
John Wiley and Sons
]9 [Richard Johnsonbough .(2007).Applied Discrete Mathematics.
Prentice Hall Amazon .com .
]10 [Susanna S. EPP . Discrete Mathematics with Applications.
Fourth Edition. De Paul University .Amazon .com.
]11 [Tucker,Alan,Applied combinatorics,2nd ed.
]12[http://www.answers.com/topic/recurrence-relations.
[13]http://mathcircle.berkeley.edu/BMC3/Bjorn1/node10htm1
176