Set Fundamentals and Notation
What you'll learn: You'll discover what sets are and how to write them down precisely using mathematical notation.
What Is a Set?
A set is simply a collection of distinct objects, called elements (or members). Think of it like a bag containing unique items—no duplicates allowed. In computer science, sets help us organize data, describe domains for quantifiers, and model collections efficiently.
For example, the set of vowels in English is {a, e, i, o, u}. Each vowel is an element of this set.
Membership
We use the symbol ∈ to express that something belongs to a set, and ∉ for does not belong to:
a ∈ {a, e, i, o, u}means "a is an element of the vowel set"b ∉ {a, e, i, o, u}means "b is not an element of the vowel set"
This connects to predicate logic: membership is like a truth value for "x is in set S."
Roster Notation
Roster notation lists all elements explicitly inside curly braces:
A = {1, 2, 3, 4, 5}— the set of integers from 1 to 5B = {red, blue, green}— a set of colors- Order doesn't matter:
{1, 2, 3} = {3, 1, 2} - No duplicates:
{1, 2, 2, 3} = {1, 2, 3}
Set-Builder Notation
Set-builder notation describes sets using a rule or condition, similar to how we used predicates:
C = {x | x is an even integer between 1 and 10}reads as "the set of all x such that x is an even integer..."- Equivalent to
C = {2, 4, 6, 8, 10} - Often uses a domain restriction:
{x ∈ ℤ | 0 < x < 6}means integers between 0 and 6
Key Takeaway: Sets are unordered collections of unique elements; use roster notation {a, b, c} to list them explicitly or set-builder notation {x | condition} to define them by a rule.