The logic of rational graph neural networks

Sammy Khalife · Submission to ICLR 2025 · Withdrawn

TL;DR

While standard ReLU Graph Neural Networks (GNNs) can uniformly express any query in the two-variable guarded counting logic $\text{GC}_2$, this paper proves that GNNs with rational activation functions (quotients of polynomials) cannot. The authors identify a strict subfragment of logic that rational GNNs can uniformly express ($\text{RGC}_2$), while demonstrating that in practice, rational GNNs can actually outperform ReLU GNNs when learning these logical queries via gradient descent.

What Problem Does This Paper Address?

Understanding the expressive power of GNNs is central to understanding what graph problems they can solve. One formal way to measure expressivity is through logic: what Boolean graph queries (e.g., "does vertex $v$ belong to a clique?" or "do all neighbors have degree at least 2?") can a GNN compute?

When a GNN's parameters do not need to grow with the graph size to express a query, it is said to have uniform expressivity. Prior work showed that GNNs using Rectified Linear Units (ReLU) can uniformly express all queries in $\text{GC}_2$ (the two-variable guarded fragment of first-order logic with counting). Grohe (2021) asked whether any non-polynomial activation function suffices to grant this same expressivity. This paper answers that question in the negative by analyzing rational activation functions (ratios of polynomials).

Methods

The authors employ both theoretical logic-based analyses and empirical benchmarks:

  • Degree-Bounded Rational Analysis (Negative Result): The authors analyze the behavior of rational GNNs on parameterized families of depth-2 trees, $T[k_1, \dots, k_m]$, where the leaves have degrees $k_1, \dots, k_m$. They show that the root node's embedding at any layer is a symmetric multivariate rational function whose numerator and denominator degrees are bounded independently of the number of neighbors $m$. By studying the asymptotic dominance of monomial exponents, they prove it is mathematically impossible for such rational functions to verify degree-threshold conditions uniformly across all graph sizes.
  • Constructive Logic Induction (Positive Result): The authors define $\text{RGC}_2$, a subfragment of $\text{GC}_2$ where nested counting quantifiers are restricted to existential 1-hop checks and negations only appear at the outermost level. They prove that polynomial (and thus rational) GNNs can uniformly express $\text{RGC}_2$ using polynomial interpolation to track discrete counts at the first iteration.

Datasets

The authors evaluated their claims on synthetic graph datasets:

  • Training Set: 3,750 randomly generated graphs ranging in size from 50 to 2,000 vertices, with an average node degree of 5.
  • Testing Set: 1,250 randomly generated graphs with the same size distribution (50 to 2,000 nodes) and average degree 5.
  • Target Queries: Two concrete $\text{GC}_2$ queries:
  • $Q_1$: Vertex $v$ has all neighbors with degree at least 2.
  • $Q_2$: Vertex $v$ is red and has a neighbor that has both a red and a blue neighbor.

Key Insights and Ideas

  • Approximation vs. Uniform Expressivity: In feedforward networks, rational activations approximate continuous functions remarkably well (often outperforming polynomials and ReLUs). However, when coupled with neighborhood aggregation over graphs of unbounded size, rational activations cannot maintain discrete, uniform logic gates.
  • The Power of ReLUs: The piece-wise nature of ReLUs allows them to compute clipped, exact step functions that do not explode as vertex degree $m \to \infty$. In contrast, rational functions without real poles cannot maintain a flat, uniform separation across all integer inputs.
  • Theory vs. Practice in Optimization: While clipped ReLU GNNs theoretically possess the weights to express $\text{GC}_2$ queries uniformly, finding those weights via gradient descent is difficult because the required parameter configurations are sparse and brittle. In numerical experiments, rational GNNs actually achieved lower test mean squared error (MSE) than clipped ReLUs when learning the query.

Key Results

  • Theoretical Separation: Rational GNNs cannot uniformly express $\text{GC}_2$, establishing that $\mathcal{L}_{\text{Rational}} \subsetneq \mathcal{L}_{\text{ReLU}} = \text{GC}_2$. This holds even when the rational GNN has infinite-precision real weights while the ReLU GNN is restricted to integer weights.
  • $\text{RGC}_2$ Expressivity: Every query in the strict subfragment $\text{RGC}_2$ can be expressed uniformly by a rational (even polynomial) GNN.
  • Empirical Generalization: On test graphs between 50 and 2,000 nodes, both rational and clipped ReLU GNNs generalized well (MSE stabilized for large graphs), but rational GNNs attained lower test MSE on learning $Q_1$ than clipped ReLU GNNs.

Limitations and Future Work

  • Aggregation Functions: The negative results focus primarily on sum aggregation and rational aggregation functions with bounded degrees; the impact on non-rational aggregations like max remains an open question.
  • Tightness of $\text{RGC}_2$: The authors conjecture that $\text{RGC}_2$ is close to the exact boundary of what rational GNNs can capture, but whether negation can be safely reintroduced into certain subformulas is unresolved.
  • Bounded Graphs: Practical tasks often operate on bounded-degree or bounded-order graphs, where the asymptotic barriers of rational functions may not restrict practical representation power.

Summary updated

Abstract

The expressivity of Graph Neural Networks (GNNs) can be described via appropriate fragments of the first-order logic. In this context, uniform expressivity guarantees that a GNN can express a logical query without the parameters depending on the size of the input graphs. It has been established that the two-variable guarded fragment with counting (GC2) can be expressed uniformly via Rectified Linear Unit (ReLU) GNNs [Barcelo &. Al., 2020]. Moreover, GC2 is the fragment that can be expressed at most by a GNN with any activation function. In this article, we prove that, on the contrary of ReLU GNNs, there are GC2 queries that cannot be uniformly expressed via any GNN with rational activations. As a consequence, non-polynomial activation functions do not grant GNNs GC2 uniform expressivity in general, answering an open question formulated by [Grohe, 2021]. We then present a strict subfragment of GC2 (RGC2), and prove that rational GNNs can express RGC2 queries uniformly over all graphs. Our numerical experiments illustrates that despite this theoretical disadvantage, rational GNNs are still able to learn some GC2 queries if some level of error is allowed.
BibTeX
@misc{khalife2023logic,
  author = {Sammy Khalife},
  title = {{The logic of rational graph neural networks}},
  year = {2023},
  eprint = {2310.13139},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.13139},
}
Figure