Abstract
Traditional machine learning algorithms typically require data to be represented as flat numerical vectors. However, many real-world domains involve deeply structured data, such as molecular graphs or hierarchical logic. This paper introduces a framework for defining kernels directly on Prolog ground terms. By leveraging the recursive nature of first-order logic, we propose both untyped and typed kernels that serve as mathematically rigorous similarity measures. Our evaluation on chemical property prediction demonstrates that this general-purpose logic-based approach achieves performance competitive with specialized neural architectures.
Introduction
A significant challenge in machine learning is the effective representation of structured data. While convolution kernels have been proposed for discrete structures, applying them to the symbolic richness of first-order logic remains an area of active research. Prolog, a logic programming language, offers a robust framework for representing complex relationships and hierarchies. It is simple, can simulate complex structures like sets, and has a long legacy in artificial intelligence. This work bridges the gap between symbolic logic and statistical learning by defining kernels on Prolog ground terms, allowing standard kernel-based algorithms like Support Vector Machines (SVMs) to operate on structured symbolic data.
Methodology
The core contribution is the definition of recursive kernels that mirror the structure of Prolog terms.
Untyped and Typed Kernels
The untyped kernel compares two terms by recursively examining their components. For simple constants, a standard identity comparison is used. For compound terms, the kernel compares the functors (labels) and then recursively evaluates the similarity of their arguments. If the structures match, it sums the similarities of their parts. To incorporate domain-specific knowledge, we introduce typed kernels. This extension allows users to define specific comparison rules for different data types—for example, using a different mathematical "yardstick" for numerical values versus categorical symbols.
Mathematical Validity
A critical requirement for any kernel is that it must be positive definite to ensure compatibility with standard optimization algorithms. The authors provide a proof sketch (Theorem 1) demonstrating that these recursive definitions satisfy the necessary conditions for positive definiteness, ensuring they work reliably with algorithms like Kernel Ridge Regression or SVMs.
Experimental Evaluation
We evaluated the proposed kernels on a Quantitative Structure-Property Relationship (QSPR) task: predicting the boiling points of alkanes based solely on their chemical structure.
As illustrated in the figure above, alkanes are represented as ordered rooted trees and encoded as Prolog ground terms. This representation allows the model to capture the branching structure of the hydrocarbons, which is a primary determinant of physical properties like boiling point. The transformation from a chemical structure to a hierarchical tree and finally to a Prolog term is central to the methodology.
Results
Using Kernel Ridge Regression, the study tested two variations of the kernel:
- Basic Kernel ($K$): Achieved a mean square error (MSE) of 4.6°C.
- Informed Kernel ($K'$): By incorporating information regarding the depth of the trees (representing molecular size), the MSE improved to 3.8°C.
These results are significant as they match the performance of highly specialized neural networks designed specifically for chemical informatics, despite the Prolog-based approach being a general-purpose framework.
Discussion and Conclusion
The recursive similarity measure developed here demonstrates that Prolog is a powerful representational framework for machine learning. It naturally handles hierarchies and relationships that are difficult to capture in flat vector spaces. Furthermore, the flexibility of typed kernels allows for the seamless integration of domain knowledge.
While the recursive definition is elegant, future work is needed to address the computational cost of comparing very large or deeply nested Prolog terms. Additionally, extending these kernels to handle uncertainty through stochastic or Bayesian logic programs represents a promising direction for the field.
Summary updated