Bridging Max Graph Neural Networks and Datalog with Negation

David J. Tena Cucala, Bernardo Cuenca GrauKR 2024

Introduction

Graph Neural Networks (GNNs) have emerged as the state-of-the-art for processing relational data, particularly in Knowledge Graph (KG) completion and node classification. However, their "black box" nature remains a significant barrier to deployment in sensitive domains. While GNNs excel at identifying patterns within complex graphs, explaining why a specific prediction was made is often difficult. This paper addresses this transparency gap by establishing a formal equivalence between a specific class of GNNs—Max GNNs—and Datalog with negation-as-failure ($\text{Datalog}^{\neg}$), a powerful logic-based language. This bridge allows for the extraction of symbolic, human-readable explanations for neural predictions.

The Challenge of Non-Monotonicity

Previous research has successfully mapped certain GNN architectures to "positive" Datalog programs. However, positive Datalog is inherently monotonic: adding new facts to a database can only ever lead to more conclusions, never the retraction of existing ones.

In real-world reasoning, non-monotonicity is essential. For instance, a recommendation engine might suggest a movie to a user unless they have already seen it. Capturing this "unless" logic requires negation. Until now, incorporating negation into the GNN-to-logic mapping was mathematically elusive. This work bridges that gap by characterizing the expressive power of GNNs that utilize "max" aggregation in terms of Datalog with negation.

The Max GNN Framework

The authors focus on Max GNNs, which utilize the max function to aggregate information from a node's neighborhood. This choice is pivotal for several reasons:

  1. Logical Mapping: The authors prove that any transformation performed by a Max GNN can be exactly replicated by a "tree-like" Datalog program with negation-as-failure.
  2. Finite Feature Vectors: A core theoretical contribution of this work is the proof that for Max GNNs, the number of possible values any feature can take across all possible input graphs is finite. This finiteness allows the continuous weights of the neural network to be discretized into a finite set of symbolic logical rules.
  3. The "Max" Advantage: Unlike "Sum" or "Mean" aggregation, "Max" aggregation is sensitive to the existence of a specific type of neighbor rather than the quantity. This property is what facilitates the mapping to symbolic logic and ensures the feature space remains manageable.

Rule Extraction and Symbolic Explanations

To make these models interpretable, the authors developed an algorithm to translate a trained Max GNN into a logical program. Because a full program for a complex model can be massive, they introduced a "local explanation" algorithm. This algorithm extracts only the specific subset of rules required to justify a single, specific prediction.

Instead of providing a heat map or a numerical saliency score, the system generates step-by-step logical proofs. For example, a prediction might be explained by a rule such as: "If X is a Director and X is not an Actor, then predict Y." This framework is also "pay-as-you-go": if the GNN happens to be monotonic (e.g., using only non-negative weights), the negation-as-failure components naturally drop out, resulting in a simpler positive Datalog program.

Experimental Evaluation

The authors evaluated Max GNNs on three standard Knowledge Graph completion benchmarks: FB15K-237 (world facts), NELL-995 (language learning data), and WN18RR (lexical relations).

Key Results:

  • Competitive Performance: Max GNNs are not merely theoretical constructs; they perform at or above the level of state-of-the-art models. They achieved the highest Accuracy and F1 scores in 7 out of 12 benchmarks when compared against Sum GNNs and rule-based systems like AnyBURL and DRUM.
  • Efficient Explanation: While extracting a global program is computationally intensive, extracting individual fact explanations is highly efficient, typically taking between 8 and 37 seconds depending on the dataset.
  • Model Verification: By converting the GNN into a logical theory, researchers can use formal verification tools to ensure the model never makes forbidden predictions, a vital feature for AI safety.

Limitations and Future Work

Despite the breakthrough, challenges remain. For highly complex datasets like FB15K-237, individual explanations can still consist of hundreds of rules, which may be difficult for a human to interpret quickly. Furthermore, the current theoretical proof relies specifically on max aggregation. Extending this framework to sum or attention mechanisms remains an open challenge, as these functions do not naturally lead to a finite feature space.

Future research will focus on developing approximation techniques to extract more concise, "fuzzy" rules that prioritize human readability while maintaining high fidelity to the underlying neural model.

Summary updated

BibTeX
@inproceedings{cucala2024bridging,
  author = {David J. Tena Cucala and Bernardo Cuenca Grau},
  title = {{Bridging Max Graph Neural Networks and Datalog with Negation}},
  booktitle = {KR},
  year = {2024},
  doi = {10.24963/kr.2024/89},
}
Figure