Solution (source code)

= Solution

Write $x=g^{-1}h$ and $S(x)=\sum_{\chi\in\widehat G}\chi(x)$, where $\widehat G$ is the <character group of a finite abelian group>. The <Fundamental theorem of finitely generated abelian groups> writes the <finite group> $G$ as a product of <cyclic groups>. A character of a <cyclic group> factor of order $r$ is determined by an arbitrary $r$th <root of unity>, so $|\widehat G|=|G|$. This description also shows that the characters separate points: if $x\ne1$, a nonzero coordinate of $x$ is detected by a character $\psi$ with $\psi(x)\ne1$.

Multiplication by $\psi$ permutes $\widehat G$, so
$$
S(x)=\sum_\chi(\chi\psi)(x)=\psi(x)S(x).
$$
For $x\ne1$ this forces $S(x)=0$. For $x=1$ every summand is one. Since $\chi(g)^{-1}\chi(h)=\chi(g^{-1}h)$, the <character-sum cancellation lemma> gives
$$
\boxed{\sum_{\chi\in\widehat G}\chi(g)^{-1}\chi(h)
=|G|\,\mathbf1_{g=h}.}
$$
All character values are <roots of unity>, so inversion here is also complex conjugation. This is the finite-abelian version of <character orthogonality>.