Zerodimensional, compact space is homeomorphic to spectrum of some ring -- elementary attempt Let $X$ be a zerodimensional (X has a base with clopen sets) and compact (quasicompact and Haussdorf) topological space and I would like to prove that $X\cong Spec(A)$ of some ring $A.$ I don't want to refer to Stone duality because I didn't had this theorem on a lecture. I try to show that $X\cong Spec(C(X,\mathbb{Z_2})),$ where latter means continuous functions with values in $\mathbb{Z_2}.$ It is related with question:
Spectrum of a ring homeomorphic to a compact, totally disconnected space
Obviously, I can show injectivity of map given in the answer of this question, continuity, also that image of open base set is open base set. I have a trouble to deal with the surjectivity (attempt which works for real-valued functions doesn't work here because of addition in $\mathbb{Z}_2.$ I'm stuck in this point and I would like ask you for a help. It is possible that ring on a right isn't correct. I underline that I don't want to use the Stone duality, I prefer an elementar way.
 A: Try to show that a prime ideal in $R=C(X,\Bbb Z_2)$ corresponds to a unique point in $X$ using compactness. (The sets $\{f^{-1}[\{0\}]: f \in I\}$ form a zero-set filter, when $I$ is an ideal in $R$ etc.) 
Then show $\textrm{Spec}(R) \simeq X$ via this correspondence.
A: Henno Brandsma has given lots of good hints, but let me spell things out a bit more for you. 
Let $R = C(X,\mathbb{Z}_2)$. For any $x\in X$, let $\mathfrak{p}_x = \{f\in R\mid f(x) = 0\}$. It is easy to check that this is a prime ideal in $R$. This gives a map $\varphi\colon X\to \text{Spec}(R)$, $x\mapsto \mathfrak{p}_x$. And this map is continuous, since a basic open set in $\text{Spec}(R)$ is given by $D_f = \{\mathfrak{p}\in \text{Spec}(R)\mid f\notin \mathfrak{p}\}$ for $f\in R$, and $$\varphi^{-1}(D_f) = \{x\in X\mid \mathfrak{p}_x\in D_f\} = \{x\in X\mid f\notin \mathfrak{p}_x\} = \{x\in X\mid f(x) \neq 0\} = f^{-1}(\{1\}),$$ which is open in $X$, since $f$ is continuous and $\mathbb{Z}_2$ is discrete.
Now it suffices to check that $\varphi$ has a continuous inverse $\psi\colon \text{Spec}(R)\to X$. For each $f\in R$, let $Z(f) = \{x\in X\mid f(x) = 0\}$. Let $\mathfrak{p}\in \text{Spec}(R)$, and let $Y = \bigcap_{f\in \mathfrak{p}} Z(f)$. 
Claim: $Y$ is nonempty.
Since $X$ is compact, and each set $Z(f)$ is closed, it suffices to show that the family $\mathcal{Z} = \{Z(f)\mid f\in \mathfrak{p}\}$ has the finite intersection property. Let $f,g\in \mathfrak{p}$. Then $Z(f)\cap Z(g) = Z(f+g+fg)$, and $f+g+fg\in \mathfrak{p}$, so $\mathcal{Z}$ is actually closed under finite intersections. Suppose for contradiction that $\emptyset\in \mathcal{Z}$, witnessed by $Z(f) = \emptyset$ with $f\in \mathfrak{p}$. Then $f$ is the constant function $1$, contradicting our assumption that $\mathfrak{p}$ is prime. We have shown that $\mathcal{Z}$ is closed under finite intersections and does not contain $\emptyset$, so by compactness its intersection $Y$ is nonempty. 
Claim: $Y$ is a singleton. 
Suppose for contradiction that $x,y\in Y$ with $x\neq y$. Since $X$ is zero dimensional and Hausdorff, there is some clopen set $C\subseteq X$ with $x\in C$ and $y\notin C$. Let $f$ be the function which sends all points in $C$ to $0$ and all points not in $C$ to $1$ ($f$ is continuous since $C$ is clopen). Then $f(1-f) = 0\in \mathfrak{p}$, and $\mathfrak{p}$ is prime, so either $f\in \mathfrak{p}$ or $(1-f)\in \mathfrak{p}$. In the first case, $y\notin Z(f)$ contradicting $y\in Y$, and in the second case, $x\notin Z(1-f)$, contradicting $x\in Y$. 
We have shown that $Y = \{x\}$ is a singleton, and we can define $\psi(\mathfrak{p}) = x$. 
It remains to check that $\varphi$ and $\psi$ are inverses and $\psi$ is continuous. I'll leave that to you. 
