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.