# More on numbers of homomorphisms.

This is directly related to this question, but should be easier: Suppose for finite groups $G_1$ and $G_2,$ we know that for any group $H,$ $$|\rm{Hom}(G_1, H)| = |\rm{Hom}(G_2, H)|$$

Does it follow that $G_1 \simeq G_2?$ I would think that requiring that $H$ is finite should not make it less true, but whatever works for you.

-
@Serkan Yes, from your condition "for any finite group $H$, $|\text{Hom}(H,G_1)|=|\text{Hom}(G_2,H)|$ and $|\text{Hom}(H,G_2)|=|\text{Hom}(G_1,H)|$" it follows that $G_1$ and $G_2$ are groups of order $1$, and so they are isomorphic. –  bof Dec 22 '13 at 9:18

It seems to me that this question can be answered in the affirmative using the same idea (of Lovász) as that other question.

For finite groups $G$ and $H$, let $h(G,H)$ be the number of homomorphisms and $s(G,H)$ the number of surjective homomorphisms from $G$ to $H$.

Consider a finite group $H$. Let $H_1,\dots,H_n$ be all the proper subgroups of $H$ (or just the maximal ones). For $I\subseteq[n]=\{1,\dots,n\}$ let $H_I=\bigcap_{i\in I}H_i$ if $I\ne\emptyset$, and let $H_\emptyset=H$. By the in-and-out principle, for any finite group $G$ we have$$s(G,H)=\sum_{I\subseteq[n]}(-1)^{|I|}h(G,H_I).$$Therefore, if $G_1$ and $G_2$ are finite groups such that $h(G_1,H)=h(G_2,H)$ for every finite group $H$, it follows that $s(G_1,H)=s(G_2,H)$ for every finite group $H$, and in particular that $s(G_1,G_2)=s(G_2,G_2)\ge1$ and $s(G_2,G_1)=s(G_1,G_1)\ge1$, whence $G_1\cong G_2$.

-
Very nice argument! –  Igor Rivin Dec 22 '13 at 14:31