Sets I
CS2100
Ross Whitaker
University of Utah
Brain Teaser
Sets
• A set is a collection of objects
• Basic operation:
x∈A
Predicate (evaluated as true or false)
“x is an element of A”, “x is in A”
Be careful
• Is “x” a variable with domain from another set?
• E.g. or does “x” refer to the letter?
=> Know what symbols are variables and their
domains
Some Useful Sets
• Z – set of integers
Z = {…, -3, -2, -1, 0, 1, 2, 3, …}
• N – Natural numbers
N = {0, 1, 2, 3, …}
Nonnegative integers
• Q – Rational numbers
• R – Real numbers
• Modify with superscripts
Z+, Z-, Z≥0, R+, …
More Definitions
• A⊆B
∀x, x∈A->x∈B
“A is a subset of B”
• A=B
∀x, x∈A<->x∈B
(A⊆B)∧(B⊆A)
• Empty set
Set containing no elements
denoted {}, or ∅
• U – Universal set or “universe”
Set containing all possible elements (in context)
Every set (in context) is a subset of U
First Proof
• Proper subset
A⊂B <-> (A⊆B)∧(∃x∈B, x∉A)
• Prove that (A⊂B)->¬(B⊆A)
Some Set Notation
• “Call the set of all even, natural
numbers E”
• E={x∈N: x is even}
E={x∈N: ∃m, x=2m}
• Set builder notation
set_name={domain: predicate}
every element of the domain that satifies
the predicate is in the set.
Even More Definitions
• For a universe: U
• A∩B
A∩B={x∈U: (x∈A)∧(x∈B)}
The intersection of sets A and B
• A∪B
A∩B={x∈U: (x∈A)∨(x∈B)}
The union of sets A and B
• A-B
A-B={x∈U: (x∈A)∧(x∉B)}
More Definitions
(Will It Ever End?)
•
•
•
•
∅ is a subset of every set
Every set is a subset of U
Two sets are disjoint iff A∩B=∅
A’=U-A
The complement of a set A, denoted A’
Elements of the universal set that are not
in A
Basic Properties of Set Operators
Venn Diagrams
U
A
B
C
Hints on Venn Diagrams
• Remember the Universe
• Always show the general case
I.e. any two sets have some regions that
overlap and some that do not
Unless there is specific reason not to
• I.e. premises such as
A∩B=∅
A⊂B
Examples
• Use Venn diagrams to illustrate:
A∩(B∪C)=(A∪B)∩(A∪C)
• Use Venn diagrams to illustrate:
A-(B∪C)=(A-B)∩(A-C)
Size of A Set
• If A has a finite number of elements,
then n(A) indicates the number of
elements in A
Often denoted A
Cardinality of A
Sets as Data Containers
• Elements have an atomic, binary operation
“=” – how you define it is up to you
defined for any two elements of the “universe”
Predicate
• The “=” returns false for any two members of a set
I.e. sets don’t allow repeat elements
• x∈A
Returns true if “x=” evaluates to true an element of A (loop
through A)
• Two sets are the same if their members are the same
No sense of order
• Data operations:
Can build sets by appending elements one at a time
• Union of set and new element
• Check for repeats
Size is the number of data objects
Universe defines the data type
Inclusion-Exclusion Principle
• n(A∪B) = n(A) + n(B) - n(A∩B)
• n(A∪B∪C) = n(A) + n(B) + n(C) - n(A∩B) – n(A∩C) - n(B∩C)
Practice
• Let T={x∈N, x≤1000}
• Use the inclusion-exclusion principle to find the
size of the set:
G={n∈T, (2n)∨(3n)}
• (2n)=?
each element is 2k, for k=1…q
max value for q is 1000÷2=500
• (3n)=1000÷3=333
• For the intersection
(2n)∧(3n) which is the same as (6n)
This size is 1000÷6=166
• G = 500 + 333 – 166 = 667
Practice
• Let T={x∈N, x≤1000}
• Use the inclusion-exclusion principle to
find the size of the set:
{n∈T, (2n)∨(3n)∨(5n)}
© Copyright 2026 Paperzz