Proving that $\left(\mathbb Q[\sqrt p_1,\dots,\sqrt p_n]:\mathbb Q\right)=2^n$ for distinct primes $p_i$. I have read the following theorem:

If $p_1,p_2,\dots,p_n$ are distinct prime numbers, then$$\left(\mathbb Q\left[\sqrt p_1,\dots,\sqrt p_n\right]:\mathbb Q\right)=2^n.$$

I have tried to prove a more general statement but I have a problem at one point. (I still don't know how to prove the theorem above, too, because I don't know how not to use linear independence, which I do in the more general statement below.)  Could you please help me overcome the obstacle I've encountered? I will post the intended proof and make it clear where I'm having trouble.
I want to prove the following statement:

Let $n\geq 1$. The set $B_n:=\left\{\sqrt {p_1^{\epsilon_1}}\sqrt {p_2^{\epsilon_2}}\cdots\sqrt {p_n^{\epsilon_n}}\,|\,(\epsilon_1,\epsilon_2,\cdots,\epsilon_n)\in\{0,1\}^n\right\}$ has $2^n$ elements and is a $\mathbb Q-$basis of $\mathbb Q\left[\sqrt p_1,\sqrt p_2,\cdots,\sqrt p_n\right].$

The proof will be by induction.
For $n=1,$ we have $B_n=\left\{1,\sqrt {p_1}\right\}.$ It is clear that $\sqrt{p_1}\neq 1,$ so the set has $2=2^1$ elements. It is the basis of $\mathbb Q[\sqrt{p_1}]$ because the minimal polynomial of $\sqrt {p_1}$ over $\mathbb Q$ has degree $2,$ and there is a theorem that $K[a]$ has $a^0,\cdots,a^{d-1}$ as a basis, where $d$ is the degree of the minimal polynomial of $a$ over $K$.
Suppose the statement is true for $n-1$, where $n\geq 2.$ We have 
$$
\left(B_n=B_{n-1}\cup\sqrt{p_n}B_{n-1}\right)\text { and } \left(B_{n-1}\cap\sqrt{p_n}B_{n-1}=\emptyset\right),
$$
which is easy to see. It is also easy to see that $\operatorname{card}(B_{n-1})=\operatorname{card}(\sqrt{p_n}B_{n-1}),$ and therefore 
$$
\operatorname{card}B_{n}=2^n.
$$
Let 
$$
\sum_{x\in B_{n}}q_xx=0
$$
for some $\{q_x\}_{x\in B_n}\subset\mathbb Q.$ Let $p(x):=\sqrt{p_n}x$ for all $x\in B_{n-1}.$ We have
$$
\sum_{x\in B_{n}}q_xx=\sum_{x\in B_{n-1}} q_xx+\sum_{x\in \sqrt{p_n}B_{n-1}} q_xx=\sum_{x\in B_{n-1}} q_xx+\sum_{x\in B_{n-1}} q_{p(x)}\sqrt{p_n}x.
$$
Therefore 
$$
\sum_{x\in B_{n-1}} q_xx=-\sqrt{p_n}\sum_{x\in B_{n-1}} q_{p(x)}x,\tag1
$$
and we can make the following division iff $q_{p(x)}\neq 0$ for all $x\in B_{n-1}$ (because $B_{n-1}$ is linearly indepentent over $\mathbb Q$): 
$$
\sqrt{p_n}=-\frac{\sum_{x\in B_{n-1}} q_xx}{\sum_{x\in B_{n-1}} q_{p(x)}x},
$$
The right-hand side belongs to $\mathbb Q\left[\sqrt p_1,\sqrt p_2,\cdots,\sqrt p_{n-1}\right],$ so we have 
$$
\sqrt{p_n}\in \mathbb Q\left[\sqrt p_1,\sqrt p_2,\cdots,\sqrt p_{n-1}\right].
$$
Therefore we can write $\sqrt{p_n}$ uniquely in the basis $B_{n-1}$.
$$
\sqrt{p_n}=\sum_{y\in B_{n-1}}c_yy
$$
for some $\{c_y\}_{y\in B_{n-1}}\subset \mathbb Q.$
After squaring this equation we will obtain
$$
p_n=\sum_{y\in B_{n-1}}c_y^2y^2+2\sum_{y,z\in B_{n-1}}c_yc_zyz.
$$
The last sum must be zero because it is not in $\mathbb Q$ and because after reducing it, we obtain a representation of $p_n$ in the basis $B_{n-1},$ which is unique. Thus 
$$p_n=\sum_{y\in B_{n-1}}c_y^2y^2.$$
Unfortunately, I can't prove that $c_yc_z$ is always zero. This was my first thought, but clearly there's trouble with the possibility of reductions in
$$
\sum_{y,z\in B_{n-1}}c_yc_zyz.
$$
Different pairs $y,z$ may yield the same element of $B_{n-1}$ in the product $yz.$ This happens for example when $y=\sqrt 5\sqrt 3,$ $z=\sqrt 5\sqrt 2,$ and $y'= \sqrt 11\sqrt 2,$ $z'=\sqrt 11\sqrt 3$.
If it were true that $c_yc_z$ is always zero, I would be able to continue my proof as follows. We would have only one $y_0$ such that $c_{y_0}\neq 0$ and we'd get
$$p_n=c_{y_0}^2y_0^2.$$
Let $c_{y_0}=\frac kl$. We can write
$$l^2p_n=k^2y_0^2.$$
But $y_0^2$ is the product of some primes different from $p_n$. Therefore the greatest  power of $p_n$ that divides the right-hand side is even. However, the greatest power of $p_n$ that divides the left-hand side is odd. A contradiction.
The contradiction proves that $q_{p(x)}=0$ for all $x\in B_{n-1}.$ Hence $(1)$ gives us that 
$$
\sum_{x\in B_{n-1}} q_xx=0
$$
and linear independence of $B_{n-1}$ gives us that $q_x=0$ for all $x\in B_{n-1}.$
This gives us that $B_n$ is linearly independent. It generates the whole $\mathbb Q\left[\sqrt p_1,\sqrt p_2,\cdots,\sqrt p_n\right]$ because 
$$
\mathbb Q\left[\sqrt p_1,\sqrt p_2,\cdots,\sqrt p_n\right]=\left(\mathbb Q\left[\sqrt p_1,\sqrt p_2,\cdots,\sqrt p_{n-1}\right]\right)\left[\sqrt{p_n}\right].
$$
This would end the proof.
 A: This is a minor variant of Jyrki's answer.
We want to prove the statements: 
(1) If $p_1,...,p_n$ are distinct primes, then there are automorphisms $\tau_i$, ($i=1,...,n$), of $\mathbb Q[\sqrt{p_1},...,\sqrt{p_n}]$ such that $\tau_i\,\sqrt{p_j}=(-1)^{\delta_{ij}}\sqrt{p_j}$ for all $i,j$.
(2) If $p_1,...,p_n$ are distinct primes, then $\sqrt{p_n}\notin\mathbb Q[\sqrt{p_1},...,\sqrt{p_{n-1}}]$.
Clearly (1) and (2) are equivalent. [By this we mean that (1) holds for all $n$-tuples $(p_1,...,p_n)$ of distinct primes if and only if (2) holds for all such $n$-tuples.]
Assume that (2) is false, and let $(p_1,...,p_n)$ be a counterexample to (2) with $n$ minimum. In particular we have 
$$
\sqrt{p_n}\in K:=\mathbb Q[\sqrt{p_1},...,\sqrt{p_{n-1}}].
$$ 
Furthermore, the automorphisms $\tau_i$, ($i=1,...,n-1$), of $K$ are well-defined. 
We easily check (3) and (4) below: 
(3) For all $x$ in $K$ we have $\tau_i\,x=x$ if and only if $x$ is in the subfield generated by the $\sqrt{p_j}$ for $j\neq i$, and 
(4) $\tau_i\,x=x$ for all $i$ if and only if $x$ is in $\mathbb Q$.
(5) We have $\tau_i\,\sqrt{p_n}=-\sqrt{p_n}$. (Indeed, in view of (3), the equality $\tau_i\,\sqrt{p_n}=\sqrt{p_n}$ would contradict the minimality of $n$.)
Now (5) and (4) imply that
$$
\sqrt{\frac{p_n}{p_1\cdots p_{n-1}}}
$$ 
is in $\mathbb Q$, which is easily seen to be false.
A: HINT $\ $ An inductive proof follows easily from this
LEMMA $\rm\ \ [K(\sqrt{a},\sqrt{b}) : K] = 4\ $ if  $\rm\ \sqrt{a},\ \sqrt{b},\ \sqrt{a\:b}\ $  all are not in $\rm\:K\:$ and $\rm\: 2 \ne 0\:$ in $\rm\:K\:.$
Proof $\ \ $  Let  $\rm\ L = K(\sqrt{b})\:.\:$ Then $\rm\:  [L:K] = 2\:$  via  $\rm\:\sqrt{b}  \not\in K\:,\:$  so it is sufficient to prove $\rm\: [L(\sqrt{a}):L] = 2\:.\:$ It fails only if  $\rm\:\sqrt{a} \in L = K(\sqrt{b})\ $ and then $\rm\ \sqrt{a}\ =\  r + s\ \sqrt{b}\ $  for $\rm\ r,s\in K\:.\:$ But that is impossible since squaring yields $\rm(1):\ \ a\ =\ r^2 + b\ s^2 + 2\:r\:s\  \sqrt{b}\:,\: $ which contradicts hypotheses as follows:  
$\rm\qquad\qquad rs \ne 0\ \ \Rightarrow\ \  \sqrt{b}\ \in\  K\ \ $ by solving $(1)$ for $\rm\sqrt{b}\:,\:$ using  $\rm\:2 \ne 0$  
$\rm\qquad\qquad\  s = 0\ \ \Rightarrow\ \  \ \sqrt{a}\ \in\  K\ \ $  via  $\rm\ \sqrt{a}\ =\ r \in K$ 
$\rm\qquad\qquad\  r = 0\ \ \Rightarrow\ \  \sqrt{a\:b}\in K\ \ $  via  $\rm\ \sqrt{a}\ =\ s\ \sqrt{b}\:,\: \ $times $\rm\:\sqrt{b}\quad\quad$ QED
Using the above as the inductive step one easily proves the following result of Besicovic.
THEOREM $\ $  Let $\rm\:Q\:$ be a field with $2 \ne 0\:,\:$ and $\rm\ L = Q(S)\ $ be an extension of $\rm\:Q\:$ generated by $\rm\: n\:$  square roots  $\rm\ S = \{ \sqrt{a}, \sqrt{b},\ldots \}$ of elts  $\rm\ a,\:b,\:\ldots \in  Q\:.\:$
If every nonempty subset of $\rm\:S\:$ has product not in $\rm\:Q\:$ then each successive 
adjunction  $\rm\ Q(\sqrt{a}),\  Q(\sqrt{a},\:\sqrt{b}),\:\ldots$ doubles the degree over $\rm\:Q\:,\:$ so, in total, $\rm\: [L:Q] \ =\ 2^n.\:$  Hence the $\rm2^n$ subproducts of the product of $\rm\:S\:$ comprise a basis of $\rm L$ over $\rm\:Q\:.$
A: Nothing wrong with the other answers. I just want to try my hand at this. I will prove by induction on the number of primes $n$ that


*

*For $K_n=\Bbb{Q}(\sqrt{p_1},\sqrt{p_2},\ldots,\sqrt{p_n})$ we have $[K_n:\Bbb{Q}]=2^n$ AND

*The extension $K/\Bbb{Q}$ is Galois with Galois group isomorphic to the $n$-fold Cartesian product $(C_2)^n$ generated by the automorphisms $\tau_i, i=1,2,\ldots,n,$ such that $\tau_i(\sqrt{p_j})=(-1)^{\delta_{ij}}\sqrt{p_j}$.


The base case $n=1$ is easy. Skipping that. Assume that the claim holds when we have $k$ primes.
Claim 1. $\sqrt{p_{k+1}}\notin K_k$.
Proof. Assume contrariwise that $\sqrt{p_{k+1}}\in K_k$. We know that $\Bbb{Q}(\sqrt{p_{k+1}})$ is a quadratic extension of $\Bbb{Q}$. By Galois theory the quadratic subfields of $K_k$ are exactly the fixed fields of index two subgroups of $\operatorname{Gal}(K_k/\Bbb{Q})$. By part two of the induction hypothesis, this Galois group is isomorphic to the additive group of a $k$-dimensional vector space $V$ over $\Bbb{F}_2$. The non-degenerate bilinear form, $B:V\times V\to\Bbb{F}_2, B\big((x_1,x_2,\ldots,x_k),(y_1,y_2,\ldots,y_k)\big)=\sum_{i=1}^kx_iy_i$, shows that the maximal subgroups are exactly the duals of the minimal subgroups of $V$. There are $2^k-1$ of those, namely the ones containing a single non-zero vector of $V$. Therefore $K_k$ has exactly $2^k-1$ quadratic subfields. But if $S$ is the product of any non-empty subset of $\{p_1,p_2,\ldots,p_k\}$, then $\Bbb{Q}(\sqrt{S})$ is a quadratic subfield of $K_k$. Such quadratic fields are easily seen to be distinct (only need the analogue of the argument showing $\sqrt2\notin\Bbb{Q}(\sqrt3)$ for this). Similarly we see that $\sqrt{p_{k+1}}$ is not in any of those quadratic subfields. The claim follows.
Claim 2. The inductive step is valid.
Proof. By Claim 1. $[K_{k+1}:K_k]=2$, so part 1 one of the induction hypothesis implies part 1 of the inductive step. Because $K_{k+1}$ is the splitting field of $\prod_{i=1}^{k+1}(x^2-p_i)\in\Bbb{Q}[x]$, it follows that $K_{k+1}$ is Galois over $\Bbb{Q}.$ Any automorphism $\tau\in \operatorname{Gal}(K_{k+1}/\Bbb{Q})$ is fully determined if we know the images $\tau(\sqrt{p_i}), i=1,2,\ldots,k+1$. There are two choices for each of those images (up to sign) - a total of $2^{k+1}$ combinations. Because the extension is Galois, we know that there will be exactly $2^{k+1}$ automorphisms, so all those sign combinations must occur. Q.E.D.
A: It may be worth mentioning that another approach is to use the fact that $\sqrt p\in\mathbb Q(\zeta_{4n})$ if and only if $p$ divides $n,$ where $\zeta_m=e^{2\pi i/m}.$
The if part follows for $p$ odd from the Gauss sum $g(p)^2=(-1)^{(p-1)/2}p,$ where $g(p)=\sum_{r=1}^{p-1}\left(\frac rp\right)\zeta_p^r,$ while for $p=2,$ we have $\sqrt 2=\zeta_8+\zeta_8^{-1}.$ The only if part is because $\mathbb Q(\zeta_l)\cap\mathbb Q(\zeta_m)=\mathbb Q(\zeta_h),$ where $h$ is the highest common factor of $l$ and $m.$ Hence if $\sqrt p\subseteq\mathbb Q_{4n}$ with $n$ prime to $p,$ then $\sqrt p\in\mathbb Q(i),$ which is impossible.
Hence, if $p$ and $p_{1,\dots,r}$ are primes and $\sqrt p\in\mathbb Q(\sqrt{p_1},\dots,\sqrt{p_r}),$ then $
\sqrt p\in\mathbb Q(\zeta_{4p_1\cdots p_r}),$ and we conclude $p$ divides $p_1\dots p_r.$ In particular, if $p_1,\dots,p_r$ are distinct then $\mathbb Q(\sqrt{p_1},\dots,\sqrt{p_i})\neq\mathbb Q(\sqrt{p_1},\dots,\sqrt{p_{i-1}})$ for $1\le i\le r-1.$ Therefore adjoining each square root gives an extension of degree 2, as required.
A: Let us show that for  $K$ field of characteristic $\ne 2$, and $d_1$, $\ldots$, $d_n \in K^{\times}$, linearly independent in $K^{\times}/(K^{\times})^2$, the extension $K(\sqrt{d_1}, \ldots, \sqrt{d_n})/K$ is of degree $2^n$.  By induction on $n$. Assume true for $n$. The extension $K(\sqrt{d_1}, \ldots, \sqrt{d_n})/K$ has a basis $\sqrt{d_I}$, for $I \subset \{1, \ldots, n\}$ ( for instance $d_{\{3,5,6\}} = d_3 \cdot d_5 \cdot d_6$). We have the multiplications formula
$$\sqrt{d_I} \cdot \sqrt{d_J} = d_{I\cap J} \cdot \sqrt{d_{I\Delta J}}$$
Therefore, for every $\epsilon = (\epsilon_1, \ldots, \epsilon_n) \in \{-1,1\}^n$, we have an automorphism of
$K(\sqrt{d_1}, \ldots, \sqrt{d_n})/K$ given by
$$\epsilon (\sqrt{d_I}) = \prod_{i\in I} \epsilon_i \cdot \sqrt{d_I}= \epsilon_I\cdot \sqrt{d_I}$$
We get in this way a faithful action of $(\{\pm 1\}^n, \cdot)$.
Consider now an element of $K(\sqrt{d_1}, \ldots, \sqrt{d_n})$
$$x = \sum_{I\subset\{1,\ldots, n\}} \alpha_I \sqrt{d_I}$$
Assume that there exists $I$, $J$ distinct subsets of $\{1, \ldots, n\}$ and nonvoid, such that $\alpha_I$, $\alpha_J\ne 0$. Let us show that for every element $\sigma$ in $\{-1,1\}^2$ there exists $\epsilon\in \{-1,1\}^n$, such that $\epsilon_I= \sigma_1$, and $\epsilon_J= \sigma_2$. Translation: given two distinct non-zero elements $v$, $w$ in $\mathbb{F}_2^n$, the map $(\mathbb{F}_2^n)^{*} \to \mathbb{F}_2^2$, $\phi\mapsto (\phi(v), \phi(w))$ is surjective.  Left as exercise. Back to the problem. For such an $x$, its orbit would have cardinality at least $4$. Therefore, all the  quadratic elements of $K(\sqrt{d_1}, \ldots, \sqrt{d_n})$ are of the form
$$x= \alpha + \beta \sqrt{d_I}$$
for some $I\subset \{1, \ldots, n\}$.
Now, to the induction step. Let $d_{n+1}$ not a square multiple of one of the $d_I$'s, for $I\subset\{1, \ldots, n\}$. Then by the above, $\sqrt{d_{n+1}}\not \in K(\sqrt{d_1}, \ldots, \sqrt{d_n})$, and so the extension
$$K(\sqrt{d_1}, \ldots, \sqrt{d_{n+1}})/K(\sqrt{d_1}, \ldots, \sqrt{d_n})$$
has degree $2$. We are done.
Note: We avoid  Galois theory, although we use automorphisms of fields.  In this way, the solution may be accessible to some interested high-school students (   use " unique writing" instead of "basis", work with $\mathbb{Q}$, in particular cases etc).
$\bf{Added:}$ The lemma that was used is proved below.
Lemma: Let $u$, $v\in \mathbb{F}_2^n$, $u\ne v$ and $v\ne 0$. Then there exists $w\in \mathbb{F}_2^n$ such that
$$u\cdot w= 0, \ \ v\cdot w = 1$$
This is clear if for the supports of the vectors we have $\sup v \not \subset \sup u$ ($w$ is has $1$-component $\ne 0$). Assume now that $\sup v \subset \sup u$. Then there exists two positions where $u$ is $1$, but $v$ is $0$ and $1$. Now take $w$ "the sum" of those components.
A: I think shortest way would be to use some Galois theory. Let $G_i=Gal(\mathbb{Q}(p_i)/\mathbb{Q})$. So we need to compute order of $G=Gal(\mathbb{Q}(p_1,p_2,...,p_n)/\mathbb{Q})$. But since $\mathbb{Q}(p_i)\cap \mathbb{Q}(p_j)=\mathbb{Q}$ for all $i\neq j$, so $G$ is isomorphic to $\prod G_i \implies |G|= \prod|G_i|=2^n$ ($G$ is isomorphic to $\prod G_i$ because taking $\sigma \in G$ and sending it to $(\sigma|_{G_i})_{i\in\{1,2,...n\}}$ is an isomorphism.
