CS202 CH 2
CS202 CH 2
Discrete Maths
U
Smith Green
Jones
Brown Moore
Subset
The set A is said to be a subset of set B if and
only if every element of set A is also an
element of set B.
We use this notation: A B
A B is true if and only if the following
quantification is true:
x ((x A) (x B))
Subset
Obviously, according to the preceding
definition, if A = B, it must be true that:
A B, and
B A.
Moreover, it should be self-evident that every
set is a subset of itself. That is:
AA
Proper Subset
However, if all of A’s elements are also in B,
but B has some elements in it that A does
not have (that is, A B), then we can be a
more precise and say that A is a proper
subset of B.
We use this notation: A B
A is a proper subset of B iff:
x (x A x B) x(x B x A)
Proper Subset
We can represent the subset relationship
using a Venn diagram. The following
diagram represents A B:
U
B
A
Subset
Interestingly enough, the empty set, , is a
subset of every other set (or, more
precisely, every nonempty set).
Your book gives a formal proof, but you
might think of it this way instead: if set S =
{a, b}, then it has 4 subsets –
{{a}, {b}, {ab}, }
Properties of Sets
One way to show that two sets are equal is to
show that each set is a subset of the other.
The Cardinality of a Set
Given a set S, and n N (that is, n is an
element of the set of natural numbers -- the
integers from 0 on up),
if there are exactly n distinct elements in S,
then:
S is a finite set, and
n is the cardinality of S
The cardinality of S is represented by |S|.
Properties of Sets
We now can see that every nonempty set S
must have at least two subsets:
and S
This is given as Theorem 1 in your book: For
every set S,
Part i: S
Part ii: S S
Powerset
A B
Set Intersection
• Intersection of two sets A and B is denoted
by AB
AB contains elements that are in both A
and B
AB = {x | x A x B} AB
A = {1,3,5}, B = {1,2,3}
AB = {1, 3} AA B
Disjoint Sets
A C
Cardinality of the Union of Sets
How many elements does AB have?
The number of elements in A plus the
number of elements in B, minus the
number of elements in both sets.
This can be written:
|AB| = |A|+|B|-|A B|
Set Difference
• Difference of two sets A and B is denoted
by AB
AB contains elements that are in A but not
in B.
AB = {x | x A x B} A-B
A = {1,3,5}, B = {1,2,3}
AB = {5}
A B
Complement of a Set
AA Identity
AUA
AUU Domination
A
AAA Idempotent
AAA
A =A Double Complement
Set Identities (Cont.)
ABBA Commutative
ABBA
A (B C) (A B) C Associative
A (B C) (A B) C
A (B C) (A B) (A C) Distributive
A (B C) (A B) (A C)
A (A B) A Absorption
A (A B) A
A B A B De Morgan's
A B A B
Examples
• Use set builder notation to prove that:
A B A B
( A B) C B B C
More Exercises
• Describe the following sets using the set builder
notation:
1. The set of all positive integers between 1 and 99.
2. A B
3. A B
4. A B
5. ( A B ) C
• Use set builder notation to prove .
A B A B
CS202
Discrete Maths
• Union: AB = {x | x A x B}
ABBA Commutative
• Intersection:
ABBA
AB = {x | x A x B}
• Difference:
A (B C) AB
(A B)= C{x | x Associative
A x B}
A (B C) (A B) C
• Complement: ĀB)=U
A (B C) (A - C)
(A A Distributive
A (B C) (A B) (A C)
• Identities similar
A (A B) A to those from logic, e.g.
Absorption
A (A B) A
A B A B De Morgan's
A B A B
Definitions
• Let A and B be sets. A function f from A to
B is an assignment of exactly one element
of B 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 of A.
• If f is a function from A to B, we write
f:AB
Definitions
• If f : A B, we say that A is the domain
of f and B is the codomain of f.
• If f(a) = b, we say that b is the image of a.
• The range of f is the set of all images of
elements of A.
Example
• Suppose that each student in a class is assigned a
letter grade from the set {A, B, C, D, F}. Let g
be the function that assigns a grade to a student.
Domain Codomain
Chavez • •A
Stokes • •B
Range
Dees • •C
Dozier • •D
Holland • •F
Example
• Consider a function f : Z Z that assigns the
square of an integer to this integer.
• How can you write this function? f(x) =
x2
• What is the domain of f ? The integers
• What is the codomain of f ? The integers
• What is the range of f ? The nonnegative
integers {0,1,4,9,..}
One-to-One Functions (injective)
• No value in the range is used by more than one
value in the domain.
• If f(x) = f(y), then x = y for all x and y in the
domain of f.
•1
a•
•2
b•
•3
c•
•4
• In other words x y (f(x) = f(y) x = y),
or using the contrapositive
x y (x ≠ y f(x) ≠ f(y))
One-to-One Functions
• Is the function f(x) = x2 from the set of integers
to the set of integers one-to-one?
x y (x2 = y2 x = y)?
• 12 = (-1)2 but 1 ≠ -1
• NO
• Is the function f(x) = x + 1 one-to-one?
x y (x + 1 = y + 1 x = y)?
• (x + 1) ≠ (y + 1) only when x ≠ y
• YES
Onto Functions (surjective)
• For every value in the codomain, there is a
value in the domain that is mapped to it.
•1
a•
•2
b•
•3
c•
d•
a f 1(b) b f(a)
A f B
F needs to be bijection
• If f is not a bijection (one-to-one correspondence)
– f is not injective (one-to-one)
– f is not surjective (onto)
• Why can’t we invert such a function?
We cannot assign to each element b in the
codomain a unique element a in the domain
such that f(a) = b, because:
– For some b there is either
• More than one a
• No such a
Inverse Functions
• Let f : Z Z be a function with f(x) = x + 1
• Is f invertible? Is f a bijection?
Is f one-to-one? YES
Is f onto? YES
So f is a one-to-one correspondence and is
therefore invertible.
• Then, what is its inverse? f(y) = y - 1
Inverse Functions
• Let f : Z Z be a function with f(x) = x2.
• Is f invertible?
• Is f a one-to-one correspondence. NO
• So f is not a one-to-one, and
• therefore, f is not invertible.
Compositions of Functions
• Let g : A B and f : B C.
• The composition of the functions f and g,
denoted by f g, is defined by:
f g(a) = f (g(a))
• f g can’t be defined unless the range of g
is a subset of the domain of f.
Example
• Let:
f(x) = 2x + 3
g(x) = 3x + 2
• Find f g(x):
2(3x +2) + 3
• Find g f(x):
3(2x + 3) + 2
Composition of Inverses
Let:
f(a) = b , so
f -1(b) = a
• Find f -1 f (a) :
a
• f f -1 (b)
b
Important functions – Floor
• Let x be a real number. The floor function
is the closest integer less than or equal to x.
• Examples:
½ =0
–½ = ?
3.1 = ?
7 =?
Important functions – Ceiling
• Let x be a real number. The ceiling function
is the closest integer greater than or equal to
x.
• Examples:
½ =1
–½ = ?
3.1 = ?
7=?
Ceiling
http://mathworld.wolfram.com/CeilingFunction.html
CS202
Discrete Maths
Lower limit
1 4 9 16 25
55
Geometric Series
• The sum of a geometric progression is
called a geometric series
• Commonly used
n
j 0 1 2 n
S ar ar ar ar ... ar
j 0
Double Summation
3 2
(i j )
i 1 j 1
2
(i j ) (i 1) (i 2) 2i 3
j 1
(2i 3) (2 1 3) (2 2 3) (2 3 3)
i 1
1 1 3 3
Useful Summation Formulae
Conclusion
• In this chapter we have covered:
– Introduction to sets
– Set operations
– Functions
– Sequences and summations