I've come across the following fact many times, and I used to take it for granted. However, I cannot think of a both beautiful and rigorous proof of it:
Fact 1:For two non-empty finite sets $A,B$ and map $f:A\times B\to \mathbb R,$ If we have $\big[\exists x_1\neq x_2\in A\times B,\ s.t. f(x_1)=f(x_2)=X\big]\Longrightarrow X=0,$
then we have $\displaystyle\sum_{x\in A}\sum_{y\in B} f(x,y)=\sum_{z\in f(A\times B)} z.$
Question: I know that we can prove this fact using induction, but is there some more beautiful proof of this fact? Thanks in advance.
Edit: I find that this fact also holds when $A,B$ are at most countable sets, and $f\geqslant 0.$
Update: Fact 1 is just a special case of the following fact:
Fact 2: For non-empty finite set $A$ and map $A\to \mathbb R,$ if we have $\big[\exists x_1,x_2\in A,\ s.t. f(x_1)=f(x_2)=X\big]\Longrightarrow X=0,$ then we have $\displaystyle\sum_{x\in A} f(x)=\sum_{z\in f(A)} z.$
Proof: According to @Christian Blatter's answer, we have$$\displaystyle\sum_{x\in A} f(x)=\sum_{z\in f(A)-\left\{0\right\}} \mathrm{Card}\big(f^{-1}(z)\big)z,$$ here $f^{-1}(z):=\left\{x\in A|\ f(x)=z\right\}.$
According to the assumption of fact 2, we have $\mathrm{Card}\big(f^{-1}(z)\big)=1$ for each $z\in f(A)-\left\{0\right\}.$ Thus we have$$\displaystyle\sum_{x\in A} f(x)=\sum_{z\in f(A)-\left\{0\right\}} z=\sum_{z\in f(A)} z.$$End of Proof
In addition, the following fact could be proved similarly:
Fact 3: For two non-empty finite sets $A, B$ and map $\sigma:A\to B,\ \psi:B\to \mathbb R,$ let $f=\psi\circ \sigma,$ denote the set of all zeros of a real-valued function $g$ as $\mathrm{Kel}(g),$ and the image set of a real-valued function $g$ as $\mathrm{Im}(g),$ then
a) if we have $\big[\exists x_1,x_2\in A,\ s.t. \sigma(x_1)=\sigma(x_2)=X\big]\Longrightarrow X\in \mathrm{Kel}(\psi),$ then we have $$\displaystyle\sum_{x\in A} f(x)=\sum_{z\in \mathrm{Im}(\sigma)} \psi(z).$$ b) if we have $\big[\exists x_1,x_2\in B,\ s.t. \psi(x_1)=\psi(x_2)=X\big]\Longrightarrow X=0,$ and $\sigma$ is injective, then we have $$\displaystyle\sum_{x\in A} f(x)=\sum_{z\in \psi\big(\mathrm{Im}(\sigma)\big)} z=\sum_{z\in \mathrm{Im}f} z.$$