Exponentially Improving the Complexity of Simulating the Weisfeiler-Lehman Test with Graph Neural Networks

Anders Aamand, Justin Y. Chen, Piotr Indyk, Shyam Narayanan, Ronitt Rubinfeld, Nicholas Schiefer, Sandeep Silwal, Tal Wagner

Introduction

Graph Neural Networks (GNNs) have become a popular tool for machine learning on graph-structured data, with applications in social network prediction [HYL17], traffic prediction [YYZ18], recommender systems [YHC+18], drug discovery [WKK+20], computer vision [LGD+19, FLM+19, MBM+17, QSMG17], and combinatorial optimization [CCK+21]. Standard message passing GNNs use the topology of the input graph to define the network structure: in each step kk, a node aggregates messages from each of its neighbors and combines them using a function ϕ(k)\phi^{(k)}, computed by a neural network, to determine its message for the next round. Crucially, the aggregation function must be symmetric, to ensure that the output of GNNs is invariant under node permutation. This restriction raised questions about how expressive such network architectures are, and in particular what classes of graphs are distinguishable using GNNs.

The seminal works of Xu et al. [XHLJ19] and Morris et al. [MRF+19] (see also [Gro21]) showed that GNNs are exactly as powerful in distinguishing graphs as the Weisfeiler-Lehman (WL) test [WL68], also known as color refinement. This combinatorial procedure is a necessary but not sufficient test for graph isomorphism. It proceeds in repeated rounds: in each round, a node labels itself with the “hash” of the multiset of labels of its neighbors. The aforementioned papers show that (i) GNNs can simulate the WL test and (ii) GNNs can only distinguish those graphs that the WL test determines to be different. This provides a complete characterization of the expressive power of GNN architectures.

The connection between GNNs and the WL test has spawned a wave of new results studying GNN variants that either match the distinguishing power of the WL test or adopt new methods beyond message passing on the edges of the input graph to overcome this barrier (see the excellent surveys [MFK21, MLM+21, Gro21] for an overview of this area). However, the results in the original as well the follow up works mostly focus on qualitative questions (how expressive GNNs are) as opposed to quantitative questions such as the network complexity. In particular, while Xu et al. [XHLJ19] show that there exist GNN architectures that can simulate the WL coloring procedure as long as the aggregation step is injective, they rely on the universal approximation theorem to show that there exists a neural network that can simulate the hash function used in WL. As a result, the size of the network could be exponential in the number of nodes nn. In contrast, the construction of Morris et al. [MFK21] uses networks of size polynomial in nn. However, the weights of the network implementing ϕ(k)\phi^{(k)} in their construction depend on the structure of the underlying graph, which suffices for node classification, but is not sufficient for the context of graph classification.

Overall, the quantitative understanding of the complexity of simulating WL remains an open problem. Indeed, the survey [Gro21] states “The size of the GNNs and related parameters like depth and width, which directly affect the complexity of inference and learning, definitely require close attention.”

The main question addressed in this work is: what is the simplest (in terms of the number of neural network units and message length) GNN capable of simulating the WL test? Equivalently, at what point does a GNN become so small that it loses its expressive power?

Our main result is a highly efficient construction of a GNN architecture that is capable of simulating the WL test. For graphs with nn nodes, it can simulate \mboxpoly(n)\mbox{poly}(n) steps of the WL test, such that the neural network implementing ϕ(k)\phi^{(k)} in each round has polylog⁡(n)\operatorname{polylog}(n) parameters, and the messages exchanged by the nodes of the GNN in each round consist of O(log⁡n)O(\log n) bits. This offers at least an exponential improvement over the prior bounds obtained in [XHLJ19, MRF+19] (see Table 1), extending the equivalence between the WL test and the expressive power of GNNs to neural networks of reasonable (in fact, quite small) size. Furthermore, our architecture is simple, using vector sum for aggregation and ReLU units for the combine function ϕ(k)\phi^{(k)}. Finally, our construction can be generalized to yield a depth-size tradeoff: for any integer t>0t>0, we can can construct a neural network of depth O(t)O(t) and size nO(1/t)polylog⁡(n)n^{O(1/t)}\operatorname{polylog}(n).

To achieve this result, our construction is randomized, i.e., some weights of the neural networks are selected at random, and the simulation of the WL test is correct with high probability 1−1/\mboxpoly(n)1-1/\mbox{poly}(n). Thus, our construction can be viewed as creating a distribution over neural networks computing the function ϕ(k)\phi^{(k)}.Note that selecting ϕ(k)\phi^{(k)} at random is quite different from random node initialization, e.g., as investigated in [ACGL21]. In particular, in our model all nodes use the same function ϕ(k)\phi^{(k)} (with the same parameters), without breaking the permutation invariance property of GNNs, as in the standard GNN model. In particular, this implies that, for each graph, there exists a single neural network implementing ϕ(k)\phi^{(k)} that accurately simulates WL on that graph. The size of the network is exponentially smaller than in [MRF+19], although the construction is probabilistic.

We complement this results with two lower bounds for executing a WL iteration. Our first lower bound addresses the communication complexity of this problem, and demonstrates that to solve it, each node must communicate labels that are at least O(log⁡n)O(\log n) bits long, matching the upper bound achieved by our construction. Our second lower bound addresses the computational complexity, namely the parameters of the neural network. It shows that if the messages sent between nodes are vectors with entries in [F]={0,1,…,F−1}[F]=\{0,1,\dots,F-1\}, then the network implementing ϕ(k)\phi^{(k)} must use Ω(log⁡F)\Omega(\log F) ReLU units.

The equivalence between the discriminative power of GNNs and the WL test has been shown in the aforementioned works [XHLJ19, MRF+19]. A strengthened version of the theorem of [XHLJ19], where the same combine function ϕ\phi is used in all iterations (i.e., ϕ=ϕ(k)\phi=\phi^{(k)} for all kk) appeared in the survey [Gro21]. Many works since have studied various representational issues in GNNs; we refer the reader to excellent surveys [Gro21, HV21, MLM+21, Jeg22]. In particular, [Lou19] established connections between GNNs and distributed computing models such as LOCAL and CONGEST, and derived lower bounds for several computational tasks based on this connection. [CVCB19] drew a connection between the expressiveness of GNNs in graph isomorphism testing and in function approximation. [BKM+20] studied the expressiveness of GNNs in computing Boolean node classifiers, and [GMP21] studied the expressiveness of graph convolutional networks (GCNs).

The emergence of WL as a barrier in GNN expressivity has also led to a flurry of work on enhancing their expressivity by means of more general architectures. These include higher-order GNNs inspired by higher-dimensional analogs of WL [MRF+19, MBHSL19], unique node identifiers [Lou19, VLF20], random node initializations [ACGL21, SYK21], relational pooling [MSRR19], incorporating additional information on the graph structure [NM20, BGRR21, BFZB22, CMR21, TRWG21], and more. We refer to [MLM+21] for a comprehensive survey of this line of work.

1 Preliminaries

For the rest of the paper, we use N(v)\mathcal{N}(v) to denote the neighborhood of vv in a graph G(V,E)G(V,E) including vv itself, and we use {⋅}\{\cdot\} to denote multisets rather than sets.

Let G=(V,E)G=(V,E) be a graph with NN nodes. GNNs use the graph structure of GG to learn node embeddings for all the nodes across multiple iterations. Let hv(k)h_{v}^{(k)} denote the embedding vector of node v∈Vv\in V in the kkth iteration. The vectors hv(0)h_{v}^{(0)} represent the initial node embeddings. In every iteration k≥1k\geq 1, each node vv sends its current embedding hv(k−1)h_{v}^{(k-1)} to all its neighbors, and then computes its new embedding hvkh_{v}^{k} by the equation

where ϕ(k)\phi^{(k)} is implemented by a neural network with ReLU activations (note that ϕ(k)\phi^{(k)} may differ across different iterations kk). The function ff is called the ‘aggregate’ function, and ϕ(k)\phi^{(k)} is called the ‘combine’ function. The embeddings hv(K)h_{v}^{(K)} at the final iteration KK can be used for node classification. For graph classification, they can be aggregated into a graph embedding hGh_{G} with a ‘readout’ function,

The WL test [WL68] is a popular heuristic for the graph isomorphism problem. While the exact complexity of this problem remains unknown [Bab16], the WL test is a powerful heuristic capable of distinguishing a large family of graphs [BK79].

A WL iteration gets existing labels {hv:v∈V}\{h_{v}:v\in V\} for all nodes, and outputs new labels {hv′:v∈V}\{h_{v}^{\prime}:v\in V\} given by

for an aggregate function ff and neural network ϕ\phi with random weights. We say the iteration is successful if for all v,u∈Vv,u\in V, the following holds:

If {hw:w∈N(v)}={hw:w∈N(u)}\{h_{w}:w\in\mathcal{N}(v)\}=\{h_{w}:w\in\mathcal{N}(u)\} then hv′=hu′h_{v}^{\prime}=h_{u}^{\prime} with probability 1, and

If {hw:w∈N(v)}≠{hw:w∈N(u)}\{h_{w}:w\in\mathcal{N}(v)\}\neq\{h_{w}:w\in\mathcal{N}(u)\} then hv′≠hu′h_{v}^{\prime}\neq h_{u}^{\prime} with probability 1−p1-p,

where the probability is over the choices of the random weights of ϕ\phi.

2 Overview of Our Techniques

In this section we give an overview of our GNN architectures for simulating WL. To explain our ideas in stages, we begin with a simpler construction of a polynomial size GNN. It is far larger than the ultimate polylogarithmic size we are aiming for, but forms a useful intermediate step toward our second and final construction.

Recall that the kkth WL iteration, for a node vv, aggregates the labels of its neighbors from the previous iteration, Hv(k−1):={hw(k−1):w∈N(v)}\mathcal{H}_{v}^{(k-1)}:=\{h_{w}^{(k-1)}:w\in\mathcal{N}(v)\}, and hashes them into a new label hv(k)h_{v}^{(k)} for vv. Our GNNs aggregate by summing, i.e., they sum Hv(k−1)\mathcal{H}_{v}^{(k-1)} into Sv(k):=∑w∈N(v)hw(k−1)\mathcal{S}_{v}^{(k)}:=\sum_{w\in\mathcal{N}(v)}h_{w}^{(k-1)}, and then hash the sum into hv(k)h_{v}^{(k)} using a ReLU neural network of our choice.

We now proceed to describe our polylogarithmic size construction. The weak point in the previous construction was the wasteful use of one-hot encoding vectors, which caused the width to be FF. In the current construction, we still wish to hash into FF bins — that is, to have FF distinct possible labels in each iteration — but we aim to represent them using bitstrings of length O(log⁡F)O(\log F), thus exponentially improving the width of the network. That is, for every node vv and iteration kk, the label hv(k−1)h_{v}^{(k-1)} would now be a vector in {0,1}O(log⁡F)\{0,1\}^{O(\log F)}. The challenge is again to avoid the two failure modes above, ensuring that the failure probability does not exceed pp. Since we cannot use one-hot encoding, we need to devise another method to avoid the first failure mode, i.e., ensure that with high probability Su(k)≠Sv(k)\mathcal{S}_{u}^{(k)}\neq\mathcal{S}_{v}^{(k)} if Hu(k−1)≠Hv(k−1)\mathcal{H}_{u}^{(k-1)}\neq\mathcal{H}_{v}^{(k-1)}.

To this end, suppose for a moment that we had access to a truly random vector a∈{0,1}Fa\in\{0,1\}^{F}. Then each node vv, instead of sending the one-hot encoding of its label hv(k−1)h_{v}^{(k-1)}, we could instead send the dot product ⟨a,hv(k−1)⟩\langle a,h_{v}^{(k-1)}\rangle, which is the single bit ahv(k−1)a_{h_{v}^{(k-1)}}. Each node uu thus receives the bits {ahw(k−1):w∈N(w)}\left\{a_{h_{w}^{(k-1)}}:w\in\mathcal{N}(w)\right\} from its neighbors and aggregates them into the sum ∑w∈N(u)⟨a,hw(k−1)⟩\sum_{w\in\mathcal{N}(u)}\langle a,h_{w}^{(k-1)}\rangle, which, by linearity, is equal to ⟨a,Su(k)⟩\langle a,\mathcal{S}_{u}^{(k)}\rangle (using the notation from Construction 1). It is easy to observe that if Su(k)≠Sv(k)\mathcal{S}_{u}^{(k)}\neq\mathcal{S}_{v}^{(k)} then ⟨a,Su(k)⟩≠⟨a,Sv(k)⟩\langle a,\mathcal{S}_{u}^{(k)}\rangle\neq\langle a,\mathcal{S}_{v}^{(k)}\rangle with probability at least 0.50.5. Repeating this process log⁡F\log F independent times decreases the collision probability to the requisite 1/F1/F. Thus, we can define a new labeling scheme hˉv(k)∈{0,1}log⁡F\bar{h}_{v}^{(k)}\in\{0,1\}^{\log F} that concatenates log⁡F\log F dot products with independent random vectors a1…alog⁡F∈{0,1}Fa^{1}\ldots a^{\log F}\in\{0,1\}^{F} as just described, failing at the summing operation with probability at most 1/F1/F. The second failure mode (hashing) can again be handled as before.

That catch is that, since aa has length FF, the overall number of parameters in the GNN would again be at least FF. To avoid this, we appeal to the computational theory of pseudorandomness. The idea is to replace the random vector aa with an efficient pseudorandom analog. Note that the above approach goes through even if the probability that ⟨a,Su(k)⟩≠⟨a,Sv(k)⟩\langle a,\mathcal{S}_{u}^{(k)}\rangle\neq\langle a,\mathcal{S}_{v}^{(k)}\rangle is slightly larger than 0.50.5, say 0.5+ϵ0.5+\epsilon for a small constant ϵ\epsilon. It is well-known in complexity theory that there exist pseudo-random generators, called ϵ\epsilon-biased spaces, that generate vectors aa satisfying this property given only O(log⁡F+log⁡(1/ϵ))O(\log F+\log(1/\epsilon)) truly random bits.Technically, they guarantee this property only when Su(k)\mathcal{S}_{u}^{(k)} are binary vectors, but Lemma 3.2 shows how to extend this property to general integer vectors as well. Crucially, each bit of aa can be computed using a threshold circuit with size polynomial in O(log⁡F+log⁡(1/ϵ))O(\log F+\log(1/\epsilon)) and constant depth (Theorem C.1), which translates to a ReLU neural network with the same parameters (Lemma C.2). Using these generators in our GNN to implement a pseudorandom (ϵ\epsilon-biased) analog of aa yields our final construction.

First Construction: Polynomial-size GNN

Our first construction towards Definition 1.1 is exponentially larger compared to our final optimized construction of Section 3. Nevertheless, it is instructive and motivates our optimized construction.

Let hu(k)h_{u}^{(k)} denote the label of a vertex uu in the kkth iteration. For our first construction, we will always maintain the invariant that hu(k)h_{u}^{(k)} will be a one-hot encoded vector in {0,1}F\{0,1\}^{F} for all u∈Vu\in V and all iterations kk. F>2nF>2n will be a prime which also satisfies F=O(poly⁡(n))F=O(\operatorname{poly}(n)). As stated previously, the aggregate function ff will just be the sum function. Our construction for the neural network used in the kkth iteration, ϕ(k)\phi^{(k)}, will take in the sum of the neighbors labels according to Equation (1.1) and output a one-hot encoded vector in {0,1}F\{0,1\}^{F}.

Our construction for ϕ(k)\phi^{(k)} is the following: First recall the notation from (simplified) Equation 1.1:

ϕ(k)\phi^{(k)} then computes ⟨x,a⟩ mod F\langle x,a\rangle\bmod F.

Altogether, ϕ(k)\phi^{(k)} can be summarized as: hv(k)=One-Hot(⟨∑w∈N(v)hw(k−1),a⟩ mod F)h_{v}^{(k)}=\text{One-Hot}\left(\left\langle\sum_{w\in\mathcal{N}(v)}h_{w}^{(k-1)},a\right\rangle\bmod F\right).

Note that we set the initial labels hu(0)h_{u}^{(0)} to be the same starting vector for all vertices (any one-hot vector). This matches the WL test which also initializes all nodes with the same initial label. Furthermore, the weights of ϕ(k)\phi^{(k)} are independent: the random vector aa is sampled independently for each iteration.

The following lemma proves that the above construction satisfies the requirement of Definition 1.1. Its proof is given in Appendix B.

Let {hw(k−1):w∈N(v)}\{h_{w}^{(k-1)}:w\in\mathcal{N}(v)\} and {hw(k−1):w∈N(u)}\{h_{w}^{(k-1)}:w\in\mathcal{N}(u)\} denote the multiset of neighborhood labels for vertices vv and uu respectively. If the multisets are distinct then the labels computed for vv and uu in the kkth iteration are the same with probability at most O(1/F)O(1/F). If the multisets are the same then the labels are the same, i.e., the kkth iteration is successful according to Definition 1.1.

We now evaluate the size complexity of implementing our construction via a neural network ϕ\phi. Note that Step 11 of the construction can be done with 11 layer as it simply involves taking an inner product. The main challenge is to implement the modulo function. We give the following construction in Section B.1 of the appendix.

Suppose F=poly⁡(n)F=\operatorname{poly}(n). There exists an explicit construction of a network which computes modulo FF in the domain {0,…,nF}\{0,\ldots,nF\} using a ReLU network with O(log⁡n)O(\log n) hidden units and O(log⁡n)O(\log n) depth. More generally, given an integer parameter t>0t>0, the function can be computed with O((Fn)O(1/t)log⁡n)O((Fn)^{O(1/t)}\log n) hidden units and O(t)O(t) depth.

Directly appealing to the theorem above, we can implement modulo FF required in Step 22 of the construction using a neural network with O(log⁡n)O(\log n) units, depth O(log⁡n)O(\log n). In addition, we need only O(log⁡n)O(\log n) bits to represent the weights.

Finally, Step 33 of our construction requires outputting a one hot encoding. We can do this by inputting zz (the output of Step 22 of the construction) into FF indicator functions, each of which detect if zz is equal to a particular integer in [F][F]. Each indicator function can be implemented via O(1)O(1) ReLU nodes as follows. Let

which can be easily implemented as a ReLU network. (Note min⁡(a,b)=a+b−max⁡(a,b)\min(a,b)=a+b-\max(a,b) and max⁡(a,b)=max⁡(a−b,0)+b=ReLU(a−b)+b\max(a,b)=\max(a-b,0)+b=\text{ReLU}(a-b)+b.) It can be checked that g(0)=1g(0)=1 and g(x)=0g(x)=0 for all other integers x≠0x\neq 0 and that gg can be implemented with O(1)O(1) ReLU function compositions. Thus, Step 33 of the construction requires O(1)O(1) hidden layers and O(F)O(F) total hidden units. Altogether we have proven the following result.

There exists a construction of a neural network ϕ\phi which performs a successful iteration according to Definition 1.1 with failure probability p=O(1/∣F∣)p=O(1/|F|). ϕ\phi has depth O(log⁡n)O(\log n), O(F)O(F) hidden units, and requires O(log⁡(nF))O(\log(nF)) bits of precision. Furthermore, all labels in all iterations are vectors in {0,1}F\{0,1\}^{F}. More generally, given an integer parameter t>0t>0, the function can be computed with nO(1/t)polylog⁡(n)n^{O(1/t)}\operatorname{polylog}(n) hidden units and O(t)O(t) depth.

In the standard WL test, the number of iterations is chosen to be O(n)O(n). Thus the right setting of FF in Theorem 2.3 is F=O(poly⁡(n))F=O(\operatorname{poly}(n)) which gives us depth O(log⁡n)O(\log n), O(poly⁡(n))O(\operatorname{poly}(n)) hidden units, and requires O(log⁡n)O(\log n) bits of precision in addition to labels in dimension O(poly⁡(n))O(\operatorname{poly}(n)).

Second Construction: Polylogarithmic-size GNN via Pseudo-randomness

We now present a more efficient construction of a GNN which simulates the WL test with an exponential improvement in the number of hidden units and label size. To motivate the improvement, we consider Step 33 of the prior construction which outputs a one-hot encoding. The one-hot encoding was useful as it allowed us to index into a uniformly random vector aa (which we then sum over mod FF in order to hash the neighborhood’s labels). However, this limited us to use feature vectors of a large dimension and required many hidden units to create one-hot vectors. Instead of working with one-hot encodings as an intermediary, we will directly compute the entries of the random vector aa as needed. This has two advantages: we can significantly reduce the dimension of the feature vectors as well as reduce the total size of the neural networks used. We accomplish this via using pseudo-random vectors whose entries can be generated as needed with a small ReLU neural network (see Corollary 3.3). This allows us to use node labels in dimension O(log⁡n)O(\log n) as opposed to O(n)O(n).

The random vectors we employ have their entries generated from an ε\varepsilon-biased sample space. These are random vectors which are approximately uniform and they have been well-studied in the complexity-theory literature. We recall some definitions below.

A probability distribution over {0,1}m\{0,1\}^{m} is called an ε\varepsilon-biased sample space if biasI(X)≤ε\textup{bias}_{I}(X)\leq\varepsilon holds for all non-empty subsets I⊆{1,…,m}I\subseteq\{1,\ldots,m\}.

Note that the uniform distribution has bias . We now state our construction for the neural network used in the kkth iteration, ϕ(k)\phi^{(k)}. We recall that hu(k)h_{u}^{(k)} denotes the label of a vertex uu in the kkth iteration.

Our construction for ϕ(k)\phi^{(k)} is the following:

Let FF be a prime of size poly⁡(n)\operatorname{poly}(n) which is at least 2n2n.

For each node vv, ϕ(k)\phi^{(k)} computes zv=⟨b,∑w∈N(v)hw(k−1)⟩ mod Fz_{v}=\langle b,\sum_{w\in\mathcal{N}(v)}h_{w}^{(k-1)}\rangle\bmod F where every entry of bb is uniformly random in {0,…,F−1}\{0,\ldots,F-1\}. Note ∑w∈N(v)hw(k−1)\sum_{w\in\mathcal{N}(v)}h_{w}^{(k-1)} is the output of the aggregation ff.

Let at∈{0,1}Fa^{t}\in\{0,1\}^{F} for t=1,…,Clog⁡nt=1,\ldots,C\log n be vectors which are independently drawn from an ε\varepsilon-biased sample space for a sufficiently small constant ε\varepsilon.

The output hv(k)h_{v}^{(k)} will be a Clog⁡nC\log n dimensional binary vector where the tt-th coordinate is equal to the zvz_{v}-th coordinate of the vector ata^{t}. In other words, hv(k)=(at(zv))t=1Clog⁡nh_{v}^{(k)}=(a^{t}(z_{v}))_{t=1}^{C\log n} where at(zv)a^{t}(z_{v}) denotes the zvz_{v}-th coordinate of ata^{t}.

We now prove the correctness of our construction. We will refer to zvz_{v} computed in Step 33 of the construction as the index of vv for the kkth iteration. To prove the correctness of the above construction, it suffices to prove the lemma below which shows our construction satisfies Definition 1.1.

Let {hw(k−1):w∈N(v)}\{h_{w}^{(k-1)}:w\in\mathcal{N}(v)\} and {hw(k−1):w∈N(u)}\{h_{w}^{(k-1)}:w\in\mathcal{N}(u)\} denote the multiset of neighborhood labels for vertices vv and uu respectively. If the multisets are distinct then the labels computed for vv and uu in the kkth iteration are distinct with probability 1−1/poly⁡(n)1-1/\operatorname{poly}(n). If the multisets are the same then the labels are the same, i.e., the kkth iteration is successful according to Definition 1.1.

We first need the following auxiliary lemma about ε\varepsilon-biased sample spaces, proven in Section C.

Note that this lemma is necessary, as we will be computing dot products of aa with integer vectors (over integers), not with binary vectors modulo 22.

Let x′=∑w∈N(v)hw(k−1)x^{\prime}=\sum_{w\in\mathcal{N}(v)}h_{w}^{(k-1)} denote the input for vv and analogously, define y′=∑w∈N(u)hw(k−1)y^{\prime}=\sum_{w\in\mathcal{N}(u)}h_{w}^{(k-1)} to be the input for uu. We first show that if {hw(k−1):w∈N(v)}\{h_{w}^{(k-1)}:w\in\mathcal{N}(v)\} is not equal to (as multisets) {hw(k−1):w∈N(u)}\{h_{w}^{(k-1)}:w\in\mathcal{N}(u)\} then x′≠y′x^{\prime}\neq y^{\prime} with sufficiently large probability. We further consider the case that k≥2k\geq 2 since for k=1k=1 (the first iteration), the statement follows since all node labels are initialized to be the same. Let zv′z_{v}^{\prime} be the indices computed in Step 33 of iteration k−1k-1 (which are used to construct the node labels hv(k−1)h_{v}^{(k-1)} in iteration k−1k-1). Note that there is a one to one mapping between zv′z_{v}^{\prime} and hv(k−1)h_{v}^{(k-1)}. Thus we can assume {zw′:w∈N(v)}≠{zw′:w∈N(u)}\{z_{w}^{\prime}:w\in\mathcal{N}(v)\}\neq\{z_{w}^{\prime}:w\in\mathcal{N}(u)\} without loss of generality.

We now condition on x′≠y′x^{\prime}\neq y^{\prime}. Without loss of generality, suppose that their first coordinates, x1′x^{\prime}_{1} and y1′y^{\prime}_{1}, differ. We know x1′≠y1′ mod Fx^{\prime}_{1}\neq y^{\prime}_{1}\bmod F since x1′≠y1′x^{\prime}_{1}\neq y^{\prime}_{1}, they are both non-negative and bounded by nn, and ∣x1′−y1′∣≤O(n)|x^{\prime}_{1}-y^{\prime}_{1}|\leq O(n) whereas FF is a prime at least 2n2n. It follows that the probability of the event ⟨(x′−y′),b⟩=0 mod F\langle(x^{\prime}-y^{\prime}),b\rangle=0\bmod F is at most 1/F1/F. To see this, condition on all the entries of bb except b1b_{1}. Then (x′−y′)1⋅b1(x^{\prime}-y^{\prime})_{1}\cdot b_{1} must be equal to a specific value modulo FF for ⟨(x′−y′),b⟩=0 mod F\langle(x^{\prime}-y^{\prime}),b\rangle=0\bmod F to hold, as desired. We now condition on this event which equivalently means we condition on zv≠zuz_{v}\neq z_{u} (see Step 33 of the construction).

We now analyze the overall complexity of representing ϕ(k)\phi^{(k)} as a ReLU neural network. First we state guarantees on generating ε\varepsilon-based vectors using a ReLU network. The following corollary is proven in Appendix C.

Let s=O(log⁡F+log⁡(1/ε))s=O(\log F+\log(1/\varepsilon)). For every ε\varepsilon and FF, there exists an explicit ReLU network C:{0,1}s∪[F]→{0,1}FC:\{0,1\}^{s}\cup[F]\rightarrow\{0,1\}^{F} which takes as input ss uniform random bits and an index i∈Fi\in F and outputs the iith coordinate of an ε\varepsilon-biased vector in {0,1}F\{0,1\}^{F}. CC uses O(log⁡F)O(\log F) bits of precision and has poly⁡(s)\operatorname{poly}(s) hidden units. More generally, given an integer parameter t>0t>0, the function can be computed with nO(1/t)polylog⁡(n)n^{O(1/t)}\operatorname{polylog}(n) hidden units and O(t)O(t) depth.

We can now analyze the complexity of our construction. The complexity can be computed by analyzing each step of the construction separately as follows:

For every node vv, the sum of feature vectors of neighbors from the prior iteration, ∑w∈N(v)hw(k−1)\sum_{w\in\mathcal{N}(v)}h_{w}^{(k-1)}, is returned by the aggregate function ff.

The inner product with the random vector bb in Step 33 of the construction can be computed using one layer of the network. Then computing modulo FF can be constructed via Theorem 2.2.

Given the inner product value zvz_{v} which is the output of Step 33 of the construction, we compute all of the O(log⁡n)O(\log n) coordinates of hv(k)h_{v}^{(k)} in parallel. We recall that each coordinate of hv(k)h_{v}^{(k)} is indexing onto O(log⁡n)O(\log n) ε\varepsilon-biased random vectors and we use the same index for all vectors, namely the zvz_{v}-th index. This can be done as follows. We first have O(log⁡n)O(\log n) edges fanning-out from the node which computes zvz_{v}. For all t=1,…,O(log⁡n)t=1,\ldots,O(\log n), the other endpoint of the tt-th fan-out edge computes the value at(zv)a^{t}(z_{v}) where ata^{t} is the tt-th ε\varepsilon-biased vector as stated in Steps 4 and 5 of the construction. This can be done by appealing to the construction guaranteed by Corollary 3.3. The result of this computation is exactly hv(k)h_{v}^{(k)}.

Altogether, we have proven the following theorem.

There exists a construction of ϕ\phi which performs a successful WL iteration according to Definition 1.1 with p≤1/poly⁡(n)p\leq 1/\operatorname{poly}(n). ϕ\phi has depth O(log⁡n)O(\log n), O(poly⁡(log⁡n))O(\operatorname{poly}(\log n)) hidden units, and requires O(log⁡n)O(\log n) bits of precision. All labels in all iterations are binary vectors in {0,1}O(log⁡n)\{0,1\}^{O(\log n)}. More generally, given an integer parameter t>0t>0, the function can be computed with nO(1/t)polylog⁡(n)n^{O(1/t)}\operatorname{polylog}(n) hidden units and O(t)O(t) depth.

Lower Bounds

We complement our construction with lower bounds on the label size and number of ReLU units required to simulate the WL test. We outline these two lower bounds below and defer the full details to Appendix D.

Recall that in our construction, the message (label) size was O(log⁡n)O(\log n) bits. Via communication complexity, we give a corresponding lower bound. In particular, we construct a graph on which any (randomized) communication protocol which simulates WL as in Definition 1.1 must send at least Ω(log⁡n)\Omega(\log n) bits along one edge of the graph. As message-passing GNNs are a specific class of communication protocols, this immediately implies that the message sizes must have Ω(log⁡n)\Omega(\log n) bits, so our construction is optimal in that respect.

The hard instance is formed by a graph which is a collection of disjoint star subgraphs of sizes ranging from 22 to Θ(n)\Theta(\sqrt{n}). In order to perform a valid WL coloring, each node must essentially learn the size of its subgraph, requiring Ω(log⁡(n))=Ω(log⁡n)\Omega(\log(\sqrt{n}))=\Omega(\log n) bits of communication. In addition, this must be done in only 22 iterations as the depth of each subgraph is 22, so some node must send Ω(log⁡n)\Omega(\log n) bits to its neighbors in a single round. See Appendix D.1 for the full details and proof.

In order to show a lower bound on the number of units needed to implement a successful WL iteration, we rely on prior work lower bounding the number of linear regions induced by a ReLU network (for instance [MPCB14]). In particular, these works show that ReLU networks induce a partition of the input space into NN convex regions (where NN is a function of the size of the network) such that the network acts as a linear function restricted to any given region. Using these results, we describe a fixed graph and a distribution over inputs to the neural network Su(k−1)S_{u}^{(k-1)} for all u∈Vu\in V (sums of the labels from the previous round) which includes O(F)O(F) potential special pairs of nodes (where FF is defined such that inputs Su(k−1)∈[F]tS_{u}^{(k-1)}\in[F]^{t} for some tt). For each such pair u,vu,v, their neighborhoods N(u),N(v)N(u),N(v) have different multisets of inputs, but both multisets of inputs sum to the same value. We show that if the number of linear regions is small, N=o(F)N=o(F), then it is relatively likely that u,vu,v will be in the same linear region and thus their sums will collide: Su(k)=Sv(k)S_{u}^{(k)}=S_{v}^{(k)} even while their neighborhoods had distinct inputs in the (k−1)(k-1)st round.

This immediately gives a Ω(log⁡F)\Omega(\log F) lower bound on the number of ReLU units (and thus number of parameters) with more refined depth/width tradeoffs given in Section D.2.1. Note that FF is the size of each coordinate in the sum of labels. Even if the labels are binary, FF can be as large as nn, depending on the max degree in the graph, which implies a Ω(log⁡n)\Omega(\log n) lower bound on the number of ReLU units. See Section D.2 for full details and proof.

Experiments

To demonstrate the expressivity of our construction, i.e., that our small-sized GNN reliably simulates the WL test, we perform experiments on both synthetic and real world data sets. Common to all of our experiments is that we start with some graph G=(V,E)G=(V,E) (either real world or generated with respect to some probability distribution). We then simulate a perfect run of the WL test on GG where any two nodes which receive different multisets of labels in iteration k−1k-1 get distinct labels in iteration kk with probability 11 as well as a run of our construction fromSince our goal is to test whether our protocol correctly simulates WL test with small messages, we are not implementing the actual GNNs but instead we are simulating their computation. Further, for simplicity, we replaced the ε\varepsilon-biased sample space with a random string, which guarantees ε=0\varepsilon=0. Section 3. At any point in time, the node labels induce partitions of VV where two nodes are in the same class if they have the same labels. Denote the partitions after kk-iterations using the perfect simulation and our construction respectively by Pk\mathcal{P}_{k} and Pk′\mathcal{P}_{k}^{\prime}. Letting k0k_{0} be minimal such that Pk0−1=Pk0\mathcal{P}_{k_{0}-1}=\mathcal{P}_{k_{0}} (at which point the WL labels have converged), we consider the implementation using our GNN successful if Pk=Pk′\mathcal{P}_{k}=\mathcal{P}_{k}^{\prime} for all k≤k0k\leq k_{0}, i.e., if the the simulation using our implementation induced the same partitions as a perfect runs. For all of our experiments it turned out that k0≤5k_{0}\leq 5 (see [BK22] for a discussion of this fast convergence).

We generated Erdős-Rényi random graphs G(n,p)G(n,p) with p=20/np=20/n for a varying number of vertices nn. For each value of nn, we generated five such graphs and for each of these five graphs, we ran 10 independent trials of our GNN implementation with message sizes t=1,2,…t=1,2,\dots. Averaging over the five graphs, we report the minimal tt such that at least 70%70\% of the 10 iterations successfully simulated the WL test. See Figure 2(a). The average message size needed to achieve this is approximately 3log⁡n3\log n where the logarithmic dependence on nn is as predicted theoretically and significantly improves on the linear message size required for prior constructions.

We generated samples of the scale free graphs from [BBCR03] with a varying number of vertices nn using the implementation from [HSS08]. Our experiment design was the same as for Erdős-Rényi random graphs. See Figure 2(b).

We finally ran experiments on the real world graph Corahttps://graphsandnetworks.com/the-cora-dataset/ which is the citation network of n=2708n=2708 scientific publications. We simulated our GNN with varying message lengths, for each message length reporting the fraction of successful runs of 3030 independent trials. See Figure 2(c) for a plot of the results. We see that with message length 3535, all of the 3030 trials successfully simulated the WL test.

Anders Aamand is supported by DFF-International Postdoc Grant 0164-00022B from the Independent Research Fund Denmark. This research was also supported by the NSF TRIPODS program (award DMS-2022448), NSF award CCF-2006664, Simons Investigator Award, MIT-IBM Watson AI Lab, GIST- MIT Research Collaboration grant, NSF Graduate Research Fellowship under Grant No. 1745302, and MathWorks Engineering Fellowship.

References

Appendix A Omitted Proofs of Section 1

Consider some iteration i≤Ti\leq T. Suppose we have the following guarantee on the node label inputs for the iith iteration (note the inputs are the output labels of the previous iteration):

Appendix B Omitted Proofs of Section 2

We now reduce the modulo FF case to the construction of the triangular wave function.

Appendix C Omitted Proofs for Section 3

We first need to define the circuit class TC0.

For inputs x1,…,xm∈{0,1}x_{1},\ldots,x_{m}\in\{0,1\} the output of a threshold gate, TH, is

TC0 is the class of boolean functions computed by constant-depth poly⁡(m)\operatorname{poly}(m)-size circuits with threshold gates.

It is known that ε\varepsilon-biased vectors can be generated using an efficient circuit in TC0.

Let s=O(log⁡F+log⁡(1/ε))s=O(\log F+\log(1/\varepsilon)). For every ε\varepsilon and FF, there exists an explicit TC0 circuit C:{0,1}s∪{0,1}⌈log2F⌉→{0,1}C:\{0,1\}^{s}\cup\{0,1\}^{\lceil log_{2}F\rceil}\rightarrow\{0,1\} which takes as input ss uniform random bits and an index i∈[F]i\in[F] and outputs the iith coordinate of an ε\varepsilon-biased vector in {0,1}F\{0,1\}^{F}. CC uses poly⁡(s)\operatorname{poly}(s) threshold gates.

Note that the guarantees of Theorem C.1 are not directly applicable since we need to use a ReLU network instead of threshold gates. Nevertheless, since the circuit CC guaranteed by Theorem C.1 has integer inputs in all gates, we can easily approximate each threshold gates using an appropriately scaled ReLU. This is a straightforward and known reduction but we briefly outline a procedure in Lemma C.2.

Consider the threshold gate TH: {0,1}m→{0,1}\{0,1\}^{m}\rightarrow\{0,1\} which computes the threshold ∑i=1maixi≥θ\sum_{i=1}^{m}a_{i}x_{i}\geq\theta. Assume that ai,θa_{i},\theta are all integers bounded by poly⁡(m)\operatorname{poly}(m). TH can be computed by a ReLU network using O(log⁡m)O(\log m) bits of precision and a constant number of parameters.

It is for all integers x≤0x\leq 0 and 11 for all integers ≥1\geq 1, i.e., it computes the threshold ‘‘x≥0"``x\geq 0". By shifting and scaling gg, we can now compute the threshold ‘‘x≥θ"``x\geq\theta" for any integer θ\theta. Finally, the sum ∑i=1maixi\sum_{i=1}^{m}a_{i}x_{i} can be computed using one additional layer. Since all parameters are integers, we only require O(log⁡m)O(\log m) bits of precision to store the shifting and scaling factors. ∎

Lastly, we remark that as per the definition of a threshold gate in Definition C.1, Theorem C.1 requires the index i∈[F]i\in[F] to be inputted as a binary string with its bits given on individual nodes. However, this presents a slight inconsistency with the statement of Theorem C.1 and its corollary, Corollary 3.3 which is used in the construction of Section 3. Specifically, Step 33 of the construction of Section 3 outputs the actual integer i∈[F]i\in[F] which we use as the index for our ε\varepsilon-biased vector, which does not match the format required by Theorem C.1. This inconsistency is straightforward to fix without having any impact whatsoever in the asymptotic size complexity of the neural network. We simply take the integer ii outputted by Step 33 of the construction and compute the jjth bit of ii for all 1≤j≤O(log⁡F)1\leq j\leq O(\log F) in parallel. The jjth bit is exactly equal to if and only if (i mod 2j+1)<2j(i\bmod 2^{j+1})<2^{j} and 11 otherwise. Note that 2j+1=O(F)2^{j+1}=O(F) for all jj and we can easily compute each  mod 2j+1\bmod 2^{j+1} by appealing to Theorem 2.2. This only requires O(1)O(1) extra depth and an additional O(poly⁡(log⁡n))O(\operatorname{poly}(\log n)) hidden units and O(log⁡n)O(\log n) bits of precision. The more general trade-off of Theorem 3.4 also readily holds.

Appendix D Lower bounds

In this appendix we provide lower bounds on the complexity of graph neural networks that are able to simulate the WL test. We present both a communication complexity lower bound and a lower bound on the number of ReLU units of the GNN. More concretely, in Section D.1, we prove that in order to maintain the invariant that with at least some constant probability, nodes with isomorphic neighborhoods get the same label while nodes with non-isomorphic neighborhoods get different labels, some message sent between nodes must be of length at least Ω(log⁡n)\Omega(\log n). This bound matches the upper bound of Theorem 3.4. Second, in Section D.2, we consider a more specific although still fairly general lower bound model which captures the implementation of the WL test using neural networks. We suppose that the messages sent between nodes are tt-dimensional vectors with integral entries. We moreover suppose that each node combines its received messages by summing them to get a vector in [F]t[F]^{t} (here, [F]={0,1,…,F−1}[F]=\{0,1,\dots,F-1\}) and applying a collectively agreed upon neural network ϕ\phi with at most HH ReLU units to this sum. We show that if the combination of summing neighborhoods and applying the neural network maps distinct multisets to distinct elements with at least some constant probability, then H=Ω(log⁡F)H=\Omega(\log F). Moreover, parametrizing in terms of the depth and width of the neural network, we obtain a more fine-grained lower bound, demonstrating that for shallow neural networks, we need even more ReLU units. In Remark D.5, we point out that our lower bound holds even if the aggregation function ff is itself a neural network with a bounded number of ReLU units. As a node in an nn-node graph could have up to n−1n-1 neighbours, we need at least F=Ω(n)F=\Omega(n) in order to store the sum of the messages from the neighbors of the nodes. With this assumption, the lower bound thus becomes Ω(log⁡n)\Omega(\log n) which matches our upper bound up to polylog⁡(n)\operatorname{polylog}(n) factors. It remains an interesting open problem to bridge the gap between the upper and lower bound.

For both our lower bounds we assume that the nodes have access to an infinite public string of random bits. In Section D.2, this is the string which the nodes use to collectively agree on some neural network network ff with respect to some distribution on such networks with at most HH ReLU units.

We consider a forest graph GG composed of pieces G1,G1′,G2,G2′…,Gm,Gm′G_{1},G_{1}^{\prime},G_{2},G_{2}^{\prime}\dots,G_{m},G_{m}^{\prime}, for m=Θ(n)m=\Theta(\sqrt{n}). Each piece GkG_{k} consists of a “top” node uku_{k}, which is only connected to a “middle” node vkv_{k}, which in turn is connected to kk “bottom” nodes wk,1,…,wk,kw_{k,1},\dots,w_{k,k}, and Gk′G_{k}^{\prime} is simply a duplicate of GkG_{k} (with vertices uk′,vk′u_{k}^{\prime},v_{k}^{\prime}, and wk,j′w_{k,j}^{\prime} for 1≤j≤k1\leq j\leq k). See Figure 3 for a depiction of GG. We note that after two rounds, each uku_{k} (and uk′u_{k}^{\prime}) should know the respective value of kk, because the local graph of depth 22 around uku_{k} is distinct for each k∈[m]k\in[m].

Suppose there exists a public random string rr that every node of GG has access to, and each node additionally has some independent private randomness. Suppose there is a communication protocol where by the end, with probability at least 3/43/4, the following hold.

For every k∈[m]k\in[m], the top nodes uku_{k} and uk′u_{k}^{\prime} output the same value.

Then, there must be some kk such that the edge (uk,vk)(u_{k},v_{k}) or the edge (uk′,vk′)(u_{k}^{\prime},v_{k}^{\prime}) has at least Ω(log⁡n)\Omega(\log n) total bits of communication. Hence, if there are only O(1)O(1) rounds of communication, one of those rounds must have sent Ω(log⁡n)\Omega(\log n) bits of communication across the edge.

First, we note that we may assume the communication is one-way from vkv_{k} to uku_{k}. This is because the node vkv_{k} can simulate all communication from uku_{k}, as uku_{k} has no information about neighbors apart from vkv_{k}. So, we just need to show the one-way communication complexity is Ω(log⁡n)\Omega(\log n). Next, we will assume there is no public randomness - we will remove this assumption at the end. So, each uku_{k} (resp., uk′u_{k}^{\prime}) receives at most bb bits of information from vkv_{k} (resp., vk′v_{k}^{\prime}). If vkv_{k} sends a randomized message of length bb to uku_{k} and uku_{k} uses this message to produce some output oko_{k}, with probability at least 34\frac{3}{4} the outputs oko_{k} must all be distinct. In addition, for each kk, the outputs of the duplicate copies of uku_{k} must be the same with probability at least 34\frac{3}{4}. Our goal is to show that b=Ω(log⁡n).b=\Omega(\log n).

To finish, we revisit the fact that we assumed there was no public randomness. Let us reintroduce the random string rr that every node of GG is given. We assume that with probability at least 3/43/4, the top nodes uk,uk′u_{k},u_{k}^{\prime} have the same output for all k∈[m]k\in[m] and that the nodes u1,…,umu_{1},\dots,u_{m} output pairwise distinct values. But as this event happens with probability at least 3/43/4 over a random string rr, there must exist a choice of rr for which it happens with probability at least 3/43/4 conditioned on rr. But then we are back to the case where there is no public randomness, as desired. ∎

D.2 Lower Bound: ReLU Units

We would like our GNN to satisfy that for any nn-node graph GG, and arbitrary inputs x1,…,xnx_{1},\dots,x_{n} to the nodes, it holds with probability at least 9/109/10 over the randomness of DD that zi≠zjz_{i}\neq z_{j} for all i,ji,j such that the multisets {xk∣k∈N(i)}\{x_{k}\mid k\in\mathcal{N}(i)\} and {xk∣k∈N(j)}\{x_{k}\mid k\in\mathcal{N}(j)\} are different. The following theorem provides a lower bound on the number of ReLU units HH needed for this property to hold.

Suppose that the neural networks in ΦH\Phi_{H} have at most H≤lg⁡F−4H\leq\lg F-4 ReLU units. Then there exists a graph GG on nn nodes and inputs x1,…,xn∈[F]tx_{1},\dots,x_{n}\in[F]^{t} such that if N(1),…,N(n)\mathcal{N}(1),\dots,\mathcal{N}(n) are the neighborhoods of the nodes of GG, then with probability at least 1−(34)n/61-\left(\frac{3}{4}\right)^{n/6}, there exists i,j∈[n]i,j\in[n] such that zi=zjz_{i}=z_{j} even though the multisets {xk∣k∈N(i)}\{x_{k}\mid k\in\mathcal{N}(i)\} and {xk∣k∈N(j)}\{x_{k}\mid k\in\mathcal{N}(j)\} are different. Thus, to simulate the WL test with neural networks from ΦH\Phi_{H}, we need H>log⁡F−3H>\log F-3 ReLU units.

Before proving the theorem, we first explain how to interpret it as a lower bound for the computational complexity of implementing a WL iteration as in Definition 1.1 as a neural network. As an initial observation, note that in any iteration kk, if for two nodes uu and vv, the sums Su(k−1)S_{u}^{(k-1)} and Sv(k−1)S_{v}^{(k-1)} are distinct (recall that Su(k−1)=∑u′∈N(u)hu(k−1)\mathcal{S}^{(k-1)}_{u}=\sum_{u^{\prime}\in\mathcal{N}(u)}h^{(k-1)}_{u}), then for the WL iteration to be successful, we must also have that hu(k)≠hv(k)h^{(k)}_{u}\neq h^{(k)}_{v}. This is because, Su(k−1)≠Sv(k−1)S_{u}^{(k-1)}\neq S_{v}^{(k-1)} implies that the multisets {hu′(k−1)∣u′∈N(u)}\{h_{u^{\prime}}^{(k-1)}\mid u^{\prime}\in\mathcal{N}(u)\} and {hv′(k−1)∣v′∈N(v)}\{h_{v^{\prime}}^{(k-1)}\mid v^{\prime}\in\mathcal{N}(v)\} are also distinct. But then Definition 1.1 yields that we need hu(k)≠hv(k)h_{u}^{(k)}\neq h_{v}^{(k)} (at least with some probability 1−p1-p). Now, consider two nodes i=ui=u and j=vj=v such that in some iteration of the WL test, the multisets of sums {Su′(k−1)∣u′∈N(u)}\{\mathcal{S}_{u^{\prime}}^{(k-1)}\mid u^{\prime}\in\mathcal{N}(u)\} and {Sv′(k−1)∣v′∈N(v)}\{\mathcal{S}_{v^{\prime}}^{(k-1)}\mid v^{\prime}\in\mathcal{N}(v)\} are different. This corresponds to the multisets {xk∣k∈N(i)}\{x_{k}\mid k\in\mathcal{N}(i)\} and {xk∣k∈N(j)}\{x_{k}\mid k\in\mathcal{N}(j)\} being different. We would like to argue that for the WL iteration to be successful according to Definition 1.1, for each such pair of nodes u,vu,v, we must have that also Su(k)≠Sv(k)\mathcal{S}_{u}^{(k)}\neq\mathcal{S}_{v}^{(k)} with some good probability (the sums of labels in the next iteration differ). Theorem D.4 tells us that the probability of this happening is very low if we use too few ReLU units. Now why do we require that Su(k)≠Sv(k)\mathcal{S}_{u}^{(k)}\neq\mathcal{S}_{v}^{(k)} for such a pair of nodes u,vu,v?

Since the multisets {Su′(k−1)∣u′∈N(u)}\{\mathcal{S}_{u^{\prime}}^{(k-1)}\mid u^{\prime}\in\mathcal{N}(u)\} and {Sv′(k−1)∣v′∈N(v)}\{\mathcal{S}_{v^{\prime}}^{(k-1)}\mid v^{\prime}\in\mathcal{N}(v)\} are different, by the initial observation, the multisets {hu′(k)∣u′∈N(u)}\{h_{u^{\prime}}^{(k)}\mid u^{\prime}\in\mathcal{N}(u)\} and {hv′(k)∣v′∈N(v)}\{h_{v^{\prime}}^{(k)}\mid v^{\prime}\in\mathcal{N}(v)\} must also be distinct for the WL test to be successful. But since the multisets of labels {hu′(k)∣u′∈N(u)}\{h_{u^{\prime}}^{(k)}\mid u^{\prime}\in\mathcal{N}(u)\} and {hu′(k)∣v′∈N(v)}\{h_{u^{\prime}}^{(k)}\mid v^{\prime}\in\mathcal{N}(v)\} are distinct it follows by another application of Definition 1.1, that we must also have that hu(k+1)≠hv(k+1)h_{u}^{(k+1)}\neq h_{v}^{(k+1)}. However, the only way this can happen is if Su(k)≠Sv(k)\mathcal{S}_{u}^{(k)}\neq\mathcal{S}_{v}^{(k)} as otherwise these two sums will be mapped to the same label by ϕ(k+1)\phi^{(k+1)}.

We remark that this lower bound applies to an isolated WL iteration rather than a full sequence of iterations. In particular, the inputs x1,…,xn∈[F]tx_{1},\dots,x_{n}\in[F]^{t} (corresponding to the sums {Su(k−1)∣u∈G}\{\mathcal{S}_{u}^{(k-1)}\mid u\in G\}) are adversarially chosen while in reality these inputs are not arbitrary but are the result of a prior WL iteration. Our construction in Section 3 indeed works against such adversarially chosen sums in the sense that different multisets of sums are mapped (via applying ϕ(k)\phi^{(k)} and summing the outputs for each multisets) to different sums with high probability, and as such our lower bound is exactly a lower bound for this harder problem. However, in general the sums Sv(k−1)S_{v}^{(k-1)} are not adversarially chosen, and it would very be interesting to find a lower bound that does not require this assumption but works all the way from a graph and its initial labels.

in spite of the multisets, {x6j,x6j+1,x6j+2}\{x_{6j},x_{6j+1},x_{6j+2}\} and {x6j+3,x6j+4,x6j+5}\{x_{6j+3},x_{6j+4},x_{6j+5}\} being different. Now, ϕ\phi is a neural network, so this identity does not need to hold. The idea is however, that if ϕ\phi has only few ReLU units, then we obtain a good upper bound on the number of linear regions by Theorem D.3 and since aa and bb are random, the set Fa,bF_{a,b} is likely to be fully contained in one of these regions. And since ϕ\phi restricted to this region in linear, (D.1) holds in this case.

In other words, if for a fixed i≤n0i\leq n_{0}, (a,b)(a,b) is chosen such that La,bL_{a,b} is fully contained in one of the convex regions, then (D.1) is satisfied. It follows that for any given i<n0i<n_{0},

Since the event (z6i+1=z6i+4)i≤n0(z_{6i+1}=z_{6i+4})_{i\leq n_{0}} are independent (as we choose independent (a,b)(a,b) for each pair of paths (Pi,Pi′)(P_{i},P_{i}^{\prime})), it follows that

If in particular, H≤lg⁡F−4H\leq\lg F-4, we obtain that

As the multisets {xk∣k∈N(6i+1)}\{x_{k}\mid k\in\mathcal{N}(6i+1)\} and {xk∣k∈N(6i+4)}\{x_{k}\mid k\in\mathcal{N}(6i+4)\} are different, this completes the proof. ∎

In analogue with our construction in Section 2 and Section 3, we assumed in the above proof that the aggregate function ff is the summation function. As such, ff is just another neural network but without a single ReLU unit. We can therefore think of the combined computation performed by ff and ϕ\phi (illustrated in Figure 5) as the result of applying a single neural network. It follows from this observation (and the proof of Theorem D.4) that in the more general setting where ff is a function in ΦH1\Phi_{H_{1}} and where the neural network ϕ∈ΦH2\phi\in\Phi_{H_{2}}, then we must have that H1+H2>log⁡F−4H_{1}+H_{2}>\log F-4 in order to successfully simulate the WL test.

The proof of Theorem D.4 used that the number of convex linear regions of any neural network with at most HH ReLU’s is at most 2H2^{H}. However, in many cases one can obtain better upper bounds on the number of such regions, and this directly translates to a better lower bound than the one given in Theorem D.4. Indeed, if the family of neural networks Φ\Phi satisfies that the domain of any ϕ∈Φ\phi\in\Phi can be partitioned into at most KK convex regions such that ϕ\phi restricted to each of these regions is linear, then the lower bound in (D.2) instead becomes

In particular, when using independence of the events (z6i+1=z6i+4)i<n0(z_{6i+1}=z_{6i+4})_{i<n_{0}}, we just need K≤F24K\leq\frac{F}{24}, say, to get that an error occur with probability at least 1−2−Ω(n)1-2^{-\Omega(n)}. Plugging in the bound K≤2HK\leq 2^{H} of Theorem D.3 gave the desired bound of Theorem D.4 which led to the Ω(log⁡F)\Omega(\log F) lower bound. If we instead use the more fine grained theorem below, we obtain better bounds for shallow neural networks with low input dimension as stated in Corollary D.7.

Any ReLU neural network with input dimension tt, width ww, and depth dd has at most O(wd⋅t)O(w^{d\cdot t}) linear regions.

Let Φt,d,w\Phi_{t,d,w} consist of all ReLU neural networks with input dimension tt, depth dd, and width ww. Suppose that we are in the setting of Theorem D.4, except that the neural network is picked from Φt,d,w\Phi_{t,d,w}. Then the conclusion of the theorem holds as long as wd⋅t≤cFw^{d\cdot t}\leq cF for a small enough constant cc. In particular, to simulate the WL test with neural networks from Φt,d,w\Phi_{t,d,w}, we need dw=Ω(dF1dt)dw=\Omega(dF^{\frac{1}{dt}}) ReLU units.

As an example, for shallow neural networks with low input dimension, say with d,t=O(1)d,t=O(1), this lower bound becomes dw=FΩ(1)dw=F^{\Omega(1)}, i.e. polynomial rather than logarithmic in the size of the underlying field.

For certain architectures of the neural networks one can obtain even stronger bounds on the number of linear regions (see e.g., Proposition 3 in [Mon17] and Theorem 1 in [STR18]). These bounds are parametrized in the number of ReLU units in each of the dd layers of the neural networks. One can therefore obtain even more fine grained lower bounds on the number of ReLU units if one makes more assumptions on the family of neural networks but the bounds are more opaque and we refrain from stating them here.

D.2.2 Description complexity

In this subsection, we consider more general function classes Φ\Phi that do not necessarily have to consist of neural networks. We prove that for any aggregation function ff, if for any two distinct multisets of labels each of size at most nn, there exists a function ϕ∈Φ\phi\in\Phi such that the multisets are mapped to different labels by ϕ∘f\phi\circ f, then ∣Φ∣=Ω(nlog⁡n)|\Phi|=\Omega\left(\frac{n}{\log n}\right). It follows that the description complexity of Φ\Phi must be Ω(log⁡n)\Omega(\log n). Our bound is combinatorial, and does not employ the linear structure of FtF^{t}. Hence we may just put t=1t=1 and think of FF as a set rather than a vector space.

Let FF and nn be natural numbers and let N=∑i=0n(i+F−1i)N=\sum_{i=0}^{n}\binom{i+F-1}{i} be the number of multisets of [F][F] of size at most nn. Suppose that ff is any aggregation function mapping multisets of [F][F] to some range R\mathcal{R}. Let Φ\Phi be any set of functions from R\mathcal{R} to FF and assume that ∣Φ∣<log⁡Nlog⁡F|\Phi|<\frac{\log N}{\log F}. Then there exists distinct multisets AA and BB each with at most nn elements from [F][F] such that ϕ(f(A))=ϕ(f(B))\phi(f(A))=\phi(f(B)) for all ϕ∈Φ\phi\in\Phi.

Note that each function ϕ∈Φ\phi\in\Phi induces a partition Pϕ\mathcal{P}_{\phi} on the set of these multisets induced by the equivalence relation defined by X∼ϕY⟺ϕ(f(X))=ϕ(f(Y))X\sim_{\phi}Y\Longleftrightarrow\phi(f(X))=\phi(f(Y)). By repeated application of the pidgeonhole principle, there must exists a collection C\mathcal{C} of multisets each containing at most nn elements from [F][F] such that (1) for all ϕ∈Φ\phi\in\Phi and all X,Y∈CX,Y\in\mathcal{C}, X∼ϕYX\sim_{\phi}Y and (2) ∣C∣≥N/F∣Φ∣|\mathcal{C}|\geq N/F^{|\Phi|}. If in particular ∣Φ∣<log⁡Nlog⁡F|\Phi|<\frac{\log N}{\log F}, we must have that ∣C∣≥2|\mathcal{C}|\geq 2. Letting AA and BB be distinct elements of C\mathcal{C}, we have that ϕ(f(A))=ϕ(f(B))\phi(f(A))=\phi(f(B)) for all ϕ∈Φ\phi\in\Phi. ∎

Note that number of distinct degrees of the vertices of a simple nn-node graph could be as large as Ω(n)\Omega(n), so it is a natural assumption that also F=Ω(n)F=\Omega(n). Indeed, if FF is smaller, then for such a graph, the simulation of the WL test will fail with probability 11 since it must inevitably assign two nodes of distinct degrees the same label in FF. With this assumption, it follows that

using the inequality (nk)≥(nk)k\binom{n}{k}\geq\left(\frac{n}{k}\right)^{k}. Thus,

In particular, the description complexity of Φ\Phi has to be Ω(log⁡n)\Omega(\log n) in order to separate any two distinct multisets X,Y⊂FX,Y\subset F each consisting of at most nn elements. We note that the description complexity of the construction in Section 3 is poly⁡log⁡n\operatorname{poly}\log n.