I want to prove that for a imaginary quadratic field $K/\mathbb Q$, $Cl(K)/2Cl(K)\simeq (\mathbb Z/2)^{r-1}$ where $r$ is the number of prime that ramify in $K$.
This question has appeared on this website, but I am not quite satisfied with the solutions. Here's my attempt. Please let me know if it looks good or there are any gaps.
Let odd prime $p$ ramify in $K$, let $p^*= (-1)^{\frac{p-1}{2}}p$. Notice that $K(\sqrt {p^*})$ contains $\mathbb Q( \sqrt {\frac{d}{p^*}})$. So $p$ is not totally ramified in the extension So $K(\sqrt { p^*})/K$ is unramified.
If $d=3 \mod 4$ then $2$ ramifies in $K$. $\mathbb Q(i)/\mathbb Q$ ramifies above $2$. since $K(i)$ contains $\mathbb Q (\sqrt {-d})$, $2$ is not totally ramified. So $K(i)/K$ is unramified. If $d= 2 \mod 4$, either $d/2$ or $d/-2$ is $1\mod 4$. So either $K(\sqrt 2)$ or $K(\sqrt {-2})$ is unramified. For the prime $2$, by $p^*$, we denote $i$ or $\sqrt 2$ or $\sqrt {-2}$, whichever is appropriate.
Let $L=K(\sqrt {p_1^*}, \dots , \sqrt {p_r^*} )$. This is an unramified extension of $K$. Furthermore, by Kummer theory its Galios group is $(\mathbb Z/2\mathbb Z)^{r-1}$.
Let $H_K$ be the Hilbet class field of $K$. Let $E$ be the maximal subsextension of $H_K/K$ such that the Galois group is $2$ torsion. Clearly, $L\subset E$. Let's look at $E/ \mathbb Q$. The only primes which ramify in this extension are the ones which ramify in $L$. And only ramified primes can have order 2. So $E=L$.
I haven't read through your solution carefully, but it certainly looks like a roundabout way to arrive at something close to the fundamental theorem from genus theory. Let me explain:
Genus theory says that for an imaginary quadratic discriminant $D$, $|Cl(D)[2]| = 2^{\mu - 1}$, where $\mu$ is defined as follows:
So for fundamental discriminants, genus theory says that $|Cl(D)[2]| = 2^{N-1}$ if $2 \nmid D$, and $2^N$ otherwise. Since $Cl(D)[2]$ is the kernel of the map $Cl(D) \to Cl(D) / 2Cl(D)$, we see that $|Cl(D) / 2Cl(D)| = |Cl(D)[2]|$ by some group theory and arithmetic. Thus $|Cl(D) / 2 Cl(D)|$ is as described above.
What does this have to do with primes that ramify in $K$? Well, a fundamental result in number theory says that the primes that ramify in $K$ are exactly the primes that divide $D$. So we see that if $2 \nmid D$, then every prime dividing $D$ is odd, and (using your notation for $r$) we have $r = N$. By the above, $|Cl(D)/2Cl(D)| = 2^{N - 1} = 2^{r-1}$. Otherwise $2 \mid D$, and $r = N + 1$, since $2$ also ramifies in $K$. Then again, we have in this case that $|Cl(D) / 2 Cl(D)| = 2^{N} = 2^{r - 1}$.
I'll recommend Cox's book Primes of the Form $x^2 + n y^2$, which gives the basic results of genus theory in the first section, and draws connections to the genus field in the second section. The reason what you've done "looks like" genus theory is because the field you've constructed is the genus field of $K$.