Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
9/1/2016
CISC 1400
Discrete Structures
Chapter 1
Sets
Fall 2016
CISC1400 Yanjun Li
1
1
Introduction to Discrete Mathematics
Continuous mathematics
Discrete mathematics
Fall 2016
Math based on the continuous number
line, or the real numbers (floating point
number).
Algebra, geometry, trigonometry, and
calculus
Working with distinct values.
Sets, sequences, Logic, relations,
functions, counting and probability.
CISC1400 Yanjun Li
2
1
9/1/2016
Discrete Math for Computer Science
A
digital computer contains a
finite amount of memory and
virtual storage space,
measured in bits (binary digits).
0/1 – one bit, 8 bits = 1 byte,
210 =1024 bytes = 1 kilobyte,
10242 bytes = 1 megabyte,
10243 bytes = 1 gigabyte,
10244 bytes = 1 terabyte
Fall 2016
CISC1400 Yanjun Li
3
What is Set?
A collection of objects
Example:
Fall 2016
Your
Your
Your
Your
Your
high school classmates.
high school friends.
family members.
MP3 playlist.
birthday gifts.
CISC1400 Yanjun Li
4
2
9/1/2016
Representation of Set
Set name and its
elements/members
Set A ={a, b, c, d, e, f}
6
elements: letter a, b, c, d, e, and f
Set B ={bob, 1,8,clown, hat}
5
Fall 2016
elements: bob, 1, 8, clown, hat.
CISC1400 Yanjun Li
5
Features of Set
Unordered :
Distinct objects:
Fall 2016
The order in which you list the
elements in a set does not matter.
For example, {1, 2, 3} = {3, 2, 1}
The elements within a set should not
be duplicated.
For example, wrong {a, b, c, d, a}
CISC1400 Yanjun Li
6
3
9/1/2016
Elements of a Set
{bob,1,8, {1,2,3}, a,
b, {clown, bob}, hat ,
4, {{{{1}}}}, clown}
Fall 2016
CISC1400 Yanjun Li
7
Membership Operator
Two key symbols that we will see:
x A means “x is an element of set A”
x A means “x is not an element of set A”
a {a, b, c}
1 {a, b, c}
Fall 2016
CISC1400 Yanjun Li
8
4
9/1/2016
Cardinality of A Set
The cardinality of a set A is the
number elements in the set, denoted
as |A|.
A set could be considered as a bag.
A set can be finite and have zero, one,
two, or any finite number of elements.
For example, A = {1,2,3}, |A|=3.
Fall 2016
CISC1400 Yanjun Li
9
Cardinality of A Set
A set has no elements, {}, is called
as the empty set or the null set, and
is represented by Ø. i.e., |{}|=0.
A set can be infinite and comprised
of an infinite number of elements.
Fall 2016
An empty bag!
Example?
CISC1400 Yanjun Li
10
5
9/1/2016
Exercises
1.
2.
A = {alpha, beta, gamma}
B = {-5, 0, 5, 10}
C = {{a,{b}}, {c,d}}
D = {Ø, 10,11}
E=Ø
F = {Ø}
Fall 2016
3.
4.
What is |A|?
3
What is
|B|+|C|
6
What is
|D|+|E|-|A|?
3+0-3=0
What is |F|?
1
CISC1400 Yanjun Li
11
Relations Between Sets
Two sets are equal when they have
the same elements.
Two sets are not equal
Fall 2016
A = {1,2,3}, B= {1,2,3}
A = B, A = A
A = {1,2,3}, C={1,2}
A≠C
CISC1400 Yanjun Li
12
6
9/1/2016
Relations Between Sets
If elements of set A are all contained in
set B, then A is a subset of B.
A = {1,2,3}, B ={1,2,3,4}
A ⊆ B, B ⊇ A
If there exists one element of set A that is
not an element of set B, then A is not a
subset of B.
Fall 2016
A = {1,2,3,5}, B ={1,2,3,4}
A ⊈ B, B ⊉ A
CISC1400 Yanjun Li
13
Relations Between Sets
If A is a subset of B and there is at least
one element in B that is not in A, then A is
a proper subset of B.
Fall 2016
A = {1,2,3}, B ={1,2,3,4}
A ⊂ B, B ⊃ A
CISC1400 Yanjun Li
14
7
9/1/2016
Commonly Used Sets
U: the universal set, containing all
possible elements that can be
placed into a set.
U: the set of all Fordham students
A: all freshman students,
B: all female students,
C: all science major students
A ⊆ U, A ⊂ U
B ⊆ U, B ⊂ U
C ⊆ U, C ⊂ U
Fall 2016
CISC1400 Yanjun Li
15
Venn Diagram
Fall 2016
A rectangle
represents
universal set, U
Circles within it
represents sets
CISC1400 Yanjun Li
A
16
8
9/1/2016
Subset
A is a subset of B.
A⊆ B
B
A
A is a proper subset of B.
A⊂ B
A is not a subset of B.
A⊈ B
C is not a subset of B.
C⊈B
C
B B
A
Fall 2016
CISC1400 Yanjun Li
17
Exercise
Find
out all subsets of set A={1,2}
Ø, {1}, {2}, {1,2}
Find
out all subsets of set
A={a,b,c}
Ø, {a}, {b}, {c}, {a,b},{a,c},{b,c},{a,b,c}
Find
out all proper subsets of set
A={a,b,c}
Ø, {a}, {b}, {c}, {a,b},{a,c},{b,c}
Fall 2016
CISC1400 Yanjun Li
18
9
9/1/2016
Commonly Used Sets
ℕ: the set of natural numbers (nonnegative integers)
ℕ = {0,1,2,3,4,5,6,…}
1 ∈ ℕ, - 10 ∉ ℕ, 3.1415 ∉ ℕ.
ℤ : the set of all integers, both positive and
negative
Fall 2016
ℤ = {… -3, -2, -1, 0, 1, 2, 3, …}
ℕ ⊆ ℤ, ℕ ⊂ ℤ
CISC1400 Yanjun Li
19
Commonly Used Sets
ℚ: the set of all rational numbers (i.e., all
numbers that can be written as a fraction)
ℝ: the set of all real numbers, which are
essentially all numbers that you can imagine.
Fall 2016
ℚ = { … 1/32, 1/31, …, 1/3, ½, … 2/32, 2/31}
π ∉ ℚ, √2 ∉ ℚ
ℚ ⊆ ℝ, ℚ ⊂ ℝ
CISC1400 Yanjun Li
20
10
9/1/2016
Variations
is the set of positive natural
numbers, { 1, 2, 3, 4, 5, …}
ℤ- is the set of negative integers
{-1,-2,-3,…}
ℚ>1 is the set of rational numbers that
are greater than 1
ℝ<10 is the set of real numbers that are
smaller than 10
ℕ+
Fall 2016
CISC1400 Yanjun Li
21
Set Builder Notation
To define a set A that contains all
positive even integers.
Fall 2016
A = {2, 4, 6, 8, 10, 12, 14, ….}
Set A is comprised of all positive even
integers.
A = {x: x is a positive even integer}
A = {x| x ∈ ℤ and x is positive and x is
even}
CISC1400 Yanjun Li
22
11
9/1/2016
Set Builder Notation
A = {x: x∈ℤ+ and x is even} is
translated to:
“All elements x such that x is an
element of the positive integers and
x is even”
x is the place holder stating that set A
will be comprised of some variable x.
Each of the following expressions is
used to enforce the constraint of x.
Fall 2016
CISC1400 Yanjun Li
23
Examples
{x : x 2 5}
{2.5}
{x : x 2k and k {1,2,3}} { 2 , 4 , 6 }
x
{x : x N and N }
3
{ 0 , 3 , 6 , 9 ,12 ,15 ,...}
{x | x 2 y and y Z }
{ 2 , 4 , 6 , 8 ,10 ,12 ,...}
Fall 2016
CISC1400 Yanjun Li
24
12
9/1/2016
Exercises
Answer the following questions:
A { x Q : x 2 1}
What is |A| ?
Are the following true ?
1.001 A
0.999 A
Find all elements of set B defined as
follows:
B { x : x N and x 4}
Fall 2016
CISC1400 Yanjun Li
25
True or False
1.
2.
3.
4.
5.
6.
If x ∈ A , and A ⊆ B, then x ∈ B
If A ⊆ B , and B ⊆ C , then A ⊆ C
If A ⊆ B , then |A| ≤ |B| when they
are both finite.
If |A| ≤ |B| , then A ⊆ B
{} has no subset.
Which of the following is true:
{1,2,3} {{1,2,3}}
{1,2,3} {{1,2,3}}
{1,2,3} {{{1,2,3}}}
Fall 2016
CISC1400 Yanjun Li
26
13
9/1/2016
Set Operation: Union
A B
Create a new set by combining all of
the elements of two sets, i.e.,
A B {x | x A or x B}
The part that has been
shaded is A ∪ B.
Fall 2016
CISC1400 Yanjun Li
27
Union Examples
A {1,2,3,4,5}
B {0,2,4,6,8}
C {0,5,10,15}
D {}
A B {0,1,2,3,4,5,6,8}
B A {0,1,2,3,4,5,6,8}
C D {0,5,10,15}
A C {0,1,2,3,4,5,10,15}
D B {0,2,4,6,8}
( A C ) ( D B ) {0,1,2,3,4,5,6,8,10,15}
Fall 2016
CISC1400 Yanjun Li
28
14
9/1/2016
Set Operation: Intersection
A B
Create a new set using the elements the
two sets have if common
A B {x | x A and x B}
The dark part is A ∩ B
Fall 2016
CISC1400 Yanjun Li
29
Intersection Examples
A {1,2,3,4,5}
B {0,2,4,6,8}
C {0,5,10,15}
D {}
A B
{ 2 , 4}
B A
{2,4}
CD
{}
AC
{5}
DB
{}
( A C ) ( D B ) {5}
Fall 2016
CISC1400 Yanjun Li
30
15
9/1/2016
Set Operation: Difference
A B
Create a new set that includes all elements
of set A, removing those elements that are
also in set B
A B {x | x A and x B}
A
Fall 2016
A-B
B
CISC1400 Yanjun Li
31
Difference Examples
A {1,2,3,4,5}
B {0,2,4,6,8}
C {0,5,10,15}
D {}
A B {1,3,5}
B A {0,6,8}
C D {0,5,10,15}
( A C ) ( D B ) {1,2,3,4}
Fall 2016
CISC1400 Yanjun Li
32
16
9/1/2016
Set Operation: Complement
Universal set: the set that includes
everything
The difference of U and A is also called
the complement of A:
Ac U A {x | x U and x A}
U
Colored area is
U-A
A
Fall 2016
CISC1400 Yanjun Li
33
Set operations example
Consider the following four subsets of the set U of all
students
A is the set of all computer science majors.
B is the set of all physics majors.
C is the set of all science majors.
D is the set of all female students.
Using set operations, describe each of the following in
terms of the sets A, B, C and D:
Fall 2016
Set of all male physics majors.
B ∩ Dc
Set of all students who are female or science majors.
D∪C
Set of all students not majoring in science.
Cc
CISC1400 Yanjun Li
34
17
9/1/2016
Power Set
P ( A)
is a set that consists of all possible
subsets of set A including Ø
P( A) {x : x A}
e.g. P({1})=?
List all subsets of {1}: {},{1}
Therefore P({1})={{},{1}}.
Fall 2016
CISC1400 Yanjun Li
35
Power Set Examples
A {1,2,3}
P ( A) {{1, 2 ,3}, {1, 2}, {1,3},
B {a, b, c, d }
{ 2 ,3}, {1}, { 2}, {3}, {}}
{{a, b, c, d }, {a, b, c}, {a, b, d },
P ( B ) {a, c, d }, {b, c, d }, {a, b}, {a, c},
{a, d }, {b, c}, {b, d }, {c, d }, {a},
{b}, {c}, {d }, {}}
Fall 2016
CISC1400 Yanjun Li
36
18
9/1/2016
Exercises on power set
1. A {a}
P( A)
2. C {a, 1 }
P(C)
Fall 2016
CISC1400 Yanjun Li
37
Cardinality of Power Set
If |A|=1, |P(A)|= ?
If |A|=2, |P(A)|=
Try P({a,b})
If set A have a certain number of subsets,
after we add one more element into A,
how many subsets A has now ?
Fall 2016
Try P({a})=
Every originally identified subsets are still valid
Add the new element into each of them, and
we get a new subset.
The number of subsets doubles !
CISC1400 Yanjun Li
38
19
9/1/2016
Cardinality of Power Set
Let an be the number of subsets that
a set of cardinality n has, then
a1 2
a
Fall 2016
n 1
We can find the closed form:
a
2a
n
n
2
n
A set of cardinality n has 2n subsets
If |A|=n, |P(A)|=2n
CISC1400 Yanjun Li
39
Cartesian Product (Cross Product)
A B
Create a new set consisting of all possible
ordered pairs where the first element is
from A, and second element is from B.
A B {( x, y ) : x A and y B}
AxB≠BxA
Fall 2016
CISC1400 Yanjun Li
40
20
9/1/2016
Example of Cartesian Product
I have two T-shirts: white, black
I have three jeans: black, blue, green
A={white shirt, black shirt}
B={black jean, blue jean, green jean}
All outfits I can make out of these ?
The set of all ordered-pairs, in the form
(T-shirt, jean)…
Fall 2016
CISC1400 Yanjun Li
41
Cartesian Product Examples
A {1,2,3}
B {a, b, c}
C {1,5}
A B {(1, a ), (1, b ), (1, c ), ( 2 , a ),
( 2 , b ), ( 2 , c ), ( 3, a ), ( 3, b ), ( 3, c )}
B A {(a,1), (a,2), (a,3), (b,1), (b,2),
(b,3), (c,1), (c,2), (c,3)}
C A {(1,1), (1,2), (1,3), (5,1),
(5,2), (5,3)}
BC
Fall 2016
{( a , 1), ( a ,5), (b , 1), (b ,5),
( c , 1), ( c ,5)}
CISC1400 Yanjun Li
42
21
9/1/2016
Cardinality of Cartesian Product
If A has m elements, B has n
elements, how many elements does
AxB have ?
Fall 2016
For every element of A, we pair it with
each of the n elements in B,. to get n
ordered pairs in AxB
So we can form n*m ordered pairs this
way
So |AxB| = m*n = |A|*|B|
This is where the name Cartesian
product comes
from.
CISC1400 Yanjun Li
43
22