2. References 1-Rosen, Kenneth H. "Discrete Mathematics and
Its Applications.“ seventh edition
2-introduction to set theory
3-rational numbers
4-Introduction to rational and irrational numbers
5-Classification of Numbers
6-SUBSETS AND POWER SETS
7-cartesian products
7-Examples
8-Functions
3. Course Content:
Chapter 2: Basic
Structures: Sets,
Functions, Sequences,
Sums, and Matrices
Chapter 8: Advanced
Counting Techniques
Chapter 1: The
Foundations: Logic and
Proofs
Chapter 4: Number
Theory and Cryptography
Chapter 5: Induction and
Recursion
Chapter 6: Counting
6. Set Theory
• Definition 1: A set is an unordered collection of objects
• A={1,2,3}
• Definition 2: Objects in a set are called elements, or members of the
set.
• We write a A to denote that a is an element of the set A.
• we write a A to denote that a is not an element of the set A.
• It is common for sets to be denoted using uppercase letters.
• Lowercase letters are usually used to denote elements of sets.
• There are several ways to describe a set. One way is to list all the
members of a set, when this is possible. We use a notation where
all members of the set are listed between braces. For example, the
notation {a, b, c, d} represents the set with the four elements a, b, c,
and d. This way of describing a set is known as the roster method.
.1 .2
.3
Visual
List Notation
7. • The set V of all vowels in the English alphabet can be
written as
• V = {a, e, i, o, u}
• The set O of odd positive integers less than 10 can be
expressed by
• O = {1, 3, 5, 7, 9}
• Although sets are usually used to group together elements with
common properties, there is nothing that prevents a set from
having seemingly unrelated elements. For instance, {a, 2, Fred,
New Jersey} is the set containing the four elements a, 2, Fred,
and New Jersey.
• Sometimes the roster method is used to describe a set without
listing all its members. Some members of the set are listed, and
then ellipses (. . .) are used when the general pattern of three
elements is obvious.
• The set of positive integers less than 100 can be denoted by {1,
2, 3, . . . , 99}.
8. Set builder notation
• 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. For instance, the set O of all
odd positive integers less than 10 can be written as
• O = {x|x is an odd positive integer less than 10}
or O = {x ℤ +|x is odd and x<10}
• Q={…,
1
1
,
1
2
,
1
3
,…} ={
𝑚
𝑛
| m, n ∈ ℤ n≠ 0}
• Even integers:
• 2 ℤ={…,-4,-2,0,2,4,…}={2n | n ∈ ℤ}
9. Additional points
• Sets can be finite or infinite
• A={1, 2, 3, 4, 5, 6}
• Z+ = 1, 2, 3, 4, … all positive integers
• Repeated elements are listed once
• {a, b, a, c, b, a, c}={a, b, c}
• There is no order in a set
• {3,2,1}={1,2,3}={2,1,3}
.a .b
.c
10. Number systems
• N={1, 2, 3, …}, or {0,1,2,3,…}natural numbers or counting numbers
• W={0,1,2,3,…},whole numbers
• Z={…,-2, -1, 0, 1, 2, …}, integers
• Z+={1, 2, 3, …}, positive integers, zero is neither positive nor negative
• Q={p/q|pZ, qZ, and q0}, rational numbers (fraction numbers and decimals numbers)
• Q+={xR|x=p/q, for positive integers p and q}
• C, the set of complex numbers.
• R, real numbers, i = −1 is not real number
• R+, the set of positive real numbers
• Terminating decimal numbers (finite) and recurring decimal numbers( infinite and repeating)
• Irrational number never terminate and never repeated, there is only one irrational number between any two rational
numbers.
• To get irrational numbers (square ,sum with irrational (rational+irr) , prod with irrational (rational *irr))
15. Intervals
• Recall the notation for intervals of real numbers. When a and b are
real numbers with a < b, we write
• [a, b] = {x | a ≤ x ≤ b} closed interval
• [a, b) = {x | a ≤ x < b}
• (a, b] = {x |a < x ≤ b}
• (a, b) = {x |a < x < b} open interval
16. Example
• The set {N,Z,Q,R} is a set containing four elements, each of which is
a set. The four elements of this set are N, the set of natural
numbers; Z, the set of integers; Q, the set of rational numbers; and
R, the set of real numbers.
• Remark: Note that the concept of a datatype, or type, in computer
science is built upon the concept of a set. In particular, a datatype
or type is the name of a set, together with a set of operations that
can be performed on objects from that set. For example, boolean is
the name of the set {0, 1} together with operators on one or more
elements of this set, such as AND, OR, and NOT.
17. Definition 3
• Definition 3: Two sets are equal if and only if they
have the same elements.
A=B if x(x A x B)
• {1, 3, 5} and {3, 5, 1} are equal
• The sets {1, 3, 5} and {3, 5, 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. Note also that it does not matter if an
element of a set is listed more than once, so {1, 3, 3, 3, 5, 5, 5, 5} is
the same as the set {1, 3, 5} because they have the same elements.
18. The Empty set
• Empty set (null set): (or {})
• There is a special set that has no elements. This set is called the
empty set or null set, and is denoted by ∅. The empty set can also
be denoted by { } (that is, we represent the empty set with a pair of
braces that encloses all the elements in this set). Often, a set of
elements with certain properties turns out to be the null set. For
instance, the set of all positive integers that are greater than their
squares is the null set.
• A set with one element is called a singleton set. A common error is
to confuse the empty set ∅ with the set {∅}, which is a singleton set.
The single element of the set {∅} is the empty set itself ! A useful
analogy for remembering this difference is to think of folders in a
computer file system. The empty set can be thought of as an empty
folder and the set consisting of just the empty set can be thought of
as a folder with exactly one folder inside, namely, the empty folder.
19. Venn diagram
• Venn diagram to graphically represent sets
• Universal set U: rectangle
• Sets: circles
• Elements of a set: point
FIGURE 1 Venn Diagram for the Set of Vowels.
20. Subsets
• Definition 4: The set A is a subset of B if and only if every
element of A is also an element of B.
A B if x(x A x B)
• Theorem 1: For every set S,
(1) S and (2) S S.
• Proper subset: A is a proper subset of B, we note A B, if
x(x A x B) x(x B x A)
21.
22. Subsets
• If AB and BA, then A=B
• Sets may have other sets as members
• A={, {a}, {b}, {a,b}}
B={x|x is a subset of the set {a,b}}
• A=B
FIGURE 2 Venn Diagram Showing that A Is a Subset of B.
23. The Size of a Set
• Definition 5: If there are exactly n distinct members
in the set S (n is a nonnegative integer), we say
that S is a finite set and that n is the cardinality of
S.
• |S|= n
• ||=0 , |{}|=1 ,|{ }|=0
• Definition 6: a set is infinite if it’s not finite.
• Z+
24. Elements and cardinality
• Let C={yellow, blue, red}
• Yellow is an element of C ,yellow∈ 𝐶
• Green is not an element of C, Green ∉ 𝐶
• The cardinality (size) of C is 3 ,|c|=3
25. Exercise
• List the elements of D. D={x ∈ ℤ+
| x<6}
• 1,2,3,4,5
• What is the cardinality of D?
• |D|=5
• What is the cardinality of {,{a,b}}
• 2
• What is the cardinality of {,{a},{b}}
• 3
• What is the cardinality of {,a,{b}}
• 3
26.
27. The Power Set
• Definition 7: The power set of S, P(S), is the set of
all subset of the set S.
• P({0,1,2}) = {∅, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}.
• P()={∅}
• P({})={∅, {∅}}
• If a set has n elements, then its power set has 2n
elements(2 choices per element).
28.
29.
30.
31.
32.
33.
34.
35. Cartesian Products
• Definition 8: Ordered n-tuple (a1, a2, …, an) is the
ordered collection that has ai as its ith element for i=1,
2, …, n.
• Definition 9: Cartesian product of A and B, denoted
by A B, is the set of all ordered pairs (a, b), where a
A and b B.
A B = {(a, b)| a A b B}
• E.g. A = {1, 2}, B = {a, b, c}
• A B={(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}.
• B×A =...
• A B and B A are not equal, unless A= or B= or
A=B
36.
37. • Definition 10: Cartesian product of A1, A2, …, An,
denoted by A1 A2 … An, is the set of all ordered n-
tuples (a1, a2, …, an), where ai Ai for i=1,2,…,n.
A1 A2 … An = {(a1, a2, …, an)| ai Ai for i=1,2,…,n}
• A = {0, 1}, B = {1, 2}, and C = {0, 1, 2}
• 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), (1, 1, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2)}.
38.
39.
40.
41. 2.2 Set Operations
• Definition 1: The union of the sets A and B,
denoted by AB, is the set containing those
elements that are either in A or in B, or in both.
• AB={x|xA xB}
• Definition 2: The intersection of the sets A and B,
denoted by AB, is the set containing those
elements in both A and B.
• A B={x|xA xB}
42. FIGURE 1 Venn Diagrams Representing the Union and
intersection of A and B.
P. 122
42
43. • Definition 3: Two sets are disjoint (متداخلة )غيرif their
intersection is the empty set.
• |AB|=|A|+|B|-| A B |
• {1,2,3} and {3,4,5} ->not disjoint
• {a,b} and {3,4} -> disjoint
44. • Definition 4: The difference of the sets A
and B, denoted by A-B, is the set
containing those elements that are in A but
not in B.
• Complement of B with respect to A
• A-B={x|xA xB}
• Definition 5: The complement of the set A,
denoted by Ā, is the complement of A with
resepect to U.
• Ā = {x|xA}
51. Generalized Unions and
Intersections
• Definition 6: The union of a collection of sets is
the set containing those elements that are
members of at least one set in the collection.
• A1 A2 … An =
• Definition 7: The intersection of a collection of
sets is the set containing those elements that
are members of all the sets in the collection.
• A1 A2 … An =
• Computer Representation of Sets
• Using bit strings
n
i
i
A
1
n
i
i
A
1
53. Exercise
• Show that if A, B, and C are sets, then 𝐴 ∩ 𝐵 ∩ 𝐶= 𝐴
∪ 𝐵 ∪ 𝐶
• a) by showing each side is a subset of the other side:
…
• b) using a membership table.
97. Inverse Functions and Compositions
of Functions
• Definition 9: Let f be a one-to-one correspondence
from A to B. The inverse function of f is the function
that assigns to an element b in B the unique
element a in A such that f(a)=b.
• f--1(b)=a when f(a)=b
102. Exercise
• Let f be the function from {a, b, c} to {1, 2, 3} such that f (a) =
2, f (b) = 3, and f (c) = 1. Is f invertible, and if it is, what is its
inverse?
• f is …
• Let f : Z → Z be such that f(x) = x + 1. Is f invertible, and if it is,
what is its inverse?
• f....
103. Composition of functions
• Definition 10: Let g be a function from A to B, and f
be a function from B to C. The composition of
functions f and g, denoted by f○g, is defined by
f○g(a) = f(g(a))
• f○g and g○f are not equal
108. Exercise
• Let g be the function such that g(a)=b, g(b)=c, and g(c)=a. Let
f be the function such that f (a)=3, f (b)=2, and f (c)=1. What is
f○g and g○f ?
• The composition f○g is defined by (f○g)(a)= f(g(a))=
…
• Note that g○f is not defined, because the range of f is not a subset of
the domain of g
109. Exercise
• Let f and g be the functions from ℤ to ℤ defined by
f(x)=2x+3 and g(x)=3x+2. What are f○g and g○f ?
• (f○g)(x) = …
• (g○f )(x) = …
110.
111. Some important Functions
• Definition 12: The floor function assigns to x the
largest integer that is less than or equal to x (x).
The ceiling function assigns to x the smallest
integer that is greater than or equal to x (x).
• 1/2 = 0, - 1/2 = -1, 3.1 = 3, 7 = 7, 1/2 = 1, - 1/2
= 0, 3.1 = 4, 7 = 7
113. 2.5 Sequences and Summations
• Definition 1: A sequence is a function from a subset
of the set of integers to a set S. We use an to
denote the image of the integer n (a term of the
sequence)
• Notation: {an} describes the sequence
• Ex: an=1/n
114. Progressions
• Definition 2: A geometric progression is a
sequence of the form
a, ar, ar2, …, arn, …
where the initial term a and the common ratio r
are real numbers
• Definition 3: A arithmetic progression is a
sequence of the form
a, a+d, a+2d, …, a+nd, …
where the initial term a and the common
difference d are real numbers
115. Examples
• {bn} with bn = (−1)n
• {cn} with cn = 2・5n
• {dn} with dn= 6・(1/3) n
119. Summations
• Summation notation:
• am+am+1+…+an
• j: index of summation
• m: lower limit
• n: upper limit
n
m
j
j
a
n
m
j j
a
n
j
m j
a
120. Exercises
• Use summation notation to express the sum of the
first 100 terms of the sequence {aj}, where aj = 1/j
for j = 1, 2, 3, . . . .
• What is the value of
100
1
1
j j
5
1
2
j
j
123. • What are the values of these sums?
5
1
)
1
(
k
k
100
1
k
k
100
1
3
k
4
1
3
1
i j
ij
4
1
3
0
2
2
i j
j
i
3
1
4
0
i j
j
i