Abstract
Weighted First-Order Model Counting (WFOMC) is a fundamental task for probabilistic inference in relational models. While the two-variable fragment of first-order logic ($FO^2$) is theoretically domain-liftable, existing implementations often struggle with complex sentences and large domains. This paper presents FASTWFOMC, a highly optimized algorithm that utilizes a novel "cell graph" representation and symmetry-breaking techniques. By grouping functionally identical "cells" into symmetric cliques, FASTWFOMC achieves significant performance gains, scaling to domain sizes previously unreachable by state-of-the-art tools like FORCLIFT.
Introduction
Weighted First-Order Model Counting (WFOMC) involves calculating the total weight of all possible worlds satisfying a set of logical rules over a given domain. This task is central to inference in Markov Logic Networks and various combinatorial problems. Although $FO^2$ was proven to be domain-liftable—meaning its complexity is polynomial in the domain size $n$—practical performance has remained a bottleneck. Existing tools like FORCLIFT often fail when logical sentences become complex because the number of "cells" (ways an individual can satisfy predicates) grows exponentially with the number of predicates.
Methods
FASTWFOMC transforms the theoretical foundations of $FO^2$ liftability into a high-performance implementation. The core data structure is the Cell Graph, a complete graph where nodes represent consistent sets of literals for a single variable (cells) and edges represent their interactions.
The algorithm incorporates several key optimizations:
- Knowledge Compilation: Utilizing a d-DNNF compiler (DSHARP) to pre-process logical sentences, enabling nearly instantaneous repeated model-counting calls.
- Model Enumeration: Pruning the search space by ignoring "impossible" cells.
- Weight-Awareness: Simplifying summation formulas by identifying independent sets within the cell graph.
- Dynamic Programming: Employing memoization to avoid redundant sub-problem calculations.
- Cell Symmetries: Identifying "symmetric cliques"—groups of cells that interact identically with the rest of the domain—and treating them as single pseudo-nodes.
This symmetry-breaking approach is a primary driver of the algorithm's efficiency, preventing the exponential explosion typically associated with increasing predicate counts.
Results
The authors evaluated FASTWFOMC against FORCLIFT on several combinatorial benchmarks, including 3-regular graphs, 4-coloured graphs, derangements, and 3-matchings.
In the 3-regular graphs benchmark, FORCLIFT timed out at a domain size of $n=30$, whereas FASTWFOMC scaled to $n=150$ in under 6 seconds. For 4-coloured graphs, FASTWFOMC provided exact results twice as fast as FORCLIFT's approximate implementation. In the 3-matchings case, FASTWFOMC was approximately five times faster at $n=40$. The only exception was the "derangements" problem, where FORCLIFT's specific recursion rules allowed it to solve the problem in near-constant time, whereas FASTWFOMC showed polynomial growth.
Conclusion
FASTWFOMC demonstrates that significant engineering, particularly in structural symmetry and graph-based decomposition, is required to realize the practical potential of theoretical domain-liftability. While $FO^2$ is expressive, future work aims to extend these techniques to more complex fragments like $S^2FO^2$ and improve heuristics for identifying symmetric cliques. Integrating these methods more deeply with counting quantifiers ($C^2$) remains a key objective for further performance optimization.
Summary updated