Sie sind auf Seite 1von 72

Module #3 - Sets

2. Sets, Functions and


Matrices

9/30/2017 (c)2001-2003, Michael P. Frank


Module #3 - Sets

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.

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

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

Describing a Set: Roster Method

• 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 }

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Roster Method

• Set of all vowels in the English alphabet:


V = {a, e, i, o, u}
• Set of all odd positive integers less than 10:
O = {1, 3, 5, 7, 9}
• Set of all positive integers less than 100:
S = {1, 2, 3, …, 99}
• Set of all integers less than 0:
L = {…, -3, -2, -1}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Some Important Sets

• N = natural numbers = {0, 1, 2, 3, …}


• Z = integers = {…, -3, -2, -1, 0, 1, 2, 3, …}
• Z⁺ = positive integers = {1, 2, 3, …}
• R = set of real numbers
• R+ = set of positive real numbers
• C = set of complex numbers
• Q = set of rational numbers

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Describing a Set: Set-Builder


Notation
• Specify the property or properties that all members must
satisfy:
S = {x | x is a positive integer less than 100}
T = {x | x is an odd positive integer less than 10}
O = {x ∈ Z⁺ | x is odd and x < 10}
• A predicate may be used:
S = {x | P(x)}
• Example: S = {x | Prime(x)}
• Positive rational numbers:
Q+ = {x ∈ R | x = p/q, for some positive integers p, q}
9/30/2017 (c)2001-2003, Michael P. Frank
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Describing a Set: Interval


Notation

[a, b] = {x | a ≤ x ≤ b}
[a, b) = {x | a ≤ x < b}
(a, b] = {x | a < x ≤ b}
(a, b) = {x | a < x < b}

Closed interval [a, b]


Open interval (a, b)

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Examples

Use the set builder notation to describe the sets


A = {1, 4, 9, 16, 25, …}
B = {a, d, e, h, m, o}

A = { x | x = n2 , n is positive integer}
B = { x | x is a letter of the word mohamed}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Describing a Set: Venn Diagrams

U : universal set

S
2 3
5 7

Prime < 10 John Venn


1834-1923

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Membership in Sets and the


Empty Set
• x  S : x is an element or member of the set S.
e.g. 3  N
“a” {x | x is a letter of the alphabet}
• x  S : (x  S) “x is not in S ”
•  (null or the empty set) is the unique set that contains no
elements.
•  = {}
• Empty set  does not equal the singleton set { }
 ≠ { }

9/30/2017
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Definition of Set Equality

• Two sets are declared to be equal if and only if they


contain exactly the same elements.
i.e. A and B are equal if and only if
x (x  A  x  B)

Example: (Order and repetition do not matter)


{1, 3 , 5} = {3, 5, 1} = {1, 3, 3, 3, 5, 5, 5}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Subset Relation

• S  T (“S is a subset of T ”) means that every element of S


is also an element of T.
S  T  x (x  S  x  T )
•  S &S S
• If S  T is true and T  S is true then S = T,
x (x  S  x  T)
• (S  T ) means S / T
i.e.  x (x  S  x  T )

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

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.

Venn Diagram equivalent of S  T

S
T
e.g. {1, 2}  {1, 2, 3}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Sets Are Objects, Too!

• The objects that are elements of a set may themselves be


sets.
e.g. let S = {x | x  {1,2,3}}
then S = {,
{1}, {2}, {3},
{1,2}, {1,3}, {2,3},
{1,2,3}}
• Note that 1  {1}  {{1}}

9/30/2017 15
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Cardinality and Finiteness

• |S| or card(S) (read the cardinality of S ) is a measure of


how many different elements S has.
e.g. | | = |{ }| = 0
|{1, 2, 3, 5}| = 4
|{a, b, c}| = 3
|{{1, 2, 3},{4, 5}}| = 2

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

The Power Set Operation

• The power set P(S) of a set S is the set of all subsets of S.


e.g.
 P({a}) = {, {a}}
 P({a, b}) = {, {a}, {b}, {a, b}}
 P({1, 2, 3}) = {, {1}, {2}, {3}, {1, 2},
{1, 3}, {2, 3}, {1, 2, 3}}
 P({}) = {, {}}
 P() = {}

Note: If a set has n elements then P(S) has 2n elements.

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Ordered n-tuples

• The ordered n-tuple (a1, a2, …, an) is the ordered collection


that has a1 as its first element, a2 as its second element and
so on.
• These are like sets, except that duplicates matter, and the
order makes a difference.
e.g. (2, 5, 6, 7) is a 4-tuple.
• Note that (1, 2)  (2, 1)  (2, 1, 1).
• Note that 2-tuples are called ordered pairs.

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Cartesian Products of Sets

• The Cartesian product of any two sets A and B is defined by


AB : {(a, b) | a  A  b  B }.
e.g. {a, b}{1, 2} = {(a, 1), (a, 2), (b, 1), (b, 2)}

• Note that for finite A and B, |AB| = |A||B|.


• Note that the Cartesian product is not commutative: AB ≠
BA.
e.g. {1, 2}{a, b} = {(1, a), (1, b), (2, a), (2, b)}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Cartesian Products of Sets

• The Cartesian products of the sets A1, A2, …, An, denoted by


A1  A2  …  An , is the set of ordered n-tuples (a1, a2, …,
an) where ai belongs to Ai for i = 1, …, n.

Example: What is A  B  C where A = {0, 1}, B = {1, 2} and


C = {0, 1, 2}
Solution: 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)}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Set Operations
The Union Operator 
• For any two sets A and B, AB is the set containing all
elements that are either in A, or in B or in both.
• Formally:
AB = {x | x A  x  B}.

{2, 3, 5}{3, 5, 7} = {2, 3, 5, 3, 5, 7} = {2, 3, 5, 7}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

The Intersection Operator 


• For any two sets A and B, their intersection AB is the set
containing all elements that are in both A and in B.
• Formally:
AB = {x | x  A  x  B}.
• {a, b, c}  {2, 3} =  disjoint
• {2, 4, 6}  {3, 4, 5} = {4}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Inclusion-Exclusion Principle

• How many elements are in AB?


|AB| = |A|  |B|  |AB|
Example:
{1, 2, 3}  {2, 3, 4, 5} = {1, 2, 3, 4, 5}
{1, 2, 3}  {2, 3, 4, 5} = {2, 3}
|{1, 2, 3, 4, 5}| = 3 + 4 – 2 = 5

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

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

e.g. {1, 2, 3, 4, 5, 6}  {2, 3, 5, 7, 9, 11} = {1, 4, 6, 7, 9, 11}


9/30/2017 (c)2001-2003, Michael P. Frank
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

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, ...}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Example
Let A and B are two subsets of a set E such that AB = {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

A = {1, 2, 7}, B = {1, 2, 3, 4},


E = {1, 2, 3, 4, 5, 7, 9}
9/30/2017 (c)2001-2003, Michael P. Frank
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

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}.

• AB = {1, 2, 3, 4, 5, 6, 7, 8}
• AB = {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}
• AB = {1, 2, 3, 6, 7, 8}

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Set Identities
• Identity: A = A = AU
• Domination: AU = U , A = 
• Idempotent: AA = A = AA
• Double complement: ( A )  A
• Commutative: AB = BA , AB = BA
• Associative: A(BC) = (AB)C
A(BC) = (AB)C
• Distribution: A(BC) = (AB)(AC)
A(BC) = (AB)(AC)
• 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

Proving Set Identities

To prove statements about sets of the form E1 = E2, where the


Es are set expressions, there are three useful techniques:
1. Proving E1  E2 and E2  E1 separately.
2. Using set builder notation and logical equivalences.
3. Using set identities.

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets
Example: Show AB = A B
Method 1: Prove E1  E2 and E2  E1

Assume x  AB
 x  AB by the definition of the complement
  x  AB 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

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Method 2: Set Builder Notation


Show that A B  A B

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

(c)2001-2003, Michael P. Frank 32


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Method 3 : Using Set Identities

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

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Method 3 : Using Set Identities

Show that ( B  C )  A  ( B  A)  (C  A).

(B  C)  A  (B  C)  A
 ( B  A)  (C  A)
 ( B  A)  (C  A).

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Method 4 : Membership Tables


Construct a membership table to show that the distributive
law holds:
A B C
0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0
0 1 0 0 0 1 0 0
0 1 1 1 1 1 1 1
1 0 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1
9/30/2017 (c)2001-2003, Michael P. Frank
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Computer Representation of Sets

• Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. The bit string (of


length |U| = 10) that represents the set A = {1, 3, 5, 6, 9}
has a one in the first, third, fifth, sixth, and ninth position,
and zero elsewhere. It is
1 0 1 0 1 1 0 0 1 0.

9/30/2017 (c)2001-2003, Michael P. Frank


Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

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

• A function f : A  B can also be defined as a subset of


A×B (a relation). This subset is restricted to be a relation
where no two elements of the relation have the same first
element.
• Specifically, a function f from A to B contains one, and
only one ordered pair (a, b) for every element a ∈ A.
xx  A  y[ y  B  ( x, y)  f ]
and
x, y1, y2 [(x, y1)  f  ( x, y2 )  f ]  y1  y2 

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

Functions may be specified in different ways:


– An explicit statement of the assignment
Students and grades example
– A formula.
f (x) = x + 1
– A computer program
A Java program that when given an integer n,
produces the nth Fibonacci Number.

9/30/2017 40
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Injections

Definition: A function f is said to be one-to-one, or


injective, if and only if f (a) = f (b) implies that a = b for
all a and b in the domain of f. A function is said to be an
injection if it is one-to-one. A B
a x
e.g. The function f (x) = x  1 from Z v
b
to Z is one-to-one since y
c
f (a) = f (b) z
d
a1=b1
w
a=b

9/30/2017 41
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Surjections

Definition: A function f from A to B is called onto, or


surjective, if and only if for every element b  B there is
an element a  A with f (a) = b. A function f is called a
surjection if it is onto. A B
a x

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

Definition: A function f is a one-to-one correspondence, or a


bijection, if it is both one-to-one and onto (surjective and
injective).
A B
a x

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

Showing that f is one-to-one or onto

9/30/2017 44
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Showing that f is one-to-one or onto


Example 1: Let f be the function from {a, b, c, d} to {1, 2, 3}
defined by f (a) = 3, f (b) = 2, f (c) = 1, and f (d) = 3. Is f an
onto function?
Solution: Yes, f is onto since all three elements of the codomain
are images of elements in the domain. If the codomain were
changed to {1, 2, 3, 4}, f would not be onto.

Example 2: Is the function f (x) = x2 from the set of integers to


the set of integers onto?
Solution: No, f is not onto because, for example, there is no
integer x with x2 = −1.
9/30/2017 45
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Inverse Functions

Definition: Let f be a bijection from A to B. Then the inverse


of f, denoted f 1, is the function from B to A defined as

No inverse exists unless f is a bijection. Why?

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.

Example 2: If f (x) = x2 and g(x) = 2x + 1, then

9/30/2017 50
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Composition

Example 3: Let f and g be functions from the set of integers to the


set of integers defined by f (x) = 2x + 3 and g(x) = 3x + 2. What
is the composition of f and g and also the composition of g and
f?
Solution:
f ∘ g (x) = f (g(x)) = f (3x + 2) = 2(3x + 2) + 3 = 6x + 7
g ∘ f (x) = g(f (x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11

Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics


Module #3 - Sets

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}.

Graph of f (n) = 2n + 1 from N to N Graph of f (x) = x2 from Z to Z

Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics


Module #3 - Sets

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.

Graphs of floor and ceiling from R to Z

Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics


Module #3 - Sets

Matrices*

• An m×n matrix is a rectangular array of mn objects


(usually numbers) arranged in m horizontal rows and n
vertical columns.

• An nn matrix is called a square matrix, whose order is n.

2 3 
5  1 2 1
  3 1
7 0   
32 22

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

Row and Column Order*

• The rows in a matrix are usually indexed 1 to m from top to


bottom. The columns are usually indexed 1 to n from left to
right. Elements are indexed by row, then column.

 a11 a12  a1n 


a a22 
 a2 n 
A  [aij ]   21

     
 
am1 am 2  amn 

9/30/2017 56
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Matrix Sums*

• The sum A + B of two matrices A, B (which must have the


same number of rows, and the same number of columns) is
the matrix given by adding corresponding elements.
• A + B = [aij + bij]

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*

For an mk matrix A and a kn matrix B, the product AB is


the mn matrix:
k 
AB  C  [cij ]   aipb pj 
 p 1 
i.e. The element (i, j ) of AB is given by the vector dot
product of the ith row of A and the jth column of B
(considered as vectors).

Note: Matrix multiplication is not commutative!

9/30/2017 58
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Matrix Product Example 1*

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

Matrix Product Example 2*

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*

• The identity matrix of order n, In , is the order-n matrix


with 1’s along the upper-left to lower-right diagonal and
0’s everywhere else.
• A In = A
1 0  0
0 1  0 1 if i  j
In      
     0 if i  j
 
0 0  1

9/30/2017 61
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Powers of Matrices*

• If A is an nn square matrix and p  0, then:


Ap  AAA ··· A (A0  In)
p times
3
 2 1  2 1  2 1  2 1
  1 0    1 0   1 0   1 0
     
 2 1  3 2  4 3
     
  1 0   2  1   3  2 

9/30/2017 62
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Matrix Transposition*

• If A is an mn matrix, then the transpose of A is the nm


matrix AT given by interchanging the rows and the
columns of A.
2 0
2 1 3 1  1 
A   AT

 0  1  2   
3  2

9/30/2017 63
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Symmetric Matrices*

• A square matrix A is symmetric if and only if AT = A.


• Which is symmetric?

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

All elements of a zero-one matrix are 0 or 1, representing


False & True respectively.
e.g.
1 1 0
A  0 1 0
1 0 1

9/30/2017 65
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics
Module #3 - Sets

Zero-One Matrix Operations

• The join of A and B (both mn zero-one matrices) is


A  B : [aij  bij].
• The meet of A and B (both mn zero-one matrices) is:
A  B  [aij  bij].

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

• Let A be an mk zero-one matrix and B be a kn zero-


one matrix,
• The Boolean product A ⊙ B of A and B is like normal
matrix product, but using  instead + and using  instead
.

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

• For a square zero-one matrix A, and any k  0, the kth


Boolean power of A is simply the Boolean product of k
copies of A.
A[k]  A ⊙ A ⊙ … ⊙ A

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

Let Find A[n] for all positive integers n.

9/30/2017 72
Arab Open University – Faculty of Computer Studies MT131 - Discrete Mathematics

Das könnte Ihnen auch gefallen