using Euclid's lemma in mod proof 
a) Use Euclid’s Lemma to show that for every odd prime $p$ and every 
  integer $a$, if $a \not\equiv 0 \pmod p$, then
      $$x^2 \equiv a \pmod p$$
  has $0$ or $2$ solutions modulo $p$. 
b) Generalize this in the following way: 
Let $m = p_1\cdots p_r$ with distinct odd primes $p_1,\dots, p_r$ and let $a$ be an integer with 
  $\gcd(a, m) = 1$. Show that $$x^2 ≡ a \pmod m$$ has either $0$ or $2^r$ solutions modulo $m$.

My attempt at part a is as follows:
suppose $$x^2 ≡ a \pmod p$$ $$y^2 ≡ a \pmod p$$
Then $$x^2 ≡ y^2 \pmod p$$ $$x^2 - y^2 ≡ 0 \pmod p$$ $$(x+y)(x-y)≡ 0 \pmod p$$
So now using Euclid's lemma $p \mid (x+y)$ or $p\mid(x-y)$, hence $y ≡ x \pmod p$ or $y ≡ -x \pmod p$
This would mean the two solutions would be $x$ and $-x$ but I'm not sure how to prove that there must be exactly 2 or exactly 0 solutions.
Is it sufficient to say that if $x^2 ≡ a \pmod p$ then $(-x^2) ≡ a \pmod p$?
Is it also true and since $x \neq-x$ then there must be two solutions? That also doesn't cover the case of 0 solutions.

Let $m=p_1...p_r$ and the equation $x^2\equiv a \pmod m$ with $\gcd(a,m)=1$
Notice that $0$ solution is given by the fact that $a\not\equiv (\pm a')^2\pmod {m}$ ($a$ is not a quadratic residue $\pmod m$ if you prefer).
For each $i\in \{1,...,r\}$ we have $p_i \mid (x-a')$ or $p_i \mid (x+a')$ (it's Euclid's lemma).
For the first case we want to prove that if each $i\in \{1,...,r\},\ p_i \mid (x+a')$ then the product divides also $(x+a')$.
$(p_i)_{i\in\{1,...,r\}}$ are pairwise coprime. Using a contradiction and Euclid's lemma you can deduce that $\gcd(p_2...p_r=P_1,...,p_1...p_{r-1}=P_r)=1$. By Bachet Bezout's generalized identity you have the existence of $u_1,...,u_r\in \mathbb{Z}$ such that : $u_1P_1+...+u_rP_r=1$. by multiplying this identity by $(x+a')$ you get directly the fact that the product divides $(x+a')$.
So you get $(x+a')\equiv 0 \pmod m$ and the other case is similar. But it gives you $2$ solutions. We have just done the two main cases.
And if we consider two systems of CRT system (the one for $a'$ and the other for $-a'$), for each we get a unique solution $\pmod m$ so it finally gives the first two solutions.  
Here is the second case : we can consider that $p_k\mid(x+a')$ and $P_k=\frac{1}{p_k}\prod\limits_{i=1}^r p_i\mid (x-a')$ with $\gcd(p_k,P_k)=1$. By the CRT you have the system $x\equiv -a' \pmod {p_k}$ and $x\equiv a' \pmod{P_k}$ and have an unique $x \pmod m$. And you still have the other solution if you reverse $p_k$ and $P_k$. So it gives two solutions.
Then you continue, for instance $p_kp_l \mid (x+a')$ (with $l,r\in\{1,...,r\}$) and $P_k \mid (x-a')$ and $P_l \mid (x-a')$. You clearly have $p_k,p_l,P_k,P_l$ pairwise coprime (if you want to see it you can use Euclid's lemma and contradiction). Moreover the fact that $\gcd(p_k,p_l)=1=\gcd(P_k,P_l)$ by a consequence of Bachet-Bézout identity $p_k\mid (x+a')$ and $p_l \mid (x+a')$ (same for $P_k,P_l$). By the CRT you get a system of four equations which tell you that there exists an unique $x\pmod m$. By reversing you still have 2 solutions.
You can iterate the process and it gives you $2^r$ solutions.
