Embeddings as Probabilistic Equivalence in Logic Programs

Jaron Maene, Efthymia TsamouraNeurIPS 2025

TL;DR

This paper introduces equivalence semantics, a new mathematical foundation for neurosymbolic AI that fixes a fundamental flaw in how neural embeddings interact with logical rules. By treating embeddings as a probability distribution over valid equivalence relations rather than simple similarity scores, the authors eliminate logical inconsistencies and achieve up to a 42% performance boost on reasoning benchmarks.

The Problem: Broken Equality in Neurosymbolic AI

In the world of Neurosymbolic AI, researchers try to combine the "soft" learning of neural networks (embeddings) with the "hard" reasoning of symbolic logic. A popular bridge between these two is soft unification.

Standard logic requires symbols to be identical to trigger a rule (e.g., isIn(paris, france)). Soft unification relaxes this: if the vector for "Paris" is similar to the vector for "City_of_Lights," the system treats them as equivalent.

The Gap: Similarity is not the same as equality. Specifically, similarity violates the transitive law: if $A$ is similar to $B$, and $B$ is similar to $C$, $A$ might not be similar to $C$. In probabilistic logic, ignoring this leads to "leaked" probability mass and optimization traps (local optima) during training. The authors argue that current neurosymbolic models are essentially trying to reason with a broken definition of equality.

Methods: Revamping Probabilistic Semantics

To resolve the transitivity issue, the authors propose a fundamental revamp of the standard semantics used in probabilistic logic programming.

Comparison of Possible World Semantics (left) and Equivalence Semantics (right)
  1. Equivalence Semantics: Instead of defining a distribution over subsets of facts (the standard "Possible World Semantics" shown on the left of the figure above), they define a distribution over all possible equivalence relations between symbols (shown on the right). This ensures that if the model thinks $A=B$ and $B=C$, it must logically conclude $A=C$.
  2. Latent Variable Factorization: To make this computationally tractable—since the number of ways to partition symbols grows exponentially—they associate each constant with a latent categorical variable. This variable represents which "cluster" or "partition" the constant belongs to. The probability of two symbols being equivalent is simply the probability that they belong to the same latent cluster.
  3. Inference Pipeline: The authors develop two distinct algorithms to handle reasoning under these new semantics.
Algorithms for Exact and Approximate Inference
  • Exact Inference (Algorithm 1): Uses singularization (transforming rules to explicitly handle equality) and magic sets (an optimization to focus only on relevant facts) combined with weighted model counting.
  • Approximate Inference (Algorithm 2): Provides a Monte-Carlo estimator that samples latent assignments to constants, turning the complex probabilistic program into a series of simple, standard Datalog programs.

Key Insights

  • The Transitivity Fix: By enforcing transitivity through the latent variable cluster approach, the model naturally avoids the "probability leakage" found in previous methods like Neural Theorem Provers (NTP).
  • Optimization Geometry: The authors prove that the probability of an atom in soft unification is not a multilinear polynomial in the embeddings. This explains why previous methods often got stuck in local optima; the "loss landscape" was mathematically more difficult to navigate.
  • Embeddings as Partitions: The most elegant idea here is viewing a symbol's embedding not just as a point in space, but as a probability vector over potential identity clusters.

Experimental Results

The model was evaluated on two main types of challenges: Link Prediction in Knowledge Graphs (Countries, Nations, UMLS, Kinship) and Differentiable Finite State Machines (DFSM). The proposed "Equivalence Semantics" consistently outperformed state-of-the-art baselines:

  • Link Prediction: On the "Countries S2" benchmark, the model achieved 100% AUC-PR, compared to 97.6% for DeepSoftLog and 91.8% for CTP. On the "Nations" dataset, it achieved a Mean Reciprocal Rank (MRR) of 0.724, significantly higher than CTP (0.709).
  • Knowledge Graph Scaling: In some benchmarks (UMLS), the model showed a 42% improvement in Hits@1 accuracy over previous state-of-the-art neurosymbolic methods.
  • Finite State Machines: The model effectively "saturated" the benchmark, achieving near 99.6% accuracy on complex image-sequence grammars where standard RNNs and previous neurosymbolic models struggled (often hovering between 50-80%).

Limitations and Future Work

  • Variance in Learning: When using approximate inference, the model relies on the REINFORCE gradient estimator, which can have high variance. This makes training with a very large number of rules challenging.
  • Language Bias: The approach still requires "rule templates" (pre-defined structures of rules). Moving toward true structure learning without templates is a logical next step.
  • Logic Scope: The current work focuses on Datalog. Extending these semantics to more complex logics (like non-monotonic logic or those with functional symbols) remains an open research question.

Summary updated

BibTeX
@inproceedings{maene2025embeddings,
  author = {Jaron Maene and Efthymia Tsamoura},
  title = {{Embeddings as Probabilistic Equivalence in Logic Programs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=rEUbDhWaXh},
}
Figure