1 Introduction
The spectrum of a , denoted is the set of cardinalities of models of . Let be the set of such that is a spectrum of some formula is an interesting research area [Sch52, DJMM12]; it is known that SPEC=NE, i.e., is a spectrum of a first order formula iff the set of binary representations of the elements of is in the complexity class NE [Fag74, JS74]. However, the characterization of spectra remains open if we require our formula, or our models, to have additional properties. In [DK17] we study the complexity class (Forced Planar Spectra), which is the set of such that there exists a formula such that and all models of are planar. It is shown there that , where the set fo such that there exists a nondeterministic Turing machine which recognizes the binary representation of in time and space . However, this result is not satisfying, since space is very low; a construction of which allows more space is left as an open problem.
In this paper we construct a formula over a signature consisting of only binary relations (neighbors in the grid in all directions) and unary relations, and which axiomatizes rectangular grids which are not narrow, i.e., grids of dimensions where and . We show that it is impossible to give a similar axiomatization of rectangular grids which includes the narrow ones. Nonnarrow rectangular grids are planar graphs of bounded degree, and they can be used to simulate Turing machines, and thus we obtain the following corollary: for every pair of functions such that and . In fact, we get a bit more – we can actually simulate a nondeterministic onedimensional cellular automaton (1DCA) working in the given time and memory. While 1DCAs are less commonly taught than Turing machines, they are simpler to define and more powerful, since they can perform computations on the whole tape at once [Kop17].
2 Axiomatizing a rectangular grid
We obtain our goal by showing a firstorder formula whose all finite models are rectangular grids. A rectangular grid is a relational structure such that , and the relations , , , hold only in the following situations: , , , , as long as these vertices exist.
Geometry
We will use four binary relations , , , , which correspond to Left, Right, Up, Down, respectively. We will need axioms to specify that these four relations work according to the Euclidean square grid geometry.

Partial injectivity. Our relations are partial injective functions. That is, we have an axiom . For , we will write for the element such that (if it exists).

Inverses. . This axiom formalizes our interpretation of directions (that Left is inverse to Right and Up is inverse to Down).

Commutativity. Let and . Then . This axiom axiomatizes the Euclidean geometry of our grid: horizontal and vertical movements commute. Additionally, it enforces that whenever we can go horizontally and vertically from the given , we can also combine these two movements and move diagonally.
Binary Counters
We will require our grid to know its number of rows. To this end, we will introduce an extra relation . Intuitively, replace every vertex in the row , where is not defined, with 1 if , and 0 otherwise. The axioms in this section will enforce that the obtained number (written in the little endian binary notation) is the index of our row.

Horizontal Zero. . The binary number encoded in the first row is zero.

Horizontal Increment. To increment a (little endian) binary number, we change every bit which is either the leftmost one, or such that its left neighbor changed from 1 to 0. This can be written as the following formula: where .

No Horizontal Overflow. . This axiom makes sure that our binary counter does not overflow.
We also have analogous axioms for vertical binary counters, using an extra unary relation , counting from right to left, with the least significant bit on the bottom. See Figures 1a and 1c, where the vertices of the grid satisfying respectively and are shown (ignore the small white circles and dark grey boxes for now – they will be essential for our further construction).
Let be the conjunction of all axioms above.
Theorem 2.1
If is a connected finite model of and there exists an and a relation such that is not defined, then is a rectangular grid.
Proof Take and such that be not defined. Without loss of generality we can assume that (horizontal and vertical axioms are symmetrical). Furthermore, we can also assume that (since is the inverse of , if is not defined for some element, then so is ).
Let , where and . From the commutativity axiom, is not defined for any . Indeed, if was defined for , we have and defined, hence is defined too.
Let . From the Horizontal Increment and No Horizontal Overflow axioms, it is easy to show that . Furthermore, we have that . Therefore, there must exist such that is not defined. Let . Let be the greatest x such that is defined, and be the greatest such that is defined. Let , and for , let . It is straightforward that gives an isomorphism between the rectangular grid and .
3 Forbidding Tori
However, rectangular grids are not the only models of . Consider the torus , where is additionally connected (with the relation) to ), and is additionally connected to (with the relation), and we add the respective inverses to and . If and are empty relations, the torus satisifes all of our axioms. Additionally, if is a model of , then the disjoint union is also a model of .
To prevent this, we use the following result of Berger [Ber66].
Theorem 3.1
There exists a finite set of Wang tiles and relations such that there exists a tiling such that the following property holds:
(1) 
However, no periodic tiling satisfying 1 holds. A tiling is periodic iff there exists such that for each .
The original coloring by Berger used 20426 tiles. It is sufficient to use 11 tiles [JR15].
We add a new relation for every tile . We also add the following axioms:

Full tiling. Everything needs to have a color.

Correct tiling. For every pair of tiles such that , we have . For every pair of tiles such that , we have .
Let be the conjuction of and the axioms above.
Theorem 3.2
If is a finite, connected model of then is a rectangular grid.
Proof Take . If one of the relations , , , is not defined for some , then is a rectangular grid by Theorem 2.1. Otherwise, let , for , be the relation which is satisfied by . For or , replace by or by . According to the correct tiling axiom, the property (1) holds.
Since is finite, we must have and refer to the same element of our structure, even though . It is easy to show that is then the period of the tiling , which contradicts Theorem 3.1.
Theorem 3.3
There exists a formula such that the models of , restricted to relations , , , , are precisely the rectangular grids such that and .
Proof By adding an axiom that there exists exactly one element such that and are not defined, we obtain a formula whose all finite models are rectangular grids.
Now, take an rectangular grid G. From Theorem 3.1 there exists a tiling satisfying 1. Assign the relation to each . If and , we can also set iff th bit of is 1, and iff th bit of is 1. Such a model will satisfy . Note that if or , the respective overflow axiom will not be satisfied.
The number 2 in the theorem above can be changed to an integer by using ary counters instead of the binary ones. However:
Theorem 3.4
There is no formula over a signature consisting of , , , , and possibly extra unary relations whose all models restricted to relations , , , are precisely all rectangular grids. Furthermore, there is no such such that all models of are rectangular grids, and there exists such that for every a rectangular model of exists.
Proof We will be using Hanf’s locality lemma [Han65]. Let a neighborhood of the vertex , be the set of all vertices whose distance from is at most . Let a type of the vertex , , be the isomorphism type of . When we restrict to models of degree bounded by , there are only finitely many such types. Let be the set of all types. Let be the function that assigns to each type the minimum of and the number of vertices of type in .
Theorem 3.5 (Hanf’s locality lemma[Han65])
Let be a FO formula. Then there exist numbers and such that, for each graph , depends only on .
Let be a FO formula such that all models of are rectangular grids. Take and from Theorem 3.5. Let the rectangular grid be a model of , where . Let be the type of column , i.e., . For sufficiently large there will be and such that for and such that for every . Construct a new structure by adding a cylinder of dimensions to , i.e., , , , , , , , whenever the point on the right hand side exists, and undefined otherwise. For every unary relation we have iff . It is easy to verify that , and every of these types already appeared at least times, and thus from Theorem 3.5, .
4 Forced Planar Spectra
Corollary 4.1
Let be a set such that there exists a nondeterministic Turing machine (or 1DCA) recognizing the set of binary representations of elements of in time and memory , where and . Then there exists a firstorder formula such that all models of are planar graphs, and the set of cardinalities of models of is .
Proof Let , and let be a nondeterministic Turing machine or a nondeterministic 1DCA recognizing in time and space such that . A nondeterministic 1DCA is where , and the final symbol . It is defined similar to a Turing machine, but where computations are performed in parallel on all the tape cells: if is the content of the tape at position and time , then the relation must hold. The 1DCA accepts when it writes the symbol .
Let ; without loss of generality we can assume . It is well known that a first order formula on a grid can be used to simulate a Turing machine (or 1DCA): the bottom row is the initial tape, and our formula ensures that each other row above it is a correct successor of the row below it.
Let . We will construct a formula which will have a model consisting of:

elements which are not in the grid. The relation will hold for all the extra elements and only for them. The relation will hold only for the elements where . The relation gives a bijection between elements such that , and the elements such that .

Encoding of the number . We encode the number in the leftmost cells in the initial tape using two relations and in the following way: is the th digit of , and the relation signifies the end of the encoding: (if exists).

Similarly we encode the numbers , and .

An encoded run of which accepts the encoded value as the input.

An encoded run of an onedimensional cellular automaton which verifies that the relation holds for the encoded numbers. A onedimensional cellular automaton can add and multiply digit numbers in time [Atr65], hence our space will be sufficient.

Our grid already has the binary representations of and computed as the relations and . In the case of the computed is already where we need it (we only need to define the relation in the straightforward way). In the case of the computed is in the rightmost column, so we add extra wiring relations to move it to the beginning of the initial tape. In the case of , we need to compute the binary representation of the number of rows such that ; this can be computed in the same way as we have computed the number of all rows (using the relation similar to ).
Figure 1 shows the elements of our construction. In all the pictures, the small circles are the extra elements (where holds), and the other elements are the grid; the thin lines represent the relation , the thick lines represent the relations , , and . In 1a the black circles represent and gray boxes represent . In 1b the gray circles represent , black circles represent and gray circles represent . In 1c the black circles represent , while in 1d the extra thick lines represent , black circles represent , and gray boxes represent .
The formula will be the conjuction of the following axioms:

(1) , restricted to elements for which does not hold. This requires that we indeed have a rectangular grid.

(2) Axiomatiziations of the Turing machine .

(3) is a bijection.

(4) The set of elements satisfying has the correct shape: ,

(5) Axiomatiziation of , similar to the axiomatization of , but where we add 1 only in the rows where holds.

(6) Axiomatiziation of the wiring moving . The axioms are as follows: ; ; every v is connected to either (a) only and is undefined, (b) only and ; (c) only and ; (d) only and ; (e) only and is not defined; (f) nothing. Furthermore, in case (c), must either be also case (c) or the bottom left corner; whenever is undefined; and the case (a) holds whenever undefined, , and defined.

(7) .

(8) For every encoded number , .

(9) Axiomatiziations of the automaton .
Our model satisfies all these axioms.
On the other hand, suppose that has a model of size . By (1) this model constists of a rectangular grid and a number of extra elements. By (3) and (4) the relation is satisfied only for bottommost elements in the leftmost column. By (5) the encoded number equals the number of these elements. By (6) and (7) the encoded numbers and equal the dimensions of the grid. By (8) and (9) we know that the encoded number indeed equals the size of . By (2) we know that accepts , therefore .
References
 [Atr65] A. J. Atrubin. A onedimensional realtime iterative multiplier. IEEE Transactions on Electronic Computers, EC14(3):394–399, June 1965.
 [Ber66] Robert Berger. The Undecidability of the Domino Problem. American Mathematical Society, 1966.
 [DJMM12] A. Durand, N. D. Jones, J. A. Makowsky, and M. More. Fifty years of the spectrum problem: survey and new results. In preparation. Bulletin of Symbolic Logic, 18, 2012.
 [DK17] Anuj Dawar and Eryk Kopczynski. Bounded degree and planar spectra. Logical Methods in Computer Science, 13(4), 2017.
 [Fag74] R. Fagin. Generalized firstorder spectra and polynomialtime recognizable sets. Complexity of computation (proc. siamams sympos. appl. math., new york, 1973) (Providence, R.I.) (Richard M. Karp, editor), SIAMAMS Proceedings, vol. 7, American Mathematical Society, pages 43–73, 1974.
 [Han65] W. Hanf. Modeltheoretic methods in the study of elementary logic. JW Addison et al.The Theory of Models, NorthHolland, Amsterdam, pages 132–145, 1965.
 [JR15] Emmanuel Jeandel and Michaël Rao. An aperiodic set of 11 wang tiles. CoRR, abs/1506.06492, 2015.
 [JS74] N. D. Jones and A. L. Selman. Turing machines and the spectra of firstorder formulas. Journal of Symbolic Logic, 39:139–150, 1974.
 [Kop17] Eryk Kopczynski. Computational complexity on the blackboard. Fundam. Inform., 152:323–339, 2017.
 [Sch52] H. Scholz. Ein ungelöstes problem in der symbolischen logik. Journal of Symbolic Logic, 17:160, 1952.