GNNTheory: A Lean 4 Formalization of Graph Neural Network Theory

1 Core Definitions: Labelled Graphs, 1-WL, and MPNNs

This chapter lays down the foundational objects of graph neural network theory: finite vertex-labelled simple graphs, isomorphism invariance and equivariance, the 1-dimensional Weisfeiler–Leman (colour refinement) algorithm, and the aggregate–combine message-passing neural network (MPNN) model.

Primary references:

  • M. Grohe, The Logic of Graph Neural Networks (arXiv:2104.14624), §2, §4, §5, §7.1.

  • C. Morris et al., Weisfeiler and Leman Go Neural (arXiv:1810.02244), §3.

  • K. Xu et al., How Powerful are Graph Neural Networks? (arXiv:1810.00826), §2–§3.

Key formalization choices.

  • Unbundled labelled graphs: LabelledGraph V L wraps Mathlib’s SimpleGraph V together with label : V -> L, subsuming unlabelled graphs (\(L = \mathrm{Unit}\)), Boolean-labelled graphs (\(L = \mathrm{Fin}\, \ell \to \mathrm{Bool}\), Grohe §2), countable feature spaces (Xu et al. §3), and real-valued features (\(L = \mathrm{Fin}\, d \to \mathbb {R}\), Morris et al. §3.3).

  • Canonical 1-WL colours without a hash oracle: WLColor L 0 = L and WLColor L (t + 1) = WLColor L t x Multiset (WLColor L t), giving canonical cross-graph comparisons and automatic countability preservation.

  • Two-tier MPNNs: Abstract MPNN and RecurrentMPNN operate on arbitrary feature types with arbitrary multiset aggregation and combination so that equivariance and 1-WL upper bounds hold in full generality; concrete \(\mathbb {R}\)-valued architectures (linear-activation MPNNs, GIN) are introduced in Chapter 3 for the converse lower bounds.

  • Initial feature consistency: Each MPNN carries init : L -> InFeat applied to G.label, unifying Grohe’s zero-padded \(\operatorname {col}(G)\), Morris et al.’s label-consistent \(f^{(0)}\), and Xu et al.’s \(h_v^{(0)} = X_v\).