Abstract
Graph Neural Networks (GNNs) are increasingly deployed in safety-critical applications, yet they remain largely "black boxes." This paper introduces $K^\#$, a new modal logic specifically designed to match the expressive power of Aggregate-Combine Graph Neural Networks (AC-GNNs). By proving that $K^\#$ formulas and AC-GNNs are effectively interchangeable, we provide a rigorous framework for formally verifying GNN properties—such as safety and robustness—and generating human-readable explanations. We demonstrate that $K^\#$ can express properties beyond first-order logic while maintaining a PSPACE-complete satisfiability complexity, making it a powerful tool for algorithmic reasoning about GNNs.
Introduction
Graph Neural Networks (GNNs) are increasingly used in safety-critical fields like drug discovery and social recommendation, yet they remain "black boxes." We lack robust tools to answer questions like: “Will this GNN always flag a specific malicious structure?” (Verification) or “Why did the GNN classify this user as a musician?” (Explainability). While researchers have previously tried to link GNNs to logic (specifically Graded Modal Logic), those logics weren't powerful enough to capture the actual math GNNs perform, such as weighted sums and linear inequalities. This paper fills that gap by creating a logic that speaks the same "language" as the GNN's internal layers.
Methods: The $K^\#$ Logic
The authors define a new logic called $K^\#$. Unlike standard logic that just checks if a property is true or false, $K^\#$ incorporates counting modalities and linear inequalities. It can express complex conditions like "the number of musician friends minus twice the number of tuba players is at least five."
The core of the paper consists of two major proofs. First, the authors provide a polynomial-time algorithm to transform any $K^\#$ formula into an equivalent GNN. Second, they show that a broad class of GNNs—specifically Aggregate-Combine GNNs using truncated ReLU activations and linear functions—can be translated back into $K^\#$ formulas. Crucially, they represent these formulas as Directed Acyclic Graphs (DAGs) rather than simple trees, which allows for the reuse of sub-formulas and keeps the representation efficient. As this is a theoretical paper focused on formal methods, no empirical datasets were used; the results are established through mathematical theorems.
Key Insights and Expressivity
The "Aha" moment of this research was the realization that the "Aggregate" and "Combine" steps in a GNN are essentially performing linear programming over neighbor counts. By baking linear inequalities directly into the logic's syntax, they achieved a perfect semantic match.
Interestingly, $K^\#$ can express properties that standard First-Order Logic (FO) cannot—such as comparing the cardinality of two different sets of neighbors (e.g., "more friends like jazz than rock"). Despite its high expressive power, the authors proved that the satisfiability problem for $K^\#$ is PSPACE-complete. This is the same complexity class as standard modal logic, meaning that reasoning about these complex GNNs isn't computationally "harder" than reasoning about much simpler logical systems.
Results and Applications
The paper establishes $K^\#$ as a full logical characterization of AC-GNNs, significantly improving upon previous literature that could only characterize a small subset of GNN behaviors. By proving PSPACE-completeness, the authors show that problems like equivalence checking (do two GNNs do the same thing?), robustness (can a small change in input flip the output?), and abductive explanation (what is the minimal reason for this output?) are all decidable within polynomial space.
Limitations and Future Work
The current logic specifically targets truncated ReLU ($\max(0, \min(1, x))$). Standard ReLU, which is unbounded, would require further extensions to the logic, possibly involving SMT (Satisfiability Modulo Theories) solvers. Additionally, the model focuses on local vertex classification and does not yet account for "global readouts" where a GNN aggregates the entire graph into a single value. Future work will also explore tailoring the logic for specific graph classes and developing heuristics to handle real-world GNN sizes.
Summary updated