\input{decls.tex}
\title{Sets}
\begin{document}
\maketitle
Set comprehensions can be written $\{ x | x \in \N \}$ or $\{ x : x \in \N \}$ - '$:$' or '$|$' \\
Sets are defined entirely by the values of $x$ for which $x \in A$
\begin{description}
	\item[Axiom of Extensionality / Set Equality] $A = B \iff \forall x. (x \in A \iff x \in B)$
	\item[$A \subseteq B$] \quad $\forall x \in A. x \in B$ \\
		Is transitive, reflexive, antisymmetric
	\item[$A \subset B$] \quad $(\forall x \in A.~x \in B) \land (\exists x \in B.~x \not\in A)$ \\
		Is transitive, antisymmetric
	\item[$\varnothing$] $\{\}$
	\item[$\cup$] Union
	\item[$\cap$] Intersection
	\item[$A \setminus B$] \quad $\{ x \in A : x \not\in B \}$
		\item[$A^\complement$]\quad $U \setminus A$
	\item[$[a, b)$] \quad $\{ x \in \R : a \leq x < b \}$
\end{description}
\begin{align*}
	C \setminus (A \cup B) \equiv           & ~ (C \setminus A) \cap (C \setminus B) \\
	C \setminus (A \cap B) \equiv           & ~ (C \setminus A) \cup (C \setminus B) \\
	(A^\complement)^\complement \equiv      & ~ A                                    \\
	A^\complement \cup B^\complement \equiv & ~ (A \cap B)^\complement               \\
	A^\complement \cap B^\complement \equiv & ~ (A \cup B)^\complement
\end{align*}
\section*{Families of Sets}
A family of sets indexed by a set $I$ (the indexing set): $A_i ~~\forall~i\in I (\equiv (A_i)_{i\in I})$ \\
$A_i$ is a set for every element $i \in I$ \\
A family of sets indexed by $\N$ is called a sequence of sets. Also written $(B_i)^{\inf}_{i=0}$ or $(B_i)_{i \geq 0}$
\begin{align*}
	\bigcup_{i \in I}~A_i \equiv \{x | \exists i \in I. x \in A_i \}                                      \\
	\bigcap_{i \in I}~A_i \equiv \{x | \forall i \in I. x \in A_i \} & \text{ Exists iff } \exists~i\in I
\end{align*}
\begin{align*}
	 & \forall i \in I. A_i \subseteq \cup_{j \in I}A_j                        \\
	 & \forall i \in I. A_i \subseteq B \implies \cup_{j \in I}A_j \subseteq B \\
	 & \forall i \in I.\cap_{j \in I}A_j \subseteq A_i                         \\
	 & \forall i \in I. B \subseteq A_i \implies B \subseteq \cap_{j \in I}A_j \\ \\
	 & B \cup \cap_{i \in I}A_i = \cup_{i \in I}(B \cap A_i)                   \\
	 & B \cap \cup_{i \in I}A_i = \cap_{i \in I}(B \cup A_i)                   \\
	 & B \setminus \cup_{i \in I}A_i = \cap_{i\in I}(B\setminus A_i)           \\
	 & B \setminus \cap_{i \in I}A_i = \cup_{i\in I}(B \setminus A_i)
\end{align*}
\section*{Cartesian Products}
Ordered pairs can be represented as $(x, y) \equiv \{x, \{x, y\}\}$ \\
$X \times Y = \{ (x, y) |~ \forall x, y.~x \in X \land y \in Y\}$ for sets $X$, $Y$ \\
$X^n$ is $X\times X^{n-1}$ for set $X$ and natural $n$ \\
$\card{X\times Y} = \card{X} \times \card{Y}$ (for finite $X$, $Y$)
\section*{Functions}
For sets $X$, $Y$:
\begin{description}
	\item[A function $F: X \to Y$] $\subseteq X\times Y$ \text { where } \\
		$\forall x \in X.~\exists \text{ a unique } F(x) \in Y.~ (x, F(x)) \in F$ \\
		There exist $\card{Y}^{\card{X}}$ functions $F: X \to Y$
	\item[$\operatorname{dom}(F)$] The domain of $F$, i.e. $X$
	\item[$\operatorname{incl}^X_A : A \to X$] $= a \quad \forall A,X. \text{ where } A \subseteq X$
	\item[Constant function] $\exists y_0 \in Y.~\forall x \in X.~ f(x) = y_0$
	\item[Characteristic Function of a set $A \subseteq X$: $\chi_A: X \to \{0, 1\}$]
		\[
			\chi_A: X \to \{0, 1\} = \left\{\begin{array}{lr}
				0 & \text{ if } x \not\in A \\
				1 & \text{ if } x \in A
			\end{array} \right.
		\]
	\item[Restriction of a function $f: X \to Y$] $\restr{f}{A}$ is $f$ specialized contravariantly to $A \subseteq X$
	\item[$f(A)$: Image of $A$ under $f$] $f$ mapped over $A$ \quad for function $f: X \to Y$, $A \subseteq X$
	\item[$\operatorname{ran}(f)$ / image of $f$ / range of $f$] $\{ f(x) | x \in X \}$, $f(X)$, i.e. all possible values of $f(x)$
	\item[Preimage of $B$ under $f$] $\{ x \in X ~|~ f(x) \in B \}$ \\
		written $f^{-1}(B)$, but is \emph{not} the inverse of f
\end{description}
For $f: X \to Y$, $A \subseteq A' \subseteq X$, $B \subseteq B' \subseteq Y$:
\begin{align*}
	f(A) \subseteq~& f(A') \\
	f^{-1}(B) \subseteq ~& f^{-1}(B') \\
	f^{-1}(f(A)) \supseteq ~& A \\
	f(f^{-1}(B)) \subseteq ~& B
\end{align*}
For set families $(A_i \subseteq X)_{i \in I}, (B_j \subseteq Y)_{j \in J}$:
\begin{align*}
	f(\cup_{i \in I} A_i) = ~& \cup_{i \in I}f(A_i) \\
	f(\cap_{i \in I} A_i) \subseteq ~& \cap_{i \in I}f(A_i) \\
	f^{-1}(\cup_{j \in J} B_j) = ~& \cup_{j \in J} f^{-1}(B_j) \\
	f^{-1}(\cap_{j \in J} B_j) = ~& \cap_{j \in J} f^{-1}(B_j)
\end{align*}
\section*{Function Composition}
For functions $f: X \to Y$, $g: Y \to Z$:
\begin{align*}
	& (g \circ f): X \to Z \\
	& (g\circ f)(x) = g(f(x)) & \forall x \in X \\ \\
\end{align*}
\section*{Surjection and Injection}
For $f: X \to Y$, $f$ is
\begin{description}
	\item[surjective] iff $f(X) = Y$, i.e. $\forall y \in Y.~ \exists x \in X.~ f(x) = y$ \\
		Range is codomain, 'onto'
	\item[injective] iff $\forall x, x' \in X. ~ f(x) = f(x') \implies x = x'$
	\item[bijective] iff $f$ is injective and $f$ is surjective
\end{description}
\end{document}
