Partial Evaluation of Logic Programs in Vector Spaces

Chiaki Sakama, Hien D. Nguyen, Taisuke Sato, Katsumi InouearXiv 2018

Introduction

Symbolic reasoning is fundamental to artificial intelligence, enabling systems to derive new conclusions from established rules. However, traditional symbolic engines often struggle to scale when processing massive knowledge bases containing millions of rules. In contrast, numerical linear algebra—the backbone of modern deep learning—is highly scalable. This paper explores a method to bridge this gap by "compiling" propositional logic programs into matrices and vectors, allowing logical reasoning to benefit from the efficiency of numerical computing.

Methodology

The core approach involves representing logical interpretations as vectors and logic programs as matrices. An interpretation is encoded as a vector where a value of 1 at index $i$ indicates that the $i$-th atom is true.

Matrix Encoding and Fixpoint Iteration

Logic rules are transformed into a program matrix $M_P$. For instance, a rule like $h \leftarrow b_1 \wedge b_2$ is represented by weights that link the body atoms ($b_1, b_2$) to the head ($h$). To determine the least model—the set of all facts inferable from the program—the system performs iterative vector-matrix multiplication. Starting with an initial "fact vector," the vector is repeatedly multiplied by the program matrix, followed by a threshold function ($\theta$) to maintain binary values. This process continues until a fixpoint is reached.

Example of a submatrix $N_{p^\delta}$ and the iterative vector computation used to derive the least model of a logic program.

Optimization Techniques

To enhance efficiency, the authors introduce two key techniques:

  1. Column Reduction: Complex programs often require auxiliary variables, increasing matrix size. Column reduction shrinks the matrix by focusing only on the original atoms, saving memory and computation.
  2. Partial Evaluation: In symbolic logic, "unfolding" a rule involves replacing a premise with its definition. The authors demonstrate that this is mathematically equivalent to computing matrix powers ($M^2, M^4, \dots$). Pre-computing these powers allows the system to "jump" through multiple steps of logical inference in a single multiplication, significantly reducing the number of iterations needed to reach a fixpoint.

Experimental Evaluation

The methodology was tested using randomly generated propositional logic programs with the following characteristics:

  • Scale: Programs included 50, 100, and 200 propositional variables ($n$) and up to 20,000 rules ($m$).
  • Structure: Rules typically had body lengths of 4 to 5 atoms to simulate real-world complexity.
  • Baseline: The matrix-based methods were compared against the standard symbolic $T_P$ operator.

Results and Discussion

The experiments revealed several key advantages of the vector-space approach:

  • Significant Speedups: For large-scale programs (e.g., 20,000 rules), the column reduction method achieved up to a 10x speedup over naive matrix computations.
  • Scalability: As the number of rules ($m$) increases relative to the number of atoms ($n$), the matrix-based approach demonstrates superior performance compared to traditional symbolic methods.
  • Efficiency via Partial Evaluation: Pre-computing matrix powers successfully reduced the total number of iterations required for convergence, validating the "jump" effect in logical reasoning.

Conclusion and Future Work

While promising, the current framework has limitations. It is currently restricted to propositional logic and does not handle first-order logic or negation (e.g., "stable models"). Additionally, the transformation into "d-programs" can increase dimensionality. Future research will focus on extending the framework to handle negation and leveraging hardware acceleration, such as GPUs via CUDA, to achieve even greater scale.

Summary updated

BibTeX
@misc{sakama2018partial,
  author = {Chiaki Sakama and Hien D. Nguyen and Taisuke Sato and Katsumi Inoue},
  title = {{Partial Evaluation of Logic Programs in Vector Spaces}},
  year = {2018},
  eprint = {1811.11435},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.11435},
}
Figure