Sets
https://slides.com/georgelee/ics141-sets/live
We're done with logic!
Sets, Functions, Sequences, Sums, Matrices
Intro to Sets
Group "objects" together
- Positive integers
- Rational numbers less than 100
- Students in this class
- {1, -2, "Peyton", "Raynor"}
- {1, 3, {2, 4}}
Properties of Sets
- Elements are unique (no duplicates)
- Elements are unordered
- Can be finite or infinite
- Can contain other sets
Fancy Notations
- We write "x ∈ A" if x is a member of set A and "x ∉ S" if x is not a member of set A.
- We use ∅ to denote the empty set (note that {∅} is a set of one element)
- For finite sets, the cardinality of a set S is the number of elements in the set and is denoted by |S|.
Tabular Notation
- Enumerate the values in the set
- {2,3,5,7}
- {b, c, a, m, z}
- Do not do something like {3, 6, 9, 12, ...}
- Use this form only if you can list all the values
Set Builder Notation
- { x | p(x) } where if p(x) is true, then x is a member of the set
- { x ∈ S | p(x) } where the first part describes our universe of discourse (natural numbers, integers, etc.)
- { x | x ∈ ℕ | x is even and less than 100 }
- { x | x is a game on Steam }
- Use this form to describe large or infinite sets
Special Sets
- ℕ: the set of natural numbers (usually including 0)
- ℤ: the set of integers
- ℚ: the set of rational numbers
- ℝ: the set of real numbers
- ℂ: the set of complex numbers
- ℤ+: the set of all positive integers
- ℤn: the set of all nonnegative integers less than n
- ℝ+: the set of all positive real numbers
Relationships Between Sets
Subset / Superset
- We say X is a subset of Y if and only if (iff) all elements of x are also in Y.
- ∀ x [ ( x ∈ X ) → ( x ∈ Y ) ]
- Denoted as X ⊆ Y
- We say Y is a superset of X iff X is a subset of Y.
- The empty set ∅ is a subset of all sets.
- Example: {1, 2, 3} is a subset of {x | x ∈ ℤ }
Equal / Not Equal
- We say X and Y are equal (X = Y) if X is a subset of Y and Y is a subset of X
- ∀ x [ ( x ∈ X ) ↔ ( x ∈ Y ) ]
- If X and Y are not equal, we write X ≠ Y
- Remember that order does not matter!
{2, 4, 6} = {6, 4, 2} - Be careful, {{2, 4, 6}} is not equal to {2, 4, 6}
Other Relationships
- X is a proper subset of Y iff X ⊆ Y and X ≠ Y
- X and Y are said to be (mutually) disjoint iff no element is in both X and Y
- Example: {1, 3, 5} is a disjoint set of {2, 4, 6}
Operations With Sets
Universal Set
The set of all elements for which the sets we're operating on will be selecting from.
For example if U = {x | x ∈ ℤ }, then sets A and B inside of this universe can only contain integers.
Union
The Union of two sets A and B are all of the elements of A and all of the elements in B.
Using set builder notation: A ∪ B = { x | x ∈ A ∨ x ∈ B }
{2, 4, 6} ∪ {1, 3, 5} = {1, 2, 3, 4, 5, 6}
Intersection
The Intersection of two sets A and B are all of the elements common to both A and B.
Using set builder notation: A ∩ B = { x | x ∈ A ∧ x ∈ B }
{2, 4, 6} ∩ {1, 2, 3} = {2}
Complement
The Complement of a set A is all of the elements in U that are not in A.
Using set builder notation: A = { x ∈ U | x ∉ A ) }
Set Difference
The Difference of two sets A and B are all the elements in A that are not in B. Note that A - B is not usually equal to B - A.
Using set builder notation: A − B = { x | x ∈ A ∧ x ∉ B }
{2, 4, 6} - {1, 2, 3} = {4, 6}
Cartesian Product
The Cartesian Product of two sets A and B is a set of ordered pairs containing all pairs of elements between A and B.
An ordered pair is of the form (x, y)
Using set builder notation: A × B = { (x, y) | x ∈ A ∧ y ∈ B }
{2, 4} x {1, 2} = {(2, 1), (2, 2), (4, 1), (4, 2)}
Power Set
The Power Set of a set A is the set of all subsets of A (including the empty set and itself). May be denoted as ℘(A) or 2^A
℘{9,10,11} = { X | X ⊆ {9,10,11} } = { ∅, {9}, {10}, {11}, {9,10}, {10,11}, {9,11}, {9,10,11} }
Sets
By George Lee
Sets
Is the set of all sets a member of itself?
- 983