GNNTheory: A Lean 4 Formalization of Graph Neural Network Theory

3.2 Constructive Matching of 1-WL (Morris et al. 2019)

Notice the exact quantification in Morris et al. (2019), Theorem 2: for a fixed finite labelled graph \((G, \ell )\) (equivalently, a disjoint union \(G_1 \sqcup G_2\) of two graphs to be compared) and any depth \(t \in \mathbb {N}\), there exists a sequence of linear-activation weight matrices (with activation \(\sigma = \operatorname {sgn}\) or \(\sigma = \operatorname {ReLU}\)) whose node embeddings are colouring-equivalent to \(\operatorname {cr}^{(t)}(G)\), assuming initial labels are encoded by linearly independent vectors (e.g. one-hot vectors). Unlike the Xu/Grohe proof, this construction requires no universal approximation theorem and uses polynomial-size weights.

Lemma 3.3 Equivalence of initial-colour 1-WL update

For any finite labelled graph \((G, \ell )\), define the modified refinement \(\tilde{c}^{(0)} := \ell \) and \(\tilde{c}^{(t+1)}(v) := \bigl(\ell (v), \{ \! \! \{ \tilde{c}^{(t)}(w) \mid w \in N^G(v) \} \! \! \} \bigr)\) (retaining the initial label \(\ell (v)\) rather than \(\tilde{c}^{(t)}(v)\)). Then \(\tilde{c}^{(t)} \equiv \operatorname {cr}^{(t)}(G)\) for all \(t \in \mathbb {N}\). (Morris et al., arXiv:1810.02244, Appendix §11.1–§11.2, Lemmas 1–2.)

Proof ▶

By minimal-counterexample induction on \(t\): if \(\tilde{c}^{(t)}(u) \neq \tilde{c}^{(t)}(v)\) then \(\tilde{c}^{(t')}(u) \neq \tilde{c}^{(t')}(v)\) for all \(t' \ge t\), because color classes of \(\tilde{c}^{(t)}\) refine those of \(\tilde{c}^{(t-1)}\) and summing neighbor counts over sub-classes determines counts in the parent class.

Lemma 3.4 Row-independent sign/ReLU separation of distinct integer rows

Let \(D \in \mathbb {Z}^{s \times r}\) have pairwise distinct rows with entries in \(\{ 0, \dots , n-1\} \). Then there exists a matrix \(X \in \mathbb {R}^{r \times s}\) such that \(\operatorname {sgn}(D X - J) \in \mathbb {R}^{s \times s}\) (where \(J\) is the all-\(1\) matrix) is nonsingular (and similarly with \(\operatorname {ReLU}\) in place of \(\operatorname {sgn}\)). (Morris et al., arXiv:1810.02244, Appendix §11, Lemma lem:dist2lu and §11.3.)

Proof ▶

Encode each integer row of \(D\) in base \(n\) to obtain strictly increasing row values \(d_1 {\lt} \dots {\lt} d_s\), choose thresholds separating consecutive values so that \(\operatorname {sgn}(D X - J)\) is upper-triangular with nonzero diagonal entries, hence invertible. Adapt to \(\operatorname {ReLU}\) by shifting and scaling the piecewise-linear ramp.

Theorem 3.5 Constructive 1-WL matching by linear-activation MPNNs

Let \((G, \ell )\) be a finite labelled graph of order \(n = |V(G)|\) with an initial encoding \(f^{(0)} : V(G) \to \mathbb {R}^d\) that is consistent with \(\ell \) and maps distinct labels to linearly independent vectors. Then for every \(t \in \mathbb {N}\), there exists a \(t\)-layer linear-activation MPNN (with activation \(\operatorname {sgn}\) or \(\operatorname {ReLU}\) and width at most \(n\)) whose node embeddings \(f^{(t)}\) satisfy \(f^{(t)} \equiv \operatorname {cr}^{(t)}(G)\). (Morris et al., arXiv:1810.02244, Theorem 2 / equal.)

Proof ▶

Induct on \(t\), maintaining the invariant that the distinct rows of the feature matrix \(F^{(t)} \in \mathbb {R}^{n \times d_t}\) are linearly independent (row-independent modulo equality) and \(F^{(t)} \equiv \operatorname {cr}^{(t)}(G)\). Given linear independence of distinct rows, a linear right-multiplier \(M\) converts \(F^{(t)}\) to the exact one-hot colour-class indicator matrix \(F^{(t)} M\). Multiplying by the adjacency matrix \(A\) yields the integer neighbor-count matrix \(D = A F^{(t)} M\). Applying Lemma 3.4 produces weights \(W\) such that \(\sigma (A F^{(t)} W - J)\) is row-independent modulo equality and equivalent to \(\operatorname {cr}^{(t+1)}(G)\).