Let $X$ be a subset in $[-1,1]^{n_0}\,{\subset}\,\Real^{n_0}$ defined by the formula \[ X=\{ {\bf x}_0\,{\mid}\,Q_1{\bf x}_1 Q_2{\bf x}_2 \cdots Q_{\nu}{\bf x}_{\nu} (({\bf x}_0,{\bf x}_1,\,{\ldots}\,,{\bf x}_{\nu}) \in X_{\nu})\}, \] where $Q_i \in \{ \exists, \forall \}$, $Q_i \neq Q_{i{+}1}$, ${\bf x}_i \in \Real^{n_i}$, and $X_{\nu}$ may be either an open or a closed set in $[-1,1]^{n_0+ \cdots +n_{\nu}}{\!}$, being the difference between a finite CW-complex and its subcomplex. An upper bound on each Betti number of $X$ is expressed via a sum of Betti numbers of some sets defined by quantifier-free formulae involving $X_{\nu}$.
In important particular cases of semialgebraic and semi-Pfaffian sets defined by quantifier-free formulae with polynomials and Pfaffian functions respectively, upper bounds on Betti numbers of $X_{\nu}$ are well known. The results allow to extend the bounds to sets defined with quantifiers, in particular to sub-Pfaffian sets.