Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Attention, convolution ⊆ message passing

Proved
GeometricDL.WL.attn_conv_eq_mp

by mikedeng1 · Oct 30, 2026 · Mathlib 0df444a (Lean v4.33.1)

geometric-deep-learninggraph-neural-networksweisfeiler-lehman

For every finite graph G=(V,E)G=(V,E)G=(V,E), node states h:V→Hh:V\to Hh:V→H, node uuu, message map ψ:H→M\psi:H\to Mψ:H→M into a real vector space, aggregator ⨁\bigoplus⨁, update φ\varphiφ, attention a:H×H→Ra:H\times H\to\mathbb Ra:H×H→R and look-up coefficient c:H×H→Rc:H\times H\to\mathbb Rc:H×H→R:

  1. the attentional layer (34) is the message-passing layer (35) with message ψ′(hu,hv)=a(hu,hv) ψ(hv)\psi'(h_u,h_v)=a(h_u,h_v)\,\psi(h_v)ψ′(hu​,hv​)=a(hu​,hv​)ψ(hv​);
  2. the convolutional layer (33) with cuv=c(hu,hv)c_{uv}=c(h_u,h_v)cuv​=c(hu​,hv​) is the message-passing layer (35) with message ψ′(hu,hv)=c(hu,hv) ψ(hv)\psi'(h_u,h_v)=c(h_u,h_v)\,\psi(h_v)ψ′(hu​,hv​)=c(hu​,hv​)ψ(hv​).
φ(hu,⨁v∈Nua(hu,hv)ψ(hv))=φ(hu,⨁v∈Nuψ′(hu,hv)).\varphi\Big(h_u,\bigoplus_{v\in N_u}a(h_u,h_v)\psi(h_v)\Big)=\varphi\Big(h_u,\bigoplus_{v\in N_u}\psi'(h_u,h_v)\Big).φ(hu​,v∈Nu​⨁​a(hu​,hv​)ψ(hv​))=φ(hu​,v∈Nu​⨁​ψ′(hu​,hv​)).

Both are special cases of message passing in which the message depends on the sender's features only through ψ(hv)\psi(h_v)ψ(hv​). Together with the previous milestone this is the containment convolution ⊆\subseteq⊆ attention ⊆\subseteq⊆ message passing.

Differences from the source:

  • reading: ψ(x_u, x_v) = c_uv ψ(x_v) for convolutional GNNs → c_uv = c(h_u, h_v), a function of the endpoints' states; reason: as in the previous milestone, a message ψ(x_u, x_v) can only carry a coefficient that is a function of (x_u, x_v); degree-dependent coefficients reach the goal through the local-layer milestone
  • encoding: node features x_u of one layer → the current states h of a stack of layers; reason: Lean convention; the first layer has h = x
  • encoding: permutation-invariant aggregator ⊕ → an arbitrary function of the multiset of messages, messages in a real vector space; reason: every function of a multiset is permutation-invariant and every permutation-invariant aggregator factors through the multiset
  • encoding: graph E ⊆ V×V with neighbourhood (11) → a relation E on a finite type, neighbourhood symmetrised, loops allowed; reason: Lean convention; same instances
Preamble
import Mathlib
import Definitions.Def_GeometricDL_WL_convLayer
import Definitions.Def_GeometricDL_WL_attnLayer
import Definitions.Def_GeometricDL_WL_mpLayer
Formal statement
namespace GeometricDL.WL

/-- **Containment attention, convolution ⊆ message passing.**
Bronstein, Bruna, Cohen & Veličković, *Geometric Deep Learning*, arXiv:2104.13478v2, §5.3,
printed pp. 79–80 (PDF pp. 83–84): "and both convolutional and attentional GNNs are special cases
of message-passing where the messages are only the sender nodes' features: ψ(x_u, x_v) = c_uv ψ(x_v)
for convolutional GNNs and ψ(x_u, x_v) = a(x_u, x_v)ψ(x_v) for attentional GNNs."

For every finite graph `(V, E)`, state `h`, node `u`, `ψ`, aggregator `agg` and update `φ`:
1. the attentional layer (34) with attention `a` equals the message-passing layer (35) with
   message `ψ'(h_u, h_v) = a(h_u, h_v) • ψ(h_v)`;
2. the convolutional layer (33) with look-up coefficient `c_uv = c(h_u, h_v)` equals the
   message-passing layer (35) with message `ψ'(h_u, h_v) = c(h_u, h_v) • ψ(h_v)`.

**Formalization Note.** As in `conv_eq_attn_of_lookup`, the convolutional coefficient is indexed by
the endpoints' states. -/
theorem attn_conv_eq_mp {V : Type*} [Fintype V] {H M A H' : Type*} [AddCommMonoid M]
    [Module ℝ M] (a c : H → H → ℝ) (ψ : H → M) (agg : Multiset M → A) (φ : H → A → H')
    (E : V → V → Prop) [DecidableRel E] (h : V → H) (u : V) :
    attnLayer a ψ agg φ E h u = mpLayer (fun hu hv => a hu hv • ψ hv) agg φ E h u ∧
      convLayer (fun hu hv _ _ => c hu hv) ψ agg φ E h u =
        mpLayer (fun hu hv => c hu hv • ψ hv) agg φ E h u := by sorry

end GeometricDL.WL
Source
Bronstein, Bruna, Cohen & Veličković, Geometric Deep Learning, arXiv:2104.13478v2, §5.3, printed pp. 79–80 (PDF pp. 83–84) ("both convolutional and attentional GNNs are special cases of message-passing where the messages are only the sender nodes' features")

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me