Definition of cartesian product I have some problem understanding some aspects of the definition of an arbitrary cartesian product. What I have so far: 

Let $\mathscr{A} = (A_s)_{s \in S}$ be a collection of sets. The
  cartesian product of the collection $\mathscr{A}$ is: $$\begin{align}
 \prod\mathscr{A} = \prod_{s \in S}A_s &:= \left\{ f: \mathscr{A} \to
 \bigcup_{s \in S}A_s \mid f(A) \in A, \, \forall\, A \in \mathscr{A} 
 \right\} \\ &= \left\{ f: S \to \bigcup_{s \in S}A_s \mid f(s) \in
 A_s, \forall\, s \in S \right\}\end{align}.
$$If $\mathscr{A} =\{A_1, \ldots A_n\}$, we will write $\prod\mathscr{A} = A_1 \times \cdots \times A_n$.

By my understanding, I get that if $A$ and $B$ are sets, we have: $$A \times B = \{f: \{A,B\} \to A \cup B\mid f(A) \in A \text{ and }f(B) \in B\}$$ 
I am asked, then, to prove that given sets $A,B$ and $C$, we have $A \times(B \cup C) = (A \times B)\cup(A \times C)$.
Doubt 1: How can I make the comparison if the domains of the elements on both sides are different? It does not make any sense at all.
Suppose I don't care and go on: If $f \in A \times(B \cup C)$, then $f(A) \in A$ and $f(B \cup C) \in B \cup C$. I would think then, that if $f(B \cup C) \in B$, then $f \in A \times B$, and if $f(B \cup C)\in C$, we have $f \in A \times C$, so anyway we have the inclusion $\subseteq$. On the other hand, it suffices to prove that $A \times B \subseteq A \times(B \cup C)$ (WLOG). If $f \in A \times B$, then $f(A) \in A$ and $f(B) \in B \subset B \cup C$ and so $f \in A \times(B \cup C)$. I am not comfortable at all with this, since I do not have a rigorous definition of a functions, and the most formal one I know is that $f : A \to B$ is a function if $f \in A \times B$ satisfies blah blah blah. It is circular.
Up next I am asked to prove that $A \times B = A \times C$ and $A \neq \varnothing$, then $B = C$. My idea consists mainly of the following: since $A \neq \varnothing$, then exists $a \in A$. Take $x \in B$, if I prove that $x \in C$ then I am done. Define $f:\{A, B\}\to A \cup B$ by setting $f(A) = a \in A$ and $f(B) = x \in B$. This way $f \in A \times B$, and by hypothesis $f \in A \times C$. I don't know how to give the next step in this argument.
Doubt 2: Can't I just say that if $f \in A \times B = A \times B$ implies $\{A,B\}=\{A,C\}$ and $A \cup B = A \cup C$, based on domains and codomains, and from there try to get $B = C$?
I probably can tackle these problems on my on, if I can understand the definitions correctly, but all of this is very cloudy and I need some help understanding. Thanks.
 A: The first problem that we encounter is in the first definition. Namely, it does not work if $(A_s)_{s\in S}$ contains duplicates. It therefore cannot be used to define one of the most common examples of the Cartesian product, namely $A^n$.
As to your problem with the circularity in the definition of a function, I think it's mostly a matter of recognising that the definition of the binary Cartesian product is a case treated separately—defined in the usual way: ordered pairs via Kuratowski's definition, then setting:
$$A \times B := \{(a,b): a \in A, b \in B\}$$
which is proved to exist in $\sf ZF$ in many, many places. It is correct that this is not equal to $\prod \{A, B\}$, and this obfuscation of the distinction between binary and arbitrary Cartesian product is a weak point in the exposition.
Next, we also have the definition of a function, $f$ is a function iff:


*

*$f \subseteq A \times B$;

*$(a,b) \in f$ and $(a,c) \in f$ imply $b= c$.


Then, the notation "$f: A \to B$" means:


*

*$\forall a: (a \in A \iff \exists b \in B: (a,b) \in f)$;

*$\forall b: \exists a \in A: (a,b) \in f \implies b \in B$.



With that all out of the way, we can get to the definition of the Cartesian product proper. To avoid confusion, let us write $\prod \{A, B\}$ instead of $A \times B$ in addressing "binary arbitrary Cartesian products". Let us also agree that for such finite products, the indexing set is $\{1\ldots n\}$.
These presuppositions having been specified, we can see that:
\begin{align*}
\prod \{A,B \cup C\} &= \left\{f: \{1,2\} \to A \cup B \cup C \middle\vert f(1) \in A, f(2) \in B \cup C \right\}\\
\prod \{A,B\} &= \left\{f: \{1,2\} \to A \cup B \middle\vert f(1) \in A, f(2) \in B \right\}\\
\prod \{A,C\} &= \left\{f: \{1,2\} \to A \cup C \middle\vert f(1) \in A, f(2) \in C \right\}\\
\end{align*}
Now that we have cut through the complicated language, I trust that you can see that the asserted equation does make sense, and indeed can prove it yourself.

Lastly, your second doubt concerns the first definition, which as said is problematic because it is not general enough. 
Your proof is good, and it can be concluded from $f \in A \times C$ that $f(2) \in C$, and by construction $f(2) = x$; hence $x \in C$. Swapping the roles of $B$ and $C$ yields the reverse inclusion, proving equality.
