TITLE: Ordered pair definition
QUESTION [5 upvotes]: Why is the ordered pair $(x,y)$ defined to be the set $\{\{x\},\{x,y\}\}$?
My book states that it is simply defined this way and then proceeds to perform a bunch of magic using this definition.

REPLY [3 votes]: The definition of the ordered pair states that $(x,y)$ is an object with $x$ as its first and $y$ as its second component. Two ordered pairs are considered equal if the following holds:
$$ (x,y) = (x',y') \leftrightarrow (x = x' \wedge y = y'). $$
In order to show that $\{ \{x\}, \{x,y\}\}$ is an equivalent representation of an ordered pair, it is sufficient to prove that it obeys the above given property.
According to the axiom of pair set, the collection $\{ \{x\}, \{x,y\}\}$ is indeed a set. Two sets are equal iff every element of one set is element of the other set and vice versa:
$$
\{ \{ x \}, \{ x, y \} \} = \{ \{ x' \}, \{ x', y' \} \} \leftrightarrow 
(\forall z) \: z \in \{ \{ x \}, \{ x, y \} \} \leftrightarrow z \in \{ \{ x' \}, \{ x', y' \} \}. \text{ (1)}
$$
Since $ \{ \{ x \}, \{ x, y \} \} $ is, according to the pair set axiom, a set, we also have
$$ z \in \{ \{ x \}, \{ x, y \} \} \leftrightarrow z = \{ x \} \vee z = \{ x, y \}. $$
Inserting this identity into (1) yields
$$ (\forall z) \: z = \{ x \} \vee z = \{ x, y \} \leftrightarrow z = \{ x' \} \vee z = \{ x', y' \}, $$
or, equivalently,
$$
(\forall z) \: (z = \{ x \} \vee z = \{ x, y \} \rightarrow z = \{ x' \} \vee z = \{ x', y' \}) 
\wedge (z = \{ x \} \vee z = \{ x,y \} \leftarrow z = \{ x' \} \vee z = \{ x',y' \}).
\text{ (2)}
$$
If $x = y$, (1) requires that
$$ (\forall z) \: z \in \{ \{ x \} \} \leftrightarrow z \in \{ \{ x' \}, \{ x', y' \} \}. $$
In this case the equivalence holds iff $x' = y'$ such that $x = x'$ and $y = y'$. 

If $x \neq y$, (2) yields two implications for the 1st clause of the conjunction:
$$
z = \{ x \} \rightarrow z = \{ x' \} \vee z = \{ x', y' \},
$$
$$
z = \{ x,y \} \rightarrow z = \{ x' \} \vee z = \{ x', y' \}.
$$
Since for two sets to be equal they need to have the same number of elements, the last two implications reduce to
$$
z = \{ x \} \rightarrow z = \{ x' \}, \text{ (3)}
$$
$$
z = \{ x,y \} \rightarrow z = \{ x', y' \}. \text{ (4)}
$$
From (3) we have that $x = x'$ while (4) requires that 
$$ \{ x,y \} = \{ x', y' \} \stackrel{(3)}{\longrightarrow} \{ x,y \} = \{ x, y' \} \rightarrow y = y'. $$
Summarizing the above yields
$$ \{ \{ x \}, \{ x, y \} \} = \{ \{ x' \}, \{ x', y' \} \} \leftrightarrow (x = x' \wedge y = y').$$
$\Box$