The cartesian product of a family $(A_i\mid i\in I)$ is defined as $$\prod_{i\in I}A_i=\{f:I\to\bigcup A_i\mid f(i)\in A_i\}$$
I'm trying to prove the below theorem. While I'm able to construct a desired mapping and intuitively found that it is a bijection, I'm unable to prove that this mapping is actually bijective in a formal proof. I also found that it's easier to use the definition of cartesian product as n-array, but I would like to use the definition of cartesian product as a function.
Let $I_{n+1} = \{i\in\mathbb N\mid 1\leq i\leq n+1\}$ and $(A_i\mid i\in I_{n+1})$ be a family of finite sets. Then $|A_{n+1}\times\prod_{i\in I_n}A_i|=|\prod_{i\in I_{n+1}}A_i|$ where $|X|$ is the cardinality of $X$.
First, we generate a family of indexed sets $(B_i\mid i\in I_2)$ as follows: $B_1=A_{n+1}$ and $B_2=\prod_{i\in I_n}A_i$. Then we construct a mapping $f:B_1\times B_2\to\prod_{i\in I_{n+1}}A_i$ such that $\{(0,b_1),(1,b_2)\}\mapsto \{(n+1,b_1)\cup b_2\}$ where $b_1\in B_1=A_{n+1},b_2\in B_2=\prod_{i\in I_n}A_i$.
How can I proceed to prove that $f$ is bijective?