---
title: "A Fast Algorithm for Consistency Checking Partially Ordered Time"
authors:
  - "Leif Eriksson"
  - "Victor Lagerkvist"
doi: "10.24963/ijcai.2023/212"
url: "https://ijcai.org/proceedings/2023/212"
pdf: "https://ijcai.org/proceedings/2023/0212.pdf"
venue: "Proceedings of the Thirty-Second International Joint Conference on Artificial Intelligence"
year: 2023
pages: "1911-1918"
track: "Main Track"
keywords:
  - "Knowledge Representation and Reasoning: KRR: Qualitative, geometric, spatial, and temporal reasoning"
  - "Constraint Satisfaction and Optimization: CSO: Constraint satisfaction"
---

# A Fast Algorithm for Consistency Checking Partially Ordered Time

Leif Eriksson, Victor Lagerkvist

*Proceedings of the Thirty-Second International Joint Conference on Artificial Intelligence*, pages 1911-1918. DOI: [10.24963/ijcai.2023/212](https://doi.org/10.24963/ijcai.2023/212)

## Abstract

Partially ordered models of time occur naturally in applications where agents/processes cannot perfectly communicate with each other, and can be traced back to the seminal work of Lamport. In this paper we consider the problem of deciding if a (likely incomplete) description of a system of events is consistent, the network consistency problem for the point algebra of partially ordered time (POT). While the classical complexity of this problem has been fully settled, comparably little is known of the fine-grained complexity of POT except that it can
be solved in O*((0.368n)^n) time by enumerating ordered partitions. We construct a much faster algorithm with a run-time bounded by O*((0.26n)^n), which, e.g., is roughly 1000 times faster than the naive enumeration algorithm in a problem with 20 events. This is achieved by a sophisticated enumeration of structures similar to total orders, which are then greedily expanded toward a solution. While similar ideas have been explored earlier for related problems it turns out that the analysis for POT is non-trivial and requires significant new ideas.

## Full text

## 1 Introduction

Qualitative reasoning is an important formalism in artificial intelligence where the objective is to reason about continuous properties given certain relations between the unknown entities. Two important subfields are temporal reasoning, e.g., the point algebra for partially ordered time (POT), Allen's interval algebra (ALLEN), and the point algebra for branching time, and spatial reasoning, e.g., the region connection calculus (RCC), the cardinal direction calculus, and the rectangle algebra. There are numerous applications of all of these formalisms in AI, e.g., in knowledge representation [Forbus, 2019], linguistics [Allen, 1984; Song and Cohen, 1988], and planning [Allen, 1991; Allen et al., 2014; Nogueira et al., 1996; Song and Cohen, 1996]. For a broad overview with further applications and references we refer to the survey by Dylla et al. [2017].

In this paper we are interested in constructing fast (but superpolynomial) algorithms for NP-hard temporal reasoning problems, with a particular focus on the POT problem.

∗ Partially supported by the Swedish research council (VR) under grant 2019-03690.

Figure 1: A scenario with tree tasks T1, T2, T3 where T1 precedes T3, T1 and T2 are incomparable, and where either T2 precedes T3, or T3 precedes T2.

![Image](https://ijcai.org/proceedings/2023/fulltext/212/image_000000_bc854538e617dbfc7740108fe3f1ad9ebb93caa5f0a92e685994f69675451bc0.png)

Here, the basic task is to check whether a given set of events and a set of possible relationships between them is consistent in the sense that there exists some partial ordering of the events which does not contradict any of the given relationships. Thus, this model of time is suitable in applications where we are working with agents/processes who cannot perfectly communicate with each other and where a global, totally ordered model of time is not possible, e.g., in distributed or concurrent systems [Anger, 1989; Anger et al., 1999; Lamport, 1986]. There are many possible formulations of the basic computational problem and we consider the setup where the possible basic relations among two points in time are less than (&lt;), greater than (&gt;), incomparable to (||) and equivalent to (=), i.e., the basic operations of the well-known point algebra [Ladkin and Maddux, 1994]. To make it possible to encode complex relationship between events we follow Broxwall &amp; Jonsson [2003] and allow disjunctions of the basic relations. Crucially, disjunctions make it possible to model incomplete relationships between tasks, e.g., we are given two tasks, where one of them started the other but we lack the knowldge of which one was first. See Figure 1 for a visualization of a constraint network with three tasks (where {&lt;, &gt;} means that &lt; or &gt; is true). This network is satisfiable since the tasks can be ordered as T1 &lt; T3, T2 &lt; T3 where T1 and T2 are incomparable. Let us also remark that all of the aforementioned problems can be formulated as infinite-domain constraint satisfaction problems (CSPs) over ω-categorical constraint languages [Bodirsky and Jonsson, 2017]. In this framework one first fixes a set of binary basic relations B and then consider CSP(B∨=) where B∨= = ⋃R∈B R is the union of the basic relations. For example, the POT problem can then be formulated as a CSP problem where the basic relations are formed over the random partial order (cf. Chapter 2 in Bodirsky [2021]).

## 1.1 RelatedWork

Significant attention has been devoted to finding maximally tractable subclasses of these problems, typically accomplished by local consistency methods, and for e.g. RCC-5, RCC-8, ALLEN, and POT, all maximal, tractable classes have been identified [Dylla et al., 2017]. If one extends to arbitrary first-order reducts of the basic relations the satisfiability problem of POT has a complexity dichotomy by Kompatscher &amp; Pham [2017], while the corresponding problem for RCC is generally undecidable. But, naturally, we cannot be content with merely understanding the tractable fragments, since their expressive power is too restrictive to be able to model real-world problems. Hence, we need methods for solving NP-hard reasoning tasks as fast as possible. To expand our understanding of the NP-hard cases we would thus like to (1) construct algorithms faster than exhaustive search, and (2) prove that certain types of speedups are not possible, subject to stronger complexity theoretical assumptions than P ̸= NP. Complexity questions like these, especially for a precise complexity parameter such as the number of variables, n, typically fall under the scope of fine-grained complexity. Thus, given a reasonable set of basic relations B, how fast can we expect to solve CSP(B∨=) (which might be NP-hard even if CSP(B) is tractable)? Here, let us first remark that any CSP(B∨=) problem is solvable by an exhaustive backtracking algorithm in 2O(n2 ) time, under mild assumptions on the set of basic relations B (e.g., that CSP(B) is solvable in polynomial time). However, for several prominent problems in qualitative reasoning, including POT, it is possible to argue that the 2O(n2 ) bound is too naive to be used as a baseline for improvement. Instead, these problems can be solved in 2O(n logn) time by enumerating ordered partitions [Jonsson and Lagerkvist, 2017; Jonsson et al., 2021], pushing down the running time to O∗ ((2n)2n ) for ALLEN, O∗ ((0.531n)n ) for RCC-8 and O∗ ((0.368n)n ) for RCC-5 and POT 1 . Thus, these problems can be solved by enumerating objects similar to assignments in finite-domain CSPs, and the question is then whether it is possible to solve the problem faster than exhaustively enumerating all orderings, similar to how it is a major open question whether CNF-SAT is solvable in O∗ (cn ) time for some c &lt; 2. This is indeed known to be possible for certain reasoning problems, e.g., ALLEN, which recently has been solved in O∗ ((1.0615n)n ) time [Eriksson and Lagerkvist, 2021], and if the problem is restricted to intervals of length one then it can even be solved in 2O(n log log n) time [Dabrowski et al., 2020], and if no point occurs inside more than k intervals then it can be solved in O∗ (kn ) time [Eriksson and Lagerkvist, 2022]. A faster f(k)n time algorithm, for some function f, is also known for the special case of POT where a solution with effective width of at most k is asked for [Eriksson and Lagerkvist, 2022]. However, despite these improvements, we are still far away from an unconditional single-exponential O∗ (cn ) time algorithm and even further away from the best-known lower bounds which only rule out subexponential algorithms running in 2o(n) time under the exponential-time hypothesis [Jonsson et al., 2021]. Hence, cutting-edge research suggests that qualitative reasoning problems in many cases admit significantly improved algorithms even though general single-exponential running times seem to be out of reach with existing methods.

1 The notation O∗ (·) suppresses polynomial factors.

## 1.2 Our Contribution

In this paper we advance this frontier by describing a novel and significantly improved algorithm for the POT problem with a running time of O∗ ((0.26n)n ), which is much faster than the previously known baseline of O∗ ((0.368n)n ). Hence, our algorithm is not only a showcase that an improved algorithm is possible for POT but significantly beats the naive upper bound based on enumerating ordered partitions. We achieve this as follows: after introducing the necessary technical background (in Section 2) we start our work on POT in Section 3. We analyze the structures of potential solutions and use greedy choices to find a structure that is suitable for enumeration and which yields a significant improvement over enumerating ordered partitions. The basic idea is to group variables into pairs and then order these pairs relative to each other instead of all variables individually, and ordering the variables in each pair can thereafter be done greedily. Hence, the basic idea is not that complex, but actually proving soundness and completeness of our approach is non-trivial and requires novel techniques. Finally, we conclude our results in Section 4 and present a discussion over how these algorithms and the ideas behind them might be open to further improvements and what other problems these ideas may be applicable to. Notably, can the algorithm be adapted to solve RCC-5 or RCC-8, and how far can we push the upper bound with this algorithmic technique?

## 2 Preliminaries

Given a set of finitary relations Γ defined on a (potentially infinite) set D of values, we define the constraint satisfaction problem over Γ (CSP(Γ)) as follows.

## CSP(Γ)

Instance: A tuple (V,C), where V is a set of variables and C a set of constraints of the form R(v1, . . . , vt), where t is the arity of R ∈ Γ and v1, . . . , vt ∈ V .

Question: Is there a function f : V → D such that (f(v1), . . . , f(vt)) ∈ R for every R(v1, . . . , vt) ∈ C?

The set Γ is referred to as a constraint language and the function f is sometimes called a satisfying assignment of an instance, I, or simply a model of I. We write ||I|| for the number of bits required to represent an instance I of CSP(Γ).

## Definition 1. We define the following orders:

1. A pair (S, ≤) is a partial order if ≤ is reflexive (∀x ∈ S then x ≤ x), antisymmetric (∀x, y ∈ S, if x ≤ y and y ≤ x then x = y), and transitive (if x ≤ y and y ≤ z then x ≤ z).

2. A pair (S,&lt;) is a strict partial order if &lt; is irreflexive, asymmetric (∀x, y ∈ S, if x &lt; y then y &lt; x does not hold), and transitive.
3. A pair (S, ≤) is a total order if ≤ is reflexive, antisymmetric, transitive and strongly connected (∀x, y ∈ S then x ≤ y or y ≤ x).

If ⊙ ∈ {&lt;, &gt;, ||, =} and P = (S, ≤P ) is a partial (or total) order then we write ⊙P for the relation induced by P : x &lt;P y if x ≤P y and y ≤P x does not hold, conversely for &gt;P , ||P if neither x ≤P y nor y ≤P x, and x =P y if x ≤P y and y ≤P x. We now define the main problem of the paper.

## PARTIALLY ORDERED TIME

Instance: A set of variables V and a set of binary constraints C where c ⊆ {&lt;, &gt;, ||, =} for each c(x, y) ∈ C. Question: Is there a partial order P = (S,≤) with |S| ≤ |V | and a function f : V → S such that for every constraint c(x, y) ∈ C, f(x) ⊙P f(y) for some ⊙ ∈ c?

Alternatively one can also use the random partial order P , i.e., the (unique) countable partial order which is universal (contains an isomorphic copy of every finite partial order) and is homogeneous (any isomorphism between finite substructures can be extended to an automorphism of P). Then, the POT problem can equivalently well be defined as CSP(RP) where RP is the closure of {&lt;P , &gt;P , ||P , =P } under union (cf. [Bodirsky, 2021]).

## 3 Partially Ordered Time

Our approach to beat the naive O∗ ((0.368n)n ) algorithm for POT involves exploring a carefully selected group of partial orders. The algorithm, in particular, organizes variables into pairs where we only have to consider a relative ordering with n2 other variables. This scheme leads to a runtime that is dominated by n!/2 n2 . Demonstrating the correctness of this strategy is a nontrivial task, and the analysis itself is arguably as interesting as the precise bound we attain.

## 3.1 Definitions

We start by introducing the concepts necessary for the soundness and completeness proofs of the main algorithm.

Definition 2. If P = (S,≤P ) and P ′ = (S′ ,≤P ′) P are two partial orders then P is a stub of P ′ if S ⊆ S′ and ≤P ⊆≤P ′ .

We chose to represent our instances as (multi-)relational networks rather than as sets of constraints. This will give us more flexibility when adding additional restrictions to our instances, since it allows us to limit ourselves to sets of partial orders under some restrictions.

Definition 3. For an arbitrary POT instance I = (V, C) we define two different variants of relational networks:

1. A function f : V 2 -→ {&lt;,&gt;, ||,=} is a relational network (over V ), if for every constraint c(x, y) ∈ C then f(x, y) ∈ c(x, y). We also say that f is a relational network for I.
2. A function f : V 2 -→ P({&lt;,&gt;, ||,=}) is a multi relational network if for every constraint c(x, y) ∈ C then

f(x, y) ⊆ c(x, y). We also say that f is a (multi) relational network for I.

If I is a 'yes'-instance, i.e. there exists a partial order (S,≤P ) such that for all c(x, y) ∈ C then x ⊙P y with ⊙ ∈ c(x, y), we say that f is a consistent (multi) relational network.

We will occasionally view (multi) relational networks as sets of constraints in the obvious way. For example, if f is a multi relational network of an instance I = (V,C), then f ∪ {x{&lt;,&gt;}y} is equivalent to the multi relational network for the instance (V, C ∪ {x{&lt;, &gt;}y}).

Definition 4. Consider the set of all multi relational networks over a fixed set V .

1. For two distinct multi relational networks f and f ′ over V we write f ⪯ f ′ if f(x, y) ⊆ f ′ (x, y) for all x, y ∈ V .
2. We write f ≺ f ′ for the corresponding irreflexive order.
3. A multi relational network f is said to be maximally general if it is a maximal element in ⪯, i.e., there does not exist f ′ such that f ≺ f ′ .

A solution for a POT instance I with relational network f can now be represented by a relational network g ⪯ f . This will be convenient since it eliminates the need to refer to fixed values in the context of a solution.

We also need a local consistency definition for our multi relational networks.

Definition 5. A multi relational network f over V is (locally) consistent over s ⊆ V if f(x, y) = ⋃ gi(x, y), x, y ∈ s where {g1, . . . , gn} is the set of all consistent relational networks gi ⪯ f over s.

Next, we define the central concept of composing a partial order with a multi relational network, roughly meaning that the partial order is used to simplify the multi relational network as much as possible.

Definition 6. Given a POT instance I = (V, C) with multi relational network f and a partial order P = (V,≤P ), we define the POT instance

<!-- formula-not-decoded -->

Note that P ◦f may have cases where f (x, y) = ∅, meaning that there is no partial order P ′ = (V,≤P ′) satisfying I for which P is a stub.

Lemma 7. Let I = (V, C) be a POT instance with multi relational network f. If there exists a partial order P = (V, ≤P ) such that P ◦ f is a 'yes'-instance then I is a 'yes'-instance.

Proof. By Definition 6, (P ◦ f) ⪯ f and hence we have that (P ◦ f)(x, y) ⊆ c(x, y) for all c(x, y) ∈ C. So, if there is an assignment satisfying P ◦ f, the same assignment must also satisfy I.

We are now ready to present the limited set of partial orders that we are interested in enumerating.

Definition 8. A total ordering of pairs (TOP) is a partial order P = (V, ≤P ) such that for every x ∈ V there is at most one y ∈ V \ {x} such that x||P y. We say that (x, y) is a pair in P if x||P y.

We will use the notation (a1, b1) &lt;P . . . &lt;P (ai, bi) for writing (part of) a TOP P. Here (aj, bj) are our pairs for j ∈ {1, . . . , i}. Note that we do not make a difference between (aj, bj) and (bj, aj).

Now we are ready to start applying TOPs on multi relational networks, see what important structures can occur and, most importantly, investigate why this is beneficial and determine for which cases the output is still difficult to solve.

Definition 9. Given a TOP P and a multi relational network f of a POT instance, a link in P ◦ f is a non-empty sequence of pairs (a1, b1) &lt;P . . . &lt;P (an, bn) such that

1. (P ◦ f)(ai, bi) \ {=} = {&lt;,&gt;},
2. (P ◦ f)(ai, aj) \ {=} = {&lt;}, 1 ≤ i &lt; j ≤ n,
3. (P ◦ f)(bi, bj) \ {=} = {&lt;}, 1 ≤ i &lt; j ≤ n, and
4. || ∈ (P ◦ f)(ai, bj), i ̸= j.

Two links overlap if they share any pairs.

Note that a single link does not need to contain more than a single pair. Also, two links sharing the same pairs, e.g. (a, b) and (b, a), are technically the same link. This is just two different representations, or directions, of the same link, which will be relevant for the following important concept.

Definition 10. Given a TOP P and multi relational network f for some POT instance, a chain in P ◦ f is two variables x &lt;P y with (P ◦ f)(x, y) \ {=} = {||} and a non-empty sequence of m links

<!-- formula-not-decoded -->

## such that

1. either x = b1,1 or (P ◦ f)(x, b1,1) ⊆ {&lt;,=},
2. either y = am,n′ or (P ◦ f)(am,n′ , y) ⊆ {&lt;,=},
3. P ◦ f(ai,ni , bi+1,1) \ {=} = {&lt;},
4. (P ◦ f)(ai,i′ , aj,j ′) \ {=} = {&lt;, ||}, i &lt; j, i′ ∈ {1, . . . , ni}, j ′ ∈ {1, . . . , nj} and

<!-- formula-not-decoded -->

We say that a chain is broken if (P ◦ f)(ai,i′ , bi,i′ ) = {&lt;} for all i′ for some i. The length of a chain is the number of links m in the chain. We say that x is the head of the chain and y the tail.

While we here differ between (a, b) and (b, a) in contrast to how we did for TOPs, it should be clear by the context when it is of importance or not, i.e. when we are speaking of chains and when we are only discussing (parts of) a TOP.

## Example 11. Take the TOP

<!-- formula-not-decoded -->

Figure 2: Graphic representation of two chains overlapping in one link (a3, b3), as described in Example 11. Variables/pairs to the left are ordered before those to the right in our TOP and hence we assume either a &lt;- or a ||-relation going from left to right.

![Image](https://ijcai.org/proceedings/2023/fulltext/212/image_000001_6aa002ceda8661292b22d4150705878ec93547c9542b6b192689152b8390fbe6.png)

f(ai, bi) = {&lt;,&gt;}. We now have five links: (a1, b1), (a2, b2) &lt;P (a3, b3), (b3, a3), (b4, a4) and (b5, a5). We also have two chains: (a1, b1) &lt;P (b3, a3) &lt;P (b4, a4) and (a2, b2) &lt;P (a3, b3) &lt;P (b5, a5). Here (a2, b2) &lt;P (a3, b3) and (b3, a3) contain the same pair in a3, b3, but their directions differ, and hence these links overlap in the opposite directions.

This example is also visualized in Figure 2.

Before we prove that T ◦ f is solvable in polynomial time for any total order T we introduce the following comparability property of partial orders.

Definition 12. Given two relational networks f and g over the same variable set V , f is ||-larger than g if, for any variables x, y ∈ V :

1. if g(x, y) = {||} then f(x, y) = {||},
2. if g(x, y) = {&lt;} then f(x, y) ∈ {&lt;, ||},
3. if g(x, y) = {&gt;} then f(x, y) ∈ {&gt;, ||},
4. if g(x, y) = {=} then f(x, y) ∈ {&lt;,&gt;, ||,=},

and there exists x, y ∈ V such that g(x, y) ̸= f(x, y).

Furthermore, we say that f is ||-maximal if there does not exist any g which is ||-larger than f.

## 3.2 The Algorithm

We begin by showing how to solve T ◦ f in polynomial time for a total order T .

Lemma 13. Let I = (V,C) be a POT instance with multi relational network f and let T = (V,&lt;T ) be a total order. Then T ◦ f is solvable in polynomial time.

Proof. Solving T ◦ f can be done by enforcing consistency for each triple x, y, z ∈ V , e.g., if f(x, y) = {&lt;} and f(y, z) = {&lt;} then f(x, z) = {&lt;}. We repeat this until no more changes occur. If any f(x, y) = ∅ then T ◦ f must be a 'no'-instance, otherwise it is a 'yes'-instance. Soundness for this approach follows naturally. To see that this approach is complete take the ||-maximal relational network g which can give T when topologically sorted. Since I given T is a

'yes'-instance, g must exist. After the first round of local consistency propagation the following must be true for all triples x &lt;T y &lt;T z for our f:

1. if = ∈ f(x, z) then = ∈ f(x, y) and = ∈ f(y, z), or || ∈ f(x, y) and || ∈ f(y, z),
2. if &lt; ∈ f(x, z) then f(x, y) = f(y, z) cannot equal =, and
3. if || ∈ f(x, z) then || ∈ f(x, y) or || = f(y, z).

Similarly, g(x, y) ∈ f(x, y). By then removing =-relations from any |f(x, y)| &gt; 1 the relations g(x, y) ∈ f(x, y) must still be true and hence the network is still a 'yes'-instance. Again, we enforce consistency for triples until no changes occur. For any triple x &lt;T y &lt;T z, where g(x, y), g(x, z) and g(y, z) are not equal to {=}, it then still holds that if || ∈ f(x, z) then || ∈ f(x, y) or || ∈ f(y, z). Hence, for every || ∈ f(x, y) we can assume f(x, y) = {||} and still have a 'yes'-instance. In fact, f = g since g is ||-maximal. Hence, if I is a 'yes'-instance and if there is any relational network for I that topologically sorts to T, we will answer 'yes'.

For the complexity, we only need to propagate complexity for variable triples, and each propagation cycle must remove at least one relation from f, else no change is made. As there are at most four possible atomic relations between each variable pair, the number of cycles is polynomially bounded by O(|V |2 ). Hence, this approach can be done in polynomial time.

Why it is actually interesting to solve T ◦ f in polynomial time is shown by the following lemma.

Lemma 14. If a POT instance I with multi relational network f is a 'yes'-instance then there is a total order T such that T ◦ f is a 'yes'-instance.

Proof. We remind the reader that we can represent a solution for I with a relation network. Take any relational network g satisfying I and the partial ordering P described by this relational network. Topologically sort P to a total order T. From the definition of T ◦ f we know that T ◦ f(x, y) = f(x, y) \ {&gt;} if x &lt;T y. As x ̸&lt;T y if g(x, y) = {&gt;}, g must be consistent with T ◦ f and hence g is also satisfies T ◦ f, proving the lemma.

As a sanity check for making sure that an instance does not have small subinstances that are 'no'-instanses, i.e. the instance is localy consistent, we prove the following lemma. Recall that ||f|| is the number of bits needed to represent f.

Lemma 15. For any multi relational network f, integer k &gt; 0 and a set of variables s ⊆ V with |s| ≤ k, a maximally general multi relational network f ′ ⪯ f which is locally consistent with s can be computed in h(k) · ||f||O(1) time for some computable function h(k).

Proof. Let {g1, . . . , gm} be the set of all consistent relational networks g ⪯ f over s. For each s, there are roughly 16|s|2 potential gis as we have four different relations that can either be allowed, or not allowed, between each pair of variables in s. Each potential gi can be compared to f to check for consistency in ||f||O(1) time as ||gi|| ≤ ||f||. Now, for each pair x, y ∈ s let f ′ (x, y) = ⋃ gi(x, y) and for all pairs where either x ̸∈ s or y ̸∈ s let f ′ (x, y) = f(x, y). Since |s| ≤ k the number of possible 16|s|2 and the complexity of constructing f ′ is bounded by h(k) for some computable function h: N→N. Clearly, f ′ ⪯ f, and since we enumerated all possible relations between all pairs in s, f ′ must also be the largest such multi relational network.

Now, we are ready to introduce the first of the two main gadgets necessary for our later proofs. For a partial order P = (V,≤) and distinct x, y ∈ V we write P x&lt;y for (V, ≤ ∪{(x, y)}). While this operation may technically produce structures that are not partial orders (e.g., x &lt;P y &lt;P x), we in the forthcoming definitions will only use it on pairs in TOPs where the result is always guaranteed to be a partial order.

Definition 16. For a TOP P = (V, ≤) and a multi relational network f over V we describe a partial function Rpar defined according to the following rules.

1. Rpar(P, f) = (P, f) if P is a total order,
2. Rpar(P, f) = R(P x&lt;y , f) if there exists distinct x, y ∈ V with x||P y and &lt;̸∈ (P ◦ f)(x, y),
3. Rpar(P, f) = R(P ai&lt;bi ) if there exists a link (a1, b1) &lt; · · · &lt; (ak, bk) such that there is no other link (c1, d1) &lt; · · · &lt; (ck′ , dk′ ) for which ai = di′ and bi = ci′ for any i and i′ ,
4. Rpar(P, f) = Rpar(P, f ′ ) if there exists a, b, c, d ∈ V and a maximally general multi relational network f ′ ̸= f , f ′ ⪯ f and locally consistent with {a, b, c, d}.

It is easy to see that if Rpar(P, f) = (T, f) is defined then it returns a total order T such that P is a stub of T . We then consider the following extension of Rpar which is guaranteed to be totally defined due to the second rule.

Definition 17. For a TOP P = (V, ≤) and a multi relational network f over V we describe a total function Rtot defined according to the following rules.

1. Rtot(P, f) = Rpar(P, f) if Rpar(P, f) is defined, and
2. Rtot(P, f) = Rtot(P x&lt;y , f) if there exists x, y ∈ V where {&lt;, &gt;} ⊆ (P ◦ f )(x, y).

Note that Rtot will always return a total order, since otherwise the second rule could be applied. However, the function is not sound and can given a 'yes'-instance P ◦ f return a 'no'-instance T ◦ f. Even so, this function will be the one we later use for solving POT instances.

As a second extension of Rpar, we introduce the total function Rcorr. This function will computationally be more expensive than Rtot, but with the trade-off that it in the second step makes sure extending the given TOP with x &lt; y is actually a reasonable choice that does not get the function stuck with a 'no'-instance. Thus, if extending the partial order by x &lt; y would yield a 'no'-instance, Rcorr (in contrast to Rtot) simply stops and returns (P, f).

Definition 18. For a TOP P = (V, ≤) and a multi relational network f over V we describe a total function Rcorr defined according to the following rules.

1. Rcorr(P, f) = Rpar(P, f) if Rpar(P, f) is defined.
2. Rcorr(P, f) = Rcorr(P x&lt;y , f) if there exists x, y ∈ V with {&lt;,&gt;} ⊆ (P ◦ f)(x, y) and where P ◦ (f ∪ {x{&lt;, ||, =}y}) is a 'yes'-instances, and
3. Rcorr((P, f)) = (P, f) otherwise.

Note that Rcorr differs fromRtot in the sense that if Rcorr (via the second rule) is given a 'yes'-instance it also guarantees that the output is a 'yes'-instance. The precise relation between Rtot and Rcorr will be of much interest to us. In fact, we will show that if f is a 'yes'-instance, then there must exist a TOP such that Rtot = Rcorr. We begin with the following lemma.

Lemma 19. For an arbitrary POT instance with multi relational network f and some arbitrary TOP P = (V,≤P ), Rtot(P, f) can be computed in poly(||I||) time and space.

Proof. Step 1 and 2 of Rpar and step 2 of Rtot are quite clearly polynomial. Since there are |V |4 sets of four variables, step 4 of Rpar is polynomial by Lemma 15. Last, step 3 of Rpar is polynomial since there are at most |V |/2 pairs, and finding if they are part of some chain (and in which directions) can be done in polynomial time. Hence, all steps of Rtot are doable in polynomial time.

Using Rtot(P, f) = (T, f ′ ) we are now left with T ◦ f ′ , which we can solve in polynomial time according to Lemma 13, and if this approach returns true then I must be a 'yes'-instance (via Lemma 7).

Returning to the relationship between Rtot and Rcorr we are now ready to describe the property needed for Rtot(P, f) ̸= Rcorr(P, f) to occur.

Lemma 20. Let P = (V, ≤P ) be a TOP and f a multi relational network over V such that P ◦f is a 'yes'-instance. Then Rtot(P, f) ̸= Rcorr(P, f) only if P ◦ f contains a non-empty set S of chains of length at least two and such that every link of every chain in the set overlaps with some other link in the opposite direction.

Proof. Assume Rtot ̸= Rcorr and S = ∅. The only step where Rtot and Rcorr differ in output is in step 2. Further, assume we have a topological sorting T of some solution for P ◦ f. Whenever Rtot reaches step 2 and for a pair x||Py chooses x{&lt;, =, ||}y, without knowing if this is a good choice or not, we have four different cases that could theoretically occur and are worth considering.

1. If x = y or x||y in our solution for P◦f, then x &lt;T y and y &lt;T x are both valid and will yield the same solution.
2. If x &lt; y in our solution, but y &lt; x in some other, but otherwise identical solution, then x &lt;T y and y &lt;T x are both valid and yield 'yes'-instances.
3. If x &lt; y in our solution and there is no solution with y &lt; x but which is otherwise identical, then there must be two variables u, v such that x ≤ u, v ≤ y and u||v. This describes a link and a chain. Then, either this chain has length one, in which point Step 4 of Rpar will be applicable as local consistency over {x, y, u, v} would not allow the case of y &lt; x, or this chain has length longer than two, but contains a link not overlapping with
4. any other link in the opposite direction. Since there is here a link that does not overlap with any other in the opposite direction, step 3 of Rpar would be applicable and we would set x &lt; y or y &lt; x depending on which one breaks the chain.
4. There are chains of length two or more, but no chain contains any link that does not overlap with some other link in the opposite direction. This matches the definition of chains in S, and hence S is non-empty.

In the first two of these cases Rtot and Rcorr behave identically, and hence yield the same output. For the third one, neither Rtot nor Rcorr reaches their respective step 2, and hence they behave identically. For the fourth case, S is nonempty. So neither of these four cases satisfies our assumption. But our four cases are exhaustive: they cover all relations between x and y in solutions for T ◦ f and all cases for all these relations. So the initial assumptions must be false, meaning that either Rtot = Rcorr or S ̸= ∅, completing the proof.

Before we introduce the final piece of the puzzle, we give two short definitions: one for a sub-class of TOPs that are easier to enumerate and one for our notation for Rtot(P, f ) = Rcorr(P, f ).

Definition 21. A proper total ordering of pairs (PTOP) is a TOP P = (V,≤P ) such that for every x ∈ V either there is exactly one y ∈ V \ {x} such that x||Py or y &lt;P x for all y ∈ V \ {x}.

Definition 22. If for some arbitrary TOP P = (V,≤P ) and relational network f over V , Rtot(P, f) = Rcorr(P, f) we say that P is reducible for f.

And now, finally, we can show, and prove, why Rtot, Rcorr, reducibility and (P)TOPs are interesting for multi relational networks for POT instances.

Lemma 23. For every 'yes'-instance I of POT with multi relational network f, there is a PTOP reducible for f.

Proof. Since I is a 'yes'-instance we have a relational network g satisfying I, and by Lemma 14 we know there is a total order T such that T ◦ f is also satisfied by g.

We start the process of finding a TOP reducible for f by generating (from T) an arbitrary PTOP P such that P is an stub of T. If P is reducible for f, then return P. Otherwise if P is not reducible for f we assume that Rcorr(P, f) = (P, f). Since Rcorr can remove chains of length one by local consistency over quads, we know by Lemma 20 that P ◦ f contains chains longer than two, and such that their links overlap with others in the opposite direction. I.e., we have a link

<!-- formula-not-decoded -->

and a second link

<!-- formula-not-decoded -->

such that there is some a1,i = v2,i′ and b1,i = u2,i′ . Furthermore, we also have a link

<!-- formula-not-decoded -->

that is part of the same chain as

<!-- formula-not-decoded -->

<!-- formula-not-decoded -->

that is part of the same chain as

<!-- formula-not-decoded -->

From all such overlaps, take the overlapping pair with the lowest index in P and call it (x, y). Without loss of generality, assume that g(x, y) = &lt; in our relational network g satisfying both I and T ◦ f. Take the variable y &lt;T z such that g(x, z) = g(z, y) = ||, and such that there is no other variable z′ &lt;T z fulfilling the same conditions. To see that such a variable z actually exists, take the tail x′ and y′ of the chains overlapping in opposite directions in (x, y). Since the chain which includes x and x′ must be broken, and similarly for y and y′ , we must have that g(x, x′ ) = || and g(y, y′ ) = ||. Assume that g(y, x′ ) =&lt;. But since g(x, y) = g(y, x′ ) =&lt; then g(x, x′ ) =&lt; while we assumed g(x, x′ ) = ||, so we have a contradiction. Hence, we have g(x, x′ ) = g(x′ , y) = || and so at least one variable with this property exists and so does our z. In T there is now a sequence x &lt;T y &lt;T x1 &lt;T . . . &lt;T xj &lt;T z. Since z is incomparable to both x and y in g and as z is the least indexed such variable in this sequence, then for all xi in the sequence we have g(z, xi) = ||. Hence, if we construct a new total order T ′ such that x &lt;T ′ z &lt;T ′ y &lt;T ′ x1 &lt;T ′ . . . &lt;T ′ xj but which is otherwise identical to T , then g also satisfies T ′ ◦ f. If we now also construct a new arbitrary TOP P ′ from T ′ our two original links are no longer links for any chains. We repeat this process until the resulting TOP P ′ is reducible for f.

The question is now if the above construction of a reducible PTOP for f halts. To answer this we make the following observation: for each recursion we choose some index i in P such that the pair at i in P ◦ f is changed from a link to a non-link in P ′ ◦ f , without making any new links out of pairs of index less than i that have previously been chosen. Hence the number of pairs at index i or less that cannot become links by choosing a new index j &gt; i has increased by one. Call the pairs at these indexes selected protected. Note that a pair at index i loses its protected status and can become a link again if j &lt; i is chosen, but then the same logic applies to j instead: the number of protected pairs at index j or less has increased. So, in each iteration, either i decreases or the number of protected pairs indexes less than i increases. Hence, the function must reach a point where no pair can be selected and P is reducible for f.

One may ask what happens to chains in P ◦ f that are satisfied by equality in the solution and are hence technically never broken. For all of the links in these chains, the local consistency check in Step 4 of Rpar will keep the equality relation, while Step 2 in Rtot will always produce a 'yes'- instance given a 'yes'-instance when working on the pairs in these links. Hence, these are a non-issue and will be satisfied by our greedy approach (as long the variables are equal in some solution).

We now have everything we need to present the main result for this section:

Theorem 24. Any arbitrary POT instance I = (V, C) with |V | = n is solvable in O∗ (n!/2 n2 ) ⊆ O∗ ((0.2601n)n ) time and poly(||I||) space.

Proof. By Lemma 7 we know that if we find any partial order P such that P ◦ f is a 'yes'-instance, then I must be a 'yes'- instance. From Lemma 23 we know there exists a PTOP P such that P ◦ f is a 'yes'-instance if I is and such that we can solve P ◦ f in polynomial time by applying Lemma 13 to the output of Rtot(P, f), and by Lemma 19 Rtot(P, f) can be calculated in polynomial time. There are n!/2 n2 such PTOPs, and we can, in a polynomial factor on n, enumerate over all PTOPs over V until we find our P . If no 'yes'-instance P ◦ f is found in this way then I must be a 'no'-instance, again by Lemma 23, and we can safely answer 'no'. Via Stirling's approximation of n! we obtain O∗ ((0.2601n)n ).

With Theorem 24 in place, we have now seen the entire chain of reasoning of how enumerating PTOPs is enough to solve any POT instance. While providing a new state of the art.

## 4 Conclusion and Discussion

In this paper we used structural properties on potential solutions for POT instances to achieve a new and significantly improved upper bound. These results, and the techniques used, raise new questions.

A major open question is whether our algorithm for POT can be adapted to other qualitative reasoning tasks such as RCC-5 or RCC-8. The issue here seems to be that the constraints partially overlapping and disjoint are harder to handle than just incomparability. Combined, however, these relations behaves identical to incomparability, so the idea is by no means far-fetched. Partially overlapping enforces a form of upwards transitivity in that every set containing a set A must also be at least partially overlapping with some set B if A and B are partially overlapping. Similarly, disjoint enforces a form of downwards transitivity in that every set contained in C must be disjoint to D if C is disjoint to D. Effectively this introduces some different forms of chains than for POT that require some novel ideas to handle. As a first step, finding a method to handle these chains faster than 2n for n links would be enough to improve the current state-of-the-art.

It is also natural to ask if it is possible to avoid enumerating certain orderings of pairs and thus push down the runtime even further. For example, can we find certain orderings of pairs that will never satisfy our instances? And can we do this fast enough, and often enough, that it yields a significant improvement to the overall runtime? Another promising idea is to partition variables into triples instead of pairs, or quads that are later further restricted to pairs in an intelligent manner. This requires non-trivial changes to our algorithm but does not seem impossible. If this approach can be pushed further, it would likely hit a limit of O∗ (√cnn ) where the local consistency checks would start bottlenecking. Even so, this would be the first o(n)n complexity result for POT and a major advance in solving NP-hard qualitative reasoning problems.

## Acknowledgements

We thank the anonymous reviewers for several insightful comments. The first author is partially supported by the National Graduate School in Computer Science (CUGS), Sweden. The second author is partially supported by the Swedish Research Council (VR) under grant 2019-03690.

## References

1. [Allen et al., 2014] James F. Allen, Henry A. Kautz, Richard N. Pelavin, and Josh D. Tenenberg. Reasoning About Plans. Elsevier Science, 2014.
2. [Allen, 1984] James F. Allen. Towards a general theory of action and time. Artificial Intelligence, 23(2):123-154, 1984.
3. [Allen, 1991] James F. Allen. Planning as temporal reason- ing. In James F. Allen, Richard Fikes, and Erik Sandewall, editors, Proceedings of the 2nd International Conference on Principles of Knowledge Representation and Reasoning (KR-1991). Cambridge, MA, USA, April 22-25, 1991, pages 3-14.
4. Morgan Kaufmann, 1991. [Anger et al., 1999]
5. Frank D. Anger, Debasis Mitra, and Rita V. Rodríguez. Satisfiability in nonlinear time: Al- gorithms and complexity. In Proceedings of the 12th In- ternational Florida Artificial Intelligence Research Society Conference (FLAIRS-1999), pages 406-411, 1999.
6. [Anger, 1989] Frank D. Anger. On lamport's interprocessor communication model. ACM Transactions on Program- ming Languages and Systems, 11(3):404-417, 7 1989.
7. [Bodirsky and Jonsson, 2017] Manuel Bodirsky and Peter Jonsson. A model-theoretic view on qualitative constraint reasoning. Journal of Artificial Intelligence Research (JAIR), 58:339-385, 2017.
8. [Bodirsky, 2021] Manuel Bodirsky. Complexity of Infinite- Domain Constraint Satisfaction. Cambridge University Press, 2021. Preprint available from https://www.math.tu- dresden.de/∼bodirsky/Book.pdf.
9. [Broxvall and Jonsson, 2003] Mathias Broxvall and Peter Jonsson. Point algebras for temporal reasoning: Algorithms and complexity. Artificial Intelligence, 149(2):179-220, 2003.
10. [Dabrowski et al., 2020] Konrad K. Dabrowski, Peter Jons- son, Sebastian Ordyniak, and George Osipov. Fine-grained complexity of temporal problems. In Proceedings of the 17th International Conference on Principles of Knowledge Representation and Reasoning (KR-2020), pages 284-293, 2020.
11. [Dylla et al., 2017] Frank Dylla, Jae H. Lee, Till Mossakowski, Thomas Schneider, André V. Delden, Jasper V. D. Ven, and Diedrich Wolter. A survey of qualitative spatial and temporal calculi: Algebraic and computational properties. ACM Computing Surveys (CSUR), 50(1):7:1-7:39, April 2017.
12. [Eriksson and Lagerkvist, 2021] Leif Eriksson and Victor Lagerkvist. Improved algorithms for Allen's interval alge- bra: a dynamic programming approach. In Proceedings of the 30th International Joint Conference on Artificial Intelligence (IJCAI-2021), pages 1873-1879, 2021.
13. [Eriksson and Lagerkvist, 2022] Leif Eriksson and Victor Lagerkvist. A multivariate complexity analysis of qualita- tive reasoning problems. In Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence, IJCAI-22, pages 1804-1810. International Joint Confer- ences on Artificial Intelligence Organization, 7 2022. Main Track.
14. [Forbus, 2019] K.D. Forbus. Qualitative Representations: How People Reason and Learn about the Continuous World. MIT Press, 2019.
15. [Jonsson and Lagerkvist, 2017] Peter Jonsson and Victor Lagerkvist. An initial study of time complexity in infinite- domain constraint satisfaction. Artificial Intelligence, 245:115-133, 2017.
16. [Jonsson et al., 2021] Peter Jonsson, Victor Lagerkvist, and George Osipov. Acyclic orders, partition schemes and csps: Unified hardness proofs and improved algorithms. Artificial Intelligence, 296:103505, 2021.
17. [Kompatscher and Pham, 2017] Michael Kompatscher and Van T. Pham. A complexity dichotomy for poset constraint satisfaction. In Proceedings of the 34th Symposium on Theoretical Aspects of Computer Science, (STACS-2017), volume 66 of LIPIcs, pages 47:1-47:12. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2017.
18. [Ladkin and Maddux, 1994] Peter B. Ladkin and Roger D. Maddux. On binary constraint problems. Journal of the ACM, 41(3):435-469, 1994.
19. [Lamport, 1986] Leslie Lamport. The mutual exclusion prob- lem: Part i-a theory of interprocess communication. J. ACM, 33(2):313-326, 4 1986.
20. [Nogueira et al., 1996] José Helano Matos Nogueira, Anto- nio L. Furtado, and José de Jesús Pérez Alcázar. A hybrid formal theory of plan recognition and its implementation. In Proceedings of the 13th Brazilian Symposium on Arti- ficial Intelligence, (SBIA-1996), volume 1159 of Lecture Notes in Computer Science, pages 31-40. Springer, 1996.
21. [Song and Cohen, 1988] Fei Song and Robin Cohen. The interpretation of temporal relations in narrative. In Pro- ceedings of the 7th National Conference on Artificial Intel- ligence (AAAI-1998), pages 745-750, 01 1988.
22. [Song and Cohen, 1996] Fei Song and Robin Cohen. A strengthened algorithm for temporal reasoning about plans. Computational Intelligence, 12:331-356, 1996.
