SlowGuess/NeurIPS_2023_OCR huggingface dataset:
A Preliminaries for Proofs 15
B Proof of Proposition 3 18
C Proof of Theorem 4 20
D Proof of Theorem 5 and Theorem 6 21
E Proof of Theorem 9 23
F Proof of Theorem 10 25
G Proof of Theorem 11 26
H Proof of Theorem 15 28
I Proof of Theorem 16 31
J Proof of Theorem 17 33
KExperiment Supplementary 34
K.1 Synthetic dataset generation 34
K.2 Statistical Information for Datasets 34
K.3 Hyper-parameters 35
K.4 More Results 35
A Preliminaries for Proofs
In this section, we give some preliminaries which will be used to prove the theorems, propositions and lemmas shown in our main body. In what follows, we fix a unary predicate set  $P_{1}$  and a binary predicate set  $P_{2}$ .
Definition 18. For an  $R^2$ -GNN, we say it is a 0/1-GNN if the recursive formula used to compute vectors  $\mathbf{x}_v^{(i)}$  for each node  $v$  in a multi-relational graph  $G = \{V, \mathcal{E}, P_1, P_2\}$  on each layer  $i$  is in the following form
$$
\mathbf {x} _ {v} ^ {(i)} = f \left(C ^ {(i)} \left(\mathbf {x} _ {v} ^ {(i - 1)} + \sum_ {r \in P _ {2}} \sum_ {u \in V} A _ {r} ^ {(i)} \mathbf {x} _ {u} ^ {(i - 1)} + R ^ {(i)} \left(\sum_ {u \in V} \mathbf {x} _ {u} ^ {(i - 1)}\right) + b ^ {(i)}\right)\right) \tag {5}
$$
where  $C^{(i)}, A_{j}^{(i)}, R^{(i)}$  are all integer matrices of size  $d_{i} \times d_{i-1}$ ,  $b^{(i)}$  is bias column vector with size  $d_{i} \times 1$ , where  $d_{i-1}$  and  $d_{i}$  are input/output dimensions, and  $f$  is defined as  $\max(0, \min(x, 1))$ .
Furthermore, we restrict the final output dimension be  $d_{L} = 1$ . Since all matrices have integer elements, initial vectors are integer vectors by initialisation function  $I(\cdot)$  (Section 2.2), and  $\max(0, \min(x, 1))$  will map all integers to  $0/1$ , it's easy to see that the output of this kind of model is always  $0/1$ , which can be directly used as the classification result. We call such model  $0/1$ -GNN. A model instance can be represented by  $\{C^{(i)}, (A_j^{(i)})_{j=1}^K, R^{(i)}, b^{(i)}\}_{i=1}^L$ , where  $K = |P_2|$
Lemma 19. Regard  $0/1$ -GNN as node classifier, then the set of node classifiers represented by  $0/1$ -GNN is closed under  $\wedge, \vee, \neg$ .
Proof. Given two 0/1-GNN  $\mathcal{A}_1, \mathcal{A}_2$ , it suffices to show that we can construct  $\neg \mathcal{A}_1$  and  $\mathcal{A}_1 \wedge \mathcal{A}_2$  in 0/1-GNN framework. That's because construction of  $\mathcal{A}_1 \vee \mathcal{A}_2$  can be reduced to constructions of  $\wedge, \neg$  by De Morgan's law, e.g.,  $a \lor b = \neg (\neg a \wedge \neg b)$ .
1. Construct  $\neg \mathcal{A}_1$ . Append a new layer to  $\mathcal{A}_1$  with dimension  $d_{L+1} = 1$ . For matrices and bias  $C^{(L+1)}, (A_j^{(L+1)})_{j=1}^K, R^{(L+1)}, b^{(L+1)}$  in layer  $L+1$ , set  $C_{1,1}^{L+1} = -1$  and  $b_1^{L+1} = 1$  and other parameters 0. Then it follows  $\mathbf{x}_v^{(L+1)} = \max(0, \min(-\mathbf{x}_v^{(L)} + 1, 1))$ . Since  $\mathbf{x}_v^{(L)}$  is the  $0/1$  classification result outputted by  $\mathcal{A}_1$ . It's easy to see that the above equation is exactly  $\mathbf{x}_v^{(L+1)} = \neg \mathbf{x}_v^{(L)}$ .
2. Construct  $\mathcal{A}_1\wedge \mathcal{A}_2$ . Without loss of generality, we can assume two models have same layer number  $L$  and same feature dimension  $d_{l}$  in each layer  $l\in \{1,\dots..L\}$ . Then, we can construct a new 0/1-GNN  $\mathcal{A}$ .  $\mathcal{A}$  has  $L + 1$  layers. For each of the first  $L$  layers, say  $l$ -th layer, it has feature dimension  $2d_{l}$ . Let  $\{C_1^{(l)},(A_{j,1}^{(l)})_{j = 1}^K,R_1^{(l)},b_1^{(l)}\},\{C_2^{(l)},(A_{j,2}^{(l)})_{j = 1}^K,R_2^{(l)},b_2^{(l)}\}$  be parameters in layer  $l$  of  $\mathcal{A}_1,\mathcal{A}_2$  respectively. Parameters for layer  $l$  of  $\mathcal{A}$  are defined below
$$
\mathbf {C} ^ {(l)} := \left[ \begin{array}{c c} \mathbf {C} _ {1} ^ {(l)} & \\ & \mathbf {C} _ {2} ^ {(l)} \end{array} \right] \mathbf {A} _ {j} ^ {(l)} := \left[ \begin{array}{c c} \mathbf {A} _ {j, 1} ^ {(l)} & \\ & \mathbf {A} _ {j, 2} ^ {(l)} \end{array} \right] \mathbf {R} ^ {(l)} := \left[ \begin{array}{c c} \mathbf {R} _ {1} ^ {(l)} & \\ & \mathbf {R} _ {2} ^ {(l)} \end{array} \right] \mathbf {b} ^ {(l)} := \left[ \begin{array}{c} \mathbf {b} _ {1} ^ {(l)} \\ \mathbf {b} _ {2} ^ {(l)} \end{array} \right] \tag {6}
$$
Initialization function of  $\mathcal{A}$  is concatenation of initial feature of  $\mathcal{A}_1, \mathcal{A}_2$ . Then it's easy to see that the feature  $\mathbf{x}_v^L$  after running first  $L$  layers of  $\mathcal{A}$  is a two dimension vector, and the two dimensions contain two values representing the classification results outputted by  $\mathcal{A}_1, \mathcal{A}_2$  respectively.
For the last layer  $L + 1$ , it has only one output dimension. We just set  $\mathbf{C}_{1,1}^{L + 1} = \mathbf{C}_{1,2}^{L + 1} = 1, \mathbf{b}_1^{L + 1} = -1$  and all other parameters 0. Then it's equivalent to  $\mathbf{x}_v^{(L + 1)} = \max(0, \min(\mathbf{x}_{v,1}^{(L)} + \mathbf{x}_{v,2}^{(L)} - 1, 1))$  where  $\mathbf{x}_{v,1}^{(L)}, \mathbf{x}_{v,2}^{(L)}$  are output of  $\mathcal{A}_1, \mathcal{A}_2$  respectively. It's easy to see that the above equation is equivalent to  $\mathbf{x}_v^{(L + 1)} = \mathbf{x}_{v,1}^{(L)} \wedge \mathbf{x}_{v,2}^{(L)}$  so the  $\mathcal{A}$  constructed in this way is exactly  $\mathcal{A}_1 \wedge \mathcal{A}_2$
Definition 20. A  $\mathcal{FOC}_2$  formula is defined inductively according to the following grammar:
$$
A (x), r (x, y), \varphi_ {1} \wedge \varphi_ {2}, \varphi_ {1} \vee \varphi_ {2}, \neg \varphi_ {1}, \exists^ {\geq n} y (\varphi_ {1} (x, y)) \text {w h e r e} A \in P _ {1} \text {a n d} r \in P _ {2} \tag {7}
$$
Definition 21. For any subset  $S \subseteq P_2$ , let  $\varphi_S(x,y)$  denote the  $\mathcal{FOC}_2$  formula  $(\bigwedge_{r \in S} r(x,y)) \wedge (\bigwedge_{r \in P_2 \setminus S} \neg r(x,y))$ . Note that  $\varphi_S(x,y)$  means there is a relation  $r$  between  $x$  and  $y$  if and only if  $r \in S$ , so  $\varphi_S(x,y)$  can be seen as a formula to restrict specific relation distribution between two nodes.  $\mathcal{RSFOC}_2$  is inductively defined according to the following grammar:
$$
A (x), \varphi_ {1} \wedge \varphi_ {2}, \varphi_ {1} \vee \varphi_ {2}, \neg \varphi_ {1}, \exists^ {\geq n} y \left(\varphi_ {S} (x, y) \wedge \varphi_ {1} (y)\right) \text {w h e r e} A \in P _ {1} \text {a n d} S \subseteq P _ {2} \tag {8}
$$
Next, we prove that  $\mathcal{FOC}_2$  and  $\mathcal{RSFOC}_2$  have the same expressiveness, namely, each  $\mathcal{FOC}_2$  node classifier can be rewritten in the form  $\mathcal{RSFOC}_2$ .
Lemma 22.  $\mathcal{FOC}_2 = \mathcal{RSFOC}_2$
Proof. Comparing the definitions of  $\mathcal{R}SFOC_2$  and  $FOC_{2}$ , it is obvious that  $\mathcal{R}SFOC_2\subseteq FOC_2$  trivially holds, so we only need to prove the other direction, namely,  $FOC_{2}\subseteq RSFOC_{2}$ . In particular, a Boolean logical classifier only contains one free variable, we only need to prove that for any one-free-variable  $FOC_{2}$  formula  $\varphi (x)$ , we can construct an equivalent  $\mathcal{R}SFOC_2$  formula  $\psi (x)$ .
We prove Lemma 22 by induction over  $k$ , where  $k$  is the quantifier depth of  $\varphi(x)$ .
In the base case where  $k = 0$ ,  $\varphi(x)$  is just the result of applying conjunction, disjunction or negation to a bunch of unary predicates  $A(x)$ , where  $A \in P_1$ . Given that the grammar of generating  $\varphi(x)$  is the same in  $\mathcal{R}S\mathcal{F}\mathcal{O}\mathcal{C}_2$  and  $\mathcal{F}\mathcal{O}\mathcal{C}_2$  when  $k = 0$ , so the lemma holds for  $k = 0$ .
For the inductive step, we assume that Lemma 22 holds for all  $\mathcal{RSFOC}_2$  formula with quantifier depth no more than  $m$ , we next need to consider the case when  $k = m + 1$ .
We can decompose  $\varphi(x)$  to be boolean combination of a bunch of  $\mathcal{FOC}_2$  formulas  $\varphi_1(x), \ldots, \varphi_N(x)$ , each of which is in the form  $\varphi_i(x) := A(x)$  where  $A \in P_1$  or  $\varphi_i(x) := \exists^{\geq n} y(\varphi'(x,y))$ . See the following example for reference.
Example 23. Assume  $\varphi(x) \coloneqq (A_1(x) \wedge \exists y(r_1(x,y))) \vee (\exists y(A_2(y) \wedge r_2(x,y)) \wedge \exists y(r_3(x,y)))$ . It can be decomposed into boolean combinations of four subformulas shown as follows:
-  $\varphi_{1}(x) = A_{1}(x)$
-  $\varphi_{2}(x) = \exists y(r_{1}(x,y))$
-  $\varphi_3(x) = \exists y(A_2(y)\wedge r_2(x,y))$
-  $\varphi_4(x) = \exists y(r_3(x,y))$
We can see that grammars of  $\mathcal{FOC}_2$  and  $\mathcal{RSFOC}_2$  have a common part:  $A(x),\varphi_1\wedge \varphi_2,\varphi_1\vee \varphi_2,\neg \varphi_1$  so we can only focus on those subformulas  $\varphi_{i}(x)$  in the form of  $\exists^{\geq n}y\varphi '(x,y)$ . In other words, if we can rewrite these  $\mathcal{FOC}_2$  subformulas into another form satisfying the grammar of  $\mathcal{RSFOC}_2$ , we can naturally construct the desired  $\mathcal{RSFOC}_2$  formula  $\psi (x)$  equivalent to  $\mathcal{FOC}_2$  formula  $\varphi (x)$ .
Without loss of generality, in what follows, we consider the construction for  $\varphi(x) = \exists^{\geq n}y(\varphi'(x,y))$ . Note that  $\varphi(x)$  has quantifier depth no more than  $m + 1$ , and  $\varphi'(x,y)$  has quantifier depth no more than  $m$ .
We can decompose  $\varphi'(x,y)$  into three sets of subformulas  $\{\varphi_i^x(x)\}_{i=1}^{N_x}, \{\varphi_i^y(y)\}_{i=1}^{N_y}, \{r_i(x,y)\}_{i=1}^{|P_2|}$ , where  $N_x$  and  $N_y$  are two natural numbers,  $\varphi_i^x, \varphi_i^y$  are its maximal subformulas whose free variable is assigned to  $x$  and  $y$ , respectively.  $\varphi'(x)$  is the combination of these sets of subformulas using  $\wedge, \vee, \neg$ .
Example 24. Assume that we have a  $\mathcal{FOC}_2$  formula in the form of  $\varphi'(x,y) = (r_1(x,y) \wedge \exists x(r_2(x,y))) \vee (\exists y(\exists x(r_3(x,y)) \vee \exists y(r_1(x,y))) \wedge \exists y(A_2(y) \wedge r_2(x,y)))$
It can be decomposed into the following subformulas:
-  $\varphi_1^x (x)\coloneqq \exists y\big(\exists x(r_3(x,y))\lor \exists y(r_1(x,y))\big);$
$\varphi_2^x (x)\coloneqq \exists y(A_2(y)\wedge r_2(x,y));$
-  $\varphi_1^y (y)\coloneqq \exists x(r_2(x,y));$
$r_1(x,y)$
Assume that  $N \coloneqq \{1, \dots, N_x\}$ , we construct a  $\mathcal{RSFOC}_2$  formula  $\varphi_T^x(x) \coloneqq (\bigwedge_{i \in T} \varphi_i^x(x)) \wedge (\bigwedge_{i \in N \setminus T} \neg \varphi_i^x(x))$ , where  $T \subseteq N$ . It is called the  $x$ -specification formula, which means  $\varphi_T^x(x)$  is true iff the following condition holds: for all  $i \in T$ ,  $\varphi_i^x(x)$  is true and for all  $i \in N \setminus T$ ,  $\varphi_i^x(x)$  is false.
By decomposing  $\varphi'(x,y)$  into three subformula sets, we know Boolean value of  $\varphi'(x,y)$  can be decided by Boolean values of these formulas  $\{\varphi_i^x(x)\}_{i=1}^{N_x}, \{\varphi_i^y(y)\}_{i=1}^{N_y}, \{r_i(x,y)\}_{i=1}^{|P_2|}$ . Now for any two specific subsets  $S \subseteq P_2$ ,  $T \subset N$ , we assume  $\varphi_S(x,y)$  and  $\varphi_T^x(x)$  are all true (Recall the definition of  $\varphi_S(x,y)$  in Definition 21). Then Boolean values for formulas in  $\{\varphi_i^x(x)\}_{i=1}^{N_x}, \{r_i(x,y)\}_{i=1}^{|P_2|}$  are determined and Boolean value of  $\varphi'(x,y)$  depends only on Boolean values of  $\{\varphi_i^y(y)\}_{i=1}^{N_y}$ . Therefore, we can write a new  $\mathcal{FOC}_2$  formula  $\varphi_{S,T}^y(y)$  which is a boolean combination of  $\{\varphi_i^y(y)\}_{i=1}^{N_y}$ . This formula should satisfy the following condition: For any graph  $G$  and two nodes  $a,b$  on it, the following holds,
$$
\varphi_ {S} (a, b) \wedge \varphi_ {T} ^ {x} (a) \Rightarrow \left(\varphi^ {\prime} (a, b) \Leftrightarrow \varphi_ {S, T} ^ {y} (b)\right) \tag {9}
$$
By our inductive assumption,  $\varphi'(x,y)$  has a quantifier depth which is no more than  $m$ , so  $\{\varphi_i^x(y)\}_{i=1}^{N_x}, \{\varphi_i^y(y)\}_{i=1}^{N_y}$  also have quantifier depths no more than  $m$ . Therefore, each of them has  $\mathcal{R}SFOC_2$  correspondence. Furthermore, since  $\wedge, \vee, \neg$  are allowed operation in  $\mathcal{R}SFOC_2$ ,  $\varphi_T^x(x)$  and  $\varphi_{S,T}^y(y)$  can also be rewritten as  $\mathcal{R}SFOC_2$  formulas.
Given that  $\varphi_S(x,y)$  and  $\varphi_T^x (y)$  specify the boolean values for all  $\{\varphi_i^x (y)\}_{i = 1}^{N_x},\{\varphi_i^r (x,y)\}_{i = 1}^{|P_2|}$  formulas, so we can enumerate all possibilities over  $S\subseteq P_{2}$  and  $T\subseteq N$  . Obviously for any graph  $G$  and a node pair  $(a,b)$  , there exists an unique  $(S,T)$  pair such that  $\varphi_S(a,b)\wedge \varphi_T^x (a)$  holds.
Hence, combining Equation (9),  $\varphi'(x,y)$  is true only when there exists a  $(S,T)$  pair such that  $\varphi_S(x,y) \wedge \varphi_T^x(x) \wedge \varphi_{S,T}^y(y)$  is true. Formally, we can rewrite  $\varphi'(x,y)$  as following form:
$$
\varphi^ {\prime} (x, y) \equiv \bigvee_ {S \subseteq P _ {2}, T \subseteq N} \left(\varphi_ {S} (x, y) \wedge \varphi_ {T} ^ {x} (x) \wedge \varphi_ {S, T} ^ {y} (y)\right) \tag {10}
$$
In order to simplify the formula above, let  $\phi_T(x)$  denote the following formula:
$$
\phi_ {T} (x, y) := \bigvee_ {S \subseteq P _ {2}} \left(\varphi_ {S} (x, y) \wedge \varphi_ {S, T} ^ {y} (y)\right) \tag {11}
$$
Then we can simplify Equation (10) to the following form:
$$
\varphi^ {\prime} (x, y) \equiv \bigvee_ {T \subseteq N} \left(\varphi_ {T} ^ {x} (x) \wedge \phi_ {T} (x, y)\right) \tag {12}
$$
Recall that  $\varphi (x) = \exists^{\geq n}y(\varphi '(x,y))$ , so it can be rewritten as:
$$
\varphi (x) \equiv \exists^ {\geq n} y \left(\bigvee_ {T \subseteq N} \left(\varphi_ {T} ^ {x} (x) \wedge \phi_ {T} (x, y)\right)\right) \tag {13}
$$
Since for any graph  $G$  and its node  $a$ , there exists exactly one  $T$  such that  $\varphi_T^x(a)$  is true. Therefore, Equation (13) can be rewritten as the following formula:
$$
\varphi (x) \equiv \bigvee_ {T \subseteq N} \left(\varphi_ {T} ^ {x} (x) \wedge \exists^ {\geq n} y \left(\phi_ {T} (x, y)\right)\right) \tag {14}
$$
Let  $\widehat{\varphi}_T(x) \coloneqq \exists^{\geq n}y(\phi_T(x,y))$ . Since  $\wedge, \vee$  are both allowed in  $\mathcal{R}\mathcal{S}\mathcal{F}\mathcal{O}\mathcal{C}_2$ . If we want to rewrite  $\varphi(x)$  in the  $\mathcal{R}\mathcal{S}\mathcal{F}\mathcal{O}\mathcal{C}_2$  form, it suffices to rewrite  $\widehat{\varphi}_T(x)$  as a  $\mathcal{R}\mathcal{S}\mathcal{F}\mathcal{O}\mathcal{C}_2$  formula, which is shown as follows,
$$
\widehat {\varphi} _ {T} (x) := \exists^ {\geq n} y \left(\phi_ {T} (x, y)\right) = \exists^ {\geq n} y \left(\bigvee_ {S \subseteq P _ {2}} \left(\varphi_ {S} (x, y) \wedge \varphi_ {S, T} ^ {y} (y)\right)\right) \tag {15}
$$
Similar to the previous argument, since for any graph  $G$  and of its node pairs  $(a,b)$ , the relation-specification formula  $\varphi_S(x,y)$  restricts exactly which types of relations exist between  $(a,b)$ , there is exactly one subset  $S \subseteq P_2$  such that  $\varphi_S(a,b)$  holds.
Therefore, for all  $S \subseteq P_2$ , we can define  $n_S$  as the number of nodes  $y$  such that  $\varphi_S(x,y) \wedge \varphi_{S,T}^y(y)$  holds. Since for two different subsets  $S_1, S_2 \subseteq P_2$  and a fixed  $y$ ,  $\varphi_{S_1}(x,y)$  and  $\varphi_{S_2}(x,y)$  can't hold simultaneously, the number of nodes  $y$  that satisfies  $\varphi_S(x,y) \wedge \varphi_{S,T}^y(y)$  is exactly the sum  $\sum_{S \subseteq P_2} n_S$ . Therefore, in order to express Equation (15), which means there exists at least  $n$  nodes  $y$  such that  $\bigvee_{S \subseteq P_2} \left( \varphi_S(x,y) \wedge \varphi_{S,T}^y(y) \right)$  holds, it suffices to enumerate all possible values for  $\{n_S | S \subseteq P_2\}$  that satisfies  $(\sum_{S \subseteq P_2} n_S) = n, n_S \in \mathbb{N}$ . Formally, we can rewrite  $\widehat{\varphi}_T(x)$  as follows:
$$
\widehat {\varphi} _ {T} (x) \equiv \bigvee_ {\left(\sum_ {S \subseteq P _ {2}} n _ {S}\right) = n} \left(\bigwedge_ {S \subseteq P _ {2}} \exists^ {\geq n _ {S}} y \left(\varphi_ {S} (x, y) \wedge \varphi_ {S, T} ^ {y} (y)\right)\right) \tag {16}
$$
Note that  $\exists^{\geq n_S}y(\varphi_S(x,y)\wedge \varphi_{S,T}^y (y))$  satisfies the grammar of  $\mathcal{RSFOC}_2$ , so  $\widehat{\varphi}_{T}(x)$  can be rewritten as  $\mathcal{RSFOC}_2$ . Then, since  $\varphi_T^x (x)$  can also be rewritten as  $\mathcal{RSFOC}_2$  by induction, combining Equation (14) and Equation (15),  $\varphi (x)$  is in  $\mathcal{RSFOC}_2$ . We finish the proof.
B Proof of Proposition 3
Proposition 3.  $\mathcal{FOC}_2\not\subseteq R^2\text{-GNN}$  and  $R^2\text{-GNN}\not\subseteq \mathcal{FOC}_2$  on some universal graph class  $\mathcal{G}_u$ .
Proof. First, we prove  $\mathcal{FOC}_2\not\subset\mathrm{R}^2$ -GNN.
Consider the two graphs  $G_{1}, G_{2}$  in Figure 1.  $(G_{1}, a), (G_{2}, a)$  can be distinguished by the  $\mathcal{FOC}_2$  formula  $\varphi(x) := \exists^{\geq 1} y(p_1(x, y) \wedge p_2(x, y))$ . However, we will prove that any  $\mathbb{R}^2$ -GNN can't distinguish any node in  $G_{1}$  from any node in  $G_{2}$ .
Let's prove it by induction over the layer number  $L$  of  $\mathbf{R}^2$ -GNN. That's to say, we want to show that for any  $L \geq 0$ ,  $\mathbf{R}^2$ -GNN with no more than  $L$  layers can't distinguish any node of  $G_1$  from that of  $G_2$ .
For the base case where  $L = 0$ , since each node feature vector is initialized by the unary predicate information, so the result trivially holds.
Assume any  $\mathbf{R}^2$ -GNN with no more than  $L = m$  layers can't distinguish nodes of  $G_{1}$  from nodes of  $G_{2}$ . Then we want to prove the result for  $L = m + 1$ .
For any  $\mathbf{R}^2$ -GNN model  $\mathcal{A}$  with  $m + 1$  layers, let  $\mathcal{A}'$  denote its first  $m$  layers, we know outputs of  $\mathcal{A}'$  on any node from  $G_{1}$  or  $G_{2}$  are the same, suppose the common output feature is  $\mathbf{x}^{(m)}$ .
Recall the updating rule of  $\mathbb{R}^2$ -GNN in Equation (2). We know the output of  $\mathcal{A}$  on any node  $v$  in  $G_{1}$  or  $G_{2}$  is defined as follows,
$$
\mathbf {x} _ {v} ^ {(m + 1)} = C ^ {(m + 1)} \left(\mathbf {x} _ {v} ^ {(m)}, \left(A _ {1} ^ {(m + 1)} \left(\{\{\mathbf {x} _ {u _ {1} (v)} ^ {(m)} \}\right)\right), A _ {2} ^ {(m + 1)} \left(\{\{\mathbf {x} _ {u _ {2} (v)} ^ {(m)} \}\right)\right), R ^ {(m + 1)} \left(\{\{\mathbf {x} _ {a} ^ {(m)}, \mathbf {x} _ {b} ^ {(m)}, \mathbf {x} _ {c} ^ {(m)}, \mathbf {x} _ {d} ^ {(m)} \}\right)\left. \right) \tag {17}
$$
Here  $C^{(m + 1)}, A_1^{(m + 1)}, A_2^{(m + 1)}, R^{(m + 1)}$  are parameters in the layer  $m + 1$  of  $\mathcal{A}$ ,  $u_1(v), u_2(v)$  is the only  $r_1, r_2$ -type neighbor of  $v$ , and  $a, b, c, d$  are nodes from the corresponding graph  $G_1$  or  $G_2$ . From Figure 1 we can see they are well defined.
By induction, since any node pairs from  $G_{1}$  and  $G_{2}$  can't be distinguished by  $\mathcal{A}'$ , we have  $\mathbf{x}_v^{(m)}, \mathbf{x}_{u_1(v)}^{(m)}, \mathbf{x}_{u_2(v)}^{(m)}, \mathbf{x}_a^{(m)}, \mathbf{x}_b^{(m)}, \mathbf{x}_c^{(m)}, \mathbf{x}_d^{(m)}$  are all the same feature  $\mathbf{x}^{(m)}$ . Therefore, Equation (17) has the same expression for all nodes  $v$  from  $G_{1}$  and  $G_{2}$ , which implies any  $\mathcal{A}$  with  $m + 1$  layers can't distinguish nodes from  $G_{1}$  and  $G_{2}$ .
Next, we then prove  $\mathbf{R}^2$ -GNNs  $\nsubseteq \mathcal{FOC}_2$ .
Assume we want to construct a classifier  $c$  which classifies a node into true iff the node has a larger number of  $r_1$ -type neighbors than that of  $r_2$ -type neighbors.
First, we prove that we can construct an  $0/1$ -GNN  $\mathcal{A}$  to capture  $c$ . It only has one layer with parameters  $C^{(1)}, A_1^{(1)}, A_2^{(1)}, R^{(1)}$ , and feature dimension  $d_0 = d_1 = 1$ . We assume that each node has the same initial feature vector, i.e., 1. We set  $A_{1,(1,1)}^{(1)} = 1, A_{2,(1,1)}^{(1)} = -1$ , where  $A_{1,(1,1)}^{(1)}$  denotes the only element in  $A_1^{(1)}$  placed in the first row and first column (similar for  $A_{2,(1,1)}^{(1)}$ ) and all other
Figure 5:  $G(n)$  and  $H(n)$ .
parameters 0. It's easy to see that  $\mathcal{A}$  is equivalent to our desired classifier  $c$  on any graph since we have  $\mathbf{x}_v^{(1)} = \max (0,\min (1,\sum_{u\in \mathcal{N}_{G,1}(v)}1 - \sum_{u\in \mathcal{N}_{G,2}(v)}1))$ .
Next, we show  $\mathcal{FOC}_2$  can't capture  $c$  on  $\mathcal{G}_s$ . In order to show that, for any natural number  $n$ , we can construct two single-edge graphs  $G(n), H(n)$  as follows:
$$
V (G (n)) = V (H (n)) = \{1, 2 \dots \dots . 4 n + 2 \}
$$
$$
E (G (n)) = \left\{r _ {1} (1, i) | \forall i \in [ 2, 2 n + 2 ] \right\} \cup \left\{r _ {2} (1, i) | i \in [ 2 n + 3, 4 n + 2 ] \right\}
$$
$$
E (H (n)) = \left\{r _ {1} (1, i) | \forall i \in [ 2, 2 n + 1 ] \right\} \cup \left\{r _ {2} (1, i) | i \in [ 2 n + 2, 4 n + 2 ] \right\}
$$
We prove the result by contradiction. Assume there is a  $\mathcal{FOC}_2$  classifier  $\varphi$  that captures the classifier  $c$ , then it has to classify  $(G(n),1)$  as true and  $(H(n),1)$  as false for all natural number  $n$ . However, in the following we will show that it's impossible, which proves the non-existence of such  $\varphi$ .
Suppose threshold numbers used on counting quantifiers of  $\varphi$  don't exceed  $m$ , then we only need to prove that  $\varphi$  can't distinguish  $(G(m),1),(H(m),1)$ , which contradicts our assumption.
For simplicity, we use  $G, H$  to denote  $G(m), H(m)$ . In order to prove the above argument. First, we define a node-classification function  $CLS(\cdot)$  as follows. It has  $G$  or  $H$  as subscript and a node of  $G$  or  $H$  as input.
1.  $CLS_{G}(1) = CLS_{H}(1) = 1$ . It means the function returns 1 when the input is the center of  $G$  or  $H$ .
2.  $CLS_{G}(v_{1}) = CLS_{H}(v_{2}) = 2, \forall v_{1} \in [2,2m + 2], \forall v_{2} \in [2,2m + 1]$ , which means the function returns 2 when the input is a  $r_1$ -neighbor of center.
3.  $CLS_{G}(v_{1}) = CLS_{H}(v_{2}) = 3, \forall v_{1} \in [2m + 3, 4m + 2], \forall v_{2} \in [2m + 2, 4m + 2]$ , which means the function returns 3 when the input is a  $r_2$ -neighbor of center.
Claim 1: Given any  $u_1, v_1 \in V(G), u_2, v_2 \in V(H)$ , if  $(CLS_G(u_1), CLS_G(v_1)) = (CLS_H(u_2), CLS_H(v_2))$ , then any  $\mathcal{FOC}_2$  formula with threshold numbers no larger than  $m$  can't distinguish  $(u_1, v_1)$  and  $(u_2, v_2)$ .
This claim is enough for our result. We will prove that for any constant  $d$  and any  $\mathcal{FOC}_2$  formula  $\phi$  with threshold numbers no larger than  $m$  and quantifier depth  $d$ ,  $\phi$  can't distinguish  $(u_1, v_1)$  and  $(u_2, v_2)$  given that  $(CLS_G(u_1), CLS_G(v_1)) = (CLS_H(u_2), CLS_H(v_2))$
The result trivially holds for the base case where  $d = 0$ . Now let's assume the result holds for  $d \leq k$ , we can now prove the inductive case when  $d = k + 1$ .
Since  $\wedge, \vee, \neg, r(x,y)$  trivially follows, we can only consider the case when  $\phi(x,y)$  is in the form  $\exists^{\geq N}y\phi'(x,y), N \leq m$  or  $\exists^{\geq N}x\phi'(x,y), N \leq m$ , where  $\phi'(x,y)$  is a  $\mathcal{FOC}_2$  formula with threshold
numbers no more than  $m$  and quantifier depth no more than  $k$ . Since these two forms are symmetrical, without loss of generality, we only consider the case  $\exists^{\geq N}y\phi '(x,y),N\leq m$