Manuscript Offprint
arXiv:2610.20937Two Variables and Two-Dimensional Structures
Abstract
We study the two-variable fragment of first-order logic over two-dimensional structures. Formulae may employ two linear orders , their successor relations , and auxiliary predicates of any arity. Despite two decades of work, three cases of finite satisfiability in this setting were still open; we settle all three. First, finite satisfiability of with one linear order and one successor relation, of the same or of a different order, is NEXPTIME-complete, even with arbitrary auxiliary predicates and constant symbols. This closes a gap left open by Manuel and Zeume (CSL 2013). As an application, a reduction based on swaps of adjacent elements shows that order-invariance and order-successor-invariance of are coNEXPTIME-complete. This reproves the main result of Zeume and Harwath (LICS 2016) and settles their question on order-successor-invariance. Second, finite satisfiability of with two linear orders is EXPSPACE-hard, already without auxiliary non-unary predicates, matching the upper bound known since 2010. Our reduction combines Kieroński's encoding of alternating Turing machines with the classical fact that the pre-order and post-order traversals of a tree define its descendant relation. Third, with two linear orders and the successor of one of them, finite satisfiability is in EXPSPACE even with arbitrary auxiliary predicates, improving the previous 2NEXPTIME bound and confirming a conjecture of Zeume and Harwath. Together with known results, our theorems show that in two dimensions, auxiliary (non-unary) predicates and constants come for free: with or without them, the complexities coincide. All our proofs are simple.
2012 ACM Subject Classification Theory of computation → Logic and verification
Keywords and phrases Two-Variable Logic, Two-Dimensional Structures, Complexity, Finite Satisfiability Problem, Decidability
Funding B. Bednarczyk was supported in full by the Austrian Science Fund (FWF) project FINGO 10.55776/ESP2407425, and D. Kojelis by DFG project LU 1417/4-1. Results from Sections 3–4 were presented in the bachelor's thesis of K. Szymański, written under the supervision of B. Bednarczyk at the University of Wrocław.
1 Introduction
Two-variable logic. The two-variable fragment of first-order logic is among the most prominent decidable fragments of FO. Mortimer showed that it has the finite model property [24], and Grädel, Kolaitis and Vardi sharpened this to models of exponential size, making its (finite) satisfiability problem NEXPTIME-complete [12]. It is also reasonably expressive: embeds many modal and description logics; over finite words it is as expressive as unary temporal logic and remains NEXPTIME-complete [9]; and over finite trees it captures navigational XPath [23], while its satisfiability problem becomes EXPSPACE-complete [2].
Semantic constraints. This expressiveness has its limits, however. With only two variables at hand, cannot say that a relation is transitive, let alone that it is an equivalence or a linear order. This has prompted a long line of work on over structures in which some distinguished binary symbols have a fixed meaning; see the survey by Kieroński, Pratt-Hartmann and Tendera [16]. Finite satisfiability remains decidable with one or two equivalence relations [15] [17], with one transitive relation [26], with one [25] or two linear orders [29], and with the successor relations of two linear orders [5] [10]. It becomes undecidable with three equivalence relations [15], with three linear orders [14], and with two linear orders together with their successors [21, Thm. 4]. Recent work by Fiuk, Kieroński and Michielini extends this line to nested equivalences and preorders for hierarchically organised data [11].
Data words and the plane. Among all semantic constraints, linear orders have received particular attention, much of it sparked by data words [3]: words in which every position carries, besides a letter, a datum from an infinite domain, modelling, e.g., attribute values of XML documents or process identifiers in traces of concurrent systems. As structures, data words come with a linear order on positions, possibly its successor, and an equivalence relating positions with equal data; over them is decidable, but its complexity is tied to reachability in Petri nets [3]. Ordering the data turns the equivalence into a total preorder [29], and if all data are moreover distinct, into a second linear order. Such a structure is best seen as a finite set of points in the plane, sorted along the -axis by and along the -axis by (see Figure 1): these are the two-dimensional structures of our title. We write for over them, where O lists the distinguished symbols available, i.e. linear orders and successor relations (see Section 2); e.g. speaks about two linear orders.
Auxiliary binary symbols. The results above come in two flavours. In the first, besides the distinguished symbols a sentence may use unary predicates only; in the second, it may use arbitrary auxiliary ones, of which binary predicates are the interesting case. Zeume and Harwath, who phrase the two flavours as the logics EMSO² and ESO², point out that the distinction is easily overlooked [31, §1]. It matters: in the plane, for instance, a binary symbol can link any two points, however far apart they lie in both orders, and many techniques that cut and paste fragments of a model, developed for the unary flavour, break down in its presence. For two linear orders, the price used to be exponential: the best known upper bound with auxiliary binary symbols [31, Thm. 7] was exponentially worse than the one without them [29, Thm. 3.1]. Toruńczyk and Zeume give a direct translation of finite satisfiability with auxiliary binary symbols into finite satisfiability without them [30, §5.2, Prop. 5.11], but the translation is doubly exponential, and thus too costly here. Table 1 collects what is known about FO²[O] in both flavours, and marks the new results of this paper with ★.
Our motivation. As the table shows, two decades of work still leave three gaps in the complexity of over two linear orders. We aim to close all three of them in this paper.
The EXPSPACE upper bound for two linear orders without auxiliary binary symbols dates back sixteen years [28] [29, Thm. 3.1] and was later reproved with automata [18], yet
Two Variables and Two-Dimensional Structures (Under submission)
the only lower bound is the NEXPTIME one inherited from . The known EXPSPACE-hardness proof [29, Thm. 4.1] relies on a preorder, whose classes may be exponentially large.
For one linear order and one foreign successor, i.e. , the gap between NEXPTIME and EXPSPACE is listed as open by Manuel and Zeume [22, Fig. 3].
With auxiliary binary symbols, only a 2NEXPTIME upper bound is known for all of the above [31, Thm. 7], while Zeume and Harwath conjecture EXPSPACE [31, §4].
Order-invariance. Two linear orders on one domain also arise naturally in finite model theory, where order-invariance is an important property. A sentence is order-invariant if it may use a linear order, but its truth does not depend on which linear order is chosen. Such sentences are ubiquitous: capturing results of descriptive complexity assume an ordered structure, and the sentences they construct typically use the order as an auxiliary device only [31, §1]. Order-invariance is undecidable for FO [20, Exer. 9.3]. For , Zeume and Harwath observed that a sentence fails to be order-invariant exactly when some finite structure with two linear orders satisfies it under the first order and violates it under the second. Order-invariance of thus reduces to the complement of the finite satisfiability problem for over two linear orders [31, §1]. With a successor at hand, however, the same idea leads to two linear orders together with their successors, where satisfiability is undecidable [21, Thm. 4]. Decidability of order-successor-invariance was thus left open [31, §7, Question 3] and, to the best of our knowledge, has remained open ever since, despite subsequent progress on both the expressive power and the complexity of order-invariant by Bednarczyk and Grange [1].
Table 1 Complexity of finite satisfiability for , for signatures whose auxiliary symbols are unary only (called in [31]) or arbitrary (called ). Our results are marked by , the previous best bounds are shown in grey, and lower bounds carry over from unary to arbitrary signatures; every NEXPTIME lower bound is inherited from [12]. Cases symmetric to listed ones are omitted. VASS is reachability in vector addition systems, Ackermann-complete [7] [19] and equivalent to multicounter-automata emptiness [3].
| Symbols O | Unary auxiliary symbols only | Arbitrary auxiliary symbols |
|---|---|---|
| One linear order or successor | ||
| {S} | NEXPTIME-complete [9] | NEXPTIME-complete [31, Thm. 3] |
| {⊆} | NEXPTIME-complete [9] | NEXPTIME-complete [25] |
| {⊆, S} | NEXPTIME-complete [9] | NEXPTIME-complete [31, Thm. 3] |
| Two linear orders or successors | ||
| {S1, S2} | NEXPTIME-complete [5] [10] | NEXPTIME-complete [5] |
| {⊆1, S2} | NEXPTIME-complete ★was: in EXPSPACE [29, Thm. 3.1] | NEXPTIME-complete ★was: in 2NEXPTIME [31, Thm. 7] |
| {⊆1, ⊆2} | EXPSPACE-complete ★was: in EXPSPACE [29, Thm. 3.1] [18] | EXPSPACE-complete ★was: in 2NEXPTIME [31, Thm. 7] |
| {⊆1, S1, ⊆2} | EXPSPACE-complete ★was: in EXPSPACE [29, Thm. 3.1] [18] | EXPSPACE-complete ★was: in 2NEXPTIME [31, Thm. 7] |
| {S1, ⊆2, S2} | VASS-complete [22, Cor. 11, Thm. 15] | VASS-complete [31, Thm. 9] |
| {⊆1, S1, ⊆2, S2} | undecidable [21, Thm. 4] | undecidable [21, Thm. 4] |
Our results. We close all the gaps above, marked by in Table 1, and settle the question on order-successor-invariance as well. In more detail, our contributions are as follows.
-
Finite satisfiability of is NEXPTIME-complete, even with arbitrary auxiliary symbols (Theorem 3.1), which closes the gap listed by Manuel and Zeume [22, Fig. 3]. The proof establishes an exponential-size model property by adapting the circular witnessing scheme of Grädel, Kolaitis and Vardi [12] to the plane: we first confine all remote witnesses to a small set of elements, and then cut the model down along . As a by-product, we reprove NEXPTIME-completeness of [31, Thm. 3] in a slightly simpler way.
-
Finite satisfiability of is EXPSPACE-hard, already without auxiliary binary symbols (Theorem 5.1); previously, only the NEXPTIME lower bound inherited from was known. We reduce from alternating Turing machines working in exponential time [4]. The descendant relation of a tree is definable by two linear orders, namely its pre-order and post-order traversals; this classical fact goes back to Dietz [8]. Benaim et al. proved EXPSPACE-hardness over finite trees with Kieroński's encoding of runs [2, Thm. 3.8] [13, Thm. 5], which we also use as a black box, after fixing a minor gap (Appendix A). The point is that two linear orders need not form a tree, so we show that the encoding survives in every model where the defined relation is merely transitive.
-
Finite satisfiability of is in EXPSPACE, even with arbitrary auxiliary symbols (Theorem 6.1). This exponentially improves the previous 2NEXPTIME bound and confirms the conjecture of Zeume and Harwath [31, §4]. As they hint [31, §4], we combine their approach with the one without auxiliary binary predicates [29].
-
In Theorem 4.1 we show that both order-invariance and order-successor-invariance of are coNEXPTIME-complete. The proof is strikingly short: swaps of adjacent elements connect any two linear orders, and constants can name the swapped pair, so both problems reduce to finite satisfiability of . This simple reduction reproves the main result of Zeume and Harwath [31] with the optimal bound (first shown in [1, Thm. 3.7]) and settles their question on order-successor-invariance [31, §7, Question 3].
Together, items 2 and 3 make and EXPSPACE-complete, with and without auxiliary binary symbols; for the second logic, this closes another gap listed in [22, Fig. 3]. In fact, the two columns of Table 1 now coincide row by row: in two dimensions, auxiliary binary symbols come for free. What remains open concerns more than two dimensions, such as three successor relations [31, §7, Question 1]. None of our proofs needs heavy machinery, which should make them easy to build upon.
Organisation. Section 2 fixes the notation. Section 3 proves our first result, which also serves as a gentle introduction to model surgery in the plane, and Section 4 applies it to order-invariance. Sections 5 and 6 establish the matching EXPSPACE lower and upper bounds, and Section 7 concludes and discusses open problems.
Structures and types. Structures are written in fraktur and their domains A, B in Roman; all of them are finite and non-empty. A formula is written if it contains a single free variable , and it is a sentence if it has none. We write for the substructure of induced by . An atomic 1-type (resp. 2-type) over a signature is a maximal satisfiable set of -literals in (resp. in , containing ), identified with its conjunction; those over the signature of are collected in and . Note that the sizes of and
Two Variables and Two-Dimensional Structures (Under submission)
are exponential in . Every realises a unique 1-type and every pair of distinct elements realises a unique 2-type .
Ordered structures and the plane. A structure is ordered if it interprets every as a linear order and every as the successor relation of some linear order on its domain, namely of itself whenever ; we identify symbols with their interpretations. Distinct elements are -close if or , and -remote otherwise; they are close if they are -close for some with , and remote otherwise. If contains but not , we speak of -closeness. An ordered structure with two linear orders is visualised as a set of points in the plane, with ordering them along the -axis and along the -axis. Thus is to the left (resp. right) of if (resp. ) and below (resp. above) it if (resp. ), whence leftmost, rightmost, topmost and bottommost elements. Further, sits directly above if and no element lies strictly between them, and a 2-type places to the right (resp. left) of if it contains (resp. ). See Figure 1.

Ranks. Positions in the plane give the ranks:
along :
along :
Closeness. Only b is close to a:
| a, b | close | close |
| b, c | close | remote |
| b, d | remote | close |
| a and c, d, e | remote | remote |
Figure 1 A visualisation of an ordered structure over with .
Decision problems. The finite satisfiability problem for asks whether a given -sentence has a finite ordered model, i.e. a finite model in which every is interpreted as a linear order and every as the successor relation of a linear order, namely of whenever . The remaining symbols of , called auxiliary, are interpreted arbitrarily. We distinguish the case in which all auxiliary symbols are unary (the logic EMSO of [31]) from the general one (the logic ESO ); see Table 1.
Scott normal form. Passing to a normal form lets us reduce the nesting of quantifiers and dispose of constants and of predicates of high arity. An -sentence is in Scott normal form if its signature is constant-free and carries only predicates of arity 1 or 2, and it reads
where and the are quantifier-free. Without loss of generality, we may assume this shape:
▶ Fact 2.1. There is a nondeterministic polynomial-time procedure that, given an -sentence , outputs an -sentence in Scott normal form and of polynomial size, such that has a finite ordered model if and only if some run outputs a that does.
The proof is routine, so we omit it [27, Lems. 3.3–3.4, pp. 69–74]. The conjuncts preserve satisfiability only over domains of at least two elements [27, p. 71], so one-element models are tested directly, and if one exists, a trivially satisfiable is output. Nondeterminism is needed only to find such a model and to get rid of equalities between constant symbols, both of which are guessed. Writing as above, amounts to three conditions: (i) is ordered; (ii) every 1-type realised in entails and every realised 2-type entails ; and (iii) every admits witnesses with . A model is thus a family of types in which every element demands witnesses, one fulfilling each .
3 One Order, One Foreign Successor: Small Models in the Plane
Call a successor relation foreign if the linear order inducing it is itself absent from O: a sentence then sees -closeness, but has no access to itself. Pairing one linear order with one foreign successor gives the simplest genuinely two-dimensional signature, and it is the one we study here. So let , and let be a sentence in Scott normal form (Fact 2.1), with universal conjunct and existential conjuncts , where . In an ordered structure we write for the linear order on A that induces , unique as A is finite. Not being in the signature, is recorded by no type: it is determined by , and constrains it only through . Closeness is therefore -closeness: distinct elements are close exactly when one of them sits directly above the other. In every model of we fix, for each element and each , one witness of for ; from now on, witnesses are these fixed ones only, and each surgery below says how it fixes them anew. A witness of , which differs from by the normal form, is called close if it is close to , and remote otherwise. Finally, we abbreviate and , both exponential in .
▶ Theorem 3.1. The finite satisfiability problem for is NEXPTIME-complete, even with arbitrary-arity auxiliary predicates and constants.
This closes the gap listed by Manuel and Zeume [22, Fig. 3]. Hardness comes from ; the known upper bounds were EXPSPACE without extra binary symbols [29, Thm. 3.1] and 2NEXPTIME in general [31, Thm. 7]. Ours utilises an exponential-model property.
▶ Lemma 3.2. If has a finite model, then it has one of size .


Figure 2 Left: rebinding 's remote witness to , with , closing it under witnesses. Right: cutting out between -pairs and of equal 2-type ; the cut is legal as and lie on the same -side of , i.e. holds.
We adapt the witnessing scheme of Grädel, Kolaitis and Vardi [12], as used for two linear orders in [1, Lem. 3.6]: we keep the extremal copies of each 1-type, the royal court, and two spare ones, as makes at most two elements close to a given one. The 2-type of a remote pair has no -atom and may be overwritten without disturbing the orders; that of a close pair may not. We proceed in two steps, shown in Figure 2. First we confine all remote witnesses to an exponentially large set W, rewiring only non-distinguished relations (Lemma 3.3). Then we shrink the model until only exponentially many elements lie strictly between any two -consecutive members of W (Lemma 3.4), which is possible precisely because nothing
Two Variables and Two-Dimensional Structures (Under submission)
outside W is still needed as a remote witness. The first step refines Otto’s treatment of [25], the second follows the word-based arguments for [9]. We start with our first model surgery, described in Lemma 3.3.
▶ Lemma 3.3. Let . There are a model and a set of size that contains the bottommost and the topmost element of , and every remote witness in . Moreover, , and and agree on all 1-types and on , and .
Proof. We assemble the desired set W in two stages, rewire connections concerning every element outside it, and finally check that no witness was lost on the way.
The royal court. For each 1-type realised in , the court collects the leftmost and the rightmost realisations of , or all of them if there are fewer than . It also contains the bottommost and the topmost element of , so that . Intuitively, holds more copies of each 1-type than any element needs: at most witnesses are asked for, and two spares cover the close elements barred from the surgery below.
Closing under witnesses. Let the set hold the witnesses of the elements of that lie outside , and let do the same for outside . Put . Every element demands at most different witnesses, hence and . In allocating witnesses we cannot simply stop at and . The rebinding below rewires pairs that enter from outside. A pair from into , however, may already be fixed as a witness pair of its endpoint in . If were rewired as well, such witnesses would be lost; we therefore spare it and keep its own witnesses as .
Rebinding. Fix , write for its witness for , and discard those for which is close to . Each remaining determines the 1-type of and the -side of on which it lies; we split the indices into classes according to this pair. Consider such a class , say of 1-type and to the right of . If has fewer than realisations, all of them lie in , the with included, and we leave alone. Otherwise the rightmost realisations of form a set , and for there are two cases: either , or lies strictly to the left of all of and then every element of lies to the right of as well. If the first case holds for all , we leave alone. Otherwise all of lies to the right of , and at least of its elements are remote from , while the set has at most elements. So we may pick an injection of this set into the elements of remote from that fixes every , redefine
and fix as the new witness of for . This is legitimate: the old and the new 2-type agree on the 1-types of both arguments, both place to the right of , and neither contains a -atom. So , , and all 1-types survive, is again ordered, and the imposed 2-type is realised in and hence entails .
Nothing breaks. Every pair touched above has one endpoint outside and the other inside . The witnesses of the elements of lie in , those of in W. So no witness pair of an element of is ever touched, and each such element keeps all its witnesses inside W. Finally, take an element outside . Its close witnesses survive, since no element close to is ever picked as a target . Its remote witnesses now lie in and still witness their demands: distinct witnesses of one class get distinct targets, and distinct classes pick targets from disjoint sets, of distinct 1-types or, for one with at least realisations, its leftmost and rightmost ones. Together with this proves the lemma.
◀
With all remote witnesses inside W, no element between two -consecutive members of W is anybody's remote witness. Such stretches can therefore be shortened by cutting between two -pairs of equal 2-type, provided that the cut respects .
▶ Lemma 3.4. Let and let contain the bottommost and the topmost element of A, and every remote witness in . Then has a model of size at most .
Proof. As W contains the bottommost and the topmost element, every element outside W lies strictly between two -consecutive members of W. Fix such members , let be the elements strictly between them, and suppose that . For put . We shall delete for some and give the 2-type . This respects 1-types if , and it respects if
and lie on the same side of (both to its left, or both to its right).
(†)
If were the successor of , every would lie to the right of . Then all would satisfy , and already would force for some . In general, the pairs may take the shape of a ‘ladder’ whose ‘rungs’ keep shifting to the left. For example, it may happen that and ; then lies to the right of , but to its left. So equal 2-types do not guarantee , but ladders turn out to be short.
Finding a cut. Suppose that no satisfies and . Let be a 2-type placing to the right of , and let be the indices with . For all , as , we see that fails for and . Since lies to the right of , the element lies to its left. Thus, as in the example above, the pairs of 2-type form a ladder:
(♣)
Now fix . By , lies to the left of and to its right, so . Let be the largest index such that lies to the right of ; as qualifies, . Then lies to the left of , by the choice of , or by if . Hence
(♠)
i.e. jumps leftwards over , and places to the left of . Moreover, for . Indeed, suppose otherwise. As and fails for and , the element lies to the right of . By and , it then also lies to the right of and of , which contradicts for . Let and be the numbers of 2-types in placing to the right and to the left of , respectively. So is taken by at most of the . Symmetrically (reverse ), every 2-type placing to the left of is taken at most times. As , counting the indices by 2-types contradicts :
Performing the cut. So let satisfy and . Put , , and , where possibly . Let arise from by deleting every with and setting , inheriting all else from . Now sits directly above , and no other pair changes its closeness. The 2-type contains , as sits directly above . It agrees with the 1-types of and , as . It places to the right of exactly when lies to the right of , i.e. by , exactly when does. So is ordered. Nothing breaks. Every 1-type and every 2-type realised in is realised in , and thus entails . Remote witnesses lie in W, which contains neither nor nor any deleted element.
Two Variables and Two-Dimensional Structures (Under submission)
So they survive and serve the same demands. Only and can lose close witnesses. Since now realises , the element replaces as a witness of , and replaces as a witness of . Thus , and and W meet the assumptions of the lemma. We repeat such cuts until fewer than elements lie between any two -consecutive members of W. Then at most elements remain.
Proof of Lemma 3.2. Let be finite. Lemma 3.3 provides and a set W of size holding every remote witness and the bottommost and the topmost element of B. Lemma 3.4 then yields a model of size , which is .
It remains to turn the exponential-model property into a decision procedure.
Proof of Theorem 3.1. Given , guess a sentence in Scott normal form output by a run of the procedure from Fact 2.1, then a structure of size (Lemma 3.2 for ), and accept whenever . The last test is the three-item check from the preliminaries: is ordered, every realised 1-type and 2-type entails the universal conjunct, and every element has its witnesses. This yields the desired NEXPTIME procedure for .
Finally, note that the axiom forces to be the successor of . As a consequence, Theorem 3.1 reproves NEXPTIME-completeness of [31, Thm. 3].
4 Application: Deciding Order- and Order-Successor-Invariance
A sentence is order-successor-invariant if, for every structure without distinguished relations, the truth of in the expansion of by a linear order on A and its successor S does not depend on the choice of . If S does not occur in , we speak of order-invariance. The two classes are denoted -inv and -inv . Recall that is order-invariant if and only if has no finite ordered model, where is with every replaced by [31, §1]; with a successor, the analogous formula lands in an undecidable fragment [21, Thm. 4]. The following theorem settles the decidability of -inv [31, §7, Question 3] and also reproves the optimal complexity bound for -inv [1, Thm. 3.7].
▶ Theorem 4.1. Deciding whether an -sentence is order-successor-invariant is coNEXPTIME-complete. The same holds for order-invariance of -sentences.
The proof is short and elementary: we reprove the main result of Zeume and Harwath with the optimal bound and answer their open question by a simple reduction to finite satisfiability of with a single linear order and its successor. For elements with , let be with and swapped, and let be its successor.
▶ Observation 4.2. A sentence is order-successor-invariant if and only if implies for all structures , orders , and elements satisfying .
Indeed, bubble sort turns any linear order into any other by swaps of neighbours. Such swaps are local: differs from on the pair alone, and, writing for the predecessor of and for the successor of (if they exist), replaces the pairs , , of S by , , . Naming the elements by fresh constants , both relations become definable with the following quantifier-free formulae:
where abbreviates four disequalities. Replacing in every atom by and every by yields an -sentence of size . We prove:
Proof of Theorem 4.1. Let and let c, d be fresh constants. In every ordered structure with , and define and . So, by Observation 4.2, is order-successor-invariant if and only if is not finitely satisfiable. As has polynomial size and finite satisfiability of is in NEXPTIME (Theorem 3.1 and the observation closing Section 3, or [31, Thm. 3]), the upper bound follows. For just order-invariance S is unnecessary: replace in by . Hardness follows from that of order-invariance [1, Thm. 3.2] on S-free sentences.
Nothing here is specific to two variables: the argument works for every logic with equality and constants that is closed under Boolean connectives and under substituting quantifier-free formulae for atoms. For instance, with [6, Thm. 6.20] it yields decidability of both kinds of invariance for the two-variable logic with counting , as asked in [1, §6].
5 Configuration Trees: An EXPSPACE Lower Bound
The complexity of finite satisfiability for has long been open. Without auxiliary binary symbols, Schwentick and Zeume placed it in EXPSPACE [29, Thm. 3.1] and proved hardness for a linear order and a total preorder [29, Thm. 4.1]. For two linear orders, only NEXPTIME-hardness from plain was known. The following theorem closes this gap. Unlike the setting of data words [29, §5], unary predicates may hold simultaneously here.
▶ Theorem 5.1. The finite satisfiability problem for is EXPSPACE-hard, already over signatures without auxiliary non-unary predicates and constant symbols.
The reduction. It suffices to encode accepting runs of alternating Turing machines working in exponential time [4, Cor. 3.6]. We lay them out in configuration trees, which carry a descendant relation , and axiomatise them by Kieroński's construction [13, Thm. 5], used as a black box (Lemma 5.3; Appendix A fixes a minor gap); Benaim et al. used it in the same way to show EXPSPACE-hardness over finite trees [2, Thm. 3.8]. Two facts make it work here. First, is definable by two linear orders, the pre-order and the post-order traversals of the tree [8] (Lemma 5.4). Second, two linear orders need not form a tree; the encoding nevertheless survives in models in which the defined relation is merely transitive (Lemma 5.3(iii)).

Figure 3 The N-configuration tree up to depth 2: columns are configurations of cells, lines form the Hasse diagram of (read downwards), and L marks left configurations.
Two Variables and Two-Dimensional Structures (Under submission)
Configuration trees. Fix N. The N-configuration tree (Figure 3) arises from the full binary tree of height by replacing each node with a configuration of cells , where . The cell has depth and position , the number written in binary; it is the first cell of its configuration if , the last one if , and, if , the next cell after the one of position . The configurations and are the left and the right child of , and the root configuration is the one with empty.
▶ Definition 5.2. Let , with binary and the rest unary. The N-configuration tree is the -structure with domain A of all with and , where, numbering bits from 0, most significant first:
■ if and only if the -th bit of the depth of is 1;
■ if and only if the -th bit of the position of is 1;
■ if and only if ends with 0;
■ holds if and only if is a proper prefix of , or and .
Defining configuration trees. Comparisons of the depths and positions encoded at , such as or , are expressible by quantifier-free formulae of size polynomial in ; e.g. is the conjunction of for the bits 1 of and for its bits 0. Adapting Kieroński's axioms [13, , p. 1672], we let be the conjunction of
where and . The conjuncts say that the first cell of the root configuration exists, that every cell but the last of its configuration has a next cell, and that below the last cell of every configuration of depth less than lie the first cells of a left and of a right child. Clearly, . Models of need not be configuration trees, as witnesses may coincide, but those interpreting transitively contain a homomorphic image of . This suffices to encode runs in expansions of , i.e. in structures obtained from by interpreting further unary predicates.
▶ Lemma 5.3 (after [13]). Let M be an alternating Turing machine working in time on inputs of length n. There are a constant c, a set of unary predicates, and a polynomial-time procedure computing, from an input u of length n, an -sentence over such that, for , these are equivalent: (i) M accepts u; (ii) some expansion of by satisfies ; (iii) has a finite model in which is transitive.
Descendants by two linear orders. It remains to define by two linear orders, which the quantifier-free formula does.
▶ Lemma 5.4. In every structure with linear orders and , the formula defines a transitive relation. Moreover, the domain of the N-configuration tree admits linear orders and such that b holds in if and only if and .
Proof. The formula defines the intersection of with the converse of , which is transitive. For the second part, observe that is the proper-ancestor relation of the rooted tree on A in which the root is , the only child of a cell other than the last of its configuration is its next cell, and the children of the last cell , for , are and . Let and be the pre-order and the post-order traversals of this tree, both visiting before . A proper ancestor of a cell precedes it in pre-order and follows it in post-order. Incomparable cells lie in the subtrees of distinct children of their lowest common ancestor, which both traversals visit one after the other, so and order them alike. Hence and hold if and only if is a proper ancestor of , i.e. if and only if holds.
Proof of Theorem 5.1. As AEXPTIME = EXPSPACE [4, Cor. 3.6], some alternating Turing machine working in time has an EXPSPACE-hard acceptance problem. Given an input , let arise from (Lemma 5.3) by replacing every atom , with , by . Then is an -sentence whose other symbols are unary, and it is computable in polynomial time. If accepts , equipping the expansion of from Lemma 5.3(ii) with the orders of Lemma 5.4 yields a finite ordered model of . Conversely, interpreting by in a finite ordered model of yields a model as in Lemma 5.3(iii), by Lemma 5.4; hence accepts .
6 Processing Lines: An EXPSPACE Upper Bound
We now add the successor of one of the two linear orders. Without auxiliary binary symbols, the resulting problem lies in EXPSPACE [29, Thm. 3.1], whereas with them only a 2NEXPTIME upper bound was known [31, Thm. 7]. Zeume and Harwath conjectured that EXPSPACE suffices [31, §4], and we confirm this.
▶ Theorem 6.1. The finite satisfiability problem for is in EXPSPACE, even over signatures with arbitrary auxiliary symbols.
Swapping the two orders, we work with instead, where the successor belongs to the vertical order . We follow the plane-sweep approach of Schwentick and Zeume [29, §3.3]: a horizontal line sweeps a model bottom-up, and an algorithm guesses, line by line, a description of what the line sees, checking consecutive lines only. With auxiliary binary symbols around, such a description has to be a substructure of the model, as in the profiles of Zeume and Harwath [31, proof of Lem. 8], but it must also keep every witness pending across the line. The crux is to keep these substructures exponentially small (Lemma 6.3) and to glue them back into a model (Lemma 6.5). So let be an -sentence in Scott normal form (Fact 2.1), with universal conjunct and existential conjuncts .


Figure 4 Two consecutive lines for one demand R (red), , one 1-type; -edges omitted. Blue/orange: ; dashed: not in the line; shaded: below it. Crossing the line, evicts b from and makes c max-extremal above; the non-extremal witness w of is kept.
Two Variables and Two-Dimensional Structures (Under submission)
Processing lines. Picture a horizontal line just above an element of a model: the elements below it, included, count as processed, and those above it as to be processed. A processing line records what the sweep has to remember at this point. We define it in terms of alone, and extract one from every element of a model afterwards. Given a finite structure with domain P and an element , we split P into and . For , the sets and consist of the leftmost and the rightmost elements of , respectively, or all of if it is smaller; and for .
▶ Definition 6.2. A processing line is a finite structure over the signature of , with domain P, equipped with a distinguished element , with sets for and , whose union we call B, and, for every , with a partial witness set of at most recorded witnesses of , such that:
(L1) Local validity. Both and are linear orders, every realised 1-type entails , and every realised 2-type entails . Every -edge points to the immediate successor in the local -order, but elements need not have an -successor or -predecessor.
(L2) Extremal elements. for all , and (read as an operator).
(L3) Witnesses at the distinguished element. At the distinguished element all demands are served: for every , some satisfies .
Intuitively, holds processed elements, whilst holds elements to be processed. The extremal sets hold the leftmost and rightmost elements of every 1-type on either side of the line, much like the royal court of Section 3. In the sequel we write .
Lines of a model. Let . A witnessing set of is a set such that, for every , some satisfies . Without loss of generality, we assume that each satisfies some demand. For every , we fix a witnessing set of size at most , and call its elements the witnesses of . Now fix . An element is below the line of if , and above it otherwise. Note that itself lies below its line, whilst its -successor, if any, lies above it. We collect the elements below and above the line in and . For write for the elements of 1-type in , with types taken in . For all , and , let , with extrema taken in ; let be their union over , and the union over and . Write for the direction opposite to . For both , define the exceptional sets \text{C}_a^\delta, \times := \{b \in \text{A}_a^\bar{\delta} \mid \text{wst}^{\mathfrak{A}}(b) \cap (\text{A}_a^\delta \setminus \text{B}_a) \neq \emptyset\} and . Let be the union of the four sets and . Informally, the elements in are those whose chosen witnesses across the line cannot all be found among the extrema in . The role of is to keep these exceptional witnesses in sight. So holds the leftmost elements of 1-type below the line, and holds the elements above the line that have a witness below it. Let be the union of , its -neighbours, , and . The processing line of is the substructure of induced by , equipped with the distinguished element , the sets , and the partial witness sets . It is easy to verify that every element of a model of gives rise to a processing line (Appendix B, Lemma B.1). In general, the sets may be as large as the model itself. The next lemma makes all lines exponentially small by rewiring: if has a nonextremal witness across the line, an extremal element of the same 1-type lies on the same side of in both orders and can take over the 2-type of ; this fails only for exponentially many .
▶ Lemma 6.3. Let . Then there is a structure over the same domain, with the same orders and 1-types, together with witnessing sets for it, such that, for each , the domain of has size at most .
Proof. We shrink the model-defined sets one line after another by rewiring witnesses into extremal sets. As will become apparent, the sets for other elements do not grow.
Shrinking one line. Fix and , and let be the elements of of 1-type . Each of them lies above the line and has a witness below it outside . We construct over the same domain in which . The set has at most elements, so at most of the are witnesses of elements of . If , let be the that are neither such witnesses nor the -successor of ; we spare the latter since we are about to redefine 2-types, which must not create or destroy -edges. Consider such a and a witness of below the line. If , we leave it alone. Otherwise, say . (The case is symmetric, with rightmost instead of leftmost elements.) As , the set consists of elements to the left of , at most of which are witnesses of . So we can pick one that is not, say, , set \text{tp}^\mathfrak{A}'(d, e) := \text{tp}^\mathfrak{A}(d, v), and fix instead of as a witness of . Notice that this operation is legal: and have the same 1-type, both lie to the left of and below , and neither is close to , as lies above the -successor of . So the orders survive, the imposed 2-type is realised in and hence entails , and no witness is lost: was no witness of , and is no witness of by the choice of the . Doing so for all witnesses below the line of all , and then for all , we obtain in which . The analogous construction for , applied to and discounting from instead of its successor, yields in which both sets are bounded as given above. As and is exponential in , the line of in has at most elements.
Other lines do not grow. The sets B depend only on 1-types and orders, which have not changed. Only the elements removed from above change their witnesses, so it suffices to show that no such enters or for any . Let . (The case is symmetric.) The elements below the line of are among those below the line of , and the elements above the line of are among those above the line of . Hence an element below the line of that lies in lies in , and an element above the line of outside lies outside . If is above the line of , then its witnesses below the line of now lie in , hence in , and so . If is below the line of but above that of , then only its witnesses above the line of changed, and these do not matter for . Finally, if is below the line of and now lies in , then it did so before: in , it had a witness above the line of outside , hence outside .
All lines at once. We treat the elements of A one by one, each time in the current model. Since no step enlarges the sets for the elements treated before, and , the resulting has all its lines of size at most .
Gluing lines. From now on, processing lines have at most elements, the bound of Lemma 6.3 (made explicit in Appendix B), named by numbers in . A sweep visits the lines of a model bottom-up, so consecutive lines have to fit together. For a sequence of processing lines, we attach the index to the data of , writing , , , and so on, and take min and max in the line indexed by the B-set in their argument. A line is initial if , and final if .
▶ Definition 6.4. A sequence of processing lines satisfies the gluing rules if is initial, is final, and the following hold for all :
(G1) Line succession. , and holds in both and .
(G2) Agreement and witness continuity. and induce the same substructure on , and for all .
Two Variables and Two-Dimensional Structures (Under submission)
(G3) Persistence of elements. and .
(G4) Extremal element update. For , let if , and otherwise. Then, for both , when read as an operator,
Intuitively, (G1) moves the line up past , (G2) and (G3) make consecutive lines describe the same model, with the only element crossing the line, and (G4) updates the extremal sets as crosses. As expected, the lines of a model satisfy the gluing rules, so if has a finite model, then some sequence of processing lines satisfies them (Appendix B, Lemma B.3). Figure 4 shows possible changes across consecutive processing lines. The converse is the heart of the matter: we glue the lines back into a model.
▶ Lemma 6.5. If processing lines satisfy the gluing rules, then has a finite model.
Proof. We build a model whose elements are the distinguished elements of the lines.
Renaming. An interval of occurrence of an element is a maximal interval of lines containing it. We rename every element apart in each of its intervals of occurrence. That is to say, for each element and an interval of occurrence , we replace with a fresh symbol, say, in . This preserves the gluing rules, so we may speak of the interval of occurrence of an element. From now on we refer to the distinguished element of as .
Crossings. Take any distinguished element . In its interval of occurrence we have that is below every whilst being above . Indeed, is below by definition. But then, by induction on , by induction, by (G1), and by (L1). Then, by (G2), as required. The ‘above’ direction is similar. In fact, by the above induction, elements are distinct.
Every element is processed. Every element occurring in a line is some . Otherwise, let have interval . Then is above the lines of all of or below all of them: if it were above the line of but below that of , then (G3) would give . A crossing from below to above is impossible too: in implies there by (G1) and (L1), and hence also in by (G2). If is above all of them, then , as by (G3) it can only leave the lines as , which contradicts ; symmetrically, if it is below all of them, then , which contradicts .
Domain and orders. Let , set for all , so that consists of the pairs , and set . We claim the -order defined in coincides with that in processing lines. To see this take with . If , then, as argued above, is below the line of whilst is above it. Hence, . By the above as well. In case we see that occurs in . Since is below the line of , whilst is above it we have that . Now, by (G1), . Thus, by (L1), exactly when . The case is then symmetric. By (G2) this is consistent throughout all in which and appear. For , we pick an injection : and let if and only if . We define on in turn. When we reach , the elements placed so far are those it shares with , placed in the order of , and thus also that of by (G2). As is dense, we can place the remaining elements of at fresh positions so that respects the order of . Hence respects in every line.
Extremal elements. For all , and , the set consists of the up to leftmost or rightmost elements of 1-type among in , and of those among . This holds for and by (L2), as and
, and propagates by induction, upwards for and downwards for , using (G4). For instance, consists of the leftmost elements of in , i.e. in , and hence of the leftmost elements of 1-type among .
Types of pairs. Distinct elements occurring together in a line take their 2-type from it. That is to say, if , then . By (G2), this is well defined, as all lines in the intersection of the elements' intervals of occurrence agree on it. In particular, by (L3), each finds in a witness for every , and by (L1), all types assigned so far entail . It remains to assign 2-types to pairs with that never occur together. By (G1), occurs in , and hence does not; thus , and . Let . By the claim on extremal elements, and consist of elements each, all to the left and all to the right of , respectively. Pick from the former if , and from the latter otherwise. Then has the 1-type of and lies on the same -side of , and holds in , so is not the -successor of . We may therefore set , which respects the orders of and, by (L1), entails . Completing the above we have .
Proof of Theorem 6.1. Given a sentence, we guess a run of the normal-form procedure in Fact 2.1, and continue with its output . We then guess an initial processing line and check (L1)–(L3). Given , we guess , check (L1)–(L3) for it and (G1)–(G4) for the pair, and forget . We accept once we reach a final line. By Lemmas B.3 and 6.5, the algorithm has an accepting run if and only if has a finite model. As every line has at most L elements named in , this nondeterministic algorithm works in exponential space. By Savitch's theorem, this yields membership in EXPSPACE.
7 Conclusions
We have settled the complexity of the finite satisfiability problem for over two-dimensional structures, as visualised in Table 1. Two linear orders, with or without the successor of one of them, yield an EXPSPACE-complete logic (Theorems 5.1 and 6.1), while one linear order and one (possibly foreign) successor reduces the complexity to just NEXPTIME (Theorem 3.1). As an application, order-invariance and order-successor-invariance of are coNEXPTIME-complete (Theorem 4.1). All our proofs are relatively simple, which we see as their main strength. Our lower bound relies on unary predicates that may hold simultaneously; whether it survives over data words with an explicit alphabet [29, §5] remains open. Future work could go in two directions. The first is to lift our results from finite to arbitrary structures, e.g. to data -words. There, satisfiability of with two linear orders and arbitrary auxiliary symbols is known to be decidable [30], so the task is to pin down its complexity. Our lower bound transfers immediately, but the upper bounds need extra work: instead of a small-model property, one has to establish a small ultimately periodic model property. The second leads to a challenging open problem: is (finite) satisfiability decidable for with three or more successor relations [31, §7, Question 1]? We conjecture that it is.
Declaration on generative AI. We developed the main results and first versions of most proofs without AI assistance. Claude Opus 5.5 helped extensively with writing, editing and reviewing, and drew our figures in TikZ. In reviewing, it found an error in an earlier version of Lemma 3.4 and smaller gaps elsewhere in Section 3, the gap in Kieroński's proof (Appendix A), and a missing step in the proof of Lemma 6.5, and suggested the fixes we adopted. From our drafts, it wrote Appendix A, including Lemmas A.3–A.4, which claims no novelty and only makes the paper self-contained. We take full responsibility for the content.
Two Variables and Two-Dimensional Structures (Under submission)
References
1 Bartosz Bednarczyk and Julien Grange. About the Expressive Power and Complexity of Order-Invariance with Two Variables. Logical Methods in Computer Science, 21(1):30:1–30:28, 2025. doi:10.46298/LMCS-21(1:30)2025.
2 Saguy Benaim, Michael Benedikt, Witold Charatonik, Emanuel Kieroński, Rastislav Lenhardt, Filip Mazowiecki, and James Worrell. Complexity of Two-Variable Logic on Finite Trees. ACM Transactions on Computational Logic, 17(4):32:1–32:38, 2016. doi:10.1145/2996796.
3 Mikolaj Bojańczyk, Claire David, Anca Muscholl, Thomas Schwentick, and Luc Segoufin. Two-Variable Logic on Data Words. ACM Transactions on Computational Logic, 12(4):27:1–27:26, 2011. doi:10.1145/1970398.1970403.
4 Ashok K. Chandra, Dexter Kozen, and Larry J. Stockmeyer. Alternation. Journal of the ACM, 28(1):114–133, 1981. doi:10.1145/322234.322243.
5 Witold Charatonik and Piotr Witkowski. Two-Variable Logic with Counting and Trees. In Proceedings of the Symposium on Logic in Computer Science (LICS), pages 73–82. IEEE Computer Society, 2013. doi:10.1109/LICS.2013.12.
6 Witold Charatonik and Piotr Witkowski. Two-Variable Logic with Counting and a Linear Order. Logical Methods in Computer Science, 12(2):8, 2016. doi:10.2168/LMCS-12(2:8)2016.
7 Wojciech Czerwiński and Łukasz Orlikowski. Reachability in Vector Addition Systems is Ackermann-complete. In Proceedings of the Symposium on Foundations of Computer Science (FOCS), pages 1229–1240. IEEE, 2021. doi:10.1109/FOCS52979.2021.00120.
8 Paul F. Dietz. Maintaining Order in a Linked List. In Proceedings of the Symposium on Theory of Computing (STOC), pages 122–127, 1982. doi:10.1145/800070.802184.
9 Kousha Etessami, Moshe Y. Vardi, and Thomas Wilke. First-Order Logic with Two Variables and Unary Temporal Logic. Information and Computation, 179(2):279–295, 2002. doi:10.1006/inco.2001.2953.
10 Diego Figueira. Satisfiability for Two-Variable Logic with Two Successor Relations on Finite Linear Orders. CoRR, abs/1204.2495, 2012. arXiv:1204.2495, doi:10.48550/arXiv.1204.2495.
11 Oskar Fiuk, Emanuel Kieroński, and Vincent Michielini. Two-Variable Logic for Hierarchically Partitioned and Ordered Data. In Proceedings of Principles of Knowledge Representation and Reasoning (KR), pages 316–325. IJCAI Organization, 2025. doi:10.24963/kr.2025/31.
12 Erich Grädel, Phokion G. Kolaitis, and Moshe Y. Vardi. On the Decision Problem for Two-Variable First-Order Logic. The Bulletin of Symbolic Logic, 3(1):53–69, 1997. doi:10.2307/421196.
13 Emanuel Kieroński. On the Complexity of the Two-Variable Guarded Fragment with Transitive Guards. Information and Computation, 204(11):1663–1703, 2006. doi:10.1016/j.ic.2006.08.001.
14 Emanuel Kieroński. Decidability Issues for Two-Variable Logics with Several Linear Orders. In Proceedings of Computer Science Logic (CSL), volume 12 of LIPIcs, pages 337–351. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2011. doi:10.4230/LIPIcs.CSL.2011.337.
15 Emanuel Kieroński and Martin Otto. Small Substructures and Decidability Issues for First-Order Logic with Two Variables. The Journal of Symbolic Logic, 77(3):729–765, 2012. doi:10.2178/jsl/1344862160.
16 Emanuel Kieroński, Ian Pratt-Hartmann, and Lidia Tendera. Two-Variable Logics with Counting and Semantic Constraints. ACM SIGLOG News, 5(3):22–43, 2018. doi:10.1145/3242953.3242958.
17 Emanuel Kieroński and Lidia Tendera. On Finite Satisfiability of Two-Variable First-Order Logic with Equivalence Relations. In Proceedings of the Symposium on Logic in Computer Science (LICS), pages 123–132. IEEE Computer Society, 2009. doi:10.1109/LICS.2009.39.
18 Nadia Labai, Tomer Kotek, Magdalena Ortiz, and Helmut Veith. Pebble-Intervals Automata and with Two Orders. In Proceedings of Language and Automata Theory and Applications
(LATA), volume 12038 of LNCS, pages 208–221. Springer, 2020. doi:10.1007/978-3-030-40608-0_14.
19 Jérôme Leroux. The Reachability Problem for Petri Nets is Not Primitive Recursive. In Proceedings of the Symposium on Foundations of Computer Science (FOCS), pages 1241–1252. IEEE, 2021. doi:10.1109/FOCS52979.2021.00121.
20 Leonid Libkin. Elements of Finite Model Theory. Texts in Theoretical Computer Science. An EATCS Series. Springer, 2004. doi:10.1007/978-3-662-07003-1.
21 Amaldev Manuel. Two Variables and Two Successors. In Proceedings of Mathematical Foundations of Computer Science (MFCS), volume 6281 of LNCS, pages 513–524. Springer, 2010. doi:10.1007/978-3-642-15155-2_45.
22 Amaldev Manuel and Thomas Zeume. Two-Variable Logic on 2-Dimensional Structures. In Proceedings of Computer Science Logic (CSL), volume 23 of LIPIcs, pages 484–499. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2013. doi:10.4230/LIPIcs.CSL.2013.484.
23 Maarten Marx and Maarten de Rijke. Semantic Characterizations of Navigational XPath. SIGMOD Record, 34(2):41–46, 2005. doi:10.1145/1083784.1083792.
24 Michael Mortimer. On Languages with Two Variables. Zeitschrift für Mathematische Logik und Grundlagen der Mathematik, 21(1):135–140, 1975. doi:10.1002/malq.19750210118.
25 Martin Otto. Two Variable First-Order Logic over Ordered Domains. The Journal of Symbolic Logic, 66(2):685–702, 2001. doi:10.2307/2695037.
26 Ian Pratt-Hartmann. Finite Satisfiability for Two-Variable, First-Order Logic with one Transitive Relation is Decidable. Mathematical Logic Quarterly, 64(3):218–248, 2018. doi:10.1002/malq.201700055.
27 Ian Pratt-Hartmann. Fragments of First-Order Logic, volume 56 of Oxford Logic Guides. Oxford University Press, 2023. doi:10.1093/oso/9780192867964.001.0001.
28 Thomas Schwentick and Thomas Zeume. Two-Variable Logic with Two Order Relations. In Proceedings of Computer Science Logic (CSL), volume 6247 of LNCS, pages 499–513. Springer, 2010. doi:10.1007/978-3-642-15205-4_38.
29 Thomas Schwentick and Thomas Zeume. Two-Variable Logic with Two Order Relations. Logical Methods in Computer Science, 8(1):15:1–15:27, 2012. doi:10.2168/LMCS-8(1:15)2012.
30 Szymon Toruńczyk and Thomas Zeume. Register Automata with Extrema Constraints, and an Application to Two-Variable Logic. Logical Methods in Computer Science, 18(1):42:1–42:38, 2022. doi:10.46298/LMCS-18(1:42)2022.
31 Thomas Zeume and Frederik Harwath. Order-Invariance of Two-Variable Logic is Decidable. In Proceedings of the Symposium on Logic in Computer Science (LICS), pages 807–816. ACM, 2016. doi:10.1145/2933575.2933594.
Two Variables and Two-Dimensional Structures (Under submission)
A Encoding Runs: Proof of Lemma 5.3
The construction of and its correctness over configuration trees (Lemma A.1) follow Kieroński's proof of [13, Thm. 5, pp. 1671–1676], with his transitive relation replaced by ; we claim no novelty here. We reproduce it only for the reader's convenience, and because the original contains a minor gap, easily repaired, and several typos, which we list first. The passage from configuration trees to arbitrary models of in which is merely transitive (Lemmas A.3 and A.4) is straightforward.
Errors in [13]. Kieroński's transition formulæ do not cover a head standing on cell 0. His formulæ and [13, pp. 1674–1675], which describe transitions, quantify over the cell y of a child configuration one to the left of the head, i.e. with . If the head is on cell 0, no such y exists, and both formulæ hold vacuously. This happens already in the initial configuration, whose head is on cell 0 by his . His assumption that the head never moves left of its initial position does not help, as the formulæ anchor y one cell to the left of the head for right moves as well. Hence the children of the root configuration may carry no head at all; then no transition formula ever applies again, his merely copies the tape, and his , which forbids the rejecting state, holds trivially. Consequently, his (with the typo in below corrected) is satisfiable whenever the initial state is not rejecting, regardless of whether the machine accepts, so the reduction fails as stated. The repair is easy: we locate y at the cell under the head, and require explicitly that the cell receiving the head exists (see below). This also treats all combinations of head moves uniformly, whereas [13, p. 1674] spells out only one of them. The remaining issues are minor.
[13, p. 1673] reads , which makes every empty and thus his unsatisfiable; is meant.
The left-move parts of and end with , which writes into the cell receiving the head; is meant.
The machine accepts or rejects exactly in the -th step [13, p. 1671], but the deepest configurations of the tree have number (his ), so runs are cut one step before they halt, and never sees a halting configuration; halting at step is meant.
[13, p. 1674] allows the head cell to carry several states. This is harmless, but we forbid it, as our proof reads off one state per configuration.
In the correctness proof [13, p. 1676], the sequence should end with , the transition formulæ are called instead of , and ‘an accepting computation tree of on ’ names the model where the machine is meant.
Apart from these repairs, we deviate from [13] only in presentation. The run encoding works over the given tree, so it needs neither his axioms for its shape ( ), which we adapt in instead, nor his auxiliary predicate . His Next comes with a separate guard , which we fold into it, and our macro Down is new. Finally, as the tree is given, we need not extract configurations from witnesses, and we derive acceptance by a bottom-up induction instead of completing the tree with dummy subtrees.
The machine. Let work in time on inputs of length , and let be an input. The states of are existential, universal, accepting, or rejecting; the latter two are halting. A configuration is accepting if its state is accepting, or existential and some successor configuration is accepting, or universal and all successor configurations are accepting; accepts if its initial configuration on is accepting. Following [13, p. 1671], we assume without loss of generality that is the initial and the only rejecting state, that every non-halting configuration has exactly two successor configurations, and that the head never moves left of its initial position; this affects the running time only by a constant factor. Hence there is a constant such that, for , every computation path of on has fewer than steps. Thus every computation tree of on fits into the N-configuration tree : configurations at depth are those reached after steps, configurations at depth are halting, and the head never leaves the cells .
We describe configurations in the standard way, by unary predicates for letters , for states , and H, which form : every cell carries the predicate of its letter, and the cell under the head also carries H and the predicate of the state. The blank letter is . A transition writes , enters , and moves the head by ; we write for the configuration obtained from by applying . For every non-halting state and letter , we fix an order , of the two transitions applicable in reading .
Navigation. For fixed , the comparisons , , , , , and of the depths and positions encoded at and (see Section 5) are expressible by quantifier-free formulae of size polynomial in . For instance, as bits are numbered most significant first, the last one is expressed by
With their help, we define two navigation macros:
Thus Next says that is the next cell after , and Down that has the position of and lies in a child of its configuration, the left one if and only if . The conjunct does the real work: without it, could lie in any configuration of the right depth.
The formula. The formulae say that every cell carries exactly one letter, that every configuration has at most one head, and that exactly the head cells carry a state, one each:
The formulae say that the root configuration is the initial configuration of on , and that cells not under the head keep their letters in both child configurations:
For a transition , the formula says that looks like the formerly scanned cell after applying : it carries , and the cell receiving the head, i.e. the next cell after if and the previous one if , exists and carries the head in state :
Two Variables and Two-Dimensional Structures (Under submission)
Let be a non-halting state, a letter, and . If is existential, enforces that the left child configuration arises by or by , and says nothing about the right one. If is universal, enforces that the left child arises by and the right one by :
Finally, forbids rejection, and we put
Clearly, is computable in time polynomial in and . A sentence is universal if its negation normal form has no existential quantifier, and occurs only negatively in it if, in negation normal form, it occurs only in literals . By construction, is universal, equality-free, and uses only negatively, namely in antecedents of implications, directly or within Next and Down. Its correctness over configuration trees reads as follows.
▶ Lemma A.1. M accepts u if and only if some expansion of by satisfies .
Proof. We identify a prefix with the configuration of , whose children are , the left one, and . In an expansion of by , the configuration encodes a configuration of if the only predicates of holding in cells of are in the cell of each position , where is the -th letter of , and and in the cell of position , where the head of is on cell in state .
(⇒) Let accept . Top-down, we assign to each configuration of either an accepting configuration of , or the label junk together with a sequence of letters. The root gets the initial configuration, which is accepting. Let be non-halting, so that , with state and letter under the head. If is universal, then and are accepting, and we assign them to and , respectively. If is existential, then is accepting for some ; we assign it to , and declare and all configurations below it junk, carrying the letters of . If is halting, all configurations below , if any, are junk carrying the letters of . We expand so that every encodes its , while junk configurations carry their letters, but neither head nor state. Then hold by construction, and holds as no is rejecting. For , note that and the configurations assigned to the children of differ at most in the cell under the head of , and that junk copies the letters of its parent. Finally, heads occur only in configurations with defined, and if is non-halting, its children encode the successors of prescribed above. As the head never leaves the cells , the cells receiving the heads exist, so all and hold.
(⇐) Let an expansion of satisfy . By , the root encodes the initial configuration of on . Let encode a non-halting configuration reached after steps, whose head is in state on cell , reading . Then , and for the cells of , of and of of position , we have , with and . If for a transition , then encodes : fixes the letter of and, by its guard, the cell receiving the head with its state; exclude further letters, heads, and states; and fixes the remaining letters. Thus if is universal, makes and encode and , i.e. all successors of ; if is existential, makes encode a successor of . Let collect the configurations of reachable from the root by passing from those encoding universal configurations to both children, and from those encoding existential ones to the left child. By the above, every encodes a configuration reached from the initial one after steps; in particular, is halting if . By induction on , every such is accepting: if is halting, it is not rejecting by ; otherwise, all successors of (if universal), or one of them (if existential), are encoded by children of in , which are accepting by induction. For the root, this means that accepts .
From configuration trees to arbitrary models. Models of need not be configuration trees, as witnesses may coincide, but it suffices that they contain an image of that is faithful on unary predicates, in the following sense.
▶ Definition A.2. A tree homomorphism into a -structure is a map : A B such that, for all and every unary , we have if and only if , and implies .
Universal sentences using only negatively pull back along tree homomorphisms.
▶ Lemma A.3. Let be a tree homomorphism into , let be an expansion of by , and let be the expansion of by with ) for every . Then satisfies all universal equality-free sentences that hold in and use only negatively.
Proof. We show, by induction on a formula of this kind in negation normal form, that implies for every assignment into A. Unary literals are preserved and reflected by : those over since is a tree homomorphism, and those over by the definition of . Literals transfer since preserves , and conjunctions and disjunctions are immediate. Finally, if , then for every , so by induction.
Equality and positive occurrences of would break the argument, since need not be injective and need not reflect . Tree homomorphisms, in turn, are provided by .
▶ Lemma A.4. We have . Moreover, for every -structure interpreting as a transitive relation, there is a tree homomorphism into .
Proof. The conjuncts of hold in by Definition 5.2, with witnesses , the next cell, and the first cells and of the children of for the last cell , respectively.
Now let with transitive. We define by increasing depth and, within a configuration, by increasing position, maintaining that agrees with on depth, position, and membership in L. Let be a witness of the first conjunct. As the image of the next cell after , for , we take a witness of the second conjunct for ; as the image of , for , we take a witness of the third conjunct for and b. The invariant is maintained since if and only if . As the and encode depths and positions exactly, the invariant means that preserves and reflects all unary predicates. Finally, is the transitive closure of the pairs of a cell and its next cell, and of the pairs . As maps them into the transitive relation , it preserves .
Proof of Lemma 5.3. Take , , and as above. By Lemmas A.1 and A.4, (i) implies (ii), which implies (iii) as is finite and is transitive. Conversely, let be a finite model of in which is transitive. Lemma A.4 yields a tree homomorphism into the -reduct of , along which , which is universal, equality-free, and uses only negatively, pulls back to an expansion of by Lemma A.3; so accepts by Lemma A.1.
Two Variables and Two-Dimensional Structures (Under submission)
B Processing Lines: Model-Induced Lines
Fix a finite and its witnessing sets as in Section 6. For , the set collects the leftmost and rightmost elements of each 1-type on each side of the line of . The set consists of elements with a selected witness across that line outside , together with those witnesses. Recall that consists of , its -neighbours, the witnesses , and the elements of .
▶ Lemma B.1. For every , the structure is a processing line satisfying (L1)-(L3).
Proof. Fix and put and . Note that . All types and orders of are inherited from , and every retained -edge joins consecutive elements in , and hence also in . This establishes (L1). For (L2), fix , and . Since lies in , restricting to leaves these extrema unchanged. Hence . Finally, for (L3), , and the underlying structure of is . As the are quantifier-free, these witnesses still serve all demands of .
▶ Lemma B.2. Let be an enumeration of A and set . Then satisfies the gluing rules (G1)-(G4).
Proof. The first and last lines are initial and final, as is bottommost and topmost. Fix and put . Write and for the model-defined sets and . Only changes sides between the two lines.
Succession and extrema. The element is the -successor of in . Both lines contain these elements and inherit their -edge, giving (G1). For either and any finite ordered set , . Applying this identity to each 1-type on both sides of the two lines gives the equations of (G4).
Persistence. Deleting preserves every other extremal element, while adding it cannot make a nonextremal element extremal. Consider . If it is extremal, it remains so in . Now, if is a witness of or of an element of , it lies in or . Lastly, if , its nonextremal witness below the first line remains nonextremal below the second, so . These exhaust the construction of and prove the first inclusion in (G3).
Conversely, let . An extremal element stays extremal when is removed. Now, if is a witness of or of an element of , it lies in or . And again, if , its nonextremal witness above the line of remains nonextremal above the line of . Thus, . Finally, by definition, . This proves the second inclusion.
Agreement and witnesses. Both lines are induced substructures of , so they agree on their common domain. For , both and equal . This proves (G2).
▶ Lemma B.3. If has a finite model, then some sequence of processing lines, each with at most L elements named in , satisfies the gluing rules.
Proof. Take from Lemma 6.3, and let M be as in its proof. A line of consists of its distinguished element, at most two -neighbours, at most witnesses, at most extremal elements, and at most and elements in each set and , respectively. So it has at most elements. Let be the elements of and ; by Lemma B.2, they satisfy the gluing rules. Rename their elements line by line, giving each element of a number unused in and ; one is free, as fewer than 2L are taken. The renaming is injective on every , so it preserves the rules.