Monadic second order finite satisfiability and unbounded tree-width

# Monadic second order finite satisfiability and unbounded tree-width

Tomer Kotek, Helmut Veith, Florian Zuleger TU Vienna
###### Abstract.

The finite satisfiability problem of monadic second order logic is decidable only on classes of structures of bounded tree-width by the classic result of Seese [24]. We prove that the following problem is decidable:

Input: (i) A monadic second order logic sentence , and (ii) a sentence in the two-variable fragment of first order logic extended with counting quantifiers. The vocabularies of and may intersect.

Output: Is there a finite structure which satisfies such that the restriction of the structure to the vocabulary of has bounded tree-width? (The tree-width of the desired structure is not bounded.)

As a consequence, we prove the decidability of the satisfiability problem by a finite structure of bounded tree-width of a logic extending monadic second order logic with linear cardinality constraints of the form on the variables , of the outer-most quantifier block. We prove the decidability of a similar extension of WS1S.

## 1. Introduction

Monadic second order logic () is among the most expressive logics with good algorithmic properties. It has found countless applications in computer science in diverse areas ranging from verification and automata theory [13, 18, 25] to combinatorics [16, 17], and parameterized complexity theory [8, 6].

The power of is most visible over graphs of bounded tree-width, and with second order quantifiers ranging over sets of edges111The logic we denote by is denoted by Courcelle and Engelfriet [6].: (1) Courcelle’s famous theorem shows that model checking is decidable over graphs of bounded tree-width in linear time [5, 1]. (2) Finite satisfiability by graphs of bounded tree-width is decidable [5] (with non-elementary complexity) – thus contrasting Trakhtenbrot’s undecidability result of first order logic. (3) Seese proved [24] that for each class of graphs with unbounded tree-width, finite satisfiability of by graphs in is undecidable. Together, (2) and (3) give a fairly clear picture of the decidability of finite satisfiability of . It appeared that (3) gives a natural limit for decidability of on graph classes. For instance, finite satisfiability on planar graphs is undecidable because their tree-width is unbounded.

While Courcelle and Seese circumvent Trakhtenbrot’s undecidability result by restricting the classes of graphs (or relational structures), several other research communities have studied syntactic restrictions of first order logic. Modal logic [26], many temporal logics [21][23, Chapter 24], the guarded fragment [9], many description logics [2], and the two-variable fragment [10] are restricted first order logics with decidable finite satisfiability, and hundreds of papers on these topics have explored the border between decidability and undecidability. While many of the earlier papers exploited variations of the tree model property to show decidability, recent research has also focused on logics such as the two-variable fragment with counting  [11, 22], where finite satisfiability is decidable despite the absence of the tree model property. In a recent breakthrough result, Charatonik and Witkowski [4] have extended this result to structures with built-in binary trees. Note that this logic is not a fragment of first order logic, but more naturally understood as a very weak second order logic which can express one specific second order property – the property of being a tree.

Our main result is a powerful generalization of the seminal result on decidability of the satisfiability problem of over bounded tree-width and the recent theorem by [4]: We show decidability of finite satisfiability of conjunctions where is in and is in by a finite structure whose restriction to the vocabulary of has bounded tree-width. (Theorem 1 in Section 3)

Let us put this result into perspective:

• The decidability problem is a trivial consequence by setting to true; Charatonik and Witkowski’s result follows by choosing to be an formula which axiomatizes a -ary tree, which is a standard construction [6].

• The decidability of model checking over a finite structure is a much simpler problem than ours: We just have to model check and one after the other. In contrast, satisfiability is not obvious because and can share relational variables. running two finite satisfiability algorithms for the two formulas independently may tield two models which disagree on the shared vocabulary. Thus, the problem we consider is similar in spirit to (but technically very different from) Nelson-Oppen [20] combinations of theories.

• Our result trivially generalizes to Boolean combinations of sentences in the two logics.

### Proof Technique.

We show how to reduce our satisfiability problem for to the finite satisfiability of a -sentence with a built-in tree, which is decidable by [4]. The most significant technical challenge is to eliminate shared binary relation symbols between and . Our Separation Theorem overcomes this challenge by an elegant construction based on local types of universe elements and a coloring argument for directed graphs. The second technical challenge is to replace the -sentence with an equi-satisfiable -sentence . To do so, we apply tools including the Feferman-Vaught theorem for and translation schemes.

### Monadic Second Order Logic with Cardinalities.

Our main theorem imply new decidability results for monadic second order logic with cardinality constraints, i.e., expressions of the form where the and are monadic second order variables. Klaedtke and Rueß [15] showed that the decision problem for the theory of weak monadic second order logic with cardinality constraints of one successor () is undecidable; they describe a decidable fragment where the second order quantifiers have no alternation and appear after the first order quantifiers in the prefix. Our main theorem implies decidability of a different fragment of WS1S with cardinalities: The fragment consists of formulas where the cardinality constraints in involve only the monadic second order variables from , cf. Theorem 6 in Section 7. Note that in contrast to [15], our fragment is a strict superset of WS1S.

For WS2S, we are not aware of results about decidable fragments with cardinalities. We describe a strict superset of whose satisfiability problem over finite graphs of bounded tree-width is decidable, and which is syntactically similar to the WS1S extension above.

### Expressive Power over Structures.

Our main result extends the existing body of results on finite satisfiability by structures of bounded tree-width to a significantly richer set of structures. The structures we consider are -axiomatizable extensions of structures of bounded tree-width. For instance, we can have interconnected doubly-linked lists as in Fig. 1(a), or a tree whose leaves are connected in a chain and have edges pointing to any of the nodes of a cyclic list as in Fig. 1(b). Such structures occur very naturally as shapes of dynamic data structures in programming – where cycles and trees are containers for data, and additional edges express relational information between the data. The analysis of semantic relations between data structures served as a motivation for us to investigate the logics in the current paper [3].

Being a cyclic list or a tree whose leaves are chained can be expressed in and both of these data structures have tree-width at most . We can compel the edges between the tree and the cyclic list to obey -expressible constraints such as:

• every leaf of the tree has a single edge to the cyclic list;

• every node of the cyclic list has an incoming edge from at least one leaf of the tree; or

• any two leaves pointing to the same node of the cyclic list agree on membership in some unary relation.

Note that while the structures we consider may contain grids of unbounded sizes as subgraphs, the logic cannot axiomatize them.

## 2. Background

This section introduces basic definitions and results in model theory and graph theory. We follow [19] and [6].

The two-variable fragment with counting is the extension of the two-variable fragment of first order logic with first order counting quantifiers , , , for every . Note that remains a fragment of first order logic. Monadic Second order logic is the extension of first order logic with set quantifiers which can range over elements of the universe or subsets of relations222On relational structures, is also known as Guarded Second Order logic . The results of this paper extend to , the extension of with modular counting quantifiers.. Throughout the paper all structures consist of unary and binary relations only. Structures are finite unless explicitly stated otherwise (in the discussion of ). Let be a vocabulary (signature). The arity of a relation symbol is denoted by . The set of unary (binary) relation symbols in are (). We write for the set of -formulas on the vocabulary . The quantifier rank of a formula , i.e. the maximal depth of nested quantifiers in is denoted . We denote by the disjoint union of two -structures and . Given vocabularies , a -structure is an expansion of a -structure if and agree on the symbols in ; in this case is the reduct of to , i.e.  is the -reduct of . We denote the reduct of to by . A -structure with universe is a substructure of a -structure with universe if and for every , . We say that is the substructure of generated by .

Graphs are structures of the vocabulary333Since we explicitly allowed quantification over subsets of relations for , we do not view graphs and structures as incidence structures, in contrast to [6, Sections 1.8.1 and 1.9.1]. consisting of a single binary relation symbol . Graphs are simple and undirected unless explicitly stated otherwise. Tree-width is a graph parameter indicating how close a simple undirected graph is to being a tree, cf. [6]. It is well-known that a graph has tree-width at most iff it is a partial -tree. A partial -tree is a subgraph of a -tree. -trees are built inductively from the -clique by repeated addition of vertices, each of which is connected with edges to a -clique. The Gaifman graph of a -structure is the graph whose vertex set is the universe of and whose edge set is the union of the symmetric closures of for every . Note the unary relations of play no role in . The tree-width of a -structure is the tree-width of its Gaifman graph. In this paper, tree-width is a parameter of finite structures only. Fix for the rest of the paper. will denote the tree-width bound we consider.

We introduce the notion of oriented -trees which refines the notion of -trees. Let be a vocabulary consisting of binary relation symbols. An oriented -tree is an -structure in which all are total functions and whose Gaifman graph is a partial -tree.

###### Lemma 1.

Every -structure of tree-width can be expanded into a -structure such that: (i) is an oriented -tree, (ii) is a subgraph of , and (iii) the tree-width of is .

The oriented -tree in Fig. 2(b) is an expansion of the directed graph in Fig. 2(a) as guaranteed in Lemma 1. In Fig. 2(b), and are denoted by the dashed arrows and the dotted arrows, respectively. There are several other oriented -trees which expand Fig. 2(a) and fulfill the requirements in Lemma 1,

To see that Lemma 1 holds, we describe a construction of echoing the process of constructing -trees above. For each vertex of the initial -clique, we can set the values of to be the other vertices of the clique. When a new vertex is added to the -tree, edges incident to it are added. We set to be the set of vertices incident to . For oriented -trees whose Gaifman graph is not a -tree the construction of an oriented -tree is augmented by changing the value of to whenever is not well-defined. This can happen when the target of under is a vertex which was eliminated by taking the subgraph of a -tree to obtain the partial -tree.

## 3. Overview of the Main Theorem and its Proof

The precise statement of the main theorem is as follows:

###### Theorem 1 (Main Theorem).

Let and be vocabularies. Let be a binary relation symbol not in . Let and . There is an effectively computable sentence over a vocabulary such that the following are equivalent:

1. There is a -structure such that and .

2. There is a -structure such that and is a binary tree.

The first step towards proving Theorem 1 is the Separation Theorem:

###### Theorem 2 (Separation Theorem).

Let and be vocabularies. Let and . There are effectively computable sentences and over vocabularies and such that only contains unary relation symbols and the following are equivalent:

1. There is a -structure with and

2. There is a -structure with and .

In conjunction with Theorem 2, we only need to prove Theorem 1 in the case that the -formula and the -formula only share unary relation symbols. The significance of Theorem 2 is that it allows us to use tools designed for in our more involved setting. The proof of Theorem 2 uses notions of types for -sentences in Scott normal form, oriented -trees, coloring arguments, and an induction on ranks of structures. Theorem 2 is discussed in Section 4. The next step is to move from structures whose reducts have bounded tree-width to structures which contain a binary tree.

###### Lemma 2.

Let and be vocabularies such that contains only unary relation symbols. Let be a binary relation symbol. There is a vocabulary consisting of and unary relation symbols only, and, for every and , effectively computable sentences and such that the following are equivalent:

1. There is a -structure such that and such that .

2. There is a -structure such that and is a binary tree.

Technically, Lemma 2 is proved using a translation scheme which maps structures with a binary tree into structures whose -reducts have tree-width at most , and conversely, each of the latter structures is the image of a structure with a binary tree under the translation scheme. Translation schemes capturing the graphs of tree-width at most as the image of labeled trees were studied in the context of decidability and model checking of  [1]. We need a more refined construction to ensure that the translation scheme also behaves correctly on -sentences, i.e. that it maps -sentences to -sentences, see Lemma 2 in Section 5.

Now that we have reduced our attention to the case that our structures contain a binary tree, we can replace -sentences with equi-satisfiable -sentences.

###### Lemma 3.

Let be a vocabulary which consists only of a binary relation symbol and unary relation symbols. Let be an -sentence. There is an effectively computable -sentence over a vocabulary such that for every -structure in which is a binary tree the following are equivalent:
(i) (ii) There is a -structure expanding such that .

For the proof of Lemma 3 we use a Feferman-Vaught type theorem which states that the Hintikka type (i.e. types) of a binary tree labeled with unary relation symbols depends only on the Hintikka types of its children. We can therefore axiomatize in that the Hintikka type of the labeled binary tree implies a given -sentence.

Having replaced the -sentence in statement (ii) of Lemma 2 with a -sentence, we are left with the problem of deciding whether a -sentence is satisfiable by a structure in which a specified relation is a binary tree, which has recently been shown to be decidable:

###### Theorem 3 (Charatonik and Witkowski [4]).

Let be a vocabulary which contains a binary relation symbol . Given a -sentence , it is decidable whether is satisfiable by a structure in which is a binary tree.

## 4. Separation Theorem

### 1-types and 2-types

We begin with some notation and definitions in the spirit of the literature on decidability of , cf. e.g. [22, 4]. Let be a vocabulary of unary and binary relations.

A 1-type is a maximal consistent set of atomic -formulas or negations of atomic -formulas with free variable , i.e., exactly one of and belongs to for every unary relation symbol , and exactly one of and belongs to for every binary relation symbol . We denote by the formula that characterizes the 1-type . We denote by the set of 1-types over .

A 2-type is a maximal consistent set of atomic -formulas or negations of atomic -formulas with free variables and , i.e., for every and unary relation symbol , exactly one of and belongs to , and for every and binary relation symbol , exactly one of and belongs to . We note that the equality relation is also part of a -type. We write for the 2-type obtained from by substituting all occurrences of resp. with resp. . We write for the 1-type obtained from by restricting to formulas with free variable . We write for the 1-type obtained from by restricting to formulas with free variable and substituting with . We denote by the formula that characterizes the 2-type . We denote by the set of 2-types over .

Let be a -structure. We denote by the unique 1-type such that . For elements of , we denote by the unique 2-type such that . We denote by the set of 2-types realized by . The following lemma is easy to see:

###### Lemma 4.

Let be two -structures over the same universe and let with quantifier-free. If , then iff .
(See proof in Appendix 8.4.)

### Scott Normal Form and T-functionality

-sentences have a Scott-Normal Form, cf. [12], which can be obtained by iteratively applying Skolemization and introducing new predicates for subformulas, together with predicates ensuring the soundness of this transformation:

###### Lemma 5 (Scott Normal Form, [12]).

For every -sentence there is a -sentence of the form

 (1) ∀x,y.χ∧⋀i∈[l]∀x.∃=1y.Si(x,y),

with quantifier-free, over an expanded vocabulary such that and are equi-satisfiable. Moreover, is computable. The expanded vocabulary contains in particular the fresh binary relation symbols in

Let be a set of binary relation symbols. We say a structure is -functional, if for every , is a total function on the universe of . Observe the following are equivalent for every structure :
(i) satisfies Eq. (1), and (ii) and is -functional.

### Message Types and Chromaticity

Let be a subset of the binary relation symbols of . We write and say is a -message type, if and for some . Let be a -structure with universe . We define . The -message-graph is the directed graph , where , where denotes the usual composition of relations. We say is -chromatic, if for all .

We note that if is -functional, then has out-degree for all . This allows us to prove Lemma 6 based on Lemma 7; the proofs can be found in Appendices 8.6 and 8.5.

###### Lemma 6.

There is a finite set of unary relations symbols such that every -functional -structure can be expanded to a -chromatic -structure.

###### Lemma 7.

Let be a directed graph with out-degree for all . Then, the underlying undirected graph has a proper -coloring.

### 4.2. Separation Theorem

Let be an (undirected) graph. We say is -bounded, if the edges of can be oriented such that every node of has out-degree less than . We say a structure is -bounded if its Gaifman graph is -bounded.

###### Theorem 2 (Separation Theorem).

Let be a natural number. Let and be vocabularies. Let and444The Separation Theorem remains correct if we replace with any logic containing which is closed under conjunction. . There are effectively computable sentences and over vocabularies and such that only contains unary relation symbols such that for every -bounded graph the following are equivalent:

1. There is a -structure with and .

2. There is a -structure with and .

We assume that is in the form given in Eq. (1) for some set of binary relation symbols and quantifier-free -formula . Let be a set of fresh binary relation symbols. We set . We begin by giving an intuition for the proof of the Separation Theorem in three stages.

### 1. Syntactic separation coupled with semantic constraints

For a binary relation symbol , we define its copy as the relation symbol . For every vocabulary , we define its copy to be the unary relation symbols of plus the copies of its binary relations symbols. We assume that copied relation symbols are distinct from non-copied symbols, i.e., . For a formula over vocabulary , we define its copy over vocabulary as the formula obtained from by substituting every occurrence of a binary relation symbol with .

The sentences (the copy of ) and do not share any binary relation symbols. Clearly, (i) from Theorem 2 holds iff

1. is satisfied by a -structure with for all and .

In the next two stages we will construct and so that (I) is equivalent to (ii) from Theorem 2. More precisely, we will construct sentences with and such that (I) is equivalent (II):

1. is satisfied by a -structure with .

### 2. Representation of k-bounded structures using functions and unary relations.

Theorem 2 as well as (I) and (II) involve reducts which are -bounded structures. -bounded -structures can be represented by introducing new binary relation symbols interpreted as functions and new unary relation symbols as follows.

1. We add fresh relation symbols and axiomatize that these relations are interpreted as total functions.

2. We add fresh unary relations and axiomatize that every element labeled by has an outgoing edge with 2-type . The symbols are called unary -type annotations.

3. We axiomatize that .

In other words, the functions interpreting witness that can be oriented so that every node in the Gaifman graph of has outdegree at most . The -type of each edge in is encode by putting the unary relation symbol of the -type of on the source in the orientation.

Given a -structure , we will use the above representation twice, on and , by axiomatizing that every element labeled by has an outgoing edge with 2-type and an outgoing edges with 2-type . This will allow us to replace the condition from (I) that for all with the condition that for all . We will define a vocabulary . Let . We will define two vocabularies and . According to (a), (b), and (c), we will construct such that (I) is equivalent to the following:

1. is satisfied by a -structure with for all and .

### 3. Establishing the semantic condition of (I’) by swapping edges.

Here we discuss how to show the implication from (II) to (I’) and make the vocabularies and precise. Let be a -structure with . It simplifies the discussion to split a -structure into two -structures. The -structure is . The -structure is obtained from by renaming copies of relation symbols to — i.e., we define the -structure by setting for all and setting iff for all and . The interpretations of the relations might differ in and . Observe that we have and . The key idea of the proof is prove the existence of a sequence of structures , where each is obtained from by swapping edges, until the interpretations of the relations agree in and . The edge swapping operation is a local operation which involves changing the -types of at most edges.

The edge swapping operation satisfies two crucial preservation requirements: edge swapping preserves (PR-1) the truth value of , i.e. , and (PR-2) -functionality. The universal constraint in is maintained under edge swapping because this operation does not change the set of -types (see Lemma 4). To satisfy the preservation requirements (PR-1) and (PR-2), all that remains is to guarantee the existence of a sequence of edge swapping preserving -functionality. Note that -functionality amounts to -functionality and -functionality. We use two main techqniues for ensuring the preservation of -functionality: chromaticity and unary -type annotations. We will axiomatize that the structures and are chromatic and we will take care that chromaticity is maintained during edge swaps. We will add fresh unary relation symbols and axiomatize that every element of labeled by has an outgoing edge with 2-type and an outgoing edge with 2-type .

### Proof of the Separation Theorem

We now start the formal proof of the Separation Theorem. Let be the vocabulary from Lemma 6. We set . We set and . Next we will define formulas and , and set . We set , , , and , , and , where:

 δ=⋀i∈[k]∀x.∃=1y.Ri(x,y)θ=∀x,y.x≉y→(⋁i∈[k]Ri(x,y)∨Ri(y,x)↔⋁B∈bin(Cbnd)B(x,y)∨B(y,x))ϵ=⋀B∈bin(Cunb)∀x,y.x≉y→(B(x,y)→⋁i∈[k]Ri(x,y)∨Ri(y,x))

expresses that each is interpreted as a total function, expresses that for every -structure with we have that , expresses that for every -structure with we have that is a subgraph of , expresses that for every with or , -structure and element of we have iff there is an element of such that , expresses that for every , -structure and element of we have iff there is an element of such that , expresses that for every -structure with , is chromatic iff .

The direction “(i) implies (ii)” of the Separation Theorem is not hard:

###### Lemma 8.

Let be a -bounded graph. Let be a -structure with and . can be expanded to a -structure with and .

###### Proof.

Because of and is -bounded, we can expand to a -structure such that and is a total function for all (possibly adding self-loops for the relations ). Thus, . According to Lemma 6, can be expanded to a chromatic structure over vocabulary with . We expand to a -structure such that for all and we have iff there is an element of such that . This definition gives us , and thus . We expand to a -structure such that for all and we have iff and or for some . We note that . ∎

Now we turn to the direction “(ii) implies (i)”. Let be a -bounded graph. Let be a -structure with and . Let be the universe of . We define the -structure by setting for all and setting iff for all and . We note that and . We define the -structure by setting . We note that .

We make the following definition: For and we set , if there are with , and ; we set , otherwise. We set and . measures the deviation of the relations in and (we note that there always are unique for with , because of and ) and has the following important property:

###### Lemma 9.

If , then and .
(See Appendix 8.8 for the proof.)

The proof of Lemma 9 uses the following simple but useful property of the rank function:

###### Lemma 10.

Let be an element with and let with . For all we have iff .
(See Appendix 8.7 for the proof.)

###### Lemma 11.

There is a sequence of -structures , with universe and , such that:

1. for all ,

2. for all ,

3. , (in particular is -functional and chromatic),

4. for all , and .

###### Proof.

Assume we have already defined and . In the following we will define . Because of we can choose some elements and such that , and . Let . We have because of . We have because of . Because we have . Thus, and . With we get , and thus . We proceed by a case distinction:

Case 1: is a -message type.
We have because of . We get because of . With , there is an element such that and . We note that