Family of sets , finite unions and intesections are also members of this family I'm really sorry if the title is not at all descriptive but I really cannot come up with anything better.

Let $\mathcal{A} \subset \mathbb{R}^{\mathbb{R}^{n}}$ be nonempty and $\mathcal{S(\mathcal{A})}$ be a family of all sets of the form $$\bigcup_{i=1}^{p} \bigcap_{j=1}^{q} \{ x\in \mathbb{R}^{n}: f_{i}(x)=0, \ g_{ij}(x)>0 \} \ \ p,q \in \mathbb{N}, \ f_{i}, g_{ij} \in \mathcal{A}\;.$$ Show that finite unions, finite intersections and complements (here some assumptions about $\mathcal A$ may be needed) of $\mathcal{S(\mathcal{A})}$'s elements are also members of $\mathcal{S(\mathcal{A})}$.

We could consider $\mathcal{A}$ as a set of functions which to every polynomial $P \in \mathbb{R}^n$ assign $x \in \mathbb{R}$. Could that $x$ be a root? I'm not sure. It doesn't make much sense that way.
Could you help me?
 A: First note that if $g_{i,q+1}:\Bbb R^n\to\Bbb R$ is any constant function with positive value,
$$\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}=\bigcap_{j=1}^{q+1}\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\;,$$
since 
$$\begin{align*}
\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{i,q+1}(x)>0\right\}&=\left\{x\in\Bbb R^n:f_i(x)=0\right\}\\
&\supseteq\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\;.
\end{align*}$$
Suppose that 
$$S=\bigcup_{i=1}^p\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}$$
and
$$T=\bigcup_{i=1}^r\bigcap_{j=1}^s\left\{x\in\Bbb R^n:h_{i}(x)=0\text{ and }k_{ij}(x)>0\right\}\;.$$
Without loss of generality assume that $q\le s$. If $q<s$, let $g_{ij}$ be a positive constant function for each $i=1,\dots,p$ and $j=q+1,\dots,s$; by the previous observation we may then write
$$S=\bigcup_{i=1}^p\bigcap_{j=1}^s\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\;.$$
Now for $i=1,\dots,r$ and $j=1,\dots,s$ let $f_{p+i}=h_i$ and $g_{p+i,j}=k_{ij}$; then
$$S\cup T=\bigcup_{i=1}^{p+r}\bigcap_{j=1}^s\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}\;,$$
and an easy induction shows that $\mathcal{S}$ is closed under finite unions.
To show that $T\cap S\in\mathcal{S}$, note first that
$$\begin{align*}
&T\cap\bigcup_{i=1}^p\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\\
&\qquad\quad=\bigcup_{i=1}^p\left(T\cap\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\right)\;,
\end{align*}$$
so it suffices to show that 
$$T\cap\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}$$
for $i=1,\dots,p$. This in turn will follow by an easy induction if we can show that
$$T\cap\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}$$
for a fixed $i$ and $j$. But
$$\begin{align*}
&T\cap\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\\
&\qquad=\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\cap\bigcup_{i=1}^r\bigcap_{j=1}^s\left\{x\in\Bbb R^n:h_{i}(x)=0\text{ and }k_{ij}(x)>0\right\}
\end{align*}$$
is a finite union of sets of the form
$$\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\cap\bigcap_{j=1}^s\left\{x\in\Bbb R^n:h_{i}(x)=0\text{ and }k_{ij}(x)>0\right\}\;,$$
which clearly belong to $\mathcal{S}$, so indeed
$$T\cap\left\{x\in\Bbb R^n:f_i(x)=0\text{ and }g_{ij}(x)>0\right\}\in\mathcal{S}$$
and hence $T\cap S\in\mathcal{S}$.
$$\begin{align*}
\Bbb R^n\setminus S&=\Bbb R^n\setminus\bigcup_{i=1}^p\bigcap_{j=1}^q\left\{x\in\Bbb R^n:f_{i}(x)=0\text{ and }g_{ij}(x)>0\right\}\\
&=\bigcap_{i=1}^p\bigcup_{j=1}^q\left\{x\in\Bbb R^n:f_i(x)\ne 0,\text{ or }g_{ij}(x)\le 0\text{ for some }j\right\}\;,
\end{align*}$$
so by what we’ve already done it suffices to show that each
$$\left\{x\in\Bbb R^n:f_i(x)\ne 0,\text{ or }g_{ij}(x)\le 0\text{ for some }j\right\}\in\mathcal{S}\;.$$
The set $$\left\{x\in\Bbb R^n:f_i(x)\ne 0,\text{ or }g_{ij}(x)\le 0\text{ for some }j\right\}$$
is the union of the following sets:
$$\begin{align*}
&\left\{x\in\Bbb R^n:f_i(x)>0\right\}\;,\\
&\left\{x\in\Bbb R^n:f_i(x)<0\right\}=\left\{x\in\Bbb R^n:-f_i(x)>0\right\}\;,\\
&\left\{x\in\Bbb R^n:g_{ij}(x)=0\right\}\;,\text{ and}\\
&\left\{x\in\Bbb R^n:g_{ij}(x)<0\right\}=\left\{x\in\Bbb R^n:-g_{ij}(x)<0\right\}\;.
\end{align*}$$
Can you show that each of them is in $\mathcal{S}$ and hence that their union is as well?
A: The elements of $\mathbb{R}^{\mathbb{R}^n}$ are the functions from $\mathbb{R}^n$ to $\mathbb{R}$, and so $\mathcal{A}$ is some set of such functions. That is, if $f\in\mathcal{A}$, then $f$ assigns to each point $p\in\mathbb{R}^n$ a number $f(p)\in\mathbb{R}$. 
Note that these don't have to be polynomial functions necessarily; for example, the function $f$ defined by $f(x,y,z) = |x|^{y+\sin(z)}$ is in $\mathbb{R}^{\mathbb{R}^3}$ but is not a polynomial function.
When you wrote $x$ rather than $f(p)$ in your question, note that it is not playing the same role as the variable $x$ in definition of $\mathcal{S}(\mathcal{A})$ -- the $x$ involved there are elements of $\mathbb{R}^n$, not $\mathbb{R}$. If $n>1$ then it doesn't actually make sense for $f(p)$ to be a "root" of $f$, because $f(f(p))$ is not defined.
