Is $A\times B\times C$ equal to $(A\times B)\times C$? I'm rather new to set theory, and I have a question about Cartesian product.

Let $A$, $B$, and $C$ be sets. Is $A\times B\times C$ equal to $(A\times B)\times C$?


I think the answer is false. My understanding is as follows:

For example, let $A=\{0\}$, $B=\{1\}$, and $C=\{2\}$. Then $$A\times B\times C=\big\{(0, 1, 2)\big\},$$ whereas $$(A\times B)\times C=\big\{((0, 1), 2)\big\}.$$

I believe these are different, but it seems counter-intuitive to me that one additional pair of parenthesis can change the entire expression. Is my understanding correct?
 A: You're correct that these are not equal as sets. An element of $A \times B \times C$ is an ordered triple $(a, b, c)$ where $a \in A$, $b \in B$, and $c \in C$. An element of $(A \times B) \times C$ is an ordered pair $(d, c)$ where $d \in A \times B$ (that is, $d$ is an ordered pair $(a, b)$ with $a \in A$ and $b \in B$) and $c \in C$.
However, your intuition that they should in some sense be considered "the same" is also correct: There is a natural one-to-one correspondence between $A \times B \times C$ and $(A \times B) \times C$ that sends each ordered triple $(a, b, c)$ to the ordered pair $((a, b), c)$. You can think of this as saying that these two constructions encode exactly the same information, just in different ways. Nonetheless, they are not literally equal as sets; elements of one are not elements of the other.
A: Just to extend the answers of others, there is something more than just a bijection/isomorphism between them! In general bijection always exists, whenever the "number" of elements of the sets are the same. But this bijection is natural/canonical with respect to maps between sets. What does it mean?
Don't fix sets $A,B,C$ but think about any random sets. For each triple of sets $X,Y,Z$ there is a bijection $$f_{X,Y,Z}:X\times Y \times Z \to (X \times Y) \times Z$$ such that all of these bijections respect each other in the following sense:
Whenever you take maps $g_1:X\to X'$, $g_2:Y\to Y'$ and $g_3:Z\to Z'$ then these maps induce new maps $$g_{123}:X\times Y\times Z \to X'\times Y' \times Z'$$ defined as
$$(x,y,z)\mapsto (g_1(x),g_2(y),g_3(z))$$
and
$$g_{(12),3}:(X\times Y)\times Z \to (X'\times Y') \times Z'$$ defined as
$$((x,y),z)\mapsto ((g_1(x),g_2(y)),g_3(z))$$
so that we get a commuting diagram(i.e. it doesn't matter from which direction you follow the diagram):
$$\begin{array}
XX\times Y \times Z & \stackrel{f_{X,Y,Z}}{\longrightarrow} & (X \times Y) \times Z \\
\downarrow{g_{123}} & & \downarrow{g_{(12),3}} \\
 X'\times Y' \times Z' & \stackrel{f_{X',Y',Z'}}{\longrightarrow} & (X' \times Y') \times Z'.   
\end{array}$$
Why is this important? Well, one of the reason is that whenever you have bunch of maps between different sets, we are free to replace any $X\times Y \times Z$ with $(X\times Y)\times Z$ and vice versa without worrying much if the maps between are still legit. This sort of ideas of "respecting the maps" and bijections which are something more than just simple bijections are made precise in category theory and are used extensively everywhere.
A: The thing about set theory is that the only objects that exist are sets. Ordered pairs aren't sets per se, but they can be encoded as them. $(a,b)$ can be represented as $\{a, \{a,b\}\}$, as $\{\{a,1\}, \{b,2\}\}$, or any number of other constructions. The reasons you might want to pick one in particular isn't important. What matters is that you encode, purely set-theoretically, the idea of a pair of objects in an order.
When you work with the notation $A \times B$, you can decide which of these constructions (or any other one) you want to use, and that choice will determine whether they're equal as sets. Once you have that, you need to define how $A \times B \times C$ is defined. If you picked $(a,b) = \{a, \{a,b\}\}$, then you could extend it to $(a,b,c) = \{a, \{a,b\},\{a,b,c\}\}$ in which case $(A \times B) \times C \neq A \times B \times C$. You could instead simply define $A \times B \times C = (A \times B) \times C$ and they would of course be the same, or even $A \times B \times C = A \times (B \times C)$ and they'd be unequal again.
When you're actually working with ordered pairs though, it doesn't really matter. Any of the constructions I outlined above encode the important part of the object, which is that you have a few elements in a certain order. As models of that idea, they're isomorphic, in which sense they are indisputably equal.
