SlideShare a Scribd company logo
9/21/2023 CS 201 1
CS201: Data Structures and
Discrete Mathematics I
Basic Set Theory
9/21/2023 CS 201 2
Sets
• A set is a collection of distinct objects.
• For example (let A denote a set):
A = {apple, orange, grape}
A = {1, 2, 3, 4, 5}
A = {1, b, c, d, e, f}
A = {(1, 2), (3, 4), (9, 10)}
A = {<1, 2, 3>, <3, 4, 5>, <6, 7, 8>}
A = a collection of anything that is meaningful.
9/21/2023 CS 201 3
Members and Equality of Sets
• The objects that make up a set are called
members or elements of the set.
• Two sets are equal iff they have the same
members.
– That is, a set is completely determined by its
members.
– Order and repetition do not matter in a set.
9/21/2023 CS 201 4
Set notations
• The notation of {...} describes a set. Each
member or element is separated by a comma.
– E.g., S = {apple, pear, grape}
– S is a set
– The members of S are: apple, pear, grape
• Order and repetition do not matter in a set.
• The following expressions are equivalent:
– {1, 3, 9}
– {9, 1, 3}
– {1, 1, 3, 3, 9}
9/21/2023 CS 201 5
The membership symbol  and the
empty set 
• The fact that x is a member of a set S can be
expressed as
– x  S
– Reads:
• x is in S, or
• x is a member of S, or
• X belongs to S
• An example, S = {1, 2, 3}, 1  S, 2  S, 3  S
• The negation of  is written as  (is not in).
• The empty set is a set without any element
– Denoted by {} or 
– For any object x, x  
9/21/2023 CS 201 6
Defining a Set by membership
properties
• Notation
o S = {x  T | P(x)} (or S = {x | x  T and P(x)})
o The members of S are members of an already
known set T that satisfy property P.
• An example:
o Let Z be the set of integers
o Let Z+ be the set of positive integers.
o Z+ = {x  Z | x > 0}
9/21/2023 CS 201 7
Sets of numbers
• Z = The set of all integers
Z = {…, -2, -1, 0, 1, 2, …}
• Z+ = The set of positive integers
Z+ = {1, 2, 3…} = {x | x  Z and x > 0} = {x  Z | x > 0}
• Z- = The set of negative integers
Z- = {…, -3, -2, -1} = {-1, -2, -3…} = {x  Z | x < 0}
• R = The set of all real numbers
• Q = the set of all rational numbers
Q = {x  R | x = p/q and p, q  Z and q  0}
• We can use “;” to replace “and”
9/21/2023 CS 201 8
Subsets
• A is a subset () of B, or B is a superset of
A iff every member of A is a member of B.
o A  B iff for all x if x  A, then x  B
• An example:
o (-2, 0, 6}  {-3, -2, -1, 0, 1, 3, 6}
• Negation: A is not a subset of B or B is not
a superset of A iff there is a member of A
that is not a member of B
o A  B iff there exist x, x  A, x  B
9/21/2023 CS 201 9
Obvious subsets
– S  S
–   S
9/21/2023 CS 201 10
Proper subsets
• A is a proper subset () of B, or B is a
proper superset of A iff A is a subset of B
and A is not equal to B.
o A  B iff A  B and A  B
• Examples:
o {1, 2, 3}  {1, 2, 3, 4, 5}
o Z+  Z  Q  R
o If S   then   S
9/21/2023 CS 201 11
Power sets
• The set of all subsets of a set is called the power
set of the set
• The power set of S is denoted by P(S).
• Example:
– P() ={}
– P({1, 2}) = {, {1}, {2}, {1, 2}}
– P(S) = {, …, S}
– What is P({1, 2, 3})?
• How many elements does the power set of S
have? Assume S has n elements. 2 ^ n
9/21/2023 CS 201 12
 and  are different
• Examples:
1  {1} is true
1  {1} is false
{1}  {1} is true
• Which of the following statement is true?
S  P(S)
S  P(S)
The 1st is true
9/21/2023 CS 201 13
Mutual inclusion and set equality
• Sets A and B have the same members iff
they mutually include
– A  B and B  A
• That is, A = B iff A  B and B  A
• Mutual inclusion is very useful for proving
the equality of sets
• To prove an equality, we prove two subset
relationships.
9/21/2023 CS 201 14
Universal sets
• Depending on the context of discussion
– Define a set of U such that all sets of interest
are subsets of U.
– The set U is known as a universal set
• Examples:
– When dealing with integers, U may be Z.
– When dealing with plane geometry, U may be
the set of points in the plane
9/21/2023 CS 201 15
Venn diagram
• Venn diagram is used to visualize
relationships of some sets.
• Each subset (of U, the rectangle) is
represented by a circle inside the
rectangle.
9/21/2023 CS 201 16
Set operations
• Let A, B be subsets of some universal set U.
• The following set operations create new sets
from A and B.
• Union:
A  B = {x  U | x  A or x  B}
• Intersection:
A  B = {x  U | x  A and x  B}
• Difference:
A  B = A  B= {x  U | x  A and x  B}
• Complement
A = U  A = {x  U | x  A}
9/21/2023 CS 201 17
Set union
• An example
{1, 2, 3}  {1, 2, 4, 5} = {1, 2, 3, 4, 5}
The venn diagram
1
2
3 4
5
9/21/2023 CS 201 18
Set intersection
• An example
{1, 2, 3}  {1, 2, 4, 5} = {1, 2}
The venn diagram
1
2
3 4
5
9/21/2023 CS 201 19
Set difference
• An example
{1, 2, 3} - {1, 2, 4, 5} = {3}
The venn diagram
1
2
3 4
5
9/21/2023 CS 201 20
Set complement
• The venn diagram
9/21/2023 CS 201 21
Basic set identities (equalities)
• Commutative laws
A  B = B  A
A  B = B  A
• Associative laws
(A  B)  C = A  (B  C)
(A  B)  C = A  (B  C)
• Distributive laws
A  (B  C) = (A  B)  (A  C)
A  (B  C) = (A  B)  (A  C)
9/21/2023 CS 201 22
Basic set identities (cont …)
• Identity laws
  A = A   = A
A  U = U  A = A
• Double complement law
(A’)’ = A
• Idempotent laws
A  A = A
A  A = A
• De Morgan’s laws
(A  B)’ = A’  B’
(A  B)’ = A’  B’
Basic set identities (cont …)
• Absorption laws
A  (A  B) = A
A  (A  B) = A
• Complement law
(U)’ = 
’ = U
• Set difference law
A – B = A  B’
• Universal bound law
A  U = U
A   = 
9/21/2023 CS 201 23
9/21/2023 CS 201 24
Infinite sets
• In a finite set, we can always designate one element as
the first member, s1, another element as the second
member, s2 and so on. If there are k elements in the set
we can list them as
– s1, s2, …, sk
• A set that is not finite is called an infinite set.
• If a set is infinite, we may still be able to select a first
element s1, a second element s2 and so on:
– s1, s2, …
• Both above sets are countable.
• Countable does not mean we can give a total number, but
means that we can say, “here is the first one” and “here is
the second one” and so on.
9/21/2023 CS 201 25
Countable sets: examples
• The set of positive integer numbers are
countable.
• The set of positive rational numbers are
countable
9/21/2023 CS 201 26
Uncountable sets
• There are also some sets that are
uncountable.
– The set is so large, and there is no way to
count out the elements.
• One example: The set of real numbers
between 0 and 1 is uncountable.
• A computer can only manage finite sets.
9/21/2023 CS 201 27
Summary
• Sets are extremely important for Computer
Science.
• A set is simply an unordered list of objects.
• Set operations: union, intersection,
difference.

More Related Content

Similar to 3a-Set theory.ppt

SET THEORY
SET THEORYSET THEORY
SET THEORY
Lena
 
Sets
SetsSets
Sets functions-sequences-exercises
Sets functions-sequences-exercisesSets functions-sequences-exercises
Sets functions-sequences-exercises
Roshayu Mohamad
 
SET AND ITS OPERATIONS
SET AND ITS OPERATIONSSET AND ITS OPERATIONS
SET AND ITS OPERATIONS
RohithV15
 
Introduction to set theory
Introduction to set theoryIntroduction to set theory
Introduction to set theory
Nittaya Noinan
 
Sets (1).ppt
Sets (1).pptSets (1).ppt
Sets (1).ppt
AeronnJassSongalia
 
Blackbox task 2
Blackbox task 2Blackbox task 2
Blackbox task 2
blackbox90s
 
Sets (Mathematics class XI)
Sets (Mathematics class XI)Sets (Mathematics class XI)
Sets (Mathematics class XI)
VihaanBhambhani
 
Sets in Maths (Complete Topic)
Sets in Maths (Complete Topic)Sets in Maths (Complete Topic)
Sets in Maths (Complete Topic)
Manik Bhola
 
Set theory
Set theorySet theory
Set theory
Shiwani Gupta
 
Mathematics Sets and Logic Week 1
Mathematics Sets and Logic Week 1Mathematics Sets and Logic Week 1
Mathematics Sets and Logic Week 1
Jasmine Jesse
 
Set Theory
Set TheorySet Theory
Set Theory
itutor
 
Lecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptxLecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptx
RydaS1
 
6.1_set.pptx
6.1_set.pptx6.1_set.pptx
6.1_set.pptx
irrfanalikhan
 
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptxMoazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
KhalidSyfullah6
 
4898850.ppt
4898850.ppt4898850.ppt
4898850.ppt
UsamaManzoorLucky1
 
Mkk1013 chapter 2.1
Mkk1013 chapter 2.1Mkk1013 chapter 2.1
Mkk1013 chapter 2.1
ramlahmailok
 
6401-Unit 2.pptx
6401-Unit 2.pptx6401-Unit 2.pptx
6401-Unit 2.pptx
hani ubaid
 
Chap2_SETS_PDF.pdf
Chap2_SETS_PDF.pdfChap2_SETS_PDF.pdf
Chap2_SETS_PDF.pdf
RatipornChomrit
 
Final maths presentation on sets
Final maths presentation on setsFinal maths presentation on sets
Final maths presentation on sets
Rahul Avicii
 

Similar to 3a-Set theory.ppt (20)

SET THEORY
SET THEORYSET THEORY
SET THEORY
 
Sets
SetsSets
Sets
 
Sets functions-sequences-exercises
Sets functions-sequences-exercisesSets functions-sequences-exercises
Sets functions-sequences-exercises
 
SET AND ITS OPERATIONS
SET AND ITS OPERATIONSSET AND ITS OPERATIONS
SET AND ITS OPERATIONS
 
Introduction to set theory
Introduction to set theoryIntroduction to set theory
Introduction to set theory
 
Sets (1).ppt
Sets (1).pptSets (1).ppt
Sets (1).ppt
 
Blackbox task 2
Blackbox task 2Blackbox task 2
Blackbox task 2
 
Sets (Mathematics class XI)
Sets (Mathematics class XI)Sets (Mathematics class XI)
Sets (Mathematics class XI)
 
Sets in Maths (Complete Topic)
Sets in Maths (Complete Topic)Sets in Maths (Complete Topic)
Sets in Maths (Complete Topic)
 
Set theory
Set theorySet theory
Set theory
 
Mathematics Sets and Logic Week 1
Mathematics Sets and Logic Week 1Mathematics Sets and Logic Week 1
Mathematics Sets and Logic Week 1
 
Set Theory
Set TheorySet Theory
Set Theory
 
Lecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptxLecture 1- DM Intro.pptx
Lecture 1- DM Intro.pptx
 
6.1_set.pptx
6.1_set.pptx6.1_set.pptx
6.1_set.pptx
 
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptxMoazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
 
4898850.ppt
4898850.ppt4898850.ppt
4898850.ppt
 
Mkk1013 chapter 2.1
Mkk1013 chapter 2.1Mkk1013 chapter 2.1
Mkk1013 chapter 2.1
 
6401-Unit 2.pptx
6401-Unit 2.pptx6401-Unit 2.pptx
6401-Unit 2.pptx
 
Chap2_SETS_PDF.pdf
Chap2_SETS_PDF.pdfChap2_SETS_PDF.pdf
Chap2_SETS_PDF.pdf
 
Final maths presentation on sets
Final maths presentation on setsFinal maths presentation on sets
Final maths presentation on sets
 

Recently uploaded

一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
Bill641377
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
zsjl4mimo
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
jitskeb
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
v7oacc3l
 
State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023
kuntobimo2016
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
sameer shah
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
Social Samosa
 

Recently uploaded (20)

一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(Harvard毕业证书)哈佛大学毕业证如何办理
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
 
State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023State of Artificial intelligence Report 2023
State of Artificial intelligence Report 2023
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
 

3a-Set theory.ppt

  • 1. 9/21/2023 CS 201 1 CS201: Data Structures and Discrete Mathematics I Basic Set Theory
  • 2. 9/21/2023 CS 201 2 Sets • A set is a collection of distinct objects. • For example (let A denote a set): A = {apple, orange, grape} A = {1, 2, 3, 4, 5} A = {1, b, c, d, e, f} A = {(1, 2), (3, 4), (9, 10)} A = {<1, 2, 3>, <3, 4, 5>, <6, 7, 8>} A = a collection of anything that is meaningful.
  • 3. 9/21/2023 CS 201 3 Members and Equality of Sets • The objects that make up a set are called members or elements of the set. • Two sets are equal iff they have the same members. – That is, a set is completely determined by its members. – Order and repetition do not matter in a set.
  • 4. 9/21/2023 CS 201 4 Set notations • The notation of {...} describes a set. Each member or element is separated by a comma. – E.g., S = {apple, pear, grape} – S is a set – The members of S are: apple, pear, grape • Order and repetition do not matter in a set. • The following expressions are equivalent: – {1, 3, 9} – {9, 1, 3} – {1, 1, 3, 3, 9}
  • 5. 9/21/2023 CS 201 5 The membership symbol  and the empty set  • The fact that x is a member of a set S can be expressed as – x  S – Reads: • x is in S, or • x is a member of S, or • X belongs to S • An example, S = {1, 2, 3}, 1  S, 2  S, 3  S • The negation of  is written as  (is not in). • The empty set is a set without any element – Denoted by {} or  – For any object x, x  
  • 6. 9/21/2023 CS 201 6 Defining a Set by membership properties • Notation o S = {x  T | P(x)} (or S = {x | x  T and P(x)}) o The members of S are members of an already known set T that satisfy property P. • An example: o Let Z be the set of integers o Let Z+ be the set of positive integers. o Z+ = {x  Z | x > 0}
  • 7. 9/21/2023 CS 201 7 Sets of numbers • Z = The set of all integers Z = {…, -2, -1, 0, 1, 2, …} • Z+ = The set of positive integers Z+ = {1, 2, 3…} = {x | x  Z and x > 0} = {x  Z | x > 0} • Z- = The set of negative integers Z- = {…, -3, -2, -1} = {-1, -2, -3…} = {x  Z | x < 0} • R = The set of all real numbers • Q = the set of all rational numbers Q = {x  R | x = p/q and p, q  Z and q  0} • We can use “;” to replace “and”
  • 8. 9/21/2023 CS 201 8 Subsets • A is a subset () of B, or B is a superset of A iff every member of A is a member of B. o A  B iff for all x if x  A, then x  B • An example: o (-2, 0, 6}  {-3, -2, -1, 0, 1, 3, 6} • Negation: A is not a subset of B or B is not a superset of A iff there is a member of A that is not a member of B o A  B iff there exist x, x  A, x  B
  • 9. 9/21/2023 CS 201 9 Obvious subsets – S  S –   S
  • 10. 9/21/2023 CS 201 10 Proper subsets • A is a proper subset () of B, or B is a proper superset of A iff A is a subset of B and A is not equal to B. o A  B iff A  B and A  B • Examples: o {1, 2, 3}  {1, 2, 3, 4, 5} o Z+  Z  Q  R o If S   then   S
  • 11. 9/21/2023 CS 201 11 Power sets • The set of all subsets of a set is called the power set of the set • The power set of S is denoted by P(S). • Example: – P() ={} – P({1, 2}) = {, {1}, {2}, {1, 2}} – P(S) = {, …, S} – What is P({1, 2, 3})? • How many elements does the power set of S have? Assume S has n elements. 2 ^ n
  • 12. 9/21/2023 CS 201 12  and  are different • Examples: 1  {1} is true 1  {1} is false {1}  {1} is true • Which of the following statement is true? S  P(S) S  P(S) The 1st is true
  • 13. 9/21/2023 CS 201 13 Mutual inclusion and set equality • Sets A and B have the same members iff they mutually include – A  B and B  A • That is, A = B iff A  B and B  A • Mutual inclusion is very useful for proving the equality of sets • To prove an equality, we prove two subset relationships.
  • 14. 9/21/2023 CS 201 14 Universal sets • Depending on the context of discussion – Define a set of U such that all sets of interest are subsets of U. – The set U is known as a universal set • Examples: – When dealing with integers, U may be Z. – When dealing with plane geometry, U may be the set of points in the plane
  • 15. 9/21/2023 CS 201 15 Venn diagram • Venn diagram is used to visualize relationships of some sets. • Each subset (of U, the rectangle) is represented by a circle inside the rectangle.
  • 16. 9/21/2023 CS 201 16 Set operations • Let A, B be subsets of some universal set U. • The following set operations create new sets from A and B. • Union: A  B = {x  U | x  A or x  B} • Intersection: A  B = {x  U | x  A and x  B} • Difference: A  B = A B= {x  U | x  A and x  B} • Complement A = U  A = {x  U | x  A}
  • 17. 9/21/2023 CS 201 17 Set union • An example {1, 2, 3}  {1, 2, 4, 5} = {1, 2, 3, 4, 5} The venn diagram 1 2 3 4 5
  • 18. 9/21/2023 CS 201 18 Set intersection • An example {1, 2, 3}  {1, 2, 4, 5} = {1, 2} The venn diagram 1 2 3 4 5
  • 19. 9/21/2023 CS 201 19 Set difference • An example {1, 2, 3} - {1, 2, 4, 5} = {3} The venn diagram 1 2 3 4 5
  • 20. 9/21/2023 CS 201 20 Set complement • The venn diagram
  • 21. 9/21/2023 CS 201 21 Basic set identities (equalities) • Commutative laws A  B = B  A A  B = B  A • Associative laws (A  B)  C = A  (B  C) (A  B)  C = A  (B  C) • Distributive laws A  (B  C) = (A  B)  (A  C) A  (B  C) = (A  B)  (A  C)
  • 22. 9/21/2023 CS 201 22 Basic set identities (cont …) • Identity laws   A = A   = A A  U = U  A = A • Double complement law (A’)’ = A • Idempotent laws A  A = A A  A = A • De Morgan’s laws (A  B)’ = A’  B’ (A  B)’ = A’  B’
  • 23. Basic set identities (cont …) • Absorption laws A  (A  B) = A A  (A  B) = A • Complement law (U)’ =  ’ = U • Set difference law A – B = A  B’ • Universal bound law A  U = U A   =  9/21/2023 CS 201 23
  • 24. 9/21/2023 CS 201 24 Infinite sets • In a finite set, we can always designate one element as the first member, s1, another element as the second member, s2 and so on. If there are k elements in the set we can list them as – s1, s2, …, sk • A set that is not finite is called an infinite set. • If a set is infinite, we may still be able to select a first element s1, a second element s2 and so on: – s1, s2, … • Both above sets are countable. • Countable does not mean we can give a total number, but means that we can say, “here is the first one” and “here is the second one” and so on.
  • 25. 9/21/2023 CS 201 25 Countable sets: examples • The set of positive integer numbers are countable. • The set of positive rational numbers are countable
  • 26. 9/21/2023 CS 201 26 Uncountable sets • There are also some sets that are uncountable. – The set is so large, and there is no way to count out the elements. • One example: The set of real numbers between 0 and 1 is uncountable. • A computer can only manage finite sets.
  • 27. 9/21/2023 CS 201 27 Summary • Sets are extremely important for Computer Science. • A set is simply an unordered list of objects. • Set operations: union, intersection, difference.