a ring of fractions which has finitely many maximal ideals

Let $R$ be a commutative ring and $P_1,\ldots ,P_n$ be prime ideals of $R$. If $S=\bigcap_{i=1}^n (R\setminus P_i)$ then show that the ring of fractions $S^{-1}R$ has only finitely many maximal ideals.

The above result will also follow if we can show that the set $\lbrace P\in\mbox{ Spec }(R) : P\subseteq\bigcup_{i=1}^n P_i\rbrace$ has only finitely many maximal elements ( where the partial order is natural inclusion).

It is a standard result in the theory of localizations that there is a one-to-one, inclusion preserving correspondence between the prime ideals of $S^{-1}R$ and the prime ideals of $R$ that are disjoint from $S$.

Thus, the prime ideals of $S^{-1}R$ in the case where $S=R\setminus (\cup P_i)$ corresponds precisely the prime ideals of $R$ that are contained in $\cup P_i$. So we just need to determine what are the ideals of $R$ that are maximal with respect to being contained in $\cup P_i$.

Suppose that $J$ is an ideal of $R$ that is contained in $\cup P_i$. I claim that in fact it is contained in one of the $P_j$.

We proceed by induction on $n$. If $n=1$, there is nothing to prove. If $n=2$, let $J\subseteq P_1\cup P_2$. If $J$ is not contained in either $P_1$ nor $P_2$, let $a\in J\setminus P_1$ (and hence, necessarily, $a\in P_2$) and $b\in J\setminus P_2$ (and hence, necessarily, $b\in P_1$). Then $a+b\in J\subseteq P_1\cup P_2$. But $a\in P_2$, $b\notin P_2$, so $a+b\notin P_2$; and $a\notin P_1$, $b\in P_1$, so $a+b\notin P_1$. Thus, $a+b\notin P_1\cup P_2$, a contradiction.

Assume the result holds for fewer than $n$ primes, $n\gt 2$. If $J$ is contained in the union of any proper subcollection of $P_i$, then we can apply induction. Thus, we may assume that $J$ is not contained in the union of any $n-1$ of the ideals. So for each $j$ we can pick $a_j$ such that $$a_j \in J\setminus \bigcup_{\stackrel{i=1}{i\neq j}}^{n} P_i.$$ Note in particular that $a_j\in P_j$.

Now, consider $a_1\cdots a_{n-1}+a_n$. Since $a_i\in P_i$, then $$a_1\cdots a_{n-1}\in P_1\cap\cdots \cap P_{n-1}\subseteq P_1\cup\cdots\cup P_n.$$ But since $a_i\notin P_n$ for $i=1,\ldots,n-1$ and $P_n$ is prime, then $a_1\cdots a_{n-1}\notin P_n$. On the other hand, $a_n\in P_n\setminus(P_1\cup\cdots \cup P_{n-1})$.

But then $a_1\cdots a_{n-1}+a_n\notin P_n$, since $a_n\in P_n$ but $a_1\cdots a_{n-1}\notin P_n$; and $a_1\cdots a_{n-1}+a_n\notin P_1\cup\cdots \cup P_{n-1}$, since $a_1\cdots a_{n-1}\in P_1\cup\cdots \cup P_{n-1}$ but $a_1\cdots a_{n-1}\notin P_n$. This is a contradiction, since it plainly lies in $J$. This completes the proof of the claim.

Therefore, if $J$ is an ideal of $R$ that is maximal among those that are contained in $P_1\cup\cdots\cup P_n$, then it must be equal to one of the $P_i$ (since it is contained in at least one, and if the inclusion is proper, then that $P_i$ would contradict the maximality).

Therefore, the maximal ideals of $S^{-1}R$ are exactly the ideals that correspond to $P_1,\ldots,P_n$: if $M$ is a maximal ideal of $S^{-1}R$, then it is also a prime ideal, hence corresponds to a prime $Q$ ideal of $R$ that is contained in $P_1\cup\cdots\cup P_n$, and maximality of $M$ implies maximality of $Q$ in $R$ among ideals contained in $P_1\cup\cdots\cup P_n$, which implies that $Q$ is equal to one of the $P_i$, which means $M$ corresponds to one of the $P_i$. In particular, there are only finitely many such maximal ideals in $S^{-1}R$.

Hint $\$ This is known as prime avoidance: ideal $\rm\:I\not\subset P_i\ prime\:\Rightarrow\:I\not\subset \cup\, P_i.\:$ Here is the inductive step (for $\rm\:n=3)$. By induction there is $\rm\:r_1 \in I\:$ but $\rm\:r_1\not\in\:P_2\cup P_3.\:$ If $\rm\:r_1\not\in P_1\:$ we are done. Similarly there are $\rm\:r_2,r_3\in I,\:$ but $\rm\: r_2 \not\in P_1\cup P_3,\:$ and $\rm\: r_3\not\in P_1\cup P_2.\:$ Again, all $\rm\: r_i \in P_i,\:$ else the proof is complete. Hence $\rm\:r_i\in P_j \iff i = j,\:$ therefore

$$\rm I\, \ni\, r = r_2 r_3 + r_1 r_3 + r_1 r_2\, \not\in\, P_1\cup P_2\cup P_3$$

since, e.g. $\rm\:mod\ P_1\!:\ r_1\equiv 0\:\Rightarrow\: r\equiv r_2 r_3\not\equiv 0\:$ by $\rm\:r_2,r_3\not\equiv 0.\:$ Ditto for the other $\rm\:P_i.$