# An Optimal Construction for the Barthelmann-Schwentick Normal Form on Classes of Structures of Bounded Degree

Building on the locality conditions for first-order logic by Hanf and Gaifman, Barthelmann and Schwentick showed in 1999 that every first-order formula is equivalent to a formula of the shape ∃ x_1 ∃ x_k ∀ y ϕ where quantification in ϕ is relativised to elements of distance ≤ r from y. Such a formula will be called Barthelmann-Schwentick normal form (BSNF) in the following. However, although the proof is effective, it leads to a non-elementary blow-up of the BSNF in terms of the size of the original formula. We show that, if equivalence on the class of all structures, or even only finite forests, is required, this non-elementary blow-up is indeed unavoidable. We then examine restricted classes of structures where more efficient algorithms are possible. In this direction, we show that on any class of structures of degree ≤ 2, BSNF can be computed in 2-fold exponential time with respect to the size of the input formula. And for any class of structures of degree ≤ d for some d≥ 3, this is possible in 3-fold exponential time. For both cases, we provide matching lower bounds.

## Authors

• 1 publication
• 1 publication
• ### Canonization for Bounded and Dihedral Color Classes in Choiceless Polynomial Time

In the quest for a logic capturing PTime the next natural classes of str...
10/23/2020 ∙ by Moritz Lichter, et al. ∙ 0

• ### On the Width of Regular Classes of Finite Structures

In this work, we introduce the notion of decisional width of a finite re...
04/21/2021 ∙ by Alexsander Andrade de Melo, et al. ∙ 0

• ### Recursive enumerability and elementary frame definability in predicate modal logic

We investigate the relationship between recursive enumerability and elem...
11/21/2019 ∙ by Mikhail Rybakov, et al. ∙ 0

• ### Characterizing Tseitin-formulas with short regular resolution refutations

Tseitin-formulas are systems of parity constraints whose structure is de...
03/17/2021 ∙ by Alexis de Colnet, et al. ∙ 0

• ### Algorithms and Lower Bounds for de Morgan Formulas of Low-Communication Leaf Gates

The class FORMULA[s] ∘𝒢 consists of Boolean functions computable by size...
02/20/2020 ∙ by Valentine Kabanets, et al. ∙ 0

• ### Learning Concepts Described by Weight Aggregation Logic

We consider weighted structures, which extend ordinary relational struct...
09/22/2020 ∙ by Steffen van Bergerem, et al. ∙ 0

• ### Towards an arboretum of monadically stable classes of graphs

Logical transductions provide a very useful tool to encode classes of st...
10/06/2020 ∙ by Jaroslav Nešetřil, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

First-order logic (for short: FO) and its extensions are employed in many fields of theoretical computer science, as for example automata theory, descriptive complexity theory, database theory, and algorithmic meta-theorems.

However, it is well-known that the expressive power of FO is very limited: it can only express local properties. This excludes properties that require a global grasp of the structure, as for example graph connectivity. The theorems by Hanf, by Gaifman, and by Schwentick and Barthelmann [16, 7, 12, 26] are formalisations of the locality of FO and thus facilitate inexpressibility proofs. Moreover, each of these locality theorems gives rise to a normal form for first-order logic.

In particular, Gaifman’s theorem implies that on the class of all structures, every sentence of FO is equivalent to a Gaifman normal form (gnf), i.e., a Boolean combination of statements of the shape

“There are nodes whose -neighbourhoods are pairwise disjoint and which satisfy the same FO-definable property .”

Hanf’s theorem implies that for every class of structures of bounded degree, each sentence of FO logic is equivalent to a Hanf normal form (hnf), i.e., a Boolean combination of statements of the shape

“There are nodes whose -neighbourhoods each have isomorphism type .”

Hanf’s and Gaifman’s theorem have found a plethora of applications in algorithms and complexity (cf., e.g., [27, 10, 23, 4, 20, 21, 28, 13, 1, 22]). In particular, algorithmic meta-theorems make use of the local conditions expressed in gnf and hnf to show that on many classes of structures, FO model checking is fixed-parameter tractable, and that the results of FO queries can be enumerated with constant delay after a linear-time preprocessing phase.

Schwentick and Barthelmann [26] presented a local normal form for first-order logic that avoids the “pairwise disjoint -neighbourhoods” constraint in Gaifman’s normal form as well as the restriction to classes of structures of bounded degree necessary for Hanf’s normal form. They showed that on the class of all structures, every sentence of FO is equivalent to a single statement of the shape

pebbles can be placed such that the -neighbourhoods of all nodes in the so extended structure satisfy the same FO-definable property .”

In the following, we call such statements Schwentick-Barthelmann normal form (bsnf). In [26], two applications of bsnf are described: a local variant of Ehrenfeucht-Fraïssé games [9, 6] which restricts the game to local neighbourhoods after an initial phase [26], and an automata model for first-order logic.

In the context of algorithmic meta-theorems, the question about the efficiency of constructing normal forms has arisen (cf., e.g., [2, 3, 24, 18, 17, 19, 22]). In particular, it was shown in [3] that there is a non-elementary lower bound for the size of gnf in respect to the input sentence if equivalence is required on the class of all finite trees. On the other hand, [2] and [18] provided 3-fold exponential algorithms and matching lower bounds for the construction of hnf and gnf, respectively, on classes of structures of bounded degree.

Concerning bsnf, the construction described in [26] is effective, but has non-elementary time complexity. We show (cf. Theorem 8) that this is indeed unavoidable – i.e., even when equivalence of the constructed bsnf to the input sentence is required on the class of all finite forests, a non-elementary blow-up in the size cannot be avoided.

For this reason, our main focus lies on an investigation of bsnf on classes of structures of bounded degree. We show that, when equivalence is only required on the class of all structures of degree at most for (), any formula from FO logic can be turned into a bsnf in -fold (-fold) exponential time in the size of (cf. Theorem 3). We complement both upper bounds by matching lower bounds (cf. Theorem 11 and Theorem 13). In particular, our upper bounds imply corresponding upper bounds on the number of pebbles to be placed in the first stage of the local Ehrenfeucht-Fraïssé game and on the size of the automata for FO logic described in [26] when restricting attention to classes of structures of bounded degree.

Our algorithm for the construction of bsnf relies on a transformation of FO formulae into hnf, as described in [2, 18, 19]. The most challenging task is to turn so-called type-formulae, which describe the isomorphism type of the -neighbourhood of their free variables, into bsnf. Our lower bound proofs use techniques already employed in [29, 11, 8, 3, 2, 18, 17].

The rest of the paper is structured as follows. Section 2 fixes basic notations used throughout the paper. Section 3 presents the algorithm leading to our upper bounds. Section 4 provides the matching lower bounds. Due to space restrictions, some proof details are deferred to an appendix.

#### Acknowledgements

The authors would like to thank Dietrich Kuske, who brought the normal form of Barthelmann and Schwentick to their attention and posed the question about its complexity. We also would like to thank Nicole Schweikardt for helpful hints on the first version of this paper.

## 2 Preliminaries

We use to denote the set of natural numbers, i.e., the set of nonnegative integers, and we let . For all with , we write for the set and let if . By we abbreviate the set .

is the set of all reals greater than or equal to . For a real number , we write to denote the logarithm of with respect to base . For every function , we write for the class of all functions for which there exists a number such that for all sufficiently large .

The function is defined by and for all . I.e., is a tower of of height with on top. We furthermore abbreviate . A function is at most -fold exponential, for some , if belongs to the class . More generally, is elementary if it is at most -fold exponential for some and non-elementary if there is no such .

##### Signatures and Structures

For signatures, structures, and FO logic, we use the standard notation, cf. [5, 23]. A signature is a finite set of relation symbols and constant symbols . Each relation symbol has an arity . A -structure is a tuple , where is a finite and non-empty set, called the universe of , where each relation symbol , , is interpreted by the relation and where each constant symbol , , is interpreted by an element . We write to express that is isomorphic to a second -structure .

In the following, we suppose that is a relational signature, i.e., a signature that only contains relation symbols. A -structure is a substructure of a -structure if and for each . In particular, is the substructure of induced by (for short: ) if for each .

A -structure is a disjoint union of -structures if the universes are pairwise disjoint, is the union of , and is the union of for all . A -structure is a component of if is the disjoint union of and some other -structure.

##### First-Order Logic

By we denote the class of all first-order formulae of signature . That is, is built from atomic formulae of the form and , for and variables or constant symbols , and closed under the Boolean connectives and existential first-order quantifiers for any variable .111As usual, , , , will be used as abbreviations when constructing formulae. By FO we denote the union of all for arbitrary signatures .

The size of an -formula is its length when viewed as a word over the alphabet , where Var is a countable set of variable symbols. The quantifier rank of an FO-formula is defined as the maximal nesting depth of its quantifiers. By we denote the set of all free variables of . A sentence is a formula with . We write , for with , to indicate that is a subset of .

If is a -structure and , we write or to indicate that the formula is satisfied in when interpreting the free occurences of the variables with the elements . Two formulae and over a signature are -equivalent, for a class of -structures, if for every and , we have if, and only if, . In particular, we call and equivalent if they are -equivalent for the class of all -structures.

For an -formula and a , it is easy to define an -formula of size such that for a -structure if, and only if, there are at least elements in such that , cf., e.g., [18]. We write for and for .

##### Gaifman Graph and Classes of Structures of Bounded Degree

Let be a signature and let be a -structure. The Gaifman graph of is the undirected and loop-free graph with node set and an edge between two distinct nodes if, and only if, there is an and a tuple , such that . For elements , we denote by the length of a shortest path between and in or if there is no such path. The -structure is connected if its Gaifman graph is connected, i.e., if for all .

For each , an -formula can be constructed (cf., e.g., [18]) in time for , such that for each -structure and all ,

 A ⊨ dist≤d[a,b]iffdistA(a,b)≤d.

For every and , the -neighbourhood of in is the set

 NAr(a) :={b∈A:distA(a,b)≤r}

and the -neighbourhood of a tuple of length is the union of the sets for all .

The degree of is the degree of its Gaifman graph . We say that is -bounded, for a degree bound , if no node in has more than neighbours. By we denote the class of all -bounded -structures. Two -formulae and are -equivalent if they are -equivalent. To bound the cardinality of a neighbourhood in a -bounded structure in dependence from its radius , let be defined by

 νd(r) :=1+d⋅∑0≤i

Then, if is -bounded, for any element and any , we have . In particular, , , , and for . I.e., is growing linearly for and exponentially for .

##### Isomorophism Types

Let be a relational signature. For each , we let for pairwise distinct constant symbols . For any , an -type (with centres over ) is a -structure that consists of a -structure and an interpretation for each constant symbol , such that . I.e., every element of has distance to at least one of the ’s. We also call the centres of . If is a -structure, for some , and , then denotes the -type of in . We say that realise an -type with centres if . For short – we often speak of types instead of isomorphism types.

We will often use the following observations from folklore (cf., [19, 1, 22]):

###### Lemma 1.

Let be a relational signature, let with , and let be a -bounded -structure. For all , , and , it holds that:

1. ,

2. if is connected, then for all ,

3. given , , and , the -type of in can be computed in time , and

4. given two -bounded -types and with centres over , it can be decided in time whether .

###### Lemma 2.

There is an algorithm which upon input of a relational signature , a degree bound with , a radius , and a number , computes a set of -bounded -types with centres over , such that for every -bounded -type with centres over there is exactly one such that . The algorithm’s runtime is . Furthermore, upon input of a -bounded -type with centres over , the particular with can be computed in time .

Given an -type with centres over , for some and , one can construct a type-formula with such that for every -structure and every tuple ,

 A⊨typeτ[¯¯¯a]if, and only if,NAr(¯¯¯a)≅τ.

More precisely, if and for some , the type-formula can be defined by

where is a conjunction of all atomic and negated atomic -formulae such that , and are chosen such that for each . Thus, if is -bounded for some , the formula can be constructed in time if , and otherwise in time .

##### Local Formulae and the Barthelmann-Schwentick Normal Form

Let be a relational signature. An -formula with and is -local around if for each -structure and all elements ,

 A ⊨φ[a1,…,am,b1,…,bn]if, and only if,A[{a1,…,am}∪NAr(b1,…,bn)] ⊨φ[a1,…,am,b1,…,bn].

We call local around if it is -local around for some . As an example, the type-formula is -local around if is an -type.

A formula is in Barthelmann-Schwentick normal form (for short: bsnf) if it has the shape

 ∃y1⋯∃yn∀zφ(¯¯¯x,y1,…,yn,z)

for an and a formula where every quantification is restricted to elements of the universe of distance at most from , i.e., the formula is -local around , for some (cf., [26]). Its locality radius is . A bsnf-formula is a formula in bsnf and a bsnf-sentence is a sentence in bsnf.

##### Forests and Trees

A forest is a directed graph where every vertex has indegree at most and whose Gaifman graph is acyclic. A tree is a connected forest. In forests, as well as in trees, nodes of indegree are called roots. By we denote the class of all finite forests. The height of a forest (a tree ) is the length of the longest path in (in ), starting in a (the) root node. denotes the class of all finite forest with height .

## 3 Upper Bounds

This section’s aim is to show that, in contrast to the non-elementary lower bound on trees of unbounded degree (cf. Theorem 8), Barthelmann-Schwentick normal forms can be computed in elementary time when equivalence to the input formula is only required on a class of structures of bounded degree. The main result of this section can be stated as follows:

###### Theorem 3.

There is an algorithm which, on input of a degree bound with , a relational signature , and a formula from , computes a formula in bsnf that is -equivalent to . The algorithm runs in time

 2(∥φ∥⋅νd((n+1)(2⋅4q+1)))O(∥σ∥),

where are the number of free variables and the quantifier rank of , respectively.

###### Remark.

Under the assumption that only contains relation symbols that actually occur in and since , the algorithm of Theorem 3 runs in time

 22poly(∥φ∥)for d=2, and2d2O(∥φ∥)for d≥3.

The algorithm described in Theorem 3 relies on the construction of Hanf normal forms described in [2, 18, 19] and proceeds in the following four steps, which are carried out in detail in the subsequent Section 3.1, 3.2, 3.3, and 3.4, respectively:

1. The input formula is transformed into a -equivalent positive Hanf normal form . Intuitively, a positive Hanf normal form is built from the following sub-formulae using only the logical connectives and :

• Counting-sentences, which either state that there are at least elements that realise a given type or that there are precisely elements that realise a given type.

• Type-formulae, which check whether the interpretation of their free variables realises a given type.

2. Each counting-sentence in is replaced by an equivalent sentence in bsnf.

3. Each type-formula in is replaced by a -equivalent formula in bsnf.

4. The formula obtained from the latter two steps is a positive Boolean combination of sentences and formulae in bsnf. We use a procedure from [26] to turn this positive Boolean combination into a single equivalent formula in bsnf.

In the remainder of this section, will always denote a relational signature.

### 3.1 (Positive) Hanf Normal Form

In this section, we recall the notion of Hanf normal form (hnf) from [19] and introduce its syntactical restriction to positve Hanf normal form ().

A threshold-counting-sentence has the shape

 ∃≥kytypeτ(y)

where and, for some , is an -type with one centre. A -structure satisfies if, and only if, there are pairwise distinct elements in that realise .

An -formula is in Hanf normal form (for short: hnf) if it is a Boolean combination of type-formulae and threshold-counting-sentences. Its locality radius is the maximum radius of all its type-formulae.

###### Theorem 4 ([2, 18, 19]).

There is an algorithm which, on input of a degree bound with , a relational signature , and a formula with quantifier rank from , computes a formula in hnf that is -equivalent to and that has locality radius . The algorithm runs in time

In the following, we also consider exact-counting-sentences of the shape for arbitrary . We will subsume exact-counting-sentences and threshold-counting-sentences under the name counting-sentences. The reason for introducing exact-counting-sentences is that in the notion of positive Hanf normal form, introduced in the following, negations are only allowed inside of type-formulae and counting-sentences, but not in the Boolean combination that connects these.

A formula is in positive Hanf normal form (for short: ) if it is a positive Boolean combination (i.e., a Boolean combination that only uses the connectives and ) of type-formulae and counting-sentences. can be obtained from hnf:

###### Lemma 5.

There is an algorithm which, on input of a degree bound with , a relational signature , and a formula with quantifier rank from , computes a formula in that is -equivalent to and that has locality radius . The algorithm runs in time

• On input of a degree bound with , a relational signature , and a formula from with quantifier rank and free variables, the algorithm proceeds as follows:

1. Using the algorithm described in Theorem 4, is turned into a -equivalent formula  in hnf that has locality radius .

2. Using de Morgan’s law and the elemination of double negations, is turned into a Boolean combination of type-formulae and threshold-counting-sentences whose negations only occur directly in front of a threshold-counting-sentence or a type-formula.

3. In the formula just constructed, we replace each negated type-formula by a -equivalent positive Boolean combination of type-formulae and each negated threshold-counting-sentence by an equivalent positive Boolean combination of exact-counting-sentences:

• Each sub-formula of the shape is equivalently replaced by the disjunction of all exact-counting-sentences for all .

• Consider a sub-formula of the shape , where, for an , is an -type with centres and is a sub-tuple of of length . This formula is -equivalent to the disjunction of all type-formula for all with (recall from Lemma 2 that is a set of representatives of the isomorphism classes of all -bounded -types with centres over ).

Clearly, the resulting formula also has locality radius . The time complexity of the algorithm is determined by the upper bounds provided by Theorem 4 and Lemma 2. A detailed analysis is deferred to Appendix A.1. ∎

In the following two sections, we will describe how counting-sentences and type-formulae can be turned into bsnf-formulae.

### 3.2 From Counting-Sentences to BSNF

In this section, we show that every counting-sentence can be turned into a bsnf-sentence that is equivalent to – not only on a class of structures of bounded degree, but on the class of all structures.

###### Lemma 6.

There is an algorithm which, on input of a counting-sentence computes an equivalent sentence in bsnf in time .

• The algorithm distinguishs on the possible shapes of the counting-sentence . In each case, it is easy to verify that the provided bsnf-sentence is indeed equivalent to .

• A threshold-counting-sentence with is equivalent to the bsnf-sentence

 ∃y1⋯∃yk∀z⎛⎝⋀1≤i
• An exact-counting-sentence with is equivalent to the bsnf-sentence

 ∃y1⋯∃yk∀z⎛⎝⋀1≤i
• An exact-counting-sentence is equivalent to the bsnf-sentence .

The analysis of the time complexity of the algorithm boils down to an analysis of the size of the constructed bsnf-sentence and is deferred to Appendix A.2. ∎

### 3.3 From Type-formulae to BSNF

Aim of this section is to turn type-formulae into -equivalent formulae in bsnf.

###### Lemma 7.

There is an algorithm which, on input of a degree bound with , a relational signature , and a type-formula , where, for some and , is an -type with centres over , computes a formula in bsnf that is -equivalent to and that has locality radius . The algorithm runs in time

 2νd(n(2r+1))O(∥σ∥).
• We describe the algorithm on input of a degree bound with , a relational signature , and a type-formula . Let and be the radius and the number of centres of , respectively. I.e., and has the shape for a -structure and centres such that .

Suppose that , for a suitable , are the connected components of . Then, each of the centres of belongs to precisely one of the structures , and each of the structures contains at least one of these centres. For each ,

• let denote the number of centres among that belong to , and

• let with be the non-empty set of indices of all centres that belong to , i.e., such that if, and only if, , and

• let .

Note that, as a consequence of Lemma 1, for each when choosing

 ri :=ℓi(2r+1) > r+(ℓi−1)(2r+1).

Furthermore, if are distinct and , , then and have distance in . I.e., and do not intersect and there are no edges in the Gaifman graph of between elements of the two sets (see Figure 1 for an illustration).

The following claim is the crucial step in constructing the desired bsnf-formula. It shows that for each there is a “type-formula” for the -type which is -local around the single variable (instead of being local around all its free variables) and which additionally verifies that the centres belonging to the other connected components of are sufficiently far away.

###### Claim 1.

Let . There is an -formula which is -local around the single free variable  such that the following holds: If is a -bounded -structure and , then if, and only if, the following conditions are satisfied:

1. and

2. for each , the sets and do not intersect and there are no edges in the Gaifman graph of between elements of the two sets.

Before proving Claim 1, let us first show how these local formulae can be used to obtain the final bsnf-formula that is -equivalent to .

For this, let be a variable that is distinct to each of the variables in the tuple . For each , let be the tuple of variables obtained from by replacing the variable with . Then, can be chosen as the formula

 αB(¯¯¯x) :=∀yk⋀i=1(y=xpi,1 → γi(¯¯¯xi)).

In particular, note that each of the formulae for is -local around and thus, the whole universally quantified subformula of is -local around . The -equivalence of ) to can easily be shown using the assumption on the shape of and the two conditions of Claim 1.

We now turn to the proof of Claim 1. Let and let denote a set of representatives of the isomorphism classes of all -bounded -types with centres such that , i.e., all elements have distance at most from , and .

###### Claim 2.

For each -type , there is an -formula that is -local around the free variable and for each -bounded -structure and all , it holds that if, and only if, the following conditions hold:

1. Condition (2) of Claim 1 holds. I.e., for each element with , the distance of to each of the elements is at least .

Observe that, by definition of the set , for each -bounded -structure and every tuple , if, and only if, there is an -type such that . Thus, using the formulae provied by Claim 2, we can let be the disjunction of the formulae for all . In particular, is -local around  since already each of the formulae for is -local around .

For the proof of Claim 2, consider an -type from . The formula extends the formula from Page 2. Suppose that for a suitable . Let be a conjunction of all atomic and negated atomic formulae over the signature such that . Furthermore, choose such that for all . With this, we define as

 ∃z1⋯∃zN(⋀\mathclap1≤j≤Ndist(xpi,1,z