Beruflich Dokumente
Kultur Dokumente
Sets
• Sets are one of the basic building blocks for the types of
objects considered in discrete mathematics.
– Important for counting.
– Programming languages have set operations.
• Set theory is an important branch of mathematics.
– Many different systems of axioms have been used to
develop set theory.
– Here we are not concerned with a formal set of axioms
for set theory. Instead, we will use what is called naïve
set theory.
Sets
• A set is an unordered collection of objects.
– The students in this class.
– The chairs in this room.
• The objects in a set are called the elements, or members of the
set. A set is said to contain its elements.
• The notation a ∈ A denotes that a is an element of the set A.
• If a is not a member of A, write a ∉ A
• There must be an underlying Universal set U, either specifically
stated or understood.
• For example:
A = {1, 3, 5, 7}; 3 A , 2 A
C = {x | x = n2 + 1, n is an integer, 0 ≤ n ≤ 10}
9/30/2017 (c)2001-2003, Michael P. Frank
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
• S = {a, b, c, d}
• Order not important
S = {a, b, c, d} = {b, c, a, d}
• Each distinct object is either a member or not; listing more
than once does not change the set.
S = {a, b, c, d} = {a, b, c, b, c, d}
• Ellipses (…) may be used to describe a set without listing
all of the members when the pattern is clear.
S = {a, b, c, d, …, z }
Roster Method
[a, b] = {x | a ≤ x ≤ b}
[a, b) = {x | a ≤ x < b}
(a, b] = {x | a < x ≤ b}
(a, b) = {x | a < x < b}
Examples
A = { x | x = n2 , n is positive integer}
B = { x | x is a letter of the word mohamed}
U : universal set
S
2 3
5 7
9/30/2017
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Subset Relation
Proper Subset
• S T (S is a proper subset of T ) means every element of
S is also an element of T, but S T.
S
T
e.g. {1, 2} {1, 2, 3}
9/30/2017 15
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Ordered n-tuples
Set Operations
The Union Operator
• For any two sets A and B, AB is the set containing all
elements that are either in A, or in B or in both.
• Formally:
AB = {x | x A x B}.
Inclusion-Exclusion Principle
Set Difference
• For any two sets A and B, the difference of A and B,
written A B, is the set of all elements that are in A but not
in B.
A B : x x A x B
x x A x B
A – B = A B is called the complement of B with respect
to A.
e.g. {1, 2, 3, 4, 5, 6} {2, 3, 5, 7, 9, 11} = {1, 4, 6 }
Set A B
Set A Set B
9/30/2017 (c)2001-2003, Michael P. Frank
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Symmetric Difference
• For any two sets A and B, the symmetric difference of A
and B, written , is the set of all elements that are in
A but not in B or in B but not in A.
: x (x A x B) (x B x A)
(A – B) (B – A) (A B) – (A B)
U
A B
Set Complements
• U : Universe of Discourse
A : For any set A U, the complement of A,
i.e. it is U A.
A {x | x A} A
A
e.g. If U = N,
U
{3, 5} {0,1, 2, 4, 6, 7, ...}
Example
Let A and B are two subsets of a set E such that AB = {1,
2}, |A|= 3, |B| = 4, A = {3, 4, 5, 9} and B = {5, 7, 9}. Find the
sets A, B and E.
A 7 1 3 B
E 2 4
5 9
Example
U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7, 8}.
• AB = {1, 2, 3, 4, 5, 6, 7, 8}
• AB = {4, 5}
• A = {0, 6, 7, 8, 9, 10}
• B = {0, 1, 2, 3, 9, 10}
• A B = {1, 2, 3}
• B A = {6, 7, 8}
• AB = {1, 2, 3, 6, 7, 8}
Set Identities
• Identity: A = A = AU
• Domination: AU = U , A =
• Idempotent: AA = A = AA
• Double complement: ( A ) A
• Commutative: AB = BA , AB = BA
• Associative: A(BC) = (AB)C
A(BC) = (AB)C
• Distribution: A(BC) = (AB)(AC)
A(BC) = (AB)(AC)
• De Morgan’s Law: A B A B
A B A B
9/30/2017 (c)2001-2003, Michael P. Frank
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Assume x AB
x AB by the definition of the complement
x AB by the definition of the negation
((x A) (x B)) by the definition of intersection
(x A) ( x B) by De Morgan’s law
x A x B by the definition of negation
x A x B by the definition of the complement
x A B by the definition of union
A B {x | x A B}
{ x | ( x A B )}
{ x | ( x A x B )}
{ x | x A x B )}
{ x | x A x B )}
{ x | x A x B )}
{ x | x A B )} A B
Show that A ( B C) (C B) A
A ( B C ) A ( B C ) De Morgan' s law
A ( B C ) De Morgan' s law
( B C ) A Commutative law
(C B) A Commutative law
(B C) A (B C) A
( B A) (C A)
( B A) (C A).
Functions
Definition: Let A and B be nonempty sets. A function f from
A to B, denoted f : A B is an assignment of each element
of A to exactly one element of B. We write f (a) = b if b is
the unique element of B assigned by the function f to the
element a of A.
Grades
• Functions are sometimes Students
A
called mappings or Carlota Rodriguez
transformations. B
Sandeep Patel
C
Jalen Williams D
Kathy Scott F
9/30/2017 37
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Functions
9/30/2017 38
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Functions
Given a function f : A B
• We say f maps A to B or
f is a mapping from A to B.
• A is called the domain of f.
• B is called the codomain of f.
• If f (a) = b,
– then b is called the image of a under f.
– a is called the preimage of b.
• The range of f is the set of all images of points in A under
f. We denote it by f (A).
• Two functions are equal when they have the same domain,
the same codomain and map each element of the domain to
the same element of the codomain.
9/30/2017 39
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Representing Functions
9/30/2017 40
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Injections
9/30/2017 41
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Surjections
b
e.g. The function f (x) = x 1 from Z y
c
to Z is onto since z
d
for all b Z, there is a Z
such that f (a) = b (a = b + 1)
9/30/2017 42
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Bijections
b
e.g. The function f (x) = x 1 from Z y
c
to Z is one-to-one and onto, hence z
d
bijective w
9/30/2017 43
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
9/30/2017 44
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Inverse Functions
9/30/2017 46
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Inverse Functions
f
A B A B
v a v
a
b b
w w
c c
d x x
d
y y
9/30/2017 47
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Questions
Example 1: 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 so
what is its inverse?
Solution: The function f is invertible because it is a one-to-one
correspondence. The inverse function f -1 reverses the
correspondence given by f, so f -1 (1) = c, f -1 (2) = a, and f -1
(3) = b.
Example 2: Let f : Z Z be such that f (x) = x + 1. Is f
invertible, and if so, what is its inverse?
Solution: The function f is invertible because it is a one-to-one
correspondence (f (a) = f (b) a + 1 = b + 1 a = b). The
inverse function f -1 reverses the correspondence so
f -1 (y) = y – 1.
9/30/2017 48
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Composition
Definition: Let f : B → C, g: A → B. The composition of f with
g, denoted f ∘ g is the function from A to C defined by
f ∘ g (x) = f (g(x))
9/30/2017 49
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Composition
Example 1: Let g be the function from the set {a, b, c} to itself such that
g(a) = b, g(b) = c, and g(c) = a. Let f be the function from the set {a, b,
c} to the set {1, 2, 3} such that f (a) = 3, f (b) = 2, and f (c) = 1. What is
the composition of f and g, and what is the composition of g and f.
Solution: The composition f ∘ g is defined by
f ∘ g (a)= f (g(a)) = f (b) = 2.
f ∘ g (b)= f (g(b)) = f (c) = 1.
f ∘ g (c)= f (g(c)) = f (a) = 3.
Note that g ∘ f is not defined, because the range of f is not a subset of
the domain of g.
9/30/2017 50
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Composition
Graphs of Functions
Let f be a function from the set A to the set B. The graph of the
function f is the set of ordered pairs {(a, b) | a ∈ A and f (a) = b}.
Important Functions
(a) The floor function, denoted
is the largest integer less than or equal to x.
(b) The ceiling function, denoted
is the smallest integer greater than or equal to x.
Matrices*
2 3
5 1 2 1
3 1
7 0
32 22
9/30/2017 54
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Matrix Equality*
• Two matrices A and B are equal if and only if they have the
same number of rows, the same number of columns, and
all corresponding elements are equal.
3 2 3 2 0
1
6 1 6 0
9/30/2017 55
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
am1 am 2 amn
9/30/2017 56
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Matrix Sums*
2 6 7 5 9 1
0 8 4 1 4 9
1 2 3 6 4 8
9/30/2017 57
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Matrix Products*
9/30/2017 58
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
2 1 4 6
A and B ,
3 0 2 1
(2 4 1 2) (2 6 1 -1)
AB
(3 4 0 2) (3 6 0 -1)
10 11
12 18
9/30/2017 59
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
0 1 1 0
0 1 1 1 0 5 1
2 0 3 2 0 2 0
3 2 11 3
1 0 3 1
2×3 3×4 2×4
9/30/2017 60
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Identity Matrices*
9/30/2017 61
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Powers of Matrices*
9/30/2017 62
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Matrix Transposition*
9/30/2017 63
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Symmetric Matrices*
1 1 2 1 3 3 0 1
1 1 1 0 2 1
0 1
1 1 3 1 2 1 1 2
9/30/2017 64
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Zero-One Matrices
9/30/2017 65
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
9/30/2017 66
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Example
1 0 1 0 1 0
A= B =
0 1 0 1 1 0
1 1 1
• The join between A and B is A B =
1 1 0
0 0 0
• The meet between A and B is A B =
0 1 0
9/30/2017 67
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Boolean Products
9/30/2017
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Example
1 0
1 1 0
Let A 0 1 and B
0 1 1
1 0
(1 1) (0 0) (1 1) (0 1) (1 0) (0 1)
(0 1) (1 0) (0 1) (1 1) (0 0) (1 1)
A⊙ B=
(1 1) (0 0) (1 1) (0 1) (1 0) (1 0)
1 1 0
0 1 1
1 1 0
9/30/2017 69
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Boolean Powers
k times
9/30/2017 70
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Example
1 1 0
Let A 0 1 0. Find A[2].
1 0 1
1 1 0 1 1 0 1 1 0
0 1 0 0 1 0
A = A ⊙ A =
⊙ 0 1 0
[2]
1 0 1 1 0 1 1 1 1
9/30/2017 71
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Example
9/30/2017 72
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics