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

PPT
Grade 7 Sets.ppt
PPT
sets.ppt
PPT
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
PDF
Discrete Structure Lecture #7 & 8.pdf
PPT
07-sets.ppt
PPTX
Explore the foundational concepts of sets in discrete mathematics
PPT
Set theory and its operations
PDF
Chap2_SETS_PDF.pdf
Grade 7 Sets.ppt
sets.ppt
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
Discrete Structure Lecture #7 & 8.pdf
07-sets.ppt
Explore the foundational concepts of sets in discrete mathematics
Set theory and its operations
Chap2_SETS_PDF.pdf

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

PPT
Theory of the sets and Venn diagram-grade 9 math
PPTX
Lec 1 ICE2151.pptx
PDF
Set Theory.pdf
PDF
Set Properties and Operations in Abstract Algebra
PPT
union of ...................SETS-ppt.ppt
PPTX
sanskriti tiwari 2 ppt.pptx
PPTX
Set theory- Introduction, symbols with its meaning
PPT
DMaths notes Introduction defination.ppt
PPTX
Lesson 1. SETS. Lesson 1. SETS. Lesson 1. SETS.pptx
PDF
Set theory
PPTX
Discrete Structure Mathematics lecture 1
PPT
Lesson 1 &2 -Set Theory and Functions.ppt
DOCX
Class7 converted
PPTX
Maths presentation of Agrima.pptx
PPTX
Sets and functions daniyal khan
PPT
Ch01-2.ppt
PPTX
Set theory. lesson. probability and statistics
PPTX
Set theory for the Data Analysis and AI.pptx
PDF
set 1.pdf
PPT
7-Sets-1.ppt
Theory of the sets and Venn diagram-grade 9 math
Lec 1 ICE2151.pptx
Set Theory.pdf
Set Properties and Operations in Abstract Algebra
union of ...................SETS-ppt.ppt
sanskriti tiwari 2 ppt.pptx
Set theory- Introduction, symbols with its meaning
DMaths notes Introduction defination.ppt
Lesson 1. SETS. Lesson 1. SETS. Lesson 1. SETS.pptx
Set theory
Discrete Structure Mathematics lecture 1
Lesson 1 &2 -Set Theory and Functions.ppt
Class7 converted
Maths presentation of Agrima.pptx
Sets and functions daniyal khan
Ch01-2.ppt
Set theory. lesson. probability and statistics
Set theory for the Data Analysis and AI.pptx
set 1.pdf
7-Sets-1.ppt
Ad

Recently uploaded (20)

PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PDF
Fluorescence-microscope_Botany_detailed content
PDF
Foundation of Data Science unit number two notes
PDF
annual-report-2024-2025 original latest.
PDF
Business Analytics and business intelligence.pdf
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
Computer network topology notes for revision
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
IB Computer Science - Internal Assessment.pptx
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
Galatica Smart Energy Infrastructure Startup Pitch Deck
Miokarditis (Inflamasi pada Otot Jantung)
Fluorescence-microscope_Botany_detailed content
Foundation of Data Science unit number two notes
annual-report-2024-2025 original latest.
Business Analytics and business intelligence.pdf
Clinical guidelines as a resource for EBP(1).pdf
Computer network topology notes for revision
Introduction-to-Cloud-ComputingFinal.pptx
climate analysis of Dhaka ,Banglades.pptx
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
IB Computer Science - Internal Assessment.pptx
Ad

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.