Introduction
Generating random instances of complex relational structures—such as social networks with specific influence patterns or chemical molecules with particular bonding rules—is a fundamental task in combinatorics and statistical relational learning. However, when these structures are defined by first-order logic constraints, the task becomes computationally daunting. This paper presents the first "domain-lifted" algorithm for sampling models of sentences in the universally-quantified two-variable fragment ($UFO^2$). Unlike traditional methods that scale exponentially with the number of objects, this approach achieves polynomial scaling, enabling the generation of large-scale relational worlds.
The Challenge of First-Order Sampling
The core difficulty lies in the "first-order sampling problem." While significant progress has been made in Weighted First-Order Model Counting (WFOMC), sampling is inherently more complex. In counting, one can exploit the symmetries of the logic to avoid enumerating every possibility. However, in sampling, once a specific assignment is made for one part of the model, the global symmetry is often "broken," potentially leading to NP-hard complexities if a naive reduction from sampling to counting is used.
A "domain-lifted" approach is required: an algorithm whose runtime is a polynomial function of the domain size ($n$), rather than exponential. This ensures that the method remains practical even as the number of entities in the relational model grows.
Methodology: A Two-Stage Lifted Approach
The authors propose a two-stage sampling algorithm specifically designed for $UFO^2$, which consists of logic sentences using only two variables ($x$ and $y$) and universal quantifiers.
1. Type Decomposition
The algorithm begins by decomposing the relational world into unary types (U-types) and binary types (B-types). U-types describe the properties of a single object, while B-types describe the relationship between a pair of objects.
2. Sampling U-Types and B-Types
Instead of sampling properties for each object sequentially, the algorithm first samples a "cardinality vector." This vector specifies how many objects belong to each possible U-type. This step is reduced to a WFOMC task, which is known to be domain-liftable for the $UFO^2$ fragment. Once the distribution of U-types is fixed, the authors demonstrate that the probabilities for relationships between pairs (B-types) become independent. This allows the algorithm to iterate through every pair of objects and sample their relationships in a lifted, efficient manner.
3. Handling Global Constraints
The framework is extended to handle more complex constraints:
- Cardinality Constraints: Using Discrete Fourier Transforms, the algorithm can enforce specific counts (e.g., "exactly $k$ nodes must have property $P$").
- Tree Constraints: By integrating Kirchhoff’s Matrix Tree Theorem, the algorithm can ensure that certain relations form a spanning tree, maintaining the lifted property by computing the number of valid remaining trees at each sampling step.
Experimental Evaluation
The algorithm was evaluated against synthetic benchmarks designed to test its limits:
- k-colored trees: Generating random trees where nodes are assigned one of $k$ colors.
- Friends-Smokers MLN: A standard benchmark in Statistical Relational AI modeling social influence.
In the Friends-Smokers benchmark, the proposed algorithm successfully sampled models for a domain of 100 objects in less than one second. In contrast, UniGen, a state-of-the-art propositional sampler, failed to scale beyond a domain size of 30. This highlights the massive advantage of lifted reasoning over methods that ground logic into massive Boolean formulas.
Insights and Future Directions
The "aha" moment of this research is the realization that while sampling individual atoms is difficult, sampling the distribution of types preserves high-level symmetries. Once the distribution is established, the remaining choices become computationally trivial.
However, limitations remain. The current algorithm is restricted to universal quantifiers. The authors show that for certain sentences containing existential quantifiers ($\exists$), the sampling problem becomes #P-complete, suggesting that a fundamentally different approach is needed for broader logic fragments. Future work will also look toward extending these results to $C^2$ (two-variable logic with counting quantifiers), bridging the gap between pure logic and complex statistical constraints.
Summary updated