02-Basic Structures (SF)
02-Basic Structures (SF)
Basic Structures
Sets, Functions
Sequences, and Sums
Objectives
Sets
Set operations
Functions
Sequences
Summations
2.1- Sets
An unordered collection of objects
The objects in a set are called the elements, or members.
A set is said to contain its elements.
Some important sets in discrete mathematics
N = { 0,1,2,3,4,… }
Z = { … , -2,-1,0,1,2,…} Z+ = {1,2,…}
R: the set of real numbers G. Cantor
p
Q r p Z , 0 q Z
q
V a, u , o, i, e
aV : a is an element of the set V // a belongs to V
cV: a is not an element of V
2.1- Sets
Definitions:
Finite set: Set has n elements, n is a nonnegative integer.
A set is an infinite set if it is not finite.
Cardinality of a set |S|: Number of elements of S.
Examples:
A 2, 4,1 finite set A 3
0,1, 2,... infinite set
B 0,1,...,8,9 finite set B 10
C a, b finite set C 2
..., 2, 1,0,1, 2,... infinite set
2.1- Sets
Definitions:
: empty set (null set), the set with no element.
What is ?
0
1
2.1- Sets
Definitions:
Two sets are equal they have the same elements
A = B if and only if x (xA x B)
Ex:
Proof:
i ) (x ) False
So x x x S True
ii) x x S x S True
Power Sets
Given a set S, power set P(S) of S is a set of all
subsets of the set S.
If the set S has n elements, then the power set P(S)
has 2n elements. P S 2 S
Note that:
S
S
For non-empty sets A and B:
A B A B B A
A B A B
Cartesian Products
11. Let A = {a, b, c}, B = {x, y}, and C = {0, 1}. Find
a) A × B. b) B × A.
c) A × B × C. d) (A × B) × C.
a) A B a, x , a, y , b, x , b, y , c, x , c, y
b) B A x, a , x, b , x, c , y , a , y , b , y , c
c) A B C a, x,0 , a, x,1 , a, y,0 , a, y,1,
b, x,0 , b, x,1, b, y,0 , b, y,1,
c, x,0 , c, x,1, c, y,0 , c, y,1
d) A B C a, x ,0 , a, x ,1 , a, y ,0 , a, y ,1,
b, x ,0 , b, x ,1, b, y ,0 , b, y ,1,
c, x ,0 , c, x ,1, c, y ,0 , c, y ,1
2.2- Set Operations
The Union of sets A and B, denoted by A B
A B x x A x B
Intersection : A B x x A x B
A A Complementation law
A B = B A A B = B A Commutative laws
A (B C) = (A B) C Associative laws
A (B C) = (A B) C
A (B C) = (A B) (A C) Distributive laws
A (B C) = (A B) (A C)
AB =AB A B = A B De Morgan laws
A (A B) = A A (A B) = A Absorption
AA =U A A = Complement laws
Generalized Unions and Intersections
n
A1 A2 A3 ... An Ai x x Ai , i 1, 2,..., n
i 1
n
A1 A2 A3 ... An Ai
i 1
x x A1 x A2 x A3 ... x An
Computer Representation of Sets
• A = {1,3,5,7,9 } A = “1010101010”
• B = {1,8,9} B = “1000000110”
A B 1010101010 1000000110
1 2 3 4 5 6 7 8 9 10
1 0 1 0 1 0 1 0 1 0
1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 1 0
A B 1000000010
A B 1,9
Computer Representation of Sets
• A = {1,3,5,7,9 } A = “1010101010”
• B = {1,8,9} B = “1000000110”
A B 1010101010 1000000110
1 2 3 4 5 6 7 8 9 10
1 0 1 0 1 0 1 0 1 0
1 0 0 0 0 0 0 1 1 0
1 0 1 0 1 0 1 1 1 0
A B 1010101110
A B 1,3,5,7,8,9
Computer Representation of Sets
• A = {1,3,5,7,9 } A = “1010101010”
• B = {1,8,9} B = “1000000110”
A B 1010101010 1000000110
1 2 3 4 5 6 7 8 9 10
1 0 1 0 1 0 1 0 1 0
1 0 0 0 0 0 0 1 1 0
0 0 1 0 1 0 1 1 0 0
A B 0010101100
A B 3,5,7,8
2.3. Functions / Mappings /Transformations…
f : , f x x 2 True
f : , f x x False
2.3. Functions / Mappings /Transformations…
Example:
2x 5
c) f : , f x True
7
d) f : , f x
2 x 5 2
True
7 2x
Some Important Functions
Floor function
f: → such that f(x)= x = largest integer that less than or
equal to x, x x
Ceiling function
f: → such that f(x)= x = smallest integer that greater than
or equal to x, xx
Ex:
f : , f x x 3 is one-to-one
f : , f x x 2 is not one-to-one (we have f(-1) = f(1))
Onto/ Surjective functions
A function f from A to B is called onto, or surjective, iff
for every element b in B there is an element a in A with f a . b
Ex: f : , f x x 1 is onto
3
f : , f x x 2 1 is not onto
because 0 B, x A : f x 0
One-to-one Correspodent/
Bijective Functions
Function f is a one-to-one corespondence or a
bijection if it is both one-to-one and onto.
bijection
A B
One-to-one Correspodent/
Bijective Functions
Inverse Functions
Let f is a bijection from A to B. The inverse function,
1
denoted by f , of f is the function that assigns to an
element b belonging to B the unique element a in A such
that f a b . Hence f b a when f a b .
1
Inverse Functions
Ex1: Let f be the function from {a, b, c, d} to {1, 2, 3, 4} such
that f(a) = 4, f(b) = 1, f(c) = 3 and f (d) = 2. Is f invertible, and if
it is, what is its inverse?
g o f x g f x
f o g x f g x
Composition of Functions
Ex:
f : , f x x 1
g : , g x x 2
f o g x f g x f ( x2 ) x2 1
go f x g f x g x 1 x 1 2
f o f x f f x f ( x 1) ( x 1) 1 x 2
g o g x g g x g x
2
2 2
x x4
2.4- Sequences
Sequence: a1, a2, a3,…, an,…
Ex: 1,3,5,8 : Finite sequence
Ex: 1, 1, 2, 3, 5, 8, 13,… : Infinite sequence
A sequence is a function from a subset of integers to a set S.
an : image of the integer n
ai : a term of the sequence
1
an :
Ex: The sequence
n
1 1 1 1
1, , , , ,
2 3 4 5
2.4- Sequences
Geometric progression
f(n) = arn a, ar, ar2, ar3, …, arn
Arithmetic progression
f(n) = a + nd a, a+d, a+2d, … , a+nd
a: initial term,
r: common ratio, a real number
d: common difference, real number
Do yourself
bn= (-1)n , n>=0 cn= 2(5)n , n>=0
tn= 7-3n, n>=0 an= -1 + 4n, n>=0
Summations
n
am am 1 am 2 ... an a j j m a j m j n a j
n
j m
a : Sequence // 1 + 2 +3+4+…+n
j : Index of summation long sum1 ( int n) // n additions
{ long S=0;
m: Lower limit for (int i=1; i<=n; i++) S+= i;
n : Upper limit return S;
}
// 1 addition, 1 multiplication, 1 division
long sum2 (int n)
{ return ((long)n) * (n+1)/2;
}
Summations
Ex1:
Ex2:
Summations
Summation of arithmetic series:
n a1 an an a1
S where n 1
2 d
S
a 1 rn if r 1
1 r
Cardinality
Cardinality = number of elements in a set.
The sets A and B have the same cardinality if and only if
there is a one-to-one correspondence from A to B
A set that is either finite or has the same cardinality as
the set of positive integers is called countable.
A set that is not countable is called uncountable.
When a infinite set S is countable, we denote the
cardinality of S is |S|= 0( אaleph null)
For example, |0 אbecause is countable and infinite
but is uncountable and infinite, and we say |0א
Examples p.159, 160
sets countable uncountable cardinality
{a, b, …, z}, {x| x5 - 3x2 – 11 = 0}, … <
{0, 2, 4, …, } 0א
N, Z+, Z, Q, ZZ, … 0א
{x| 0 < x < 1}, R,… 20א
Review chapter 2
Two sets are equal they have the same elements
A B: the set A is a subset of the set B
A B if and only if x (xA x B)
A B: A is a proper subset of B
A B if and only if (A B) ^ (A ≠ B)
P S 2
S
A1 A2 An A1 A2 An
a b f a f b
Inverse Functions: f x y f 1 y x
Composition of Functions: g o f x g f x
f o g x f g x
Summation of arithmetic series:
n a1 an an a1
S where n 1
2 d
S
a 1 rn if r 1
1 r
Thanks