0% found this document useful (0 votes)
97 views48 pages

Lecture 1 - Sets and Sets Operations - Updated PDF

This document provides an overview of key concepts in discrete structures related to sets, including: 1) Definitions of sets, elements, membership, equality of sets, and important common sets like natural numbers. 2) Notation for describing membership and equality of sets. 3) Ways to describe sets including listing elements, using ellipses, and set builder notation. 4) Concepts like the empty set, singleton sets, subsets, proper subsets, finite and infinite sets, and cardinality. 5) Operations on sets like unions, intersections, and the power set.

Uploaded by

Migi Alucrad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views48 pages

Lecture 1 - Sets and Sets Operations - Updated PDF

This document provides an overview of key concepts in discrete structures related to sets, including: 1) Definitions of sets, elements, membership, equality of sets, and important common sets like natural numbers. 2) Notation for describing membership and equality of sets. 3) Ways to describe sets including listing elements, using ellipses, and set builder notation. 4) Concepts like the empty set, singleton sets, subsets, proper subsets, finite and infinite sets, and cardinality. 5) Operations on sets like unions, intersections, and the power set.

Uploaded by

Migi Alucrad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

1

CS100: DISCRETE STRUCTURES

Computer Sciences
Department
Lecture 1: Set and Sets Operations
Lecture Contents
2

 Sets Definition.
 Some Important Sets.
 Notation used to describe membership in sets.
 How to describe a set?
 Sets.
 Venn diagrams.
 Subset.
 Finite and Infinite Sets.
 Cardinality.
 Sets Operations.
 Exercises.

Computer Sciences Department


3 Sets and sets operations
Sets

Computer Sciences Department


Sets Definition:
4

 Set is the fundamental discrete structure on which all


other discrete structures are built.

 Sets are used to group objects together. Often, the


objects in a set have similar properties.
 A set is an unordered collection of objects.

 The objects in a set are called the elements or


members of the set

Computer Sciences Department


Some Important Sets:
5

The set of natural numbers:


N = {0, 1, 2, 3, . . .}
The set of integers:
Z = {. . . ,−2,−1, 0, 1, 2, . . .}
The set of positive integers:
Z+ = {1, 2, 3, . . .}
The set of fractions:
Q = {0,½, –½, –5, 78/13,…}
Q ={p/q | pЄ Z , qЄZ, and q≠0 }
The set of Real:
R = {–3/2,0,e,π2,sqrt(5),…}

Computer Sciences Department


Notation used to describe membership in sets
6

o a set A is a collection of elements.


o If x is an element of A, we write xA; If not: xA.
o xA Say: “x is a member of A” or “x is in A”.
o Note: Lowercase letters are used for elements, capitals for sets.
o Two sets are equal if and only if they have the same elements
A= B : x( x A  x B) also
o Two sets A and B are equal if A  B and B  A.
o So to show equality of sets A and B, show:
 AB
 BA

Computer Sciences Department


Notation used to describe membership in sets
7

 The sets {1,3,5} and {3,5,1} are equal , because they have
the same elements.

Yes , because they have the same elements.

Computer Sciences Department


How to describe a set?
8

1. List all the members of a set, when this is


possible. We use a notation where all members
of the set are listed between braces. { }
Example :
 {dog, cat, horse}
 The set O of odd positive integers less than 10 can be
expressed by
O={1,3,5,7,9}

Computer Sciences Department


How to describe a set?
9

2. Sometimes the brace notation is used to describe a


set without listing all its members. Some members
of the set are listed, and then ellipses (...) are used
when the general pattern of the elements is
obvious.
Example:
 The
set A of positive integers less than 100 can be
denoted by
A={1, 2, 3, . . . , 99}

Computer Sciences Department


How to describe a set?
10

3. Another way to describe a set is to use set builder


notation. We characterize all those elements in the
set by stating the property or properties they must
have to be members.
Example:
 theset O of all odd positive integers less than 10 can
be written as:
O = {x | x is an odd positive integer <10} or, specifying
the universe as the set of positive integers, as
O = {x  Z+ | x is odd and x<10}.
Computer Sciences Department
Sets:
11

 The Empty Set (Null Set)


We use  to denote the empty set and can also be
denoted { }, i.e. the set with no elements.
Example:
 the set of all positive integers that are greater than
their squares is the null set.

 Singleton set
A set with one element is called a singleton set.

Computer Sciences Department


Sets:
12

 Computer Science
 Note that the concept of a data type, or type, in
computer science is built upon the concept of a set. In
particular, a data type is the name of a set, together
with a set of operations that can be performed on
objects from that set.
Example:
 Boolean is the name of the set {0, 1} together with
operators on one or more elements of this set, such as
AND, OR, and NOT.

Computer Sciences Department


Venn diagrams:
13

 Sets can be represented graphically using Venn


diagrams.
 In Venn diagrams the universal set U, which contains
all the objects under consideration, is represented
by a rectangle.
 Inside this rectangle, circles or other geometrical
figures are used to represent sets.
 Sometimes points are used to represent the
particular elements of the set.
Computer Sciences Department
Venn diagrams:
14

Example:
 A Venn diagram that represents V = {a, e, i, o, u}

the set of vowels in the English alphabet

Computer Sciences Department


Subset:
15

 The set A is said to be a subset of B if and only if every


element of A is also an element of B.
 We use the notation A  B to indicate that A is a subset of the
set B.
 We see that A  B if and only if
the quantification
x (x  A → x  B) is true.
Examples:
 The set of all odd positive integers less than 10 is subset of the set of
all positive integers .
 The set of rational numbers is subset of the set of real numbers .

Computer Sciences Department


Subsets:
16

 For every set S,


S
SS

Proper subset:
When a set A is a subset of a set B but A ≠ B,
A  B, and A  B
We write A  B and say that A is a proper subset of B
 For A  B to be true, it must be the case that
x ((x  A)  (x  B))  x ((x  B)  (x  A))

Computer Sciences Department


Subsets:
17

Quick Examples:
{1,2,3}  {1,2,3,4,5}
{1,2,3}  {1,2,3,4,5}

 Is   {1,2,3}? Yes!
 Is   {1,2,3}? No!
 Is   {,1,2,3}? Yes!
 Is   {,1,2,3}? Yes!

Computer Sciences Department


Subsets:
18

Quiz Time:
 Is {x}  {x,{x}}?
Yes!
 Is {x}  {x,{x}}? Yes!
 Is {x}  {x}? Yes!
 Is {x}  {x}? No!

Computer Sciences Department


Finite and Infinite Sets:
19

 Finite set
Let S be a set. If there are exactly n distinct elements in S
where n is a nonnegative integer, we say that S is a finite
set and that n is the cardinality of S.
 The cardinality of S is denoted by |S|.
| A  B | = | A| + | B| - | A  B|

N.B. We only count


unrepeated elements
 Infinite set
A set is said to be infinite if it is not finite. For example,
the set of positive integers is infinite.
Computer Sciences Department
Cardinality:
20

Find
 S = {1,2,3}, |S| = 3.

 S = {3,3,3,3,3}, |S| = 1
 S = , |S| = 0.

 S = { , {}, {,{}} }, |S| = 3.


 S = {0,1,2,3,…}, |S| is infinite

Computer Sciences Department


Sets:
21

Ways to Define Sets:


 Explicitly: {John, Paul, George, Ringo}
 Implicitly: {1,2,3,…}, or {2,3,5,7,11,13,17,…}

 Set builder: { x : x is prime }, { x | x is odd }.

In general { x : P(x) is true }, where P(x) is some


description of the set.

Computer Sciences Department


The power of a set:
22

 Many problems involve testing all combinations of


elements of a set to see if they satisfy some property.
 To consider all such combinations of elements of a set S,
we build a new set that has as its members all the
subsets of S.
 Given a set S, the power set of S is the set of all subsets
of the set S.
 The power set of S is denoted by P(S).
 if a set has n elements , then the power has 2n elements.

Computer Sciences Department


The power of a set:
23

Example:
What is the power set of the set {0, 1, 2}?
P({0,1,2}) is the set of all subsets of {0, 1, 2}
P({0,1,2})= { , {0},{1},{2},{0,1},{0,2},{1,2},{0,1,2}}
What is the power set of the empty set? What is the
power set of the set {} ?
P()= {} N.B. the power set of any subset
has at least two elements
P({})= {,{}} The null set and the set itself

Computer Sciences Department


The Power Set:
24

Quick Quiz:
Find the power set of the following:
 S = {a}, P(S)= {, {a}}.

 S = {a,b}, P(S) = {, {a}, {b}, {a,b}}.

 S = , P(S) = {}.

 S = {,{}}, P(S) = {, {}, {{}}, {,{}}}.

Computer Sciences Department


Cartesian Products:
25

 The order of elements in a collection is often


important.
 Because sets are unordered, a different structure is
needed to represent ordered collections.
 This is provided by 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 an as its nth element.

Computer Sciences Department


Cartesian Products:
26

Let A and B be sets. The Cartesian product of A and B,


denoted by A×B, is the set of all ordered pairs (a, b),
where aA and bB.
A×B = {(a, b) | a  A  b  B}.
A1×A2×…×An={(a1, a2,…, an) | aiAi for i=1,2,…,n}.
A×B not equal to B×A
Example :
A={1,2} , B={3,4}
 A×B={(1,3),(1,4),(2,3),(2,4)}
 B×A={(3,1),(3,2),(4,1),(4,2)}

Computer Sciences Department


Cartesian Products:
27

Example:
What is the Cartesian product A × B × C, where
A = {0, 1}, B = {1, 2}, and C = {0, 1, 2}?

AxBxC = {(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)}

Computer Sciences Department


28 Sets and sets operations
Sets Operations

Computer Sciences Department


UNION:
29

The union of two sets A and B is:


A  B = { x : x  A v x  B}
 If A = {1, 2, 3}, and B = {2, 4}, then

 A  B = {1,2,3,4}
B
A

Computer Sciences Department


Intersection:
30

The intersection of two sets A and B is:


A  B = { x : x  A  x  B}
 If A = {Charlie, Lucy, Linus}, and B = {Lucy, Desi},
then

 A  B = {Lucy} B
A

Computer Sciences Department


Intersection:
31

If A = {x : x is a US president}, and

B = {x : x is deceased}, then

A  B = {x : x is a deceased US president}

B
A

Computer Sciences Department


Disjoint:
32

If A = {x : x is a US president}, and B = {x : x is in this room},


then

A  B = {x : x is a US president in this room} =

B
A
Sets whose intersection
is empty are
called disjoint sets

Computer Sciences Department


Complement:
33

The complement of a set A is:


ഥ = A’ = { x : x  A}
A
AB=BA
If A = {x : x is bored}, then
ഥ = {x : x is not bored} = 
A

U =U
A
and

U=

Computer Sciences Department


Difference:
34

The set difference, A - B, is:


U
A
B

A-B={x:xAxB}
A-B=AB

Computer Sciences Department


Symmetric Difference:
35

The symmetric difference, A  B, is:


A  B = { x : (x  A  x  B) v (x  B  x  A)}

= (A - B)  (B - A)

U
Like
A “exclusive or”
B

Computer Sciences Department


Symmetric Difference:
36

Example:
Let A = {1,2,3,4,5,6,7} B = {3,4,p,q,r,s}
Then we have
A  B=
{1,2,3,4,5,6,7,p,q,r,s}
AB=
{3,4}
We get AB= {1,2,5,6,7,p,q,r,s}
Computer Sciences Department
TABLE 1: Set Identities
Identity Name
AU =A
Identity laws
37
AU=A
AU U=U
Domination laws
A=
A  A=A
Idempotent laws
AA=A
(A) = A Complementation laws
A B=B  A
Commutative laws
AB=BA
A  (B  C) = (A  B)  C
Associative laws
A  (B  C) = (A  B)  C
A  (B U C) = (A  B)  (A  C)
Distributive laws
A  (B  C) = (A U B)  (A U C)
AUB=AB
De Morgan’s laws
AB=AUB
A  (A  B) = A
Absorption laws
A  (A  B) = A
A  A=U
Complement lawsDepartment
Computer Sciences
AA=
38

Let’s proof one of the Identities Using a Membership Table


A  (B  C) = (A  B)  (A  C)
TABLE 2: A Membership Table for the Distributive Property
A B C B  C A  (B  C) AB AC (A  B)  (A  C)
1 1 1 1 1 1 1 1
1 1 0 1 1 1 0 1
1 0 1 1 1 0 1 1
1 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0
Computer Sciences Department
Exercise 1:
39

List the members of these sets:


a) {x | x is a real number such that x² = 1}
{-1, 1}
b) {x | x is a positive integer less than 12}
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
c) {x | x is the square of an integer and x < 100}
{0, 1, 4, 9, 16, 25, 36, 49, 64, 81}
d) {x | x is an integer such that x² = 2}

Computer Sciences Department


Exercise 2:
40

Determine whether each of these pairs of sets are


equal:

a) {4, 3, 3, 7, 4, 7, 7, 3}, {4, 3, 7}


Yes
b) {{1}}, {1, {2}}
No
c) , {}
No

Computer Sciences Department


Exercise 3:
41

 Determine whether these statements are true or false.


a) 0 ∈ ∅ False
b) ∅ ∈ {0} False
c) {0} ⊂ ∅ False
d) ∅ ⊂ {0} True
e) {0} ∈ {0} False
f) {0} ⊂ {0} False
g) {∅} ⊆ {∅} True

Computer Sciences Department


Exercise 4:
42

 Use a Venn diagram to illustrate the relationships


𝐀 ⊂ 𝑩 𝒂𝒏𝒅 𝑩 ⊂ 𝑪 .

A B C

Computer Sciences Department


Exercise 5:
43

 What is the cardinality of each of these sets?


a) {a}
 1

b) {{a}}
 1

c) {∅, {∅}}
 2

d) {a, {a}, {a, {a}}}


 3

Computer Sciences Department


Exercise 6:
44

Let A = {1, 2, 3, 4, 5} and B = {0, 3, 6}. Find :


a) A ∪ B
 {0, 1, 2, 3, 4, 5, 6}
b) A ∩ B
 {3}
c) A – B
 {1, 2, 4, 5}
d) B – A
 {0, 6}
Computer Sciences Department
Exercise 7:
45

For U = {1, 2,3, 4,5,6,7,8,9,10} let A = {1, 2,3,4,5} , B


= {1,2, 4,8}, C = {1, 2,3,5,7}, and D = {2, 4,6,8} .
Determine each of the following:
a) (A∪B)∩C = {1,2,3,5}
b) A∪(B∩C)= {1,2,3,4,5}
c) C ∪ D = {1, 2,3, 4, 5, 6, 7, 8}
d) (A∪B)−C = {4,8}
e) A∪(B−C)= {1,2,3,4,5,8}
f) (B −C)−D = {}
g) B−(C−D)= {2,4,8}
h) (A∪B)−(C ∩D)= {1,3,4,5,8}
i) A ⊕ B = {3,5,8}
Computer Sciences Department
Exercise 8:
46

 Draw the VENN DIAGRAM of these sets and


find (A∪B)−C and B′

A B
B

Computer Sciences Department


Exercise 9:
47

Given the Universal set U={positive integers not larger than 12},
and the sets : A={positive integers not more than 6}
B={3,4,6,7} , C={5,6,7,8,9,10} , Find :
i) A U B =
{1,2,3,4,5,6,7}
ii) | A−B |=
3
iii) P(A‐B)=Power set of (A‐B)=

{ф,{1},{2},{5},{1,2},{1,5},{2,5},{1,2,5}}

Computer Sciences Department


48

Refer to Chapter 2 for further reading

Computer Sciences Department

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy