Abstract
The Weighted First-Order Model Counting Problem (WFOMC) asks to compute the weighted sum of models of a given first-order logic sentence over a given domain. The boundary between fragments for which WFOMC can be computed in polynomial time relative to the domain size lies between the two-variable fragment ($ ext{FO}^2$) and the three-variable fragment ($ ext{FO}^3$). It is known that WFOMC for $ ext{FO}^3$ is $\mathsf{\#P_1}$-hard while polynomial-time algorithms exist for computing WFOMC for $ ext{FO}^2$ and $ ext{C}^2$, possibly extended by certain axioms such as the linear order axiom, the acyclicity axiom, and the connectedness axiom. All existing research has concentrated on extending the fragment with axioms on a single distinguished relation, leaving a gap in understanding the complexity boundary of axioms on multiple relations. In this study, we explore the extension of the two-variable fragment by axioms on two relations, presenting both negative and positive results. We show that WFOMC for $ ext{FO}^2$ with two linear order relations and $ ext{FO}^2$ with two acyclic relations are $\mathsf{\#P_1}$-hard. Conversely, we provide an algorithm in time polynomial in the domain size for WFOMC of $ ext{C}^2$ with a linear order relation, its successor relation and another successor relation.
Introduction
Weighted First-Order Model Counting (WFOMC) is a foundational problem in Statistical Relational Learning (SRL), serving as the engine for inference in frameworks like Markov Logic Networks and probabilistic databases. The central challenge in WFOMC is achieving domain-liftability: the development of algorithms that run in time polynomial relative to the domain size $n$.
While it is well-established that the two-variable fragment of logic ($ ext{FO}^2$) is domain-liftable, recent research has pushed these boundaries by adding structural "axioms"—such as forcing a relation to be a linear order or a tree. However, these successes have largely been limited to constraints on a single relation. This paper investigates the "gap" in our understanding of multiple relations: if a system must satisfy structural constraints on two different relationships simultaneously, does the counting problem remain efficient?
The Complexity Boundary: Hardness Results
The authors identify a new complexity boundary by demonstrating that even slight increases in structural complexity can lead to computational intractability.
Two Linear Orders and Acyclicity
The study proves that WFOMC for $ ext{FO}^2$ with two linear order relations is $\mathsf{\#P_1}$-hard. To establish this, the authors use a reduction from a counting variant of the Tiling Problem. In logic, the ability to "force" a grid structure is typically a precursor to hardness. The authors show that two linear orders can be used to encode a grid where every model corresponds to exactly one valid tiling. This allows the encoding of a Turing machine's computation, making the counting of models as difficult as counting the accepting paths of that machine. Similarly, the paper proves that $ ext{FO}^2$ with two acyclic relations is also $\mathsf{\#P_1}$-hard, suggesting that multiple global structural constraints generally move the problem beyond the reach of polynomial-time algorithms.
Algorithmic Breakthroughs for Successor Relations
Despite the negative results for full linear orders, the authors identify a significant positive case involving "successor" relations. A key insight of the paper is the relative "weakness" of a successor relation compared to a linear order; while a linear order relates every element to every other element, a successor relation only constrains immediate neighbors.
Dynamic Programming for $\text{C}^2$
The authors developed a Dynamic Programming (DP) algorithm to prove that $ ext{C}^2$ (two-variable logic with counting quantifiers) remains domain-liftable when combined with a linear order ($L$), its successor relation ($S_1$), and an additional independent successor relation ($S_2$).
This algorithm treats the successor relations as sets of "segments" or broken strings of elements relative to the master linear order. By tracking the number of "heads" and "tails" of these segments for each "1-type" (the set of unary predicates true for a single element), the algorithm can count valid configurations without enumerating them. This demonstrates that while two full orders are intractable, a master order combined with local successor structures remains computationally feasible.
Empirical Evaluation
The paper evaluates the proposed DP algorithm using combinatorial sequences and synthetic scenarios rather than traditional machine learning datasets.
Combinatorial Sequences and the Train Scenario
The authors tested their algorithm against known counting problems from the Online Encyclopedia of Integer Sequences (OEIS), including:
- A000670: Ordered partitions (Fubini numbers).
- A000629: Calculations related to necklaces.
They also introduced a "train station" scenario ($\Phi_{train}$), simulating a real-world constraint satisfaction problem where a train moves between stations with limited "turn-around" capabilities.
Performance Results
When benchmarked against general-purpose model counters like d4 and GANAK, the specialized DP algorithm showed superior scalability. While general counters struggled as the domain size $n$ reached 20–50, the new algorithm handled $n=2000$ with ease. This confirms that for specific structured fragments, specialized lifted algorithms are far more efficient than grounding-based approaches.
Conclusion and Future Work
This research clarifies the limits of domain-liftability in the presence of multiple relations. While the combination of two linear orders is $\mathsf{\#P_1}$-hard, the combination of a linear order with multiple successor relations is domain-liftable.
Future work remains to be done regarding the "Decidability-Counting Gap." While $ ext{FO}^2$ with two successor relations is known to be decidable, this paper confirms it is also liftable. However, for two linear orders, the problem is both undecidable and $\mathsf{\#P_1}$-hard. Determining if there is a formal, unified link between the undecidability of a logic and its counting hardness remains a major open question in the field. Additionally, exploring axioms for multiple trees or equivalence relations could further expand the practical utility of WFOMC.
Summary updated