Abstract 1 Introduction 2 Preliminaries 3 Logics and prior complexity bounds concerning them 4 Finite satisfiability of 𝗚𝗣𝟮 is in EXP 5 Spectra of 𝗖𝟮 formulas 6 Negative results about the spectrum of 𝗚𝗣𝟮 sentences 7 Related work 8 Conclusion References

Analysis of Logics with Arithmetic

Michael Benedikt ORCID University of Oxford, UK Chia-Hsuan Lu ORCID University of Oxford, UK Tony Tan ORCID University of Liverpool, UK
Abstract

We present new results on finite satisfiability of logics with counting and arithmetic. One result is a tight bound on the complexity of satisfiability of logics with so-called local Presburger quantifiers, which sum over neighbors of a node in a graph. A second contribution concerns computing a semilinear representation of the cardinalities associated with a formula in two variable logic extended with counting quantifiers. Such a representation allows you to get bounds not only on satisfiability for these logics, but for satisfiability in the presence of additional “global cardinality constraints”: restrictions on cardinalities of unary formulas, expressed using arbitrary decidability logics over arithmetic. In the process, we provide simpler proofs of some key prior results on finite satisfiability and semi-linearity of the spectrum for these logics.

Keywords and phrases:
Presburger quantifiers, Spectrum, Guarded logics
Copyright and License:
[Uncaptioned image] © Michael Benedikt, Chia-Hsuan Lu, and Tony Tan; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Logic and verification
Related Version:
Full Version: https://arxiv.org/abs/2508.03574
Editors:
Stefano Guerrini and Barbara König

1 Introduction

This paper concerns the problem of determining whether a formula in some logic is satisfied in some finite structure: the finite satisfiability problem for . For the fragments of interest to us, the decidability of this problem will imply decidability of many other static analysis problems for the logic, such as validity of a sentence over finite structures and equivalence of two sentences over finite structures. The problem is known to be undecidable for first order logic [20]. In the last decades two paradigms for decidability emerged, one based on restricting to guarded quantification, and another restricting to two variable fragments. The two variable fragment of first order logic was shown to have decidable finite satisfiability problem and this was extended to allow “counting quantifiers”, of the form kyϕ(x,y), where k is fixed. The complexity of the satisfiability problem for this logic, normally denoted 𝖢𝟤, over finite structures, as well as the complexity of satisfiability when considering arbitrary structures, was isolated in [15]. The same problem for the sublogic where quantification is guarded was shown to have slightly lower complexity [16].

In recent years there has been interest in adding more powerful arithmetic capabilities to these decidable logics. Instead of just asking whether the number of elements satisfying a property is above or below a constant, we can ask whether the cardinality is even, or whether the cardinality of several properties satisfies a linear inequality. Presburger logic focuses on linear inequalities between properties [2, 4, 3, 12], and local Presburger logic, 𝖦𝖯𝟤, restricts to properties that involve neighbors of a given element. These logics are most naturally applied to finite models, to avoid dealing with addition or parity of infinity: thus in this work, finite satisfiability will always be our default, and we just refer to “satisfiability” henceforward. In [6] it was shown that local Presburger logics are in some sense equally expressive as certain variations of Graph Neural Networks (GNNs), and GNN verification problems can be reduced to satisfiability problems for these logics. It has been shown that satisfiability of Presburger logic is undecidable, while satisfiability of local Presburger logic is decidable [4]: the complexity of local Presburger logic is 𝖭𝖤𝖷𝖯 complete [3, 12], but the exact complexity of finite satisfiability had not been determined. Another way of enhancing logic with arithmetic involves global cardinality constraints. In such an enhancement, we can write a constraint that defines a constraint (e.g., a linear inequality) between one variable formulas. But we cannot have such a constraint parameterized by a second free variable. For example, we can write that unary predicate U has cardinality below unary predicate V. But if E and F are two binary predicates, we cannot express that the elements that are not E adjacent to x have greater cardinality than the elements that are not F adjacent to x.

As with local Presburger logic, it follows from prior results that 𝖢𝟤 enhanced with global cardinality constraints has decidable (finite) satisfiability problem. The exact complexity is not explicitly studied in the literature, although in the case of global cardinality constraints consisting of linear inequalities, tight bounds follow from results of Rudolph in [18]. A natural approach to proving decidability for logics enhanced with global constraints follows is to show that the the spectrum of each tuple of unary formulas of the logic is effectively semilinear. The spectrum of a tuple of unary formulas ϕ1(x)ϕk(x) is the set of possible values that the tuple of cardinalities of the satisfiers of the formula can have within a finite model. For example, for the pair of formulas ϕ1(x)=U(x),ϕ2(x)=U(x)V(x) the spectrum consists of all pairs (m,n) with nm. The spectrum being effectively semilinear means that we can find a quantifier-free formula of arithmetic that defines it. From effective semilinearity of the spectrum, we easily obtain decidability with additional global constraints. Here we provide complexity bounds for several of these problems, one featuring arithmetic over counts of neighbors, another concerning computing the spectrum of formulas. See Table 1 for the summary of our new upper bounds. At the same time, we provide simpler proofs of two fundamental results in the area: decidability of (finite) satisfiability for 𝖦𝖯𝟤 (see Section 4), and effective semi-linearity of the spectrum for 𝖢𝟤 (Section 5). We complement these positive results with a counterexample to semilinearity of spectra for 𝖦𝖯𝟤 unary formulas (Section 6).

2 Preliminaries

Basic notions.

A graph will always mean a finite directed graph without self-loops. A colored graph is a graph where nodes have a unique node label, and every pair of distinct nodes is connected by a unique edge (in one direction or the other), with node and edge vocabularies distinct. A multigraph is a finite directed graph without self-loops that allows a finite number of parallel edges (including no edge) between a pair of distinct nodes. A colored multigraph is defined similarly, but requiring each node to have a unique label. The multiplicity of a multigraph is defined as the maximum edge multiplicity within it.

The ith unit vector, denoted by 𝐞i, has ith entry 1, and other entries are 0. We define 𝟎 as the vector where all entries are 0, and 𝟏 as the vector that all entries are 1. For 𝐯,𝐮n, 𝐯𝐮 if, for 1in, 𝐯i𝐮i Let 𝗉𝗋𝗈𝗃n(𝐯) denote the projection operator that maps 𝐯 to its first n entries. Let 𝐀 and 𝐯 denote the maximal absolute values of the entries in 𝐀 and 𝐯, respectively.

Linear algebra and Kleene star.

An integer linear constraint is an inequality iaixic involving integer coefficients ai, non-negative integer variables xi, and an integer constant c. The set of solutions of such a constraint is called a modulus-free semilinear set, while if we include equations x=cmodp for integers c,p>0 it is a semilinear set. A constraint is homogeneous if c=0.

For an integer linear system 𝒬(𝐱):𝐀𝐱=𝐜, we denote by 𝒬(𝐱) the set of solutions in , i.e., 𝒬(𝐱):={𝐯n|𝐀𝐯=𝐜}, and similarly for a Boolean combination of linear systems. Note that if 𝒬(𝐱) is feasible, then it has a solution in which the number of non-zero assignments is bounded, and the values of the assignments are also bounded.

Lemma 1 ([13], [7], also see Corollary 2.2 in [12]).

There are constants c1,c2 such that for every integer linear system 𝒬(𝐱), if 𝒬(𝐱) admits a solution in , then it admits a solution in in which the number of variables assigned non-zero values is at most c1tlog(c2tM) and every variable is assigned a value bounded by c1t(tM)c2t, where t is the number of constraints in 𝒬(𝐱) and M is the maximal absolute value of the coefficients in 𝒬(𝐱).

Definition 2 (Kleene star).

For a set 𝒮n, the Kleene star of 𝒮 is defined as

𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(𝒮):={s𝒮s|𝒮 is a finite multisubset of 𝒮}.

Note that 𝟎𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(𝒮) for any 𝒮.

If 𝒮 is semilinear then its Kleene star is semilinear: this is closely-related to Parikh’s theorem which gives a correspondence between semi-linear sets and regular languages: see [14, 8]. We will be interested in bounding the complexity of the Kleene star of a semilinear set using numerical data associated to the set. Note that for an integer linear system 𝒬(𝐱):𝐀𝐱=𝐜, if 𝐜=𝟎, then 𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(𝒬(𝐱))=𝒬(𝐱). The following result gives a bound when 𝐜𝟎.

Lemma 3.

For every integer linear system 𝒬(𝐱):𝐀𝐱=𝐜 with 𝐜𝟎, where 𝐀m×n and 𝐜m, there exists 𝐀~(n+t)×(n+k) with 𝐀~=1 such that 𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(𝒬(𝐱))=𝒬~(𝐱), where 𝒬~(𝐱) is the Boolean combination of integer linear systems

𝐲1,𝐲2(𝐱=𝗉𝗋𝗈𝗃n(𝐲1)+𝐲2)(𝐀~𝐲1= 0)(𝐀𝐲2= 0)((𝐲1=𝟎)(𝐲2=𝟎)),

k=n(2D+1)m+1, t2nk, and D=n𝐀((n+1)𝐀+𝐜+1)m. Moreover, 𝐀~ can be computed in time 2𝒪(logn+logK+m2), where K:=max(𝐀,𝐜).

We defer the proof of this to the appendix.

Types.

Let σ be a vocabulary with unary U1,,Un and binary R1,,Rm.

Definition 4 (1- and 2-type).

A 1-type (w.r.t. σ) is a maximal consistent subset of

i[n]{Ui(x),¬Ui(x)}i[m]{Ri(x,x),¬Ri(x,x)}.

A 2-type (w.r.t. σ) is a maximal consistent subset of

i[m]{Ri(x,y),¬Ri(x,y),Ri(y,x),¬Ri(y,x)}.

We denote the set of 1-types by 𝖮𝗇𝖾𝖳𝗉𝗌 and the set of 2-types 𝖳𝗐𝗈𝖳𝗉𝗌.

Given an element v in a σ-structure 𝒢, we let 𝖮𝗇𝖾𝖳𝗉(v) denote its one-type in 𝒢 and similarly for a pair of elements v,u in 𝒢 we let 𝖳𝗐𝗈𝖳𝗉(v,u) denote its two-type in 𝒢; in both cases we omit the dependence on 𝒢 for brevity.

The following definitions are variations of notions in Pratt-Hartmann’s [15, 16, 17].

Definition 5 (Silent 2-type).

The silent type, denoted by η0, is the unique 2-type that consists of only negated terms. If a type is not silent we say it is audible.

Definition 6 (Dual of 2-type).

For a 2-type η, the dual of η, denoted by η~, it the unique 2-type that swaps x and y in η.

We denote the set of all 2-types except η0 by 𝖳𝗐𝗈𝖳𝗉𝗌+, and the set of all 2-types that contain Rt(x,y) by 𝖳𝗐𝗈𝖳𝗉𝗌t for 1tm.

Note that |𝖮𝗇𝖾𝖳𝗉𝗌|=2n+m, |𝖳𝗐𝗈𝖳𝗉𝗌|=22m, |𝖳𝗐𝗈𝖳𝗉𝗌+|=22m1, and |𝖳𝗐𝗈𝖳𝗉𝗌t|=22m1.

We can abstract a model based on types:

Definition 7 (Type graph).

We associate to a σ-structure in a binary vocabulary a colored graph with the same set of vertices in an exponentially larger vocabulary: each vertex is colored with a 1-type, and each edge is colored with a 2-type. This is the type graph of the σ-structure.

Losing information, we can abstract a finite model based on cardinalities of 1-types. The notion will be crucial in Section 5:

Definition 8 (1-type cardinality vector of a σ-structure).

Let 𝒢 be a σ-structure. The 1-type cardinality vector of 𝒢 is a |𝖮𝗇𝖾𝖳𝗉𝗌|-dimensional vector where the ith component is the number of elements in 𝒢 with 1-type πi.

3 Logics and prior complexity bounds concerning them

We fix a vocabulary σ which consists of n unary predicates U1,,Un and m binary predicates R1,,Rm. All of our logics will consist of formulas with at most two variables, x and y. We start by reviewing two variable logic with counting (𝖢𝟤), built up from atomic formulas Ui(x), Ui(y), Ri(x,y), and Ri(y,x) via the Boolean operators and the quantifier constructs ρ(x):=kyϕ(x,y), where ϕ is a 𝖢𝟤 formula and k is a natural number, and similarly with the role of x and y swapped.

Our semantics will always be over finite structures interpreting the vocabulary σ. The formula ρ(y) above holds in a model M at an element u for x when there are least k elements v such that Mϕ(u,v). The case k=1 represents standard existential quantification.

Guarded two variable logic with counting (𝖦𝖢𝟤), restricts 𝖢𝟤 by requiring quantification to be guarded by an atom. The quantifier rule now includes the forms:

kyRi(x,y)ϕ(x,y),kyRi(y,x)ϕ(x,y),orkxUi(x)ϕ(x).

The logic 𝖯𝟤 replaces 𝖢𝟤’s counting quantifier with a Presburger quantifier:

ρ(x):=(t[m]κt#y[ϕt(x,y)])δ,

where κt are integers, is an inequality or equality, and δ is an integer. In 𝖯𝟤 we will also allow unguarded quantification over unary formulas: if ϕ(x) is a formula, so is xϕ(x). For example, x(#y[R(x,y)]3#y[R(y,x)]=0) is a sentence of 𝖯𝟤 that holds in a directed graph when there is an element that has 3 times as many outgoing edges as incoming edges.

The logic 𝖦𝖯𝟤 (guarded two variable logic with Presburger quantifiers) restricts 𝖯𝟤 by requiring each ϕi in a Presburger quantifier to be guarded, although still allowing unguarded unary quantification. Note that global cardinality constraints can be expressed in 𝖯𝟤, but not in 𝖦𝖯𝟤. Following prior papers [12], we do not allow a quantifier that tests the modulus of a linear combination of cardinalities of one dimensional sets, and thus our quantifiers are in a sense weaker than Presburger arithmetic. A Presburger modulus constraint is as above, but allowing δ to be replaced by (=mmodn), for natural numbers m,n with m<n. Likewise, 𝖢𝟤+g can be extended to allow modulus constraints. In the appendix we show that all of of our results on 𝖦𝖯𝟤 and 𝖢𝟤+g also hold for the extension with modulus constraints; in the body of the paper we focus on plain 𝖦𝖯𝟤 and 𝖢𝟤+g in the statements.

Given a unary formula ϕ(x) in some logic, and a finite model M, we let |ϕ|M be the cardinality of ϕ in M; we extend this notation to a tuple ϕ1(x)ϕk(x). Given such a tuple, its spectrum is the set of vectors of numbers of the form |ϕ1(x)ϕk(x)|M. We say that such a spectrum is semi-linear if it can be represented as a set of linear inequalities. When we talk about computing the spectrum for a formula, we mean computing a semi-linear representation. If we have such a representation, we can clearly check whether an individual ϕi(x) is satisfiable, simply by seeing if the corresponding set of constraints is feasible. Thus, in cases, where the spectrum is known always to have such a representation, computing the spectrum can be seen as a generalization of the satisfiability pboelm.

The positive results in this paper, as well as the prior bounds, are summarized in Table 1. In the table, Sat Logic refers to the satisfiability problem for formulas of the logic over finite structures, while Spectrum refers to a bound on the size of a representation of the spectrum, again over finite structure. An entry of the form X-c indicates that the problem is complete for complexity class X.

Table 1: Complexity results, with those new to this work in bold.
Sat Logic Spectrum Size Bound
𝖦𝖢𝟤 𝖤𝖷𝖯-c [16] 𝖤𝖷𝖯 (formerly 𝟤𝖤𝖷𝖯)
𝖢𝟤 𝖭𝖤𝖷𝖯-c [15] 𝖤𝖷𝖯, Thm 25 (formerly 𝟤𝖤𝖷𝖯 [5])
𝖦𝖯𝟤 𝖤𝖷𝖯-c, Thm 9 (formerly 𝖤𝖷𝖯-hard, in 𝟥𝖭𝖤𝖷𝖯 [4]) Open
𝖯𝟤 Undecidable [4] No size bound

We give results on the spectrum, but they have applications to decidability of richer logics. 𝖢𝟤 can be extended with global unary cardinality constraints: these are of the form ρ:=(t[n]κt|ϕt(x)|)δ, where ϕt are 𝖢𝟤 formulas in one free variable, κt are integers, is an inequality or equality, and δ is an integer. ρ is a sentence, and we define the semantics only for finite structures M. Such M satisfies ρ if, letting st be the number of elements in M satisfying ϕt(x), we have (t[n]κtst)δ. We write 𝖢𝟤+g for the extension of 𝖢𝟤 with global cardinality constraints. As we explain later, computation of the spectrum provides an approach to get tight bounds on these extended logics. In the case where the global constraints are in Presburger arithmetic, these can be seen as an alternative to the technique of [18], which obtains tight bounds for the logic through reduction to satisfiability of 𝖢𝟤 itself.

4 Finite satisfiability of 𝗚𝗣𝟮 is in EXP

The goal of this section is to prove:

Theorem 9.

The finite satisfiability problem of 𝖦𝖯𝟤 is in 𝖤𝖷𝖯.

𝗚𝗣𝟮 infrastructure.

We fix a vocabulary σ which consists of n unary predicates U1,,Un and m binary predicates R1,,Rm. We consider 𝖦𝖯𝟤 sentences φ over σ in normal form:

φ:=xγ(x)i[m]xy(Ri(x,y)xy)αi(x,y)i[n]xUi(x)Pi(x),

where γ(x) is a quantifier-free formula, each αi(x,y) is a quantifier-free formula, and each Pi(x) is a Presburger quantified formula of the form:

Pi(x):=(t[m]λi,t#y[Rt(x,y)xy])iδi.

Note that in the normal form we allow xy(R(x,y)xy)α(x,y) which is equivalent to a 𝖦𝖯𝟤 sentence.

There is a linear time algorithm that converts every 𝖦𝖯𝟤 sentence into an equi-satisfiable sentence in normal form [12], which is based on the standard renaming technique for 𝖦𝖢𝟤 introduced in [10, 16]. See the appendix for an argument.

Definition 10 (Compatibility of 1- and 2-types).

For a 𝖦𝖯𝟤 sentence φ in the normal form above and a 1-type π, we say π is compatible with φ, if π(x)γ(x), where γ(x) is from the normal form, that is, the “unary universal part” of φ.

For 1-types π1 and π2, and a 2-type η, we say that π1,η,π2 is compatible with φ, if

  • π1(x)η(x,y)π2(y)i[m](Ri(x,y)xy)αi(x,y), and

  • π2(x)η~(x,y)π1(y)i[m](Ri(x,y)xy)αi(x,y).

That is, the tuple satisfies the “binary universal part”.

We denote the set of 1-types compatible with φ by 𝖮𝗇𝖾𝖳𝗉𝗌φ𝖮𝗇𝖾𝖳𝗉𝗌. Note that it takes time 𝒪(|φ|) to check compatibility with φ either for a 1-type π or a tuple π1,η,π2𝖮𝗇𝖾𝖳𝗉𝗌×𝖳𝗐𝗈𝖳𝗉𝗌×𝖮𝗇𝖾𝖳𝗉𝗌.

In order to capture the counting conditions, we introduce behavior vectors. Informally, the behavior vector of a vertex encodes the configuration of its neighbors. We fix an ordering of the set 𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌, which has cardinality 2n+3m2n+m. A behavior vector 𝐟 is an element of 2n+3m2n+m. Abusing notation, we write 𝐟(π,η) to refer to the ith component of 𝐟, where i is the index of the tuple π,η in the fixed ordering of 𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌.

Definition 11 (Behavior vector of a vertex).

For a σ-structure 𝒢 and a vertex v in 𝒢, the behavior vector realized by v, denoted by 𝖻𝗁(v), is an element of 2n+3m2n+m defined as follows: for every η𝖳𝗐𝗈𝖳𝗉𝗌+ and π𝖮𝗇𝖾𝖳𝗉𝗌, 𝖻𝗁(v)(η,π) is the number of edges e in 𝒢 adjacent to v such that the 2-type of e is η and the 1-type of e’s destination is π.

Definition 12 (Characteristic system).

For 𝖦𝖯𝟤 sentence φ in normal form and 1-type π, the characteristic system of φ and π, denoted 𝒞πφ(𝐱), is the integer linear system defined:

  • The variables of 𝒞πφ(𝐱) are xη,π for every η𝖳𝗐𝗈𝖳𝗉𝗌+ and π𝖮𝗇𝖾𝖳𝗉𝗌.

  • (Compatibility) For every η𝖳𝗐𝗈𝖳𝗉𝗌+ and π𝖮𝗇𝖾𝖳𝗉𝗌 if π or π,η,π is not compatible with φ, then xη,π=0 is a constraint in 𝒞πφ(𝐱).

  • (Counting) For 1in, if Ui(x)π then the following constraint is in 𝒞πφ(𝐱):

    (t[m]λi,tη𝖳𝗐𝗈𝖳𝗉𝗌tπ𝖮𝗇𝖾𝖳𝗉𝗌xη,π)iδi.

Note that there are |𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌| variables and at most n, the number of unary predicates, constraints in 𝒞πφ(𝐱). The absolute value of coefficients in 𝒞πφ(𝐱) is bounded by K, where K is the maximal absolute value of coefficients in φ.

Definition 13 (Compatibility of behavior vector).

For a 𝖦𝖯𝟤 sentence φ in normal form and a 1-type π, we say that a behavior vector 𝐟 is compatible with φ and π if 𝐟 is a solution of 𝒞πφ(𝐱).

We denote the set of all behavior vectors that are compatible with φ and π by πφ:=𝒞πφ(𝐱). Note that πφ can be infinite but semilinear.

The following property restates satisfaction of a formula in a σ-structure in terms of the type graph of the structure, where the types are identified with vertex- and edge-labels:

Proposition 14.

For every 𝖦𝖯𝟤 sentence φ in normal form, φ is finitely satisfiable if and only if there exists a colored graph 𝒢 satisfying the following conditions:

  • (1-type) For every vertex vV, 𝖮𝗇𝖾𝖳𝗉(v) is compatible with φ.

  • (2-type) For every pair of vertices v1,v2V, 𝖮𝗇𝖾𝖳𝗉(v1),𝖳𝗐𝗈𝖳𝗉(v1,v2),𝖮𝗇𝖾𝖳𝗉(v2) is compatible with φ.

  • (Counting) For every vertex vV, 𝖻𝗁(v) is compatible with 𝖮𝗇𝖾𝖳𝗉(v) and φ.

We say that a colored multiple graph in the vocabulary of types, 𝒢, is a finite pseudo-model of a 𝖦𝖯𝟤 sentence φ if it satisfies all conditions in Proposition 14. Here we show that to establish the finite satisfiability of φ, it is sufficient to construct a pseudo-model.

Lemma 15.

For every 𝖦𝖯𝟤 sentence φ in normal form, φ is finitely satisfiable if and only if it has a finite pseudo-model.

Proof.

Note that the type graph of a finite model of φ is a finite pseudo-model of φ. Thus we focus on the if direction, constructing (the type graph of) a finite model of φ using a duplicating and swapping procedure.

Let 𝒢0 be a finite pseudo-model of φ, and let 𝒢0 be a copy of 𝒢0. Define 𝒢1 as the disjoint union of 𝒢0 and 𝒢0, after iteratively applying the following swapping procedure: for every pair of vertices v and u in 𝒢0 with more than one edge between them, let e be an edge between them, and let e be the corresponding edge in 𝒢0. We then swap the destinations of e and e in 𝒢1.

It is straightforward to verify that 𝒢1 is a pseudo-model of φ and its multiplicity is one less than 𝒢0. We can repeat this procedure until we obtain a finite pseudo-model 𝒢t where no two vertices have multiple edges. Finally, the type graph of the finite model of φ is obtained by connecting all remaining pairs in 𝒢t with the silent type.

The main construction.

For every 𝖦𝖯𝟤 sentence φ in normal form, we assume that for every 1-type π𝖮𝗇𝖾𝖳𝗉𝗌φ, 𝟎πφ. Otherwise φ is trivially satisfiable by a model with only one vertex with 1-type π.

Lemma 16.

A 𝖦𝖯𝟤 sentence φ in normal form is finitely satisfiable if and only if there exists vectors 𝐠π𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ) for each π𝖮𝗇𝖾𝖳𝗉𝗌φ satisfying the following conditions.

  • (Matching) For every π1,η,π2𝖮𝗇𝖾𝖳𝗉𝗌φ×𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌φ, 𝐠π1(η,π2)=𝐠π2(η~,π1).

  • (Non-triviality) There exists some π𝖮𝗇𝖾𝖳𝗉𝗌φ such that 𝐠π𝟎.

Proof.

Suppose that 𝝋 is finitely satisfiable with finite model 𝓖.

For a 1-type π, let VπV be the set of vertices v in 𝒢 with 1-type π. Note that the Vπ partition V. Since 𝒢φ, for every v in Vπ, 𝖻𝗁(v)πφ. We claim that 𝐠π=vVπ𝖻𝗁(v)𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ) satisfies the conditions.

  • (Matching) For every π1,η,π2𝖮𝗇𝖾𝖳𝗉𝗌φ×𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌φ, note that
    vVπ1𝖻𝗁(v)(η,π2)= vVπ1|{uV|vu𝖳𝗐𝗈𝖳𝗉(v,u)=η, and 𝖮𝗇𝖾𝖳𝗉(u)=π2}| = |{(v,u)V2|vu𝖮𝗇𝖾𝖳𝗉(v)=π2𝖳𝗐𝗈𝖳𝗉(v,u)=η, and 𝖮𝗇𝖾𝖳𝗉(u)=π2}|.

    That is, 𝐠π1(η,π2) is the number of edges with types π1,η,π2 in 𝒢. Similarly, 𝐠π2(η~,π1) is the number of edges with types π2,η~,π1 in 𝒢. Since the number of edges with types π1,η,π2 and π2,η~,π1 should be the same, the Matching constraint holds.

  • (Non-triviality) Since 𝒢 is non-empty, by our assumption, it has a vertex v with 1-type π satisfying that 𝖻𝗁(v)𝟎. Therefore, 𝐠π=𝖻𝗁(v)+uVπ{v}𝖻𝗁(u)𝟎.

Suppose that there exists such 𝐠𝝅𝗞𝗹𝗲𝗲𝗻𝗲𝗦𝘁𝗮𝗿(𝓑𝝅𝝋) for 𝝅𝗢𝗻𝗲𝗧𝗽𝘀𝝋

. By the definition of Kleene star, for every π𝖮𝗇𝖾𝖳𝗉𝗌φ, there exists 𝐟π,1,,𝐟π,ππφ, not necessarily distinct, such that 𝐠π=i[π]𝐟π,i. We construct a colored multigraph 𝒢, which will be the type graph of our structure, as follows. The vertices in 𝒢 are π𝖮𝗇𝖾𝖳𝗉𝗌φ{vπ,1,,vπ,π}. Each vertex vπ,i is colored with a 1-type π, and we let Vπ be the set of vertices colored with π. For every π1,η,π2𝖮𝗇𝖾𝖳𝗉𝗌φ×𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌φ, we add edges between Vπ1 and Vπ2 such that for each vπ1,i, the number of edges connected to it with 2-type η is 𝐟π1,i(η,π2) and for each vπ2,i, the number of edges connected to it with 2-type η is 𝐟π2,i(η~,π1). Note that by the Matching constraint, 𝐠π1(η,π2)=𝐠π2(η~,π1), so this construction is always possible. We claim that 𝒢 is a pseudo-model of φ. Note that each vertex in 𝒢 is colored with 1-type in 𝖮𝗇𝖾𝖳𝗉𝗌φ, each edge in 𝒢 is colored with 2-type in 𝖳𝗐𝗈𝖳𝗉𝗌+, and it is routine to check that the behavior vector of vπ,i is 𝐟π,i. By the Non-triviality constraint, 𝒢 is non-empty. Thus by Lemma 15, φ is finitely satisfiable.

Above we connected the finite satisfiability problem of 𝖦𝖯𝟤 sentence φ and the Kleene star of behavior vectors. However, because the cardinality of the set 𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ) is infinite, it is not clear how to determine the solvability of the conditions in Lemma 16. In addition, this representation does not tell us anything about the shape of the models.

Recall that the set of behavior vectors πφ is the solution set of the characteristic system 𝒞πφ(𝐱). We can apply Lemma 3 and obtain that

𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ)=𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(𝒞πφ(𝐱))=𝒞~πφ(𝐱).

Thus the conditions in Lemma 16 can be encoded in the following integer linear system.

Definition 17.

For every 𝖦𝖯𝟤 sentence φ in normal form, the integer linear system 𝒬φ(𝐱) is defined as follows.

  • The variables of 𝒬φ(𝐱) are xπ1,η,π2 for every π1,π2𝖮𝗇𝖾𝖳𝗉𝗌φ and η𝖳𝗐𝗈𝖳𝗉𝗌+. Let 𝐱π1 denote the vector of variables xπ1,η,π2.

  • (Structure) For every π𝖮𝗇𝖾𝖳𝗉𝗌φ, 𝒞~πφ(𝐱π) is part of 𝒬φ(𝐱), where 𝒞~πφ(𝐱) is the integer linear system obtained by applying Lemma 3 to the characteristic system 𝒞πφ(𝐱).

  • (Matching) For every π1,η,π2𝖮𝗇𝖾𝖳𝗉𝗌φ×𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌φ, the following constraint is in 𝒬φ(𝐱), xπ1,η,π2=xπ2,η~,π1, where we recall that η~ denotes the dual 2-type.

  • (Non-triviality) π1𝖮𝗇𝖾𝖳𝗉𝗌φη𝖳𝗐𝗈𝖳𝗉𝗌+π2𝖮𝗇𝖾𝖳𝗉𝗌φxπ1,η,π2>0.

Lemma 18.

For every 𝖦𝖯𝟤 sentence φ in normal form, φ is finitely satisfiable if and only if 𝒬φ(𝐱) has a solution in .

Proof.

Suppose that 𝝋 is finitely satisfiable.

By Lemma 16, there exists 𝐠π𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ) for π𝖮𝗇𝖾𝖳𝗉𝗌φ satisfying the Matching and Non-triviality conditions.

For every π1,π2𝖮𝗇𝖾𝖳𝗉𝗌φ and η𝖳𝗐𝗈𝖳𝗉𝗌+, let aπ1,η,π2:=𝐠π1(η,π2). We claim that assigning xπ1,η,π2 to aπ1,η,π2 gives a solution of the system 𝒬φ(𝐱).

  • (Structure) By definition, for every π𝖮𝗇𝖾𝖳𝗉𝗌φ, 𝐠π𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ). By Lemma 3, 𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ)=𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(𝒞πφ(𝐱))=𝒞~πφ(𝐱). Thus, 𝐚π is a solution of 𝒞~πφ(𝐱).

  • (Matching) For every π1,η,π2𝖮𝗇𝖾𝖳𝗉𝗌φ×𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌φ, by the Matching condition in Lemma 16, 𝐠π1(η,π2)=𝐠π2(η~,π1). Thus aπ1,η,π2=aπ2,η~,π1.

  • (Non-triviality) By the Non-triviality condition in Lemma 16, there exists a 1-type π𝖮𝗇𝖾𝖳𝗉𝗌φ such that 𝐠π𝟎. Therefore,

    π1𝖮𝗇𝖾𝖳𝗉𝗌φη𝖳𝗐𝗈𝖳𝗉𝗌+π2𝖮𝗇𝖾𝖳𝗉𝗌φaπ1,η,π2= π1𝖮𝗇𝖾𝖳𝗉𝗌φη𝖳𝗐𝗈𝖳𝗉𝗌+π2𝖮𝗇𝖾𝖳𝗉𝗌φ𝐠π1(η,π2)
    η𝖳𝗐𝗈𝖳𝗉𝗌+π2𝖮𝗇𝖾𝖳𝗉𝗌φ𝐠π(η,π2)> 0.

Suppose that 𝓠𝝋(𝐱) has a solution, assigning 𝒙𝝅𝟏,𝜼,𝝅𝟐 to 𝒂𝝅𝟏,𝜼,𝝅𝟐.

For every π𝖮𝗇𝖾𝖳𝗉𝗌φ, since 𝐚π is a valid assignment of 𝒞~πφ(𝐱), by Lemma 3, 𝐚π𝖪𝗅𝖾𝖾𝗇𝖾𝖲𝗍𝖺𝗋(πφ). We claim that 𝐚π are vectors satisfying the conditions in Lemma 16, which implies that φ is finitely satisfiable. The proof of Non-triviality is routine. Here we focus on the Matching constraint. For every π1,η,π2𝖮𝗇𝖾𝖳𝗉𝗌φ×𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌φ, by the Matching condition of 𝒬φ, aπ1,η,π2=aπ2,η~,π1. Since 𝐚π1(η,π2)=aπ1,η,π2, we have 𝐚π1(η,π2)=𝐚π2(η~,π1).

The system 𝒬φ(𝐱) is a Boolean combination of exponentially many integer linear constraints, and thus can be solved in 𝖭𝖤𝖷𝖯. To get 𝖤𝖷𝖯, we apply an idea from [16], refining to get exponentially many homogeneous constraints.

Definition 19.

For every 𝖦𝖯𝟤 sentence φ in normal form, for M, the integer linear system 𝒬Mφ(𝐱) is the system 𝒬φ(𝐱) where the Structure constraint is replaced with:

  • (Structure) For every π𝖮𝗇𝖾𝖳𝗉𝗌φ,

    𝐲1,𝐲2(𝐱π=𝗉𝗋𝗈𝗃n(𝐲1)+𝐲2)(𝐀~𝐲1= 0)(𝐀𝐲2= 0)((𝟏𝐲2)M(𝟏𝐲2)),

    where 𝐀~ is the matrix obtained by applying Lemma 3 to the characteristic system 𝒞πφ(𝐱).

Lemma 20.

For every 𝖦𝖯𝟤 sentence φ in normal form, there exists Mφ, such that for every MMφ, 𝒬φ(𝐱) has a solution in if and only if 𝒬Mφ(𝐱) has a solution in .

Moreover, Mφ can be computed directly from φ in time exponential in the length of φ, assuming binary encoding of coefficients.

Proof.

By Lemma 1, if 𝒬φ has a solution in , then it has a “small solution”: every value is bounded by M0φ=c1t(tλ~)c2t, where λ~ is the maximal coefficient in φ and t is the number of constraints in 𝒬φ, which is exponential in the number of unary and binary predicates. Thus M0φ can be computed directly from φ in time exponential in the length of φ, assuming binary encoding of coefficients. Let Mφ=2nM0φ.

Note that the only difference between 𝒬φ(𝐱) and 𝒬Mφ(𝐱) pertains to constraints (𝐲1=𝟎)(𝐲2=𝟎) and ((𝟏𝐲2)M(𝟏𝐲1)). We show that the two systems are equi-satisfiable, provided M is sufficiently large.

Suppose that 𝓠𝝋(𝐱) has a solution in .

We claim that a small solution 𝐚π of 𝒬φ(𝐱) is a solution of 𝒬φ(𝐱). For every π𝖮𝗇𝖾𝖳𝗉𝗌φ, let 𝐛1 and 𝐛2 be corresponding assignments for 𝐲1 and 𝐲2 in 𝒞~πφ(𝐱π). If 𝐚π=𝟎, then 𝐛1=𝟎 and 𝐛2=𝟎, which implies that (𝟏𝐛2)Mφ(𝟏𝐛1) holds trivially. On the other hand, if 𝐚π𝟎, then 𝐛1𝟎, which implies that (𝟏𝐛1)1. Therefore (𝟏𝐛2) 2nM0φ=MφMM(𝟏𝐛1)

Suppose that 𝓠𝑴𝝋(𝐱) has a solution 𝐚𝝅 in .

We claim that the 𝐚π also form a solution to 𝒬φ(𝐱). It is sufficient to show that, for vectors 𝐛1 and 𝐛2, if (𝟏𝐛2)M(𝟏𝐛1), then (𝐛1=𝟎)(𝐛2=𝟎). If 𝐛1=𝟎, then (𝟏𝐛2)M(𝟏𝐛1)=0, which implies that 𝐛2=𝟎. Otherwise if 𝐛1𝟎, then (𝐛1=𝟎)(𝐛2=𝟎) holds trivially.

We are now ready to prove Theorem 9:

Proof.

For every 𝖦𝖯𝟤 sentence φ in normal form, by Lemma 16, Lemma 18, and Lemma 20, φ is finitely satisfiable if and only if 𝒬Mφφ(𝐱) has a solution in . Note that 𝒬Mφφ(𝐱) is an integer linear system with 2𝒪(m(n+logK)) variables, 2𝒪(m(n+logK)) constraints, and coefficients bounded by Mφ. Moreover, 𝒬Mφφ(𝐱) is homogeneous. Thus, it has a solution in the natural numbers if and only if it has a rational solution. The feasibility of an integer linear system over the rationals can be checked in time polynomial in the number of variables, the number of equations, and the logarithm of the absolute value of the maximum coefficients [9]. Consequently, this process takes time exponential in the length of φ, assuming binary encoding of coefficients

Note that the solutions to the linear system used in proving Theorem 9 will contain a representation of every finite model: the vector of cardinalities of 1-types. But it contains additional vectors that do not correspond to the cardinalities of one types in any model. This is related to the fact that while existence of a pseudo-model implies existence of a model (Lemma 15), cardinalities are not preserved in moving from a pseudo-model to the corresponding model. We return to this in Section 6.

5 Spectra of 𝗖𝟮 formulas

In this section we will consider converting formulas in logic with arithmetic into linear constraints. These constraints will characterize the set of models of a 𝖢𝟤 formula. With this characterization in place, we have reduced finite satisfiability of the formula to a check for satisfiability of the conjunction of the linear constraints, which can be done via standard linear algebra solving. From this it will follow that 𝖢𝟤 with a variety of global cardinality constraints is decidable: we just conjoined the cardinality constraints with the constraints characterizing the models.

We fix a vocabulary σ which consists of n unary predicates U1,,Un and m binary predicates R1,,Rm. We consider 𝖢𝟤 sentence φ over σ in normal form:

φ:=xγ(x)xy(xyα(x,y))i[m]x=kiy(Ri(x,y)xy),

where γ(x) and α(x,y) are quantifier-free, Ri are binary predicates, 0mm, and ki.

Definition 21 (Count bound vector).

The count bound vector of φ, denoted by 𝐤φ, is the m dimension vector such that the ith component of 𝐤φ is ki.

We denote the sum of ki by Kφ.

Definition 22 (Forward and backward characteristic vector of 2-types).

For m as above and a 2-type η, the forward characteristic vector of η, denoted by η, is an m dimensional vector defined: for every 1im, if Ri(x,y)η, then the ith component of η is 1. Otherwise, it is 0. The backward characteristic vector of η, denoted by η, is defined similarly.

Definition 23 (Forward and backward silent 2-type).

For m as above and a 2-type η we say that η is forward-silent if for 1im, ¬Ri(x,y)η. Backward-silent is defined similarly.

We define the notions of 𝖮𝗇𝖾𝖳𝗉𝗌φ and 𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ similarly to those in 𝖦𝖯𝟤. We also define 𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ,𝗌𝗂𝗅𝖾𝗇𝗍𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ as the set of 2-types that are both forward- and backward-silent, 𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ, for 2-types that are not forward-silent but are backward-silent, and 𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ, for 2-types that are neither forward- nor backward-silent.

In the rest of the section, we deal only with normal form sentences. We explain how the results apply to arbitrary 𝖢𝟤 sentences in the appendix.

Definition 24 (Spectrum and 1-type spectrum).

For every 𝖢𝟤 sentence φ, the spectrum of φ, denoted by 𝖲𝖯𝖤𝖢(φ), is the set of natural numbers that are sizes of finite models of φ.

The 1-type spectrum of φ, denoted by Π-𝖲𝖯𝖤𝖢(φ), is the set of 1-type cardinality vectors (see Definition 8) corresponding to finite models of φ.

We aim to show:

Theorem 25.

For every 𝖢𝟤 sentence φ, 𝖲𝖯𝖤𝖢(φ) and Π-𝖲𝖯𝖤𝖢(φ) are semilinear. Furthermore, each spectrum can be represented by an existential Presburger formula of size doubly exponential in φ.

Definition 26 (Silent compatible 1-types).

For a pair of 1-types π1 and π2, we say that π1 and π2 are silent-compatible w.r.t. φ, if 𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ,𝗌𝗂𝗅𝖾𝗇𝗍 is non-empty. Otherwise, we say, following [15], that π1 and π2 are a noisy pair.

Lemma 27.

For every 𝖢𝟤 sentence φ in normal form and σ-structure 𝒢φ, for every pair of 1-types π1 and π2, if π1 and π2 are a noisy pair (w.r.t. φ), then at least one of the 1-types π1 or π2 is realized by at most 2Kφ+1 vertices in 𝒢.

Proof.

Recall that Vπ denotes the vertices in V with 1-type π. Because 𝒢φ, for vertex v𝒢, uV{v}𝖳𝗐𝗈𝖳𝗉(v,u)=𝐤φ. We consider two cases.

Suppose that 𝝅𝟏=𝝅𝟐.

Since 𝖳𝗐𝗈𝖳𝗉(v,u)=𝖳𝗐𝗈𝖳𝗉(u,v), we have

vVπ1uVπ1{v}(𝖳𝗐𝗈𝖳𝗉(v,u)+𝖳𝗐𝗈𝖳𝗉(v,u))= 2vVπ1uVπ1{v}𝖳𝗐𝗈𝖳𝗉(v,u)
2vVπ1uV{v}𝖳𝗐𝗈𝖳𝗉(v,u)= 2|Vπ1|𝐤φ.

For every pair of vertices v and u in Vπ1 with vu, by definition of noisy pair, the sum of components of 𝖳𝗐𝗈𝖳𝗉(v,u)+𝖳𝗐𝗈𝖳𝗉(v,u) is at least 1. Therefore, we have

vVπ1uVπ1{v}1=|Vπ1|(|Vπ1|1) 2|Vπ1|Kφ,

which implies that |Vπ1|2Kφ+1.

Suppose that 𝝅𝟏𝝅𝟐.

By a similar argument, |Vπ1||Vπ2|(|Vπ1|+|Vπ2|)Kφ. If |Vπ1|2Kφ+1 we are done. So assume the opposite. Then we have

|Vπ2|Kφ1Kφ|Vπ1|Kφ1Kφ2Kφ+1 2Kφ.

The following straightforward proposition gives conditions that characterize the satisfiability of 𝖢𝟤 by a model in terms of the prior constructs.

Proposition 28.

For every 𝖢𝟤 sentence φ in normal form and σ-structure 𝒢, 𝒢 is a model of φ if and only if following conditions hold. For every v,uV with vu,

  • (1-type) 𝖮𝗇𝖾𝖳𝗉(v)𝖮𝗇𝖾𝖳𝗉𝗌φ,

  • (2-type) 𝖳𝗐𝗈𝖳𝗉(v,u)𝖳𝗐𝗈𝖳𝗉𝗌𝖮𝗇𝖾𝖳𝗉(v),𝖮𝗇𝖾𝖳𝗉(u)φ, and

  • (Counting) uV{v}𝖳𝗐𝗈𝖳𝗉(v,u)=𝐤φ,

where 𝐤φ is the count bound vector of φ.

Definition 29 (Partial model of 𝖢𝟤 sentence).

For every 𝖢𝟤 sentence φ and σ-structure 𝒢, we say that a complete colored graph 𝒢 is a partial model of φ if 𝒢 satisfies the first two conditions in Proposition 28.

The following is obvious.

Lemma 30.

For every 𝖢𝟤 sentence φ in normal form, for every σ-structure 𝒢φ, for every 𝒢, is a partial model of φ.

Core of structures.

Definition 31.

For 𝒢 a σ-structure, , we say that substructure 𝒢 is an -core of 𝒢 if

  • for every 1-type π, the number of vertices in 𝒢 with 1-type π is either 0 or at least

  • for 1-types π1, π2, and 2-type η, there are either 0 and at least pairs of vertices v,u𝒢 satisfying that vu, 𝖮𝗇𝖾𝖳𝗉(v)=π1, 𝖳𝗐𝗈𝖳𝗉(v,u)=η, and 𝖮𝗇𝖾𝖳𝗉(u)=π2.

Note that the core of 𝒢 is not unique, and 𝒢 is trivially a core of itself for every . Therefore, we are interested in the existence of a small core of 𝒢. We can show that for every , every σ-structure has an exponential-size core.

Lemma 32.

For every σ-structure 𝒢, for every , 𝒢 has an -core with size at most (22n+4m+2).

The intuition behind the construction is to repeatedly select a 1-type or tuple that violates the -core condition and add the relevant vertices to . Since there are only finitely many such choices, the process eventually stabilizes, and the size of the constructed core remains bounded: see the appendix for details.

For a 𝖢𝟤 sentence φ and a σ-structure 𝒢φ, if is a -core of 𝒢 with sufficiently large , then we have the following important property of 𝒢:

Lemma 33.

For every 𝖢𝟤 sentence φ and σ-structure 𝒢φ, for every -core 𝒢 with >2Kφ+1, the 1-types realized in 𝒢 are silent-compatible (w.r.t. φ).

Proof.

Suppose that there exist 1-types π1 and π2 realized in 𝒢 which are not silent-compatible. By Lemma 27, at least one of the 1-types π1 or π2 is realized by at most 2Kφ+1 vertices in 𝒢. Without loss of generality, suppose that π1 is realized by at most 2Kφ+1 vertices in 𝒢, then there are at most 2Kφ+1< vertices in 𝒢 realized π1. However, by the definition of -core, since π1 is realized in 𝒢, it is realized by at least vertices in 𝒢. This leads to a contradiction.

In Section 4, we introduced the notion of behavior vectors to describe the number of edges connected to a given vertex with specific 2-types. In this section, we consider σ-structures with a fixed core and extend the concept of behavior vectors to incorporate information about the core. Again, we fix an ordering of the set 𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌, which has cardinality 2n+3m2n+m.

Definition 34 (Extended behavior).

Fixing a vocabulary σ, an extended behavior w.r.t. a set of vertices V is a tuple g,𝐟 where g is a mapping from a vertex vV to a 2-type in 𝖳𝗐𝗈𝖳𝗉𝗌, and 𝐟 is an element of 2n+3m2n+m.

Informally, each extended behavior consists of two components. The first one is a mapping from vertices in the core to 2-types, capturing the 2-type realized by the edge between a given vertex and core vertices. The second component is a behavior vector.

Abusing notation, for an extended behavior g,𝐟, we will write g(v) for (g(v)) and g~(v) for the dual of g(v). We will also write 𝐟(η,π) for the ith component of 𝐟, where i is the index of the tuple η,π in the fixed ordering of 𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌.

Definition 35 (Compatibility of extended behaviors).

For a 𝖢𝟤 sentence φ in normal form, π𝖮𝗇𝖾𝖳𝗉𝗌φ, and a σ-structure with vertices V, we say that an extended behavior function g,𝐟 w.r.t. V is compatible with φ, π, and if f satisfies:

  1. 1.

    (Compatibility with ) For every vV, g(v)𝖳𝗐𝗈𝖳𝗉𝗌π,𝖮𝗇𝖾𝖳𝗉(v)φ.

  2. 2.

    (Compatibility with 1- and 2- types) For every η,π𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌, if π𝖮𝗇𝖾𝖳𝗉𝗌φ or η𝖳𝗐𝗈𝖳𝗉𝗌π,πφ, then 𝐟(η,π)=0.

  3. 3.

    (Forward-silent zero) For every η,π𝖳𝗐𝗈𝖳𝗉𝗌+×𝖮𝗇𝖾𝖳𝗉𝗌, if η is forward-silent, then 𝐟(η,π)=0.

  4. 4.

    (Counting) The remaining entries of 𝐟, that is, entries for 2-types that are not forward-silent, are bounded by the following constraint:

    vVg(v)+π𝖮𝗇𝖾𝖳𝗉𝗌φ(η𝖳𝗐𝗈𝖳𝗉𝗌π,πφ,𝐟(η,π)η+η𝖳𝗐𝗈𝖳𝗉𝗌π,πφ,𝐟(η,π)η)=𝐤φ.

    Note that this condition implies that if π and η are compatible with φ, and η is not forward-silent, then 𝐟(η,π) is bounded by Kφ.

Note that given an extended behavior, we can check whether it is compatible with π and in time polynomial in 2n and |V|. Let π,φ be the set of extended behaviors w.r.t. the vertices of that are compatible with φ, π and . For each g,𝐟π,φ, recall that every entry of 𝐟 is bounded by |Kφ|. Thus the cardinality of π,φ is bounded by |V||𝖳𝗐𝗈𝖳𝗉𝗌||Kφ||𝖳𝗐𝗈𝖳𝗉𝗌×𝖮𝗇𝖾𝖳𝗉𝗌| which is doubly exponential in the length of φ.

Computing a semilinear representation of the spectrum of a 𝗖𝟮 sentence.

We are now ready to show that the 1-type spectrum of a 𝖢𝟤 sentence φ in normal form is semilinear. For every finite model 𝒢 of φ, by Lemma 27, for sufficiently large , for every -core of 𝒢 and pair of 1-types π1 and π2 in 𝒢, π1 and π2 are silent-compatible w.r.t. φ. Furthermore by Lemma 32, 𝒢 has an -core whose size is exponential in φ and . We prove Theorem 37 via a two-step construction. First we show that for every such core , there exists an existential Presburger formula Ψφ(𝐱) such that the solution set of Ψφ(𝐱) corresponds to the set of 1-type cardinality vectors of finite models of φ with -core .

  • The variables are xπ for π𝖮𝗇𝖾𝖳𝗉𝗌φ, and yπ,g,𝐟 for π𝖮𝗇𝖾𝖳𝗉𝗌φ and g,𝐟π,φ. Intuitively, 𝐱 is the 1-type spectrum of the finite model 𝒢 and yπ,g,𝐟 is the number of vertices in 𝒢 with 1-type π and extended behavior g,𝐟.

  • The formula 𝖲𝖴𝖬(𝐱,𝐲) asserts that the 1-type spectrum of 𝒢 is the sum of the 1-type spectrum of and the 1-type spectrum of 𝒢. Let sπ be the number of vertices in with 1-type π.

    𝖲𝖴𝖬(𝐱,𝐲):=π𝖮𝗇𝖾𝖳𝗉𝗌φ(xπ=sπ+g,𝐟π,φyπ,g,𝐟).

  • The formula 𝖢𝖮𝖬𝖯(𝐲) guarantees that the vertices in satisfies the Counting condition of Proposition 28. Let Vc be the vertices in .

    𝖢𝖮𝖬𝖯(𝐲):=vVc(uVc{v}𝖳𝗐𝗈𝖳𝗉(v,u)+π𝖮𝗇𝖾𝖳𝗉𝗌φg,𝐟π,φg(v)yπ,g,𝐟=𝐤φ).

  • The formula 𝖲𝖨𝖫𝖤𝖭𝖳(𝐲) assert that 1-types realized in 𝒢 are silent compatible.

    𝖲𝖨𝖫𝖤𝖭𝖳(𝐲):=π1,π2𝖮𝗇𝖾𝖳𝗉𝗌φare not silent compatible(g,𝐟π1,φyπ1,g,𝐟=0)(g,𝐟π2,φyπ2,g,𝐟=0).

  • The formula 𝖡𝖨𝖦(𝐲) guarantees that 1-types and tuples realized in 𝒢 satisfy the requirements of a core.

    𝖡𝖨𝖦(𝐲):=π𝖮𝗇𝖾𝖳𝗉𝗌φz(z=g,𝐟π,φyπ,g,𝐟)(z=0z(2Kφ+1)2)π1,π2𝖮𝗇𝖾𝖳𝗉𝗌φη𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ,z(z=g,𝐟π1,φ𝐟(η,π2)yπ1,g,𝐟)(z=0z(2Kφ+1)2).

  • The formula 𝖬𝖠𝖳𝖢𝖧1,(𝐲) encodes the edge matching condition for audible 2-types and vertices in 𝒢.

    𝖬𝖠𝖳𝖢𝖧1,(𝐲):=π1,π2𝖮𝗇𝖾𝖳𝗉𝗌φη𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ,(g,𝐟π1,φ𝐟(η,π2)yπ1,g,𝐟=g,𝐟π2,φ𝐟(η~,π1)yπ2,g,𝐟).

  • The formula 𝖬𝖠𝖳𝖢𝖧2,(𝐲) encodes the edge matching condition for backward-silent but not forward-silent 2-types and vertices in 𝒢.

    𝖬𝖠𝖳𝖢𝖧2,(𝐲):=π1,π2𝖮𝗇𝖾𝖳𝗉𝗌φη𝖳𝗐𝗈𝖳𝗉𝗌π1,π2φ,((g,𝐟π1,φ𝐟(η,π2)yπ1,g,𝐟>0)(g,𝐟π2,φyπ2,g,𝐟>0)).

    Keep in mind that we will always be considering solutions in the natural numbers. So this implication could be rewritten without summation: if for one of the extended behaviors for this triple, 𝐟(η,π2)yπ1,g,𝐟>0, then one of the numbers yπ2,g,𝐟>0.

Finally, Ψφ(𝐱):=𝐲𝖲𝖴𝖬(𝐱,𝐲)𝖢𝖮𝖬𝖯(𝐲)𝖲𝖨𝖫𝖤𝖭𝖳(𝐲)𝖡𝖨𝖦(𝐲)i=1,2𝖬𝖠𝖳𝖢𝖧i,(𝐲).

This system characterizes the spectrum:

Lemma 36.

For every 𝖢𝟤 sentence φ and partial model of φ, a vector 𝐯 is a solution of Ψφ(𝐱) if and only if there exists a finite model 𝒢 of φ such that the 1-type cardinality vector of 𝒢 is 𝐯, and is a (2Kφ+1)2-core of 𝒢.

It is easy to see that vectors in the spectrum satisfy the equations. In the other direction, we extend the core to a finite model 𝒢 of φ. Solutions to the equations tell us how many vertices of each 1-type and extended behavior to create in 𝒢. We assign edge colors so that each vertex realizes its intended extended behavior. This is always possible because the solution is sufficiently large, as ensured by the Big condition in the equation. This extra size gives us some leeway to match up 1-types via 2-types. Details are in the appendix.

Let be the collection of partial models of φ with size at most 22n+4m+2(2Kφ+1)2. We define the existential Presburger formula Ψφ(𝐱):=Ψφ(𝐲).

Lemma 37.

For every 𝖢𝟤 sentence φ, Ψφ(𝐱)=Π-𝖲𝖯𝖤𝖢(φ).

Proof.

Suppose that 𝐯Ψφ(𝐱), there exists such that 𝐯Ψφ(𝐱). By Lemma 36, there exists a model 𝒢 of φ such that the 1-type cardinality vector of 𝒢 is 𝐯. Thus 𝐯Π-𝖲𝖯𝖤𝖢(φ). On the other hand, suppose that 𝐯Π-𝖲𝖯𝖤𝖢(φ). Then there is a model 𝒢 of φ with 1-type cardinality vector 𝐯. By Lemma 32, 𝒢 has a (2Kφ+1)2-core with size at most 22n+4m+2(2Kφ+1)2, which implies that . By Lemma 36, 𝐯Ψφ(𝐱). Since , 𝐯Ψφ(𝐱).

Theorem 25 follows immediately from Lemma 37.

Note that the length of the formula Ψφ(𝐱) is doubly exponential in the length of φ, since the length of Ψφ(𝐱) is already doubly exponential in the length of φ, as the number of variables yπ,g,𝐟 is doubly exponential. Moreover, there are doubly exponentially many possible cores .

Consequences for finite satisfiability of 𝗖𝟮 with global constraints.

Note that in Lemma 37, we show that for every 𝖢𝟤 sentence φ in normal form, there exists an existential Presburger formula Ψφ(𝐱) of doubly exponential size such that Π-𝖲𝖯𝖤𝖢φ=Ψφ(𝐱). Since for every 1-type π and partial model of φ, we can compute π,φ in doubly exponential time in the length of φ and by a straightforward enumerate-and-check procedure, Ψφ(𝐱) can be computed from φ in doubly exponential time. Note that global constraints of 𝖢𝟤 sentences are linear constraints over the 1-type cardinality vector. Therefore the finite satisfiability problem of 𝖢𝟤 with global constraints reduces to satisfiability problem of Ψφ(𝐱) together with those linear constraints. This naive approach yields a 2-𝖭𝖤𝖷𝖯 algorithm.

We observe that Ψφ(𝐱) can be rewritten as disjunctions of doubly exponentially many integer linear systems. Each system contains doubly exponentially many variables, but only exponentially many constraints. By Lemma 1, if such a system has a solution, then there exists a solution in which only exponentially many variables are assigned non-zero values.

Therefore, we can decide the finite satisfiability of 𝖢𝟤 with global constraints using the 𝖭𝖤𝖷𝖯 procedure in Algorithm 1.

Algorithm 1 Algorithm for the finite satisfiability problem of 𝖢𝟤 with global constraints.

We emphasize again that the argument here is completely generic, and the same comment holds to show that for any decidability extension of Presburger arithmetic (e.g. Büchi Arithemetic or Semenov Arithmetic [19]), 𝖢𝟤 with global cardinality constraints of that form is decidable, with the complexity the maximum of 𝖭𝖤𝖷𝖯 and the complexity of solving the corresponding constraints.

6 Negative results about the spectrum of 𝗚𝗣𝟮 sentences

The 1-type spectrum of a 𝖢𝟤 sentence is semilinear, and we showed how to calculate it in the previous section. For 𝖦𝖯𝟤, earlier in the paper we were able to characterize models by a linear system: but the solutions to this linear system are not in one-to-one correspondence with the number of satisfiers of 1-types. Thus a natural question is whether the 1-type spectrum of a 𝖦𝖯𝟤 sentence is semilinear. We answer this below in the negative.

Consider the following 𝖦𝖯𝟤 formula φ over vocabulary {P1,P2,E}:

φ:= x((¬P1(x)P2(x))(P1(x)¬P2(x)))1i2xPi(x)γi(x)
γ1(x):= #y[E(x,y)P1(y)]#y[E(x,y)P2(y)]=0
γ2(x):= #y[E(y,x)P1(y)]=1.

Let 𝒢 be a finite model of φ. A vertex in 𝒢 is labeled with either P1 or P2. Let Vi be the set of vertices in 𝒢 with label Pi. For every vV1, the number of edges from v to V1 is the same as the number of edges from v to V2. For every vertex vV2, there exists exactly one edge from V1 to v. Therefore the cardinality of V2 is the same as the number of edges between vertices of V1, which is bounded by |V1|(|V1|1). Thus the 1-type spectrum of φ is {(0,a,b,0)4|ba(a1)}. Hence we have the following negative result.

Theorem 38.

The 1-type spectrum of a 𝖦𝖯𝟤 sentence is not always semilinear.

This does not resolve whether the set of cardinalities of finite models is a semilinear set, and it leaves open whether 𝖦𝖯𝟤 with global cardinality constraints is decidable.

7 Related work

The logic 𝖦𝖯𝟤 was shown decidable in [4, 12], while the decidability of 𝖢𝟤 with cardinality constraints is implicit in [11, 5]. Our complexity bound for 𝖦𝖯𝟤 refines the analysis of the Kleene star operator in [6], which in turn relies on [8]. Our analysis of 𝖢𝟤 with constraints obviously relies heavily on the techniques developed by Pratt-Hartmann for analysis of 𝖢𝟤, in particular normal forms, the categorization of types, and the distinction between large and small number of realizers (e.g. the notion of Z-differentiated [15, 16]).

Although we borrow techniques from prior work, our approach gives a self-contained proof of decidability for 𝖢𝟤 itself, and also for 𝖢𝟤 with global constraints in extensions of Presburger arithmetic. An alternative approach to get bounds for 𝖢𝟤 with Presburger global constraints is by reducing to decidability of 𝖢𝟤. This approach was presented by Rudolph in [18], relying on ideas from [1]. Although technically speaking the results in [18] are presented for description logics, they could easily be applied to give the same bounds for 𝖢𝟤.

In addition to contributing tight bounds for complexity for decidability of 𝖦𝖯𝟤 a well as the size of the spectrum for 𝖢𝟤, we note that [6] is phrased in terms of graph neural networks, while from the analysis of spectra in [11, 5] it would be difficult to see how semilinear representations are derived. Thus we believe our work additionally makes the analyses of logics with arithmetic substantially more accessible.

8 Conclusion

In the paper we isolate the complexity of satisfiability for two logics combining relational structure and arithmetic, 𝖦𝖯𝟤 and the logics 𝖢𝟤 and 𝖦𝖢𝟤 extended with cardinality constraints. In the process we refine and simplify proof techniques for analyzing such logics. 𝖦𝖯𝟤 and 𝖢𝟤 are incomparable in expressiveness. The former allows inductively forming open formulas that involve arithmetic between counts of neighbors, while in the latter arithmetic can only be used at top-level for forming sentences. On the other hand, 𝖢𝟤 allows unguarded formulas. See the appendix for a formal argument. We leave open the question of the decidability of combinations of formulas in the two languages.

References

  • [1] Franz Baader. Expressive cardinality restrictions on concepts in a description logic with expressive number restrictions. SIGAPP Appl. Comput. Rev., 19(3), 2019.
  • [2] Bartosz Bednarczyk. One-variable logic meets presburger arithmetic. Theoretical Computer Science, 802:141–146, 2020. doi:10.1016/J.TCS.2019.09.028.
  • [3] Bartosz Bednarczyk and Oskar Fiuk. Presburger büchi tree automata with applications to logics with expressive counting. In Logic, Language, Information, and Computation, pages 295–308, Cham, 2022. Springer International Publishing. doi:10.1007/978-3-031-15298-6_19.
  • [4] Bartosz Bednarczyk, Maja Orlowska, Anna Pacanowska, and Tony Tan. On classical decidable logics extended with percentage quantifiers and arithmetics. In FSTTCS, 2021.
  • [5] Michael Benedikt, Egor Kostylev, and Tony Tan. Two Variable Logic with Ultimately Periodic Counting. SIAM Journal on Computing, 53(4):884–968, 2024. doi:10.1137/22M1504792.
  • [6] Michael Benedikt, Chia-Hsuan Liu, Boris Motik, and Tony Tan. Verification of graph neural networks via logical characterizations. In ICALP, 2024.
  • [7] Friedrich Eisenbrand and Gennady Shmonin. Carathéodory bounds for integer cones. Oper. Res. Lett., 34(5):564–568, 2006. doi:10.1016/J.ORL.2005.09.008.
  • [8] Christoph Haase and Georg Zetzsche. Presburger arithmetic with stars, rational subsets of graph groups, and nested zero tests. In LICS, 2019.
  • [9] Narendra Karmarkar. A new polynomial-time algorithm for linear programming. In STOC, 1984.
  • [10] Yevgeny Kazakov. A polynomial translation from the two-variable guarded fragment with number restrictions to the guarded fragment. In JELIA, 2004.
  • [11] Eryk Kopczynski and Tony Tan. Regular graphs and the spectra of two-variable logic with counting. SIAM J. Comput., 44(3):786–818, 2015. doi:10.1137/130943625.
  • [12] Chia-Hsuan Lu and Tony Tan. On two-variable guarded fragment logic with expressive local Presburger constraints. Logical Methods in Computer Science, 20, 2024. doi:10.46298/LMCS-20(3:16)2024.
  • [13] Christos H. Papadimitriou. On the complexity of integer programming. J. ACM, 28(4):765–768, 1981. doi:10.1145/322276.322287.
  • [14] Rohit Parikh. On Context-Free Languages. JACM, 13(4):570–581, 1966. doi:10.1145/321356.321364.
  • [15] Ian Pratt-Hartmann. Complexity of the two-variable fragment with counting quantifiers. Journal of Logic Language and Information, 14:369–395, 2005. doi:10.1007/S10849-005-5791-1.
  • [16] Ian Pratt-Hartmann. Complexity of the guarded two-variable fragment with counting quantifiers. Journal of Logic and Computation, 17(1):133–155, 2007. doi:10.1093/LOGCOM/EXL034.
  • [17] Ian Pratt-Hartmann. The two-variable fragment with counting. In WoLLIC, 2010.
  • [18] "Johann" Sebastian Rudolph. Presburger concept cardinality constraints in very expressive description logics - allegro sexagenarioso ma non ritardando. In Description Logic, Theory Combination, and All That - Essays Dedicated to Franz Baader on the Occasion of His 60th Birthday, 2019. doi:10.1007/978-3-030-22102-7_25.
  • [19] Aleksei L. Semenov. Logical theories of one-place functions on the set of natural numbers. Math. USSR Izv., 22(3):587–618, 1984.
  • [20] Boris Trakhtenbrot. The Impossibility of an Algorithm for the Decidability Problem on Finite Classes. Proceedings of the USSR Academy of Sciences, 70(4):569–572, 1950.