A collection/bunch/group/class/aggregate/container of elements.
It is safer to consider elements all of the same kind.
Membership: key operation, $x \in A$.
Many other operations later.
$A=\{1,2,3,4,5\}$ five-element set.
$2 \in A$, $7 \not \in A$, membership in $A$.
$\{\}$ or $\varnothing$ empty set, no member element.
$\mathbb N = \{0,1,2,\ldots\}$ natural numbers (sometimes no zero).
$\mathbb Z, \mathbb Q, \mathbb R, \mathbb C$ well-known sets.
$\mathbb E = \{x \mid x=2y \mbox{ for some $y \in \mathbb Z$}\}$ even integers.
$S^+, S^-, S^*$ pos, neg, non-zero elements of $S$.
$\{1,2,\{1,2\},3\}$ beware of tricky sets.
$R=\{x \mid x \not \in x\}$ does $R \in R$ ?!
Discuss during the lecture membership in these sets.
Subset: $A \subset B$ iff $\forall x (x \in A \to x \in B)$.
Equality: $A = B$ iff $\forall x (x \in A \leftrightarrow x \in B)$.
Equality (alternate): $A = B$ iff $A \subset B \land B \subset A$.
Notations: $\subset$, $\subseteq$, $\subsetneq$, $\not \subset$, $\not \subseteq$, $\not \subsetneq$.
The powerset of a set $A$, ${\cal P}(A)$, contains all and only the subsets of $A$.
Suppose $A=\{0,1\}$. Compute ${\cal P}(A)$ during the lecture.
Also denoted $2^A$.
How many elements are there in $2^A$, if there are $n$ elements in $A$ ?
Notation rationale: $|2^A| = 2^{|A|}$.
Intersection: $A \cap B = \{x \mid x \in A \land x \in B\}$.
Union: $A \cup B = \{x \mid x \in A \lor x \in B\}$.
Complement: $\overline A = \{x \in {\cal U} \mid x \not \in A\}$.
Difference: $A - B = \{x \mid x \in A \land x \not \in B\}$.
Symmetric Difference: $A \oplus B = \{x \mid x \in A \oplus x \in B\}$.Examples: $A=\{1,2,3,4\}$ and $B=\{3,4,5,6\}$.
Compute all combinations during the lecture.
$n$ sets produce $2^n$ regions (does not scale well).Diagrams useful to reason. E.g., show $(A \cap B) \cup A = A$.
E.g., if $A$ has $n$ elements and $B$ has $m$, how many elements are in $A \cup B$ ?
Associative: $A \cup (B \cup C) = (A \cup B) \cup C$.
Commnutative: $A \cup B = B \cup A$.
Absorption: $A \cup (A \cap B) = A$.
... dozen more ...
Prove one during lecture.
$\displaystyle \cup_{n=1}^N A_n = A_1 \cup A_2 \cup \ldots A_N = \{x \mid \exists n (x \in A_n)\}$
Similar formula for intersection.
Upper bound can be infinity.
A partition of a set $S$ is a set of disjoint non-empty subsets of $S$ whose union is $S$.
E.g., $S=\{1,2,3,4\}$, $P=\{\{1\},\{2,3\},\{4\}\}$.
Question: how many elements can there be in a partition of $A$, if $A$ has $n$ elements?
$A \times B = \{(a,b) \mid a \in A \land b \in B\}$.
Generalized to $n$ sets.
Power notation, $A^n = \underbrace{A \times \cdots \times A}_{n ~\rm{times}}$.
The elements of a cartesian product are called tuples.
Examples: $A=\{1,2,3\}$ and $B=\{T,F\}$. Show during the lecture $A \times B$.
In a set there is no order and there are no repetitions.
A multiset is a set-like structure in which elements can be repeated (still no order).
Same notation as set (beware).
How to define membership, union and intersection (hint: what should $A \cup A$ and $A \cap A$ be)?
Are there sets, multisets, cartesian products in your favorite programming language ?
How would you implement these structures in C?
Sets in ruby.