GNNTheory: A Lean 4 Formalization of Graph Neural Network Theory

2.2 Graph-Level and Recurrent Upper Bounds

Theorem 2.2 Round-\(d\) MPNN readout is bounded by round-\(d\) 1-WL
✓

For every \(d \in \mathbb {N}\), every \(d\)-layer MPNN \(N\), and all finite \(L\)-labelled graphs \(G, H\), if \(G \equiv _{\mathrm{WL}}^{(d)} H\) then \(N(G) = N(H)\). (Grohe, arXiv:2104.14624, §8; Xu et al., arXiv:1810.00826, Lemma 2.)

Lean 4 Spec · GNNTheory/Spec/MPNN.lean:L116–L119 · Proved in GNNTheory/Proofs/MPNN.lean:L90–L93Pending AuditApprove SpecDispute
def mpnn_le_wl_at_stmt : Prop :=
  ∀ {V W L Y : Type} [Fintype V] [Fintype W] {d : ℕ}
    (N : MPNN L Y d) (G : LabelledGraph V L) (H : LabelledGraph W L),
    WLEquivAt d G H → N.readout G = N.readout H
Proof ▶

Paper proofs: Grohe (arXiv:2104.14624), §8; Xu et al. (arXiv:1810.00826), Appendix A (Proof of Lemma 2). Lean formalization: Apply CrossRefines.map_eq_of_map_eq to mpnn_le_wl_vertex on the full vertex multiset, then apply N.readoutFn.

Lean 4 Proof · GNNTheory/Proofs/MPNN.lean:L90–L93Verified ✓
theorem mpnn_le_wl_at : Spec.mpnn_le_wl_at_stmt := by
  intro V W L Y _ _ d N G H h
  unfold MPNN.readout liftVertexInvariant
  exact congrArg N.readoutFn ((mpnn_le_wl_vertex N G H).map_eq_of_map_eq h)
Theorem 2.3 MPNNs are bounded by 1-WL
✓

For every \(d \in \mathbb {N}\), every \(d\)-layer MPNN \(N\), and all finite \(L\)-labelled graphs \(G, H\), if \(G \equiv _{\mathrm{WL}} H\) then \(N(G) = N(H)\). (Grohe, arXiv:2104.14624, Corollary 8.3; Morris et al., arXiv:1810.02244, Theorem 1; Xu et al., arXiv:1810.00826, Lemma 2.)

Lean 4 Spec · GNNTheory/Spec/MPNN.lean:L124–L127 · Proved in GNNTheory/Proofs/MPNN.lean:L99–L101Pending AuditApprove SpecDispute
def mpnn_le_wl_stmt : Prop :=
  ∀ {V W L Y : Type} [Fintype V] [Fintype W] {d : ℕ}
    (N : MPNN L Y d) (G : LabelledGraph V L) (H : LabelledGraph W L),
    WLEquiv G H → N.readout G = N.readout H
Proof ▶

Paper proofs: Grohe (arXiv:2104.14624), §8 (Corollary 8.3); Xu et al. (arXiv:1810.00826), Appendix A (Proof of Lemma 2). Lean formalization: Specialize \(G \equiv _{\mathrm{WL}} H\) to round \(d\) and apply mpnn_le_wl_at.

Lean 4 Proof · GNNTheory/Proofs/MPNN.lean:L99–L101Verified ✓
theorem mpnn_le_wl : Spec.mpnn_le_wl_stmt := by
  intro V W L Y _ _ d N G H h
  exact mpnn_le_wl_at N G H (h d)

For every recurrent MPNN \(R\), all finite \(L\)-labelled graphs \(G, H\), and every iteration count \(t \in \mathbb {N}\): (1) \((\operatorname {cr}^{(t)}(G), \operatorname {cr}^{(t)}(H))\) cross-refines \((\zeta ^{(t)}_R(G), \zeta ^{(t)}_R(H))\); (2) within \(G\), vertices indistinguishable by \(\operatorname {cr}^{(s)}\) for all \(s\) receive equal embeddings \(\zeta ^{(t)}_R(G)\); (3) \(G \equiv _{\mathrm{WL}} H \implies R(G, t) = R(H, t)\). (Grohe, arXiv:2104.14624, Corollaries 8.2–8.3.)

Lean 4 Spec · GNNTheory/Spec/MPNN.lean:L132–L138 · Proved in GNNTheory/Proofs/MPNN.lean:L137–L150Pending AuditApprove SpecDispute
def recurrent_mpnn_le_wl_stmt : Prop :=
  ∀ {V W L Y : Type} [Fintype V] [Fintype W]
    (R : RecurrentMPNN L Y) (G : LabelledGraph V L) (H : LabelledGraph W L) (t : ℕ),
    CrossRefines (wlColor G t) (wlColor H t) (R.nodeEmbed G t) (R.nodeEmbed H t) ∧
    (∀ v₁ v₂ : V, (∀ s : ℕ, wlColor G s v₁ = wlColor G s v₂) →
      R.nodeEmbed G t v₁ = R.nodeEmbed G t v₂) ∧
    (WLEquiv G H → R.readout G t = R.readout H t)
Proof ▶

Paper proof: Grohe (arXiv:2104.14624), §8 (Corollaries 8.2–8.3). Lean formalization: Unroll the recurrent layer \(t\) times into a fixed-depth \(t\)-layer MPNN (unrollMPNN) and apply mpnn_le_wl_vertex and mpnn_le_wl.

Lean 4 Proof · GNNTheory/Proofs/MPNN.lean:L137–L150Verified ✓
theorem recurrent_mpnn_le_wl : Spec.recurrent_mpnn_le_wl_stmt := by
  intro V W L Y _ _ R G H t
  have hv : CrossRefines (wlColor G t) (wlColor H t) (R.nodeEmbed G t) (R.nodeEmbed H t) := by
    rw [← unrollMPNN_nodeEmbed R G t, ← unrollMPNN_nodeEmbed R H t]
    exact mpnn_le_wl_vertex (unrollMPNN R t) G H
  refine ⟨hv, ?_, ?_⟩
  · intro v₁ v₂ h
    have hvG : CrossRefines (wlColor G t) (wlColor G t) (R.nodeEmbed G t) (R.nodeEmbed G t) := by
      rw [← unrollMPNN_nodeEmbed R G t]
      exact mpnn_le_wl_vertex (unrollMPNN R t) G G
    exact hvG v₁ v₂ (h t)
  · intro h
    rw [← unrollMPNN_readout R G t, ← unrollMPNN_readout R H t]
    exact mpnn_le_wl (unrollMPNN R t) G H h