arXiv:2610.20937cs.LOOct 2026

Manuscript Offprint

arXiv:2610.20937

Two Variables and Two-Dimensional Structures

Bartosz Jan Bednarczyk, Daumantas Kojelis, Krzysztof Szymański

Abstract

We study the two-variable fragment FO2FO^2 of first-order logic over two-dimensional structures. Formulae may employ two linear orders ⪯1,⪯2\preceq_1, \preceq_2, their successor relations S1,S2S_1, S_2, 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 FO2FO^2 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 FO2FO^2 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 FO2FO^2 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 FO2FO^{2} 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: FO2FO^{2} 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, FO2FO^{2} 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 FO2FO^{2} 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; FO2FO^2 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 xx-axis by ⪯1\preceq_1 and along the yy-axis by ⪯2\preceq_2 (see Figure 1): these are the two-dimensional structures of our title. We write FO2[O]FO^2[O] for FO2FO^2 over them, where O lists the distinguished symbols available, i.e. linear orders ⪯i\preceq_i and successor relations SiS_i (see Section 2); e.g. FO2[{⪯1,⪯2}]FO^2[\{\preceq_1, \preceq_2\}] 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 FO2FO^{2} 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 FO2\mathrm{FO}^2. 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. FO2[{⪯1,S2}]\mathrm{FO}^2[\{\preceq_1, \mathrm{S}_2\}], 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 FO2\mathrm{FO}^2, 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 FO2\mathrm{FO}^2 thus reduces to the complement of the finite satisfiability problem for FO2\mathrm{FO}^2 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 FO2\mathrm{FO}^2 by Bednarczyk and Grange [1].

Table 1 Complexity of finite satisfiability for FO2[O]\mathrm{FO}^2[\mathrm{O}], for signatures whose auxiliary symbols are unary only (called EMSO2\mathrm{EMSO}^2 in [31]) or arbitrary (called ESO2\mathrm{ESO}^2). Our results are marked by ⋆\star, 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 FO2\mathrm{FO}^2 [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 OUnary auxiliary symbols onlyArbitrary 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 ⋆\star in Table 1, and settle the question on order-successor-invariance as well. In more detail, our contributions are as follows.

  1. Finite satisfiability of FO2[{⪯1,S2}]\mathrm{FO}^2[\{\preceq_1, \mathrm{S}_2\}] 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 ⪯2\preceq_2. As a by-product, we reprove NEXPTIME-completeness of FO2[{⪯,S}]\mathrm{FO}^2[\{\preceq, S\}] [31, Thm. 3] in a slightly simpler way.

  2. Finite satisfiability of FO2[{⪯1,⪯2}]\mathrm{FO}^2[\{\preceq_1, \preceq_2\}] is EXPSPACE-hard, already without auxiliary binary symbols (Theorem 5.1); previously, only the NEXPTIME lower bound inherited from FO2\mathrm{FO}^2 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.

  3. Finite satisfiability of FO2[{⪯1,S1,⪯2}]\mathrm{FO}^2[\{\preceq_1, S_1, \preceq_2\}] 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].

  4. In Theorem 4.1 we show that both order-invariance and order-successor-invariance of FO2FO^2 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 FO2[{⪯,S}]FO^2[\{\preceq, S\}]. 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 FO2[{⪯1,⪯2}]\mathrm{FO}^2[\{\preceq_1, \preceq_2\}] and FO2[{⪯1,S1,⪯2}]\mathrm{FO}^2[\{\preceq_1, S_1, \preceq_2\}] 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.

References (47)