For each given set $X$ in 2 and 3 we will give a sentence of the form $A\wedge B$ having spectrum precisely $X$, and so that the sentence $A\wedge\neg B$ has spectrum precisely the complement of $X$.
The idea is to consider the axioms for finite sets with addition, multiplication, a strict linear order, a smallest element with respect to the strict linear order, and with successors (e.g. think of positive integers modulo some $n$, in essence).
Consider the language $\mathcal{L}$ containing the following predicates (intuitive meaning to the right):
- $Ox: x=1$
- $Pxyz: x+y=z$
- $Qxyz: x\cdot y=z$
- $Rxy: x<y$
- $Sxy: x+1=y$
- $=$ (identity predicate)
Let $A'$ denote the conjunction of the following:
- $\forall x\,\forall y\,(Rxy\vee Ryx\vee x=y)$
- $\forall x\,\forall y\,(Rxy\Rightarrow\neg Ryx)$
- $\forall x\,\forall y\,((Rxy\wedge Ryz)\Rightarrow Rxz)$
These three sentences say $R$ is a strict linear ordering.
- $\forall x\,\forall z\,(Sxz\Leftrightarrow(Rxz\wedge\neg\exists y\,(Rxy\wedge Ryz)))$
This sentence says $S$ is the immediate successor predicate with respect to $R$.
- $\forall u\,(Ou\Leftrightarrow\neg\exists x\,Rxu)$
This sentence says there is a smallest element with respect to $R$.
- $\forall u\,(Ou\Rightarrow\forall x\,\forall z\,(Puxz\Leftrightarrow Sxz))$
- $\forall v\,\forall w\,(Svw\Rightarrow\forall x\,\forall z\,(Pwxz\Leftrightarrow\exists y\,(Syz\wedge Pvxy)))$
These two sentences define the addition predicate $P$ in terms of $S$ by induction along $R$.
- $\forall u\,(Ou\Rightarrow\forall x\,\forall z\,(Quxz\Leftrightarrow x=z))$
- $\forall v\,\forall w\,(Svw\Rightarrow\forall x\,\forall z\,(Qwxz\Leftrightarrow\exists y\,(Qvxy\wedge Pxyz)))$
These two sentences define the multiplication predicate $Q$ in terms of $S$ and $P$ by induction along $R$.
A key feature of the $\mathcal{L}$-sentence $A'$ is that for any finite $\mathcal{L}$-structure $M$, then $M\vDash A'$ if and only if $M$ is isomorphic to $M_{n}$ for some $n$, where $M_{n}$ denotes the $\mathcal{L}$-structure
$$M_{n}=(U_{n},O_{n},P_{n},Q_{n},R_{n},S_{n},I_{n}),$$
where
- $U_{n}=\{1,\ldots,n\}$
- $O_{n}=\{1\}$
- $P_{n}=\{(i,j,k)\in U_{n}^{3}:i+j=k\}$
- $Q_{n}=\{(i,j,k)\in U_{n}^{3}:i\cdot j=k\}$
- $R_{n}=\{(i,j)\in U_{n}^{2}:i<j\}$
- $S_{n}=\{(i,j)\in U_{n}^{2}:i+1=j\}$
- $I_{n}=\{(i,j)\in U_{n}^{2}:i=j\}$
Now, let us consider the set of Fibonacci numbers and its complement: Add a new unary predicate $F$ to the language $\mathcal{L}$, with $Fx$ intuitively meaning `$x$ is a Fibonacci number'. Then consider a sentence $A$ which is the conjunction of $A'$ with the following:
- $\forall u\,(Ou\Rightarrow Fu)$
- $\forall u\,\forall v\,(Ou\wedge Suv\Rightarrow Fv)$
- $\forall v\,(((\neg Ov)\wedge(\neg\exists u\,Ou\wedge Suv))\Rightarrow(Fv\Leftrightarrow(\exists x\,\exists y\,(Fx\wedge Fy\wedge Rxy\wedge Pxyv\wedge\forall z\,((Rxz\wedge Rzy)\Rightarrow\neg Fz)))))$
These sentences define $F$ recursively.
Next, consider the sentence stating that the largest number in our domain is a Fibonacci number, i.e.
$$B=\exists z\,((\neg\exists w\,Rzw)\wedge Fz).$$
The spectrum of $A\wedge B$ is precisely the set of Fibonacci numbers, and the spectrum of $A\wedge\neg B$ is precisely the complement of the set of Fibonacci numbers.
Finally, we consider the set $X=\{x^{y}:x,y\geq 2\}$ and its complement. We add a new ternary predicate $H$ to the original language $\mathcal{L}$, intuitively meaning $Hxyz: x^{y}=z$. We now define $A$ to be the conjunction of $A'$ with the following:
- $\forall u\,(Ou\Rightarrow\forall x\,\forall z\,((Huxz\Leftrightarrow Oz)\wedge(Hxuz\Leftrightarrow x=z)))$
- $\forall v\,\forall w\,(Svw\Rightarrow \forall x\,\forall z\,((Hxwz\Leftrightarrow\exists y\,(Hxvy\wedge Qyxz))\wedge(Hwxz\Leftrightarrow\exists y\,(Syz\wedge\exists t\,Qvty))))$
These sentences define exponentiation in terms of $S$ and $Q$ by induction along $R$.
Next, consider the sentence stating that the largest number in our domain is of the form $x^{y}$, with $x,y\geq 2$.
$$B=\exists z\,((\neg\exists w\,Rzw)\wedge \exists x\,\exists y\,((\neg Ox)\wedge(\neg Oy)\wedge Hxyz)).$$
The spectrum of $A\wedge B$ is precisely the set $X$, and the spectrum of $A\wedge\neg B$ is precisely the complement of $X$.
For the set $Y=\{x+y+x^{y}:x,y\geq 2\}$ provided by Noah Schweber in his answer, the language $\mathcal{L}$ and the $\mathcal{L}$-sentence $A$ are the same as for the set $X$ above, and $B$ is the $\mathcal{L}$-sentence
$$\exists z\,((\neg\exists w\,Rzw)\wedge \exists x\,\exists y\,\exists t\,\exists v((\neg Ox)\wedge(\neg Oy)\wedge Pxyt\wedge Hxyv\wedge Ptvz)).$$
The spectrum of $A\wedge B$ is $Y$ and the spectrum of $A\wedge\neg B$ is the complement of $Y$.