# Stuck on a proof showing the correspondence between a specific homomorphism and the direct sum of two subgroups.

Let $H$ and $K$ be subgroups of an abelian group $G$. Show that

$$G=H\oplus K\iff \exists\phi : G\rightarrow H, \text{a homomorphism, st.} \phi(h)=h, \forall h\in H \text{ and } \ker(\phi)=K$$

I seem to be having an inordinate amount of trouble with this. Here's what I have so far:

$\textbf{The forward direction:}$ Assume $G=H\oplus K$. Then, construct a homomorphism $\phi : G\rightarrow H$ such that $\phi (x)=x, \forall x\in G-(K-\{0\})$ and equal to $0$, otherwise. (Initially I wrote $\forall x\in H$, but I am not convinced that $H$ and $K$ are the only potential subgroups in $G$.)

From our construction, it's easy to see that such a map leaves $\ker \phi = K$ and $\phi(h)=h, \forall h\in H$. Proof that such a $\phi$ is a homomorphism is trickier. If we consider $\phi (x+y)$ for $x,y\in G$, we have either $\phi (x+y)=x+y$ or $\phi (x+y) =0$ (mutually exclusive). But with either case, we essentially know nothing about $x$ and $y$, individually. Here, I am stuck.

Similarly, $\textbf{the backward direction: }$It is easy to show that $H\cap K=\{0\}$ and since $H,K\trianglelefteq G$, we have $H+K$ is a direct sum. If we let $g\in G$, we still have to show that $g=h+k$ for $h\in H, k \in K$. Here, I am stuck.

Please do NOT simply give me the answer. I would much rather be given a $\textbf{hint}$ to put me on the right path. Thank you!

Hint for the forward direction. Since $G=H\oplus K$, every element $x\in G$ can be written uniquely as $x=h+k$, where $h\in H$ and $k\in K$. Then let's define $\phi(x)=\phi(h+k)=h$. Using this definition of $\phi$, it'll be much easier to show that $\phi$ is a homomorphism.
Hint for the backward direction. For an arbitrary $x\in G$, let $h=\phi(x)$. Show that $x-h\in K$ by taking $\phi$ of $x-h$.