Abstract 1 Introduction 2 Preliminaries 3 Hereditary model checking and CSPs 4 Hereditary model checking and quantifier prefixes 5 Undecidability of the tractability problem 6 Conclusion and Open Problems References Appendix A Examples Appendix B Comparison of complexity classifications Appendix C Two missing proofs

Hereditary First-Order Logic:
the Tractable Quantifier Prefix Classes

Manuel Bodirsky ORCID Institut für Algebra, TU Dresden, Germany Santiago Guzmán-Pro ORCID Institut für Algebra, TU Dresden, Germany
Abstract

Many computational problems can be modelled as the class of all finite structures 𝔸 that satisfy a fixed first-order sentence ϕ hereditarily, i.e., we require that every (induced) substructure of 𝔸 satisfies ϕ. We call the corresponding computational problem the hereditary model checking problem for ϕ, and denote it by Her(ϕ).

We present a complete description of the quantifier prefixes for ϕ such that Her(ϕ) is in P; we show that for every other quantifier prefix there exists a formula ϕ with this prefix such that Her(ϕ) is coNP-complete. Specifically, we show that if Q is of the form or of the form , then Her(ϕ) can be solved in polynomial time whenever the quantifier prefix of ϕ is Q. Otherwise, Q contains or as a subword, and in this case, there is a first-order formula ϕ whose quantifier prefix is Q and Her(ϕ) is coNP-complete. Moreover, we show that there is no algorithm that decides for a given first-order formula ϕ whether Her(ϕ) is in P (unless P=NP).

Keywords and phrases:
Quantifier prefix, first-order Logic, Computational Complexity, Polynomial-time algorithm, coNP-completeness
Copyright and License:
[Uncaptioned image] © Manuel Bodirsky and Santiago Guzmán-Pro; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Complexity theory and logic
Related Version:
Full Version: https://arxiv.org/abs/2411.10860 [3]
Acknowledgements:
This is a low-co2 research paper: https://tcs4f.org/low-co2-v1. This research was developed, written, submitted and presented without the use of air travel.
Funding:
Both authors have been funded by the European Research Council (Project POCOCOP, ERC Synergy Grant 101071674). Views and opinions expressed are however those of the authors only and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them.
Editors:
Stefano Guerrini and Barbara König

1 Introduction

Vertex-deletion problems were first studied as optimization problems [17, 18]: Given an input graph 𝔾 determine the minimum number of vertices to be deleted so that the remaining (induced) subgraph belongs to a specified class 𝒞. Krishnamoorthy and Deo [17] showed that this problem is NP-hard for several natural graph classes 𝒞 such as trees, planar, bipartite, hamiltonian, interval, and chordal graphs. Shortly after, Lewis and Yanakkakis [18] proved that if 𝒞 is a non-trivial hereditary class of finite graphs (i.e., 𝒞 is an infinite class of finite graphs which is closed under induced subgraphs and which is not the class of all finite graphs), then the vertex-deletion problem defined by 𝒞 is NP-hard.

Given the previous hardness results, it was natural to study vertex-deletion problems from the viewpoint of approximation or of parametrized complexity. Regarding the former, Fujito [13] proposed a unified polynomial-time algorithm that approximates an optimal solution to a vertex-deletion problem defined by a non-trivial hereditary class. Some well-known results include the fixed parameter tractability of the odd-cycle transversal problem [21], and of the feedback vertex set problem [20] – the former corresponds to the vertex-deletion problem for bipartite graphs, and the latter to the vertex-deletion problem for forests.

Recently, the parametrized complexity perspective has been studied systematically for vertex-deletion problems defined by graph classes expressible by some first-order sentence ϕ [1, 12]. In this paper we are interested in the class of graphs 𝔾 such that no matter how many vertices are removed from 𝔾, the remaining induced subgraph does not satisfy ϕ. Since first-order logic is closed under negations, we prefer the positive phrasing of this problem: Given a graph 𝔾, test whether all non-empty induced subgraphs of 𝔾 satisfy a specified first-order formula ψ.

Hereditary first-order logic

From now on we work in the setting of relational structures, for which graphs and digraphs are prototypical examples. We use the convention that all structures have a non-empty domain. We begin by introducing hereditary first-order logic. A structure 𝔸 hereditarily satisfies ϕ if every substructure111Some authors use the term “induced substructure”; we follow the convention in model theory and omit the adjective ‘induced . 𝔹 of 𝔸 satisfies ϕ. We denote by Her(ϕ) the class of finite structures that hereditarily satisfy ϕ. The hereditary model checking problem for a fixed sentence ϕ consists of deciding whether an input structure 𝔸 belongs to Her(ϕ). Since verifying whether a finite structure 𝔸 models a fixed first-order formula ϕ can be done in polynomial time, it follows that Her(ϕ) is in coNP.

We say that a class 𝒞 of finite τ-structures is hereditarily first-order definable if there is a first-order sentence ϕ such that 𝒞=Her(ϕ). In this case, we also say that 𝒞 is in HerFO. Clearly, every class in HerFO is hereditary, i.e., closed under taking substructures.

Three simple examples

Clearly, every hereditary class in FO is also in HerFO. The following graph and digraph classes are in HerFO, but not in FO.

Example 1 (Forests).

Consider a first-order formula ϕ stating that “there is a loopless vertex of degree at most 1”. Clearly, every forest hereditarily satisfies ϕ. Conversely, suppose that 𝔾 is a finite graph that hereditarily satisfies ϕ. Then 𝔾 has a loopless vertex v of degree at most 1. We inductively see that the subgraph with vertex set (G{v}) is a forest, i.e., has no cycles, and since v has degree at most 1 and does not have a loop, we conclude that 𝔾 is a forest.222This example naturally generalizes to k-degenerate graphs, i.e., the class of graphs 𝔾 such that every subgraph of 𝔾 contains a vertex of degree at most k.

Example 2 (Chordal graphs).

A graph 𝔾 is chordal if every cycle of 𝔾 contains a chord; equivalently, if 𝔾 contains no induced cycle of length n4. Rose [22] proved that a graph 𝔾 is chordal if and only if every induced subgraph contains a vertex whose neighbourhood induces a clique. Hence, if ϕ is a first-order sentence stating “there is a (loopless) vertex v such that every two neighbours of v are adjacent”, then Her(ϕ) describes the class of chordal graphs. It is known that membership in this class can be decided in polynomial time [23].

Example 3 (Directed acyclic digraphs).

The class of acyclic digraphs belongs to HerFO as well. Indeed, it suffices to consider the first-order sentence xy.¬E(x,y), i.e., the first order sentence that states that there exists a sink, i.e., a vertex without outgoing edges. Equivalently, the constraint satisfaction problem for (,<) (denoted by CSP(,<), see Section 2) is in HerFO. Also this computational problem can be solved in polynomial time (e.g., by depth-first-search).

We are interested in the expressive power of hereditary first-order logic, as well as complexity classification for the hereditary model checking problem. Regarding the former, we will see that HerFO is a particularly natural formalism when it comes to the description of constraint satisfaction problems (for the definition of CSPs, see Section 2). Regarding the latter, we will study complexity classifications based on the quantifier prefix of the fixed first-order sentence ϕ. This is motivated by similar classifications for universal and existential second-order logic [9, 14], which we now review.

Prefix classifications

It is straightforward to observe that Her(ϕ) can be expressed in universal monadic second-order logic.

Observation 4.

Consider a first-order τ-formula ϕ:=Q1x1Qnxn.ψ(x1,,xn) and a finite structure 𝔸. If S is a unary predicate not in τ, then 𝔸 hereditarily satisfies ϕ if and only if 𝔸 models

SQ1x1Qnxn(z.S(z)iUS(xi)iES(xi)ψ(x1,,xn)),

where U (respectively, E) is the set of indices i{1,,n} such that Qi is a universal (respectively, existential) quantifier.

The question whether a given existential second-order (ESO) sentence describes a polynomial-time solvable problem is easily seen to be undecidable (see, e.g., Theorem 1.4.2 in [2]). This motivates quantifier-prefix dichotomy results for existential second-order logic [9, 14]. For instance, the classification for monadic ESO is as follows [14, Figure 1(a)]. For every quantifier prefix Q{,} the following holds:

  • either Q is of the form , and in this case every monadic ESO sentence Φ whose first-order part has a quantifier-free prefix Q is polynomial-time decidable, or

  • Q contains or as subwords, and in this case there is an ESO sentence Φ whose first-order part has quantifier prefix Q and deciding Φ is NP-complete.

It follows from this classification, via Observation 4, that Her(ϕ) is in P whenever ϕ is a first-order sentence with a quantifier prefix of the form . However, as we will soon see, HerFO enjoys a richer polynomial-time solvable fragment.

Our contributions

We first study the expressive power of HerFO in the context of CSPs. We see that HerFO can express finite-domain CSPs note expressible in first-order logic (Example 25), that it can express coNP-complete infinite-domain CSPs (Theorem 8), and that every CSP expressible in HerFO is the CSP of an ω-categorical structure (Remark 6). We then turn to computational aspects of the hereditary model checking problem for fixed sentences ϕ. In particular, we show that if the signature of ϕ is monadic, then Her(ϕ) is solvable in polynomial-time (Proposition 11).

Our first main results are two classifications of the computational complexity of problems in HerFO. The first one concerns sentences with at least one binary predicate (Theorem 20), and the second one concerns sentences ϕ such that Her(ϕ) describes a CSP (Corollary 21). These classifications coincide, and are based on the quantifier prefix Q{,} of the fixed first-order formula:

  • either Q is of the form or the form , and in this case Her(ϕ) is polynomial-time decidable for every first-order formula ϕ with quantifier prefix Q, or

  • Q contains or as a subword, and in this case there are first-order sentences with quantifier prefix Q such that Her(ϕ) is coNP-complete.

Our final main result shows that more fine-grained classifications of the complexity are undecidable: there is no algorithm that tests for a given first-order sentence ϕ whether Her(ϕ) can be solved in polynomial time (Theorem 23). Moreover, we show that this is also the case even if ϕ is restricted to having quantifier-prefix Q= or Q= (Corollary 24). We leave open the decidability of this meta-problem for first-order sentences ϕ with quantifier prefix .

Outline

We begin by recalling some basic concepts from finite model theory (Section 2). We then list further examples of problems in HerFO, and prove that certain problems cannot be expressed in HerFO (Section 3); it will also become clear why hereditary model checking is quite natural in the context of constraint satisfaction. The classifications of the complexity of HerFO depending on the allowed quantifier prefix are the main results of Section 4. The undecidability of tractability of HerFO can be found in Section 5. A series of problems that are left open can be found in Section 6. In Appendix B we present a comparison between our complexity classifications, the complexity landscape for the parametrized version of HerFO from [12], and the general model checking problem for UMSO from [14].

2 Preliminaries

We assume basic familiarity with first-order logic and we follow standard notation from model theory, as, e.g., in [15]. We also use standard notions from complexity theory.

(First-order) structures

Given a relational signature τ and a τ-structure 𝔸, we denote by R𝔸 the interpretation in 𝔸 of a relation symbol Rτ. Also, we denote relational structures with letters 𝔸,𝔹,,, and their domains by A,B,C,. In this article, structures have non-empty domains, and we only work with finite signatures τ.

If 𝔸 and 𝔹 are τ-structures, then a homomorphism from 𝔸 to 𝔹 is a map f:AB such that for all a1,,akA and Rτ of arity k, if (a1,,ak)R𝔸, then R(f(a1),,f(ak))R𝔹. We write 𝔸𝔹 if there exists a homomorphism from 𝔸 to 𝔹, and we denote by CSP(𝔹) the class of finite structures 𝔸 such that 𝔸𝔹. Let 𝒞 be a class of finite τ-structures. We say that 𝒞 is

  • closed under homomorphisms if for every 𝔹𝒞, if 𝔹𝔸, then 𝔸𝒞 as well.

  • closed under inverse homomorphisms if for every 𝔹𝒞, if 𝔸𝔹, then 𝔸𝒞 as well (i.e., the complement of 𝒞 in the class of all finite τ-structures is closed under homomorphisms).

Note that CSP(𝔹) is closed under inverse homomorphisms.

If 𝔸 and 𝔹 are τ-structures with disjoint domains A and B, respectively, then the disjoint union 𝔸𝔹 is the τ-structure with domain AB and the relation R=R𝔸R𝔹 for every Rτ. Note that CSP(𝔹) is closed under disjoint unions, i.e., if 𝔸CSP(𝔹) and 𝔹CSP(𝔹), then 𝔸𝔹CSP(𝔹). It is well-known that a class of finite τ-structures 𝒞 is of the form CSP(𝔹) for some countably infinite τ-structure 𝔹 if and only if 𝒞 is closed under inverse homomorphisms and disjoint unions (see, e.g., [2, Lemma 1.1.8]).

For examples we will often use graphs and digraphs, and we will think of these as binary structures with signature {E}. We follow and adapt standard notions from graph theory [6] to this setting. In particular, given a digraph 𝔻, we call E𝔻 the edge set of 𝔻, and its elements we call edges. A graph is a digraph whose edge set is a symmetric relation, and an oriented graph is a digraph whose edge set is an anti-symmetric relation. Given a positive integer n, we denote by Kn the complete graph on n vertices, and by Pn the directed path on n vertices. An oriented path is an oriented graph whose symmetric closure is a path.

Fragments of first-order logic

A first-order τ-formula ϕ is called positive if it does not use the negation symbol ¬ (so it just uses the logical symbols ,,,,=, variables and symbols from τ). The negation of a positive formula is called negative; note that every negative formula is equivalent to a formula in prenex conjunctive normal form where every atomic formula appears in negated form, and all negation symbols are in front of atomic formulas; such formulas will also be called negative.

Consider a quantifier-free formula ψ using only variables, the symbols and =, and symbols from τ, and let ψ be the formula obtained from ψ by iteratively removing each equality conjunct x=y and substituting each occurrence of the variable y by the variable x. We now consider the structure ψ whose vertex set is the set of variables appearing in ψ, and the interpretation of Rτ consists of those tuples x¯ such that ψ contains the positive literal R(x¯). We say that a negative first-order sentence ϕ in prenex conjunctive normal form is connected if for every clause φ of the quantifier-free part of ϕ, the structure ¬φ is connected.

3 Hereditary model checking and CSPs

In this section we see that hereditary model checking naturally arises in the context of constraint satisfaction problems. We do so by providing several examples of CSPs in HerFO. We also include inexpressible examples of HerFO which help build intuition about hereditary model checking.

It is well-known that a universal first-order sentence ϕ in conjunctive normal form describes a CSP if ϕ is negative and connected (see, e.g., Theorem 5.6.2 in [2]). The following observation extends this to not necessarily universal sentences.

Observation 5.

The following statements hold for every first-order sentence ϕ in prenex conjunctive normal form.

  • If ϕ is negative, then Her(ϕ) is closed under inverse homomorphisms.

  • If ϕ is negative and connected, then there is a structure 𝕊 such that Her(ϕ)=CSP(𝕊).

Proof.

To prove the first itemized statement, suppose that there is a homomorphism f:𝔸𝔹 and 𝔹Her(ϕ). Let 𝔸 be a substructure of 𝔸. The substructure of 𝔹 with vertex set f[A] models ϕ. Suppose for contradiction that 𝔸 does not satisfy ϕ. Then it would satisfy the sentence ¬ϕ, which is equivalent to a positive sentence. Since surjective homomorphisms preserve positive first-order formulas [15, Theorem 2.4.3], we obtain that 𝔸 satisfies ¬ϕ, a contradiction.

It is straightforward to observe that if ϕ is negative and connected, then the class of finite models of ϕ is closed under disjoint unions. Hence, if every substructure of 𝔸 and every substructure of 𝔹 satisfies ϕ, then every substructure of 𝔸𝔹 satisfies ϕ, i.e., Her(ϕ) is closed under disjoint unions. By the first claim, Her(ϕ) is also closed under inverse homomorphisms, and it thus follows that there is a structure 𝕊 such that CSP(𝕊)=Her(ϕ) – for any class 𝒞 of τ-structures there exists a τ-structure 𝕊 such that 𝒞=CSP(𝕊) if and only if 𝒞 is closed under disjoint unions and inverse homomorphisms [2, Lemma 1.1.8].

 Remark 6.

Every CSP in HerFO is the CSP of an ω-categorical structure (see [2] for the many consequences that the model theoretic property of ω-categoricity has for the study of the complexity of the CSP). This follows from a result in [5, Corollary 14], which states that every CSP in monadic second-order logic (MSO) is the CSP for an ω-categorical structure; clearly, HerFO is a fragment of monadic second-order logic (see, e.g., Observation 4). For a concrete application of this remark see Example 26.

Example 7.

Let τ={EQ,N} be the signature where EQ and N are two binary relational symbols which will encode “equal” and “not equal”, respectively. Note that a τ-structure 𝔸 belongs to CSP(,=,) if and only if the structure obtained from 𝔸 by contracting all connected components of the edge relation EQ𝔸 contains no loop N(x,x). Equivalently, 𝔸CSP(,=,) if and only if N𝔸 contains no loop (x,x) and no contradicting cycle, i.e., vertices x1,,xn such that EQ(x1,xi+1) for all i[n1] and N(x1,xn). Despite the fact that the existence of such a cycle is not a first-order property, the problem CSP(,=,) is in HerFO. For a positive integer k we write dEQ(x)=k for the first-order formula stating “x has exactly k neighbors in the relation EQ (different from x)”, and dEQ(x)k for its negation. Now, consider the formula

ϕ:=x,yz(¬N(x,y)dEQ(x)1dEQ(y)1(dEQ(z)2z{x,y})).

If 𝔸 does not hereditarily model ϕ, then there is a subset {a1,,an} such that N(a1,an) and every ai has degree exactly 2 in the relation EQ except for a1 and an, and so 𝔸 contains a contradicting cycle. Conversely, if 𝔸 has a contradicting cycle one can find a substructure 𝔹 of 𝔸 that does not model ϕ, namely, any shortest contradicting cycle. Therefore, CSP(,=,) is hereditarily defined by the first-order sentence ϕx.¬N(x,x).

Some further examples of polynomial-time solvable CSPs in HerFO include a finite-domain CSP in HerFO but not in FO (Example 25), and an infinite-domain CSP in HerFO but not even in Datalog (Example 27).

Hard examples

Here, we present an example of a coNP-complete CSP in HerFO that we will also use in Corollaries 24 and 21; to see another (possibly better-known) one see the full version of this paper.

Let τ consist of two binary symbols Eb and Er; we think of a τ-structure is a digraph with blue and red edges. For a positive integer n2 we denote by 𝕋𝔻n the structure with vertex set [n] such that ([n],Eb) is a directed cycle 1,,n, and ([n],Er) is a complete (symmetric) graph. Let 𝒯 be the set containing the one-element structure with a red loop, and the one-element structure with a blue loop, and all structures 𝕋𝔻n for n2. Let Forb(𝒯) be the class of finite τ-structures 𝔸 for which there is no homomorphism 𝕋𝔸 for any 𝕋𝒯. Clearly, Forb(𝒯) is closed under inverse homomorphisms. Since all structures in 𝒯 are connected, Forb(𝒯) is also closed under disjoint unions, and hence Forb(𝒯)=CSP(𝔹𝒯) for some τ-structure 𝔹𝒯 (see, e.g., [2, Lemma 1.1.8]).333The reader familiar with Fraïsse limits [16] may notice that 𝔹𝒯 can be chosen to be a countable homogeneous structure, i.e., such that every isomorphism between finite substructures of 𝔹𝒯 can be extended to an automorphism of 𝔹𝒯. We show that CSP(𝔹𝒯) is a coNP-complete CSP in HerFO. Consider the τ-sentence

ϕ𝒯:=x,yz(¬Eb(z,z)¬Er(z,z)(¬Eb(x,z)(xy¬Er(x,y)))).

Clearly, no loop satisfies ϕ𝒯. We now show that no structure 𝕋𝔻n, for n2, satisfies ϕ𝒯. Consider a pair of vertices x,yTDn. Firstly, there is some z such that (x,z)Eb𝕋𝔻n, because the blue edges define a directed cycle in 𝕋𝔻n. Secondly, if xy, then (x,y)Er𝕋𝔻n because the red edges induce a red clique. Hence, 𝕋𝔻n does not satisfy the last conjunct of ϕ𝒯. Also, since ϕ𝒯 is negative and connected, it follows by Observation 5 that if 𝔽𝔸 for some structure 𝔽𝒯, then 𝔸 does not hereditarily satisfy ϕ𝒯. On the other hand, observe that if a τ-structure 𝔸 does not hereditarily satisfy ϕ𝒯, then 𝔸 contains a loop, or there is a subset AA such that (A,Er𝔸) is a complete symmetric graph with at least two vertices, and every vertex xA has a blue out-neighbour. So if 𝔸 contains no loops, then the shortest directed blue cycle in A induces a structure isomorphic to 𝕋𝔻n for some n2. Therefore, Her(ϕ𝒯)=Forb(𝒯)=CSP(𝔹𝒯).

Theorem 8.

Forb(𝒯) is a coNP-complete CSP hereditarily definable by an - and by an -sentence.

Proof.

It is easy to see that ϕ𝒯 is equivalent to the sentence ϕ𝒯 obtained from ϕ𝒯 by changing the prefix x,yz to xzy. Hence, it follows from the discussion above that Forb(𝒯) is hereditarily definable by an - and by an -sentence. We now show that Forb(𝒯) is coNP-complete. Consider an instance ψ of 3SAT with variables V and clauses C1,,Cm, where Ci=(ci1,ci2,ci3) and cik{v,¬v} for some vV. We construct a τ-structure 𝔸 with vertices aij for each i[m] and j[3]. The blue edges of 𝔸 consist of all pairs (aij,ai+1k) and (amj,a1k), for i[m1] and j,k[3]; the red edges of 𝔸 correspond to the relation cik¬cjl with ij, i.e., (aik,ajl)Er𝔸 if and only if the literal cik does not equal the negation of the literal ¬cjl – in particular, Er𝔸 is a symmetric relation without loops.

We claim that ψ is satisfiable if and only if 𝔸Forb(𝒯). Suppose there is a satisfying assignment for ψ, and consider the vertices aiki where ciki is true in the clause Ci. Then the substructure 𝔸 with domain a1k1,,amkm satisfies that every vertex has a blue out-neighbour. Clearly, ciki cannot be the negation of cjkj, so (A,Er𝔸) is a complete red graph. This shows that if ψ is satisfiable, then there is a homomorphism 𝕋𝔻m𝔸.

Conversely, suppose that 𝔸Forb(𝒯). Notice that if there is a substructure 𝔸 of 𝔸 that satisfies that every vertex has a blue out-neighbour, then A contains a vertex aiki for each i[m]. Moreover, if (A,Er𝔸) is a complete graph, then A contains at most one vertex aiki for each i[m]. Then the evaluation f:V{0,1} defined by f(v)=1 if there is some clause Ci such that v=cik and aikA shows that ψ is satisfiable.

Inexpressible examples

In this section we study the limitations of the expressive power of HerFO. Clearly, a class 𝒞 is first-order definable if and only if the complement of 𝒞 is first-order definable. A structure 𝔸 is a minimal obstruction of a hereditary class 𝒞 if 𝔸𝒞 but every proper substructure 𝔸 of 𝔸 belongs to 𝒞. We show that 𝒞HerFO if and only if the complement of 𝒞 contains a first-order definable subclass that contains all minimal obstructions of 𝒞 (Lemma 9).

We then apply this observation to show that the class of bipartite graphs is not in HerFO (Example 10). It is well-known that a graph is bipartite if and only if it does not contain an odd cycle, and that the class of odd cycles cannot be expressed by a first-order formula. However, this is not enough to show that the class of bipartite graphs is not in HerFO: there are properties that are not first-order definable, but the class of all -free structures is in HerFO; see Example 7. To prove that the class of bipartite graphs is not in HerFO, we therefore need the following lemma which we prove in Appendix C.

Lemma 9.

Let 𝒞 be a hereditary class of finite τ-structures and let be the class of minimal obstructions of 𝒞. Then 𝒞 is hereditarily first-order definable if and only if there is a first-order sentence ψ such that

  • if 𝔽, then 𝔽ψ, and

  • if 𝔸 is a finite τ-structure such that 𝔸ψ, then there is an embedding 𝔽𝔸 for some 𝔽.

Building on this simple lemma we can now use standard Ehrenfeucht-Fraïssé arguments to show that certain hereditary classes are not in HerFO. If 𝔸 and 𝔸 are τ-structures, we write 𝔸k𝔸 if 𝔸 and 𝔸 satisfy the same first-order τ-sentences with at most k variables.

Example 10 (Bipartite graphs not in HerFO).

It is well known that the minimal obstructions of the class of bipartite graphs are all odd symmetric cycles and the non-symmetric edge. For every positive integer k, there is a large enough odd cycle and a large enough even cycle such that k (this can be shown by an Ehrenfeucht-Fraïssé argument; see, e.g., [8]). Hence, we conclude via Lemma 9 that the class of bipartite graphs is not in HerFO. Moreover, note that CSP(K2) is the class of bipartite digraphs. So it also follows from the existence of such cycles k and Lemma 9 that CSP(K2) is not in HerFO.

In the appendix we use Lemma 9 to show that CSP(,<,=) is not in HerFO (Example 29). Another method for proving that certain CSPs are not expressible in HerFO is using ω-categoricity and Remark 6. We present an example in the appendix (Example 26).

4 Hereditary model checking and quantifier prefixes

A quantifier prefix is a word Q{,}; we say that a first-order formula ϕ in prenex normal form has quantifier prefix Q if ϕ=Q1x1Qnxn.ψ where Q=Q1Qn and ψ is a quantifier-free formula. In this section we present the following dichotomy for quantifier prefixes: for every quantifier prefix Q{,} either

  • Her(ϕ) is in P for every first-order formula ϕ with quantifier prefix Q, or

  • there exists a first-order formula ϕ with quantifier prefix Q such that Her(ϕ) is coNP-complete.

Moreover, we show that in the former case, Her(ϕ) is expressible by an ESO sentence Ψ whose first-order part is universal.

A relational signature τ is called monadic if all relation symbols in τ are monadic. It is easy to see that every problem in HerFO with a monadic signature is in FO, and so polynomial-time solvable. We postpone its simple proof to Appendix C.

Proposition 11.

Let τ be a finite monadic relational signature. For every first-order formula ϕ the class Her(ϕ) is universally definable and hence in P.

From now on, we only consider the non-monadic case. The key components in the proof of our classification (Theorem 20) are Algorithm 1 (for one of the tractable cases) and the fact that the problem of deciding whether every directed cycle in an input digraph 𝔻 induces a symmetric edge is coNP-complete (Theorem 18) and expressible in HerFO (Lemma 17).

The fragment

In this section we prove that for every -formula ϕ there is a universal formula ϕ such that a structure 𝔸 hereditarily satisfies ϕ if and only if 𝔸ϕ.

Lemma 12.

Let ϕ be a -formula with k universally quantified variables. Then a structure 𝔸 hereditarily models ϕ if and only if every k-element substructure of 𝔸 models ϕ.

Proof.

We prove the non-trivial (but straightforward) implication. Suppose that every substructure 𝔹 of 𝔸 with |B|k models ϕ, and let 𝔸 be a substructure of 𝔸. If |A|k, then 𝔸ϕ; otherwise, for a k-tuple (a1,,ak)(A)k, let b¯ be a tuple such that the quantifier-free part ψ of ϕ is true of (a1,,ak,b¯) in the substructure of 𝔸 with vertex set {a1,,ak}. It follows that 𝔸ψ(a1,,ak,b¯), and since such a b¯ exists for every a¯(A)k, we conclude that 𝔸ϕ, and therefore 𝔸Her(ϕ).

Corollary 13.

If ϕ is a -sentence, then Her(ϕ) is universally definable and hence polynomial-time solvable.

Proof.

If ϕ=x1,,xky1,,yl.ψ where ψ is quantifier-free, let ϕ be the formula

x1,,xky1{x1,,xk},,yl{x1,,xk}.ψ.

By Lemma 12, a structure hereditarily satisfies ϕ if and only if it satisfies ϕ.

The fragment

An SNP τ-sentence (short for strict non-deterministic polynomial-time) is a sentence of the form

R1,,Rkx1,,xn.ψ

where ψ is a quantifier free τ{R1,,Rk}-formula [10, 19]. If a structure 𝔸 satisfies the sentence Ψ, we write 𝔸Ψ. We say that a class of finite τ-structures 𝒞 is in SNP if there exists an SNP τ-sentence Φ such that 𝔸Φ if and only if 𝔸𝒞. We show that if ϕ is a -formula, then Her(ϕ) is in SNP P.

In the following we consider a fixed -formula

ϕ=x1,,xlyxl+1,,xn.ψ(x1,,xl,y,xl+1,,xn)

where ψ is a quantifier-free τ-formula. We expand τ with an (l+2)-ary relation symbol L. We will interpret L as a reflexive linear order with l parameters, i.e., if the first l arguments of L are fixed, then the binary relation defined by the remaining two free variables is a linear order. It is straightforward to observe that there is a universal {L}-formula Lin(x1,,xl) such that Lin is true of an l-tuple a¯ in an {L}-structure 𝔸 if and only if the binary relation L(a¯,x,y) defines a reflexive linear order xa¯y on A. Consider now the SNP sentence defined as follows.

Φ:=Lx1,,xl, y,xl+1,,xn.Lin(x1,,xl)
(i[n]L(x1,,xl,y,xi))ψ(x1,,xl,y,xl+1,,xn).
Lemma 14.

A finite τ-structure 𝔸 hereditarily models ϕ if and only if it models Φ.

Proof.

For the easy direction, suppose that (𝔸,L) models the first-order part of Φ. For all a1,,alA, let bA be the minimum with respect to the linear order a1,,al, i.e., the element bA such that L(a1,,al,b,c) for all cA. In particular, for all al+1,,anA and i[n] the atomic formula L(a1,,al,b,ai) holds in 𝔸, and thus 𝔸ψ(a1,,al,b,al+1,,an). Since the first-order part of Φ is universal, every substructure 𝔹 of 𝔸 also models Φ, and by the previous argument we conclude that 𝔹 models ϕ. Hence, 𝔸 hereditarily models ϕ.

Conversely, suppose that 𝔸 hereditarily satisfies ϕ. For every l-tuple a¯=(a1,,al) of A we define a reflexive linear order a¯ such that the expansion

(𝔸,{(a1,,al,b,c):b(a1,,al)c})

models the first-order part of Φ. We define elements b1,,bm inductively as follows. Let b1A be any element witnessing that 𝔸 satisfies

yxl+1,,xn.ψ(a¯,y,xl+1,,xn).

For l>1, if no bi is a coordinate of a¯ for i<l, choose bl to be any element witnessing that the substructure of 𝔸 with domain A{b1,,bl1} satisfies yxl+1,,xn.ψ(a¯,y,xl+1,,xn) (such a vertex bl exists since 𝔸 hereditarily satisfies ϕ). Otherwise, if some bi equals some coordinate of a¯, then let bl be an arbitrary element of A{b1,,bl1}. We define the linear ordering bia¯bj if and only if ij, and let L:={(a¯,b,c)Al+2:ba¯c}. It follows from the definition of L and of Lin that (𝔸,L)a1,,al.Lin(a1,,al).

Suppose that (𝔸,L) satisfies i[n]L(a1,,al,b,ai) for some a1,,al,b,al+1,,anA. Let b1,,bm be the enumeration of A corresponding to the linear ordering (a1,,al), and suppose that b=bl. Since (𝔸,L)i[n]L(a1,,al,b,ai), i.e., b(a1,,al)ai for every i[n], it must be the case that every ai belongs to A{b1,,bl1}. It thus follows from the definition of bl that the substructure 𝔹 of 𝔸 with vertex set A{b1,,bl1} models ψ(a1,,al,bl,al+1,,an), and thus (𝔸,L)ψ(a1,,al,bl,al+1,,an). This shows that 𝔸 satisfies Φ.

The proof of Lemma 14 suggests a polynomial-time algorithm that on input structure 𝔸 finds parameterized linear orderings proving that 𝔸 hereditarily satisfies ϕ, or finds a substructure 𝔹 of 𝔸 that does not model ϕ (which certifies that 𝔸 does not hereditarily satisfy ϕ). See Figure 1 for an illustration.

Certifying polynomial-time algorithm.

Consider a fixed first-order sentence

ϕ:=x1,,xly.ϕ(x1,,xl,y)

where ϕ is a universal formula.

Algorithm 1 Cert-Her-.
Lemma 15.

For every first-order formula ϕ:=x1,,xly.ϕ(x1,,xl,y) where ϕ is a universal formula xl+1,,xn.ψ for some quantifier-free formula ψ, and for every τ-structure 𝔸 with domain A={a1,,am} the following statements hold.

  • If Algorithm 1 returns a substructure 𝔸 of 𝔸, then 𝔸¬ϕ, and 𝔸Her(ϕ).

  • If Algorithm 1 returns an expansion (𝔸,L) of 𝔸, then (𝔸,L) satisfies the first-order part of Φ, and 𝔸Her(ϕ).

Proof.

To prove the first claim, notice that (by finite induction) at the if statement in the repeat-until loop of the algorithm, the set A contains all entries of a¯. Hence, if the algorithm returns 𝔸, then 𝔸 does not satisfy y.ϕ(a¯,y) and hence 𝔸 does not hereditarily satisfy ϕ. Now we argue that the second itemized statement holds. It is straightforward to observe that a¯ is a reflexive linear order for every a¯Al. Hence, it follows from the definition of L that (𝔸,L)x1,,xl.Lin(x1,,xl). To see that (𝔸,L) models the second conjunct of Φ, let b¯Al, cA, and bl+1,,bnA (so (b¯,c,bl+1,,bn) is an evaluation of the universally quantified variables of Φ in A). Further, suppose that

(𝔸,L)i[n]L(b1,,bl,c,bi);

otherwise the second conjunct in the definition of Φ is vacuously true for the tuple (b1,,bl,c, bl+1,,bn). By the definition of L, this means that cb¯bi for every i[n]. Hence, there is some iteration of the repeat-until loop such that cS. Let Si be the set S and the end of this iteration i of the loop, and S0:=. It follows from the definition of b¯ and the assumption that cb¯bj for each j[n], that if Si=Si1{c}, then ({b1,,bn}Si1)=. Since c was added to S in the i-th iteration, it must be the case that in the i-th iteration the if statement is not true for s:=c, i.e., 𝔸x1,,xl.ϕ(x1,,xl,c). Since {b1,,bn}ASi1, we conclude that in particular 𝔸ϕ(b¯,c) where the universally quantified variables from ϕ are interpreted as (bl+1,,bn). This means that

(𝔸,L)(i[n]L(b1,,bl,c,bi))ψ(b1,,bl,c,bl+1,,bn).

Since this is true for any choice of elements b1,,bn and c in A, we conclude that (𝔸,L) satisfies the first-order part of Φ, and by Lemma 14 we conclude that 𝔸Her(ϕ).

Clearly, Algorithm 1 runs in polynomial time in the representation size of 𝔸. Hence, the following statement is an immediate consequence of Lemma 15.

Theorem 16.

If ϕ is a -sentence, then there is an SNP sentence Φ such that a finite structure 𝔸 satisfies Φ if and only if 𝔸Her(ϕ). Moreover, Φ can be efficiently computed from ϕ, and there is a polynomial-time algorithm that either finds an expansion of 𝔸 proving that 𝔸Φ, or finds a substructure 𝔸 of 𝔸 such that 𝔸¬ϕ.

Note that this theorem covers the first-order sentences that show that Example 1, Example 2, Example 3, and Example 27 are in HerFO, because they are sentences. Hence, the polynomial-time tractability of each of these problems follows from Theorem 16.

Figure 1: Consider a first-order {E}-sentence ϕ that states that E is a symmetric relation, and that for every vertex x there is a vertex y not adjacent to x such that the neighbourhood of y induces a clique. Clearly, ϕ can be chosen to be an formula. On the top, we depict a graph 𝔾 with two distinguished vertices a and b. At the bottom left, we depict the linear order a (from left to right) of 𝔾 obtained via Algorithm 1 (where the linear order between the vertices greater that a can be arbitrary), and that proves that (𝔾,a) hereditarily satisfies ϕ(a,y,z¯). At the bottom right, we depict the partial linear order < and the subgraph (depicted with black vertices) of 𝔾 that Algorithm 1 finds when running the loop for x=b, which proves that (𝔾,b) does not hereditarily satisfy ϕ.

- and 𝟐-sentences

Theorem 8 already provides examples of first-order sentences ϕ and ψ with quantifier prefix and 2 such that Her(ϕ) and Her(ψ) are coNP-complete. Moreover, ϕ and ψ are formulas with a binary signature (with two relation symbols). In this section we provide first-order sentences with the same quantifier prefixes over the signature of digraphs (they only use one binary symbol), which is the final ingredient needed to prove Theorem 20.

Consider the class of digraphs 𝔻 such that for every directed cycle d1,,dn of 𝔻 there exist i,j[n] such that didj is a symmetric edge of 𝔻, i.e., (di,dj),(dj,di)𝔻. In this case, we say that every directed cycle of 𝔻 ‘induces a symmetric edge’.

Lemma 17.

Every directed cycle of a finite digraph 𝔻 induces a symmetric edge if and only if 𝔻 hereditarily satisfies the sentence

x,ya(¬E(x,a)[E(x,y)E(y,x)]). (1)
Proof.

Suppose there is a directed cycle d1,,dn of 𝔻 that does not induce a symmetric edge. Then the substructure of 𝔻 with vertex set {d1,,dn} satisfies the formula

x,ya(E(x,a)[¬E(x,y)¬E(y,x)]),

and so 𝔻 does not hereditarily satisfy (1).

Conversely, suppose that every directed cycle of 𝔻 induces a symmetric edge and let BD. If 𝔹 contains a sink b, then 𝔹a¬E(b,a), and so 𝔹 satisfies (1). Otherwise, 𝔹 contains a directed cycle, and by assumption this directed cycle induces a symmetric edge uv, so by letting x=u and y=v we conclude that 𝔹 satisfies x,y(E(x,y)E(y,x)). Again, 𝔹 satisfies (1).

Now, we prove that deciding whether every directed cycle of an input digraph 𝔻 induces a symmetric edge is coNP-complete.

Theorem 18.

The problem of deciding whether every directed cycle in an input digraph 𝔻 induces a symmetric edge is coNP-complete.

Proof.

Let 𝒞 be the class of digraphs described in this theorem, i.e., the class of all finite digraphs such that every directed cycle induces a symmetric edge. Fix 𝕏 to be a no-instance to this class, e.g., 𝕏=3. We reduce from the coNP-hard CSP in Theorem 8 (deciding membership in Forb(𝒯)) to deciding membership to 𝒞. First, on an input 𝔸 to Forb(𝒯), we check whether 𝔸 contains a blue loop, a red loop, or 𝕋𝔻2 (i.e., a pair of vertices connected by symmetric pairs of blue and red edges). If so, the reduction returns a 𝕏. Otherwise, the reduction returns the following digraph 𝔻=f(𝔸). The vertex set D of 𝔻 equals the domain A of 𝔸, there are no loops (u,u)E(𝔻), and for a pair of distinct vertices u and v we do the following.

  • If at least one of (u,v) or (v,u) is not a red edge in 𝔸, then we connect u and v by a symmetric pair of edges (u,v) and (v,u) in E(𝔻).

  • If (u,v),(v,u) is a symmetric pair of red edges in 𝔸, and (u,v) is a blue edge in 𝔸, then we connect them by a non-symmetric edge (u,v) in E(𝔻).

  • If (u,v),(v,u) is a symmetric pair of red edges in 𝔸, and u and v are not connected by blue edges in 𝔸, we do not connect u and v by any edge in 𝔻.

Clearly, the edge relation E(𝔻) admits a quantifier-free definition in 𝔸, and so, if 𝔸 is a substructure of 𝔹, then f(𝔸) is a substructure of f(𝔹). Clearly, for every 𝕋𝔻n with n3, the digraph f(𝕋𝔻n) is a directed cycle that does not induce any symmetric edge. Conversely, if f(𝔸) is a directed cycle on n vertices, then 𝔸𝕋𝔻n. It is straightforward to observe that a loopless {Eb,Er}-structure 𝔸 with no 𝕋𝔻2 belongs to Forb(𝒯) if and only if it does not embed any 𝕋𝔻n for n3. Hence, we obtained a polynomial-time reduction from deciding Forb(𝒯) to deciding membership to 𝒞. Therefore, the coNP-hardness of 𝒞 follows from Theorem 8.

Corollary 19.

There are 2 and (digraph) formulas ϕ and ψ such that Her(ϕ) and Her(ψ) are coNP-complete.

Proof.

For ϕ consider the formula from Lemma 17 and for ψ consider the quantifier reordering xay of ϕ, and notice that ϕ and ψ are logically equivalent.

Prefix classification

The classification for general relational signatures follows from the lemmas proved earlier in this section.

Theorem 20.

Let τ be a relational signature which is not monadic. For every quantifier prefix Q{,} one of the following statements hold:

  • Q is of the form , or of the form , and in this case Her(ϕ) is in P for every first-order τ-sentence ϕ with quantifier prefix Q, or

  • Q contains a subword or , and in this case there is a first-order τ-sentence ϕ with quantifier prefix Q such that Her(ϕ) is coNP-complete.

Proof.

Clearly, both items describe disjoint and complementary cases. The claim in the first item follows from Corollary 13 and Theorem 16. If τ contains a binary relation symbol, then the claim in the second item follows from Corollary 19. Otherwise, τ must contain a relation R of arity at least three; however, we can use R to model a binary relation, so the claim also holds in this case.

This classification also holds for the intersection of HerFO and CSPs (via Theorem 8).

Corollary 21.

For every quantifier prefix Q{,} one of the following statements hold:

  • Q is of the form , or of the form , and in this case if CSP(𝔸)=Her(ϕ) for some structure 𝔸 and some first-order sentence ϕ with quantifier prefix Q, then CSP(𝔸) is in P, or

  • Q contains a subword or , and in this case there is a structure 𝔹 such that CSP(𝔹)=Her(ϕ) for some first-order sentence ϕ with quantifier prefix Q, and CSP(𝔹) is coNP-complete.

5 Undecidability of the tractability problem

The tractability problem for HerFO asks whether Her(ϕ) can be solved in polynomial time for a given first-order sentence ϕ. In this section we show that if PNP, then the tractability problem for HerFO is undecidable. We begin with the following simple observation.

Observation 22.

Consider a first-order τ-sentence ϕ:=Q1x1Qnxn.ψ(x1,,xn). If ξ(x) is a first-order τ-formula, then there is a τ-sentence ϕξ such that a τ-structure 𝔸 satisfies ϕξ if and only if there is no element aA that satisfies ξ or the substructure of 𝔸 with domain {aA:𝔸ξ(a)} satisfies ϕ. Namely, if Q1==Qn=, then

ϕξ:=y.¬ξ(y)x1,,xn(i[n]ξ(xi)ψ(x1,,xn)).

Otherwise,

ϕξ:=Q1x1Qnxn(iUξ(xi)iEξ(xi)ψ(x1,,xn))

where U (respectively, E) is the set of indices i{1,,n} such that Qi is a universal (respectively, existential) quantifier.

Similarly, if U is a monadic predicate and ϕ is a first-order sentence, then ϕU:=ϕU(x) denotes the relativization of ϕ to the vertices in the set U, and ϕ¬U:=ϕ¬U(x) the relativization of ϕ to the complement of U.

Theorem 23.

If PcoNP, then it is undecidable to test whether the hereditary model-checking problem for a given first-order sentence ϕ is solvable in polynomial time.

Proof.

We use Trakhtenbrot’s theorem, which states that there is no algorithm that decides whether a given first-order formula ϕ has a finite model [24]. We reduce this decision problem to our problem.

Let ϕ be a first-order τ-sentence, let U be a monadic predicate not in τ, and let E a binary predicate also not in τ. Let ψ be a first-order {E}-sentence such that the hereditary model-checking problem for ψ in coNP-complete, e.g., ψ can be chosen to be the sentence hereditarily describing the CSP from Corollary 19. Building on the relativizations ψ¬U and (¬ϕ)U we define the following first-order τ{U,E}-sentence

χ:=(¬ϕ)Uψ¬U.

We claim that if ϕ does not have a finite model, then Her(χ) is polynomial-time solvable, and if ϕ has a finite model, then Her(χ) is coNP-complete. We first observe that if ϕ does not have a finite model, then χ is valid on all finite τ{U,E}-structures. To see this, let 𝔸 be a τ{U,E}-structure. If U𝔸=, then 𝔸 satisfies the first disjunct (¬ϕ)U of χ (Observation 22), and if U𝔸, then the substructure induced by U𝔸 also satisfies (¬ϕ)U, because ϕ has no finite models. In particular, this implies that Her(χ) can be solved in polynomial-time, because every instance is a yes-instance.

Now suppose that ϕ has a finite model. Let 𝕊 be a minimal model of ϕ, i.e., every proper substructure of 𝕊 satisfies ¬ϕ. We present a polynomial-time reduction from Her(ψ) to Her(χ), which implies that Her(χ) is coNP-complete. Given an {E}-structure 𝔸 we consider the τ{U,E}-structure 𝔹 defined as follows:

  • the domain B of 𝔹 is the disjoint union AS,

  • the interpretation of U in 𝔹 is S,

  • the interpretation of E in 𝔹 equals E𝔸, and

  • for every Rτ, the interpretation of R in 𝔹 is R𝕊.

The structure 𝔹 can be computed from the structure 𝔸 in polynomial time (the structure 𝕊 is constant). We now show that every substructure of 𝔸 satisfies ψ if and only if every substructure of 𝔹 satisfies χ. First, note that if a substructure of 𝔹 does not contain 𝕊, then satisfies χ. Indeed, if CA, then there is no element of that models U(x), so by Observation 22 it follows that (¬ϕ)U and hence χ. Otherwise, if CSS, then the substructure of with domain U satisfies ¬ϕ, because is a proper substructure of 𝕊, and 𝕊 is the smallest model of ϕ. Hence, (¬ϕ)U, and so χ. These observations imply that every substructure of 𝔹 satisfies χ if and only if every substructure 𝔻 of 𝔹 with SD satisfies χ. If S=D, then U𝔻=D, so no element d of 𝔻 satisfies ¬U(d), and similarly as above, we conclude that 𝔻χ because 𝔻ψ¬U. Finally, we assume that SD and DS, and so DA. Since SD and 𝕊ϕ, we have that 𝔻 does not satisfy (¬ϕ)U. Hence, 𝔻χ if and only if 𝔻ψ¬U, and the latter holds if and only if the substructure of 𝔸 with domain DA satisfies ψ. We thus conclude that 𝔹Her(χ) if and only if 𝔸Her(ψ).

All together this shows that if PcoNP, then ϕ has a finite model if and only if Her(χ) is not solvable in polynomial time.

We say that two quantifier prefixes are dual to each other if one can be obtained from the other by exchanging the symbols and .

Corollary 24.

Consider a quantifier prefix Q{,}, and assume PNP. If the finite satisfiability problem for first-order sentences whose quantifier prefix Q is undecidable, then the tractability problem for HerFO is undecidable for first-order sentences whose quantifier prefix is dual to Q. In particular, we obtain that the tractability problem for HerFO is undecidable if the quantifier prefix of the input may contain or 3 as subwords.

Proof.

Denote by Q the dual of Q. It follows from [7, Theorem 3.0.1] that if the finite satisfiability problem for first-order sentences with quantifier prefix Q is undecidable, then Q contains or 3 as a subword. Dually, Q contains or 3 as a subword, and so, by Theorem 8, there is a FO sentence ψ with quantifier prefix Q such that Her(ψ) is coNP-complete. Now, we can reduce from the finite satisfiability, because the finite satisfiability problem for the fragments of FO with quantifier prefix Q= or Q=3 is undecidable [7, Theorem 3.0.1].

6 Conclusion and Open Problems

We introduced the hereditary first-order model checking problem HerFO, and presented a complexity classification for HerFO based on allowed quantifier prefixes. A number of open problems are left for future research.

  1. 1.

    Are there first-order sentences ϕ such that Her(ϕ) is coNP-intermediate (assuming PNP)? We conjecture that there are.

  2. 2.

    Is every finite-domain CSP which is in HerFO also in P? If coNPNP, then it follows from the P vs. NP-complete finite-domain CSP dichotomy that this answer has a positive question. We ask for a proof which does not use any complexity-theoretic assumptions.

  3. 3.

    Which finite-domain CSPs are in HerFO?

  4. 4.

    Is every CSP in HerFO also of the form Her(ϕ) for some negative connected sentence ϕ?

  5. 5.

    Is it true that the tractability problem for HerFO is undecidable even for first-order sentences with quantifier prefix (assuming PNP)? This is the only quantifier-prefix for which the decidability of the tractability problem for HerFO remains open (see Corollary 24 and the first item of Theorem 20).

References

  • [1] Max Bannach, Florian Chudigiewitsch, and Till Tantau. On the descriptive complexity of vertex deletion problems. In Rastislav Královic and Antonín Kucera, editors, 49th International Symposium on Mathematical Foundations of Computer Science, MFCS 2024, August 26-30, 2024, Bratislava, Slovakia, volume 306 of LIPIcs, pages 17:1–17:14, Dagstuhl, Germany, 2024. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.MFCS.2024.17.
  • [2] Manuel Bodirsky. Complexity of Infinite-Domain Constraint Satisfaction. Lecture Notes in Logic (52). Cambridge University Press, Cambridge, United Kingdom; New York, NY, 2021. doi:10.1017/9781107337534.
  • [3] Manuel Bodirsky and Santiago Guzmán-Pro. Hereditary First-Order Logic: the tractable quantifier prefix classes. Preprint arXiv:2411.10860, 2024. doi:10.48550/arXiv.2411.10860.
  • [4] Manuel Bodirsky and Jan Kára. A fast algorithm and datalog inexpressibility for temporal reasoning. ACM Trans. Comput. Log., 11(3):15:1–15:21, 2010. doi:10.1145/1740582.1740583.
  • [5] Manuel Bodirsky, Simon Knäuer, and Sebastian Rudolph. Datalog-expressibility for monadic and guarded second-order logic. In Nikhil Bansal, Emanuela Merelli, and James Worrell, editors, 48th International Colloquium on Automata, Languages, and Programming, ICALP 2021, July 12-16, 2021, Glasgow, Scotland (Virtual Conference), volume 198 of LIPIcs, pages 120:1–120:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. Preprint available at https://arxiv.org/abs/2010.05677. doi:10.4230/LIPIcs.ICALP.2021.120.
  • [6] J. Adrian Bondy and Uppaluri S. R. Murty. Graph Theory. Graduate Texts in Mathematics. Springer, Berlin, 2008. doi:10.1007/978-1-84628-970-5.
  • [7] Egon Börger, Erich Grädel, and Yuri Gurevich. The Classical Decision Problem. Perspectives in Mathematical Logic. Springer, 1997.
  • [8] Heinz-Dieter Ebbinghaus and Jörg Flum. Finite model theory. Perspectives in Mathematical Logic. Springer, Berlin, Heidelberg, New York, 1995. Second edition.
  • [9] Thomas Eiter, Georg Gottlob, and Thomas Schwentick. The model checking problem for prefix classes of second-order logic: A survey. In Andreas Blass, Nachum Dershowitz, and Wolfgang Reisig, editors, Fields of Logic and Computation, Essays Dedicated to Yuri Gurevich on the Occasion of His 70th Birthday, volume 6300 of Lecture Notes in Computer Science, pages 227–250, Berlin, Heidelberg, 2010. Springer. doi:10.1007/978-3-642-15025-8_13.
  • [10] Tomás Feder and Moshe Y. Vardi. The computational structure of monotone monadic SNP and constraint satisfaction: A study through datalog and group theory. SIAM J. Comput., 28(1):57–104, 1998. doi:10.1137/S0097539794266766.
  • [11] Tomás Feder and Moshe Y. Vardi. Homomorphism closed vs. existential positive. In 18th IEEE Symposium on Logic in Computer Science (LICS 2003), 22-25 June 2003, Ottawa, Canada, Proceedings, pages 311–320. IEEE Computer Society, 2003. doi:10.1109/LICS.2003.1210071.
  • [12] Fedor V. Fomin, Petr A. Golovach, and Dimitrios M. Thilikos. On the parameterized complexity of graph modification to first-order logic properties. Theory Comput. Syst., 64(2):251–271, 2020. doi:10.1007/s00224-019-09938-8.
  • [13] Toshihiro Fujito. A unified approximation algorithm for node-deletion problems. Discret. Appl. Math., 86(2-3):213–231, 1998. doi:10.1016/S0166-218X(98)00035-3.
  • [14] Georg Gottlob, Phokion G. Kolaitis, and Thomas Schwentick. Existential second-order logic over graphs: Charting the tractability frontier. J. ACM, 51(2):312–362, 2004. doi:10.1145/972639.972646.
  • [15] Wilfrid Hodges. Model theory, volume 42 of Encyclopedia of mathematics and its applications. Cambridge University Press, Cambridge, 1993.
  • [16] Wilfrid Hodges. A shorter model theory. Cambridge University Press, Cambridge, 1997.
  • [17] Mukkai S. Krishnamoorthy and Narsingh Deo. Node-deletion np-complete problems. SIAM J. Comput., 8(4):619–625, 1979. doi:10.1137/0208049.
  • [18] John M. Lewis and Mihalis Yannakakis. The node-deletion problem for hereditary properties is np-complete. J. Comput. Syst. Sci., 20(2):219–230, 1980. doi:10.1016/0022-0000(80)90060-4.
  • [19] Christos H. Papadimitriou and Mihalis Yannakakis. Optimization, approximation, and complexity classes. J. Comput. Syst. Sci., 43(3):425–440, 1991. doi:10.1016/0022-0000(91)90023-X.
  • [20] Venkatesh Raman, Saket Saurabh, and C. R. Subramanian. Faster fixed parameter tractable algorithms for finding feedback vertex sets. ACM Trans. Algorithms, 2(3):403–415, July 2006. doi:10.1145/1159892.1159898.
  • [21] Bruce A. Reed, Kaleigh Smith, and Adrian Vetta. Finding odd cycle transversals. Oper. Res. Lett., 32(4):299–301, 2004. doi:10.1016/j.orl.2003.10.009.
  • [22] Donald J. Rose. A note on consistent ordering and zero circulation. J. ACM, 18(4):573–575, 1971. doi:10.1145/321662.321671.
  • [23] Donald J. Rose, Robert Endre Tarjan, and George S. Lueker. Algorithmic aspects of vertex elimination on graphs. SIAM J. Comput., 5(2):266–283, 1976. doi:10.1137/0205021.
  • [24] Boris A. Trakhtenbrot. Understanding basic automata theory in the continuous time setting. Fundam. Informaticae, 62(1):69–121, 2004. (in Russian). URL: http://content.iospress.com/articles/fundamenta-informaticae/fi62-1-04.

Appendix A Examples

Polynomial-time solvable examples

Example 3 shows that CSP(,<) is in HerFO but not in FO. There are also finite-domain CSPs that are in HerFO, but not in FO, as the following examples show. First, recall that the algebraic length of an oriented walk P is the absolute value of the difference between the number of forward edges and the number of backward edges in P. It is well-known (and straightforward to observe) that a digraph D homomorphically maps to the directed path of length 2 if and only if every oriented walk in D has algebraic length at most 2.

Example 25.

The problem CSP(P3) is in HerFO. Consider a first-order formula ϕ saying that there is a loop, or there are (directed) edges (x,y) and (a,b) such that the following hold:

  • y has exactly one out-neighbour different from b, and x is the unique in-neighbour of y;

  • a has exactly one in-neighbour different from x, and b is the unique out-neighbour of a;

  • every z{x,y,a,b} either

    • has no in-neighbours and exactly two out-neighbours, and they are different from b, or

    • has no out-neighbours and exactly two in-neighbours, and they are different from x.

Suppose that a loopless digraph 𝔻 satisfies ϕ, and let a,b,x,yD be witnesses that show that ϕ holds in 𝔻. By using the first bullet, we find z1D{b} such that (y,z1)E(𝔻), and by using the third point iteratively, we find an alternating oriented path z1,z2,,zk for some k3, i.e., (z2,z1),(z2,z3),(z4,z3),E(𝔻), and zk{a,b,x,y}. We claim that we can find an oriented walk of the form

xyz1z2zk, where zk=b, or of the form
xyz1z2zk, where zk{x,a}.

We may choose zk so that zk{a,b,x,y} and zi{a,b,x,y} for i[k1]. We first consider the case where zk is an in-neighbour of zk1. In this case, we know by the first item that zky, because k3 and y has exactly one out-neighbour different from b, namely z1zk1. We also know that zka because the unique out-neighbour of a is bzk1 (second bullet). Finally, zkx, because zk1 has exactly two in-neighbours, and they are different from x, and so, zk=b. In the case where zk is an out-neighbour of zk1, then zky because the unique in-neighbour of y is xzk1. Similarly as before, we see that zkb by applying the third bullet to zk1.

Using the existence of such paths we can easily find an oriented path of algebraic length three in 𝔻. Indeed, in the case where the path ends with an edge zk1zk, and zk=b, we use the unique in-neighbour a of a to construct a path of length three a,a,b,zk1. Now, consider the case when the path ends with an edge zk1zk. If zk=x, then zk1,x,y,z1 is a directed walk of length three, and if zk=a, then x,y,z1,,zk1,a,b is an oriented walk of algebraic length three. Hence, if 𝔻Her(¬ϕ), then either 𝔻 contains a loop or a walk of algebraic length 3, and so 𝔻↛P3.

Conversely, if 𝔻↛P3, then either 𝔻 contains a loop or it has an oriented path of algebraic length 3. In the former case, 𝔻 clearly satisfies ϕ, and in the latter, by choosing the shortest such path v1,,vn we find a substructure of 𝔻 that models ϕ; namely, the substructure with vertex set {v1,,vn}. Therefore, if 𝔻↛P3, then 𝔻Her(¬ϕ).

Inexpressible examples and 𝝎-categoricity

A digraph 𝔻 is balanced if every oriented cycle in 𝔻 has the same number of forward and of backward edges. Clearly, the class of balanced digraphs is hereditary, and so, it could a priory be expressible in HerFO. Here, we the notion of ω-categoricity (Remark 6) to prove that the class of balanced digraphs is not expressible in HerFO.

Example 26.

It is folklore that a digraph 𝔻 maps homomorphically to some directed path if and only 𝔻 is balanced. Equivalently, if succ is the successor relation in , then 𝔻(,succ) if and only if 𝔻 is a balanced digraph. Hence, the class of balanced digraphs is in HerFO iff CSP(,succ) is in HerFO. It is known that there is no ω-categorical structure 𝔸 whose CSP equals the CSP of (,succ) [2, Proposition 5.8.2]. Therefore, CSP(,succ) (equivalently, the class of balanced digraphs) is not expressible in HerFO.

HerFO and Datalog

Datalog can be seen as the subclass of SNP where we require that the first-order part ψ of the SNP sentence

  • is Horn, i.e., written in conjunctive normal form such that each clause contains at most one positive literal, and

  • is such that every positive literal in ψ is existentially quantified.

A class 𝒞 of finite models is in Datalog if there exists an SNP sentence Φ of the form described above such that a finite structure is in 𝒞 if and only if it does not satisfy Φ. Note that if a class is in Datalog, then it is closed under homomorphisms444Our definition is standard, but different from the terminology of Feder and Vardi [10, 11], who defined that CSP(𝔹) is in Datalog if its complement is in Datalog in the standard sense. and in P.

A simple example of a CSP which is solved by a Datalog program is CSP(K2). In Example 10 we showed that this class is not in HerFO. There are also CSPs that are in HerFO and in P, but not in Datalog.

Example 27.

For any positive integer k consider a (k+1)-ary relation symbol R. The problem CSP(,{(x,y1,,yk):x<max{y1,,yk}) is in P, but not in Datalog [4]. Notice that the problem is in HerFO: consider the formula

xy1,,yk.¬R(x,y1,,yk).
Corollary 28.

The classes of CSPs in Datalog and in PHerFO are incomparable.

HerFO and pp definitions

A primitive positive formula is an existential positive formula whose quantifier-free part only uses variables and symbols from {,=}τ (i.e., disjunction is forbidden). Given a structure 𝔸 we say that a relation RAr is primitively positively definable (pp-definable) in 𝔸 if there is a primitive positive formula ϕ(x1,,xr) such that a¯R if and only if 𝔸ϕ(a¯). A class of structures 𝒞 is preserved by primitive positive definitions if for every 𝔸𝒞, and every pp-definable relation R in 𝔸, the structure (𝔸,R) belongs to 𝒞. In Example 3 we showed that CSP(,<) is expressible in HerFO. The following example shows that CSP(,<,=) is not expressible in HerFO, and so, the class of structures whose CSP in HerFO is not preserved by primitive positive definitions.

Example 29.

The problem CSP(,<,=) is not hereditarily definable. Consider the family of structures n and 𝔻n illustrated below (where undirected blue edges represent the (symmetric) binary relation =, and directed black edges represent the binary relation <). It is not hard to see that for every positive integer n,

  • n is a minimal obstruction of CSP(,<,=), and

  • 𝔻nCSP(,<,=).

Now, for every k one can choose n,m appropriately so that nk𝔻m, and it thus follows by Lemma 9 that this CSP is not expressible in HerFO.

Appendix B Comparison of complexity classifications

As we discussed in the introduction, for every first-order sentence ϕ, there is a UMSO sentence Φ such that Her(ϕ) is described by Ψ, and the first-order part of Φ has the same quantifier-prefix as ϕ. Hence, if every problem expressible by a UMSO sentence with quantifier prefix Q can be solved in polynomial time, then Her(ϕ) can be solved in polynomial time for ϕ with quantifier prefix Q.

We also discussed the vertex deletion problem (parametrized version of HerFO): for a fixed first-order sentence ϕ, decide whether an input structure 𝔸 satisfies ϕ after deleting at most k vertices. In Table 1, we present a comparison between our complexity classification based on the quantifier prefix and similar known classifications for UMSO and for the parametrized version. We restrict these classification to digraphs, because, as far as we are aware, complexity classifications for the vertex deletion problem have only been considered for digraphs.

Table 1: Complexity landscape for the model checking problems for UMSO, for HerFO, and for the vertex deletion problem (all restricted to digraphs). In the HerFO column, “Always in P” means that Her(ϕ) is polynomial-time solvable whenever ϕ has quantifier prefix Q; in the UMSO column, it means that the model checking problem can be solved in polynomial time for every UMSO sentence Φ whose first-order part has quantifier prefix Q. “Hard” in the HerFO and UMSO columns means that the corresponding fragments can express coNP-complete problems. On the last column, FPT means that for every first-order sentence ϕ with quantifier prefix Q, the vertex deletion problem to ϕ is fixed-parameter tractable; and “hard” means that there are W[2]-hard problems in that fragment.
Quantifier prefix HerFO UMSO Vertex deletion
Q (Theorem 20) [14, Figure 1(a)] [12, Theorem 1]
Always in P Always in P Always FPT
Always in P Hard Always FPT
Always in P Hard Hard
Hard Hard Always FPT
Hard Hard Always FPT
Hard Hard Hard

Appendix C Two missing proofs

Proof of Lemma 9.

Suppose that 𝒞=Her(ϕ) for some first-order formula ϕ. We claim that ψ:=¬ϕ satisfies both itemized statements. Firstly, note that if 𝔽, then 𝔽Her(ϕ), so some substructure of 𝔽 does not satisfy ϕ. Moreover, all substructures of 𝔽 belong to Her(ϕ), so we have that 𝔽 itself does not satisfy ϕ, and hence satisfies ψ. If 𝔸 is a finite τ-structure such that 𝔸ψ, then 𝔸𝒞, and hence there exists 𝔽 which embeds into 𝔸. This shows the forward implication of the statement. Conversely, if there exists a formula ψ that satisfies both items of the statement, then it is similarly straightforward to show that 𝒞=Her(¬ψ).

Proof of Proposition 11.

We claim that 𝔸 hereditarily models ϕ if and only if every substructure 𝔹 of 𝔸 with at most 2|τ| many elements satisfies ϕ. One direction follows from definition of hereditary satisfiability. For the converse implication, let 𝔹 be a substructure of 𝔸 and consider a minimal subset CB such that for every bB there is a cC such that U(b)U(c) for all Uτ. Clearly, |C|2|τ| and it is straightforward to observe that 𝔹ϕ if and only if ϕ, and the claim follows.